| 4094 | } |
| 4095 | |
| 4096 | int b2bl_get_tuple_key(str *key, unsigned int *hash_index, |
| 4097 | unsigned int *local_index, str *entity_str) |
| 4098 | { |
| 4099 | int ret; |
| 4100 | str callid, from_tag, to_tag, *tuple; |
| 4101 | |
| 4102 | /* check to see if the key is specified as callid;from_tag;to_tag */ |
| 4103 | from_tag.s = q_memchr(key->s, ';', key->len); |
| 4104 | if (!from_tag.s) { |
| 4105 | LM_DBG("there's no tuple separator: must be plain key: %.*s\n", |
| 4106 | key->len, key->s); |
| 4107 | tuple = key; |
| 4108 | goto end; |
| 4109 | } |
| 4110 | callid.s = key->s; |
| 4111 | callid.len = from_tag.s - callid.s; |
| 4112 | from_tag.s++; |
| 4113 | to_tag.s = q_memchr(from_tag.s, ';', key->len - callid.len - 1); |
| 4114 | if (!to_tag.s) { |
| 4115 | LM_DBG("invalid key format: %.*s\n", key->len, key->s); |
| 4116 | return -1; |
| 4117 | } |
| 4118 | from_tag.len = to_tag.s - from_tag.s; |
| 4119 | to_tag.s++; |
| 4120 | to_tag.len = key->s + key->len - to_tag.s; |
| 4121 | |
| 4122 | /* we've got the entity's coordinates, try to find the entity now */ |
| 4123 | tuple = b2b_api.get_b2bl_key(&callid, &from_tag, &to_tag, entity_str); |
| 4124 | if(!tuple) { |
| 4125 | LM_DBG("cannot find entity [%.*s]\n", key->len, key->s); |
| 4126 | return -2; |
| 4127 | } |
| 4128 | end: |
| 4129 | ret = b2bl_parse_key(tuple, hash_index, local_index); |
| 4130 | if (key != tuple) |
| 4131 | pkg_free(tuple); |
| 4132 | return ret; |
| 4133 | } |
no test coverage detected