diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2016-08-18 13:13:55 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-09-09 06:43:32 +0000 |
commit | df63de2e37af890f3abb11d4de2334c2b49ae13c (patch) | |
tree | fbba6d8566475df9e97b24fa0967de0f74029c97 /include | |
parent | 30e08f5b8e9ed4dbc12983d61eb1f1661eb91dd0 (diff) |
build: move headers to include/osmocom/*
This came up while fixing 'make distcheck'; this is certainly not the easiest
way but it makes sense to have the headers in include/, like we do in openbsc.
The easy alternative might be to add -I$(top_srcdir)/src to src/Makefile.am.
Remove -I$(top_srcdir)/src from src/tests/Makefile.am, no longer needed.
Change-Id: I5a82e029dcdc4df0a60a31271a4883393fe59234
Diffstat (limited to 'include')
-rw-r--r-- | include/osmocom/iuh/Makefile.am | 4 | ||||
-rw-r--r-- | include/osmocom/iuh/context_map.h | 43 | ||||
-rw-r--r-- | include/osmocom/iuh/hnbgw.h | 154 | ||||
-rw-r--r-- | include/osmocom/iuh/hnbgw_cn.h | 5 | ||||
-rw-r--r-- | include/osmocom/iuh/hnbgw_hnbap.h | 6 | ||||
-rw-r--r-- | include/osmocom/iuh/hnbgw_ranap.h | 6 | ||||
-rw-r--r-- | include/osmocom/iuh/hnbgw_rua.h | 13 | ||||
-rw-r--r-- | include/osmocom/iuh/iu_common.h | 23 | ||||
-rw-r--r-- | include/osmocom/rua/Makefile.am | 2 | ||||
-rw-r--r-- | include/osmocom/rua/rua_msg_factory.h | 9 |
10 files changed, 263 insertions, 2 deletions
diff --git a/include/osmocom/iuh/Makefile.am b/include/osmocom/iuh/Makefile.am index e2f7126..b2a667d 100644 --- a/include/osmocom/iuh/Makefile.am +++ b/include/osmocom/iuh/Makefile.am @@ -1,2 +1,4 @@ noinst_HEADERS = \ - vty.h + vty.h \ + context_map.h hnbgw.h hnbgw_cn.h \ + hnbgw_hnbap.h hnbgw_rua.h hnbgw_ranap.h diff --git a/include/osmocom/iuh/context_map.h b/include/osmocom/iuh/context_map.h new file mode 100644 index 0000000..c1a4495 --- /dev/null +++ b/include/osmocom/iuh/context_map.h @@ -0,0 +1,43 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/linuxlist.h> + +enum hnbgw_context_map_state { + MAP_S_NULL, + MAP_S_ACTIVE, /* currently active map */ + MAP_S_RESERVED1, /* just disconnected, still resrved */ + MAP_S_RESERVED2, /* still reserved */ +}; + +struct hnb_context; +struct hnbgw_cnlink; + +struct hnbgw_context_map { + /* entry in the per-CN list of mappings */ + struct llist_head cn_list; + /* entry in the per-HNB list of mappings */ + struct llist_head hnb_list; + /* pointer to HNB */ + struct hnb_context *hnb_ctx; + /* pointer to CN */ + struct hnbgw_cnlink *cn_link; + /* RUA contxt ID */ + uint32_t rua_ctx_id; + /* SCCP User SAP connection ID */ + uint32_t scu_conn_id; + + enum hnbgw_context_map_state state; +}; + + +struct hnbgw_context_map * +context_map_alloc_by_hnb(struct hnb_context *hnb, uint32_t rua_ctx_id, + struct hnbgw_cnlink *cn_if_new); + +struct hnbgw_context_map * +context_map_by_cn(struct hnbgw_cnlink *cn, uint32_t scu_conn_id); + +void context_map_deactivate(struct hnbgw_context_map *map); + +int context_map_init(struct hnb_gw *gw); diff --git a/include/osmocom/iuh/hnbgw.h b/include/osmocom/iuh/hnbgw.h new file mode 100644 index 0000000..21a9602 --- /dev/null +++ b/include/osmocom/iuh/hnbgw.h @@ -0,0 +1,154 @@ +#pragma once + +#include <osmocom/core/select.h> +#include <osmocom/core/linuxlist.h> +#include <osmocom/core/write_queue.h> +#include <osmocom/core/timer.h> +#include <osmocom/sigtran/sccp_sap.h> + +#define DEBUG +#include <osmocom/core/logging.h> + + +enum { + DMAIN, + DHNBAP, + DSUA, + DRUA, + DRANAP, +}; + + +/* 25.467 Section 7.1 */ +#define IUH_DEFAULT_SCTP_PORT 29169 +#define RNA_DEFAULT_SCTP_PORT 25471 + +#define IUH_PPI_RUA 19 +#define IUH_PPI_HNBAP 20 +#define IUH_PPI_SABP 31 +#define IUH_PPI_RNA 42 +#define IUH_PPI_PUA 55 + +#define IUH_MSGB_SIZE 2048 + +struct umts_cell_id { + uint16_t mcc; /*!< Mobile Country Code */ + uint16_t mnc; /*!< Mobile Network Code */ + uint16_t lac; /*!< Locaton Area Code */ + uint16_t rac; /*!< Routing Area Code */ + uint16_t sac; /*!< Service Area Code */ + uint32_t cid; /*!< Cell ID */ +}; + +struct hnb_gw; + +enum hnbgw_cnlink_state { + /* we have just been initialized or were disconnected */ + CNLINK_S_NULL, + /* establishment of the SUA/SCCP link is pending */ + CNLINK_S_EST_PEND, + /* establishment of the SUA/SCCP link was confirmed */ + CNLINK_S_EST_CONF, + /* we have esnt the RANAP RESET and wait for the ACK */ + CNLINK_S_EST_RST_TX_WAIT_ACK, + /* we have received the RANAP RESET ACK and are active */ + CNLINK_S_EST_ACTIVE, +}; + +struct hnbgw_cnlink { + struct llist_head list; + enum hnbgw_cnlink_state state; + struct hnb_gw *gw; + /* are we a PS connection (1) or CS (0) */ + int is_ps; + /* timer for re-transmitting the RANAP Reset */ + struct osmo_timer_list T_RafC; + /* reference to the SCCP User SAP by which we communicate */ + struct osmo_sccp_user *sua_user; + struct osmo_sccp_link *sua_link; + struct osmo_sccp_addr local_addr; + struct osmo_sccp_addr remote_addr; + uint32_t next_conn_id; + + /* linked list of hnbgw_context_map */ + struct llist_head map_list; +}; + +struct hnb_context { + /*! Entry in HNB-global list of HNB */ + struct llist_head list; + /*! HNB-GW we are part of */ + struct hnb_gw *gw; + /*! SCTP socket + write queue for Iuh to this specific HNB */ + struct osmo_stream_srv *conn; + /*! copied from HNB-Identity-Info IE */ + char identity_info[256]; + /*! copied from Cell Identity IE */ + struct umts_cell_id id; + + /*! SCTP stream ID for HNBAP */ + uint16_t hnbap_stream; + /*! SCTP stream ID for RUA */ + uint16_t rua_stream; + + /* linked list of hnbgw_context_map */ + struct llist_head map_list; +}; + +struct ue_context { + /*! Entry in the HNB-global list of UE */ + struct llist_head list; + /*! Unique Context ID for this UE */ + uint32_t context_id; + char imsi[16+1]; + /* TODO: track TMSI, for HNBAP UE Register Request with TMSI, + * seen with ip.access nano3G femto cell */ + /*! UE is serviced via this HNB */ + struct hnb_context *hnb; +}; + +#define HNBGW_IUH_BIND_ADDR_DEFAULT "0.0.0.0" + +struct hnb_gw { + struct { + const char *iuh_bind_addr; + /*! SCTP port for Iuh listening */ + uint16_t iuh_listen_port; + /*! The UDP port where we receive multiplexed CS user + * plane traffic from HNBs */ + uint16_t iuh_cs_mux_port; + uint16_t rnc_id; + } config; + /*! SCTP listen socket for incoming connections */ + struct osmo_stream_srv_link *iuh; + /* list of struct hnb_context */ + struct llist_head hnb_list; + /* list of struct ue_context */ + struct llist_head ue_list; + /* list of struct hnbgw_cnlink */ + struct llist_head cn_list; + /* next availble UE Context ID */ + uint32_t next_ue_ctx_id; + + /* currently active CN links for CS and PS */ + struct hnbgw_cnlink *cnlink_cs; + struct hnbgw_cnlink *cnlink_ps; +}; + +extern void *talloc_asn1_ctx; + +struct ue_context *ue_context_by_id(struct hnb_gw *gw, uint32_t id); +struct ue_context *ue_context_by_imsi(struct hnb_gw *gw, const char *imsi); +struct ue_context *ue_context_alloc(struct hnb_context *hnb, const char *imsi); +void ue_context_free(struct ue_context *ue); + +struct hnb_context *hnb_context_alloc(struct hnb_gw *gw, struct osmo_stream_srv_link *link, int new_fd); +void hnb_context_release(struct hnb_context *ctx); + +void hnbgw_vty_init(struct hnb_gw *gw, void *tall_ctx); + +/* + * Return IP address passed to the hnbgw/iuh/bind command, or + * IUH_BIND_ADDR_DEFAULT + */ +const char *hnbgw_get_iuh_bind_addr(struct hnb_gw *gw); diff --git a/include/osmocom/iuh/hnbgw_cn.h b/include/osmocom/iuh/hnbgw_cn.h new file mode 100644 index 0000000..d5bec04 --- /dev/null +++ b/include/osmocom/iuh/hnbgw_cn.h @@ -0,0 +1,5 @@ +#pragma once + +#include <osmocom/iuh/hnbgw.h> + +struct hnbgw_cnlink *hnbgw_cnlink_init(struct hnb_gw *gw, const char *host, uint16_t port, int is_ps); diff --git a/include/osmocom/iuh/hnbgw_hnbap.h b/include/osmocom/iuh/hnbgw_hnbap.h new file mode 100644 index 0000000..cca3550 --- /dev/null +++ b/include/osmocom/iuh/hnbgw_hnbap.h @@ -0,0 +1,6 @@ +#pragma once + +#include <osmocom/iuh/hnbgw.h> + +int hnbgw_hnbap_rx(struct hnb_context *hnb, struct msgb *msg); +int hnbgw_hnbap_init(void); diff --git a/include/osmocom/iuh/hnbgw_ranap.h b/include/osmocom/iuh/hnbgw_ranap.h new file mode 100644 index 0000000..2c55964 --- /dev/null +++ b/include/osmocom/iuh/hnbgw_ranap.h @@ -0,0 +1,6 @@ +#pragma once + +#include <osmocom/iuh/hnbgw.h> + +int hnbgw_ranap_rx(struct msgb *msg, uint8_t *data, size_t len); +int hnbgw_ranap_init(void); diff --git a/include/osmocom/iuh/hnbgw_rua.h b/include/osmocom/iuh/hnbgw_rua.h new file mode 100644 index 0000000..6a890b7 --- /dev/null +++ b/include/osmocom/iuh/hnbgw_rua.h @@ -0,0 +1,13 @@ +#pragma once + +#include <osmocom/iuh/hnbgw.h> +#include <osmocom/rua/RUA_Cause.h> + +int hnbgw_rua_rx(struct hnb_context *hnb, struct msgb *msg); +int hnbgw_rua_init(void); + +int rua_tx_udt(struct hnb_context *hnb, const uint8_t *data, unsigned int len); +int rua_tx_dt(struct hnb_context *hnb, int is_ps, uint32_t context_id, + const uint8_t *data, unsigned int len); +int rua_tx_disc(struct hnb_context *hnb, int is_ps, uint32_t context_id, + const RUA_Cause_t *cause, const uint8_t *data, unsigned int len); diff --git a/include/osmocom/iuh/iu_common.h b/include/osmocom/iuh/iu_common.h new file mode 100644 index 0000000..11c2a79 --- /dev/null +++ b/include/osmocom/iuh/iu_common.h @@ -0,0 +1,23 @@ +#pragma once + +/* A humble attempt of reading the Iu messages (RUA/RANAP/HNBAP) without an asn.1 parser. + * Not actually used anywhere (yet?) */ + +struct iu_common_hdr { + uint8_t msg_type; + uint8_t procedure_code; + uint8_t criticality; + uint8_t len; /* first byte of length field */ + uint8_t payload[0]; /* possible further length field + payload */ + /* extension? */ + /* ? */ + /* number of ProtocolIEs */ +} __attribute__ ((packed)); + +struct iu_common_ie { + uint16_t iei; + uint8_t criticality; + uint8_t len; /* first byte of length field */ + uint8_t payload[0]; /* possible further length field + payload */ +} __attribute__ ((packed)); + diff --git a/include/osmocom/rua/Makefile.am b/include/osmocom/rua/Makefile.am index 49e2150..307f123 100644 --- a/include/osmocom/rua/Makefile.am +++ b/include/osmocom/rua/Makefile.am @@ -1,5 +1,5 @@ noinst_HEADERS = \ - rua_common.h rua_ies_defs.h \ + rua_common.h rua_ies_defs.h rua_msg_factory.h \ RUA_Ansi-41-IDNNS.h \ RUA_Cause.h \ RUA_CauseMisc.h \ diff --git a/include/osmocom/rua/rua_msg_factory.h b/include/osmocom/rua/rua_msg_factory.h new file mode 100644 index 0000000..ca2f4e8 --- /dev/null +++ b/include/osmocom/rua/rua_msg_factory.h @@ -0,0 +1,9 @@ +#pragma once + +#include <stdint.h> +#include <osmocom/core/msgb.h> + +struct msgb *rua_new_udt(struct msgb *inmsg); +struct msgb *rua_new_conn(int is_ps, uint32_t context_id, struct msgb *inmsg); +struct msgb *rua_new_dt(int is_ps, uint32_t context_id, struct msgb *inmsg); +struct msgb *rua_new_disc(int is_ps, uint32_t context_id, struct msgb *inmsg); |