/* ================================================================= */ static void func_invite(struct cell *t,struct sip_msg *msg,int code,void *param) { int i; //callback function if (!check_transaction_quadruple(msg)) { //we do not have a correct message from/callid/cseq/to return; } i = encode_contact(msg,"enc_prefix","193.175.135.38"); fprintf(stdout,"decode/encode = returned %d\n",i);fflush(stdout); if (t->is_invite) { if (msg->buf != NULL) { fprintf(stdout,"INVITE:received \n%s\n",msg->buf);fflush(stdout); i = sdp_mangle_port(msg,"1000",NULL); fprintf(stdout,"sdp_mangle_port returned %d\n",i);fflush(stdout); i = sdp_mangle_ip(msg,"10.0.0.0/16","123.124.125.126"); fprintf(stdout,"sdp_mangle_ip returned %d\n",i);fflush(stdout); } else fprintf(stdout,"INVITE:received NULL\n");fflush(stdout); } else { fprintf(stdout,"NOT INVITE(REGISTER?) received \n%s\n",msg->buf);fflush(stdout); //i = decode_contact(msg,NULL,NULL); //fprintf(stdout,"decode/encode = returned %d\n",i);fflush(stdout); } fflush(stdout); }
/* * encodes a (maybe aggregated) contact header. * encoding is: * 1: flags * 0x01 this is a star contact (*) *[ * 1: number of contacts present * N: fore each contact present, the length of the contact structure * N*M: the contact structures concatenated *] */ int encode_contact_body(char *hdr,int hdrlen,contact_body_t *contact_parsed,unsigned char *where) { int i=0,k,contact_offset; unsigned char flags=0,tmp[500]; contact_t *mycontact; if(contact_parsed->star){ flags|=STAR_F; where[0]=flags; return 1; } for(contact_offset=0,i=0,mycontact=contact_parsed->contacts;mycontact;mycontact=mycontact->next,i++){ if((k=encode_contact(hdr,hdrlen,mycontact,&tmp[contact_offset]))<0){ LM_ERR("parsing contact number %d\n",i); return -1; } where[2+i]=k; contact_offset+=k; } where[1]=(unsigned char)i; memcpy(&where[2+i],tmp,contact_offset); return 2+i+contact_offset; }