nt2mku has uploaded this change for review.

View Change

Allow vpair with E1oIP

This change allows virtual E1 pairs to be connected to E1oIP.
The other vpair interface could then be used by another
application accessing the e1d control socket.

Example:
e1d
virtual-e1-pair 1

interface 0 vpair
line 0
mode channelized

interface 1 vpair
line 0
mode e1oip

octoi-client x.x.x.x 12345
local-bind 0.0.0.0 23456
account myaccount
mode vpair
vpair interface-number 1
vpair line-number 0

Change-Id: I510180ac52ca1a9091430e85f46c963cf086b1d0
---
M include/osmocom/octoi/octoi.h
M src/e1oip.c
M src/intf_line.c
M src/octoi/octoi_clnt_vty.c
M src/octoi/octoi_srv_fsm.c
M src/octoi/octoi_srv_vty.c
M src/octoi/octoi_vty.h
7 files changed, 75 insertions(+), 5 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/64/43764/1
diff --git a/include/osmocom/octoi/octoi.h b/include/osmocom/octoi/octoi.h
index b80f8be..1e2cb45 100644
--- a/include/osmocom/octoi/octoi.h
+++ b/include/osmocom/octoi/octoi.h
@@ -12,6 +12,7 @@
ACCOUNT_MODE_ICE1USB,
ACCOUNT_MODE_REDIRECT,
ACCOUNT_MODE_DAHDI_TRUNKDEV,
+ ACCOUNT_MODE_VPAIR,
};

extern const struct value_string octoi_account_mode_name[];
@@ -37,6 +38,10 @@
char *name; /* DAHDI trunkdev name */
uint8_t line_nr; /* line number inside icE1usb */
} dahdi_trunkdev;
+ struct {
+ uint8_t intf_nr; /* e1d virtual-E1-pair interface */
+ uint8_t line_nr; /* line number inside vpair interface */
+ } vpair;
} u;
};

diff --git a/src/e1oip.c b/src/e1oip.c
index 86172d0..1b1666e 100644
--- a/src/e1oip.c
+++ b/src/e1oip.c
@@ -59,6 +59,15 @@
}

static struct e1_line *
+find_line_by_vpair(struct e1_daemon *e1d, uint8_t intf_nr, uint8_t line_nr)
+{
+ struct e1_intf *e1i = e1d_find_intf(e1d, intf_nr);
+ if (!e1i || e1i->drv != E1_DRIVER_VPAIR)
+ return NULL;
+ return e1_intf_find_line(e1i, line_nr);
+}
+
+static struct e1_line *
find_line_for_account(struct e1_daemon *e1d, const struct octoi_account *acc)
{
switch (acc->mode) {
@@ -68,6 +77,8 @@
case ACCOUNT_MODE_DAHDI_TRUNKDEV:
return find_line_by_trunkdev_name(e1d, acc->u.dahdi_trunkdev.name,
acc->u.dahdi_trunkdev.line_nr);
+ case ACCOUNT_MODE_VPAIR:
+ return find_line_by_vpair(e1d, acc->u.vpair.intf_nr, acc->u.vpair.line_nr);
break;
default:
return NULL;
@@ -152,9 +163,13 @@
if (line->mode != E1_LINE_MODE_E1OIP)
return;

- /* check if line is active */
- if (!osmo_timer_pending(&line->ts0.timer))
- return;
+ /* A vpair has no physical-driver activation event. Activate an E1oIP
+ * line lazily when its configured OCTOI client becomes available. */
+ if (!osmo_timer_pending(&line->ts0.timer)) {
+ if (line->intf->drv != E1_DRIVER_VPAIR)
+ return;
+ e1_line_active(line);
+ }

/* TODO: kill old peer, if != current peer */
if (!line->octoi_peer)
diff --git a/src/intf_line.c b/src/intf_line.c
index 445fe5b..0efb44c 100644
--- a/src/intf_line.c
+++ b/src/intf_line.c
@@ -327,6 +327,12 @@
line->id == acc->u.dahdi_trunkdev.line_nr)
return clnt;
break;
+ case ACCOUNT_MODE_VPAIR:
+ if (line->intf->drv == E1_DRIVER_VPAIR &&
+ line->intf->id == acc->u.vpair.intf_nr &&
+ line->id == acc->u.vpair.line_nr)
+ return clnt;
+ break;
case ACCOUNT_MODE_NONE:
case ACCOUNT_MODE_REDIRECT:
break;
diff --git a/src/octoi/octoi_clnt_vty.c b/src/octoi/octoi_clnt_vty.c
index 3ea3a9a..8697a63 100644
--- a/src/octoi/octoi_clnt_vty.c
+++ b/src/octoi/octoi_clnt_vty.c
@@ -279,6 +279,8 @@
install_node(&clnt_account_node, NULL);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_ice1_serno_cmd);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_ice1_line_cmd);
+ install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_vpair_intf_cmd);
+ install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_vpair_line_cmd);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_mode_cmd);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_batching_factor_cmd);
install_element(OCTOI_CLNT_ACCOUNT_NODE, &cfg_account_force_all_ts_cmd);
diff --git a/src/octoi/octoi_srv_fsm.c b/src/octoi/octoi_srv_fsm.c
index 81b27da..59d8048 100644
--- a/src/octoi/octoi_srv_fsm.c
+++ b/src/octoi/octoi_srv_fsm.c
@@ -110,6 +110,7 @@
switch (acc->mode) {
case ACCOUNT_MODE_ICE1USB:
case ACCOUNT_MODE_DAHDI_TRUNKDEV:
+ case ACCOUNT_MODE_VPAIR:
/* check if a matching device exists for that account */
st->app_priv = g_octoi->ops->client_connected(srv, st->peer, acc);
if (!st->app_priv) {
diff --git a/src/octoi/octoi_srv_vty.c b/src/octoi/octoi_srv_vty.c
index 05a99a4..1fea1da 100644
--- a/src/octoi/octoi_srv_vty.c
+++ b/src/octoi/octoi_srv_vty.c
@@ -49,6 +49,7 @@
{ ACCOUNT_MODE_ICE1USB, "ice1usb" },
{ ACCOUNT_MODE_REDIRECT, "redirect" },
{ ACCOUNT_MODE_DAHDI_TRUNKDEV, "dahdi-trunkdev" },
+ { ACCOUNT_MODE_VPAIR, "vpair" },
{ 0, NULL }
};

@@ -288,11 +289,12 @@
#endif

gDEFUN(cfg_account_mode, cfg_account_mode_cmd,
- "mode (ice1usb|redirect|dahdi-trunkdev)",
+ "mode (ice1usb|redirect|dahdi-trunkdev|vpair)",
"Operational mode of account\n"
"Connect to local icE1usb (identified by USB serial + line number)\n"
"Redirect to other IP/Port\n"
- "Use DAHDI trunkdev virtual trunk\n")
+ "Use DAHDI trunkdev virtual trunk\n"
+ "Use an osmo-e1d virtual E1 pair member\n")
{
struct octoi_account *acc = vty->index;

@@ -318,6 +320,8 @@
VTY_NEWLINE);
return CMD_WARNING;
#endif
+ } else if (!strcmp(argv[0], "vpair")) {
+ acc->mode = ACCOUNT_MODE_VPAIR;
} else
OSMO_ASSERT(0);

@@ -440,6 +444,35 @@
acc->batching_factor, acc->prefill_frame_count, VTY_NEWLINE);
}

+
+#define VPAIR_STR "osmo-e1d virtual E1 pair settings\n"
+
+gDEFUN(cfg_account_vpair_intf, cfg_account_vpair_intf_cmd,
+ "vpair interface-number <0-255>",
+ VPAIR_STR "E1 interface number\n" "E1 interface number\n")
+{
+ struct octoi_account *acc = vty->index;
+ if (acc->mode != ACCOUNT_MODE_VPAIR) {
+ vty_out(vty, "%% Error: Not in vpair mode!%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ acc->u.vpair.intf_nr = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
+gDEFUN(cfg_account_vpair_line, cfg_account_vpair_line_cmd,
+ "vpair line-number <0-255>",
+ VPAIR_STR "E1 line number\n" "E1 line number\n")
+{
+ struct octoi_account *acc = vty->index;
+ if (acc->mode != ACCOUNT_MODE_VPAIR) {
+ vty_out(vty, "%% Error: Not in vpair mode!%s", VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ acc->u.vpair.line_nr = atoi(argv[0]);
+ return CMD_SUCCESS;
+}
+
#ifdef HAVE_DAHDI_TRUNKDEV

#define DAHDI_STR "DAHDI trunkdev settings\n"
@@ -513,6 +546,10 @@
vty_out(vty, " dahdi-trunkdev line-number %u%s", acc->u.dahdi_trunkdev.line_nr, VTY_NEWLINE);
#endif
break;
+ case ACCOUNT_MODE_VPAIR:
+ vty_out(vty, " vpair interface-number %u%s", acc->u.vpair.intf_nr, VTY_NEWLINE);
+ vty_out(vty, " vpair line-number %u%s", acc->u.vpair.line_nr, VTY_NEWLINE);
+ break;
}
}

@@ -570,6 +607,8 @@
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_ice1_serno_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_ice1_line_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_redir_cmd);
+ install_element(OCTOI_ACCOUNT_NODE, &cfg_account_vpair_intf_cmd);
+ install_element(OCTOI_ACCOUNT_NODE, &cfg_account_vpair_line_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_batching_factor_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_force_all_ts_cmd);
install_element(OCTOI_ACCOUNT_NODE, &cfg_account_no_force_all_ts_cmd);
diff --git a/src/octoi/octoi_vty.h b/src/octoi/octoi_vty.h
index a452e9d..7142e18 100644
--- a/src/octoi/octoi_vty.h
+++ b/src/octoi/octoi_vty.h
@@ -7,6 +7,8 @@
extern struct cmd_element cfg_account_mode_cmd;
extern struct cmd_element cfg_account_ice1_serno_cmd;
extern struct cmd_element cfg_account_ice1_line_cmd;
+extern struct cmd_element cfg_account_vpair_intf_cmd;
+extern struct cmd_element cfg_account_vpair_line_cmd;
extern struct cmd_element cfg_account_batching_factor_cmd;
extern struct cmd_element cfg_account_force_all_ts_cmd;
extern struct cmd_element cfg_account_no_force_all_ts_cmd;

To view, visit change 43764. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: newchange
Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I510180ac52ca1a9091430e85f46c963cf086b1d0
Gerrit-Change-Number: 43764
Gerrit-PatchSet: 1
Gerrit-Owner: nt2mku <degrunert.web@googlemail.com>