From 2b5d3ce7c69e1149bb2af815ab8b8534026063ca Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 6 Nov 2011 20:47:08 +0100 Subject: src: add generic channel infrastructure and A-bis IPA server support This patch adds the generic channel infrastructure that allows to create channel of different types. Each channel has their own configuration functions. struct osmo_chan *chan; chan = osmo_chan_create(tall_example, CHAN_ABIS_IPA_SERVER); ... /* specific configuration functions per supported channel. */ osmo_chan_abis_ipa_server_set_cb_signalmsg(chan, signal_msg_cb); osmo_chan_abis_ipa_unit_add(chan, 1801, 0); /* open channel. */ osmo_chan_open(chan); The input path requires a callback to be registered. The output path is handled through: int osmo_chan_enqueue(struct osmo_chan *c, struct msgb *msg); The msg->dst must be set (it can be taken from the original message to route one reply). This patch also adds A-bis IPA server support. It has been tested with e1inp_ipa_bsc_test available in libosmo-abis. --- include/osmocom/netif/Makefile.am | 5 ++- include/osmocom/netif/channel.h | 49 +++++++++++++++++++++++++ include/osmocom/netif/channel/Makefile.am | 3 ++ include/osmocom/netif/channel/abis_ipa_server.h | 14 +++++++ include/osmocom/netif/ipa.h | 42 ++++++++++++++++----- include/osmocom/netif/stream.h | 2 + 6 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 include/osmocom/netif/channel.h create mode 100644 include/osmocom/netif/channel/Makefile.am create mode 100644 include/osmocom/netif/channel/abis_ipa_server.h (limited to 'include') diff --git a/include/osmocom/netif/Makefile.am b/include/osmocom/netif/Makefile.am index 4e63846..6d2980d 100644 --- a/include/osmocom/netif/Makefile.am +++ b/include/osmocom/netif/Makefile.am @@ -1,4 +1,7 @@ -osmonetif_HEADERS = datagram.h \ +SUBDIRS = channel + +osmonetif_HEADERS = channel.h \ + datagram.h \ ipa.h \ stream.h diff --git a/include/osmocom/netif/channel.h b/include/osmocom/netif/channel.h new file mode 100644 index 0000000..65955e8 --- /dev/null +++ b/include/osmocom/netif/channel.h @@ -0,0 +1,49 @@ +#ifndef _CHANNEL_H_ +#define _CHANNEL_H_ + +#include + +#define CHAN_SIGN_OML 0 +#define CHAN_SIGN_RSL 1 + +enum { + CHAN_NONE, + CHAN_ABIS_IPA_SERVER, + CHAN_MAX, +}; + +#define CHAN_F_DEFAULT (1 << 0) +#define CHAN_F_BUFFERED (1 << 1) +#define CHAN_F_STREAM (1 << 2) +#define CHAN_F_ERRORS (1 << 3) +#define CHAN_F_MAX (1 << 4) + +struct osmo_chan; +struct msgb; + +struct osmo_chan_type { + int type; + int datasiz; + + int (*create)(struct osmo_chan *chan); + void (*destroy)(struct osmo_chan *chan); + int (*open)(struct osmo_chan *chan); + void (*close)(struct osmo_chan *chan); + int (*enqueue)(struct osmo_chan *chan, struct msgb *msg); +}; + +struct osmo_chan { + void *ctx; + struct osmo_chan_type *ops; + char data[0]; +}; + +struct osmo_chan *osmo_chan_create(void *ctx, int type); +void osmo_chan_destroy(struct osmo_chan *c); + +int osmo_chan_open(struct osmo_chan *c); +void osmo_chan_close(struct osmo_chan *c); + +int osmo_chan_enqueue(struct osmo_chan *c, struct msgb *msg); + +#endif /* _CHANNEL_H_ */ diff --git a/include/osmocom/netif/channel/Makefile.am b/include/osmocom/netif/channel/Makefile.am new file mode 100644 index 0000000..4f2b876 --- /dev/null +++ b/include/osmocom/netif/channel/Makefile.am @@ -0,0 +1,3 @@ +osmonetif_channel_HEADERS = abis_ipa_server.h + +osmonetif_channeldir = $(includedir)/osmocom/netif/channel diff --git a/include/osmocom/netif/channel/abis_ipa_server.h b/include/osmocom/netif/channel/abis_ipa_server.h new file mode 100644 index 0000000..0338021 --- /dev/null +++ b/include/osmocom/netif/channel/abis_ipa_server.h @@ -0,0 +1,14 @@ +#ifndef _ABIS_IPA_SERVER_H_ +#define _ABIS_IPA_SERVER_H_ + +void osmo_chan_abis_ipa_server_set_oml_addr(struct osmo_chan *c, const char *addr); +void osmo_chan_abis_ipa_server_set_oml_port(struct osmo_chan *c, uint16_t port); + +void osmo_chan_abis_ipa_server_set_rsl_addr(struct osmo_chan *c, const char *addr); +void osmo_chan_abis_ipa_server_set_rsl_port(struct osmo_chan *c, uint16_t port); + +void osmo_chan_abis_ipa_server_set_cb_signalmsg(struct osmo_chan *c, void (*signal_msg)(struct msgb *msg, int type)); + +int osmo_chan_abis_ipa_unit_add(struct osmo_chan *c, uint16_t site_id, uint16_t bts_id); + +#endif diff --git a/include/osmocom/netif/ipa.h b/include/osmocom/netif/ipa.h index 5b53b3a..152ea24 100644 --- a/include/osmocom/netif/ipa.h +++ b/include/osmocom/netif/ipa.h @@ -34,19 +34,43 @@ struct ipa_head_ext { #define IPAC_MSGT_SCCP_OLD 0xff /* OpenBSC extension */ enum ipaccess_id_tags { - IPAC_IDTAG_SERNR = 0x00, - IPAC_IDTAG_UNITNAME = 0x01, - IPAC_IDTAG_LOCATION1 = 0x02, - IPAC_IDTAG_LOCATION2 = 0x03, - IPAC_IDTAG_EQUIPVERS = 0x04, - IPAC_IDTAG_SWVERSION = 0x05, - IPAC_IDTAG_IPADDR = 0x06, - IPAC_IDTAG_MACADDR = 0x07, - IPAC_IDTAG_UNIT = 0x08, + IPAC_IDTAG_SERNR = 0x00, + IPAC_IDTAG_UNITNAME = 0x01, + IPAC_IDTAG_LOCATION1 = 0x02, + IPAC_IDTAG_LOCATION2 = 0x03, + IPAC_IDTAG_EQUIPVERS = 0x04, + IPAC_IDTAG_SWVERSION = 0x05, + IPAC_IDTAG_IPADDR = 0x06, + IPAC_IDTAG_MACADDR = 0x07, + IPAC_IDTAG_UNIT = 0x08, }; struct msgb *osmo_ipa_msg_alloc(int headroom); void osmo_ipa_msg_push_header(struct msgb *msg, uint8_t proto); int osmo_ipa_msg_recv(int fd, struct msgb *msg); +struct ipaccess_unit { + uint16_t site_id; + uint16_t bts_id; + uint16_t trx_id; + char *unit_name; + char *equipvers; + char *swversion; + uint8_t mac_addr[6]; + char *location1; + char *location2; + char *serno; +}; + +struct osmo_fd; +struct tlv_parsed; + +int osmo_ipa_rcvmsg_base(struct msgb *msg, struct osmo_fd *bfd); +int osmo_ipa_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len); +int osmo_ipa_parse_unitid(const char *str, struct ipaccess_unit *unit_data); + +int ipaccess_send_pong(int fd); +int ipaccess_send_id_ack(int fd); +int ipaccess_send_id_req(int fd); + #endif diff --git a/include/osmocom/netif/stream.h b/include/osmocom/netif/stream.h index a43516e..fe04088 100644 --- a/include/osmocom/netif/stream.h +++ b/include/osmocom/netif/stream.h @@ -23,6 +23,8 @@ void *osmo_stream_server_conn_get_data(struct osmo_stream_server_conn *conn); struct osmo_fd *osmo_stream_server_conn_get_ofd(struct osmo_stream_server_conn *link); void osmo_stream_server_conn_destroy(struct osmo_stream_server_conn *conn); +void osmo_stream_server_conn_set_data(struct osmo_stream_server_conn *conn, void *data); + void osmo_stream_server_conn_send(struct osmo_stream_server_conn *conn, struct msgb *msg); int osmo_stream_server_conn_recv(struct osmo_stream_server_conn *conn, struct msgb *msg); -- cgit v1.2.3