blob: e1e314b9bb18a4c678fedc2ce0cc8d0a852527a1 [file] [log] [blame]
Harald Welte5fd8a542009-02-13 02:43:36 +00001/* OpenBSC Abis input driver for ip.access */
2
3/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +02004 * (C) 2010 by Holger Hans Peter Freyther
5 * (C) 2010 by On-Waves
Harald Welte5fd8a542009-02-13 02:43:36 +00006 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +010010 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
Harald Welte5fd8a542009-02-13 02:43:36 +000012 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Harald Welte9af6ddf2011-01-01 15:25:50 +010017 * GNU Affero General Public License for more details.
Harald Welte5fd8a542009-02-13 02:43:36 +000018 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010019 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
Harald Welte5fd8a542009-02-13 02:43:36 +000021 *
22 */
23
24#include <stdio.h>
25#include <unistd.h>
26#include <stdlib.h>
27#include <errno.h>
28#include <string.h>
29#include <time.h>
30#include <sys/fcntl.h>
31#include <sys/types.h>
32#include <sys/socket.h>
33#include <sys/ioctl.h>
34#include <arpa/inet.h>
35
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010036#include <osmocom/core/select.h>
37#include <osmocom/gsm/tlv.h>
38#include <osmocom/core/msgb.h>
39#include <osmocom/core/talloc.h>
Harald Welte5fd8a542009-02-13 02:43:36 +000040#include <openbsc/debug.h>
41#include <openbsc/gsm_data.h>
42#include <openbsc/abis_nm.h>
43#include <openbsc/abis_rsl.h>
44#include <openbsc/subchan_demux.h>
45#include <openbsc/e1_input.h>
Harald Welte4f361fc2009-02-15 15:32:53 +000046#include <openbsc/ipaccess.h>
Harald Welte5540c4c2010-05-19 14:38:50 +020047#include <openbsc/socket.h>
Harald Weltef338a032011-01-14 15:55:42 +010048#include <openbsc/signal.h>
Harald Welte5fd8a542009-02-13 02:43:36 +000049
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +010050#define PRIV_OML 1
51#define PRIV_RSL 2
52
Harald Welte5fd8a542009-02-13 02:43:36 +000053/* data structure for one E1 interface with A-bis */
54struct ia_e1_handle {
55 struct bsc_fd listen_fd;
Harald Welte5c1e4582009-02-15 11:57:29 +000056 struct bsc_fd rsl_listen_fd;
Harald Welteedb37782009-05-01 14:59:07 +000057 struct gsm_network *gsmnet;
Harald Welte5fd8a542009-02-13 02:43:36 +000058};
59
Harald Welteedb37782009-05-01 14:59:07 +000060static struct ia_e1_handle *e1h;
61
62
Holger Hans Peter Freyther6c8c0dd2010-04-04 18:12:37 +020063#define TS1_ALLOC_SIZE 900
Harald Welte5fd8a542009-02-13 02:43:36 +000064
Pablo Neira Ayuso22f58a92011-04-07 14:15:06 +020065/*
66 * Common propietary IPA messages:
67 * - PONG: in reply to PING.
68 * - ID_REQUEST: first messages once OML has been established.
69 * - ID_ACK: in reply to ID_ACK.
70 */
71const u_int8_t ipa_pong_msg[] = {
72 0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_PONG
73};
74
75const u_int8_t ipa_id_ack_msg[] = {
76 0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_ACK
77};
78
79const u_int8_t ipa_id_req_msg[] = {
80 0, 17, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_GET,
81 0x01, IPAC_IDTAG_UNIT,
82 0x01, IPAC_IDTAG_MACADDR,
83 0x01, IPAC_IDTAG_LOCATION1,
84 0x01, IPAC_IDTAG_LOCATION2,
85 0x01, IPAC_IDTAG_EQUIPVERS,
86 0x01, IPAC_IDTAG_SWVERSION,
87 0x01, IPAC_IDTAG_UNITNAME,
88 0x01, IPAC_IDTAG_SERNR,
89};
Harald Welte5fd8a542009-02-13 02:43:36 +000090
Harald Welteedb37782009-05-01 14:59:07 +000091static const char *idtag_names[] = {
92 [IPAC_IDTAG_SERNR] = "Serial_Number",
93 [IPAC_IDTAG_UNITNAME] = "Unit_Name",
94 [IPAC_IDTAG_LOCATION1] = "Location_1",
95 [IPAC_IDTAG_LOCATION2] = "Location_2",
96 [IPAC_IDTAG_EQUIPVERS] = "Equipment_Version",
97 [IPAC_IDTAG_SWVERSION] = "Software_Version",
98 [IPAC_IDTAG_IPADDR] = "IP_Address",
99 [IPAC_IDTAG_MACADDR] = "MAC_Address",
100 [IPAC_IDTAG_UNIT] = "Unit_ID",
101};
102
Pablo Neira Ayuso66add642011-04-07 14:15:11 +0200103const char *ipaccess_idtag_name(int tag)
Harald Welte5fd8a542009-02-13 02:43:36 +0000104{
Harald Welteedb37782009-05-01 14:59:07 +0000105 if (tag >= ARRAY_SIZE(idtag_names))
106 return "unknown";
107
108 return idtag_names[tag];
109}
110
Holger Hans Peter Freytherd3d5be12010-02-09 14:37:23 +0100111int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
Harald Welteedb37782009-05-01 14:59:07 +0000112{
113 u_int8_t t_len;
114 u_int8_t t_tag;
115 u_int8_t *cur = buf;
116
Holger Hans Peter Freyther949e0ba2010-10-14 17:21:04 +0200117 memset(dec, 0, sizeof(*dec));
118
Holger Hans Peter Freytherd9e81d02010-10-14 20:42:45 +0200119 while (len >= 2) {
120 len -= 2;
Harald Welteedb37782009-05-01 14:59:07 +0000121 t_len = *cur++;
122 t_tag = *cur++;
123
Holger Hans Peter Freytherd9e81d02010-10-14 20:42:45 +0200124 if (t_len > len + 1) {
125 LOGP(DMI, LOGL_ERROR, "The tag does not fit: %d\n", t_len);
126 return -1;
127 }
128
Pablo Neira Ayuso66add642011-04-07 14:15:11 +0200129 DEBUGPC(DMI, "%s='%s' ", ipaccess_idtag_name(t_tag), cur);
Harald Welteedb37782009-05-01 14:59:07 +0000130
131 dec->lv[t_tag].len = t_len;
132 dec->lv[t_tag].val = cur;
133
134 cur += t_len;
Holger Hans Peter Freytherd9e81d02010-10-14 20:42:45 +0200135 len -= t_len;
Harald Welteedb37782009-05-01 14:59:07 +0000136 }
137 return 0;
138}
139
140struct gsm_bts *find_bts_by_unitid(struct gsm_network *net,
141 u_int16_t site_id, u_int16_t bts_id)
142{
Harald Weltee441d9c2009-06-21 16:17:15 +0200143 struct gsm_bts *bts;
Harald Welteedb37782009-05-01 14:59:07 +0000144
Harald Weltee441d9c2009-06-21 16:17:15 +0200145 llist_for_each_entry(bts, &net->bts_list, list) {
Harald Welteedb37782009-05-01 14:59:07 +0000146
147 if (!is_ipaccess_bts(bts))
148 continue;
149
150 if (bts->ip_access.site_id == site_id &&
151 bts->ip_access.bts_id == bts_id)
152 return bts;
153 }
154
155 return NULL;
156}
157
Pablo Neira Ayusoc281b4e2011-04-07 14:15:20 +0200158int ipaccess_parse_unitid(const char *str, u_int16_t *site_id,
159 u_int16_t *bts_id, u_int16_t *trx_id)
Harald Welteedb37782009-05-01 14:59:07 +0000160{
161 unsigned long ul;
162 char *endptr;
163 const char *nptr;
164
165 nptr = str;
166 ul = strtoul(nptr, &endptr, 10);
167 if (endptr <= nptr)
168 return -EINVAL;
169 if (site_id)
170 *site_id = ul & 0xffff;
171
172 if (*endptr++ != '/')
173 return -EINVAL;
174
175 nptr = endptr;
176 ul = strtoul(nptr, &endptr, 10);
177 if (endptr <= nptr)
178 return -EINVAL;
179 if (bts_id)
180 *bts_id = ul & 0xffff;
181
182 if (*endptr++ != '/')
183 return -EINVAL;
184
185 nptr = endptr;
186 ul = strtoul(nptr, &endptr, 10);
187 if (endptr <= nptr)
188 return -EINVAL;
189 if (trx_id)
190 *trx_id = ul & 0xffff;
191
192 return 0;
193}
194
Pablo Neira Ayuso22f58a92011-04-07 14:15:06 +0200195static int ipaccess_send(int fd, const void *msg, size_t msglen)
196{
197 int ret;
198
199 ret = write(fd, msg, msglen);
200 if (ret < 0)
201 return ret;
202 if (ret < msglen) {
203 DEBUGP(DINP, "ipaccess_send: short write\n");
204 return -EIO;
205 }
206 return ret;
207}
208
209int ipaccess_send_pong(int fd)
210{
211 return ipaccess_send(fd, ipa_pong_msg, sizeof(ipa_pong_msg));
212}
213
Holger Hans Peter Freyther301e6282010-01-13 09:06:46 +0100214int ipaccess_send_id_ack(int fd)
215{
Pablo Neira Ayuso22f58a92011-04-07 14:15:06 +0200216 return ipaccess_send(fd, ipa_id_ack_msg, sizeof(ipa_id_ack_msg));
Holger Hans Peter Freyther301e6282010-01-13 09:06:46 +0100217}
218
Holger Hans Peter Freyther3bc856b2010-02-07 12:04:07 +0100219int ipaccess_send_id_req(int fd)
220{
Pablo Neira Ayuso22f58a92011-04-07 14:15:06 +0200221 return ipaccess_send(fd, ipa_id_req_msg, sizeof(ipa_id_req_msg));
Holger Hans Peter Freyther3bc856b2010-02-07 12:04:07 +0100222}
223
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200224/* base handling of the ip.access protocol */
225int ipaccess_rcvmsg_base(struct msgb *msg,
226 struct bsc_fd *bfd)
Harald Welteedb37782009-05-01 14:59:07 +0000227{
Harald Welte5fd8a542009-02-13 02:43:36 +0000228 u_int8_t msg_type = *(msg->l2h);
Holger Freytherff9592f2009-03-09 16:17:14 +0000229 int ret = 0;
Harald Welte5fd8a542009-02-13 02:43:36 +0000230
Harald Welte5fd8a542009-02-13 02:43:36 +0000231 switch (msg_type) {
Harald Welte4f361fc2009-02-15 15:32:53 +0000232 case IPAC_MSGT_PING:
Pablo Neira Ayuso22f58a92011-04-07 14:15:06 +0200233 ret = ipaccess_send_pong(bfd->fd);
Harald Welte5fd8a542009-02-13 02:43:36 +0000234 break;
Harald Welte4f361fc2009-02-15 15:32:53 +0000235 case IPAC_MSGT_PONG:
Harald Welte5fd8a542009-02-13 02:43:36 +0000236 DEBUGP(DMI, "PONG!\n");
237 break;
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200238 case IPAC_MSGT_ID_ACK:
239 DEBUGP(DMI, "ID_ACK? -> ACK!\n");
Holger Hans Peter Freyther301e6282010-01-13 09:06:46 +0100240 ret = ipaccess_send_id_ack(bfd->fd);
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200241 break;
242 }
243 return 0;
244}
245
246static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
247 struct bsc_fd *bfd)
248{
249 struct tlv_parsed tlvp;
250 u_int8_t msg_type = *(msg->l2h);
251 u_int16_t site_id = 0, bts_id = 0, trx_id = 0;
252 struct gsm_bts *bts;
Holger Hans Peter Freythere3839802010-10-14 21:17:30 +0200253 char *unitid;
254 int len;
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200255
256 /* handle base messages */
257 ipaccess_rcvmsg_base(msg, bfd);
258
259 switch (msg_type) {
Harald Welte4f361fc2009-02-15 15:32:53 +0000260 case IPAC_MSGT_ID_RESP:
Harald Welteedb37782009-05-01 14:59:07 +0000261 DEBUGP(DMI, "ID_RESP ");
262 /* parse tags, search for Unit ID */
Holger Hans Peter Freytherd3d5be12010-02-09 14:37:23 +0100263 ipaccess_idtag_parse(&tlvp, (u_int8_t *)msg->l2h + 2,
Harald Welteedb37782009-05-01 14:59:07 +0000264 msgb_l2len(msg)-2);
265 DEBUGP(DMI, "\n");
266
267 if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT))
268 break;
269
Holger Hans Peter Freythere3839802010-10-14 21:17:30 +0200270 len = TLVP_LEN(&tlvp, IPAC_IDTAG_UNIT);
271 if (len < 1)
272 break;
273
Harald Welteedb37782009-05-01 14:59:07 +0000274 /* lookup BTS, create sign_link, ... */
Holger Hans Peter Freythere3839802010-10-14 21:17:30 +0200275 unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT);
276 unitid[len - 1] = '\0';
Pablo Neira Ayusoc281b4e2011-04-07 14:15:20 +0200277 ipaccess_parse_unitid(unitid, &site_id, &bts_id, &trx_id);
Harald Welteedb37782009-05-01 14:59:07 +0000278 bts = find_bts_by_unitid(e1h->gsmnet, site_id, bts_id);
279 if (!bts) {
Harald Welteafdca0f2009-12-23 23:01:04 +0100280 LOGP(DINP, LOGL_ERROR, "Unable to find BTS configuration for "
Harald Welteedb37782009-05-01 14:59:07 +0000281 " %u/%u/%u, disconnecting\n", site_id, bts_id,
282 trx_id);
283 return -EIO;
284 }
285 DEBUGP(DINP, "Identified BTS %u/%u/%u\n", site_id, bts_id, trx_id);
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100286 if (bfd->priv_nr == PRIV_OML) {
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200287 /* drop any old oml connection */
288 ipaccess_drop_oml(bts);
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100289 bts->oml_link = e1inp_sign_link_create(&line->ts[PRIV_OML - 1],
Harald Welteedb37782009-05-01 14:59:07 +0000290 E1INP_SIGN_OML, bts->c0,
Harald Welte8175e952009-10-20 00:22:00 +0200291 bts->oml_tei, 0);
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100292 } else if (bfd->priv_nr == PRIV_RSL) {
Harald Welteedb37782009-05-01 14:59:07 +0000293 struct e1inp_ts *e1i_ts;
294 struct bsc_fd *newbfd;
Harald Welte8175e952009-10-20 00:22:00 +0200295 struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_id);
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200296
297 /* drop any old rsl connection */
298 ipaccess_drop_rsl(trx);
299
300 if (!bts->oml_link) {
301 bsc_unregister_fd(bfd);
302 close(bfd->fd);
303 bfd->fd = -1;
304 talloc_free(bfd);
305 return 0;
306 }
307
Harald Welteedb37782009-05-01 14:59:07 +0000308 bfd->data = line = bts->oml_link->ts->line;
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100309 e1i_ts = &line->ts[PRIV_RSL + trx_id - 1];
Harald Welteedb37782009-05-01 14:59:07 +0000310 newbfd = &e1i_ts->driver.ipaccess.fd;
Harald Welte8175e952009-10-20 00:22:00 +0200311 e1inp_ts_config(e1i_ts, line, E1INP_TS_TYPE_SIGN);
Harald Welteedb37782009-05-01 14:59:07 +0000312
Harald Welte8175e952009-10-20 00:22:00 +0200313 trx->rsl_link = e1inp_sign_link_create(e1i_ts,
314 E1INP_SIGN_RSL, trx,
315 trx->rsl_tei, 0);
Holger Hans Peter Freytherd49fc5a2010-11-15 20:36:21 +0100316 trx->rsl_link->ts->sign.delay = 0;
Holger Hans Peter Freyther354ef812010-03-24 04:02:55 +0100317
Harald Welteedb37782009-05-01 14:59:07 +0000318 /* get rid of our old temporary bfd */
319 memcpy(newbfd, bfd, sizeof(*newbfd));
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100320 newbfd->priv_nr = PRIV_RSL + trx_id;
Harald Welteedb37782009-05-01 14:59:07 +0000321 bsc_unregister_fd(bfd);
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200322 bfd->fd = -1;
Harald Weltea4ffea92009-06-22 01:36:25 +0200323 talloc_free(bfd);
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200324 bsc_register_fd(newbfd);
Harald Welteedb37782009-05-01 14:59:07 +0000325 }
Harald Welte5fd8a542009-02-13 02:43:36 +0000326 break;
Harald Welte5fd8a542009-02-13 02:43:36 +0000327 }
Harald Welte5fd8a542009-02-13 02:43:36 +0000328 return 0;
329}
330
Harald Welte88a412a2009-12-16 17:32:37 +0100331#define OML_UP 0x0001
332#define RSL_UP 0x0002
Harald Welte7782c142009-02-15 03:39:51 +0000333
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200334/*
335 * read one ipa message from the socket
336 * return NULL in case of error
337 */
338struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error)
Harald Welte5fd8a542009-02-13 02:43:36 +0000339{
Harald Welte966636f2009-06-26 19:39:35 +0200340 struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP");
Harald Welte5fd8a542009-02-13 02:43:36 +0000341 struct ipaccess_head *hh;
Sylvain Munautd7d1c992009-10-29 16:33:59 +0100342 int len, ret = 0;
Harald Welte5fd8a542009-02-13 02:43:36 +0000343
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200344 if (!msg) {
345 *error = -ENOMEM;
346 return NULL;
347 }
Harald Welte5fd8a542009-02-13 02:43:36 +0000348
349 /* first read our 3-byte header */
350 hh = (struct ipaccess_head *) msg->data;
Holger Hans Peter Freytherb3121c52010-03-24 08:40:55 +0100351 ret = recv(bfd->fd, msg->data, sizeof(*hh), 0);
352 if (ret == 0) {
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200353 msgb_free(msg);
354 *error = ret;
355 return NULL;
Holger Hans Peter Freytherb3121c52010-03-24 08:40:55 +0100356 } else if (ret != sizeof(*hh)) {
357 if (errno != EAGAIN)
358 LOGP(DINP, LOGL_ERROR, "recv error %d %s\n", ret, strerror(errno));
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200359 msgb_free(msg);
360 *error = ret;
361 return NULL;
Harald Welte5fd8a542009-02-13 02:43:36 +0000362 }
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200363
Harald Welte5fd8a542009-02-13 02:43:36 +0000364 msgb_put(msg, ret);
365
366 /* then read te length as specified in header */
367 msg->l2h = msg->data + sizeof(*hh);
Sylvain Munautd7d1c992009-10-29 16:33:59 +0100368 len = ntohs(hh->len);
Holger Hans Peter Freytherb3121c52010-03-24 08:40:55 +0100369
370 if (len < 0 || TS1_ALLOC_SIZE < len + sizeof(*hh)) {
371 LOGP(DINP, LOGL_ERROR, "Can not read this packet. %d avail\n", len);
372 msgb_free(msg);
373 *error = -EIO;
374 return NULL;
375 }
376
Sylvain Munautd7d1c992009-10-29 16:33:59 +0100377 ret = recv(bfd->fd, msg->l2h, len, 0);
378 if (ret < len) {
Holger Hans Peter Freytherb3121c52010-03-24 08:40:55 +0100379 LOGP(DINP, LOGL_ERROR, "short read! Got %d from %d\n", ret, len);
Harald Welte5c1e4582009-02-15 11:57:29 +0000380 msgb_free(msg);
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200381 *error = -EIO;
382 return NULL;
Harald Welte5fd8a542009-02-13 02:43:36 +0000383 }
384 msgb_put(msg, ret);
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200385
386 return msg;
387}
388
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200389int ipaccess_drop_oml(struct gsm_bts *bts)
390{
391 struct gsm_bts_trx *trx;
392 struct e1inp_ts *ts;
393 struct e1inp_line *line;
394 struct bsc_fd *bfd;
395
396 if (!bts || !bts->oml_link)
397 return -1;
398
399 /* send OML down */
400 ts = bts->oml_link->ts;
401 line = ts->line;
Harald Weltef338a032011-01-14 15:55:42 +0100402 e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi);
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200403
404 bfd = &ts->driver.ipaccess.fd;
405 bsc_unregister_fd(bfd);
406 close(bfd->fd);
407 bfd->fd = -1;
408
409 /* clean up OML and RSL */
410 e1inp_sign_link_destroy(bts->oml_link);
411 bts->oml_link = NULL;
412 bts->ip_access.flags = 0;
413
414 /* drop all RSL connections too */
415 llist_for_each_entry(trx, &bts->trx_list, list)
416 ipaccess_drop_rsl(trx);
417
418 /* kill the E1 line now... as we have no one left to use it */
419 talloc_free(line);
420
421 return -1;
422}
423
424static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd)
425{
426 struct e1inp_sign_link *link;
427 int bts_nr;
428
429 if (!ts) {
430 /*
431 * If we don't have a TS this means that this is a RSL
432 * connection but we are not past the authentication
433 * handling yet. So we can safely delete this bfd and
434 * wait for a reconnect.
435 */
436 bsc_unregister_fd(bfd);
437 close(bfd->fd);
438 bfd->fd = -1;
439 talloc_free(bfd);
440 return -1;
441 }
442
443 /* attempt to find a signalling link */
444 if (ts->type == E1INP_TS_TYPE_SIGN) {
445 llist_for_each_entry(link, &ts->sign.sign_links, list) {
446 bts_nr = link->trx->bts->bts_nr;
447 /* we have issues just reconnecting RLS so we drop OML */
448 ipaccess_drop_oml(link->trx->bts);
449 return bts_nr;
450 }
451 }
452
453 /* error case */
454 LOGP(DINP, LOGL_ERROR, "Failed to find a signalling link for ts: %p\n", ts);
455 bsc_unregister_fd(bfd);
456 close(bfd->fd);
457 bfd->fd = -1;
458 return -1;
459}
460
461int ipaccess_drop_rsl(struct gsm_bts_trx *trx)
462{
463 struct bsc_fd *bfd;
464 struct e1inp_ts *ts;
465
466 if (!trx || !trx->rsl_link)
467 return -1;
468
469 /* send RSL down */
470 ts = trx->rsl_link->ts;
Harald Weltef338a032011-01-14 15:55:42 +0100471 e1inp_event(ts, S_INP_TEI_DN, trx->rsl_link->tei, trx->rsl_link->sapi);
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200472
473 /* close the socket */
474 bfd = &ts->driver.ipaccess.fd;
475 bsc_unregister_fd(bfd);
476 close(bfd->fd);
477 bfd->fd = -1;
478
479 /* destroy */
480 e1inp_sign_link_destroy(trx->rsl_link);
481 trx->rsl_link = NULL;
482
483 return -1;
484}
485
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200486static int handle_ts1_read(struct bsc_fd *bfd)
487{
488 struct e1inp_line *line = bfd->data;
489 unsigned int ts_nr = bfd->priv_nr;
490 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
491 struct e1inp_sign_link *link;
492 struct msgb *msg;
493 struct ipaccess_head *hh;
Holger Hans Peter Freyther67b59612009-10-27 10:08:38 +0100494 int ret = 0, error;
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200495
496 msg = ipaccess_read_msg(bfd, &error);
497 if (!msg) {
498 if (error == 0) {
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200499 int ret = ipaccess_drop(e1i_ts, bfd);
500 if (ret >= 0)
Harald Welte (local)7971d3d2009-12-28 17:52:11 +0100501 LOGP(DINP, LOGL_NOTICE, "BTS %u disappeared, dead socket\n",
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200502 ret);
503 else
Harald Welte (local)7971d3d2009-12-28 17:52:11 +0100504 LOGP(DINP, LOGL_NOTICE, "unknown BTS disappeared, dead socket\n");
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200505 }
506 return error;
507 }
508
Sylvain Munaut86538c72009-09-30 22:35:04 +0200509 DEBUGP(DMI, "RX %u: %s\n", ts_nr, hexdump(msgb_l2(msg), msgb_l2len(msg)));
Harald Welte5fd8a542009-02-13 02:43:36 +0000510
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200511 hh = (struct ipaccess_head *) msg->data;
Harald Welteedb37782009-05-01 14:59:07 +0000512 if (hh->proto == IPAC_PROTO_IPACCESS) {
513 ret = ipaccess_rcvmsg(line, msg, bfd);
Holger Hans Peter Freyther70402a42010-04-15 11:17:24 +0200514 if (ret < 0)
515 ipaccess_drop(e1i_ts, bfd);
Harald Welteedb37782009-05-01 14:59:07 +0000516 msgb_free(msg);
517 return ret;
518 }
519 /* BIG FAT WARNING: bfd might no longer exist here, since ipaccess_rcvmsg()
520 * might have free'd it !!! */
521
Harald Welte8175e952009-10-20 00:22:00 +0200522 link = e1inp_lookup_sign_link(e1i_ts, hh->proto, 0);
Harald Welte5fd8a542009-02-13 02:43:36 +0000523 if (!link) {
Harald Welteafdca0f2009-12-23 23:01:04 +0100524 LOGP(DINP, LOGL_ERROR, "no matching signalling link for "
525 "hh->proto=0x%02x\n", hh->proto);
Harald Welte5fd8a542009-02-13 02:43:36 +0000526 msgb_free(msg);
527 return -EIO;
528 }
529 msg->trx = link->trx;
530
Harald Welte8175e952009-10-20 00:22:00 +0200531 switch (link->type) {
532 case E1INP_SIGN_RSL:
Harald Welte1394fea2009-12-21 23:01:33 +0100533 if (!(msg->trx->bts->ip_access.flags & (RSL_UP << msg->trx->nr))) {
Harald Weltef338a032011-01-14 15:55:42 +0100534 e1inp_event(e1i_ts, S_INP_TEI_UP, link->tei, link->sapi);
Harald Welte1394fea2009-12-21 23:01:33 +0100535 msg->trx->bts->ip_access.flags |= (RSL_UP << msg->trx->nr);
Harald Weltee73501a2009-10-21 21:16:00 +0200536 }
Harald Welte5fd8a542009-02-13 02:43:36 +0000537 ret = abis_rsl_rcvmsg(msg);
538 break;
Harald Welte8175e952009-10-20 00:22:00 +0200539 case E1INP_SIGN_OML:
Harald Welte88a412a2009-12-16 17:32:37 +0100540 if (!(msg->trx->bts->ip_access.flags & OML_UP)) {
Harald Weltef338a032011-01-14 15:55:42 +0100541 e1inp_event(e1i_ts, S_INP_TEI_UP, link->tei, link->sapi);
Harald Welte88a412a2009-12-16 17:32:37 +0100542 msg->trx->bts->ip_access.flags |= OML_UP;
Harald Welte7782c142009-02-15 03:39:51 +0000543 }
Harald Welte5fd8a542009-02-13 02:43:36 +0000544 ret = abis_nm_rcvmsg(msg);
545 break;
546 default:
Harald Welteafdca0f2009-12-23 23:01:04 +0100547 LOGP(DINP, LOGL_NOTICE, "Unknown IP.access protocol proto=0x%02x\n", hh->proto);
Harald Welte5fd8a542009-02-13 02:43:36 +0000548 msgb_free(msg);
549 break;
550 }
551 return ret;
552}
553
Holger Hans Peter Freyther5d7b65b2011-04-07 23:31:58 +0200554void ipaccess_prepend_header_ext(struct msgb *msg, int proto)
555{
556 struct ipaccess_head_ext *hh_ext;
557
558 /* prepend the osmo ip.access header extension */
559 hh_ext = (struct ipaccess_head_ext *) msgb_push(msg, sizeof(*hh_ext));
560 hh_ext->proto = proto;
561}
562
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200563void ipaccess_prepend_header(struct msgb *msg, int proto)
564{
565 struct ipaccess_head *hh;
566
567 /* prepend the ip.access header */
568 hh = (struct ipaccess_head *) msgb_push(msg, sizeof(*hh));
Sylvain Munautd7d1c992009-10-29 16:33:59 +0100569 hh->len = htons(msg->len - sizeof(*hh));
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200570 hh->proto = proto;
571}
572
Andreas Eversberg38ae5cb2009-10-08 12:53:16 +0200573static int ts_want_write(struct e1inp_ts *e1i_ts)
574{
575 e1i_ts->driver.ipaccess.fd.when |= BSC_FD_WRITE;
576
577 return 0;
578}
579
580static void timeout_ts1_write(void *data)
581{
582 struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
583
584 /* trigger write of ts1, due to tx delay timer */
585 ts_want_write(e1i_ts);
586}
587
Harald Welte5fd8a542009-02-13 02:43:36 +0000588static int handle_ts1_write(struct bsc_fd *bfd)
589{
590 struct e1inp_line *line = bfd->data;
591 unsigned int ts_nr = bfd->priv_nr;
592 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
593 struct e1inp_sign_link *sign_link;
594 struct msgb *msg;
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200595 u_int8_t proto;
Harald Welte5fd8a542009-02-13 02:43:36 +0000596 int ret;
597
Andreas Eversberg38ae5cb2009-10-08 12:53:16 +0200598 bfd->when &= ~BSC_FD_WRITE;
599
Harald Welte5fd8a542009-02-13 02:43:36 +0000600 /* get the next msg for this timeslot */
601 msg = e1inp_tx_ts(e1i_ts, &sign_link);
602 if (!msg) {
Andreas Eversberg38ae5cb2009-10-08 12:53:16 +0200603 /* no message after tx delay timer */
Harald Welte5fd8a542009-02-13 02:43:36 +0000604 return 0;
605 }
606
Harald Welte5fd8a542009-02-13 02:43:36 +0000607 switch (sign_link->type) {
608 case E1INP_SIGN_OML:
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200609 proto = IPAC_PROTO_OML;
Harald Welte5fd8a542009-02-13 02:43:36 +0000610 break;
611 case E1INP_SIGN_RSL:
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200612 proto = IPAC_PROTO_RSL;
Harald Welte5fd8a542009-02-13 02:43:36 +0000613 break;
614 default:
615 msgb_free(msg);
Andreas Eversberg38ae5cb2009-10-08 12:53:16 +0200616 bfd->when |= BSC_FD_WRITE; /* come back for more msg */
Harald Welte5fd8a542009-02-13 02:43:36 +0000617 return -EINVAL;
618 }
619
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200620 msg->l2h = msg->data;
Harald Welte8175e952009-10-20 00:22:00 +0200621 ipaccess_prepend_header(msg, sign_link->tei);
Holger Hans Peter Freytherd5f05222009-08-18 10:05:45 +0200622
623 DEBUGP(DMI, "TX %u: %s\n", ts_nr, hexdump(msg->l2h, msgb_l2len(msg)));
Harald Welte5fd8a542009-02-13 02:43:36 +0000624
625 ret = send(bfd->fd, msg->data, msg->len, 0);
626 msgb_free(msg);
Andreas Eversberg38ae5cb2009-10-08 12:53:16 +0200627
628 /* set tx delay timer for next event */
629 e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
630 e1i_ts->sign.tx_timer.data = e1i_ts;
Holger Hans Peter Freyther63cb4472010-04-11 10:10:04 +0200631
632 /* Reducing this might break the nanoBTS 900 init. */
Holger Hans Peter Freytherd85642a2010-04-26 16:02:04 +0800633 bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
Harald Welte5fd8a542009-02-13 02:43:36 +0000634
635 return ret;
636}
637
Harald Welte5fd8a542009-02-13 02:43:36 +0000638/* callback from select.c in case one of the fd's can be read/written */
639static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what)
640{
641 struct e1inp_line *line = bfd->data;
642 unsigned int ts_nr = bfd->priv_nr;
643 unsigned int idx = ts_nr-1;
Harald Welteedb37782009-05-01 14:59:07 +0000644 struct e1inp_ts *e1i_ts;
Harald Welte5fd8a542009-02-13 02:43:36 +0000645 int rc = 0;
646
Harald Welteedb37782009-05-01 14:59:07 +0000647 /* In case of early RSL we might not yet have a line */
648
649 if (line)
650 e1i_ts = &line->ts[idx];
651
652 if (!line || e1i_ts->type == E1INP_TS_TYPE_SIGN) {
Harald Welte5fd8a542009-02-13 02:43:36 +0000653 if (what & BSC_FD_READ)
654 rc = handle_ts1_read(bfd);
655 if (what & BSC_FD_WRITE)
656 rc = handle_ts1_write(bfd);
Harald Welteedb37782009-05-01 14:59:07 +0000657 } else
Harald Welteafdca0f2009-12-23 23:01:04 +0100658 LOGP(DINP, LOGL_ERROR, "unknown E1 TS type %u\n", e1i_ts->type);
Harald Welte5fd8a542009-02-13 02:43:36 +0000659
660 return rc;
661}
662
Harald Welte5fd8a542009-02-13 02:43:36 +0000663struct e1inp_driver ipaccess_driver = {
664 .name = "ip.access",
665 .want_write = ts_want_write,
Holger Hans Peter Freytherd49fc5a2010-11-15 20:36:21 +0100666 .default_delay = 0,
Harald Welte5fd8a542009-02-13 02:43:36 +0000667};
668
Harald Welteedb37782009-05-01 14:59:07 +0000669/* callback of the OML listening filedescriptor */
Harald Welte5fd8a542009-02-13 02:43:36 +0000670static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
671{
Harald Welte5fd8a542009-02-13 02:43:36 +0000672 int ret;
Harald Welteedb37782009-05-01 14:59:07 +0000673 int idx = 0;
Holger Hans Peter Freytheredee7942010-03-24 11:20:27 +0100674 int i;
Harald Welteedb37782009-05-01 14:59:07 +0000675 struct e1inp_line *line;
676 struct e1inp_ts *e1i_ts;
677 struct bsc_fd *bfd;
678 struct sockaddr_in sa;
679 socklen_t sa_len = sizeof(sa);
Harald Welte5fd8a542009-02-13 02:43:36 +0000680
Harald Welteedb37782009-05-01 14:59:07 +0000681 if (!(what & BSC_FD_READ))
682 return 0;
Harald Welte5fd8a542009-02-13 02:43:36 +0000683
Harald Welteedb37782009-05-01 14:59:07 +0000684 ret = accept(listen_bfd->fd, (struct sockaddr *) &sa, &sa_len);
685 if (ret < 0) {
686 perror("accept");
687 return ret;
Harald Welte5fd8a542009-02-13 02:43:36 +0000688 }
Harald Welteafdca0f2009-12-23 23:01:04 +0100689 LOGP(DINP, LOGL_NOTICE, "accept()ed new OML link from %s\n",
690 inet_ntoa(sa.sin_addr));
Harald Welteedb37782009-05-01 14:59:07 +0000691
Holger Hans Peter Freyther5ea73132009-10-29 02:29:45 +0100692 line = talloc_zero(tall_bsc_ctx, struct e1inp_line);
Harald Welteedb37782009-05-01 14:59:07 +0000693 if (!line) {
694 close(ret);
695 return -ENOMEM;
696 }
Harald Welteedb37782009-05-01 14:59:07 +0000697 line->driver = &ipaccess_driver;
698 //line->driver_data = e1h;
699 /* create virrtual E1 timeslots for signalling */
700 e1inp_ts_config(&line->ts[1-1], line, E1INP_TS_TYPE_SIGN);
Harald Welteedb37782009-05-01 14:59:07 +0000701
Holger Hans Peter Freytheredee7942010-03-24 11:20:27 +0100702 /* initialize the fds */
703 for (i = 0; i < ARRAY_SIZE(line->ts); ++i)
704 line->ts[i].driver.ipaccess.fd.fd = -1;
705
Harald Welteedb37782009-05-01 14:59:07 +0000706 e1i_ts = &line->ts[idx];
707
708 bfd = &e1i_ts->driver.ipaccess.fd;
709 bfd->fd = ret;
710 bfd->data = line;
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100711 bfd->priv_nr = PRIV_OML;
Harald Welteedb37782009-05-01 14:59:07 +0000712 bfd->cb = ipaccess_fd_cb;
713 bfd->when = BSC_FD_READ;
714 ret = bsc_register_fd(bfd);
715 if (ret < 0) {
Harald Welteafdca0f2009-12-23 23:01:04 +0100716 LOGP(DINP, LOGL_ERROR, "could not register FD\n");
Harald Welteedb37782009-05-01 14:59:07 +0000717 close(bfd->fd);
Harald Weltea4ffea92009-06-22 01:36:25 +0200718 talloc_free(line);
Harald Welteedb37782009-05-01 14:59:07 +0000719 return ret;
720 }
721
722 /* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
Holger Hans Peter Freyther3bc856b2010-02-07 12:04:07 +0100723 ret = ipaccess_send_id_req(bfd->fd);
Harald Welteedb37782009-05-01 14:59:07 +0000724
Holger Hans Peter Freyther09e364b2009-08-10 07:59:27 +0200725 return ret;
Harald Welte42581822009-08-08 16:12:58 +0200726 //return e1inp_line_register(line);
Harald Welte5fd8a542009-02-13 02:43:36 +0000727}
728
Harald Welte5c1e4582009-02-15 11:57:29 +0000729static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
730{
Harald Welteedb37782009-05-01 14:59:07 +0000731 struct sockaddr_in sa;
732 socklen_t sa_len = sizeof(sa);
Harald Weltea4ffea92009-06-22 01:36:25 +0200733 struct bsc_fd *bfd;
Harald Welte5c1e4582009-02-15 11:57:29 +0000734 int ret;
735
Harald Welteedb37782009-05-01 14:59:07 +0000736 if (!(what & BSC_FD_READ))
737 return 0;
Harald Welte5c1e4582009-02-15 11:57:29 +0000738
Holger Hans Peter Freyther5ea73132009-10-29 02:29:45 +0100739 bfd = talloc_zero(tall_bsc_ctx, struct bsc_fd);
Harald Weltea4ffea92009-06-22 01:36:25 +0200740 if (!bfd)
741 return -ENOMEM;
Harald Weltea4ffea92009-06-22 01:36:25 +0200742
Harald Welteedb37782009-05-01 14:59:07 +0000743 /* Some BTS has connected to us, but we don't know yet which line
744 * (as created by the OML link) to associate it with. Thus, we
Holger Hans Peter Freytherc7df7c62009-11-15 13:50:39 +0100745 * allocate a temporary bfd until we have received ID from BTS */
Harald Welteedb37782009-05-01 14:59:07 +0000746
747 bfd->fd = accept(listen_bfd->fd, (struct sockaddr *) &sa, &sa_len);
748 if (bfd->fd < 0) {
749 perror("accept");
750 return bfd->fd;
Harald Welte5c1e4582009-02-15 11:57:29 +0000751 }
Harald Welteafdca0f2009-12-23 23:01:04 +0100752 LOGP(DINP, LOGL_NOTICE, "accept()ed new RSL link from %s\n", inet_ntoa(sa.sin_addr));
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100753 bfd->priv_nr = PRIV_RSL;
Harald Welteedb37782009-05-01 14:59:07 +0000754 bfd->cb = ipaccess_fd_cb;
755 bfd->when = BSC_FD_READ;
756 ret = bsc_register_fd(bfd);
757 if (ret < 0) {
Harald Welteafdca0f2009-12-23 23:01:04 +0100758 LOGP(DINP, LOGL_ERROR, "could not register FD\n");
Harald Welteedb37782009-05-01 14:59:07 +0000759 close(bfd->fd);
Harald Weltea4ffea92009-06-22 01:36:25 +0200760 talloc_free(bfd);
Harald Welteedb37782009-05-01 14:59:07 +0000761 return ret;
762 }
763 /* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
Pablo Neira Ayuso22f58a92011-04-07 14:15:06 +0200764 ret = ipaccess_send_id_req(bfd->fd);
Harald Welteedb37782009-05-01 14:59:07 +0000765
Harald Welte5c1e4582009-02-15 11:57:29 +0000766 return 0;
767}
768
Harald Welte25de9912009-04-30 15:53:07 +0000769/* Actively connect to a BTS. Currently used by ipaccess-config.c */
770int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa)
771{
772 struct e1inp_ts *e1i_ts = &line->ts[0];
773 struct bsc_fd *bfd = &e1i_ts->driver.ipaccess.fd;
774 int ret, on = 1;
775
776 bfd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
777 bfd->cb = ipaccess_fd_cb;
778 bfd->when = BSC_FD_READ | BSC_FD_WRITE;
779 bfd->data = line;
Holger Hans Peter Freytherdc6af632010-03-24 04:56:13 +0100780 bfd->priv_nr = PRIV_OML;
Harald Welte25de9912009-04-30 15:53:07 +0000781
Holger Hans Peter Freyther4d2d95b2010-02-19 13:07:05 +0100782 if (bfd->fd < 0) {
783 LOGP(DINP, LOGL_ERROR, "could not create TCP socket.\n");
784 return -EIO;
785 }
786
Harald Welte25de9912009-04-30 15:53:07 +0000787 setsockopt(bfd->fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
788
789 ret = connect(bfd->fd, (struct sockaddr *) sa, sizeof(*sa));
790 if (ret < 0) {
Harald Welteafdca0f2009-12-23 23:01:04 +0100791 LOGP(DINP, LOGL_ERROR, "could not connect socket\n");
Harald Welte25de9912009-04-30 15:53:07 +0000792 close(bfd->fd);
793 return ret;
794 }
795
796 ret = bsc_register_fd(bfd);
797 if (ret < 0) {
798 close(bfd->fd);
799 return ret;
800 }
801
802 line->driver = &ipaccess_driver;
803
Holger Hans Peter Freyther09e364b2009-08-10 07:59:27 +0200804 return ret;
Harald Welte42581822009-08-08 16:12:58 +0200805 //return e1inp_line_register(line);
Harald Welte25de9912009-04-30 15:53:07 +0000806}
807
Harald Welteedb37782009-05-01 14:59:07 +0000808int ipaccess_setup(struct gsm_network *gsmnet)
Harald Welte5c1e4582009-02-15 11:57:29 +0000809{
Harald Welte5c1e4582009-02-15 11:57:29 +0000810 int ret;
Harald Welte5fd8a542009-02-13 02:43:36 +0000811
812 /* register the driver with the core */
813 /* FIXME: do this in the plugin initializer function */
814 ret = e1inp_driver_register(&ipaccess_driver);
815 if (ret)
816 return ret;
817
Holger Hans Peter Freyther5ea73132009-10-29 02:29:45 +0100818 e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle);
Harald Weltea4ffea92009-06-22 01:36:25 +0200819 if (!e1h)
820 return -ENOMEM;
Harald Weltea4ffea92009-06-22 01:36:25 +0200821
Harald Welteedb37782009-05-01 14:59:07 +0000822 e1h->gsmnet = gsmnet;
Harald Welte5fd8a542009-02-13 02:43:36 +0000823
Harald Welte5c1e4582009-02-15 11:57:29 +0000824 /* Listen for OML connections */
Pablo Neira Ayuso165fe562011-04-05 18:33:24 +0200825 ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY,
826 IPA_TCP_PORT_OML, 0, listen_fd_cb, NULL);
Harald Weltecf559782009-05-01 15:43:49 +0000827 if (ret < 0)
828 return ret;
Harald Welte5fd8a542009-02-13 02:43:36 +0000829
Harald Welte5c1e4582009-02-15 11:57:29 +0000830 /* Listen for RSL connections */
Pablo Neira Ayuso165fe562011-04-05 18:33:24 +0200831 ret = make_sock(&e1h->rsl_listen_fd, IPPROTO_TCP, INADDR_ANY,
832 IPA_TCP_PORT_RSL, 0, rsl_listen_fd_cb, NULL);
Harald Welte9b455bf2010-03-14 15:45:01 +0800833 if (ret < 0)
834 return ret;
835
Harald Welteedb37782009-05-01 14:59:07 +0000836 return ret;
Harald Welte5fd8a542009-02-13 02:43:36 +0000837}