mirror of https://gerrit.osmocom.org/libosmocore
ns2: move LL into public api
Also fix prefix. GPRS_NS -> GPRS_NS2. In preparation to move LL into upper layer. Change-Id: I3b5e0d51ce69b095095e5160ca0cf0d4534db1b8
This commit is contained in:
parent
0bd8a4b5b3
commit
24a14ac80c
|
@ -32,6 +32,14 @@ enum gprs_ns2_vc_mode {
|
||||||
NS2_VC_MODE_ALIVE,
|
NS2_VC_MODE_ALIVE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*! Osmocom NS link layer types */
|
||||||
|
enum gprs_ns2_ll {
|
||||||
|
GPRS_NS2_LL_UDP, /*!< NS/UDP/IP */
|
||||||
|
GPRS_NS2_LL_E1, /*!< NS/E1 */
|
||||||
|
GPRS_NS2_LL_FR, /*!< NS/FR */
|
||||||
|
GPRS_NS2_LL_FR_GRE, /*!< NS/FR/GRE/IP */
|
||||||
|
};
|
||||||
|
|
||||||
/*! Osmocom NS primitives according to 48.016 5.2 Service primitves */
|
/*! Osmocom NS primitives according to 48.016 5.2 Service primitves */
|
||||||
enum gprs_ns2_prim {
|
enum gprs_ns2_prim {
|
||||||
PRIM_NS_UNIT_DATA,
|
PRIM_NS_UNIT_DATA,
|
||||||
|
|
|
@ -227,7 +227,7 @@ char *gprs_ns2_ll_str_buf(char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
switch (nsvc->ll) {
|
switch (nsvc->ll) {
|
||||||
case GPRS_NS_LL_UDP:
|
case GPRS_NS2_LL_UDP:
|
||||||
if (!gprs_ns2_is_ip_bind(nsvc->bind)) {
|
if (!gprs_ns2_is_ip_bind(nsvc->bind)) {
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -250,13 +250,13 @@ char *gprs_ns2_ll_str_buf(char *buf, size_t buf_len, struct gprs_ns2_vc *nsvc)
|
||||||
local_str.ip, local_str.port,
|
local_str.ip, local_str.port,
|
||||||
remote_str.ip, remote_str.port);
|
remote_str.ip, remote_str.port);
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR_GRE:
|
case GPRS_NS2_LL_FR_GRE:
|
||||||
snprintf(buf, buf_len, "frgre)");
|
snprintf(buf, buf_len, "frgre)");
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_E1:
|
case GPRS_NS2_LL_E1:
|
||||||
snprintf(buf, buf_len, "e1)");
|
snprintf(buf, buf_len, "e1)");
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR:
|
case GPRS_NS2_LL_FR:
|
||||||
if (!gprs_ns2_is_frgre_bind(nsvc->bind)) {
|
if (!gprs_ns2_is_frgre_bind(nsvc->bind)) {
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -397,7 +397,7 @@ static struct gprs_ns2_vc *ns2_load_sharing(
|
||||||
/* signalling */
|
/* signalling */
|
||||||
nsvc = ns2_load_sharing_signal(nse);
|
nsvc = ns2_load_sharing_signal(nse);
|
||||||
} else {
|
} else {
|
||||||
enum gprs_ns_ll ll;
|
enum gprs_ns2_ll ll;
|
||||||
|
|
||||||
/* data with load sharing parameter */
|
/* data with load sharing parameter */
|
||||||
if (llist_empty(&nse->nsvc))
|
if (llist_empty(&nse->nsvc))
|
||||||
|
@ -406,7 +406,7 @@ static struct gprs_ns2_vc *ns2_load_sharing(
|
||||||
ll = nsvc->ll;
|
ll = nsvc->ll;
|
||||||
|
|
||||||
switch (ll) {
|
switch (ll) {
|
||||||
case GPRS_NS_LL_FR:
|
case GPRS_NS2_LL_FR:
|
||||||
nsvc = ns2_load_sharing_modulor(nse, bvci, link_selector);
|
nsvc = ns2_load_sharing_modulor(nse, bvci, link_selector);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -855,7 +855,7 @@ enum gprs_ns2_cs ns2_create_vc(struct gprs_ns2_vc_bind *bind,
|
||||||
if (!nsvc)
|
if (!nsvc)
|
||||||
return GPRS_NS2_CS_SKIPPED;
|
return GPRS_NS2_CS_SKIPPED;
|
||||||
|
|
||||||
nsvc->ll = GPRS_NS_LL_UDP;
|
nsvc->ll = GPRS_NS2_LL_UDP;
|
||||||
|
|
||||||
nsvci = tlvp_val16be(&tp, NS_IE_VCI);
|
nsvci = tlvp_val16be(&tp, NS_IE_VCI);
|
||||||
nsvc->nsvci = nsvci;
|
nsvc->nsvci = nsvci;
|
||||||
|
|
|
@ -490,7 +490,7 @@ struct gprs_ns2_vc *gprs_ns2_fr_connect(struct gprs_ns2_vc_bind *bind,
|
||||||
|
|
||||||
nsvc->nsvci = nsvci;
|
nsvc->nsvci = nsvci;
|
||||||
nsvc->nsvci_is_valid = true;
|
nsvc->nsvci_is_valid = true;
|
||||||
nsvc->ll = GPRS_NS_LL_FR;
|
nsvc->ll = GPRS_NS2_LL_FR;
|
||||||
|
|
||||||
gprs_ns2_vc_fsm_start(nsvc);
|
gprs_ns2_vc_fsm_start(nsvc);
|
||||||
|
|
||||||
|
|
|
@ -56,14 +56,6 @@ enum ns_stat {
|
||||||
NS_STAT_ALIVE_DELAY,
|
NS_STAT_ALIVE_DELAY,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*! Osmocom NS link layer types */
|
|
||||||
enum gprs_ns_ll {
|
|
||||||
GPRS_NS_LL_UDP, /*!< NS/UDP/IP */
|
|
||||||
GPRS_NS_LL_E1, /*!< NS/E1 */
|
|
||||||
GPRS_NS_LL_FR, /*!< NS/FR */
|
|
||||||
GPRS_NS_LL_FR_GRE, /*!< NS/FR/GRE/IP */
|
|
||||||
};
|
|
||||||
|
|
||||||
/*! Osmocom NS2 VC create status */
|
/*! Osmocom NS2 VC create status */
|
||||||
enum gprs_ns2_cs {
|
enum gprs_ns2_cs {
|
||||||
GPRS_NS2_CS_CREATED, /*!< A NSVC object has been created */
|
GPRS_NS2_CS_CREATED, /*!< A NSVC object has been created */
|
||||||
|
@ -173,7 +165,7 @@ struct gprs_ns2_vc {
|
||||||
struct osmo_stat_item_group *statg;
|
struct osmo_stat_item_group *statg;
|
||||||
|
|
||||||
/*! which link-layer are we based on? */
|
/*! which link-layer are we based on? */
|
||||||
enum gprs_ns_ll ll;
|
enum gprs_ns2_ll ll;
|
||||||
enum gprs_ns2_vc_mode mode;
|
enum gprs_ns2_vc_mode mode;
|
||||||
|
|
||||||
struct osmo_fsm_inst *fi;
|
struct osmo_fsm_inst *fi;
|
||||||
|
|
|
@ -391,7 +391,7 @@ struct gprs_ns2_vc *gprs_ns2_ip_bind_connect(struct gprs_ns2_vc_bind *bind,
|
||||||
priv = nsvc->priv;
|
priv = nsvc->priv;
|
||||||
priv->remote = *remote;
|
priv->remote = *remote;
|
||||||
|
|
||||||
nsvc->ll = GPRS_NS_LL_UDP;
|
nsvc->ll = GPRS_NS2_LL_UDP;
|
||||||
|
|
||||||
return nsvc;
|
return nsvc;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ const struct osmo_sockaddr *gprs_ns2_ip_vc_local(const struct gprs_ns2_vc *nsvc)
|
||||||
{
|
{
|
||||||
struct priv_bind *priv;
|
struct priv_bind *priv;
|
||||||
|
|
||||||
if (nsvc->ll != GPRS_NS_LL_UDP)
|
if (nsvc->ll != GPRS_NS2_LL_UDP)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (nsvc->bind->driver != &vc_driver_ip)
|
if (nsvc->bind->driver != &vc_driver_ip)
|
||||||
|
@ -420,7 +420,7 @@ const struct osmo_sockaddr *gprs_ns2_ip_vc_remote(const struct gprs_ns2_vc *nsvc
|
||||||
{
|
{
|
||||||
struct priv_vc *priv;
|
struct priv_vc *priv;
|
||||||
|
|
||||||
if (nsvc->ll != GPRS_NS_LL_UDP)
|
if (nsvc->ll != GPRS_NS2_LL_UDP)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
priv = nsvc->priv;
|
priv = nsvc->priv;
|
||||||
|
@ -442,7 +442,7 @@ bool gprs_ns2_ip_vc_equal(const struct gprs_ns2_vc *nsvc,
|
||||||
struct priv_vc *vpriv;
|
struct priv_vc *vpriv;
|
||||||
struct priv_bind *bpriv;
|
struct priv_bind *bpriv;
|
||||||
|
|
||||||
if (nsvc->ll != GPRS_NS_LL_UDP)
|
if (nsvc->ll != GPRS_NS2_LL_UDP)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
vpriv = nsvc->priv;
|
vpriv = nsvc->priv;
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct ns2_vty_vc {
|
||||||
struct llist_head list;
|
struct llist_head list;
|
||||||
|
|
||||||
struct osmo_sockaddr_str remote;
|
struct osmo_sockaddr_str remote;
|
||||||
enum gprs_ns_ll ll;
|
enum gprs_ns2_ll ll;
|
||||||
|
|
||||||
/* old vty code doesnt support multiple NSVCI per NSEI */
|
/* old vty code doesnt support multiple NSVCI per NSEI */
|
||||||
uint16_t nsei;
|
uint16_t nsei;
|
||||||
|
@ -213,7 +213,7 @@ static int config_write_ns(struct vty *vty)
|
||||||
vtyvc->remote_end_is_sgsn ? "sgsn" : "bss", VTY_NEWLINE);
|
vtyvc->remote_end_is_sgsn ? "sgsn" : "bss", VTY_NEWLINE);
|
||||||
|
|
||||||
switch (vtyvc->ll) {
|
switch (vtyvc->ll) {
|
||||||
case GPRS_NS_LL_UDP:
|
case GPRS_NS2_LL_UDP:
|
||||||
vty_out(vty, " nse %u nsvci %u encapsulation udp%s", vtyvc->nsei, vtyvc->nsvci,
|
vty_out(vty, " nse %u nsvci %u encapsulation udp%s", vtyvc->nsei, vtyvc->nsvci,
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
vty_out(vty, " nse %u nsvci %u remote-ip %s%s", vtyvc->nsei, vtyvc->nsvci,
|
vty_out(vty, " nse %u nsvci %u remote-ip %s%s", vtyvc->nsei, vtyvc->nsvci,
|
||||||
|
@ -221,7 +221,7 @@ static int config_write_ns(struct vty *vty)
|
||||||
vty_out(vty, " nse %u nsvci %u remote-port %u%s", vtyvc->nsei, vtyvc->nsvci,
|
vty_out(vty, " nse %u nsvci %u remote-port %u%s", vtyvc->nsei, vtyvc->nsvci,
|
||||||
vtyvc->remote.port, VTY_NEWLINE);
|
vtyvc->remote.port, VTY_NEWLINE);
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR_GRE:
|
case GPRS_NS2_LL_FR_GRE:
|
||||||
vty_out(vty, " nse %u nsvci %u encapsulation framerelay-gre%s", vtyvc->nsei,
|
vty_out(vty, " nse %u nsvci %u encapsulation framerelay-gre%s", vtyvc->nsei,
|
||||||
vtyvc->nsvci, VTY_NEWLINE);
|
vtyvc->nsvci, VTY_NEWLINE);
|
||||||
vty_out(vty, " nse %u nsvci %u remote-ip %s%s", vtyvc->nsei, vtyvc->nsvci,
|
vty_out(vty, " nse %u nsvci %u remote-ip %s%s", vtyvc->nsei, vtyvc->nsvci,
|
||||||
|
@ -229,7 +229,7 @@ static int config_write_ns(struct vty *vty)
|
||||||
vty_out(vty, " nse %u nsvci %u fr-dlci %u%s", vtyvc->nsei, vtyvc->nsvci,
|
vty_out(vty, " nse %u nsvci %u fr-dlci %u%s", vtyvc->nsei, vtyvc->nsvci,
|
||||||
vtyvc->frdlci, VTY_NEWLINE);
|
vtyvc->frdlci, VTY_NEWLINE);
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR:
|
case GPRS_NS2_LL_FR:
|
||||||
vty_out(vty, " nse %u nsvci %u fr %s dlci %u%s", vtyvc->nsei, vtyvc->nsvci,
|
vty_out(vty, " nse %u nsvci %u fr %s dlci %u%s", vtyvc->nsei, vtyvc->nsvci,
|
||||||
vtyvc->netif, vtyvc->frdlci, VTY_NEWLINE);
|
vtyvc->netif, vtyvc->frdlci, VTY_NEWLINE);
|
||||||
break;
|
break;
|
||||||
|
@ -430,7 +430,7 @@ DEFUN(cfg_nse_fr, cfg_nse_fr_cmd,
|
||||||
osmo_strlcpy(vtyvc->netif, name, sizeof(vtyvc->netif));
|
osmo_strlcpy(vtyvc->netif, name, sizeof(vtyvc->netif));
|
||||||
vtyvc->frdlci = dlci;
|
vtyvc->frdlci = dlci;
|
||||||
vtyvc->nsvci = nsvci;
|
vtyvc->nsvci = nsvci;
|
||||||
vtyvc->ll = GPRS_NS_LL_FR;
|
vtyvc->ll = GPRS_NS2_LL_FR;
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ DEFUN(cfg_nse_fr_dlci, cfg_nse_fr_dlci_cmd,
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vtyvc->ll != GPRS_NS_LL_FR_GRE) {
|
if (vtyvc->ll != GPRS_NS2_LL_FR_GRE) {
|
||||||
vty_out(vty, "Warning: seting FR DLCI on non-FR NSE%s",
|
vty_out(vty, "Warning: seting FR DLCI on non-FR NSE%s",
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
}
|
}
|
||||||
|
@ -554,9 +554,9 @@ DEFUN(cfg_nse_encaps, cfg_nse_encaps_cmd,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(argv[2], "udp"))
|
if (!strcmp(argv[2], "udp"))
|
||||||
vtyvc->ll = GPRS_NS_LL_UDP;
|
vtyvc->ll = GPRS_NS2_LL_UDP;
|
||||||
else
|
else
|
||||||
vtyvc->ll = GPRS_NS_LL_FR_GRE;
|
vtyvc->ll = GPRS_NS2_LL_FR_GRE;
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -855,7 +855,7 @@ int gprs_ns2_vty_create() {
|
||||||
llist_for_each_entry(vtyvc, &priv.vtyvc, list) {
|
llist_for_each_entry(vtyvc, &priv.vtyvc, list) {
|
||||||
/* validate settings */
|
/* validate settings */
|
||||||
switch (vtyvc->ll) {
|
switch (vtyvc->ll) {
|
||||||
case GPRS_NS_LL_UDP:
|
case GPRS_NS2_LL_UDP:
|
||||||
if (strlen(vtyvc->remote.ip) == 0) {
|
if (strlen(vtyvc->remote.ip) == 0) {
|
||||||
/* Invalid IP for VC */
|
/* Invalid IP for VC */
|
||||||
continue;
|
continue;
|
||||||
|
@ -871,10 +871,10 @@ int gprs_ns2_vty_create() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR:
|
case GPRS_NS2_LL_FR:
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR_GRE:
|
case GPRS_NS2_LL_FR_GRE:
|
||||||
case GPRS_NS_LL_E1:
|
case GPRS_NS2_LL_E1:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,7 +889,7 @@ int gprs_ns2_vty_create() {
|
||||||
nse->persistent = true;
|
nse->persistent = true;
|
||||||
|
|
||||||
switch (vtyvc->ll) {
|
switch (vtyvc->ll) {
|
||||||
case GPRS_NS_LL_UDP:
|
case GPRS_NS2_LL_UDP:
|
||||||
nsvc = gprs_ns2_ip_connect(bind,
|
nsvc = gprs_ns2_ip_connect(bind,
|
||||||
&sockaddr,
|
&sockaddr,
|
||||||
nse,
|
nse,
|
||||||
|
@ -900,7 +900,7 @@ int gprs_ns2_vty_create() {
|
||||||
}
|
}
|
||||||
nsvc->persistent = true;
|
nsvc->persistent = true;
|
||||||
break;
|
break;
|
||||||
case GPRS_NS_LL_FR: {
|
case GPRS_NS2_LL_FR: {
|
||||||
if (vty_fr_network == NULL) {
|
if (vty_fr_network == NULL) {
|
||||||
/* TODO: add a switch for BSS/SGSN/gbproxy */
|
/* TODO: add a switch for BSS/SGSN/gbproxy */
|
||||||
vty_fr_network = osmo_fr_network_alloc(vty_nsi);
|
vty_fr_network = osmo_fr_network_alloc(vty_nsi);
|
||||||
|
@ -924,8 +924,8 @@ int gprs_ns2_vty_create() {
|
||||||
nsvc->persistent = true;
|
nsvc->persistent = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GPRS_NS_LL_FR_GRE:
|
case GPRS_NS2_LL_FR_GRE:
|
||||||
case GPRS_NS_LL_E1:
|
case GPRS_NS2_LL_E1:
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue