This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.
Sylvain Munaut 246tnt at gmail.comFrom: Sylvain Munaut <tnt at 246tNt.com> Note, there is still an ugly hack: We send packets to the first BTS we find and not the "right" one, mostly because I had no idea how to find the right one ... Signed-off-by: Sylvain Munaut <tnt at 246tNt.com> --- openbsc/include/openbsc/gsm_data.h | 4 ++++ openbsc/src/bsc_init.c | 4 ++-- openbsc/src/input/ipaccess.c | 24 +++++++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h index ed36e9a..670df8f 100644 --- a/openbsc/include/openbsc/gsm_data.h +++ b/openbsc/include/openbsc/gsm_data.h @@ -2,6 +2,7 @@ #define _GSM_DATA_H #include <sys/types.h> +#include <arpa/inet.h> struct value_string { unsigned int value; @@ -346,6 +347,9 @@ struct gsm_bts { struct { u_int16_t site_id; u_int16_t bts_id; + + struct in_addr ina_local; + struct in_addr ina_remote; } ip_access; struct { struct { diff --git a/openbsc/src/bsc_init.c b/openbsc/src/bsc_init.c index 00f25d8..2526306 100644 --- a/openbsc/src/bsc_init.c +++ b/openbsc/src/bsc_init.c @@ -1045,8 +1045,8 @@ static void patch_nm_tables(struct gsm_bts *bts) nanobts_attr_nsvc0[3] = bts->gprs.nsvc[0].nsvci >> 8; nanobts_attr_nsvc0[4] = bts->gprs.nsvc[0].nsvci & 0xff; - /* FIXME: patch our own IP address as SGSN IP */ - //nanobts_attr_nsvc0[10] = + /* patch our own IP address as SGSN IP */ + memcpy(&nanobts_attr_nsvc0[10], &bts->ip_access.ina_local, 4); /* patch BVCI */ nanobts_attr_cell[12] = bts->gprs.cell.bvci >> 8; diff --git a/openbsc/src/input/ipaccess.c b/openbsc/src/input/ipaccess.c index fb13570..6ec4e0b 100644 --- a/openbsc/src/input/ipaccess.c +++ b/openbsc/src/input/ipaccess.c @@ -221,6 +221,20 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg, } DEBUGP(DINP, "Identified BTS %u/%u/%u\n", site_id, bts_id, trx_id); if (bfd->priv_nr == 1) { + int rv; + socklen_t l = sizeof(struct sockaddr_in); + struct sockaddr_in sa; + + rv = getpeername(bfd->fd, (struct sockaddr *)&sa, &l); + if (rv || (l != sizeof(struct sockaddr_in))) + return -EINVAL; + bts->ip_access.ina_remote = sa.sin_addr; + + rv = getsockname(bfd->fd, (struct sockaddr *)&sa, &l); + if (rv || (l != sizeof(struct sockaddr_in))) + return -EINVAL; + bts->ip_access.ina_local = sa.sin_addr; + bts->oml_link = e1inp_sign_link_create(&line->ts[1-1], E1INP_SIGN_OML, bts->c0, bts->oml_tei, 0); @@ -513,11 +527,19 @@ static int handle_gprs_write(struct bsc_fd *bfd) int ipac_gprs_send(struct msgb *msg) { + struct gsm_bts *bts; struct sockaddr_in sin; int rc; + /* FIXME: Just take the first ip.access bts we find */ + llist_for_each_entry(bts, &e1h->gsmnet->bts_list, list) { + if (!is_ipaccess_bts(bts)) + continue; + break; + } + sin.sin_family = AF_INET; - inet_aton("192.168.100.111", &sin.sin_addr); + sin.sin_addr = bts->ip_access.ina_remote; sin.sin_port = htons(23000); rc = sendto(e1h->gprs_fd.fd, msg->data, msg->len, 0, -- 1.6.5.1