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

Function get_branch_field

pvar.c:2043–2089  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2041}
2042
2043static inline int get_branch_field( int idx, int field_id, pv_value_t *res)
2044{
2045 struct msg_branch *branch;
2046
2047 branch = get_msg_branch(idx);
2048 if (branch==NULL)
2049 return pv_get_null( NULL, NULL, res);
2050
2051 /* got a valid branch, return the field */
2052 switch (field_id) {
2053 case 0:
2054 case BR_URI_ID: /* return URI */
2055 res->rs = branch->uri;
2056 res->flags = PV_VAL_STR;
2057 break;
2058 case BR_Q_ID: /* return Q */
2059 res->rs.s = q2str(branch->q, (unsigned int*)&res->rs.len);
2060 res->flags = PV_VAL_STR;
2061 break;
2062 case BR_DURI_ID: /* return DURI */
2063 if ( ZSTR(branch->dst_uri) )
2064 return pv_get_null(NULL, NULL, res);
2065 res->rs = branch->dst_uri;
2066 res->flags = PV_VAL_STR;
2067 break;
2068 case BR_PATH_ID: /* return PATH */
2069 if ( ZSTR(branch->path) )
2070 return pv_get_null(NULL, NULL, res);
2071 res->rs = branch->path;
2072 res->flags = PV_VAL_STR;
2073 break;
2074 case BR_FLAGS_ID: /* return FLAGS */
2075 res->rs = bitmask_to_flag_list(FLAG_TYPE_BRANCH, branch->bflags);
2076 res->flags = PV_VAL_STR;
2077 break;
2078 case BR_SOCKET_ID: /* return SOCKET */
2079 if ( branch->force_send_socket==NULL )
2080 return pv_get_null(NULL, NULL, res);
2081 res->rs = branch->force_send_socket->sock_str;
2082 res->flags = PV_VAL_STR;
2083 break;
2084 default:
2085 LM_CRIT("BUG - unsupported ID %d\n",field_id);
2086 return pv_get_null(NULL, NULL, res);
2087 }
2088 return 0;
2089}
2090
2091
2092static int pv_get_branch_fields(struct sip_msg *msg, pv_param_t *param,

Callers 2

pv_get_branch_fieldsFunction · 0.85
get_msg_branch_fieldFunction · 0.85

Calls 4

get_msg_branchFunction · 0.85
pv_get_nullFunction · 0.85
q2strFunction · 0.85
bitmask_to_flag_listFunction · 0.85

Tested by

no test coverage detected