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

Function comp_ip

route.c:395–416  ·  view source on GitHub ↗

! \brief comp_scriptvar helping function */

Source from the content-addressed store, hash-verified

393
394/*! \brief comp_scriptvar helping function */
395inline static int comp_ip(int op, str *ip_str, struct net *ipnet)
396{
397 struct ip_addr *ip_tmp = NULL;
398
399 ip_tmp = str2ip(ip_str);
400 if (!ip_tmp) {
401 ip_tmp = str2ip6(ip_str);
402 if (!ip_tmp) {
403 LM_DBG("Var value is not an IP\n");
404 return -1;
405 }
406 }
407
408 if (op == EQUAL_OP) {
409 return (matchnet(ip_tmp, ipnet) == 1);
410 } else if (op == DIFF_OP) {
411 return (matchnet(ip_tmp, ipnet) != 1);
412 } else {
413 LM_CRIT("invalid operator %d\n", op);
414 return -1;
415 }
416}
417
418/*! \brief compare str to str */
419inline static int comp_s2s(int op, str *s1, str *s2)

Callers 1

comp_scriptvarFunction · 0.85

Calls 3

str2ipFunction · 0.85
str2ip6Function · 0.85
matchnetFunction · 0.85

Tested by

no test coverage detected