libomsocc: Add function to check if interface is attached

pull/1/head
Andreas Eversberg 2 years ago
parent 2d1b5fb437
commit 046834ac97
  1. 35
      src/libosmocc/endpoint.c
  2. 1
      src/libosmocc/endpoint.h

@ -172,6 +172,27 @@ static int split_address(const char *address, const char **host_p, uint16_t *por
return 0;
}
osmo_cc_call_t *osmo_cc_get_attached_interface(osmo_cc_endpoint_t *ep, const char *interface)
{
osmo_cc_call_t *att;
for (att = ep->call_list; att; att = att->next) {
if (att->state != OSMO_CC_STATE_ATTACH_IN)
continue;
/* no interface given, just use the attached peer */
if (!interface[0])
break;
/* no interface name given on attached peer, ignore it */
if (!att->attached_name || !att->attached_name[0])
continue;
/* interface given, use the attached peer with the same interface name */
if (!strcmp(interface, att->attached_name))
break;
}
return att;
}
/* helper to forward message to upper layer */
static void forward_to_ul(osmo_cc_call_t *call, osmo_cc_msg_t *msg)
{
@ -233,19 +254,7 @@ reject:
if (rc < 0)
interface[0] = '\0';
/* check for incoming attachment */
for (att = call->ep->call_list; att; att = att->next) {
if (att->state != OSMO_CC_STATE_ATTACH_IN)
continue;
/* no interface given, just use the attached peer */
if (!interface[0])
break;
/* no interface name given on attached peer, ignore it */
if (!att->attached_name || !att->attached_name[0])
continue;
/* interface given, use the attached peer with the same interface name */
if (!strcmp(interface, att->attached_name))
break;
}
att = osmo_cc_get_attached_interface(call->ep, interface);
if (!att && !interface[0]) {
PDEBUG(DCC, DEBUG_ERROR, "No remote peer attached, rejecting call.\n");
goto reject;

@ -112,6 +112,7 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u
void osmo_cc_delete(struct osmo_cc_endpoint *ep);
int osmo_cc_handle(void);
osmo_cc_call_t *osmo_cc_call_by_callref(osmo_cc_endpoint_t *ep, uint32_t callref);
osmo_cc_call_t *osmo_cc_get_attached_interface(osmo_cc_endpoint_t *ep, const char *interface);
void osmo_cc_ll_msg(osmo_cc_endpoint_t *ep, uint32_t callref, osmo_cc_msg_t *msg);
void osmo_cc_ul_msg(void *priv, uint32_t callref, osmo_cc_msg_t *msg);
osmo_cc_call_t *osmo_cc_call_new(osmo_cc_endpoint_t *ep);

Loading…
Cancel
Save