MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / bin_pop_str

Function bin_pop_str

bin_interface.c:332–362  ·  view source on GitHub ↗

* pops an str from the current position in the packet * @info: pointer to store the result * * @return: * 0 (success): info retrieved * 1 (success): nothing returned, all data has been consumed! * < 0: error * * Note: The pointer returned in @info str is only valid for the duration of * the callback. Don't forget to copy the info into a safe buffer! */

Source from the content-addressed store, hash-verified

330 * the callback. Don't forget to copy the info into a safe buffer!
331 */
332int bin_pop_str(bin_packet_t *packet, str *info)
333{
334 if (packet->front_pointer - packet->buffer.s == packet->buffer.len)
335 return 1;
336
337 if (packet->front_pointer - packet->buffer.s > packet->buffer.len ||
338 packet->front_pointer - packet->buffer.s + LEN_FIELD_SIZE > packet->buffer.len)
339 goto error;
340
341 info->len = 0;
342 memcpy(&info->len, packet->front_pointer, LEN_FIELD_SIZE);
343 packet->front_pointer += LEN_FIELD_SIZE;
344
345 if (packet->front_pointer - packet->buffer.s + info->len > packet->buffer.len)
346 goto error;
347
348 if (info->len == 0)
349 info->s = NULL;
350 else
351 info->s = packet->front_pointer;
352
353 packet->front_pointer += info->len;
354
355 LM_DBG("Popped: '%.*s' [%d]\n", info->len, info->s, info->len);
356
357 return 0;
358
359error:
360 LM_ERR("Receive binary packet buffer overflow\n");
361 return -1;
362}
363
364/*
365 * pops an integer value from the current position in the buffer

Callers 15

handle_pres_updateFunction · 0.85
ds_status_updateFunction · 0.85
lb_recv_status_updateFunction · 0.85
handle_presentity_queryFunction · 0.85
cache_replicated_insertFunction · 0.85
cache_replicated_removeFunction · 0.85
bin_pop_streamFunction · 0.85
unpack_update_fieldsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected