Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1 | /* OpenBSC Abis input driver for ip.access */ |
| 2 | |
Harald Welte | 4154755 | 2021-04-28 18:23:21 +0200 | [diff] [blame] | 3 | /* (C) 2009-2021 by Harald Welte <laforge@gnumonks.org> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 4 | * (C) 2010 by Holger Hans Peter Freyther |
| 5 | * (C) 2010 by On-Waves |
| 6 | * |
| 7 | * All Rights Reserved |
| 8 | * |
Harald Welte | 323d39d | 2017-11-13 01:09:21 +0900 | [diff] [blame] | 9 | * SPDX-License-Identifier: AGPL-3.0+ |
| 10 | * |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU Affero General Public License as published by |
| 13 | * the Free Software Foundation; either version 3 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU Affero General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU Affero General Public License |
| 22 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | #include "internal.h" |
| 27 | |
| 28 | #include <stdio.h> |
| 29 | #include <unistd.h> |
| 30 | #include <stdlib.h> |
Pablo Neira Ayuso | eb43413 | 2011-07-07 19:19:46 +0200 | [diff] [blame] | 31 | #include <stdbool.h> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 32 | #include <errno.h> |
Daniel Willmann | 8598072 | 2014-01-09 14:30:55 +0100 | [diff] [blame] | 33 | #include <netinet/tcp.h> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 34 | #include <string.h> |
| 35 | #include <time.h> |
Holger Hans Peter Freyther | 2547458 | 2017-01-23 19:49:07 +0100 | [diff] [blame] | 36 | #include <fcntl.h> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 37 | #include <sys/socket.h> |
| 38 | #include <sys/ioctl.h> |
| 39 | #include <arpa/inet.h> |
| 40 | |
| 41 | #include <osmocom/core/select.h> |
| 42 | #include <osmocom/gsm/tlv.h> |
| 43 | #include <osmocom/core/msgb.h> |
Harald Welte | f5efba4 | 2014-08-18 17:30:36 +0200 | [diff] [blame] | 44 | #include <osmocom/core/macaddr.h> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 45 | #include <osmocom/core/logging.h> |
Harald Welte | 71d87b2 | 2011-07-18 14:49:56 +0200 | [diff] [blame] | 46 | #include <osmocom/core/talloc.h> |
Pablo Neira Ayuso | 177094b | 2011-06-07 12:21:51 +0200 | [diff] [blame] | 47 | #include <osmocom/abis/e1_input.h> |
| 48 | #include <osmocom/abis/ipaccess.h> |
Pablo Neira Ayuso | f67471f | 2011-06-07 11:25:49 +0200 | [diff] [blame] | 49 | #include <osmocom/core/socket.h> |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 50 | #include <osmocom/abis/ipa.h> |
Pablo Neira Ayuso | ef13269 | 2013-07-08 01:17:27 +0200 | [diff] [blame] | 51 | #include <osmocom/core/backtrace.h> |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 52 | #include <osmocom/gsm/ipa.h> |
Philipp Maier | f5f31d3 | 2021-12-06 16:46:40 +0100 | [diff] [blame] | 53 | #include <osmocom/core/stats_tcp.h> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 54 | |
Harald Welte | 4154755 | 2021-04-28 18:23:21 +0200 | [diff] [blame] | 55 | /* global parameters of IPA input driver */ |
| 56 | struct ipa_pars g_e1inp_ipaccess_pars; |
| 57 | |
Pablo Neira Ayuso | 54b4979 | 2011-06-07 12:15:26 +0200 | [diff] [blame] | 58 | static void *tall_ipa_ctx; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 59 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 60 | #define TS1_ALLOC_SIZE 900 |
| 61 | |
Daniel Willmann | 8598072 | 2014-01-09 14:30:55 +0100 | [diff] [blame] | 62 | #define DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT 30 |
| 63 | #define DEFAULT_TCP_KEEPALIVE_INTERVAL 3 |
| 64 | #define DEFAULT_TCP_KEEPALIVE_RETRY_COUNT 10 |
| 65 | |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 66 | static inline struct e1inp_ts *ipaccess_line_ts(struct osmo_fd *bfd, struct e1inp_line *line) |
| 67 | { |
| 68 | if (bfd->priv_nr == E1INP_SIGN_OML) |
| 69 | return e1inp_line_ipa_oml_ts(line); |
| 70 | else |
| 71 | return e1inp_line_ipa_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL); |
| 72 | } |
| 73 | |
| 74 | static inline void ipaccess_keepalive_fsm_cleanup(struct e1inp_ts *e1i_ts) |
| 75 | { |
| 76 | struct osmo_fsm_inst *ka_fsm; |
| 77 | |
| 78 | ka_fsm = e1i_ts->driver.ipaccess.ka_fsm; |
| 79 | if (ka_fsm) { |
| 80 | ipa_keepalive_fsm_stop(ka_fsm); |
| 81 | e1i_ts->driver.ipaccess.ka_fsm = NULL; |
| 82 | } |
| 83 | } |
| 84 | |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 85 | static int ipaccess_drop(struct osmo_fd *bfd, struct e1inp_line *line) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 86 | { |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 87 | int ret = 1; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 88 | struct e1inp_ts *e1i_ts = ipaccess_line_ts(bfd, line); |
Pau Espin Pedrol | deb5c4f | 2020-07-31 12:55:01 +0200 | [diff] [blame] | 89 | e1inp_line_get2(line, __func__); |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 90 | |
| 91 | ipaccess_keepalive_fsm_cleanup(e1i_ts); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 92 | |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 93 | /* Error case: we did not see any ID_RESP yet for this socket. */ |
| 94 | if (bfd->fd != -1) { |
Pau Espin Pedrol | 91314c1 | 2020-11-23 14:45:03 +0100 | [diff] [blame] | 95 | LOGPITS(e1i_ts, DLINP, LOGL_NOTICE, "Forcing socket shutdown\n"); |
Pablo Neira Ayuso | 9621b41 | 2011-07-07 16:19:21 +0200 | [diff] [blame] | 96 | osmo_fd_unregister(bfd); |
| 97 | close(bfd->fd); |
| 98 | bfd->fd = -1; |
Pau Espin Pedrol | 9af069d | 2020-11-23 14:54:00 +0100 | [diff] [blame] | 99 | switch (line->ops->cfg.ipa.role) { |
| 100 | case E1INP_LINE_R_BSC: |
| 101 | /* This is BSC code, ipaccess_drop() is only called for |
| 102 | accepted() sockets, hence the bfd holds a reference to |
| 103 | e1inp_line in ->data that needs to be released */ |
| 104 | OSMO_ASSERT(bfd->data == line); |
| 105 | bfd->data = NULL; |
| 106 | e1inp_line_put2(line, "ipa_bfd"); |
| 107 | break; |
| 108 | case E1INP_LINE_R_BTS: |
| 109 | /* BTS code: bfd->data contains pointer to struct |
| 110 | * ipa_client_conn. Leave it alive so it reconnects. |
| 111 | */ |
| 112 | break; |
| 113 | default: |
| 114 | break; |
| 115 | } |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 116 | ret = -ENOENT; |
Pau Espin Pedrol | 91314c1 | 2020-11-23 14:45:03 +0100 | [diff] [blame] | 117 | } else { |
| 118 | LOGPITS(e1i_ts, DLINP, LOGL_ERROR, |
| 119 | "Forcing socket shutdown with no signal link set\n"); |
Pablo Neira Ayuso | 9621b41 | 2011-07-07 16:19:21 +0200 | [diff] [blame] | 120 | } |
Pablo Neira Ayuso | 6cc3f92 | 2012-08-22 13:57:58 +0200 | [diff] [blame] | 121 | |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 122 | msgb_free(e1i_ts->pending_msg); |
| 123 | e1i_ts->pending_msg = NULL; |
| 124 | |
Pablo Neira Ayuso | 6cc3f92 | 2012-08-22 13:57:58 +0200 | [diff] [blame] | 125 | /* e1inp_sign_link_destroy releases the socket descriptors for us. */ |
Pau Espin Pedrol | c4c3a85 | 2022-09-16 19:24:07 +0200 | [diff] [blame] | 126 | if (line->ops->sign_link_down) |
| 127 | line->ops->sign_link_down(line); |
Pablo Neira Ayuso | 6cc3f92 | 2012-08-22 13:57:58 +0200 | [diff] [blame] | 128 | |
Pau Espin Pedrol | deb5c4f | 2020-07-31 12:55:01 +0200 | [diff] [blame] | 129 | e1inp_line_put2(line, __func__); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 130 | return ret; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 131 | } |
| 132 | |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 133 | static void ipa_bsc_keepalive_write_server_cb(struct osmo_fsm_inst *fi, void *conn, struct msgb *msg) |
| 134 | { |
| 135 | struct osmo_fd *bfd = (struct osmo_fd *)conn; |
| 136 | write(bfd->fd, msg->data, msg->len); |
| 137 | msgb_free(msg); |
| 138 | } |
| 139 | |
| 140 | static int ipa_bsc_keepalive_timeout_cb(struct osmo_fsm_inst *fi, void *data) |
| 141 | { |
| 142 | struct osmo_fd *bfd = (struct osmo_fd *)data; |
| 143 | |
| 144 | if (bfd->fd == -1) |
| 145 | return 1; |
| 146 | |
| 147 | ipaccess_drop(bfd, (struct e1inp_line *)bfd->data); |
| 148 | return 1; |
| 149 | } |
| 150 | |
| 151 | static void ipaccess_bsc_keepalive_fsm_alloc(struct e1inp_ts *e1i_ts, struct osmo_fd *bfd, const char *id) |
| 152 | { |
| 153 | struct e1inp_line *line = e1i_ts->line; |
| 154 | struct osmo_fsm_inst *ka_fsm; |
| 155 | |
| 156 | ipaccess_keepalive_fsm_cleanup(e1i_ts); |
| 157 | if (!line->ipa_kap) |
| 158 | return; |
| 159 | |
| 160 | ka_fsm = ipa_generic_conn_alloc_keepalive_fsm(tall_ipa_ctx, bfd, line->ipa_kap, id); |
| 161 | e1i_ts->driver.ipaccess.ka_fsm = ka_fsm; |
| 162 | if (!ka_fsm) |
| 163 | return; |
| 164 | |
| 165 | ipa_keepalive_fsm_set_timeout_cb(ka_fsm, ipa_bsc_keepalive_timeout_cb); |
| 166 | ipa_keepalive_fsm_set_send_cb(ka_fsm, ipa_bsc_keepalive_write_server_cb); |
| 167 | ipa_keepalive_fsm_start(ka_fsm); |
| 168 | } |
| 169 | |
| 170 | static void ipa_bts_keepalive_write_client_cb(struct osmo_fsm_inst *fi, void *conn, struct msgb *msg) { |
| 171 | struct ipa_client_conn *link = (struct ipa_client_conn *)conn; |
| 172 | int ret = 0; |
| 173 | |
| 174 | ret = ipa_send(link->ofd->fd, msg->data, msg->len); |
| 175 | if (ret != msg->len) { |
| 176 | LOGP(DLINP, LOGL_ERROR, "cannot send message. Reason: %s\n", strerror(errno)); |
| 177 | } |
| 178 | msgb_free(msg); |
| 179 | } |
| 180 | |
| 181 | static void update_fd_settings(struct e1inp_line *line, int fd); |
| 182 | static void ipaccess_bts_updown_cb(struct ipa_client_conn *link, int up); |
| 183 | |
| 184 | static int ipa_bts_keepalive_timeout_cb(struct osmo_fsm_inst *fi, void *conn) { |
| 185 | ipaccess_bts_updown_cb(conn, false); |
| 186 | return 1; |
| 187 | } |
| 188 | |
| 189 | static void ipaccess_bts_keepalive_fsm_alloc(struct e1inp_ts *e1i_ts, struct ipa_client_conn *client, const char *id) |
| 190 | { |
| 191 | struct e1inp_line *line = e1i_ts->line; |
| 192 | struct osmo_fsm_inst *ka_fsm; |
| 193 | |
| 194 | ipaccess_keepalive_fsm_cleanup(e1i_ts); |
| 195 | if (!line->ipa_kap) |
| 196 | return; |
| 197 | |
| 198 | ka_fsm = ipa_client_conn_alloc_keepalive_fsm(client, line->ipa_kap, id); |
| 199 | e1i_ts->driver.ipaccess.ka_fsm = ka_fsm; |
| 200 | if (!ka_fsm) |
| 201 | return; |
| 202 | |
| 203 | ipa_keepalive_fsm_set_timeout_cb(ka_fsm, ipa_bts_keepalive_timeout_cb); |
| 204 | ipa_keepalive_fsm_set_send_cb(ka_fsm, ipa_bts_keepalive_write_client_cb); |
| 205 | } |
| 206 | |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 207 | /* Returns -1 on error, and 0 or 1 on success. If -1 or 1 is returned, line has |
| 208 | * been released and should not be used anymore by the caller. */ |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 209 | static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, |
| 210 | struct osmo_fd *bfd) |
| 211 | { |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 212 | struct tlv_parsed tlvp; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 213 | uint8_t msg_type = *(msg->l2h); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 214 | struct ipaccess_unit unit_data = {}; |
| 215 | struct e1inp_sign_link *sign_link; |
| 216 | char *unitid; |
| 217 | int len, ret; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 218 | struct e1inp_ts *e1i_ts; |
| 219 | struct osmo_fsm_inst *ka_fsm; |
| 220 | |
| 221 | /* peek the pong for our keepalive fsm */ |
| 222 | e1i_ts = ipaccess_line_ts(bfd, line); |
| 223 | ka_fsm = e1i_ts->driver.ipaccess.ka_fsm; |
| 224 | if (ka_fsm && msg_type == IPAC_MSGT_PONG) |
| 225 | ipa_keepalive_fsm_pong_received(ka_fsm); |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 226 | |
Pablo Neira Ayuso | eb43413 | 2011-07-07 19:19:46 +0200 | [diff] [blame] | 227 | /* Handle IPA PING, PONG and ID_ACK messages. */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 228 | ret = ipa_ccm_rcvmsg_base(msg, bfd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 229 | switch(ret) { |
| 230 | case -1: |
| 231 | /* error in IPA control message handling */ |
| 232 | goto err; |
| 233 | case 1: |
| 234 | /* this is an IPA control message, skip further processing */ |
Pablo Neira Ayuso | eb43413 | 2011-07-07 19:19:46 +0200 | [diff] [blame] | 235 | return 0; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 236 | case 0: |
| 237 | /* this is not an IPA control message, continue */ |
| 238 | break; |
| 239 | default: |
| 240 | LOGP(DLINP, LOGL_ERROR, "Unexpected return from " |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 241 | "ipa_ccm_rcvmsg_base " |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 242 | "(ret=%d)\n", ret); |
| 243 | goto err; |
| 244 | } |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 245 | |
| 246 | switch (msg_type) { |
| 247 | case IPAC_MSGT_ID_RESP: |
Pau Espin Pedrol | 30e80d5 | 2020-07-14 13:23:05 +0200 | [diff] [blame] | 248 | DEBUGP(DLMI, "ID_RESP "); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 249 | /* parse tags, search for Unit ID */ |
Harald Welte | 82eb55e | 2018-08-01 13:22:55 +0200 | [diff] [blame] | 250 | ret = ipa_ccm_id_resp_parse(&tlvp, (const uint8_t *)msg->l2h+1, msgb_l2len(msg)-1); |
Pau Espin Pedrol | 30e80d5 | 2020-07-14 13:23:05 +0200 | [diff] [blame] | 251 | DEBUGPC(DLMI, "\n"); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 252 | if (ret < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 253 | LOGP(DLINP, LOGL_ERROR, "IPA response message " |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 254 | "with malformed TLVs\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 255 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 256 | } |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 257 | if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT)) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 258 | LOGP(DLINP, LOGL_ERROR, "IPA response message " |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 259 | "without unit ID\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 260 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 261 | |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 262 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 263 | len = TLVP_LEN(&tlvp, IPAC_IDTAG_UNIT); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 264 | if (len < 1) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 265 | LOGP(DLINP, LOGL_ERROR, "IPA response message " |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 266 | "with too small unit ID\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 267 | goto err; |
| 268 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 269 | unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT); |
| 270 | unitid[len - 1] = '\0'; |
Vadim Yanitskiy | 1c94f6a | 2019-12-02 02:16:07 +0700 | [diff] [blame] | 271 | ret = ipa_parse_unitid(unitid, &unit_data); |
| 272 | if (ret) { |
| 273 | LOGP(DLINP, LOGL_ERROR, "Failed to parse unit ID '%s'\n", unitid); |
| 274 | goto err; |
| 275 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 276 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 277 | if (!line->ops->sign_link_up) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 278 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | cd8d2e5 | 2011-07-02 17:05:21 +0200 | [diff] [blame] | 279 | "Unable to set signal link, closing socket.\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 280 | goto err; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 281 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 282 | /* the BSC creates the new sign links at this stage. */ |
| 283 | if (bfd->priv_nr == E1INP_SIGN_OML) { |
| 284 | sign_link = |
| 285 | line->ops->sign_link_up(&unit_data, line, |
| 286 | E1INP_SIGN_OML); |
| 287 | if (sign_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 288 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | cd8d2e5 | 2011-07-02 17:05:21 +0200 | [diff] [blame] | 289 | "Unable to set signal link, " |
| 290 | "closing socket.\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 291 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 292 | } |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 293 | |
| 294 | ipaccess_bsc_keepalive_fsm_alloc(e1i_ts, bfd, "oml_bsc_to_bts"); |
| 295 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 296 | } else if (bfd->priv_nr == E1INP_SIGN_RSL) { |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 297 | struct e1inp_ts *ts; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 298 | struct osmo_fd *newbfd; |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 299 | struct e1inp_line *new_line; |
Michael Iedema | ee2589e | 2022-05-03 07:27:38 -0700 | [diff] [blame] | 300 | char tcp_stat_name[64]; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 301 | |
| 302 | sign_link = |
| 303 | line->ops->sign_link_up(&unit_data, line, |
| 304 | E1INP_SIGN_RSL); |
| 305 | if (sign_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 306 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | cd8d2e5 | 2011-07-02 17:05:21 +0200 | [diff] [blame] | 307 | "Unable to set signal link, " |
| 308 | "closing socket.\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 309 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 310 | } |
Pau Espin Pedrol | 8a4e3d9 | 2020-07-14 21:20:55 +0200 | [diff] [blame] | 311 | /* Finally, we know which OML link is associated with |
| 312 | * this RSL link, attach it to this socket. */ |
| 313 | new_line = sign_link->ts->line; |
Pablo Neira Ayuso | db1c8a7 | 2011-07-08 15:12:03 +0200 | [diff] [blame] | 314 | /* this is a bugtrap, the BSC should be using the |
| 315 | * virtual E1 line used by OML for this RSL link. */ |
Pau Espin Pedrol | 8a4e3d9 | 2020-07-14 21:20:55 +0200 | [diff] [blame] | 316 | if (new_line == line) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 317 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | db1c8a7 | 2011-07-08 15:12:03 +0200 | [diff] [blame] | 318 | "Fix your BSC, you should use the " |
| 319 | "E1 line used by the OML link for " |
| 320 | "your RSL link.\n"); |
| 321 | return 0; |
| 322 | } |
Pau Espin Pedrol | 5196cd5 | 2020-07-14 17:52:09 +0200 | [diff] [blame] | 323 | e1inp_line_get2(new_line, "ipa_bfd"); |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 324 | ts = e1inp_line_ipa_rsl_ts(new_line, unit_data.trx_id); |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 325 | newbfd = &ts->driver.ipaccess.fd; |
Pau Espin Pedrol | 815117c | 2020-07-14 21:19:16 +0200 | [diff] [blame] | 326 | OSMO_ASSERT(newbfd != bfd); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 327 | |
Pau Espin Pedrol | 56ae85f | 2018-08-22 13:11:19 +0200 | [diff] [blame] | 328 | /* preserve 'newbfd->when' flags potentially set by sign_link_up() */ |
Pau Espin Pedrol | 67902bb | 2018-08-23 14:35:08 +0200 | [diff] [blame] | 329 | osmo_fd_setup(newbfd, bfd->fd, newbfd->when | bfd->when, bfd->cb, |
Pau Espin Pedrol | 8a4e3d9 | 2020-07-14 21:20:55 +0200 | [diff] [blame] | 330 | new_line, E1INP_SIGN_RSL + unit_data.trx_id); |
| 331 | |
| 332 | |
| 333 | /* now we can release the dummy RSL line (old temporary bfd). */ |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 334 | osmo_fd_unregister(bfd); |
| 335 | bfd->fd = -1; |
Pau Espin Pedrol | 8a4e3d9 | 2020-07-14 21:20:55 +0200 | [diff] [blame] | 336 | /* bfd->data holds a reference to line, drop it */ |
| 337 | OSMO_ASSERT(bfd->data == line); |
| 338 | bfd->data = NULL; |
| 339 | e1inp_line_put2(line, "ipa_bfd"); |
| 340 | |
Harald Welte | ae3a993 | 2016-11-26 09:25:23 +0100 | [diff] [blame] | 341 | ret = osmo_fd_register(newbfd); |
| 342 | if (ret < 0) { |
| 343 | LOGP(DLINP, LOGL_ERROR, |
| 344 | "could not register FD\n"); |
| 345 | goto err; |
| 346 | } |
Michael Iedema | ee2589e | 2022-05-03 07:27:38 -0700 | [diff] [blame] | 347 | snprintf(tcp_stat_name, sizeof(tcp_stat_name), "site.%u.bts.%u.ipa-rsl.%u", |
| 348 | unit_data.site_id, unit_data.bts_id, unit_data.trx_id); |
Michael Iedema | 2966786 | 2022-02-24 09:25:20 -0800 | [diff] [blame] | 349 | osmo_stats_tcp_osmo_fd_register(newbfd, tcp_stat_name); |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 350 | |
| 351 | e1i_ts = ipaccess_line_ts(newbfd, new_line); |
| 352 | ipaccess_bsc_keepalive_fsm_alloc(e1i_ts, newbfd, "rsl_bsc_to_bts"); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 353 | return 1; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 354 | } |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 355 | break; |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 356 | default: |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 357 | LOGP(DLINP, LOGL_ERROR, "Unknown IPA message type\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 358 | goto err; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 359 | } |
| 360 | return 0; |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 361 | err: |
Harald Welte | b4a7db0 | 2019-07-21 11:51:56 +0200 | [diff] [blame] | 362 | if (bfd->fd != -1) { |
Pau Espin Pedrol | dc55a5f | 2020-07-14 21:14:34 +0200 | [diff] [blame] | 363 | osmo_fd_unregister(bfd); |
Harald Welte | b4a7db0 | 2019-07-21 11:51:56 +0200 | [diff] [blame] | 364 | close(bfd->fd); |
| 365 | bfd->fd = -1; |
Pau Espin Pedrol | dc55a5f | 2020-07-14 21:14:34 +0200 | [diff] [blame] | 366 | /* This is a BSC accepted socket, bfd->data holds a reference to line, drop it */ |
| 367 | OSMO_ASSERT(bfd->data == line); |
| 368 | bfd->data = NULL; |
| 369 | e1inp_line_put2(line, "ipa_bfd"); |
Harald Welte | b4a7db0 | 2019-07-21 11:51:56 +0200 | [diff] [blame] | 370 | } |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 371 | return -1; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 372 | } |
| 373 | |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 374 | /* Returns -EBADF if bfd cannot be used by the caller anymore after return. */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 375 | static int handle_ts1_read(struct osmo_fd *bfd) |
| 376 | { |
| 377 | struct e1inp_line *line = bfd->data; |
| 378 | unsigned int ts_nr = bfd->priv_nr; |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 379 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 380 | struct e1inp_sign_link *link; |
| 381 | struct ipaccess_head *hh; |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 382 | struct msgb *msg = NULL; |
Max | c9fa25e | 2017-01-09 13:23:15 +0100 | [diff] [blame] | 383 | int ret, rc; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 384 | |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 385 | e1i_ts = ipaccess_line_ts(bfd, line); |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 386 | ret = ipa_msg_recv_buffered(bfd->fd, &msg, &e1i_ts->pending_msg); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 387 | if (ret < 0) { |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 388 | if (ret == -EAGAIN) |
| 389 | return 0; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 390 | LOGP(DLINP, LOGL_NOTICE, "Sign link problems, " |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 391 | "closing socket. Reason: %s\n", strerror(-ret)); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 392 | goto err; |
| 393 | } else if (ret == 0) { |
| 394 | LOGP(DLINP, LOGL_NOTICE, "Sign link vanished, dead socket\n"); |
| 395 | goto err; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 396 | } |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 397 | DEBUGP(DLMI, "RX %u: %s\n", ts_nr, osmo_hexdump(msgb_l2(msg), msgb_l2len(msg))); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 398 | |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 399 | hh = (struct ipaccess_head *) msg->data; |
| 400 | if (hh->proto == IPAC_PROTO_IPACCESS) { |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 401 | ret = ipaccess_rcvmsg(line, msg, bfd); |
| 402 | /* BIG FAT WARNING: bfd might no longer exist here (ret != 0), |
| 403 | * since ipaccess_rcvmsg() might have free'd it !!! */ |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 404 | msgb_free(msg); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 405 | return ret != 0 ? -EBADF : 0; |
Holger Hans Peter Freyther | 63ddf46 | 2013-12-28 21:19:19 +0100 | [diff] [blame] | 406 | } else if (e1i_ts->type == E1INP_TS_TYPE_NONE) { |
| 407 | /* this sign link is not know yet.. complain. */ |
| 408 | LOGP(DLINP, LOGL_ERROR, "Timeslot is not configured.\n"); |
Holger Hans Peter Freyther | 63ddf46 | 2013-12-28 21:19:19 +0100 | [diff] [blame] | 409 | goto err_msg; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 410 | } |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 411 | |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 412 | link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0); |
| 413 | if (!link) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 414 | LOGP(DLINP, LOGL_ERROR, "no matching signalling link for " |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 415 | "hh->proto=0x%02x\n", hh->proto); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 416 | goto err_msg; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 417 | } |
| 418 | msg->dst = link; |
| 419 | |
| 420 | /* XXX better use e1inp_ts_rx? */ |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 421 | if (!e1i_ts->line->ops->sign_link) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 422 | LOGP(DLINP, LOGL_ERROR, "Fix your application, " |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 423 | "no action set for signalling messages.\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 424 | goto err_msg; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 425 | } |
Max | c9fa25e | 2017-01-09 13:23:15 +0100 | [diff] [blame] | 426 | rc = e1i_ts->line->ops->sign_link(msg); |
| 427 | if (rc < 0) { |
Pablo Neira Ayuso | a49c24d | 2012-10-16 11:24:08 +0200 | [diff] [blame] | 428 | /* Don't close the signalling link if the upper layers report |
| 429 | * an error, that's too strict. BTW, the signalling layer is |
| 430 | * resposible for releasing the message. |
| 431 | */ |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 432 | LOGP(DLINP, LOGL_ERROR, "Bad signalling message," |
Max | c9fa25e | 2017-01-09 13:23:15 +0100 | [diff] [blame] | 433 | " sign_link returned error: %s.\n", strerror(-rc)); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 434 | } |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 435 | |
Pau Espin Pedrol | ed122f3 | 2018-08-28 18:25:02 +0200 | [diff] [blame] | 436 | return rc; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 437 | err_msg: |
| 438 | msgb_free(msg); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 439 | err: |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 440 | ipaccess_drop(bfd, line); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 441 | return -EBADF; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 442 | } |
| 443 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 444 | static int ts_want_write(struct e1inp_ts *e1i_ts) |
| 445 | { |
Harald Welte | 949b8a2 | 2020-10-18 23:01:53 +0200 | [diff] [blame] | 446 | osmo_fd_write_enable(&e1i_ts->driver.ipaccess.fd); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 447 | |
| 448 | return 0; |
| 449 | } |
| 450 | |
Pablo Neira Ayuso | add3ec8 | 2011-07-05 14:45:46 +0200 | [diff] [blame] | 451 | static void ipaccess_close(struct e1inp_sign_link *sign_link) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 452 | { |
Pablo Neira Ayuso | add3ec8 | 2011-07-05 14:45:46 +0200 | [diff] [blame] | 453 | struct e1inp_ts *e1i_ts = sign_link->ts; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 454 | struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 455 | struct e1inp_line *line = e1i_ts->line; |
Pau Espin Pedrol | 3d3e5af | 2022-09-16 19:10:41 +0200 | [diff] [blame] | 456 | struct osmo_fsm_inst *ka_fsm = e1i_ts->driver.ipaccess.ka_fsm; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 457 | |
Pau Espin Pedrol | 3d3e5af | 2022-09-16 19:10:41 +0200 | [diff] [blame] | 458 | /* depending on caller the fsm might be dead */ |
| 459 | if (ka_fsm) |
| 460 | ipa_keepalive_fsm_stop(ka_fsm); |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 461 | |
Pau Espin Pedrol | 8737ad4 | 2020-07-14 21:11:56 +0200 | [diff] [blame] | 462 | e1inp_int_snd_event(e1i_ts, sign_link, S_L_INP_TEI_DN); |
| 463 | /* the first e1inp_sign_link_destroy call closes the socket. */ |
| 464 | if (bfd->fd != -1) { |
| 465 | osmo_fd_unregister(bfd); |
| 466 | close(bfd->fd); |
| 467 | bfd->fd = -1; |
| 468 | /* If The bfd holds a reference to e1inp_line in ->data (BSC |
| 469 | * accepted() sockets), then release it */ |
| 470 | if (bfd->data == line) { |
| 471 | bfd->data = NULL; |
| 472 | e1inp_line_put2(line, "ipa_bfd"); |
| 473 | } |
| 474 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 475 | } |
| 476 | |
Pau Espin Pedrol | 90df035 | 2022-05-09 12:59:35 +0200 | [diff] [blame] | 477 | static bool e1i_ts_has_pending_tx_msgs(struct e1inp_ts *e1i_ts) |
| 478 | { |
| 479 | struct e1inp_sign_link *link; |
| 480 | llist_for_each_entry(link, &e1i_ts->sign.sign_links, list) { |
| 481 | if (!llist_empty(&link->tx_list)) { |
| 482 | return true; |
| 483 | } |
| 484 | } |
| 485 | return false; |
| 486 | } |
| 487 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 488 | static void timeout_ts1_write(void *data) |
| 489 | { |
| 490 | struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; |
| 491 | |
| 492 | /* trigger write of ts1, due to tx delay timer */ |
Pau Espin Pedrol | 90df035 | 2022-05-09 12:59:35 +0200 | [diff] [blame] | 493 | if (e1i_ts_has_pending_tx_msgs(e1i_ts)) |
| 494 | ts_want_write(e1i_ts); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 495 | } |
| 496 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 497 | static int __handle_ts1_write(struct osmo_fd *bfd, struct e1inp_line *line) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 498 | { |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 499 | unsigned int ts_nr = bfd->priv_nr; |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 500 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 501 | struct e1inp_sign_link *sign_link; |
| 502 | struct msgb *msg; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 503 | int ret; |
| 504 | |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 505 | e1i_ts = ipaccess_line_ts(bfd, line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 506 | |
| 507 | /* get the next msg for this timeslot */ |
| 508 | msg = e1inp_tx_ts(e1i_ts, &sign_link); |
| 509 | if (!msg) { |
| 510 | /* no message after tx delay timer */ |
Harald Welte | 28fea77 | 2022-05-06 19:38:33 +0000 | [diff] [blame] | 511 | osmo_fd_write_disable(bfd); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 512 | return 0; |
| 513 | } |
| 514 | |
| 515 | switch (sign_link->type) { |
| 516 | case E1INP_SIGN_OML: |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 517 | case E1INP_SIGN_RSL: |
Harald Welte | 46fc7e2 | 2014-08-18 19:04:26 +0200 | [diff] [blame] | 518 | case E1INP_SIGN_OSMO: |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 519 | break; |
| 520 | default: |
Pau Espin Pedrol | d20a10c | 2022-05-09 12:45:07 +0200 | [diff] [blame] | 521 | /* leave WRITE flag enabled, come back for more msg */ |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 522 | ret = -EINVAL; |
| 523 | goto out; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | msg->l2h = msg->data; |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 527 | ipa_prepend_header(msg, sign_link->tei); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 528 | |
Vadim Yanitskiy | 77a7cf4 | 2020-11-29 20:39:57 +0100 | [diff] [blame] | 529 | LOGPITS(e1i_ts, DLMI, LOGL_DEBUG, "TX %u: %s\n", ts_nr, |
Pau Espin Pedrol | 3bdf59b | 2020-11-23 13:47:16 +0100 | [diff] [blame] | 530 | osmo_hexdump(msg->l2h, msgb_l2len(msg))); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 531 | |
| 532 | ret = send(bfd->fd, msg->data, msg->len, 0); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 533 | if (ret != msg->len) { |
Pau Espin Pedrol | 3bdf59b | 2020-11-23 13:47:16 +0100 | [diff] [blame] | 534 | LOGPITS(e1i_ts, DLINP, LOGL_ERROR, "failed to send A-bis IPA signalling " |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 535 | "message. Reason: %s\n", strerror(errno)); |
| 536 | goto err; |
| 537 | } |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 538 | |
Harald Welte | 28fea77 | 2022-05-06 19:38:33 +0000 | [diff] [blame] | 539 | /* this is some ancient code that apparently exists to slow down writes towards |
| 540 | * some even more ancient nanoBTS 900 units. See git commit |
| 541 | * d49fc5ae24fc9d44d2b284392ab619cc7a69a876 of openbsc.git (now osmo-bsc.git) */ |
| 542 | if (e1i_ts->sign.delay) { |
| 543 | osmo_fd_write_disable(bfd); |
| 544 | /* set tx delay timer for next event */ |
| 545 | osmo_timer_setup(&e1i_ts->sign.tx_timer, timeout_ts1_write, e1i_ts); |
| 546 | osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); |
Pau Espin Pedrol | 90df035 | 2022-05-09 12:59:35 +0200 | [diff] [blame] | 547 | } else { |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 548 | out: |
Pau Espin Pedrol | 90df035 | 2022-05-09 12:59:35 +0200 | [diff] [blame] | 549 | if (!e1i_ts_has_pending_tx_msgs(e1i_ts)) |
| 550 | osmo_fd_write_disable(bfd); |
| 551 | } |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 552 | msgb_free(msg); |
| 553 | return ret; |
| 554 | err: |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 555 | ipaccess_drop(bfd, line); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 556 | msgb_free(msg); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 557 | return ret; |
| 558 | } |
| 559 | |
Pablo Neira Ayuso | 88136fc | 2011-07-08 16:21:55 +0200 | [diff] [blame] | 560 | static int handle_ts1_write(struct osmo_fd *bfd) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 561 | { |
| 562 | struct e1inp_line *line = bfd->data; |
| 563 | |
| 564 | return __handle_ts1_write(bfd, line); |
| 565 | } |
| 566 | |
Pablo Neira Ayuso | f099567 | 2011-09-08 12:58:38 +0200 | [diff] [blame] | 567 | static int ipaccess_bts_write_cb(struct ipa_client_conn *link) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 568 | { |
| 569 | struct e1inp_line *line = link->line; |
| 570 | |
| 571 | return __handle_ts1_write(link->ofd, line); |
| 572 | } |
| 573 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 574 | /* callback from select.c in case one of the fd's can be read/written */ |
Pablo Neira Ayuso | 495ddb6 | 2011-07-08 21:04:11 +0200 | [diff] [blame] | 575 | int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 576 | { |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 577 | int rc = 0; |
| 578 | |
Harald Welte | de3959e | 2020-10-18 22:28:50 +0200 | [diff] [blame] | 579 | if (what & OSMO_FD_READ) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 580 | rc = handle_ts1_read(bfd); |
Harald Welte | de3959e | 2020-10-18 22:28:50 +0200 | [diff] [blame] | 581 | if (rc != -EBADF && (what & OSMO_FD_WRITE)) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 582 | rc = handle_ts1_write(bfd); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 583 | |
| 584 | return rc; |
| 585 | } |
| 586 | |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 587 | static int ipaccess_line_update(struct e1inp_line *line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 588 | |
| 589 | struct e1inp_driver ipaccess_driver = { |
| 590 | .name = "ipa", |
| 591 | .want_write = ts_want_write, |
| 592 | .line_update = ipaccess_line_update, |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 593 | .close = ipaccess_close, |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 594 | .default_delay = 0, |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 595 | .has_keepalive = 1, |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 596 | }; |
| 597 | |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 598 | static void update_fd_settings(struct e1inp_line *line, int fd) |
| 599 | { |
| 600 | int ret; |
| 601 | int val; |
| 602 | |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 603 | if (line->keepalive_num_probes) { |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 604 | /* Enable TCP keepalive to find out if the connection is gone */ |
| 605 | val = 1; |
| 606 | ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)); |
| 607 | if (ret < 0) |
| 608 | LOGP(DLINP, LOGL_NOTICE, "Failed to set keepalive: %s\n", |
| 609 | strerror(errno)); |
| 610 | else |
| 611 | LOGP(DLINP, LOGL_NOTICE, "Keepalive is set: %i\n", ret); |
| 612 | |
| 613 | #if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) && defined(TCP_KEEPCNT) |
| 614 | /* The following options are not portable! */ |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 615 | val = line->keepalive_idle_timeout > 0 ? |
| 616 | line->keepalive_idle_timeout : |
| 617 | DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 618 | ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, |
| 619 | &val, sizeof(val)); |
| 620 | if (ret < 0) |
| 621 | LOGP(DLINP, LOGL_NOTICE, |
| 622 | "Failed to set keepalive idle time: %s\n", |
| 623 | strerror(errno)); |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 624 | val = line->keepalive_probe_interval > -1 ? |
| 625 | line->keepalive_probe_interval : |
| 626 | DEFAULT_TCP_KEEPALIVE_INTERVAL; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 627 | ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, |
| 628 | &val, sizeof(val)); |
| 629 | if (ret < 0) |
| 630 | LOGP(DLINP, LOGL_NOTICE, |
| 631 | "Failed to set keepalive interval: %s\n", |
| 632 | strerror(errno)); |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 633 | val = line->keepalive_num_probes > 0 ? |
| 634 | line->keepalive_num_probes : |
| 635 | DEFAULT_TCP_KEEPALIVE_RETRY_COUNT; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 636 | ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, |
| 637 | &val, sizeof(val)); |
| 638 | if (ret < 0) |
| 639 | LOGP(DLINP, LOGL_NOTICE, |
| 640 | "Failed to set keepalive count: %s\n", |
| 641 | strerror(errno)); |
Eric Wild | 6eb186c | 2019-06-21 15:26:25 +0200 | [diff] [blame] | 642 | #if defined(TCP_USER_TIMEOUT) |
| 643 | val = 1000 * line->keepalive_num_probes * |
| 644 | line->keepalive_probe_interval + |
| 645 | line->keepalive_idle_timeout; |
| 646 | ret = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, |
| 647 | &val, sizeof(val)); |
| 648 | if (ret < 0) |
| 649 | LOGP(DLINP, LOGL_NOTICE, |
| 650 | "Failed to set user timoeut: %s\n", |
| 651 | strerror(errno)); |
| 652 | #endif |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 653 | #endif |
Holger Hans Peter Freyther | f465a4c | 2014-02-03 09:34:02 +0100 | [diff] [blame] | 654 | } |
Oliver Smith | 62725d0 | 2020-04-17 10:57:46 +0200 | [diff] [blame] | 655 | |
| 656 | val = 1; |
| 657 | ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); |
| 658 | if (ret < 0) |
| 659 | LOGP(DLINP, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 660 | } |
| 661 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 662 | /* callback of the OML listening filedescriptor */ |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 663 | static int ipaccess_bsc_oml_cb(struct ipa_server_link *link, int fd) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 664 | { |
| 665 | int ret; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 666 | int i; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 667 | struct e1inp_line *line; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 668 | struct e1inp_ts *e1i_ts; |
| 669 | struct osmo_fd *bfd; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 670 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 671 | /* clone virtual E1 line for this new OML link. */ |
Pau Espin Pedrol | 5196cd5 | 2020-07-14 17:52:09 +0200 | [diff] [blame] | 672 | line = e1inp_line_clone(tall_ipa_ctx, link->line, "ipa_bfd"); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 673 | if (line == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 674 | LOGP(DLINP, LOGL_ERROR, "could not clone E1 line\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 675 | return -ENOMEM; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 676 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 677 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 678 | /* create virrtual E1 timeslots for signalling */ |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 679 | e1inp_ts_config_sign(e1inp_line_ipa_oml_ts(line), line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 680 | |
| 681 | /* initialize the fds */ |
| 682 | for (i = 0; i < ARRAY_SIZE(line->ts); ++i) |
| 683 | line->ts[i].driver.ipaccess.fd.fd = -1; |
| 684 | |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 685 | e1i_ts = e1inp_line_ipa_oml_ts(line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 686 | |
Pablo Neira Ayuso | 93c6201 | 2011-06-26 19:12:47 +0200 | [diff] [blame] | 687 | bfd = &e1i_ts->driver.ipaccess.fd; |
Harald Welte | de3959e | 2020-10-18 22:28:50 +0200 | [diff] [blame] | 688 | osmo_fd_setup(bfd, fd, OSMO_FD_READ, ipaccess_fd_cb, line, E1INP_SIGN_OML); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 689 | ret = osmo_fd_register(bfd); |
| 690 | if (ret < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 691 | LOGP(DLINP, LOGL_ERROR, "could not register FD\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 692 | goto err_line; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 693 | } |
Philipp Maier | f5f31d3 | 2021-12-06 16:46:40 +0100 | [diff] [blame] | 694 | osmo_stats_tcp_osmo_fd_register(bfd, "ipa-oml"); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 695 | |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 696 | update_fd_settings(line, bfd->fd); |
Daniel Willmann | 8598072 | 2014-01-09 14:30:55 +0100 | [diff] [blame] | 697 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 698 | /* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 699 | ret = ipa_ccm_send_id_req(bfd->fd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 700 | if (ret < 0) { |
| 701 | LOGP(DLINP, LOGL_ERROR, "could not send ID REQ. Reason: %s\n", |
| 702 | strerror(errno)); |
| 703 | goto err_socket; |
| 704 | } |
| 705 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 706 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 707 | err_socket: |
| 708 | osmo_fd_unregister(bfd); |
| 709 | err_line: |
| 710 | close(bfd->fd); |
| 711 | bfd->fd = -1; |
Pau Espin Pedrol | a2ff733 | 2020-07-14 21:12:50 +0200 | [diff] [blame] | 712 | bfd->data = NULL; |
Pau Espin Pedrol | 5196cd5 | 2020-07-14 17:52:09 +0200 | [diff] [blame] | 713 | e1inp_line_put2(line, "ipa_bfd"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 714 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 715 | } |
| 716 | |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 717 | static int ipaccess_bsc_rsl_cb(struct ipa_server_link *link, int fd) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 718 | { |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 719 | struct e1inp_line *line; |
| 720 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 721 | struct osmo_fd *bfd; |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 722 | int i, ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 723 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 724 | /* We don't know yet which OML link to associate it with. Thus, we |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 725 | * allocate a temporary E1 line until we have received ID. */ |
Pau Espin Pedrol | 5196cd5 | 2020-07-14 17:52:09 +0200 | [diff] [blame] | 726 | line = e1inp_line_clone(tall_ipa_ctx, link->line, "ipa_bfd"); |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 727 | if (line == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 728 | LOGP(DLINP, LOGL_ERROR, "could not clone E1 line\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 729 | return -ENOMEM; |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 730 | } |
| 731 | /* initialize the fds */ |
| 732 | for (i = 0; i < ARRAY_SIZE(line->ts); ++i) |
| 733 | line->ts[i].driver.ipaccess.fd.fd = -1; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 734 | |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 735 | /* we need this to initialize this in case to avoid crashes in case |
| 736 | * that the socket is closed before we've seen an ID_RESP. */ |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 737 | e1inp_ts_config_sign(e1inp_line_ipa_oml_ts(line), line); |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 738 | |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 739 | e1i_ts = e1inp_line_ipa_rsl_ts(line, 0); |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 740 | |
| 741 | bfd = &e1i_ts->driver.ipaccess.fd; |
Harald Welte | de3959e | 2020-10-18 22:28:50 +0200 | [diff] [blame] | 742 | osmo_fd_setup(bfd, fd, OSMO_FD_READ, ipaccess_fd_cb, line, E1INP_SIGN_RSL); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 743 | ret = osmo_fd_register(bfd); |
| 744 | if (ret < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 745 | LOGP(DLINP, LOGL_ERROR, "could not register FD\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 746 | goto err_line; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 747 | } |
Philipp Maier | f5f31d3 | 2021-12-06 16:46:40 +0100 | [diff] [blame] | 748 | osmo_stats_tcp_osmo_fd_register(bfd, "ipa-rsl"); |
| 749 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 750 | /* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 751 | ret = ipa_ccm_send_id_req(bfd->fd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 752 | if (ret < 0) { |
| 753 | LOGP(DLINP, LOGL_ERROR, "could not send ID REQ. Reason: %s\n", |
| 754 | strerror(errno)); |
| 755 | goto err_socket; |
| 756 | } |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 757 | update_fd_settings(line, bfd->fd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 758 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 759 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 760 | err_socket: |
| 761 | osmo_fd_unregister(bfd); |
| 762 | err_line: |
| 763 | close(bfd->fd); |
| 764 | bfd->fd = -1; |
Pau Espin Pedrol | a2ff733 | 2020-07-14 21:12:50 +0200 | [diff] [blame] | 765 | bfd->data = NULL; |
Pau Espin Pedrol | 5196cd5 | 2020-07-14 17:52:09 +0200 | [diff] [blame] | 766 | e1inp_line_put2(line, "ipa_bfd"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 767 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 768 | } |
| 769 | |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 770 | #define IPA_STRING_MAX 64 |
| 771 | |
| 772 | static struct msgb * |
Max | 7139352 | 2018-01-08 15:42:00 +0100 | [diff] [blame] | 773 | ipa_bts_id_resp(const struct ipaccess_unit *dev, uint8_t *data, int len, int trx_nr) |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 774 | { |
| 775 | struct msgb *nmsg; |
| 776 | char str[IPA_STRING_MAX]; |
| 777 | uint8_t *tag; |
| 778 | |
| 779 | memset(str, 0, sizeof(str)); |
| 780 | |
| 781 | nmsg = ipa_msg_alloc(0); |
| 782 | if (!nmsg) |
| 783 | return NULL; |
| 784 | |
| 785 | *msgb_put(nmsg, 1) = IPAC_MSGT_ID_RESP; |
| 786 | while (len) { |
| 787 | if (len < 2) { |
| 788 | LOGP(DLINP, LOGL_NOTICE, |
| 789 | "Short read of ipaccess tag\n"); |
| 790 | msgb_free(nmsg); |
| 791 | return NULL; |
| 792 | } |
| 793 | switch (data[1]) { |
| 794 | case IPAC_IDTAG_UNIT: |
| 795 | snprintf(str, sizeof(str), "%u/%u/%u", |
| 796 | dev->site_id, dev->bts_id, trx_nr); |
| 797 | break; |
| 798 | case IPAC_IDTAG_MACADDR: |
| 799 | snprintf(str, sizeof(str), |
| 800 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 801 | dev->mac_addr[0], dev->mac_addr[1], |
| 802 | dev->mac_addr[2], dev->mac_addr[3], |
| 803 | dev->mac_addr[4], dev->mac_addr[5]); |
| 804 | break; |
| 805 | case IPAC_IDTAG_LOCATION1: |
| 806 | if (dev->location1) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 807 | osmo_strlcpy(str, dev->location1, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 808 | break; |
| 809 | case IPAC_IDTAG_LOCATION2: |
| 810 | if (dev->location2) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 811 | osmo_strlcpy(str, dev->location2, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 812 | break; |
| 813 | case IPAC_IDTAG_EQUIPVERS: |
| 814 | if (dev->equipvers) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 815 | osmo_strlcpy(str, dev->equipvers, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 816 | break; |
| 817 | case IPAC_IDTAG_SWVERSION: |
| 818 | if (dev->swversion) |
Neels Hofmeyr | 4c57eef | 2018-07-26 17:28:24 +0200 | [diff] [blame] | 819 | osmo_strlcpy(str, dev->swversion, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 820 | break; |
| 821 | case IPAC_IDTAG_UNITNAME: |
| 822 | snprintf(str, sizeof(str), |
| 823 | "%s-%02x-%02x-%02x-%02x-%02x-%02x", |
| 824 | dev->unit_name, |
| 825 | dev->mac_addr[0], dev->mac_addr[1], |
| 826 | dev->mac_addr[2], dev->mac_addr[3], |
| 827 | dev->mac_addr[4], dev->mac_addr[5]); |
| 828 | break; |
| 829 | case IPAC_IDTAG_SERNR: |
| 830 | if (dev->serno) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 831 | osmo_strlcpy(str, dev->serno, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 832 | break; |
| 833 | default: |
| 834 | LOGP(DLINP, LOGL_NOTICE, |
| 835 | "Unknown ipaccess tag 0x%02x\n", *data); |
| 836 | msgb_free(nmsg); |
| 837 | return NULL; |
| 838 | } |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 839 | |
| 840 | LOGP(DLINP, LOGL_INFO, " tag %d: %s\n", data[1], str); |
| 841 | tag = msgb_put(nmsg, 3 + strlen(str) + 1); |
| 842 | tag[0] = 0x00; |
| 843 | tag[1] = 1 + strlen(str) + 1; |
| 844 | tag[2] = data[1]; |
| 845 | memcpy(tag + 3, str, strlen(str) + 1); |
| 846 | data += 2; |
| 847 | len -= 2; |
| 848 | } |
| 849 | ipa_msg_push_header(nmsg, IPAC_PROTO_IPACCESS); |
| 850 | return nmsg; |
| 851 | } |
| 852 | |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 853 | static struct msgb *ipa_bts_id_ack(void) |
| 854 | { |
| 855 | struct msgb *nmsg2; |
| 856 | |
Pablo Neira Ayuso | 88136fc | 2011-07-08 16:21:55 +0200 | [diff] [blame] | 857 | nmsg2 = ipa_msg_alloc(0); |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 858 | if (!nmsg2) |
| 859 | return NULL; |
| 860 | |
| 861 | *msgb_put(nmsg2, 1) = IPAC_MSGT_ID_ACK; |
Pablo Neira Ayuso | 88136fc | 2011-07-08 16:21:55 +0200 | [diff] [blame] | 862 | ipa_msg_push_header(nmsg2, IPAC_PROTO_IPACCESS); |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 863 | |
| 864 | return nmsg2; |
| 865 | } |
| 866 | |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 867 | static void ipaccess_bts_updown_cb(struct ipa_client_conn *link, int up) |
| 868 | { |
| 869 | struct e1inp_line *line = link->line; |
| 870 | |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 871 | if (up) { |
| 872 | struct osmo_fsm_inst *ka_fsm = ipaccess_line_ts(link->ofd, line)->driver.ipaccess.ka_fsm; |
| 873 | |
| 874 | update_fd_settings(line, link->ofd->fd); |
| 875 | if (ka_fsm && line->ipa_kap) |
| 876 | ipa_keepalive_fsm_start(ka_fsm); |
| 877 | return; |
| 878 | } |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 879 | |
| 880 | if (line->ops->sign_link_down) |
| 881 | line->ops->sign_link_down(line); |
| 882 | } |
| 883 | |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 884 | /* handle incoming message to BTS, check if it is an IPA CCM, and if yes, |
| 885 | * handle it accordingly (PING/PONG/ID_REQ/ID_RESP/ID_ACK) */ |
| 886 | int ipaccess_bts_handle_ccm(struct ipa_client_conn *link, |
| 887 | struct ipaccess_unit *dev, struct msgb *msg) |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 888 | { |
| 889 | struct ipaccess_head *hh = (struct ipaccess_head *) msg->data; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 890 | struct msgb *rmsg; |
| 891 | int ret = 0; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 892 | /* line might not exist if != bsc||bts */ |
| 893 | struct e1inp_line *line = link->line; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 894 | |
| 895 | /* special handling for IPA CCM. */ |
| 896 | if (hh->proto == IPAC_PROTO_IPACCESS) { |
| 897 | uint8_t msg_type = *(msg->l2h); |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 898 | struct osmo_fsm_inst* ka_fsm = NULL; |
| 899 | |
| 900 | /* peek the pong for our keepalive fsm */ |
| 901 | if (line && msg_type == IPAC_MSGT_PONG) { |
| 902 | ka_fsm = ipaccess_line_ts(link->ofd, line)->driver.ipaccess.ka_fsm; |
| 903 | ipa_keepalive_fsm_pong_received(ka_fsm); |
| 904 | } |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 905 | |
| 906 | /* ping, pong and acknowledgment cases. */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 907 | ret = ipa_ccm_rcvmsg_bts_base(msg, link->ofd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 908 | if (ret < 0) |
| 909 | goto err; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 910 | |
| 911 | /* this is a request for identification from the BSC. */ |
| 912 | if (msg_type == IPAC_MSGT_ID_GET) { |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 913 | uint8_t *data = msgb_l2(msg); |
| 914 | int len = msgb_l2len(msg); |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 915 | int trx_nr = 0; |
| 916 | |
| 917 | if (link->ofd->priv_nr >= E1INP_SIGN_RSL) |
| 918 | trx_nr = link->ofd->priv_nr - E1INP_SIGN_RSL; |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 919 | |
Vadim Yanitskiy | 69ae238 | 2019-12-02 02:42:43 +0700 | [diff] [blame] | 920 | LOGP(DLINP, LOGL_NOTICE, "received ID_GET for unit ID %u/%u/%u\n", |
Pau Espin Pedrol | dd95eb6 | 2018-10-02 20:05:28 +0200 | [diff] [blame] | 921 | dev->site_id, dev->bts_id, trx_nr); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 922 | rmsg = ipa_bts_id_resp(dev, data + 1, len - 1, trx_nr); |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 923 | ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 924 | if (ret != rmsg->len) { |
| 925 | LOGP(DLINP, LOGL_ERROR, "cannot send ID_RESP " |
| 926 | "message. Reason: %s\n", strerror(errno)); |
| 927 | goto err_rmsg; |
| 928 | } |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 929 | msgb_free(rmsg); |
| 930 | |
| 931 | /* send ID_ACK. */ |
| 932 | rmsg = ipa_bts_id_ack(); |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 933 | ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 934 | if (ret != rmsg->len) { |
| 935 | LOGP(DLINP, LOGL_ERROR, "cannot send ID_ACK " |
| 936 | "message. Reason: %s\n", strerror(errno)); |
| 937 | goto err_rmsg; |
| 938 | } |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 939 | msgb_free(rmsg); |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 940 | } |
| 941 | return 1; |
| 942 | } |
Harald Welte | 6eddd47 | 2013-06-30 20:18:53 +0200 | [diff] [blame] | 943 | |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 944 | return 0; |
| 945 | |
| 946 | err_rmsg: |
| 947 | msgb_free(rmsg); |
| 948 | err: |
| 949 | ipa_client_conn_close(link); |
| 950 | return -1; |
| 951 | } |
| 952 | |
| 953 | static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg) |
| 954 | { |
| 955 | struct ipaccess_head *hh = (struct ipaccess_head *) msg->data; |
| 956 | struct e1inp_ts *e1i_ts = NULL; |
| 957 | struct e1inp_sign_link *sign_link; |
Neels Hofmeyr | fe67311 | 2018-08-24 17:43:45 +0200 | [diff] [blame] | 958 | uint8_t msg_type = *(msg->l2h); |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 959 | int ret = 0; |
| 960 | |
| 961 | /* special handling for IPA CCM. */ |
| 962 | if (hh->proto == IPAC_PROTO_IPACCESS) { |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 963 | /* this is a request for identification from the BSC. */ |
| 964 | if (msg_type == IPAC_MSGT_ID_GET) { |
| 965 | if (!link->line->ops->sign_link_up) { |
| 966 | LOGP(DLINP, LOGL_ERROR, |
| 967 | "Unable to set signal link, " |
| 968 | "closing socket.\n"); |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 969 | goto err; |
| 970 | } |
| 971 | } |
| 972 | } |
| 973 | |
| 974 | /* core CCM handling */ |
| 975 | ret = ipaccess_bts_handle_ccm(link, link->line->ops->cfg.ipa.dev, msg); |
| 976 | if (ret < 0) |
| 977 | goto err; |
| 978 | |
| 979 | if (ret == 1 && hh->proto == IPAC_PROTO_IPACCESS) { |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 980 | if (msg_type == IPAC_MSGT_ID_GET) { |
Harald Welte | 6eddd47 | 2013-06-30 20:18:53 +0200 | [diff] [blame] | 981 | sign_link = link->line->ops->sign_link_up(msg, |
| 982 | link->line, |
| 983 | link->ofd->priv_nr); |
| 984 | if (sign_link == NULL) { |
| 985 | LOGP(DLINP, LOGL_ERROR, |
| 986 | "Unable to set signal link, " |
| 987 | "closing socket.\n"); |
Harald Welte | 6eddd47 | 2013-06-30 20:18:53 +0200 | [diff] [blame] | 988 | goto err; |
| 989 | } |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 990 | } |
Pablo Neira Ayuso | 84e5cb9 | 2012-08-23 23:41:54 +0200 | [diff] [blame] | 991 | msgb_free(msg); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 992 | return ret; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 993 | } else if (link->port == IPA_TCP_PORT_OML) |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 994 | e1i_ts = e1inp_line_ipa_oml_ts(link->line); |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 995 | else if (link->port == IPA_TCP_PORT_RSL) |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 996 | e1i_ts = e1inp_line_ipa_rsl_ts(link->line, link->ofd->priv_nr - E1INP_SIGN_RSL); |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 997 | |
Pablo Neira Ayuso | b948701 | 2013-07-05 14:38:43 +0200 | [diff] [blame] | 998 | OSMO_ASSERT(e1i_ts != NULL); |
| 999 | |
Neels Hofmeyr | fe67311 | 2018-08-24 17:43:45 +0200 | [diff] [blame] | 1000 | if (e1i_ts->type == E1INP_TS_TYPE_NONE) { |
| 1001 | LOGP(DLINP, LOGL_ERROR, "Signalling link not initialized. Discarding." |
| 1002 | " port=%u msg_type=%u\n", link->port, msg_type); |
Neels Hofmeyr | fe67311 | 2018-08-24 17:43:45 +0200 | [diff] [blame] | 1003 | goto err; |
| 1004 | } |
Pau Espin Pedrol | 7ad2b15 | 2018-08-28 17:37:59 +0200 | [diff] [blame] | 1005 | |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 1006 | /* look up for some existing signaling link. */ |
| 1007 | sign_link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0); |
| 1008 | if (sign_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1009 | LOGP(DLINP, LOGL_ERROR, "no matching signalling link for " |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 1010 | "hh->proto=0x%02x\n", hh->proto); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 1011 | goto err; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 1012 | } |
| 1013 | msg->dst = sign_link; |
| 1014 | |
| 1015 | /* XXX better use e1inp_ts_rx? */ |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 1016 | if (!link->line->ops->sign_link) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1017 | LOGP(DLINP, LOGL_ERROR, "Fix your application, " |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 1018 | "no action set for signalling messages.\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 1019 | goto err; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 1020 | } |
Pau Espin Pedrol | ed122f3 | 2018-08-28 18:25:02 +0200 | [diff] [blame] | 1021 | return link->line->ops->sign_link(msg); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 1022 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 1023 | err: |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 1024 | ipa_client_conn_close(link); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 1025 | msgb_free(msg); |
Pau Espin Pedrol | 7ad2b15 | 2018-08-28 17:37:59 +0200 | [diff] [blame] | 1026 | return -EBADF; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 1027 | } |
| 1028 | |
Pablo Neira Ayuso | d621640 | 2011-08-31 16:47:44 +0200 | [diff] [blame] | 1029 | struct ipaccess_line { |
Oliver Smith | 65ae42c | 2020-01-22 11:24:52 +0100 | [diff] [blame] | 1030 | bool line_already_initialized; |
Pau Espin Pedrol | 92aee51 | 2021-10-11 12:14:36 +0200 | [diff] [blame] | 1031 | struct ipa_client_conn *ipa_cli[NUM_E1_TS]; /* 0=OML, 1+N=TRX_N */ |
Pablo Neira Ayuso | d621640 | 2011-08-31 16:47:44 +0200 | [diff] [blame] | 1032 | }; |
| 1033 | |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 1034 | static int ipaccess_line_update(struct e1inp_line *line) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1035 | { |
| 1036 | int ret = -ENOENT; |
Pablo Neira Ayuso | d621640 | 2011-08-31 16:47:44 +0200 | [diff] [blame] | 1037 | struct ipaccess_line *il; |
| 1038 | |
| 1039 | if (!line->driver_data) |
| 1040 | line->driver_data = talloc_zero(line, struct ipaccess_line); |
| 1041 | |
| 1042 | if (!line->driver_data) { |
| 1043 | LOGP(DLINP, LOGL_ERROR, "ipaccess: OOM in line update\n"); |
| 1044 | return -ENOMEM; |
| 1045 | } |
| 1046 | il = line->driver_data; |
| 1047 | |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 1048 | switch(line->ops->cfg.ipa.role) { |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1049 | case E1INP_LINE_R_BSC: { |
Pau Espin Pedrol | d2d28d8 | 2021-09-29 14:15:56 +0200 | [diff] [blame] | 1050 | /* We only initialize this line once. */ |
| 1051 | if (il->line_already_initialized) |
| 1052 | return 0; |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1053 | struct ipa_server_link *oml_link, *rsl_link; |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 1054 | const char *ipa = e1inp_ipa_get_bind_addr(); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1055 | |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 1056 | LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BSC mode on %s " |
| 1057 | "with OML %u and RSL %u TCP ports\n", ipa, |
| 1058 | IPA_TCP_PORT_OML, IPA_TCP_PORT_RSL); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1059 | |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 1060 | oml_link = ipa_server_link_create(tall_ipa_ctx, line, ipa, |
Neels Hofmeyr | 0db1d43 | 2016-02-22 13:29:09 +0100 | [diff] [blame] | 1061 | IPA_TCP_PORT_OML, |
Pablo Neira Ayuso | e009f4a | 2011-06-23 13:36:34 +0200 | [diff] [blame] | 1062 | ipaccess_bsc_oml_cb, NULL); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1063 | if (oml_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1064 | LOGP(DLINP, LOGL_ERROR, "cannot create OML " |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1065 | "BSC link: %s\n", strerror(errno)); |
| 1066 | return -ENOMEM; |
Pablo Neira Ayuso | f67471f | 2011-06-07 11:25:49 +0200 | [diff] [blame] | 1067 | } |
Harald Welte | 4154755 | 2021-04-28 18:23:21 +0200 | [diff] [blame] | 1068 | oml_link->dscp = g_e1inp_ipaccess_pars.oml.dscp; |
| 1069 | oml_link->priority = g_e1inp_ipaccess_pars.oml.priority; |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1070 | if (ipa_server_link_open(oml_link) < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1071 | LOGP(DLINP, LOGL_ERROR, "cannot open OML BSC link: %s\n", |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1072 | strerror(errno)); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1073 | ipa_server_link_destroy(oml_link); |
| 1074 | return -EIO; |
Pablo Neira Ayuso | f67471f | 2011-06-07 11:25:49 +0200 | [diff] [blame] | 1075 | } |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 1076 | rsl_link = ipa_server_link_create(tall_ipa_ctx, line, ipa, |
Neels Hofmeyr | 0db1d43 | 2016-02-22 13:29:09 +0100 | [diff] [blame] | 1077 | IPA_TCP_PORT_RSL, |
Pablo Neira Ayuso | e009f4a | 2011-06-23 13:36:34 +0200 | [diff] [blame] | 1078 | ipaccess_bsc_rsl_cb, NULL); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1079 | if (rsl_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1080 | LOGP(DLINP, LOGL_ERROR, "cannot create RSL " |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1081 | "BSC link: %s\n", strerror(errno)); |
| 1082 | return -ENOMEM; |
| 1083 | } |
Harald Welte | 4154755 | 2021-04-28 18:23:21 +0200 | [diff] [blame] | 1084 | rsl_link->dscp = g_e1inp_ipaccess_pars.rsl.dscp; |
| 1085 | rsl_link->priority = g_e1inp_ipaccess_pars.rsl.priority; |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1086 | if (ipa_server_link_open(rsl_link) < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1087 | LOGP(DLINP, LOGL_ERROR, "cannot open RSL BSC link: %s\n", |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1088 | strerror(errno)); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1089 | ipa_server_link_destroy(rsl_link); |
| 1090 | return -EIO; |
| 1091 | } |
| 1092 | ret = 0; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1093 | break; |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 1094 | } |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1095 | case E1INP_LINE_R_BTS: { |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1096 | struct ipa_client_conn *link; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 1097 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1098 | |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 1099 | LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BTS mode, " |
| 1100 | "OML connecting to %s:%u\n", line->ops->cfg.ipa.addr, |
| 1101 | IPA_TCP_PORT_OML); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1102 | |
Pau Espin Pedrol | d2d28d8 | 2021-09-29 14:15:56 +0200 | [diff] [blame] | 1103 | /* Drop previous line */ |
Pau Espin Pedrol | 92aee51 | 2021-10-11 12:14:36 +0200 | [diff] [blame] | 1104 | if (il->ipa_cli[0]) { |
| 1105 | ipa_client_conn_close(il->ipa_cli[0]); |
| 1106 | ipa_client_conn_destroy(il->ipa_cli[0]); |
| 1107 | il->ipa_cli[0] = NULL; |
Pau Espin Pedrol | d2d28d8 | 2021-09-29 14:15:56 +0200 | [diff] [blame] | 1108 | } |
| 1109 | |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 1110 | link = ipa_client_conn_create2(tall_ipa_ctx, |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 1111 | e1inp_line_ipa_oml_ts(line), |
Pablo Neira Ayuso | 00af772 | 2011-09-08 12:47:06 +0200 | [diff] [blame] | 1112 | E1INP_SIGN_OML, |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 1113 | NULL, 0, |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 1114 | line->ops->cfg.ipa.addr, |
| 1115 | IPA_TCP_PORT_OML, |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 1116 | ipaccess_bts_updown_cb, |
Harald Welte | a3e9dd5 | 2013-06-30 14:25:07 +0200 | [diff] [blame] | 1117 | ipaccess_bts_read_cb, |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 1118 | ipaccess_bts_write_cb, |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 1119 | line); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1120 | if (link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1121 | LOGP(DLINP, LOGL_ERROR, "cannot create OML " |
Pablo Neira Ayuso | 29465d3 | 2011-06-21 14:21:33 +0200 | [diff] [blame] | 1122 | "BTS link: %s\n", strerror(errno)); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1123 | return -ENOMEM; |
| 1124 | } |
Harald Welte | 4154755 | 2021-04-28 18:23:21 +0200 | [diff] [blame] | 1125 | link->dscp = g_e1inp_ipaccess_pars.oml.dscp; |
| 1126 | link->priority = g_e1inp_ipaccess_pars.oml.priority; |
Pablo Neira Ayuso | f099567 | 2011-09-08 12:58:38 +0200 | [diff] [blame] | 1127 | if (ipa_client_conn_open(link) < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 1128 | LOGP(DLINP, LOGL_ERROR, "cannot open OML BTS link: %s\n", |
Pablo Neira Ayuso | 29465d3 | 2011-06-21 14:21:33 +0200 | [diff] [blame] | 1129 | strerror(errno)); |
Pablo Neira Ayuso | f099567 | 2011-09-08 12:58:38 +0200 | [diff] [blame] | 1130 | ipa_client_conn_close(link); |
| 1131 | ipa_client_conn_destroy(link); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1132 | return -EIO; |
| 1133 | } |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 1134 | |
| 1135 | e1i_ts = e1inp_line_ipa_oml_ts(line); |
| 1136 | ipaccess_bts_keepalive_fsm_alloc(e1i_ts, link, "oml_bts_to_bsc"); |
Pau Espin Pedrol | 92aee51 | 2021-10-11 12:14:36 +0200 | [diff] [blame] | 1137 | il->ipa_cli[0] = link; |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1138 | ret = 0; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1139 | break; |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 1140 | } |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1141 | default: |
| 1142 | break; |
| 1143 | } |
Philipp Maier | ea0f1bd | 2021-05-20 21:01:23 +0200 | [diff] [blame] | 1144 | |
| 1145 | il->line_already_initialized = true; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1146 | return ret; |
| 1147 | } |
| 1148 | |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 1149 | /* backwards compatibility */ |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1150 | int e1inp_ipa_bts_rsl_connect(struct e1inp_line *line, |
| 1151 | const char *rem_addr, uint16_t rem_port) |
| 1152 | { |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 1153 | return e1inp_ipa_bts_rsl_connect_n(line, rem_addr, rem_port, 0); |
| 1154 | } |
| 1155 | |
| 1156 | int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line, |
| 1157 | const char *rem_addr, uint16_t rem_port, |
| 1158 | uint8_t trx_nr) |
| 1159 | { |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1160 | struct ipa_client_conn *rsl_link; |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 1161 | struct e1inp_ts *e1i_ts = e1inp_line_ipa_rsl_ts(line, trx_nr); |
Pau Espin Pedrol | 92aee51 | 2021-10-11 12:14:36 +0200 | [diff] [blame] | 1162 | struct ipaccess_line *il; |
Pau Espin Pedrol | 57a148f | 2022-09-15 18:54:21 +0200 | [diff] [blame] | 1163 | int rc; |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1164 | |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 1165 | if (E1INP_SIGN_RSL+trx_nr-1 >= NUM_E1_TS) { |
| 1166 | LOGP(DLINP, LOGL_ERROR, "cannot create RSL BTS link: " |
| 1167 | "trx_nr (%d) out of range\n", trx_nr); |
| 1168 | return -EINVAL; |
| 1169 | } |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 1170 | |
Pau Espin Pedrol | 57a148f | 2022-09-15 18:54:21 +0200 | [diff] [blame] | 1171 | /* Drop previous line */ |
| 1172 | if ((rc = e1inp_ipa_bts_rsl_close_n(line, trx_nr)) < 0) |
| 1173 | return rc; |
| 1174 | |
Pau Espin Pedrol | 92aee51 | 2021-10-11 12:14:36 +0200 | [diff] [blame] | 1175 | if (!line->driver_data) |
| 1176 | line->driver_data = talloc_zero(line, struct ipaccess_line); |
| 1177 | il = line->driver_data; |
| 1178 | |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 1179 | rsl_link = ipa_client_conn_create2(tall_ipa_ctx, |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 1180 | e1inp_line_ipa_rsl_ts(line, trx_nr), |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 1181 | E1INP_SIGN_RSL+trx_nr, |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 1182 | NULL, 0, |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1183 | rem_addr, rem_port, |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 1184 | ipaccess_bts_updown_cb, |
Harald Welte | a3e9dd5 | 2013-06-30 14:25:07 +0200 | [diff] [blame] | 1185 | ipaccess_bts_read_cb, |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1186 | ipaccess_bts_write_cb, |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 1187 | line); |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1188 | if (rsl_link == NULL) { |
| 1189 | LOGP(DLINP, LOGL_ERROR, "cannot create RSL " |
| 1190 | "BTS link: %s\n", strerror(errno)); |
| 1191 | return -ENOMEM; |
| 1192 | } |
Harald Welte | 4154755 | 2021-04-28 18:23:21 +0200 | [diff] [blame] | 1193 | rsl_link->dscp = g_e1inp_ipaccess_pars.rsl.dscp; |
| 1194 | rsl_link->priority = g_e1inp_ipaccess_pars.rsl.priority; |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1195 | if (ipa_client_conn_open(rsl_link) < 0) { |
| 1196 | LOGP(DLINP, LOGL_ERROR, "cannot open RSL BTS link: %s\n", |
| 1197 | strerror(errno)); |
| 1198 | ipa_client_conn_close(rsl_link); |
| 1199 | ipa_client_conn_destroy(rsl_link); |
| 1200 | return -EIO; |
| 1201 | } |
Eric Wild | ef1f327 | 2019-07-10 18:10:31 +0200 | [diff] [blame] | 1202 | ipaccess_bts_keepalive_fsm_alloc(e1i_ts, rsl_link, "rsl_bts_to_bsc"); |
Pau Espin Pedrol | 92aee51 | 2021-10-11 12:14:36 +0200 | [diff] [blame] | 1203 | il->ipa_cli[1 + trx_nr] = rsl_link; |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 1204 | return 0; |
| 1205 | } |
| 1206 | |
Pau Espin Pedrol | 57a148f | 2022-09-15 18:54:21 +0200 | [diff] [blame] | 1207 | /* Close the underlying IPA TCP socket of an RSL link */ |
| 1208 | int e1inp_ipa_bts_rsl_close_n(struct e1inp_line *line, uint8_t trx_nr) |
| 1209 | { |
| 1210 | struct ipaccess_line *il; |
| 1211 | |
| 1212 | if (E1INP_SIGN_RSL+trx_nr-1 >= NUM_E1_TS) { |
| 1213 | LOGP(DLINP, LOGL_ERROR, |
| 1214 | "cannot close RSL BTS link: trx_nr (%d) out of range\n", trx_nr); |
| 1215 | return -EINVAL; |
| 1216 | } |
| 1217 | |
| 1218 | il = line->driver_data; |
| 1219 | if (!il) |
| 1220 | return 0; /* Nothing to do, no lines created */ |
| 1221 | |
| 1222 | if (il->ipa_cli[1 + trx_nr]) { |
| 1223 | ipa_client_conn_close(il->ipa_cli[1 + trx_nr]); |
| 1224 | ipa_client_conn_destroy(il->ipa_cli[1 + trx_nr]); |
| 1225 | il->ipa_cli[1 + trx_nr] = NULL; |
| 1226 | } |
| 1227 | return 0; |
| 1228 | } |
| 1229 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1230 | void e1inp_ipaccess_init(void) |
| 1231 | { |
Pablo Neira Ayuso | 54b4979 | 2011-06-07 12:15:26 +0200 | [diff] [blame] | 1232 | tall_ipa_ctx = talloc_named_const(libosmo_abis_ctx, 1, "ipa"); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1233 | e1inp_driver_register(&ipaccess_driver); |
| 1234 | } |
Neels Hofmeyr | 0db1d43 | 2016-02-22 13:29:09 +0100 | [diff] [blame] | 1235 | |
| 1236 | void e1inp_ipa_set_bind_addr(const char *ip_bind_addr) |
| 1237 | { |
| 1238 | talloc_free((char*)ipaccess_driver.bind_addr); |
| 1239 | ipaccess_driver.bind_addr = NULL; |
| 1240 | |
| 1241 | if (ip_bind_addr) |
| 1242 | ipaccess_driver.bind_addr = talloc_strdup(tall_ipa_ctx, |
| 1243 | ip_bind_addr); |
| 1244 | } |
| 1245 | |
| 1246 | const char *e1inp_ipa_get_bind_addr(void) |
| 1247 | { |
| 1248 | return ipaccess_driver.bind_addr? |
| 1249 | ipaccess_driver.bind_addr |
| 1250 | : "0.0.0.0"; |
| 1251 | } |