Fw: Re: Fw: Help with setting sm_length!
Yury Mikhienko <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | Mobicom-Kavkaz |
| Message-ID | <[email protected]> |
On Mon, 14 Apr 2003 16:46:24 +0200 Alexander Malysh <[email protected]> wrote: > Am Montag, 14. April 2003 16:51 schrieb Yury Mikhienko: > [snip] > > > > May be I'm stupib, but in smpp_pdu_pack function I dont see the point of > > calculating size of message and placing value into sm_length. In my > > opinion, sm_length is the INTEGER field in pdu.submit_sm structure, and I > > found defenition length of fields and packing into PDU only: ... > > switch (pdu->type) { > > #define OPTIONAL_BEGIN(num_expected) > > #define TLV(tag_id, min_len, max_len) > > #define OPTIONAL_END > > #define INTEGER(name, octets) p = *(&p); > > #define NULTERMINATED(name, max_octets) p = *(&p); > > #define OCTETS(name, field_giving_octets) \ > > p->field_giving_octets = octstr_len(p->name); > > here sm_length will be calculated , after preprocessing: > p->sm_length = octstr_len(p->short_message); > > > [snip] > Thanks for your patience, but WHERE? I do not see the "p->sm_length = octstr_len(p->short_message);" (or like this) code :(((( my smpp_pdu_pack function, full snip: Octstr *smpp_pdu_pack(SMPP_PDU *pdu) { Octstr *os; Octstr *temp; Octstr *opt_tag = NULL; Octstr *opt_val = NULL; int sm_length = 0; os = octstr_create(""); gw_assert(pdu != NULL); /* * Fix lengths of octet string fields. */ switch (pdu->type) { #define OPTIONAL_BEGIN(num_expected) #define TLV(tag_id, min_len, max_len) #define OPTIONAL_END #define INTEGER(name, octets) p = *(&p); #define NULTERMINATED(name, max_octets) p = *(&p); #define OCTETS(name, field_giving_octets) \ p->field_giving_octets = octstr_len(p->name); #define PDU(name, id, fields) \ case id: { struct name *p = &pdu->u.name; fields } break; #include "smpp_pdu.def" default: error(0, "Unknown SMPP_PDU type, internal error while packing."); } switch (pdu->type) { #define OPTIONAL_BEGIN(num_expected) #define TLV(tag_id, min_len, max_len) \ { /* Add optional parameter - if existing */ \ short tag_id_buffer = tag_id; \ opt_tag = octstr_create_real(""); \ append_encoded_integer(opt_tag,tag_id_buffer,2); \ opt_val = dict_get(p->optional_parameters, opt_tag); \ if (opt_val != NULL) { \ long opt_len = octstr_len(opt_val); \ debug("smpp_pdu", 0, "Packing optional parameter " \ "(tag = %x, val = %s, len = %ld)", \ tag_id, octstr_get_cstr(opt_val), opt_len); \ gw_assert(min_len == -1 || (min_len <= opt_len && opt_len <= max_len)); \ octstr_append(os, opt_tag); \ append_encoded_integer(os,opt_len,2); \ octstr_append(os, opt_val); \ } \ octstr_destroy(opt_tag); \ } #define OPTIONAL_END #define INTEGER(name, octets) \ append_encoded_integer(os, p->name, octets); #define NULTERMINATED(name, max_octets) \ gw_assert(octstr_len(p->name) < max_octets); \ if (p->name != NULL) { \ if (octstr_len(p->name) >= max_octets) { \ warning(0, "SMPP: PDU element <%s> to long " \ "(length is %ld, should be %d)", \ #name, octstr_len(p->name), max_octets); \ temp = octstr_copy(p->name, 0, max_octets-1); \ } else \ temp = octstr_duplicate(p->name); \ octstr_append(os, temp); \ octstr_destroy(temp); \ } \ octstr_append_char(os, '\0'); #define OCTETS(name, field_giving_octets) \ octstr_append(os, p->name); #define PDU(name, id, fields) \ case id: { struct name *p = &pdu->u.name; fields } break; #include "smpp_pdu.def" default: error(0, "Unknown SMPP_PDU type, internal error while packing."); } temp = octstr_create(""); append_encoded_integer(temp, octstr_len(os) + 4, 4); octstr_insert(os, temp, 0); octstr_destroy(temp); return os; } -- Best regards, Yury Mikhienko. IT engineer, ZAO "Mobicom-Kavkaz" -- Best regards, Yury Mikhienko. IT engineer, ZAO "Mobicom-Kavkaz"