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

Function ospConvertToInAddress

modules/osp/destination.c:602–640  ·  view source on GitHub ↗

* Convert "[x.x.x.x]:port" or "hostname:prot" to "address:port" format * param src Source address string * param dest Destination address string * param bufsize Size of dest buffer */

Source from the content-addressed store, hash-verified

600 * param bufsize Size of dest buffer
601 */
602void ospConvertToInAddress(
603 const char* src,
604 char* dest,
605 int bufsize)
606{
607 char buffer[OSP_STRBUF_SIZE];
608 char* end;
609 char* port;
610 int size;
611
612 if ((src != NULL) && (*src != '\0')) {
613 size = sizeof(buffer);
614 strncpy(buffer, src, size);
615 buffer[size - 1] = '\0';
616
617 if (buffer[0] == '[') {
618 if((port = strchr(buffer + 1, ':')) != NULL) {
619 *port = '\0';
620 port++;
621 }
622
623 if ((end = strchr(buffer + 1, ']')) != NULL) {
624 *end = '\0';
625 }
626
627 if (port != NULL) {
628 snprintf(dest, bufsize, "%s:%s", buffer + 1, port);
629 } else {
630 strncpy(dest, buffer + 1, bufsize);
631 dest[bufsize - 1] = '\0';
632 }
633 } else {
634 strncpy(dest, src, bufsize);
635 dest[bufsize - 1] = '\0';
636 }
637 } else {
638 *dest = '\0';
639 }
640}
641

Callers 2

ospLoadRoutesFunction · 0.85
ospVerifyParametersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected