daniel has submitted this change. ( 
https://gerrit.osmocom.org/c/libosmo-abis/+/30617 )

Change subject: ipaccess: Add connect timeout in e1inp_line
......................................................................

ipaccess: Add connect timeout in e1inp_line

* VTY command e1_line N connect-timeout T to set the connect() timeout
* use ipa_client_conn_open2 to connect with timeout

Related: SYS#6237
Change-Id: I7379102d19c172bed2aa00377d92bc885f54b640
---
M TODO-RELEASE
M include/osmocom/abis/e1_input.h
M src/e1_input.c
M src/e1_input_vty.c
M src/input/ipaccess.c
5 files changed, 30 insertions(+), 2 deletions(-)

Approvals:
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  daniel: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve



diff --git a/TODO-RELEASE b/TODO-RELEASE
index 5456ba8..a848040 100644
--- a/TODO-RELEASE
+++ b/TODO-RELEASE
@@ -8,3 +8,4 @@
 # If any interfaces have been removed or changed since the last public 
release: c:r:0.
 #library       what            description / commit summary line
 libosmo-abis   ipa_client_conn_open2 New API added
+libosmo-abis   struct e1inp_line Field added at the end
diff --git a/include/osmocom/abis/e1_input.h b/include/osmocom/abis/e1_input.h
index 91a71e1..2c8f4d8 100644
--- a/include/osmocom/abis/e1_input.h
+++ b/include/osmocom/abis/e1_input.h
@@ -227,6 +227,8 @@
        /* file name and file descriptor of pcap for this line */
        char *pcap_file;
        int pcap_fd;
+
+       unsigned int connect_timeout;
 };
 #define e1inp_line_ipa_oml_ts(line) (&line->ts[0])
 #define e1inp_line_ipa_rsl_ts(line, trx_id) (((1 + (trx_id)) < NUM_E1_TS) ? 
(&line->ts[1 + (trx_id)]) : NULL)
diff --git a/src/e1_input.c b/src/e1_input.c
index ee529cc..02f3b30 100644
--- a/src/e1_input.c
+++ b/src/e1_input.c
@@ -509,6 +509,7 @@
        line->keepalive_idle_timeout = E1INP_USE_DEFAULT;
        line->keepalive_num_probes = E1INP_USE_DEFAULT;
        line->keepalive_probe_interval = E1INP_USE_DEFAULT;
+       line->connect_timeout = 0;

        line->rate_ctr = rate_ctr_group_alloc(line, &e1inp_ctr_g_d, line->num);
        if (!line->rate_ctr) {
diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c
index f6781d1..ca45f93 100644
--- a/src/e1_input_vty.c
+++ b/src/e1_input_vty.c
@@ -245,6 +245,26 @@
        return CMD_SUCCESS;
 }

+DEFUN_ATTR(cfg_e1line_connect_timeout, cfg_e1_line_connect_timeout_cmd,
+          "e1_line <0-255> connect-timeout <0-60>",
+          E1_LINE_HELP "Set connect timeout\n" "Connect timeout in seconds (0 
to disable)\n",
+          CMD_ATTR_IMMEDIATE)
+{
+       struct e1inp_line *line;
+       int e1_nr = atoi(argv[0]);
+       unsigned int timeout = atoi(argv[1]);
+
+       line = e1inp_line_find(e1_nr);
+       if (!line) {
+               vty_out(vty, "%% Line %d doesn't exist%s", e1_nr, VTY_NEWLINE);
+               return CMD_WARNING;
+       }
+       line->connect_timeout = timeout;
+
+       return CMD_SUCCESS;
+}
+
+
 DEFUN_ATTR(cfg_e1line_pcap, cfg_e1line_pcap_cmd,
           "e1_line <0-255> pcap .FILE",
           E1_LINE_HELP "Setup a pcap recording of E1 traffic for line\n"
@@ -376,6 +396,9 @@
                if (line->name)
                        vty_out(vty, " e1_line %u name %s%s", line->num,
                                line->name, VTY_NEWLINE);
+               if (line->connect_timeout != 0)
+                       vty_out(vty, " e1_line %u connect-timeout %u%s", 
line->num, line->connect_timeout,
+                               VTY_NEWLINE);
                if (!line->keepalive_num_probes)
                        vty_out(vty, " no e1_line %u keepalive%s", line->num,
                                VTY_NEWLINE);
@@ -563,6 +586,7 @@
        install_lib_element(L_E1INP_NODE, &cfg_e1_line_port_cmd);
        install_lib_element(L_E1INP_NODE, &cfg_e1_line_socket_cmd);
        install_lib_element(L_E1INP_NODE, &cfg_e1_line_name_cmd);
+       install_lib_element(L_E1INP_NODE, &cfg_e1_line_connect_timeout_cmd);
        install_lib_element(L_E1INP_NODE, &cfg_e1_line_keepalive_cmd);
        install_lib_element(L_E1INP_NODE, &cfg_e1_line_keepalive_params_cmd);
        install_lib_element(L_E1INP_NODE, &cfg_e1_line_no_keepalive_cmd);
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 44c1b78..8a52591 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -1124,7 +1124,7 @@
                }
                link->dscp = g_e1inp_ipaccess_pars.oml.dscp;
                link->priority = g_e1inp_ipaccess_pars.oml.priority;
-               if (ipa_client_conn_open(link) < 0) {
+               if (ipa_client_conn_open2(link, line->connect_timeout) < 0) {
                        LOGP(DLINP, LOGL_ERROR, "cannot open OML BTS link: 
%s\n",
                                strerror(errno));
                        ipa_client_conn_close(link);
@@ -1191,7 +1191,7 @@
        }
        rsl_link->dscp = g_e1inp_ipaccess_pars.rsl.dscp;
        rsl_link->priority = g_e1inp_ipaccess_pars.rsl.priority;
-       if (ipa_client_conn_open(rsl_link) < 0) {
+       if (ipa_client_conn_open2(rsl_link, line->connect_timeout) < 0) {
                LOGP(DLINP, LOGL_ERROR, "cannot open RSL BTS link: %s\n",
                        strerror(errno));
                ipa_client_conn_close(rsl_link);

--
To view, visit https://gerrit.osmocom.org/c/libosmo-abis/+/30617
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I7379102d19c172bed2aa00377d92bc885f54b640
Gerrit-Change-Number: 30617
Gerrit-PatchSet: 7
Gerrit-Owner: daniel <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to