summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2012-06-16 14:59:56 +0800
committerHarald Welte <laforge@gnumonks.org>2012-06-16 15:14:00 +0800
commit73952e3ab4629076c67fd64351d3d0649d75a426 (patch)
tree9b5df5f75d44d93de18172605e3caee85bb77526
parent1e57eb611238a5e46bbfdc6fdca2ba60fca1d701 (diff)
split libgb into a separate library for outside use
This also removes the dependency to osmo_sock() inside libcommon and replaces it with osmo_sock_* from libosmocore
-rw-r--r--openbsc/include/osmocom/gprs/Makefile.am3
-rw-r--r--openbsc/include/osmocom/gprs/gprs_bssgp.h (renamed from openbsc/include/openbsc/gprs_bssgp.h)2
-rw-r--r--openbsc/include/osmocom/gprs/gprs_ns.h (renamed from openbsc/include/openbsc/gprs_ns.h)0
-rw-r--r--openbsc/include/osmocom/gprs/gprs_ns_frgre.h (renamed from openbsc/include/openbsc/gprs_ns_frgre.h)0
-rw-r--r--openbsc/src/libgb/gprs_bssgp.c8
-rw-r--r--openbsc/src/libgb/gprs_bssgp_bss.c4
-rw-r--r--openbsc/src/libgb/gprs_bssgp_util.c4
-rw-r--r--openbsc/src/libgb/gprs_bssgp_vty.c13
-rw-r--r--openbsc/src/libgb/gprs_ns.c21
-rw-r--r--openbsc/src/libgb/gprs_ns_frgre.c14
-rw-r--r--openbsc/src/libgb/gprs_ns_vty.c13
11 files changed, 50 insertions, 32 deletions
diff --git a/openbsc/include/osmocom/gprs/Makefile.am b/openbsc/include/osmocom/gprs/Makefile.am
new file mode 100644
index 00000000..fe5714ea
--- /dev/null
+++ b/openbsc/include/osmocom/gprs/Makefile.am
@@ -0,0 +1,3 @@
+libgb_HEADERS = gprs_bssgp.h gprs_ns.h gprs_ns_frgre.h
+
+libgbdir = $(includedir)/osmocom/gprs
diff --git a/openbsc/include/openbsc/gprs_bssgp.h b/openbsc/include/osmocom/gprs/gprs_bssgp.h
index df93f5b2..bfc7d331 100644
--- a/openbsc/include/openbsc/gprs_bssgp.h
+++ b/openbsc/include/osmocom/gprs/gprs_bssgp.h
@@ -143,6 +143,8 @@ enum gprs_bssgp_cause {
/* Our implementation */
+#include <osmocom/gsm/gsm48.h>
+
/* gprs_bssgp_util.c */
extern struct gprs_ns_inst *bssgp_nsi;
struct msgb *bssgp_msgb_alloc(void);
diff --git a/openbsc/include/openbsc/gprs_ns.h b/openbsc/include/osmocom/gprs/gprs_ns.h
index 7045d84d..7045d84d 100644
--- a/openbsc/include/openbsc/gprs_ns.h
+++ b/openbsc/include/osmocom/gprs/gprs_ns.h
diff --git a/openbsc/include/openbsc/gprs_ns_frgre.h b/openbsc/include/osmocom/gprs/gprs_ns_frgre.h
index abcd43ff..abcd43ff 100644
--- a/openbsc/include/openbsc/gprs_ns_frgre.h
+++ b/openbsc/include/osmocom/gprs/gprs_ns_frgre.h
diff --git a/openbsc/src/libgb/gprs_bssgp.c b/openbsc/src/libgb/gprs_bssgp.c
index 6722cafb..e93b3de9 100644
--- a/openbsc/src/libgb/gprs_bssgp.c
+++ b/openbsc/src/libgb/gprs_bssgp.c
@@ -35,10 +35,10 @@
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/gsm_04_08_gprs.h>
-#include <openbsc/gprs_bssgp.h>
-#include <openbsc/gprs_llc.h>
-#include <openbsc/gprs_ns.h>
-#include <openbsc/gprs_sgsn.h>
+
+#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gprs/gprs_ns.h>
+
#include <openbsc/gprs_gmm.h>
void *bssgp_tall_ctx = NULL;
diff --git a/openbsc/src/libgb/gprs_bssgp_bss.c b/openbsc/src/libgb/gprs_bssgp_bss.c
index 9d76c3aa..a53423ca 100644
--- a/openbsc/src/libgb/gprs_bssgp_bss.c
+++ b/openbsc/src/libgb/gprs_bssgp_bss.c
@@ -28,11 +28,11 @@
#include <osmocom/core/rate_ctr.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gprs/gprs_ns.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
-#include <openbsc/gprs_bssgp.h>
-#include <openbsc/gprs_ns.h>
uint8_t *bssgp_msgb_tlli_put(struct msgb *msg, uint32_t tlli)
{
diff --git a/openbsc/src/libgb/gprs_bssgp_util.c b/openbsc/src/libgb/gprs_bssgp_util.c
index a1eb37e1..c794a590 100644
--- a/openbsc/src/libgb/gprs_bssgp_util.c
+++ b/openbsc/src/libgb/gprs_bssgp_util.c
@@ -27,11 +27,11 @@
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gprs/gprs_ns.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
-#include <openbsc/gprs_bssgp.h>
-#include <openbsc/gprs_ns.h>
struct gprs_ns_inst *bssgp_nsi;
diff --git a/openbsc/src/libgb/gprs_bssgp_vty.c b/openbsc/src/libgb/gprs_bssgp_vty.c
index a0d74ac9..256e8af7 100644
--- a/openbsc/src/libgb/gprs_bssgp_vty.c
+++ b/openbsc/src/libgb/gprs_bssgp_vty.c
@@ -26,17 +26,13 @@
#include <arpa/inet.h>
-#include <openbsc/gsm_data.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
-#include <openbsc/debug.h>
-#include <openbsc/signal.h>
-#include <openbsc/gprs_ns.h>
-#include <openbsc/gprs_bssgp.h>
-#include <openbsc/vty.h>
+#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
@@ -44,6 +40,11 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
+#include <openbsc/vty.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/debug.h>
+
+
/* FIXME: this should go to some common file as it is copied
* in vty_interface.c of the BSC */
static const struct value_string gprs_bssgp_timer_strs[] = {
diff --git a/openbsc/src/libgb/gprs_ns.c b/openbsc/src/libgb/gprs_ns.c
index 39ccd285..c1efa431 100644
--- a/openbsc/src/libgb/gprs_ns.c
+++ b/openbsc/src/libgb/gprs_ns.c
@@ -68,18 +68,18 @@
#include <arpa/inet.h>
-#include <openbsc/gsm_data.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
+#include <osmocom/core/socket.h>
+#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/gprs/gprs_bssgp.h>
+#include <osmocom/gprs/gprs_ns_frgre.h>
+
#include <openbsc/debug.h>
#include <openbsc/signal.h>
-#include <openbsc/gprs_ns.h>
-#include <openbsc/gprs_bssgp.h>
-#include <openbsc/gprs_ns_frgre.h>
-#include <openbsc/socket.h>
static const struct tlv_definition ns_att_tlvdef = {
.def = {
@@ -1026,14 +1026,19 @@ static int nsip_fd_cb(struct osmo_fd *bfd, unsigned int what)
*/
int gprs_ns_nsip_listen(struct gprs_ns_inst *nsi)
{
+ struct in_addr in;
int ret;
- ret = make_sock(&nsi->nsip.fd, IPPROTO_UDP, nsi->nsip.local_ip,
- nsi->nsip.local_port, 0, nsip_fd_cb, NULL);
+ in.s_addr = htonl(nsi->nsip.local_ip);
+
+ nsi->nsip.fd.cb = nsip_fd_cb;
+ nsi->nsip.fd.data = nsi;
+ ret = osmo_sock_init_ofd(&nsi->nsip.fd, AF_INET, SOCK_DGRAM,
+ IPPROTO_UDP, inet_ntoa(in),
+ nsi->nsip.local_port, OSMO_SOCK_F_BIND);
if (ret < 0)
return ret;
- nsi->nsip.fd.data = nsi;
return ret;
}
diff --git a/openbsc/src/libgb/gprs_ns_frgre.c b/openbsc/src/libgb/gprs_ns_frgre.c
index 27c5c57b..9be9f2a8 100644
--- a/openbsc/src/libgb/gprs_ns_frgre.c
+++ b/openbsc/src/libgb/gprs_ns_frgre.c
@@ -34,10 +34,10 @@
#include <osmocom/core/select.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/socket.h>
+#include <osmocom/gprs/gprs_ns.h>
-#include <openbsc/socket.h>
#include <openbsc/debug.h>
-#include <openbsc/gprs_ns.h>
#define GRE_PTYPE_FR 0x6559
#define GRE_PTYPE_IPv4 0x0800
@@ -282,8 +282,11 @@ static int nsfrgre_fd_cb(struct osmo_fd *bfd, unsigned int what)
int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi)
{
+ struct in_addr in;
int rc;
+ in.s_addr = htonl(nsi->frgre.local_ip);
+
/* Make sure we close any existing socket before changing it */
if (nsi->frgre.fd.fd)
close(nsi->frgre.fd.fd);
@@ -291,8 +294,11 @@ int gprs_ns_frgre_listen(struct gprs_ns_inst *nsi)
if (!nsi->frgre.enabled)
return 0;
- rc = make_sock(&nsi->frgre.fd, IPPROTO_GRE, nsi->frgre.local_ip,
- 0, 0, nsfrgre_fd_cb, NULL);
+ nsi->frgre.fd.cb = nsfrgre_fd_cb;
+ nsi->frgre.fd.data = nsi;
+ rc = osmo_sock_init_ofd(&nsi->frgre.fd, AF_INET, SOCK_RAW,
+ IPPROTO_GRE, inet_ntoa(in), 0,
+ OSMO_SOCK_F_BIND);
if (rc < 0) {
LOGP(DNS, LOGL_ERROR, "Error creating GRE socket (%s)\n",
strerror(errno));
diff --git a/openbsc/src/libgb/gprs_ns_vty.c b/openbsc/src/libgb/gprs_ns_vty.c
index 1e485ac9..f1ab2873 100644
--- a/openbsc/src/libgb/gprs_ns_vty.c
+++ b/openbsc/src/libgb/gprs_ns_vty.c
@@ -26,17 +26,13 @@
#include <arpa/inet.h>
-#include <openbsc/gsm_data.h>
#include <osmocom/core/msgb.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/rate_ctr.h>
-#include <openbsc/debug.h>
-#include <openbsc/signal.h>
-#include <openbsc/gprs_ns.h>
-#include <openbsc/gprs_bssgp.h>
-#include <openbsc/vty.h>
+#include <osmocom/gprs/gprs_ns.h>
+#include <osmocom/gprs/gprs_bssgp.h>
#include <osmocom/vty/vty.h>
#include <osmocom/vty/command.h>
@@ -44,6 +40,11 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
+#include <openbsc/gsm_data.h>
+#include <openbsc/debug.h>
+#include <openbsc/signal.h>
+#include <openbsc/vty.h>
+
static struct gprs_ns_inst *vty_nsi = NULL;
/* FIXME: this should go to some common file as it is copied