Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1 | /* OpenBSC Abis input driver for ip.access */ |
| 2 | |
| 3 | /* (C) 2009 by Harald Welte <laforge@gnumonks.org> |
| 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> |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 53 | |
Pablo Neira Ayuso | 54b4979 | 2011-06-07 12:15:26 +0200 | [diff] [blame] | 54 | static void *tall_ipa_ctx; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 55 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 56 | #define TS1_ALLOC_SIZE 900 |
| 57 | |
Daniel Willmann | 8598072 | 2014-01-09 14:30:55 +0100 | [diff] [blame] | 58 | #define DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT 30 |
| 59 | #define DEFAULT_TCP_KEEPALIVE_INTERVAL 3 |
| 60 | #define DEFAULT_TCP_KEEPALIVE_RETRY_COUNT 10 |
| 61 | |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 62 | 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] | 63 | { |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 64 | int ret = 1; |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 65 | struct e1inp_ts *e1i_ts; |
| 66 | if (bfd->priv_nr == E1INP_SIGN_OML) |
| 67 | e1i_ts = e1inp_line_ipa_oml_ts(line); |
| 68 | else |
| 69 | e1i_ts = e1inp_line_ipa_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 70 | |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 71 | /* Error case: we did not see any ID_RESP yet for this socket. */ |
| 72 | if (bfd->fd != -1) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 73 | LOGP(DLINP, LOGL_ERROR, "Forcing socket shutdown with " |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 74 | "no signal link set\n"); |
Pablo Neira Ayuso | 9621b41 | 2011-07-07 16:19:21 +0200 | [diff] [blame] | 75 | osmo_fd_unregister(bfd); |
| 76 | close(bfd->fd); |
| 77 | bfd->fd = -1; |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 78 | ret = -ENOENT; |
Pablo Neira Ayuso | 9621b41 | 2011-07-07 16:19:21 +0200 | [diff] [blame] | 79 | } |
Pablo Neira Ayuso | 6cc3f92 | 2012-08-22 13:57:58 +0200 | [diff] [blame] | 80 | |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 81 | msgb_free(e1i_ts->pending_msg); |
| 82 | e1i_ts->pending_msg = NULL; |
| 83 | |
Pablo Neira Ayuso | 6cc3f92 | 2012-08-22 13:57:58 +0200 | [diff] [blame] | 84 | /* e1inp_sign_link_destroy releases the socket descriptors for us. */ |
| 85 | line->ops->sign_link_down(line); |
| 86 | |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 87 | return ret; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 88 | } |
| 89 | |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 90 | /* Returns -1 on error, and 0 or 1 on success. If -1 or 1 is returned, line has |
| 91 | * been released and should not be used anymore by the caller. */ |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 92 | static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, |
| 93 | struct osmo_fd *bfd) |
| 94 | { |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 95 | struct tlv_parsed tlvp; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 96 | uint8_t msg_type = *(msg->l2h); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 97 | struct ipaccess_unit unit_data = {}; |
| 98 | struct e1inp_sign_link *sign_link; |
| 99 | char *unitid; |
| 100 | int len, ret; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 101 | |
Pablo Neira Ayuso | eb43413 | 2011-07-07 19:19:46 +0200 | [diff] [blame] | 102 | /* Handle IPA PING, PONG and ID_ACK messages. */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 103 | ret = ipa_ccm_rcvmsg_base(msg, bfd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 104 | switch(ret) { |
| 105 | case -1: |
| 106 | /* error in IPA control message handling */ |
| 107 | goto err; |
| 108 | case 1: |
| 109 | /* this is an IPA control message, skip further processing */ |
Pablo Neira Ayuso | eb43413 | 2011-07-07 19:19:46 +0200 | [diff] [blame] | 110 | return 0; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 111 | case 0: |
| 112 | /* this is not an IPA control message, continue */ |
| 113 | break; |
| 114 | default: |
| 115 | LOGP(DLINP, LOGL_ERROR, "Unexpected return from " |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 116 | "ipa_ccm_rcvmsg_base " |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 117 | "(ret=%d)\n", ret); |
| 118 | goto err; |
| 119 | } |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 120 | |
| 121 | switch (msg_type) { |
| 122 | case IPAC_MSGT_ID_RESP: |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 123 | DEBUGP(DLMI, "ID_RESP\n"); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 124 | /* parse tags, search for Unit ID */ |
Harald Welte | 82eb55e | 2018-08-01 13:22:55 +0200 | [diff] [blame] | 125 | ret = ipa_ccm_id_resp_parse(&tlvp, (const uint8_t *)msg->l2h+1, msgb_l2len(msg)-1); |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 126 | DEBUGP(DLMI, "\n"); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 127 | if (ret < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 128 | LOGP(DLINP, LOGL_ERROR, "IPA response message " |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 129 | "with malformed TLVs\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 130 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 131 | } |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 132 | if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT)) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 133 | LOGP(DLINP, LOGL_ERROR, "IPA response message " |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 134 | "without unit ID\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 135 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 136 | |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 137 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 138 | len = TLVP_LEN(&tlvp, IPAC_IDTAG_UNIT); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 139 | if (len < 1) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 140 | LOGP(DLINP, LOGL_ERROR, "IPA response message " |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 141 | "with too small unit ID\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 142 | goto err; |
| 143 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 144 | unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT); |
| 145 | unitid[len - 1] = '\0'; |
Vadim Yanitskiy | 1c94f6a | 2019-12-02 02:16:07 +0700 | [diff] [blame] | 146 | ret = ipa_parse_unitid(unitid, &unit_data); |
| 147 | if (ret) { |
| 148 | LOGP(DLINP, LOGL_ERROR, "Failed to parse unit ID '%s'\n", unitid); |
| 149 | goto err; |
| 150 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 151 | |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 152 | if (!line->ops->sign_link_up) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 153 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | cd8d2e5 | 2011-07-02 17:05:21 +0200 | [diff] [blame] | 154 | "Unable to set signal link, closing socket.\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 155 | goto err; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 156 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 157 | /* the BSC creates the new sign links at this stage. */ |
| 158 | if (bfd->priv_nr == E1INP_SIGN_OML) { |
| 159 | sign_link = |
| 160 | line->ops->sign_link_up(&unit_data, line, |
| 161 | E1INP_SIGN_OML); |
| 162 | if (sign_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 163 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | cd8d2e5 | 2011-07-02 17:05:21 +0200 | [diff] [blame] | 164 | "Unable to set signal link, " |
| 165 | "closing socket.\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 166 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 167 | } |
| 168 | } else if (bfd->priv_nr == E1INP_SIGN_RSL) { |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 169 | struct e1inp_ts *ts; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 170 | struct osmo_fd *newbfd; |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 171 | struct e1inp_line *new_line; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 172 | |
| 173 | sign_link = |
| 174 | line->ops->sign_link_up(&unit_data, line, |
| 175 | E1INP_SIGN_RSL); |
| 176 | if (sign_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 177 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | cd8d2e5 | 2011-07-02 17:05:21 +0200 | [diff] [blame] | 178 | "Unable to set signal link, " |
| 179 | "closing socket.\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 180 | goto err; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 181 | } |
Pablo Neira Ayuso | db1c8a7 | 2011-07-08 15:12:03 +0200 | [diff] [blame] | 182 | /* this is a bugtrap, the BSC should be using the |
| 183 | * virtual E1 line used by OML for this RSL link. */ |
| 184 | if (sign_link->ts->line == line) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 185 | LOGP(DLINP, LOGL_ERROR, |
Pablo Neira Ayuso | db1c8a7 | 2011-07-08 15:12:03 +0200 | [diff] [blame] | 186 | "Fix your BSC, you should use the " |
| 187 | "E1 line used by the OML link for " |
| 188 | "your RSL link.\n"); |
| 189 | return 0; |
| 190 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 191 | /* Finally, we know which OML link is associated with |
| 192 | * this RSL link, attach it to this socket. */ |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 193 | bfd->data = new_line = sign_link->ts->line; |
| 194 | e1inp_line_get(new_line); |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 195 | 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] | 196 | newbfd = &ts->driver.ipaccess.fd; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 197 | |
| 198 | /* get rid of our old temporary bfd */ |
Pau Espin Pedrol | 56ae85f | 2018-08-22 13:11:19 +0200 | [diff] [blame] | 199 | /* preserve 'newbfd->when' flags potentially set by sign_link_up() */ |
Pau Espin Pedrol | 67902bb | 2018-08-23 14:35:08 +0200 | [diff] [blame] | 200 | osmo_fd_setup(newbfd, bfd->fd, newbfd->when | bfd->when, bfd->cb, |
Pau Espin Pedrol | 56ae85f | 2018-08-22 13:11:19 +0200 | [diff] [blame] | 201 | bfd->data, E1INP_SIGN_RSL + unit_data.trx_id); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 202 | osmo_fd_unregister(bfd); |
| 203 | bfd->fd = -1; |
Harald Welte | ae3a993 | 2016-11-26 09:25:23 +0100 | [diff] [blame] | 204 | ret = osmo_fd_register(newbfd); |
| 205 | if (ret < 0) { |
| 206 | LOGP(DLINP, LOGL_ERROR, |
| 207 | "could not register FD\n"); |
| 208 | goto err; |
| 209 | } |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 210 | /* now we can release the dummy RSL line. */ |
| 211 | e1inp_line_put(line); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 212 | return 1; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 213 | } |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 214 | break; |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 215 | default: |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 216 | LOGP(DLINP, LOGL_ERROR, "Unknown IPA message type\n"); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 217 | goto err; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 218 | } |
| 219 | return 0; |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 220 | err: |
| 221 | osmo_fd_unregister(bfd); |
Harald Welte | b4a7db0 | 2019-07-21 11:51:56 +0200 | [diff] [blame] | 222 | if (bfd->fd != -1) { |
| 223 | close(bfd->fd); |
| 224 | bfd->fd = -1; |
| 225 | } |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 226 | e1inp_line_put(line); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 227 | return -1; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 228 | } |
| 229 | |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 230 | /* 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] | 231 | static int handle_ts1_read(struct osmo_fd *bfd) |
| 232 | { |
| 233 | struct e1inp_line *line = bfd->data; |
| 234 | unsigned int ts_nr = bfd->priv_nr; |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 235 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 236 | struct e1inp_sign_link *link; |
| 237 | struct ipaccess_head *hh; |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 238 | struct msgb *msg = NULL; |
Max | c9fa25e | 2017-01-09 13:23:15 +0100 | [diff] [blame] | 239 | int ret, rc; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 240 | |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 241 | if (bfd->priv_nr == E1INP_SIGN_OML) |
| 242 | e1i_ts = e1inp_line_ipa_oml_ts(line); |
| 243 | else |
| 244 | e1i_ts = e1inp_line_ipa_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL); |
| 245 | |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 246 | 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] | 247 | if (ret < 0) { |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 248 | if (ret == -EAGAIN) |
| 249 | return 0; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 250 | LOGP(DLINP, LOGL_NOTICE, "Sign link problems, " |
Jacob Erlbeck | 98af3c3 | 2014-03-31 10:53:32 +0200 | [diff] [blame] | 251 | "closing socket. Reason: %s\n", strerror(-ret)); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 252 | goto err; |
| 253 | } else if (ret == 0) { |
| 254 | LOGP(DLINP, LOGL_NOTICE, "Sign link vanished, dead socket\n"); |
| 255 | goto err; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 256 | } |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 257 | 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] | 258 | |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 259 | hh = (struct ipaccess_head *) msg->data; |
| 260 | if (hh->proto == IPAC_PROTO_IPACCESS) { |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 261 | ret = ipaccess_rcvmsg(line, msg, bfd); |
| 262 | /* BIG FAT WARNING: bfd might no longer exist here (ret != 0), |
| 263 | * since ipaccess_rcvmsg() might have free'd it !!! */ |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 264 | msgb_free(msg); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 265 | return ret != 0 ? -EBADF : 0; |
Holger Hans Peter Freyther | 63ddf46 | 2013-12-28 21:19:19 +0100 | [diff] [blame] | 266 | } else if (e1i_ts->type == E1INP_TS_TYPE_NONE) { |
| 267 | /* this sign link is not know yet.. complain. */ |
| 268 | LOGP(DLINP, LOGL_ERROR, "Timeslot is not configured.\n"); |
Holger Hans Peter Freyther | 63ddf46 | 2013-12-28 21:19:19 +0100 | [diff] [blame] | 269 | goto err_msg; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 270 | } |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 271 | |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 272 | link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0); |
| 273 | if (!link) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 274 | LOGP(DLINP, LOGL_ERROR, "no matching signalling link for " |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 275 | "hh->proto=0x%02x\n", hh->proto); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 276 | goto err_msg; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 277 | } |
| 278 | msg->dst = link; |
| 279 | |
| 280 | /* XXX better use e1inp_ts_rx? */ |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 281 | if (!e1i_ts->line->ops->sign_link) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 282 | LOGP(DLINP, LOGL_ERROR, "Fix your application, " |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 283 | "no action set for signalling messages.\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 284 | goto err_msg; |
Pablo Neira Ayuso | 5a4b7c5 | 2011-06-07 14:07:48 +0200 | [diff] [blame] | 285 | } |
Max | c9fa25e | 2017-01-09 13:23:15 +0100 | [diff] [blame] | 286 | rc = e1i_ts->line->ops->sign_link(msg); |
| 287 | if (rc < 0) { |
Pablo Neira Ayuso | a49c24d | 2012-10-16 11:24:08 +0200 | [diff] [blame] | 288 | /* Don't close the signalling link if the upper layers report |
| 289 | * an error, that's too strict. BTW, the signalling layer is |
| 290 | * resposible for releasing the message. |
| 291 | */ |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 292 | LOGP(DLINP, LOGL_ERROR, "Bad signalling message," |
Max | c9fa25e | 2017-01-09 13:23:15 +0100 | [diff] [blame] | 293 | " sign_link returned error: %s.\n", strerror(-rc)); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 294 | } |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 295 | |
Pau Espin Pedrol | ed122f3 | 2018-08-28 18:25:02 +0200 | [diff] [blame] | 296 | return rc; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 297 | err_msg: |
| 298 | msgb_free(msg); |
Pablo Neira Ayuso | 466c546 | 2011-07-07 19:17:20 +0200 | [diff] [blame] | 299 | err: |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 300 | ipaccess_drop(bfd, line); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 301 | return -EBADF; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 302 | } |
| 303 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 304 | static int ts_want_write(struct e1inp_ts *e1i_ts) |
| 305 | { |
| 306 | e1i_ts->driver.ipaccess.fd.when |= BSC_FD_WRITE; |
| 307 | |
| 308 | return 0; |
| 309 | } |
| 310 | |
Pablo Neira Ayuso | add3ec8 | 2011-07-05 14:45:46 +0200 | [diff] [blame] | 311 | static void ipaccess_close(struct e1inp_sign_link *sign_link) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 312 | { |
Pablo Neira Ayuso | add3ec8 | 2011-07-05 14:45:46 +0200 | [diff] [blame] | 313 | struct e1inp_ts *e1i_ts = sign_link->ts; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 314 | struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd; |
Holger Hans Peter Freyther | 55467f0 | 2011-12-28 19:47:07 +0100 | [diff] [blame] | 315 | return e1inp_close_socket(e1i_ts, sign_link, bfd); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 316 | } |
| 317 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 318 | static void timeout_ts1_write(void *data) |
| 319 | { |
| 320 | struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data; |
| 321 | |
| 322 | /* trigger write of ts1, due to tx delay timer */ |
| 323 | ts_want_write(e1i_ts); |
| 324 | } |
| 325 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 326 | 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] | 327 | { |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 328 | unsigned int ts_nr = bfd->priv_nr; |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 329 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 330 | struct e1inp_sign_link *sign_link; |
| 331 | struct msgb *msg; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 332 | int ret; |
| 333 | |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 334 | if (bfd->priv_nr == E1INP_SIGN_OML) |
| 335 | e1i_ts = e1inp_line_ipa_oml_ts(line); |
| 336 | else |
| 337 | e1i_ts = e1inp_line_ipa_rsl_ts(line, bfd->priv_nr - E1INP_SIGN_RSL); |
| 338 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 339 | bfd->when &= ~BSC_FD_WRITE; |
| 340 | |
| 341 | /* get the next msg for this timeslot */ |
| 342 | msg = e1inp_tx_ts(e1i_ts, &sign_link); |
| 343 | if (!msg) { |
| 344 | /* no message after tx delay timer */ |
| 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | switch (sign_link->type) { |
| 349 | case E1INP_SIGN_OML: |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 350 | case E1INP_SIGN_RSL: |
Harald Welte | 46fc7e2 | 2014-08-18 19:04:26 +0200 | [diff] [blame] | 351 | case E1INP_SIGN_OSMO: |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 352 | break; |
| 353 | default: |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 354 | bfd->when |= BSC_FD_WRITE; /* come back for more msg */ |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 355 | ret = -EINVAL; |
| 356 | goto out; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 357 | } |
| 358 | |
| 359 | msg->l2h = msg->data; |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 360 | ipa_prepend_header(msg, sign_link->tei); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 361 | |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 362 | DEBUGP(DLMI, "TX %u: %s\n", ts_nr, osmo_hexdump(msg->l2h, msgb_l2len(msg))); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 363 | |
| 364 | ret = send(bfd->fd, msg->data, msg->len, 0); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 365 | if (ret != msg->len) { |
| 366 | LOGP(DLINP, LOGL_ERROR, "failed to send A-bis IPA signalling " |
| 367 | "message. Reason: %s\n", strerror(errno)); |
| 368 | goto err; |
| 369 | } |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 370 | |
| 371 | /* set tx delay timer for next event */ |
Pablo Neira Ayuso | b26f2fd | 2017-06-07 18:32:13 +0200 | [diff] [blame] | 372 | osmo_timer_setup(&e1i_ts->sign.tx_timer, timeout_ts1_write, e1i_ts); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 373 | |
| 374 | /* Reducing this might break the nanoBTS 900 init. */ |
| 375 | osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay); |
| 376 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 377 | out: |
| 378 | msgb_free(msg); |
| 379 | return ret; |
| 380 | err: |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 381 | ipaccess_drop(bfd, line); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 382 | msgb_free(msg); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 383 | return ret; |
| 384 | } |
| 385 | |
Pablo Neira Ayuso | 88136fc | 2011-07-08 16:21:55 +0200 | [diff] [blame] | 386 | static int handle_ts1_write(struct osmo_fd *bfd) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 387 | { |
| 388 | struct e1inp_line *line = bfd->data; |
| 389 | |
| 390 | return __handle_ts1_write(bfd, line); |
| 391 | } |
| 392 | |
Pablo Neira Ayuso | f099567 | 2011-09-08 12:58:38 +0200 | [diff] [blame] | 393 | static int ipaccess_bts_write_cb(struct ipa_client_conn *link) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 394 | { |
| 395 | struct e1inp_line *line = link->line; |
| 396 | |
| 397 | return __handle_ts1_write(link->ofd, line); |
| 398 | } |
| 399 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 400 | /* 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] | 401 | int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 402 | { |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 403 | int rc = 0; |
| 404 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 405 | if (what & BSC_FD_READ) |
| 406 | rc = handle_ts1_read(bfd); |
Pau Espin Pedrol | 7edc25d | 2018-05-23 14:57:03 +0200 | [diff] [blame] | 407 | if (rc != -EBADF && (what & BSC_FD_WRITE)) |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 408 | rc = handle_ts1_write(bfd); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 409 | |
| 410 | return rc; |
| 411 | } |
| 412 | |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 413 | static int ipaccess_line_update(struct e1inp_line *line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 414 | |
| 415 | struct e1inp_driver ipaccess_driver = { |
| 416 | .name = "ipa", |
| 417 | .want_write = ts_want_write, |
| 418 | .line_update = ipaccess_line_update, |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 419 | .close = ipaccess_close, |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 420 | .default_delay = 0, |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 421 | .has_keepalive = 1, |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 422 | }; |
| 423 | |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 424 | static void update_fd_settings(struct e1inp_line *line, int fd) |
| 425 | { |
| 426 | int ret; |
| 427 | int val; |
| 428 | |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 429 | if (line->keepalive_num_probes) { |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 430 | /* Enable TCP keepalive to find out if the connection is gone */ |
| 431 | val = 1; |
| 432 | ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val)); |
| 433 | if (ret < 0) |
| 434 | LOGP(DLINP, LOGL_NOTICE, "Failed to set keepalive: %s\n", |
| 435 | strerror(errno)); |
| 436 | else |
| 437 | LOGP(DLINP, LOGL_NOTICE, "Keepalive is set: %i\n", ret); |
| 438 | |
| 439 | #if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) && defined(TCP_KEEPCNT) |
| 440 | /* The following options are not portable! */ |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 441 | val = line->keepalive_idle_timeout > 0 ? |
| 442 | line->keepalive_idle_timeout : |
| 443 | DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 444 | ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, |
| 445 | &val, sizeof(val)); |
| 446 | if (ret < 0) |
| 447 | LOGP(DLINP, LOGL_NOTICE, |
| 448 | "Failed to set keepalive idle time: %s\n", |
| 449 | strerror(errno)); |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 450 | val = line->keepalive_probe_interval > -1 ? |
| 451 | line->keepalive_probe_interval : |
| 452 | DEFAULT_TCP_KEEPALIVE_INTERVAL; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 453 | ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, |
| 454 | &val, sizeof(val)); |
| 455 | if (ret < 0) |
| 456 | LOGP(DLINP, LOGL_NOTICE, |
| 457 | "Failed to set keepalive interval: %s\n", |
| 458 | strerror(errno)); |
Jacob Erlbeck | 8fe1571 | 2014-01-09 14:30:58 +0100 | [diff] [blame] | 459 | val = line->keepalive_num_probes > 0 ? |
| 460 | line->keepalive_num_probes : |
| 461 | DEFAULT_TCP_KEEPALIVE_RETRY_COUNT; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 462 | ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, |
| 463 | &val, sizeof(val)); |
| 464 | if (ret < 0) |
| 465 | LOGP(DLINP, LOGL_NOTICE, |
| 466 | "Failed to set keepalive count: %s\n", |
| 467 | strerror(errno)); |
Eric Wild | 6eb186c | 2019-06-21 15:26:25 +0200 | [diff] [blame] | 468 | #if defined(TCP_USER_TIMEOUT) |
| 469 | val = 1000 * line->keepalive_num_probes * |
| 470 | line->keepalive_probe_interval + |
| 471 | line->keepalive_idle_timeout; |
| 472 | ret = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, |
| 473 | &val, sizeof(val)); |
| 474 | if (ret < 0) |
| 475 | LOGP(DLINP, LOGL_NOTICE, |
| 476 | "Failed to set user timoeut: %s\n", |
| 477 | strerror(errno)); |
| 478 | #endif |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 479 | #endif |
Holger Hans Peter Freyther | f465a4c | 2014-02-03 09:34:02 +0100 | [diff] [blame] | 480 | } |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 481 | } |
| 482 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 483 | /* callback of the OML listening filedescriptor */ |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 484 | 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] | 485 | { |
| 486 | int ret; |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 487 | int i; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 488 | struct e1inp_line *line; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 489 | struct e1inp_ts *e1i_ts; |
| 490 | struct osmo_fd *bfd; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 491 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 492 | /* clone virtual E1 line for this new OML link. */ |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 493 | line = e1inp_line_clone(tall_ipa_ctx, link->line); |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 494 | if (line == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 495 | LOGP(DLINP, LOGL_ERROR, "could not clone E1 line\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 496 | return -ENOMEM; |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 497 | } |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 498 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 499 | /* create virrtual E1 timeslots for signalling */ |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 500 | e1inp_ts_config_sign(e1inp_line_ipa_oml_ts(line), line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 501 | |
| 502 | /* initialize the fds */ |
| 503 | for (i = 0; i < ARRAY_SIZE(line->ts); ++i) |
| 504 | line->ts[i].driver.ipaccess.fd.fd = -1; |
| 505 | |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 506 | e1i_ts = e1inp_line_ipa_oml_ts(line); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 507 | |
Pablo Neira Ayuso | 93c6201 | 2011-06-26 19:12:47 +0200 | [diff] [blame] | 508 | bfd = &e1i_ts->driver.ipaccess.fd; |
Pau Espin Pedrol | 56ae85f | 2018-08-22 13:11:19 +0200 | [diff] [blame] | 509 | osmo_fd_setup(bfd, fd, BSC_FD_READ, ipaccess_fd_cb, line, E1INP_SIGN_OML); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 510 | ret = osmo_fd_register(bfd); |
| 511 | if (ret < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 512 | LOGP(DLINP, LOGL_ERROR, "could not register FD\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 513 | goto err_line; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 514 | } |
| 515 | |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 516 | update_fd_settings(line, bfd->fd); |
Daniel Willmann | 8598072 | 2014-01-09 14:30:55 +0100 | [diff] [blame] | 517 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 518 | /* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 519 | ret = ipa_ccm_send_id_req(bfd->fd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 520 | if (ret < 0) { |
| 521 | LOGP(DLINP, LOGL_ERROR, "could not send ID REQ. Reason: %s\n", |
| 522 | strerror(errno)); |
| 523 | goto err_socket; |
| 524 | } |
| 525 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 526 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 527 | err_socket: |
| 528 | osmo_fd_unregister(bfd); |
| 529 | err_line: |
| 530 | close(bfd->fd); |
| 531 | bfd->fd = -1; |
| 532 | e1inp_line_put(line); |
| 533 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 534 | } |
| 535 | |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 536 | 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] | 537 | { |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 538 | struct e1inp_line *line; |
| 539 | struct e1inp_ts *e1i_ts; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 540 | struct osmo_fd *bfd; |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 541 | int i, ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 542 | |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 543 | /* 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] | 544 | * allocate a temporary E1 line until we have received ID. */ |
| 545 | line = e1inp_line_clone(tall_ipa_ctx, link->line); |
| 546 | if (line == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 547 | LOGP(DLINP, LOGL_ERROR, "could not clone E1 line\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 548 | return -ENOMEM; |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 549 | } |
| 550 | /* initialize the fds */ |
| 551 | for (i = 0; i < ARRAY_SIZE(line->ts); ++i) |
| 552 | line->ts[i].driver.ipaccess.fd.fd = -1; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 553 | |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 554 | /* we need this to initialize this in case to avoid crashes in case |
| 555 | * 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] | 556 | e1inp_ts_config_sign(e1inp_line_ipa_oml_ts(line), line); |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 557 | |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 558 | e1i_ts = e1inp_line_ipa_rsl_ts(line, 0); |
Pablo Neira Ayuso | 3832c4f | 2011-07-07 17:47:26 +0200 | [diff] [blame] | 559 | |
| 560 | bfd = &e1i_ts->driver.ipaccess.fd; |
Pau Espin Pedrol | 56ae85f | 2018-08-22 13:11:19 +0200 | [diff] [blame] | 561 | osmo_fd_setup(bfd, fd, BSC_FD_READ, ipaccess_fd_cb, line, E1INP_SIGN_RSL); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 562 | ret = osmo_fd_register(bfd); |
| 563 | if (ret < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 564 | LOGP(DLINP, LOGL_ERROR, "could not register FD\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 565 | goto err_line; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 566 | } |
| 567 | /* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 568 | ret = ipa_ccm_send_id_req(bfd->fd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 569 | if (ret < 0) { |
| 570 | LOGP(DLINP, LOGL_ERROR, "could not send ID REQ. Reason: %s\n", |
| 571 | strerror(errno)); |
| 572 | goto err_socket; |
| 573 | } |
Jacob Erlbeck | a4ec51e | 2014-01-09 14:30:56 +0100 | [diff] [blame] | 574 | update_fd_settings(line, bfd->fd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 575 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 576 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 577 | err_socket: |
| 578 | osmo_fd_unregister(bfd); |
| 579 | err_line: |
| 580 | close(bfd->fd); |
| 581 | bfd->fd = -1; |
| 582 | e1inp_line_put(line); |
| 583 | return ret; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 584 | } |
| 585 | |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 586 | #define IPA_STRING_MAX 64 |
| 587 | |
| 588 | static struct msgb * |
Max | 7139352 | 2018-01-08 15:42:00 +0100 | [diff] [blame] | 589 | 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] | 590 | { |
| 591 | struct msgb *nmsg; |
| 592 | char str[IPA_STRING_MAX]; |
| 593 | uint8_t *tag; |
| 594 | |
| 595 | memset(str, 0, sizeof(str)); |
| 596 | |
| 597 | nmsg = ipa_msg_alloc(0); |
| 598 | if (!nmsg) |
| 599 | return NULL; |
| 600 | |
| 601 | *msgb_put(nmsg, 1) = IPAC_MSGT_ID_RESP; |
| 602 | while (len) { |
| 603 | if (len < 2) { |
| 604 | LOGP(DLINP, LOGL_NOTICE, |
| 605 | "Short read of ipaccess tag\n"); |
| 606 | msgb_free(nmsg); |
| 607 | return NULL; |
| 608 | } |
| 609 | switch (data[1]) { |
| 610 | case IPAC_IDTAG_UNIT: |
| 611 | snprintf(str, sizeof(str), "%u/%u/%u", |
| 612 | dev->site_id, dev->bts_id, trx_nr); |
| 613 | break; |
| 614 | case IPAC_IDTAG_MACADDR: |
| 615 | snprintf(str, sizeof(str), |
| 616 | "%02x:%02x:%02x:%02x:%02x:%02x", |
| 617 | dev->mac_addr[0], dev->mac_addr[1], |
| 618 | dev->mac_addr[2], dev->mac_addr[3], |
| 619 | dev->mac_addr[4], dev->mac_addr[5]); |
| 620 | break; |
| 621 | case IPAC_IDTAG_LOCATION1: |
| 622 | if (dev->location1) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 623 | osmo_strlcpy(str, dev->location1, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 624 | break; |
| 625 | case IPAC_IDTAG_LOCATION2: |
| 626 | if (dev->location2) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 627 | osmo_strlcpy(str, dev->location2, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 628 | break; |
| 629 | case IPAC_IDTAG_EQUIPVERS: |
| 630 | if (dev->equipvers) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 631 | osmo_strlcpy(str, dev->equipvers, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 632 | break; |
| 633 | case IPAC_IDTAG_SWVERSION: |
| 634 | if (dev->swversion) |
Neels Hofmeyr | 4c57eef | 2018-07-26 17:28:24 +0200 | [diff] [blame] | 635 | osmo_strlcpy(str, dev->swversion, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 636 | break; |
| 637 | case IPAC_IDTAG_UNITNAME: |
| 638 | snprintf(str, sizeof(str), |
| 639 | "%s-%02x-%02x-%02x-%02x-%02x-%02x", |
| 640 | dev->unit_name, |
| 641 | dev->mac_addr[0], dev->mac_addr[1], |
| 642 | dev->mac_addr[2], dev->mac_addr[3], |
| 643 | dev->mac_addr[4], dev->mac_addr[5]); |
| 644 | break; |
| 645 | case IPAC_IDTAG_SERNR: |
| 646 | if (dev->serno) |
Stefan Sperling | 961776a | 2018-12-06 13:09:48 +0100 | [diff] [blame] | 647 | osmo_strlcpy(str, dev->serno, sizeof(str)); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 648 | break; |
| 649 | default: |
| 650 | LOGP(DLINP, LOGL_NOTICE, |
| 651 | "Unknown ipaccess tag 0x%02x\n", *data); |
| 652 | msgb_free(nmsg); |
| 653 | return NULL; |
| 654 | } |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 655 | |
| 656 | LOGP(DLINP, LOGL_INFO, " tag %d: %s\n", data[1], str); |
| 657 | tag = msgb_put(nmsg, 3 + strlen(str) + 1); |
| 658 | tag[0] = 0x00; |
| 659 | tag[1] = 1 + strlen(str) + 1; |
| 660 | tag[2] = data[1]; |
| 661 | memcpy(tag + 3, str, strlen(str) + 1); |
| 662 | data += 2; |
| 663 | len -= 2; |
| 664 | } |
| 665 | ipa_msg_push_header(nmsg, IPAC_PROTO_IPACCESS); |
| 666 | return nmsg; |
| 667 | } |
| 668 | |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 669 | static struct msgb *ipa_bts_id_ack(void) |
| 670 | { |
| 671 | struct msgb *nmsg2; |
| 672 | |
Pablo Neira Ayuso | 88136fc | 2011-07-08 16:21:55 +0200 | [diff] [blame] | 673 | nmsg2 = ipa_msg_alloc(0); |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 674 | if (!nmsg2) |
| 675 | return NULL; |
| 676 | |
| 677 | *msgb_put(nmsg2, 1) = IPAC_MSGT_ID_ACK; |
Pablo Neira Ayuso | 88136fc | 2011-07-08 16:21:55 +0200 | [diff] [blame] | 678 | ipa_msg_push_header(nmsg2, IPAC_PROTO_IPACCESS); |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 679 | |
| 680 | return nmsg2; |
| 681 | } |
| 682 | |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 683 | static void ipaccess_bts_updown_cb(struct ipa_client_conn *link, int up) |
| 684 | { |
| 685 | struct e1inp_line *line = link->line; |
| 686 | |
Eric Wild | b824272 | 2019-06-21 13:52:06 +0200 | [diff] [blame] | 687 | if (up) { |
| 688 | update_fd_settings(line, link->ofd->fd); |
| 689 | return; |
| 690 | } |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 691 | |
| 692 | if (line->ops->sign_link_down) |
| 693 | line->ops->sign_link_down(line); |
| 694 | } |
| 695 | |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 696 | /* handle incoming message to BTS, check if it is an IPA CCM, and if yes, |
| 697 | * handle it accordingly (PING/PONG/ID_REQ/ID_RESP/ID_ACK) */ |
| 698 | int ipaccess_bts_handle_ccm(struct ipa_client_conn *link, |
| 699 | struct ipaccess_unit *dev, struct msgb *msg) |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 700 | { |
| 701 | struct ipaccess_head *hh = (struct ipaccess_head *) msg->data; |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 702 | struct msgb *rmsg; |
| 703 | int ret = 0; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 704 | |
| 705 | /* special handling for IPA CCM. */ |
| 706 | if (hh->proto == IPAC_PROTO_IPACCESS) { |
| 707 | uint8_t msg_type = *(msg->l2h); |
| 708 | |
| 709 | /* ping, pong and acknowledgment cases. */ |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 710 | ret = ipa_ccm_rcvmsg_bts_base(msg, link->ofd); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 711 | if (ret < 0) |
| 712 | goto err; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 713 | |
| 714 | /* this is a request for identification from the BSC. */ |
| 715 | if (msg_type == IPAC_MSGT_ID_GET) { |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 716 | uint8_t *data = msgb_l2(msg); |
| 717 | int len = msgb_l2len(msg); |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 718 | int trx_nr = 0; |
| 719 | |
| 720 | if (link->ofd->priv_nr >= E1INP_SIGN_RSL) |
| 721 | trx_nr = link->ofd->priv_nr - E1INP_SIGN_RSL; |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 722 | |
Vadim Yanitskiy | 69ae238 | 2019-12-02 02:42:43 +0700 | [diff] [blame] | 723 | 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] | 724 | dev->site_id, dev->bts_id, trx_nr); |
Harald Welte | e416e2e | 2017-05-26 13:11:59 +0200 | [diff] [blame] | 725 | rmsg = ipa_bts_id_resp(dev, data + 1, len - 1, trx_nr); |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 726 | ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 727 | if (ret != rmsg->len) { |
| 728 | LOGP(DLINP, LOGL_ERROR, "cannot send ID_RESP " |
| 729 | "message. Reason: %s\n", strerror(errno)); |
| 730 | goto err_rmsg; |
| 731 | } |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 732 | msgb_free(rmsg); |
| 733 | |
| 734 | /* send ID_ACK. */ |
| 735 | rmsg = ipa_bts_id_ack(); |
Harald Welte | b65f58f | 2014-08-20 22:04:11 +0200 | [diff] [blame] | 736 | ret = ipa_send(link->ofd->fd, rmsg->data, rmsg->len); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 737 | if (ret != rmsg->len) { |
| 738 | LOGP(DLINP, LOGL_ERROR, "cannot send ID_ACK " |
| 739 | "message. Reason: %s\n", strerror(errno)); |
| 740 | goto err_rmsg; |
| 741 | } |
Pablo Neira Ayuso | dfafe68 | 2011-07-02 14:32:32 +0200 | [diff] [blame] | 742 | msgb_free(rmsg); |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 743 | } |
| 744 | return 1; |
| 745 | } |
Harald Welte | 6eddd47 | 2013-06-30 20:18:53 +0200 | [diff] [blame] | 746 | |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 747 | return 0; |
| 748 | |
| 749 | err_rmsg: |
| 750 | msgb_free(rmsg); |
| 751 | err: |
| 752 | ipa_client_conn_close(link); |
| 753 | return -1; |
| 754 | } |
| 755 | |
| 756 | static int ipaccess_bts_read_cb(struct ipa_client_conn *link, struct msgb *msg) |
| 757 | { |
| 758 | struct ipaccess_head *hh = (struct ipaccess_head *) msg->data; |
| 759 | struct e1inp_ts *e1i_ts = NULL; |
| 760 | struct e1inp_sign_link *sign_link; |
Neels Hofmeyr | fe67311 | 2018-08-24 17:43:45 +0200 | [diff] [blame] | 761 | uint8_t msg_type = *(msg->l2h); |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 762 | int ret = 0; |
| 763 | |
| 764 | /* special handling for IPA CCM. */ |
| 765 | if (hh->proto == IPAC_PROTO_IPACCESS) { |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 766 | /* this is a request for identification from the BSC. */ |
| 767 | if (msg_type == IPAC_MSGT_ID_GET) { |
| 768 | if (!link->line->ops->sign_link_up) { |
| 769 | LOGP(DLINP, LOGL_ERROR, |
| 770 | "Unable to set signal link, " |
| 771 | "closing socket.\n"); |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 772 | goto err; |
| 773 | } |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | /* core CCM handling */ |
| 778 | ret = ipaccess_bts_handle_ccm(link, link->line->ops->cfg.ipa.dev, msg); |
| 779 | if (ret < 0) |
| 780 | goto err; |
| 781 | |
| 782 | if (ret == 1 && hh->proto == IPAC_PROTO_IPACCESS) { |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 783 | if (msg_type == IPAC_MSGT_ID_GET) { |
Harald Welte | 6eddd47 | 2013-06-30 20:18:53 +0200 | [diff] [blame] | 784 | sign_link = link->line->ops->sign_link_up(msg, |
| 785 | link->line, |
| 786 | link->ofd->priv_nr); |
| 787 | if (sign_link == NULL) { |
| 788 | LOGP(DLINP, LOGL_ERROR, |
| 789 | "Unable to set signal link, " |
| 790 | "closing socket.\n"); |
Harald Welte | 6eddd47 | 2013-06-30 20:18:53 +0200 | [diff] [blame] | 791 | goto err; |
| 792 | } |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 793 | } |
Pablo Neira Ayuso | 84e5cb9 | 2012-08-23 23:41:54 +0200 | [diff] [blame] | 794 | msgb_free(msg); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 795 | return ret; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 796 | } else if (link->port == IPA_TCP_PORT_OML) |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 797 | e1i_ts = e1inp_line_ipa_oml_ts(link->line); |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 798 | else if (link->port == IPA_TCP_PORT_RSL) |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 799 | 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] | 800 | |
Pablo Neira Ayuso | b948701 | 2013-07-05 14:38:43 +0200 | [diff] [blame] | 801 | OSMO_ASSERT(e1i_ts != NULL); |
| 802 | |
Neels Hofmeyr | fe67311 | 2018-08-24 17:43:45 +0200 | [diff] [blame] | 803 | if (e1i_ts->type == E1INP_TS_TYPE_NONE) { |
| 804 | LOGP(DLINP, LOGL_ERROR, "Signalling link not initialized. Discarding." |
| 805 | " port=%u msg_type=%u\n", link->port, msg_type); |
Neels Hofmeyr | fe67311 | 2018-08-24 17:43:45 +0200 | [diff] [blame] | 806 | goto err; |
| 807 | } |
Pau Espin Pedrol | 7ad2b15 | 2018-08-28 17:37:59 +0200 | [diff] [blame] | 808 | |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 809 | /* look up for some existing signaling link. */ |
| 810 | sign_link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0); |
| 811 | if (sign_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 812 | LOGP(DLINP, LOGL_ERROR, "no matching signalling link for " |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 813 | "hh->proto=0x%02x\n", hh->proto); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 814 | goto err; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 815 | } |
| 816 | msg->dst = sign_link; |
| 817 | |
| 818 | /* XXX better use e1inp_ts_rx? */ |
Pablo Neira Ayuso | f163d23 | 2011-06-25 18:42:55 +0200 | [diff] [blame] | 819 | if (!link->line->ops->sign_link) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 820 | LOGP(DLINP, LOGL_ERROR, "Fix your application, " |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 821 | "no action set for signalling messages.\n"); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 822 | goto err; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 823 | } |
Pau Espin Pedrol | ed122f3 | 2018-08-28 18:25:02 +0200 | [diff] [blame] | 824 | return link->line->ops->sign_link(msg); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 825 | |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 826 | err: |
Harald Welte | 783715b | 2014-08-17 18:24:51 +0200 | [diff] [blame] | 827 | ipa_client_conn_close(link); |
Pablo Neira Ayuso | 1e40194 | 2012-08-22 14:16:24 +0200 | [diff] [blame] | 828 | msgb_free(msg); |
Pau Espin Pedrol | 7ad2b15 | 2018-08-28 17:37:59 +0200 | [diff] [blame] | 829 | return -EBADF; |
Pablo Neira Ayuso | 591ddad | 2011-06-21 18:16:42 +0200 | [diff] [blame] | 830 | } |
| 831 | |
Pablo Neira Ayuso | d621640 | 2011-08-31 16:47:44 +0200 | [diff] [blame] | 832 | struct ipaccess_line { |
| 833 | int line_already_initialized; |
| 834 | }; |
| 835 | |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 836 | static int ipaccess_line_update(struct e1inp_line *line) |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 837 | { |
| 838 | int ret = -ENOENT; |
Pablo Neira Ayuso | d621640 | 2011-08-31 16:47:44 +0200 | [diff] [blame] | 839 | struct ipaccess_line *il; |
| 840 | |
| 841 | if (!line->driver_data) |
| 842 | line->driver_data = talloc_zero(line, struct ipaccess_line); |
| 843 | |
| 844 | if (!line->driver_data) { |
| 845 | LOGP(DLINP, LOGL_ERROR, "ipaccess: OOM in line update\n"); |
| 846 | return -ENOMEM; |
| 847 | } |
| 848 | il = line->driver_data; |
| 849 | |
| 850 | /* We only initialize this line once. */ |
| 851 | if (il->line_already_initialized) |
| 852 | return 0; |
| 853 | |
| 854 | il->line_already_initialized = 1; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 855 | |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 856 | switch(line->ops->cfg.ipa.role) { |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 857 | case E1INP_LINE_R_BSC: { |
| 858 | struct ipa_server_link *oml_link, *rsl_link; |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 859 | const char *ipa = e1inp_ipa_get_bind_addr(); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 860 | |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 861 | LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BSC mode on %s " |
| 862 | "with OML %u and RSL %u TCP ports\n", ipa, |
| 863 | IPA_TCP_PORT_OML, IPA_TCP_PORT_RSL); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 864 | |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 865 | oml_link = ipa_server_link_create(tall_ipa_ctx, line, ipa, |
Neels Hofmeyr | 0db1d43 | 2016-02-22 13:29:09 +0100 | [diff] [blame] | 866 | IPA_TCP_PORT_OML, |
Pablo Neira Ayuso | e009f4a | 2011-06-23 13:36:34 +0200 | [diff] [blame] | 867 | ipaccess_bsc_oml_cb, NULL); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 868 | if (oml_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 869 | LOGP(DLINP, LOGL_ERROR, "cannot create OML " |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 870 | "BSC link: %s\n", strerror(errno)); |
| 871 | return -ENOMEM; |
Pablo Neira Ayuso | f67471f | 2011-06-07 11:25:49 +0200 | [diff] [blame] | 872 | } |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 873 | if (ipa_server_link_open(oml_link) < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 874 | LOGP(DLINP, LOGL_ERROR, "cannot open OML BSC link: %s\n", |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 875 | strerror(errno)); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 876 | ipa_server_link_destroy(oml_link); |
| 877 | return -EIO; |
Pablo Neira Ayuso | f67471f | 2011-06-07 11:25:49 +0200 | [diff] [blame] | 878 | } |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 879 | rsl_link = ipa_server_link_create(tall_ipa_ctx, line, ipa, |
Neels Hofmeyr | 0db1d43 | 2016-02-22 13:29:09 +0100 | [diff] [blame] | 880 | IPA_TCP_PORT_RSL, |
Pablo Neira Ayuso | e009f4a | 2011-06-23 13:36:34 +0200 | [diff] [blame] | 881 | ipaccess_bsc_rsl_cb, NULL); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 882 | if (rsl_link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 883 | LOGP(DLINP, LOGL_ERROR, "cannot create RSL " |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 884 | "BSC link: %s\n", strerror(errno)); |
| 885 | return -ENOMEM; |
| 886 | } |
| 887 | if (ipa_server_link_open(rsl_link) < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 888 | LOGP(DLINP, LOGL_ERROR, "cannot open RSL BSC link: %s\n", |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 889 | strerror(errno)); |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 890 | ipa_server_link_destroy(rsl_link); |
| 891 | return -EIO; |
| 892 | } |
| 893 | ret = 0; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 894 | break; |
Pablo Neira Ayuso | 986191f | 2011-06-21 19:56:26 +0200 | [diff] [blame] | 895 | } |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 896 | case E1INP_LINE_R_BTS: { |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 897 | struct ipa_client_conn *link; |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 898 | |
Max | 4c4a1c2 | 2016-12-30 15:10:47 +0100 | [diff] [blame] | 899 | LOGP(DLINP, LOGL_NOTICE, "enabling ipaccess BTS mode, " |
| 900 | "OML connecting to %s:%u\n", line->ops->cfg.ipa.addr, |
| 901 | IPA_TCP_PORT_OML); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 902 | |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 903 | link = ipa_client_conn_create2(tall_ipa_ctx, |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 904 | e1inp_line_ipa_oml_ts(line), |
Pablo Neira Ayuso | 00af772 | 2011-09-08 12:47:06 +0200 | [diff] [blame] | 905 | E1INP_SIGN_OML, |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 906 | NULL, 0, |
Pablo Neira Ayuso | 4e862cb | 2011-08-19 18:43:38 +0200 | [diff] [blame] | 907 | line->ops->cfg.ipa.addr, |
| 908 | IPA_TCP_PORT_OML, |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 909 | ipaccess_bts_updown_cb, |
Harald Welte | a3e9dd5 | 2013-06-30 14:25:07 +0200 | [diff] [blame] | 910 | ipaccess_bts_read_cb, |
Pablo Neira Ayuso | c9c4fd3 | 2011-06-30 12:19:42 +0200 | [diff] [blame] | 911 | ipaccess_bts_write_cb, |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 912 | line); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 913 | if (link == NULL) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 914 | LOGP(DLINP, LOGL_ERROR, "cannot create OML " |
Pablo Neira Ayuso | 29465d3 | 2011-06-21 14:21:33 +0200 | [diff] [blame] | 915 | "BTS link: %s\n", strerror(errno)); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 916 | return -ENOMEM; |
| 917 | } |
Pablo Neira Ayuso | f099567 | 2011-09-08 12:58:38 +0200 | [diff] [blame] | 918 | if (ipa_client_conn_open(link) < 0) { |
Harald Welte | cc2241b | 2011-07-19 16:06:06 +0200 | [diff] [blame] | 919 | LOGP(DLINP, LOGL_ERROR, "cannot open OML BTS link: %s\n", |
Pablo Neira Ayuso | 29465d3 | 2011-06-21 14:21:33 +0200 | [diff] [blame] | 920 | strerror(errno)); |
Pablo Neira Ayuso | f099567 | 2011-09-08 12:58:38 +0200 | [diff] [blame] | 921 | ipa_client_conn_close(link); |
| 922 | ipa_client_conn_destroy(link); |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 923 | return -EIO; |
| 924 | } |
| 925 | ret = 0; |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 926 | break; |
Pablo Neira Ayuso | 96e8128 | 2011-06-09 15:06:11 +0200 | [diff] [blame] | 927 | } |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 928 | default: |
| 929 | break; |
| 930 | } |
| 931 | return ret; |
| 932 | } |
| 933 | |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 934 | |
| 935 | /* backwards compatibility */ |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 936 | int e1inp_ipa_bts_rsl_connect(struct e1inp_line *line, |
| 937 | const char *rem_addr, uint16_t rem_port) |
| 938 | { |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 939 | return e1inp_ipa_bts_rsl_connect_n(line, rem_addr, rem_port, 0); |
| 940 | } |
| 941 | |
| 942 | int e1inp_ipa_bts_rsl_connect_n(struct e1inp_line *line, |
| 943 | const char *rem_addr, uint16_t rem_port, |
| 944 | uint8_t trx_nr) |
| 945 | { |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 946 | struct ipa_client_conn *rsl_link; |
| 947 | |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 948 | if (E1INP_SIGN_RSL+trx_nr-1 >= NUM_E1_TS) { |
| 949 | LOGP(DLINP, LOGL_ERROR, "cannot create RSL BTS link: " |
| 950 | "trx_nr (%d) out of range\n", trx_nr); |
| 951 | return -EINVAL; |
| 952 | } |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 953 | |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 954 | rsl_link = ipa_client_conn_create2(tall_ipa_ctx, |
Pau Espin Pedrol | b5cfc6b | 2018-10-02 21:22:18 +0200 | [diff] [blame] | 955 | e1inp_line_ipa_rsl_ts(line, trx_nr), |
Andreas Eversberg | f422a75 | 2014-01-21 14:54:41 +0100 | [diff] [blame] | 956 | E1INP_SIGN_RSL+trx_nr, |
Pau Espin Pedrol | b6e28bf | 2019-11-08 17:30:28 +0100 | [diff] [blame] | 957 | NULL, 0, |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 958 | rem_addr, rem_port, |
Harald Welte | 51de9ca | 2013-06-30 20:13:16 +0200 | [diff] [blame] | 959 | ipaccess_bts_updown_cb, |
Harald Welte | a3e9dd5 | 2013-06-30 14:25:07 +0200 | [diff] [blame] | 960 | ipaccess_bts_read_cb, |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 961 | ipaccess_bts_write_cb, |
Harald Welte | 10b4130 | 2013-06-30 14:05:49 +0200 | [diff] [blame] | 962 | line); |
Harald Welte | 84f67b2 | 2013-06-30 13:13:59 +0200 | [diff] [blame] | 963 | if (rsl_link == NULL) { |
| 964 | LOGP(DLINP, LOGL_ERROR, "cannot create RSL " |
| 965 | "BTS link: %s\n", strerror(errno)); |
| 966 | return -ENOMEM; |
| 967 | } |
| 968 | if (ipa_client_conn_open(rsl_link) < 0) { |
| 969 | LOGP(DLINP, LOGL_ERROR, "cannot open RSL BTS link: %s\n", |
| 970 | strerror(errno)); |
| 971 | ipa_client_conn_close(rsl_link); |
| 972 | ipa_client_conn_destroy(rsl_link); |
| 973 | return -EIO; |
| 974 | } |
| 975 | return 0; |
| 976 | } |
| 977 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 978 | void e1inp_ipaccess_init(void) |
| 979 | { |
Pablo Neira Ayuso | 54b4979 | 2011-06-07 12:15:26 +0200 | [diff] [blame] | 980 | tall_ipa_ctx = talloc_named_const(libosmo_abis_ctx, 1, "ipa"); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 981 | e1inp_driver_register(&ipaccess_driver); |
| 982 | } |
Neels Hofmeyr | 0db1d43 | 2016-02-22 13:29:09 +0100 | [diff] [blame] | 983 | |
| 984 | void e1inp_ipa_set_bind_addr(const char *ip_bind_addr) |
| 985 | { |
| 986 | talloc_free((char*)ipaccess_driver.bind_addr); |
| 987 | ipaccess_driver.bind_addr = NULL; |
| 988 | |
| 989 | if (ip_bind_addr) |
| 990 | ipaccess_driver.bind_addr = talloc_strdup(tall_ipa_ctx, |
| 991 | ip_bind_addr); |
| 992 | } |
| 993 | |
| 994 | const char *e1inp_ipa_get_bind_addr(void) |
| 995 | { |
| 996 | return ipaccess_driver.bind_addr? |
| 997 | ipaccess_driver.bind_addr |
| 998 | : "0.0.0.0"; |
| 999 | } |