summaryrefslogtreecommitdiffstats
path: root/src/libosmocc/endpoint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libosmocc/endpoint.c')
-rw-r--r--src/libosmocc/endpoint.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/src/libosmocc/endpoint.c b/src/libosmocc/endpoint.c
index e1d6027..1a7e3a3 100644
--- a/src/libosmocc/endpoint.c
+++ b/src/libosmocc/endpoint.c
@@ -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;
@@ -1146,7 +1155,7 @@ static int osmo_cc_set_address(osmo_cc_endpoint_t *ep, const char *text)
PDEBUG(DCC, DEBUG_ERROR, "Given local address '%s' is invalid.\n", *host_p);
return -EINVAL;
}
- osmo_cc_set_local_peer(osmo_cc_session_nettype_inet, addrtype, *host_p);
+ osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, addrtype, *host_p);
return 0;
}
@@ -1166,7 +1175,7 @@ static void osmo_cc_help_rtp(void)
printf("interfaces, between machines, local machine's IP must be given.\n\n");
}
-static int osmo_cc_set_rtp(const char *text)
+static int osmo_cc_set_rtp(osmo_cc_endpoint_t *ep, const char *text)
{
int peer = 0, ports = 0;
@@ -1195,7 +1204,7 @@ static int osmo_cc_set_rtp(const char *text)
PDEBUG(DCC, DEBUG_ERROR, "Given RTP address '%s' is invalid.\n", text);
return -EINVAL;
}
- osmo_cc_set_local_peer(osmo_cc_session_nettype_inet, addrtype, text);
+ osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, addrtype, text);
return 0;
}
@@ -1227,7 +1236,7 @@ static int osmo_cc_set_rtp(const char *text)
from = from * 10 + *text - '0';
}
- osmo_cc_set_rtp_ports(from, to);
+ osmo_cc_set_rtp_ports(&ep->session_config, from, to);
return 0;
}
@@ -1270,6 +1279,9 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u
ep->serving_location = serving_location;
ep->priv = priv;
+ osmo_cc_set_local_peer(&ep->session_config, osmo_cc_session_nettype_inet, osmo_cc_session_addrtype_ipv4, "127.0.0.1");
+ osmo_cc_set_rtp_ports(&ep->session_config, 16384, 32767);
+
/* apply args */
for (i = 0; i < argc; i++) {
if (!strncasecmp(argv[i], "local", 5)) {
@@ -1285,7 +1297,7 @@ int osmo_cc_new(osmo_cc_endpoint_t *ep, const char *version, const char *name, u
}
} else
if (!strncasecmp(argv[i], "rtp", 3)) {
- rc = osmo_cc_set_rtp(argv[i]);
+ rc = osmo_cc_set_rtp(ep, argv[i]);
if (rc < 0) {
return rc;
}