- struct message *message;
- struct dialing_info dialinginfo;
- int i,j, ii;
- struct port_list *portlist = ea_endpoint->ep_portlist;
- char *dial;
- char address_buffer[256], *address=address_buffer;
- char host[128] = "";
- int ip_a=0, ip_b=0, ip_c=0, ip_d=0, port=0;
- struct route_param *rparam;
- char helpbuffer[128];
-
- /* check if address parameter is given */
- if ((rparam = routeparam(e_action, PARAM_ADDRESS)))
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): complete address is given by parameter: '%s'\n", ea_endpoint->ep_serial, rparam->string_value);
- SCPY(address_buffer, rparam->string_value);
- goto address_complete;
- }
-
- /* check for given host */
- if ((rparam = routeparam(e_action, PARAM_HOST)))
- if (rparam->string_value[0])
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): host is given by parameter: '%s'\n", ea_endpoint->ep_serial, rparam->string_value);
- SCPY(host, rparam->string_value);
- if ((rparam = routeparam(e_action, PARAM_PORT)))
- {
- if (rparam->integer_value>0 && rparam->integer_value<65536)
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): port is given with the host by parameter: %d\n", ea_endpoint->ep_serial, rparam->integer_value);
- if (strlen(host)+7 < sizeof(host))
- UPRINT(host, ":%d/", rparam->integer_value);
- } else
- {
- SCAT(host, "/");
- }
- } else
- {
- SCAT(host, "/");
- }
- }
-
- /* include prefix and put 'host'(port) in front */
- if ((rparam = routeparam(e_action, PARAM_PREFIX)))
- {
- SPRINT(address_buffer, "%s%s%s", host, rparam->string_value, e_extdialing);
- } else
- {
- if (host[0])
- {
- SPRINT(address_buffer, "%s%s", host, e_extdialing);
- printf("address:%s host %s extdialing %s\n",address,host, e_extdialing);
- } else {
- address = e_extdialing;
- }
- }
- dial = address;
-
- /* check dialing */
- /* check for ip-number only with numerical digits (can be dialed by any phone) */
- if (host[0])
- {
- dial = address + strlen(host);
- goto check_user; /* we have complete host (port) */
- }
- i = 0;
- while(i < 12)
- {
- if (dial[i] == '\0')
- return; /* unfinished */
- if (dial[i]<'0' || dial[i]>'9')
- goto check_complex;
- i++;
-
- if (i == 3)
- {
- ip_a = (dial[0]-'0')*100 + (dial[1]-'0')*10 + (dial[2]-'0');
- if (ip_a > 255)
- {
- invalid:
- printlog("%3d action H323 address '%s' is invalid.\n", ea_endpoint->ep_serial, address);
- message_disconnect_port(portlist, CAUSE_INVALID, LOCATION_PRIVATE_LOCAL, "");
- new_state(EPOINT_STATE_OUT_DISCONNECT);
- set_tone(portlist,"cause_1c");
- return;
- }
- }
- if (i == 6)
- {
- ip_b = (dial[3]-'0')*100 + (dial[4]-'0')*10 + (dial[5]-'0');
- if (ip_b > 255)
- goto invalid;
- }
- if (i == 9)
- {
- ip_c = (dial[6]-'0')*100 + (dial[7]-'0')*10 + (dial[8]-'0');
- if (ip_c > 255)
- goto invalid;
- }
- if (i == 12)
- {
- ip_d = (dial[9]-'0')*100 + (dial[10]-'0')*10 + (dial[11]-'0');
- if (ip_d > 255)
- goto invalid;
- }
- if (i==4 || i==7 || i==10)
- {
- if (dial[i-1] > '2')
- goto invalid;
- }
- if (i==5 || i==8 || i==11)
- {
- if (dial[i-2]=='2' && dial[i-1]>'5')
- goto invalid;
- }
- }
- UPRINT(address, "%d.%d.%d.%d", ip_a, ip_b, ip_c, ip_d);
- i = strlen(address);
- goto address_complete;
-
- /* there are three stages of dialing: 1. ip, 2. port, 3. user, let's find out where we at */
- check_complex:
- if (strchr(address, '@'))
- {
- dial = strchr(address, '\0');
- goto address_complete;
- }
- if (strchr(address, ':'))
- {
- dial = strchr(address, ':') + 1;
- goto check_port;
- }
- if (strchr(address, '/'))
- {
- dial = strchr(address, '/') + 1;
- goto check_user;
- }