| 290 | |
| 291 | |
| 292 | char* id_builder(struct sip_msg* msg, unsigned int *id_len) |
| 293 | { |
| 294 | char* buf, *p; |
| 295 | int len, value_len, size; |
| 296 | char revhex[sizeof(int)*2]; |
| 297 | |
| 298 | size=sizeof(int)*2; |
| 299 | p=&revhex[0]; |
| 300 | if (int2reverse_hex(&p, &size, msg->rcv.proto_reserved1)==-1){ |
| 301 | LM_CRIT("not enough space for id\n"); |
| 302 | return 0; |
| 303 | } |
| 304 | value_len=p-&revhex[0]; |
| 305 | len=ID_PARAM_LEN+value_len; |
| 306 | buf=pkg_malloc(sizeof(char)*(len+1));/* place for ending \0 */ |
| 307 | if (buf==0){ |
| 308 | ser_error=E_OUT_OF_MEM; |
| 309 | LM_ERR("out of pkg memory\n"); |
| 310 | return 0; |
| 311 | } |
| 312 | memcpy(buf, ID_PARAM, ID_PARAM_LEN); |
| 313 | memcpy(buf+ID_PARAM_LEN, revhex, value_len); |
| 314 | buf[len]=0; /* null terminate it */ |
| 315 | *id_len=len; |
| 316 | return buf; |
| 317 | } |
| 318 | |
| 319 | |
| 320 |
no test coverage detected