Hi,
I'm trying to add a header to SIP messages (for a research project). However, it seems as ser (version 0.8.11pre26) doesn't like my code. Below is the function which is part of a module. It seems as depending on the length of the variable test, ser either crashes or just doesn't send on the full message (truncated after the new header). It sounds a bit like a memory problem. I tried to make sure that memory is properly allocated (thats why the pkg_malloc) and the string is terminated.
I'd be grateful for any pointers!
Thanks, Mario
--
static int exec_pol(struct sip_msg* msg, char* string, char* string2) {
struct lump* anchor; char* nheader; char test[] = "ConType: ABC";
LOG(L_ERR, "PSCON: New Attempt to Add a Header");
if (parse_headers(msg, HDR_EOH, 0) == -1) { LOG(L_ERR, "Error parsing headers"); return 1; }
if(msg->first_line.type == SIP_REQUEST) { anchor = anchor_lump(&msg->add_rm, msg->eoh - msg->buf, 0, 0); if (anchor == 0) { LOG(L_ERR, "Problem with getting anchor"); return 1; }
nheader = pkg_malloc(strlen(test)+1); strcpy(nheader, test); nheader[strlen(test)]=0;
if (insert_new_lump_after(anchor, nheader, strlen(nheader)+1, 0)==0) { LOG(L_ERR, "ERROR: inserting new header"); } }
LOG(L_ERR, "pscon: all fine, returning now ...\n"); return 1; }
On Jul 07, 2003 at 13:08, Mario Kolberg mko@cs.stir.ac.uk wrote:
Hi,
I'm trying to add a header to SIP messages (for a research project). However, it seems as ser (version 0.8.11pre26) doesn't like my code. Below is the function which is part of a module. It seems as depending on the length of the variable test, ser either crashes or just doesn't send on the full message (truncated after the new header). It sounds a bit like a memory problem. I tried to make sure that memory is properly allocated (thats why the pkg_malloc) and the string is terminated.
I'd be grateful for any pointers!
The code seems ok. Could you send us a core dump along with a tar.{gz,bz2} with the sources and the binaries? (either to serhelp@lists.iptel.org or put them on a ftp/http server) To get a core dump you might need to run: ulimit -c unlimited and then start ser with ./ser -w dir_where_core_will_be_dumped.
BTW: if you want to add a header make sure is not 0 terminated (this will insert a \0 in the message!). It should be terminated by a CR LF (\r\n).
Andrei
Hi,
On Monday 07 July 2003 14:08, Mario Kolberg wrote:
I'm trying to add a header to SIP messages (for a research project). However, it seems as ser (version 0.8.11pre26) doesn't like my code. Below is the function which is part of a module. It seems as depending on the length of the variable test, ser either crashes or just doesn't send on the full message (truncated after the new header). It sounds a bit like a memory problem. I tried to make sure that memory is properly allocated (thats why the pkg_malloc) and the string is terminated.
I'd be grateful for any pointers!
sorry, but is their any obvious reason which i do not see why you are not just use append_hf from the textops module to insert a new header field?
Regards Nils