? gw/kannel.conf Index: gw/msg-decl.h =================================================================== RCS file: /home/cvs/gateway/gw/msg-decl.h,v retrieving revision 1.31 diff -r1.31 msg-decl.h 108a109 > INTEGER(submitmulti); Index: gw/smsbox.c =================================================================== RCS file: /home/cvs/gateway/gw/smsbox.c,v retrieving revision 1.260 diff -r1.260 smsbox.c 381d380 < 505c504 < int *rpi, Octstr **binfo, int *priority) --- > int *rpi, Octstr **binfo, int *priority, int *submitmulti) 594a594,596 > else if (octstr_case_compare(name, octstr_imm("X-Kannel-Submit-Multi")) == 0) { > sscanf(octstr_get_cstr(val),"%d", submitmulti); > } 651c653 < Octstr **binfo, int *priority) --- > Octstr **binfo, int *priority, int *submitmulti) 825c827,834 < --- > /*Submit-Multi*/ > get_tag(*body, octstr_imm("submitmulti"), &tmp, 0, 0); > if(tmp) { > if(octstr_parse_long(&tmplong, tmp, 0, 10) != -1) > *submitmulti = tmplong; > O_DESTROY(tmp); > } > 865c874 < Octstr *charset, Octstr *binfo, int priority) --- > Octstr *charset, Octstr *binfo, int priority, int submitmulti) 1022a1032,1038 > if (submitmulti != SMS_PARAM_UNDEFINED) { > if (urltrans_accept_x_kannel_headers(trans)) > msg->sms.submitmulti = submitmulti; > else > warning(0, "Tried to change submitmulti to '%d', denied.", submitmulti); > } > 1100c1116 < int validity, deferred, priority; --- > int validity, deferred, priority, submitmulti; 1118c1134 < = validity = deferred = priority = SMS_PARAM_UNDEFINED; --- > = validity = deferred = priority = submitmulti = SMS_PARAM_UNDEFINED; 1136c1152 < &binfo, &priority); --- > &binfo, &priority, &submitmulti); 1146c1162 < &binfo, &priority); --- > &binfo, &priority,&submitmulti); 1155c1171 < &binfo, &priority); --- > &binfo, &priority, &submitmulti); 1166c1182 < &binfo, &priority); --- > &binfo, &priority, &submitmulti); 1186c1202 < binfo, priority); --- > binfo, priority, submitmulti); 1968c1984 < List *receiver, Octstr *binfo, int priority) --- > List *receiver, Octstr *binfo, int priority, int submitmulti) 1971c1987 < Octstr *newfrom, *returnerror, *receiv; --- > Octstr *newfrom, *returnerror, *receiv, *allowedtomulti; 2262a2279,2283 > if (submitmulti != SMS_PARAM_UNDEFINED && (submitmulti < 0 || submitmulti > 1)) { > returnerror = octstr_create("submitmulti field misformed, rejected"); > goto fielderror; > } > msg->sms.submitmulti = submitmulti; 2294,2314c2315,2357 < < while ((receiv = gwlist_extract_first(allowed)) != NULL) { < < O_DESTROY(msg->sms.receiver); < msg->sms.receiver = octstr_duplicate(receiv); < < msg->sms.time = time(NULL); < /* send the message and return number of splits */ < ret = send_message(t, msg); < < if (ret == -1) { < /* add the receiver to the failed list */ < gwlist_append(failed_id, receiv); < } else { < /* log the sending as successful for this particular message */ < alog("send-SMS request added - sender:%s:%s %s target:%s request: '%s'", < octstr_get_cstr(urltrans_username(t)), < octstr_get_cstr(newfrom), octstr_get_cstr(client_ip), < octstr_get_cstr(receiv), < udh == NULL ? ( text == NULL ? "" : octstr_get_cstr(text) ) : "<< UDH >>"); < } --- > /* Switch between Submit_multi and Submit_sm as specified in the message submission. > * If its a multi, send the list to bearerbox otherwise loop over the list and multi-submit_sm > * Hence we choose between a single submit_multi or Multiple submit_sms > * Undefined=-1 or 0 we go for submit_sm otherwise .... > */ > > switch (msg->sms.submitmulti){ > case 0: > case SMS_PARAM_UNDEFINED: > while ((receiv = gwlist_extract_first(allowed)) != NULL) { > > O_DESTROY(msg->sms.receiver); > msg->sms.receiver = octstr_duplicate(receiv); > > msg->sms.time = time(NULL); > /* send the message and return number of splits */ > ret = send_message(t, msg); > > if (ret == -1) { > /* add the receiver to the failed list */ > gwlist_append(failed_id, receiv); > } else { > /* log the sending as successful for this particular message */ > alog("send-SMS request added - sender:%s:%s %s target:%s request: '%s'", > octstr_get_cstr(urltrans_username(t)), > octstr_get_cstr(newfrom), octstr_get_cstr(client_ip), > octstr_get_cstr(receiv), > udh == NULL ? ( text == NULL ? "" : octstr_get_cstr(text) ) : "<< UDH >>"); > } > } > break; > case 1: > /*List creation*/ > allowedtomulti=octstr_create(""); > msg->sms.time = time(NULL); > /*Space separate em*/ > while ((receiv = gwlist_extract_first(allowed)) != NULL) { > octstr_append(allowedtomulti, receiv); > octstr_append(allowedtomulti, octstr_imm(" ")); > } > msg->sms.receiver = octstr_duplicate(allowedtomulti); > ret = send_message(t, msg); > break; 2480c2523 < int alt_dcs, rpi, priority; --- > int alt_dcs, rpi, priority, submitmulti; 2484c2527 < pid = alt_dcs = rpi = priority = SMS_PARAM_UNDEFINED; --- > pid = alt_dcs = rpi = priority = submitmulti = SMS_PARAM_UNDEFINED; 2554a2598,2602 > > tmp_string = http_cgi_variable(args, "submitmulti"); > if(tmp_string != NULL) > sscanf(octstr_get_cstr(tmp_string),"%d", &submitmulti); > 2574c2622 < pid, alt_dcs, rpi, NULL, binfo, priority); --- > pid, alt_dcs, rpi, NULL, binfo, priority, submitmulti); 2594c2642 < int pid, alt_dcs, rpi, priority; --- > int pid, alt_dcs, rpi, priority, submitmulti; 2606c2654 < pid = alt_dcs = rpi = priority = SMS_PARAM_UNDEFINED; --- > pid = alt_dcs = rpi = priority = submitmulti = SMS_PARAM_UNDEFINED; 2620c2668 < &binfo, &priority); --- > &binfo, &priority,&submitmulti); 2628c2676 < &binfo, &priority); --- > &binfo, &priority, submitmulti); 2634c2682 < &rpi, &tolist, &charset, &binfo, &priority); --- > &rpi, &tolist, &charset, &binfo, &priority,&submitmulti); 2685c2733 < binfo, priority); --- > binfo, priority,submitmulti); Index: gw/smsc/smsc_smpp.c =================================================================== RCS file: /home/cvs/gateway/gw/smsc/smsc_smpp.c,v retrieving revision 1.87 diff -r1.87 smsc_smpp.c 731,753c731,1196 < < pdu = smpp_pdu_create(submit_sm, < counter_increase(smpp->message_id_counter)); < < pdu->u.submit_sm.source_addr = octstr_duplicate(msg->sms.sender); < pdu->u.submit_sm.destination_addr = octstr_duplicate(msg->sms.receiver); < < /* Set the service type of the outgoing message. We'll use the config < * directive as default and 'binfo' as specific parameter. */ < pdu->u.submit_sm.service_type = octstr_len(msg->sms.binfo) ? < octstr_duplicate(msg->sms.binfo) : octstr_duplicate(smpp->service_type); < < /* Check for manual override of source ton and npi values */ < if(smpp->source_addr_ton > -1 && smpp->source_addr_npi > -1) { < pdu->u.submit_sm.source_addr_ton = smpp->source_addr_ton; < pdu->u.submit_sm.source_addr_npi = smpp->source_addr_npi; < debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced source addr ton = %d, source add npi = %d", < octstr_get_cstr(smpp->conn->id), smpp->source_addr_ton, < smpp->source_addr_npi); < } else { < /* setup default values */ < pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */ < pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */ --- > Octstr *holder, *recipient; > List *recipients; > int no_recpts,ton,npi; > /*Submit_sm is explicitly set or defaulted to*/ > switch(msg->sms.submitmulti){ > case 0: > case SMS_PARAM_UNDEFINED: > pdu = smpp_pdu_create(submit_sm, > counter_increase(smpp->message_id_counter)); > > pdu->u.submit_sm.source_addr = octstr_duplicate(msg->sms.sender); > pdu->u.submit_sm.destination_addr = octstr_duplicate(msg->sms.receiver); > > /* Set the service type of the outgoing message. We'll use the config > * directive as default and 'binfo' as specific parameter. */ > pdu->u.submit_sm.service_type = octstr_len(msg->sms.binfo) ? > octstr_duplicate(msg->sms.binfo) : octstr_duplicate(smpp->service_type); > > /* Check for manual override of source ton and npi values */ > if(smpp->source_addr_ton > -1 && smpp->source_addr_npi > -1) { > pdu->u.submit_sm.source_addr_ton = smpp->source_addr_ton; > pdu->u.submit_sm.source_addr_npi = smpp->source_addr_npi; > debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced source addr ton = %d, source add npi = %d", > octstr_get_cstr(smpp->conn->id), smpp->source_addr_ton, > smpp->source_addr_npi); > } else { > /* setup default values */ > pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */ > pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */ > } > > if (smpp->autodetect_addr) { > /* lets see if its international or alphanumeric sender */ > if (octstr_get_char(pdu->u.submit_sm.source_addr, 0) == '+') { > if (!octstr_check_range(pdu->u.submit_sm.source_addr, 1, 256, gw_isdigit)) { > pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; /* alphanum */ > pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN; /* short code */ > if (smpp->alt_addr_charset) { > if (octstr_str_case_compare(smpp->alt_addr_charset, "gsm") == 0) { > /* @ would break PDU if converted into GSM*/ > octstr_replace(pdu->u.submit_sm.source_addr, octstr_imm("@"), octstr_imm("?")); > charset_latin1_to_gsm(pdu->u.submit_sm.source_addr); > } else if (charset_convert(pdu->u.submit_sm.source_addr, SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)) != 0) > error(0, "Failed to convert source_addr from charset <%s> to <%s>, will send as is.", > SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)); > } > } else { > /* numeric sender address with + in front -> international (remove the +) */ > octstr_delete(pdu->u.submit_sm.source_addr, 0, 1); > pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_INTERNATIONAL; > } > } else { > if (!octstr_check_range(pdu->u.submit_sm.source_addr,0, 256, gw_isdigit)) { > pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; > pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN; > if (smpp->alt_addr_charset) { > if (octstr_str_case_compare(smpp->alt_addr_charset, "gsm") == 0) { > /* @ would break PDU if converted into GSM */ > octstr_replace(pdu->u.submit_sm.source_addr, octstr_imm("@"), octstr_imm("?")); > charset_latin1_to_gsm(pdu->u.submit_sm.source_addr); > } else if (charset_convert(pdu->u.submit_sm.source_addr, SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)) != 0) > error(0, "Failed to convert source_addr from charset <%s> to <%s>, will send as is.", > SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)); > } > } > } > } > > /* Check for manual override of destination ton and npi values */ > if (smpp->dest_addr_ton > -1 && smpp->dest_addr_npi > -1) { > pdu->u.submit_sm.dest_addr_ton = smpp->dest_addr_ton; > pdu->u.submit_sm.dest_addr_npi = smpp->dest_addr_npi; > debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced dest addr ton = %d, dest add npi = %d", > octstr_get_cstr(smpp->conn->id), smpp->dest_addr_ton, > smpp->dest_addr_npi); > } else { > pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */ > pdu->u.submit_sm.dest_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */ > } > > /* > * if its a international number starting with +, lets remove the > * '+' and set number type to international instead > */ > if (octstr_get_char(pdu->u.submit_sm.destination_addr,0) == '+') { > octstr_delete(pdu->u.submit_sm.destination_addr, 0,1); > pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_INTERNATIONAL; > } > > /* check length of src/dst address */ > if (octstr_len(pdu->u.submit_sm.destination_addr) > 20 || > octstr_len(pdu->u.submit_sm.source_addr) > 20) { > smpp_pdu_destroy(pdu); > return NULL; > } > > /* > * set the data coding scheme (DCS) field > * check if we have a forced value for this from the smsc-group. > * Note: if message class is set, then we _must_ force alt_dcs otherwise > * dcs has reserved values (e.g. mclass=2, dcs=0x11). We check MWI flag > * first here, because MWI and MCLASS can not be set at the same time and > * function fields_to_dcs check MWI first, so we have no need to force alt_dcs > * if MWI is set. > */ > if (msg->sms.mwi == MWI_UNDEF && msg->sms.mclass != MC_UNDEF) > pdu->u.submit_sm.data_coding = fields_to_dcs(msg, 1); /* force alt_dcs */ > else > pdu->u.submit_sm.data_coding = fields_to_dcs(msg, > (msg->sms.alt_dcs != SMS_PARAM_UNDEFINED ? > msg->sms.alt_dcs : smpp->conn->alt_dcs)); > > /* set protocol id */ > if(msg->sms.pid != SMS_PARAM_UNDEFINED) > pdu->u.submit_sm.protocol_id = msg->sms.pid; > > /* > * set the esm_class field > * default is store and forward, plus udh and rpi if requested > */ > pdu->u.submit_sm.esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE; > if (octstr_len(msg->sms.udhdata)) > pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class | > ESM_CLASS_SUBMIT_UDH_INDICATOR; > if (msg->sms.rpi > 0) > pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class | > ESM_CLASS_SUBMIT_RPI; > > /* > * set data segments and length > */ > > pdu->u.submit_sm.short_message = octstr_duplicate(msg->sms.msgdata); > > /* > * only re-encoding if using default smsc charset that is defined via > * alt-charset in smsc group and if MT is not binary > */ > if (msg->sms.coding == DC_7BIT || (msg->sms.coding == DC_UNDEF && octstr_len(msg->sms.udhdata))) { > /* > * consider 3 cases: > * a) data_coding 0xFX: encoding should always be GSM 03.38 charset > * b) data_coding 0x00: encoding may be converted according to alt-charset > * c) data_coding 0x00: assume GSM 03.38 charset if alt-charset is not defined > */ > if ((pdu->u.submit_sm.data_coding & 0xF0) || > (!smpp->alt_charset && pdu->u.submit_sm.data_coding == 0)) { > charset_latin1_to_gsm(pdu->u.submit_sm.short_message); > } > else if (pdu->u.submit_sm.data_coding == 0 && smpp->alt_charset) { > /* > * convert to the given alternative charset > */ > if (charset_convert(pdu->u.submit_sm.short_message, "ISO-8859-1", > octstr_get_cstr(smpp->alt_charset)) != 0) > error(0, "Failed to convert msgdata from charset <%s> to <%s>, will send as is.", > "ISO-8859-1", octstr_get_cstr(smpp->alt_charset)); > } > } > > /* prepend udh if present */ > if (octstr_len(msg->sms.udhdata)) { > octstr_insert(pdu->u.submit_sm.short_message, msg->sms.udhdata, 0); > } > > pdu->u.submit_sm.sm_length = octstr_len(pdu->u.submit_sm.short_message); > > /* > * check for validity and defered settings > * were message value has higher priiority then smsc config group value > */ > validity = msg->sms.validity >= 0 ? msg->sms.validity : smpp->validityperiod; > if (validity >= 0) { > struct tm tm = gw_gmtime(time(NULL) + validity * 60); > pdu->u.submit_sm.validity_period = octstr_format("%02d%02d%02d%02d%02d%02d000+", > tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, > tm.tm_hour, tm.tm_min, tm.tm_sec); > } > > if (msg->sms.deferred >= 0) { > struct tm tm = gw_gmtime(time(NULL) + msg->sms.deferred * 60); > pdu->u.submit_sm.schedule_delivery_time = octstr_format("%02d%02d%02d%02d%02d%02d000+", > tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, > tm.tm_hour, tm.tm_min, tm.tm_sec); > } > > /* ask for the delivery reports if needed */ > if (DLR_IS_SUCCESS_OR_FAIL(msg->sms.dlr_mask)) > pdu->u.submit_sm.registered_delivery = 1; > else if (DLR_IS_FAIL(msg->sms.dlr_mask) && !DLR_IS_SUCCESS(msg->sms.dlr_mask)) > pdu->u.submit_sm.registered_delivery = 2; > > /* set priority */ > if (msg->sms.priority >= 0 && msg->sms.priority <= 3) > pdu->u.submit_sm.priority_flag = msg->sms.priority; > else > pdu->u.submit_sm.priority_flag = smpp->priority; > > /* set more messages to send */ > if (smpp->version > 0x33 && msg->sms.msg_left > 0) > pdu->u.submit_sm.more_messages_to_send = 1; > break; > case 1: > pdu = smpp_pdu_create(submit_multi, > counter_increase(smpp->message_id_counter)); > > pdu->u.submit_multi.source_addr = octstr_duplicate(msg->sms.sender); > > pdu->u.submit_multi.service_type = octstr_len(msg->sms.binfo) ? > octstr_duplicate(msg->sms.binfo) : octstr_duplicate(smpp->service_type); > > /* Validate source address*/ > if (octstr_len(pdu->u.submit_multi.source_addr) > 20) { > smpp_pdu_destroy(pdu); > return NULL; > } > debug("bb.sms.smpp", 0,"*************Number of list entries are %s*************\n",octstr_get_cstr(msg->sms.receiver)); > recipients = octstr_split_words(msg->sms.receiver); > no_recpts=gwlist_len(recipients); > debug("bb.sms.smpp", 0,"Sending to %d recipients. Will construct multiple submit_multi if count recipients (%d)>254",no_recpts,no_recpts); > holder= octstr_create(""); > /*Iterate over rcpt items. Guess/assign defaults for dest_flag, ton and npi in that order*/ > while ((recipient = gwlist_extract_first(recipients)) != NULL) { > /* check length of src/dst address */ > /*Should we terminate sending or just skip the rcpt?*/ > if (octstr_len(recipient) > 20) { > smpp_pdu_destroy(pdu); > return NULL; > } > /* Ok looks good. */ > > octstr_append_from_hex(holder,"01"); //dest_flag > > > /* Check for manual override of destination ton and npi values */ > if (smpp->dest_addr_ton > -1 && smpp->dest_addr_npi > -1) { > ton = smpp->dest_addr_ton; > npi = smpp->dest_addr_npi; > debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced dest addr ton = %d, dest add npi = %d", > octstr_get_cstr(smpp->conn->id), smpp->dest_addr_ton, > smpp->dest_addr_npi); > } else if (octstr_get_char(recipient,0) == '+') { > /* > * if its a international number starting with +, lets remove the > * '+' and set number type to international instead > */ > octstr_delete(recipient, 0,1); > ton = GSM_ADDR_TON_INTERNATIONAL; > > }else{ > ton = 2; /* national */ > npi = 1; /* ISDN number plan */ > } > > switch(ton){ > case 0: //( 0 || GSM_ADDR_TON_UNKNOWN ): unknown > octstr_append_from_hex(holder,"00"); //ton > break; > case 1: // ( 1 || GSM_ADDR_TON_INTERNATIONAL ): International > octstr_append_from_hex(holder,"01"); //ton > break; > case 2: //( 2 || GSM_ADDR_TON_NATIONAL ): national > octstr_append_from_hex(holder,"02"); //ton > break; > case 3: //( 3 || GSM_ADDR_TON_NETWORKSPECIFIC ): network specific > octstr_append_from_hex(holder,"03"); //ton > break; > case 4: //( 4 || GSM_ADDR_TON_SUBSCRIBER ): subscriber > octstr_append_from_hex(holder,"04"); //ton > break; > case 5: //( 5 || GSM_ADDR_TON_ALPHANUMERIC ): alphanumeric > octstr_append_from_hex(holder,"05"); //ton > break; > case 6: //( 6 || GSM_ADDR_TON_ABBREVIATED ): abbreviated > octstr_append_from_hex(holder,"06"); //ton > break; > case 7: //( 7 || GSM_ADDR_TON_EXTENSION ): reserved > octstr_append_from_hex(holder,"07"); //ton > break; > default: > octstr_append_from_hex(holder,"02"); //ton > } > switch(npi){ > case 0: //( 0 || GSM_ADDR_NPI_UNKNOWN ): unknown > octstr_append_from_hex(holder,"00"); //npi > break; > case 1: //( 1 || GSM_ADDR_NPI_E164 ): E164 > octstr_append_from_hex(holder,"01"); //npi > break; > case 3: //( 3 || GSM_ADDR_NPI_X121 ): X121 > octstr_append_from_hex(holder,"03"); //npi > break; > case 4: //( 4 || GSM_ADDR_NPI_TELEX ): telex > octstr_append_from_hex(holder,"04"); //npi > break; > case 8: //( 8 || GSM_ADDR_NPI_NATIONAL ): national > octstr_append_from_hex(holder,"08"); //npi > break; > case 9: //( 9 || GSM_ADDR_NPI_PRIVATE ): private > octstr_append_from_hex(holder,"09"); //npi > break; > case 10: //( 10 || GSM_ADDR_NPI_ERMES ): Ermes > octstr_append_from_hex(holder,"0A"); //npi > break; > case 15: //( 15 || GSM_ADDR_NPI_EXTENSION ): reserved > octstr_append_from_hex(holder,"0F"); //npi > break; > default: > octstr_append_from_hex(holder,"01"); //npi > } > /*Append a recipient*/ > octstr_append(holder,recipient); //number > /*Add a null delimiter (Null term string...)*/ > octstr_append_from_hex(holder,"00"); //nul delimiter > } > /*Remove extra null bcoz pdu assembler(pack) will append null */ > octstr_truncate(holder, (octstr_len(holder)-1)); > /* copy to pdu */ > pdu->u.submit_multi.dest_address_es = octstr_duplicate(holder); > pdu->u.submit_multi.number_of_dests=no_recpts; > /* Set the service type of the outgoing message. We'll use the config > * directive as default and 'binfo' as specific parameter. */ > //pdu->u.submit_multi.service_type = octstr_len(msg->sms.binfo) ? > // octstr_duplicate(msg->sms.binfo) : octstr_duplicate(smpp->service_type); > > /* Check for manual override of source ton and npi values */ > if(smpp->source_addr_ton > -1 && smpp->source_addr_npi > -1) { > pdu->u.submit_multi.source_addr_ton = smpp->source_addr_ton; > pdu->u.submit_multi.source_addr_npi = smpp->source_addr_npi; > debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced source addr ton = %d, source add npi = %d", > octstr_get_cstr(smpp->conn->id), smpp->source_addr_ton, > smpp->source_addr_npi); > } else { > /* setup default values */ > pdu->u.submit_multi.source_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */ > pdu->u.submit_multi.source_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */ > } > > if (smpp->autodetect_addr) { > /* lets see if its international or alphanumeric sender */ > if (octstr_get_char(pdu->u.submit_multi.source_addr, 0) == '+') { > if (!octstr_check_range(pdu->u.submit_multi.source_addr, 1, 256, gw_isdigit)) { > pdu->u.submit_multi.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; /* alphanum */ > pdu->u.submit_multi.source_addr_npi = GSM_ADDR_NPI_UNKNOWN; /* short code */ > } else { > /* numeric sender address with + in front -> international (remove the +) */ > octstr_delete(pdu->u.submit_multi.source_addr, 0, 1); > pdu->u.submit_multi.source_addr_ton = GSM_ADDR_TON_INTERNATIONAL; > } > } else { > if (!octstr_check_range(pdu->u.submit_multi.source_addr,0, 256, gw_isdigit)) { > pdu->u.submit_multi.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; > pdu->u.submit_multi.source_addr_npi = GSM_ADDR_NPI_UNKNOWN; > } > } > } > > > /* > * set the data coding scheme (DCS) field > * check if we have a forced value for this from the smsc-group. > * Note: if message class is set, then we _must_ force alt_dcs otherwise > * dcs has reserved values (e.g. mclass=2, dcs=0x11). We check MWI flag > * first here, because MWI and MCLASS can not be set at the same time and > * function fields_to_dcs check MWI first, so we have no need to force alt_dcs > * if MWI is set. > */ > if (msg->sms.mwi == MWI_UNDEF && msg->sms.mclass != MC_UNDEF) > pdu->u.submit_multi.data_coding = fields_to_dcs(msg, 1); /* force alt_dcs */ > else > pdu->u.submit_multi.data_coding = fields_to_dcs(msg, > (msg->sms.alt_dcs != SMS_PARAM_UNDEFINED ? > msg->sms.alt_dcs : smpp->conn->alt_dcs)); > > /* set protocol id */ > if(msg->sms.pid != SMS_PARAM_UNDEFINED) > pdu->u.submit_multi.protocol_id = msg->sms.pid; > > /* > * set the esm_class field > * default is store and forward, plus udh and rpi if requested > */ > pdu->u.submit_multi.esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE; > if (octstr_len(msg->sms.udhdata)) > pdu->u.submit_multi.esm_class = pdu->u.submit_multi.esm_class | > ESM_CLASS_SUBMIT_UDH_INDICATOR; > if (msg->sms.rpi > 0) > pdu->u.submit_multi.esm_class = pdu->u.submit_multi.esm_class | > ESM_CLASS_SUBMIT_RPI; > > /* > * set data segments and length > */ > > pdu->u.submit_multi.short_message = octstr_duplicate(msg->sms.msgdata); > > /* > * only re-encoding if using default smsc charset that is defined via > * alt-charset in smsc group and if MT is not binary > */ > if (msg->sms.coding == DC_7BIT || (msg->sms.coding == DC_UNDEF && octstr_len(msg->sms.udhdata))) { > /* > * consider 3 cases: > * a) data_coding 0xFX: encoding should always be GSM 03.38 charset > * b) data_coding 0x00: encoding may be converted according to alt-charset > * c) data_coding 0x00: assume GSM 03.38 charset if alt-charset is not defined > */ > if ((pdu->u.submit_multi.data_coding & 0xF0) || > (!smpp->alt_charset && pdu->u.submit_multi.data_coding == 0)) { > charset_latin1_to_gsm(pdu->u.submit_multi.short_message); > } > else if (pdu->u.submit_multi.data_coding == 0 && smpp->alt_charset) { > /* > * convert to the given alternative charset > */ > if (charset_convert(pdu->u.submit_multi.short_message, "ISO-8859-1", > octstr_get_cstr(smpp->alt_charset)) != 0) > error(0, "Failed to convert msgdata from charset <%s> to <%s>, will send as is.", > "ISO-8859-1", octstr_get_cstr(smpp->alt_charset)); > } > } > > /* prepend udh if present */ > if (octstr_len(msg->sms.udhdata)) { > octstr_insert(pdu->u.submit_multi.short_message, msg->sms.udhdata, 0); > } > > pdu->u.submit_multi.sm_length = octstr_len(pdu->u.submit_multi.short_message); > > /* > * check for validity and defered settings > * were message value has higher priiority then smsc config group value > */ > validity = msg->sms.validity >= 0 ? msg->sms.validity : smpp->validityperiod; > if (validity >= 0) { > struct tm tm = gw_gmtime(time(NULL) + validity * 60); > pdu->u.submit_multi.validity_period = octstr_format("%02d%02d%02d%02d%02d%02d000+", > tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, > tm.tm_hour, tm.tm_min, tm.tm_sec); > } > > if (msg->sms.deferred >= 0) { > struct tm tm = gw_gmtime(time(NULL) + msg->sms.deferred * 60); > pdu->u.submit_multi.schedule_delivery_time = octstr_format("%02d%02d%02d%02d%02d%02d000+", > tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, > tm.tm_hour, tm.tm_min, tm.tm_sec); > } > > /* ask for the delivery reports if needed */ > if (DLR_IS_SUCCESS_OR_FAIL(msg->sms.dlr_mask)) > pdu->u.submit_multi.registered_delivery = 1; > else if (DLR_IS_FAIL(msg->sms.dlr_mask) && !DLR_IS_SUCCESS(msg->sms.dlr_mask)) > pdu->u.submit_multi.registered_delivery = 2; > > /* set priority */ > if (msg->sms.priority >= 0 && msg->sms.priority <= 3) > pdu->u.submit_multi.priority_flag = msg->sms.priority; > else > pdu->u.submit_multi.priority_flag = smpp->priority; > > /* set more messages to send */ > //if (smpp->version > 0x33 && msg->sms.msg_left > 0) > // pdu->u.submit_multi.more_messages_to_send = 1; > debug("bb.sms.smpp", 0,"svc-type %d:: rcpts %d::ston %d::snpi %d::Dcoding %d::PID %d::ESM %d::Len %d::Validity %d::Defer %d:: priority %d:: DLR(REGistered) %d::\n", pdu->u.submit_multi.service_type, no_recpts, pdu->u.submit_multi.source_addr_ton, pdu->u.submit_multi.source_addr_npi, pdu->u.submit_multi.data_coding, pdu->u.submit_multi.protocol_id, pdu->u.submit_multi.esm_class, pdu->u.submit_multi.sm_length, validity, validity, msg->sms.deferred, pdu->u.submit_multi.priority_flag, pdu->u.submit_multi.registered_delivery ); > debug("bb.sms.smpp", 0,"++++++++++++++++++++++bb.sms.smpp SUBMIT_MULTI AS %d+++++++++++++++\n",msg->sms.submitmulti); > break; 755,926d1197 < < if (smpp->autodetect_addr) { < /* lets see if its international or alphanumeric sender */ < if (octstr_get_char(pdu->u.submit_sm.source_addr, 0) == '+') { < if (!octstr_check_range(pdu->u.submit_sm.source_addr, 1, 256, gw_isdigit)) { < pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; /* alphanum */ < pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN; /* short code */ < if (smpp->alt_addr_charset) { < if (octstr_str_case_compare(smpp->alt_addr_charset, "gsm") == 0) { < /* @ would break PDU if converted into GSM*/ < octstr_replace(pdu->u.submit_sm.source_addr, octstr_imm("@"), octstr_imm("?")); < charset_latin1_to_gsm(pdu->u.submit_sm.source_addr); < } else if (charset_convert(pdu->u.submit_sm.source_addr, SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)) != 0) < error(0, "Failed to convert source_addr from charset <%s> to <%s>, will send as is.", < SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)); < } < } else { < /* numeric sender address with + in front -> international (remove the +) */ < octstr_delete(pdu->u.submit_sm.source_addr, 0, 1); < pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_INTERNATIONAL; < } < } else { < if (!octstr_check_range(pdu->u.submit_sm.source_addr,0, 256, gw_isdigit)) { < pdu->u.submit_sm.source_addr_ton = GSM_ADDR_TON_ALPHANUMERIC; < pdu->u.submit_sm.source_addr_npi = GSM_ADDR_NPI_UNKNOWN; < if (smpp->alt_addr_charset) { < if (octstr_str_case_compare(smpp->alt_addr_charset, "gsm") == 0) { < /* @ would break PDU if converted into GSM */ < octstr_replace(pdu->u.submit_sm.source_addr, octstr_imm("@"), octstr_imm("?")); < charset_latin1_to_gsm(pdu->u.submit_sm.source_addr); < } else if (charset_convert(pdu->u.submit_sm.source_addr, SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)) != 0) < error(0, "Failed to convert source_addr from charset <%s> to <%s>, will send as is.", < SMPP_DEFAULT_CHARSET, octstr_get_cstr(smpp->alt_addr_charset)); < } < } < } < } < < /* Check for manual override of destination ton and npi values */ < if (smpp->dest_addr_ton > -1 && smpp->dest_addr_npi > -1) { < pdu->u.submit_sm.dest_addr_ton = smpp->dest_addr_ton; < pdu->u.submit_sm.dest_addr_npi = smpp->dest_addr_npi; < debug("bb.sms.smpp", 0, "SMPP[%s]: Manually forced dest addr ton = %d, dest add npi = %d", < octstr_get_cstr(smpp->conn->id), smpp->dest_addr_ton, < smpp->dest_addr_npi); < } else { < pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_NATIONAL; /* national */ < pdu->u.submit_sm.dest_addr_npi = GSM_ADDR_NPI_E164; /* ISDN number plan */ < } < < /* < * if its a international number starting with +, lets remove the < * '+' and set number type to international instead < */ < if (octstr_get_char(pdu->u.submit_sm.destination_addr,0) == '+') { < octstr_delete(pdu->u.submit_sm.destination_addr, 0,1); < pdu->u.submit_sm.dest_addr_ton = GSM_ADDR_TON_INTERNATIONAL; < } < < /* check length of src/dst address */ < if (octstr_len(pdu->u.submit_sm.destination_addr) > 20 || < octstr_len(pdu->u.submit_sm.source_addr) > 20) { < smpp_pdu_destroy(pdu); < return NULL; < } < < /* < * set the data coding scheme (DCS) field < * check if we have a forced value for this from the smsc-group. < * Note: if message class is set, then we _must_ force alt_dcs otherwise < * dcs has reserved values (e.g. mclass=2, dcs=0x11). We check MWI flag < * first here, because MWI and MCLASS can not be set at the same time and < * function fields_to_dcs check MWI first, so we have no need to force alt_dcs < * if MWI is set. < */ < if (msg->sms.mwi == MWI_UNDEF && msg->sms.mclass != MC_UNDEF) < pdu->u.submit_sm.data_coding = fields_to_dcs(msg, 1); /* force alt_dcs */ < else < pdu->u.submit_sm.data_coding = fields_to_dcs(msg, < (msg->sms.alt_dcs != SMS_PARAM_UNDEFINED ? < msg->sms.alt_dcs : smpp->conn->alt_dcs)); < < /* set protocol id */ < if(msg->sms.pid != SMS_PARAM_UNDEFINED) < pdu->u.submit_sm.protocol_id = msg->sms.pid; < < /* < * set the esm_class field < * default is store and forward, plus udh and rpi if requested < */ < pdu->u.submit_sm.esm_class = ESM_CLASS_SUBMIT_STORE_AND_FORWARD_MODE; < if (octstr_len(msg->sms.udhdata)) < pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class | < ESM_CLASS_SUBMIT_UDH_INDICATOR; < if (msg->sms.rpi > 0) < pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class | < ESM_CLASS_SUBMIT_RPI; < < /* < * set data segments and length < */ < < pdu->u.submit_sm.short_message = octstr_duplicate(msg->sms.msgdata); < < /* < * only re-encoding if using default smsc charset that is defined via < * alt-charset in smsc group and if MT is not binary < */ < if (msg->sms.coding == DC_7BIT || (msg->sms.coding == DC_UNDEF && octstr_len(msg->sms.udhdata))) { < /* < * consider 3 cases: < * a) data_coding 0xFX: encoding should always be GSM 03.38 charset < * b) data_coding 0x00: encoding may be converted according to alt-charset < * c) data_coding 0x00: assume GSM 03.38 charset if alt-charset is not defined < */ < if ((pdu->u.submit_sm.data_coding & 0xF0) || < (!smpp->alt_charset && pdu->u.submit_sm.data_coding == 0)) { < charset_latin1_to_gsm(pdu->u.submit_sm.short_message); < } < else if (pdu->u.submit_sm.data_coding == 0 && smpp->alt_charset) { < /* < * convert to the given alternative charset < */ < if (charset_convert(pdu->u.submit_sm.short_message, "ISO-8859-1", < octstr_get_cstr(smpp->alt_charset)) != 0) < error(0, "Failed to convert msgdata from charset <%s> to <%s>, will send as is.", < "ISO-8859-1", octstr_get_cstr(smpp->alt_charset)); < } < } < < /* prepend udh if present */ < if (octstr_len(msg->sms.udhdata)) { < octstr_insert(pdu->u.submit_sm.short_message, msg->sms.udhdata, 0); < } < < pdu->u.submit_sm.sm_length = octstr_len(pdu->u.submit_sm.short_message); < < /* < * check for validity and defered settings < * were message value has higher priiority then smsc config group value < */ < validity = msg->sms.validity >= 0 ? msg->sms.validity : smpp->validityperiod; < if (validity >= 0) { < struct tm tm = gw_gmtime(time(NULL) + validity * 60); < pdu->u.submit_sm.validity_period = octstr_format("%02d%02d%02d%02d%02d%02d000+", < tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, < tm.tm_hour, tm.tm_min, tm.tm_sec); < } < < if (msg->sms.deferred >= 0) { < struct tm tm = gw_gmtime(time(NULL) + msg->sms.deferred * 60); < pdu->u.submit_sm.schedule_delivery_time = octstr_format("%02d%02d%02d%02d%02d%02d000+", < tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday, < tm.tm_hour, tm.tm_min, tm.tm_sec); < } < < /* ask for the delivery reports if needed */ < if (DLR_IS_SUCCESS_OR_FAIL(msg->sms.dlr_mask)) < pdu->u.submit_sm.registered_delivery = 1; < else if (DLR_IS_FAIL(msg->sms.dlr_mask) && !DLR_IS_SUCCESS(msg->sms.dlr_mask)) < pdu->u.submit_sm.registered_delivery = 2; < < /* set priority */ < if (msg->sms.priority >= 0 && msg->sms.priority <= 3) < pdu->u.submit_sm.priority_flag = msg->sms.priority; < else < pdu->u.submit_sm.priority_flag = smpp->priority; < < /* set more messages to send */ < if (smpp->version > 0x33 && msg->sms.msg_left > 0) < pdu->u.submit_sm.more_messages_to_send = 1; < 1008c1279,1280 < os = octstr_format("%ld", pdu->u.submit_sm.sequence_number); --- > /*Need to also check for submit_multi tho this will also work seq_no formats match ...*/ > os = octstr_format("%ld", pdu->u.submit_sm.sequence_number); 1489a1762,1823 > case submit_multi_resp: > printf("++++++++++++++Got a response++++++"); > os = octstr_format("%ld", pdu->u.submit_multi_resp.sequence_number); > smpp_msg = dict_remove(smpp->sent_msgs, os); > octstr_destroy(os); > if (smpp_msg == NULL) { > warning(0, "SMPP[%s]: SMSC sent submit_multi_resp " > "with wrong sequence number 0x%08lx", > octstr_get_cstr(smpp->conn->id), > pdu->u.submit_multi_resp.sequence_number); > break; > } > msg = smpp_msg->msg; > smpp_msg_destroy(smpp_msg, 0); > if (pdu->u.submit_multi_resp.command_status != 0) { > error(0, "SMPP[%s]: SMSC returned error code 0x%08lx (%s) " > "in response to submit_multi.", > octstr_get_cstr(smpp->conn->id), > pdu->u.submit_sm_resp.command_status, > smpp_error_to_string(pdu->u.submit_multi_resp.command_status)); > reason = smpp_status_to_smscconn_failure_reason( > pdu->u.submit_multi_resp.command_status); > > /* > * check to see if we got a "throttling error", in which case we'll just > * sleep for a while > */ > if (pdu->u.submit_multi_resp.command_status == SMPP_ESME_RTHROTTLED) > time(&(smpp->throttling_err_time)); > else > smpp->throttling_err_time = 0; > > bb_smscconn_send_failed(smpp->conn, msg, reason, > octstr_format("%ld/%s", pdu->u.submit_multi_resp.command_status, > smpp_error_to_string(pdu->u.submit_multi_resp.command_status))); > --(*pending_submits); > } else { > Octstr *tmp; > > /* check if msg_id is C string, decimal or hex for this SMSC */ > if (smpp->smpp_msg_id_type == -1) { > /* the default, C string */ > tmp = octstr_duplicate(pdu->u.submit_multi_resp.message_id); > } else { > if (smpp->smpp_msg_id_type & 0x01) { > tmp = octstr_format("%ld", strtol( /* hex */ > octstr_get_cstr(pdu->u.submit_multi_resp.message_id), NULL, 16)); > } else { > tmp = octstr_format("%ld", strtol( /* decimal */ > octstr_get_cstr(pdu->u.submit_multi_resp.message_id), NULL, 10)); > } > } > > /* SMSC ACK.. now we have the message id. */ > /*I doubt this works... But JIC*/ > if (DLR_IS_ENABLED_DEVICE(msg->sms.dlr_mask)) > dlr_add(smpp->conn->id, tmp, msg); > > octstr_destroy(tmp); > bb_smscconn_sent(smpp->conn, msg, NULL); > --(*pending_submits); > } /* end if for SMSC ACK */ 1490a1825 > break; Index: wap/wtls_pdusupport.h =================================================================== RCS file: /home/cvs/gateway/wap/wtls_pdusupport.h,v retrieving revision 1.4 diff -r1.4 wtls_pdusupport.h Binary files /tmp/cvsvU8VId and wtls_pdusupport.h differ