[Serusers] adding a header

Mario Kolberg mko at cs.stir.ac.uk
Mon Jul 7 14:08:01 CEST 2003


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;
}


-- 
The University of Stirling is a university established in Scotland by
charter at Stirling, FK9 4LA.  Privileged/Confidential Information may
be contained in this message.  If you are not the addressee indicated
in this message (or responsible for delivery of the message to such
person), you may not disclose, copy or deliver this message to anyone
and any action taken or omitted to be taken in reliance on it, is
prohibited and may be unlawful.  In such case, you should destroy this
message and kindly notify the sender by reply email.  Please advise
immediately if you or your employer do not consent to Internet email
for messages of this kind.  Opinions, conclusions and other
information in this message that do not relate to the official
business of the University of Stirling shall be understood as neither
given nor endorsed by it.



More information about the sr-users mailing list