Definition in file bin_pcscf.c.
#include "bin_pcscf.h"
Go to the source code of this file.
Functions | |
| static int | str_shm_dup (str *dest, str *src) |
| int | bin_encode_p_dialog (bin_data *x, p_dialog *d) |
| Encode an dialog into a binary form. | |
| p_dialog * | bin_decode_p_dialog (bin_data *x) |
| Decode a dialog from a binary data structure. | |
| int | bin_encode_ipsec (bin_data *x, r_ipsec *ipsec) |
| Encode an ipsec into a binary form. | |
| int | bin_decode_ipsec (bin_data *x, r_ipsec **ipsec) |
| Decode a ipsec from a binary data structure. | |
| int | bin_encode_tls (bin_data *x, r_tls *tls) |
| Encode an tls into a binary form. | |
| int | bin_decode_tls (bin_data *x, r_tls **tls) |
| Decode a tls from a binary data structure. | |
| int | bin_encode_r_security (bin_data *x, r_security *s) |
| Encode an security into a binary form. | |
| int | bin_decode_r_security (bin_data *x, r_security **sec) |
| Decode a security from a binary data structure. | |
| int | bin_encode_pinhole (bin_data *x, r_nat_dest *pinhole) |
| Encode a pinhole into a binary form. | |
| int | bin_decode_pinhole (bin_data *x, r_nat_dest **pinhole) |
| Decode a pinhole from a binary data structure. | |
| int | bin_encode_r_public (bin_data *x, r_public *p) |
| Encode a r_public into a binary form. | |
| r_public * | bin_decode_r_public (bin_data *x) |
| Decode a r_public from a binary data structure. | |
| int | bin_encode_r_contact (bin_data *x, r_contact *c) |
| Encode a r_contact into a binary form. | |
| r_contact * | bin_decode_r_contact (bin_data *x) |
| Decode a r_contact from a binary data structure. | |
| int | bin_encode_r_subscription (bin_data *x, r_subscription *s) |
| Encode a r_subscription into a binary form. | |
| r_subscription * | bin_decode_r_subscription (bin_data *x) |
| Decode a r_subscription from a binary data structure. | |
Variables | |
| tm_binds | tmb |
| Structure with pointers to tm funcs. | |
| int | r_hash_size |
| Size of S-CSCF registrar hash table. | |
| static int str_shm_dup | ( | str * | dest, | |
| str * | src | |||
| ) | [inline, static] |
Definition at line 63 of file bin_pcscf.c.
References M_NAME.
Referenced by bin_decode_auth_userdata(), bin_decode_auth_vector(), bin_decode_filter_criteria(), bin_decode_ims_subscription(), bin_decode_ipsec(), bin_decode_p_dialog(), bin_decode_public_identity(), bin_decode_r_contact(), bin_decode_r_public(), bin_decode_r_security(), bin_decode_r_subscriber(), bin_decode_r_subscription(), bin_decode_s_dialog(), and bin_decode_spt().
00064 { 00065 dest->s = shm_malloc(src->len); 00066 if (!dest->s){ 00067 LOG(L_ERR,"ERR:"M_NAME":str_shm_dup: Error allocating %d bytes\n",src->len); 00068 dest->len=0; 00069 return 0; 00070 } 00071 dest->len = src->len; 00072 memcpy(dest->s,src->s,src->len); 00073 return 1; 00074 }
Encode an dialog into a binary form.
| x | - binary data to append to | |
| u | - the dialog to encode |
Definition at line 84 of file bin_pcscf.c.
References bin_encode_dlg_t(), bin_encode_int(), bin_encode_str(), bin_encode_time_t(), bin_encode_uchar(), bin_encode_ushort(), _p_dialog::call_id, _p_dialog::dialog_c, _p_dialog::dialog_s, _p_dialog::direction, _p_dialog::expires, _p_dialog::first_cseq, _p_dialog::host, if, _p_dialog::is_releasing, _p_dialog::last_cseq, _p_dialog::lr_session_expires, M_NAME, _p_dialog::method, _p_dialog::method_str, _p_dialog::port, _p_dialog::refresher, _p_dialog::routes, _p_dialog::routes_cnt, _p_dialog::state, _p_dialog::transport, and _p_dialog::uac_supp_timer.
Referenced by bin_cache_dump_dialogs_to_table(), and make_snapshot_dialogs().
00085 { 00086 int i; 00087 char c; 00088 00089 if (!bin_encode_str(x,&(d->call_id))) goto error; 00090 00091 c = d->direction; 00092 if (!bin_encode_uchar(x,c)) goto error; 00093 00094 if (!bin_encode_str(x,&(d->host))) goto error; 00095 if (!bin_encode_ushort(x,d->port)) goto error; 00096 00097 c = d->transport; 00098 if (!bin_encode_uchar(x,c)) goto error; 00099 00100 if (!bin_encode_ushort(x,d->routes_cnt)) goto error; 00101 for(i=0;i<d->routes_cnt;i++) 00102 if (!bin_encode_str(x,d->routes+i)) goto error; 00103 00104 c = d->method; 00105 if (!bin_encode_uchar(x,c)) goto error; 00106 if (!bin_encode_str(x,&(d->method_str))) goto error; 00107 00108 if (!bin_encode_int(x,d->first_cseq)) goto error; 00109 if (!bin_encode_int(x,d->last_cseq)) goto error; 00110 00111 c = d->state; 00112 if (!bin_encode_uchar(x,c)) goto error; 00113 00114 if (!bin_encode_time_t(x,d->expires)) goto error; 00115 if (!bin_encode_time_t(x,d->lr_session_expires)) goto error; 00116 if (!bin_encode_str(x,&(d->refresher))) goto error; 00117 if (!bin_encode_uchar(x,d->uac_supp_timer)) goto error; 00118 00119 if (!bin_encode_uchar(x,d->is_releasing)) goto error; 00120 if (!bin_encode_dlg_t(x,d->dialog_c)) goto error; 00121 if (!bin_encode_dlg_t(x,d->dialog_s)) goto error; 00122 00123 return 1; 00124 error: 00125 LOG(L_ERR,"ERR:"M_NAME":bin_encode_p_dialog: Error while encoding.\n"); 00126 return 0; 00127 }
Decode a dialog from a binary data structure.
| x | - binary data to decode from |
Definition at line 134 of file bin_pcscf.c.
References bin_decode_char(), bin_decode_dlg_t(), bin_decode_int(), bin_decode_str(), bin_decode_time_t(), bin_decode_uchar(), bin_decode_ushort(), _p_dialog::call_id, _p_dialog::dialog_c, _p_dialog::dialog_s, _p_dialog::direction, _p_dialog::expires, _p_dialog::first_cseq, get_p_dialog_hash(), _p_dialog::hash, _p_dialog::host, if, _p_dialog::is_releasing, _p_dialog::last_cseq, _p_dialog::lr_session_expires, M_NAME, _bin_data::max, _p_dialog::method, _p_dialog::method_str, _p_dialog::port, _p_dialog::refresher, _p_dialog::routes, _p_dialog::routes_cnt, _p_dialog::state, str_shm_dup(), _p_dialog::transport, and _p_dialog::uac_supp_timer.
Referenced by bin_cache_load_dialogs_from_table(), and load_snapshot_dialogs().
00135 { 00136 p_dialog *d=0; 00137 int len,i; 00138 str s; 00139 char c; 00140 unsigned char uc; 00141 00142 len = sizeof(p_dialog); 00143 d = (p_dialog*) shm_malloc(len); 00144 if (!d) { 00145 LOG(L_ERR,"ERR:"M_NAME":bin_decode_p_dialog: Error allocating %d bytes.\n",len); 00146 goto error; 00147 } 00148 memset(d,0,len); 00149 00150 if (!bin_decode_str(x,&s)||!str_shm_dup(&(d->call_id),&s)) goto error; 00151 00152 if (!bin_decode_uchar(x, &uc)) goto error; 00153 d->direction = uc; 00154 00155 if (!bin_decode_str(x,&s)||!str_shm_dup(&(d->host),&s)) goto error; 00156 if (!bin_decode_ushort(x, &d->port)) goto error; 00157 00158 if (!bin_decode_uchar(x, &uc)) goto error; 00159 d->transport = uc; 00160 00161 if (!bin_decode_ushort(x, &d->routes_cnt)) goto error; 00162 00163 len = sizeof(str)*d->routes_cnt; 00164 d->routes = (str*) shm_malloc(len); 00165 if (!d) { 00166 LOG(L_ERR,"ERR:"M_NAME":bin_decode_p_dialog: Error allocating %d bytes.\n",len); 00167 goto error; 00168 } 00169 memset(d->routes,0,len); 00170 for(i=0;i<d->routes_cnt;i++) 00171 if (!bin_decode_str(x,&s)||!str_shm_dup(d->routes+i,&s)) goto error; 00172 00173 if (!bin_decode_char(x, &c)) goto error; 00174 d->method = c; 00175 if (!bin_decode_str(x,&s)||!str_shm_dup(&(d->method_str),&s)) goto error; 00176 00177 if (!bin_decode_int(x, &d->first_cseq)) goto error; 00178 if (!bin_decode_int(x, &d->last_cseq)) goto error; 00179 00180 if (!bin_decode_char(x, &c)) goto error; 00181 d->state = c; 00182 00183 if (!bin_decode_time_t(x, &d->expires)) goto error; 00184 00185 if (!bin_decode_time_t(x, &d->lr_session_expires)) goto error; 00186 if (!bin_decode_str(x,&s)||!str_shm_dup(&(d->refresher),&s)) goto error; 00187 if (!bin_decode_uchar(x,&d->uac_supp_timer)) goto error; 00188 00189 if (!bin_decode_uchar(x, &d->is_releasing)) goto error; 00190 if (!bin_decode_dlg_t(x,&(d->dialog_c))) goto error; 00191 if (!bin_decode_dlg_t(x,&(d->dialog_s))) goto error; 00192 00193 d->hash = get_p_dialog_hash(d->call_id); 00194 00195 return d; 00196 error: 00197 LOG(L_ERR,"ERR:"M_NAME":bin_decode_p_dialog: Error while decoding (at %d (%04x)).\n",x->max,x->max); 00198 if (d) { 00199 if (d->call_id.s) shm_free(d->call_id.s); 00200 if (d->host.s) shm_free(d->host.s); 00201 if (d->routes_cnt){ 00202 for(i=0;i<d->routes_cnt;i++) 00203 if (d->routes[i].s) shm_free(d->routes[i].s); 00204 shm_free(d->routes); 00205 } 00206 if (d->method_str.s) shm_free(d->method_str.s); 00207 if (d->refresher.s) shm_free(d->refresher.s); 00208 shm_free(d); 00209 } 00210 return 0; 00211 }
Encode an ipsec into a binary form.
| x | - binary data to append to | |
| ipsec | - the r_ipsec to encode |
Definition at line 228 of file bin_pcscf.c.
References _r_ipsec::alg, bin_encode_char(), bin_encode_int(), bin_encode_str(), bin_encode_ushort(), _r_ipsec::ck, _r_ipsec::ealg, _r_ipsec::ik, M_NAME, _r_ipsec::port_uc, _r_ipsec::port_us, _r_ipsec::r_alg, _r_ipsec::r_ealg, _r_ipsec::spi_pc, _r_ipsec::spi_ps, _r_ipsec::spi_uc, and _r_ipsec::spi_us.
Referenced by bin_encode_r_security().
00229 { 00230 if (!ipsec){ 00231 if (!bin_encode_char(x,0)) goto error; 00232 return 1; 00233 } 00234 00235 if (!bin_encode_char(x,1)) goto error; 00236 00237 if (!bin_encode_int(x,ipsec->spi_uc)) goto error; 00238 if (!bin_encode_int(x,ipsec->spi_us)) goto error; 00239 if (!bin_encode_int(x,ipsec->spi_pc)) goto error; 00240 if (!bin_encode_int(x,ipsec->spi_ps)) goto error; 00241 if (!bin_encode_ushort(x,ipsec->port_uc)) goto error; 00242 if (!bin_encode_ushort(x,ipsec->port_us)) goto error; 00243 00244 if (!bin_encode_str(x,&(ipsec->ealg))) goto error; 00245 if (!bin_encode_str(x,&(ipsec->r_ealg))) goto error; 00246 if (!bin_encode_str(x,&(ipsec->ck))) goto error; 00247 if (!bin_encode_str(x,&(ipsec->alg))) goto error; 00248 if (!bin_encode_str(x,&(ipsec->r_alg))) goto error; 00249 if (!bin_encode_str(x,&(ipsec->ik))) goto error; 00250 00251 return 1; 00252 error: 00253 LOG(L_ERR,"ERR:"M_NAME":bin_encode_ipsec: Error while encoding.\n"); 00254 return 0; 00255 }
Decode a ipsec from a binary data structure.
| x | - binary data to decode from | |
| ipsec | - ** to write into |
Definition at line 263 of file bin_pcscf.c.
References bin_decode_char(), bin_decode_int(), bin_decode_str(), bin_decode_ushort(), M_NAME, _bin_data::max, and str_shm_dup().
Referenced by bin_decode_r_security().
00264 { 00265 int len; 00266 str s; 00267 char c; 00268 00269 if (!bin_decode_char(x, &c)) goto error; 00270 00271 if (c==0) { 00272 *ipsec = 0; 00273 return 1; 00274 } 00275 00276 len = sizeof(r_ipsec); 00277 *ipsec = (r_ipsec*) shm_malloc(len); 00278 if (!*ipsec) { 00279 LOG(L_ERR,"ERR:"M_NAME":bin_decode_ipsec: Error allocating %d bytes.\n",len); 00280 goto error; 00281 } 00282 memset(*ipsec,0,len); 00283 00284 if (!bin_decode_int(x, &(*ipsec)->spi_uc)) goto error; 00285 if (!bin_decode_int(x, &(*ipsec)->spi_us)) goto error; 00286 if (!bin_decode_int(x, &(*ipsec)->spi_pc)) goto error; 00287 if (!bin_decode_int(x, &(*ipsec)->spi_ps)) goto error; 00288 if (!bin_decode_ushort(x, &(*ipsec)->port_uc)) goto error; 00289 if (!bin_decode_ushort(x, &(*ipsec)->port_us)) goto error; 00290 00291 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*ipsec)->ealg),&s)) goto error; 00292 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*ipsec)->r_ealg),&s)) goto error; 00293 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*ipsec)->ck),&s)) goto error; 00294 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*ipsec)->alg),&s)) goto error; 00295 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*ipsec)->r_alg),&s)) goto error; 00296 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*ipsec)->ik),&s)) goto error; 00297 00298 return 1; 00299 error: 00300 LOG(L_ERR,"ERR:"M_NAME":bin_decode_ipsec: Error while decoding (at %d (%04x)).\n",x->max,x->max); 00301 if (*ipsec) { 00302 if ((*ipsec)->ealg.s) shm_free((*ipsec)->ealg.s); 00303 if ((*ipsec)->r_ealg.s) shm_free((*ipsec)->r_ealg.s); 00304 if ((*ipsec)->ck.s) shm_free((*ipsec)->ck.s); 00305 if ((*ipsec)->alg.s) shm_free((*ipsec)->alg.s); 00306 if ((*ipsec)->r_alg.s) shm_free((*ipsec)->r_alg.s); 00307 if ((*ipsec)->ik.s) shm_free((*ipsec)->ik.s); 00308 shm_free(*ipsec); 00309 *ipsec = 0; 00310 } 00311 return 0; 00312 }
Encode an tls into a binary form.
| x | - binary data to append to | |
| tls | - the r_tls to encode |
Definition at line 322 of file bin_pcscf.c.
References bin_encode_char(), bin_encode_ushort(), M_NAME, and _r_tls::port_tls.
Referenced by bin_encode_r_security().
00323 { 00324 if (!tls){ 00325 if (!bin_encode_char(x,0)) goto error; 00326 return 1; 00327 } 00328 00329 if (!bin_encode_char(x,1)) goto error; 00330 00331 if (!bin_encode_ushort(x,tls->port_tls)) goto error; 00332 00333 return 1; 00334 error: 00335 LOG(L_ERR,"ERR:"M_NAME":bin_encode_tls: Error while encoding.\n"); 00336 return 0; 00337 }
Decode a tls from a binary data structure.
| x | - binary data to decode from | |
| tls | - ** to write into |
Definition at line 345 of file bin_pcscf.c.
References bin_decode_char(), bin_decode_ushort(), M_NAME, and _bin_data::max.
Referenced by bin_decode_r_security().
00346 { 00347 int len; 00348 char c; 00349 00350 if (!bin_decode_char(x, &c)) goto error; 00351 00352 if (c==0) { 00353 *tls = 0; 00354 return 1; 00355 } 00356 00357 len = sizeof(r_tls); 00358 *tls = (r_tls*) shm_malloc(len); 00359 if (!*tls) { 00360 LOG(L_ERR,"ERR:"M_NAME":bin_decode_tls: Error allocating %d bytes.\n",len); 00361 goto error; 00362 } 00363 memset(*tls,0,len); 00364 00365 if (!bin_decode_ushort(x, &(*tls)->port_tls)) goto error; 00366 return 1; 00367 error: 00368 LOG(L_ERR,"ERR:"M_NAME":bin_decode_tls: Error while decoding (at %d (%04x)).\n",x->max,x->max); 00369 if (*tls) { 00370 shm_free(*tls); 00371 *tls = 0; 00372 } 00373 return 0; 00374 }
| int bin_encode_r_security | ( | bin_data * | x, | |
| r_security * | s | |||
| ) |
Encode an security into a binary form.
| x | - binary data to append to | |
| s | - the r_security to encode |
Definition at line 385 of file bin_pcscf.c.
References bin_encode_char(), bin_encode_int(), bin_encode_ipsec(), bin_encode_str(), bin_encode_tls(), _r_security::data, _r_security::ipsec, M_NAME, _r_security::q, _r_security::sec_header, SEC_IPSEC, SEC_NONE, SEC_TLS, _r_security::tls, and _r_security::type.
Referenced by bin_encode_r_contact().
00386 { 00387 if (!s){ 00388 if (!bin_encode_char(x,0)) goto error; 00389 return 1; 00390 } 00391 00392 if (!bin_encode_char(x,1)) goto error; 00393 00394 if (!bin_encode_str(x,&(s->sec_header))) goto error; 00395 if (!bin_encode_int(x,s->type)) goto error; 00396 switch (s->type){ 00397 case SEC_NONE: 00398 break; 00399 case SEC_TLS: 00400 if (!bin_encode_tls(x,s->data.tls)) goto error; 00401 break; 00402 case SEC_IPSEC: 00403 if (!bin_encode_ipsec(x,s->data.ipsec)) goto error; 00404 break; 00405 } 00406 if (!bin_encode_int(x,s->q*1000)) goto error; /* yeah yeah.... */ 00407 00408 return 1; 00409 error: 00410 LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_security: Error while encoding.\n"); 00411 return 0; 00412 }
| int bin_decode_r_security | ( | bin_data * | x, | |
| r_security ** | sec | |||
| ) |
Decode a security from a binary data structure.
| x | - binary data to decode from | |
| sec | - ** to write into |
Definition at line 420 of file bin_pcscf.c.
References bin_decode_char(), bin_decode_int(), bin_decode_ipsec(), bin_decode_str(), bin_decode_tls(), free_r_ipsec(), free_r_tls(), M_NAME, _bin_data::max, SEC_IPSEC, SEC_NONE, SEC_TLS, and str_shm_dup().
Referenced by bin_decode_r_contact().
00421 { 00422 int len; 00423 str s; 00424 char c; 00425 int y; 00426 00427 if (!bin_decode_char(x, &c)) goto error; 00428 00429 if (c==0) { 00430 *sec = 0; 00431 return 1; 00432 } 00433 00434 len = sizeof(r_security); 00435 *sec = (r_security*) shm_malloc(len); 00436 if (!*sec) { 00437 LOG(L_ERR,"ERR:"M_NAME":bin_decode_r_security: Error allocating %d bytes.\n",len); 00438 goto error; 00439 } 00440 memset(*sec,0,len); 00441 00442 if (!bin_decode_str(x,&s)||!str_shm_dup(&((*sec)->sec_header),&s)) goto error; 00443 if (!bin_decode_int(x,&y)) goto error; 00444 (*sec)->type = y; 00445 switch ((*sec)->type){ 00446 case SEC_NONE: 00447 break; 00448 case SEC_TLS: 00449 if (!bin_decode_tls(x,&((*sec)->data.tls))) goto error; 00450 break; 00451 case SEC_IPSEC: 00452 if (!bin_decode_ipsec(x,&((*sec)->data.ipsec))) goto error; 00453 break; 00454 } 00455 if (!bin_decode_int(x, &y)) goto error; 00456 (*sec)->q = ((float)y)/1000.0; 00457 00458 return 1; 00459 error: 00460 LOG(L_ERR,"ERR:"M_NAME":bin_decode_r_security: Error while decoding (at %d (%04x)).\n",x->max,x->max); 00461 if (*sec) { 00462 if ((*sec)->sec_header.s) shm_free((*sec)->sec_header.s); 00463 switch ((*sec)->type){ 00464 case SEC_NONE: 00465 break; 00466 case SEC_TLS: 00467 if ((*sec)->data.tls) free_r_tls((*sec)->data.tls); 00468 break; 00469 case SEC_IPSEC: 00470 if ((*sec)->data.ipsec) free_r_ipsec((*sec)->data.ipsec); 00471 break; 00472 } 00473 shm_free(*sec); 00474 *sec = 0; 00475 } 00476 return 0; 00477 }
| int bin_encode_pinhole | ( | bin_data * | x, | |
| r_nat_dest * | pinhole | |||
| ) |
Encode a pinhole into a binary form.
| x | - binary data to append to | |
| u | - the dialog to encode |
Definition at line 485 of file bin_pcscf.c.
References bin_encode_char(), bin_encode_uint(), bin_encode_ushort(), M_NAME, _r_nat_dest::nat_addr, and _r_nat_dest::nat_port.
Referenced by bin_encode_r_contact().
00486 { 00487 if (!pinhole){ 00488 if (!bin_encode_char(x,0)) goto error; 00489 return 1; 00490 } 00491 00492 if (!bin_encode_char(x,1)) goto error; 00493 00494 if (!bin_encode_uint(x,pinhole->nat_addr.af)) goto error; 00495 if (!bin_encode_uint(x,pinhole->nat_addr.len)) goto error; 00496 if (!bin_encode_uint(x,pinhole->nat_addr.u.addr32[0])) goto error; 00497 if (!bin_encode_uint(x,pinhole->nat_addr.u.addr32[1])) goto error; 00498 if (!bin_encode_uint(x,pinhole->nat_addr.u.addr32[2])) goto error; 00499 if (!bin_encode_uint(x,pinhole->nat_addr.u.addr32[3])) goto error; 00500 00501 if (!bin_encode_ushort(x,pinhole->nat_port)) goto error; 00502 00503 return 1; 00504 error: 00505 LOG(L_ERR,"ERR:"M_NAME":bin_encode_pinhole: Error while encoding.\n"); 00506 return 0; 00507 }
| int bin_decode_pinhole | ( | bin_data * | x, | |
| r_nat_dest ** | pinhole | |||
| ) |
Decode a pinhole from a binary data structure.
| x | - binary data to decode from | |
| pinhole | - ** to write into |
Definition at line 515 of file bin_pcscf.c.
References bin_decode_char(), bin_decode_uint(), bin_decode_ushort(), _bin_data::len, M_NAME, and _bin_data::max.
Referenced by bin_decode_r_contact().
00516 { 00517 int len; 00518 char c; 00519 00520 if (!bin_decode_char(x, &c)) goto error; 00521 00522 if (c==0) { 00523 *pinhole = 0; 00524 return 1; 00525 } 00526 00527 len = sizeof(r_nat_dest); 00528 *pinhole = (r_nat_dest*) shm_malloc(len); 00529 if (!*pinhole) { 00530 LOG(L_ERR,"ERR:"M_NAME":bin_decode_pinhole: Error allocating %d bytes.\n",len); 00531 goto error; 00532 } 00533 memset(*pinhole,0,len); 00534 00535 if (!bin_decode_uint(x, &(*pinhole)->nat_addr.af)) goto error; 00536 if (!bin_decode_uint(x, &(*pinhole)->nat_addr.len)) goto error; 00537 if (!bin_decode_uint(x, &(*pinhole)->nat_addr.u.addr32[0])) goto error; 00538 if (!bin_decode_uint(x, &(*pinhole)->nat_addr.u.addr32[1])) goto error; 00539 if (!bin_decode_uint(x, &(*pinhole)->nat_addr.u.addr32[2])) goto error; 00540 if (!bin_decode_uint(x, &(*pinhole)->nat_addr.u.addr32[3])) goto error; 00541 if (!bin_decode_ushort(x, &(*pinhole)->nat_port)) goto error; 00542 00543 return 1; 00544 error: 00545 LOG(L_ERR,"ERR:"M_NAME":bin_decode_pinhole: Error while decoding (at %d (%04x)).\n",x->max,x->max); 00546 if (*pinhole) { 00547 shm_free(*pinhole); 00548 *pinhole = 0; 00549 } 00550 return 0; 00551 }
Encode a r_public into a binary form.
| x | - binary data to append to | |
| p | - the r_public to encode |
Definition at line 561 of file bin_pcscf.c.
Referenced by bin_encode_r_contact(), and make_snapshot_registrar().
00562 { 00563 char c; 00564 if (!bin_encode_str(x,&(p->aor))) goto error; 00565 c = p->is_default; 00566 if (!bin_encode_char(x,c)) goto error; 00567 00568 return 1; 00569 error: 00570 LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_public: Error while encoding.\n"); 00571 return 0; 00572 }
Decode a r_public from a binary data structure.
| x | - binary data to decode from |
Definition at line 579 of file bin_pcscf.c.
Referenced by bin_decode_r_contact(), and load_snapshot_registrar().
00580 { 00581 str s; 00582 int len; 00583 char c; 00584 r_public *p; 00585 00586 len = sizeof(r_public); 00587 p = (r_public*) shm_malloc(len); 00588 if (!p) { 00589 LOG(L_ERR,"ERR:"M_NAME":bin_decode_r_public: Error allocating %d bytes.\n",len); 00590 goto error; 00591 } 00592 memset(p,0,len); 00593 00594 if (!bin_decode_str(x,&s)||!str_shm_dup(&(p->aor),&s)) goto error; 00595 if (!bin_decode_char(x, &c)) goto error; 00596 p->is_default = c; 00597 00598 return p; 00599 error: 00600 LOG(L_ERR,"ERR:"M_NAME":bin_decode_r_public: Error while decoding (at %d (%04x)).\n",x->max,x->max); 00601 if (p) { 00602 if (p->aor.s) shm_free(p->aor.s); 00603 shm_free(p); 00604 } 00605 return 0; 00606 }
Encode a r_contact into a binary form.
| x | - binary data to append to | |
| p | - the r_contact to encode |
Definition at line 624 of file bin_pcscf.c.
Referenced by bin_cache_dump_registrar_to_table(), bin_encode_r_public(), and make_snapshot_registrar().
00625 { 00626 int i; 00627 char k; 00628 unsigned short us; 00629 r_public *p=0; 00630 00631 if (!bin_encode_str(x,&(c->host))) goto error; 00632 if (!bin_encode_ushort(x,c->port)) goto error; 00633 if (!bin_encode_char(x,c->transport)) goto error; 00634 00635 if (!bin_encode_r_security(x,c->security_temp)) goto error; 00636 if (!bin_encode_r_security(x,c->security)) goto error; 00637 00638 if (!bin_encode_str(x,&(c->uri))) goto error; 00639 00640 k = c->reg_state; 00641 if (!bin_encode_char(x,k)) goto error; 00642 00643 if (!bin_encode_time_t(x,c->expires)) goto error; 00644 00645 if (!bin_encode_ushort(x,c->service_route_cnt)) goto error; 00646 for(i=0;i<c->service_route_cnt;i++) 00647 if (!bin_encode_str(x,c->service_route+i)) goto error; 00648 00649 if (!bin_encode_pinhole(x,c->pinhole)) goto error; 00650 00651 us=0; 00652 for(p=c->head;p;p=p->next) 00653 us++; 00654 if (!bin_encode_ushort(x,us)) goto error; 00655 for(p=c->head;p;p=p->next) 00656 if (!bin_encode_r_public(x,p)) goto error; 00657 00658 return 1; 00659 error: 00660 LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_contact: Error while encoding.\n"); 00661 return 0; 00662 }
Decode a r_contact from a binary data structure.
| x | - binary data to decode from |
Definition at line 669 of file bin_pcscf.c.
Referenced by bin_cache_load_registrar_from_table(), bin_decode_r_public(), and load_snapshot_registrar().
00670 { 00671 r_contact *c=0; 00672 r_public *p=0,*pn=0; 00673 int len,i; 00674 char k; 00675 unsigned short us; 00676 str st; 00677 00678 len = sizeof(r_contact); 00679 c = (r_contact*) shm_malloc(len); 00680 if (!c) { 00681 LOG(L_ERR,"ERR:"M_NAME":bin_decode_r_contact: Error allocating %d bytes.\n",len); 00682 goto error; 00683 } 00684 memset(c,0,len); 00685 00686 if (!bin_decode_str(x,&st)||!str_shm_dup(&(c->host),&st)) goto error; 00687 if (!bin_decode_ushort(x,&c->port)) goto error; 00688 if (!bin_decode_char(x,&c->transport)) goto error; 00689 00690 c->hash = get_contact_hash(c->host,c->port,c->transport,r_hash_size); 00691 00692 if (!bin_decode_r_security(x,&(c->security_temp))) goto error; 00693 if (!bin_decode_r_security(x,&(c->security))) goto error; 00694 00695 if (!bin_decode_str(x,&st)||!str_shm_dup(&(c->uri),&st)) goto error; 00696 00697 if (!bin_decode_char(x,&k)) goto error; 00698 c->reg_state = k; 00699 00700 if (!bin_decode_time_t(x,&c->expires)) goto error; 00701 00702 if (!bin_decode_ushort(x, &c->service_route_cnt)) goto error; 00703 00704 len = sizeof(str)*c->service_route_cnt; 00705 c->service_route = (str*) shm_malloc(len); 00706 if (!c->service_route) { 00707 LOG(L_ERR,"ERR:"M_NAME":bin_decode_r_contact: Error allocating %d bytes.\n",len); 00708 goto error; 00709 } 00710 memset(c->service_route,0,len); 00711 for(i=0;i<c->service_route_cnt;i++) 00712 if (!bin_decode_str(x,&st)||!str_shm_dup(c->service_route+i,&st)) goto error; 00713 00714 if (!bin_decode_pinhole(x,&(c->pinhole ))) goto error; 00715 00716 if (!