diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/libosmocore/include/osmocom/core/Makefile.am | 2 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/core/prim.h | 38 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/core/socket.h | 11 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/gsm/Makefile.am | 2 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/gsm/abis_nm.h | 4 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/gsm/prim.h | 13 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h | 2 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/gsm/rsl.h | 1 | ||||
-rw-r--r-- | src/shared/libosmocore/include/osmocom/gsm/sysinfo.h | 3 | ||||
-rw-r--r-- | src/shared/libosmocore/src/gsm/rsl.c | 76 | ||||
-rw-r--r-- | src/shared/libosmocore/src/gsm/sysinfo.c | 6 | ||||
-rw-r--r-- | src/shared/libosmocore/src/gsmtap_util.c | 6 | ||||
-rw-r--r-- | src/shared/libosmocore/src/socket.c | 39 |
13 files changed, 186 insertions, 17 deletions
diff --git a/src/shared/libosmocore/include/osmocom/core/Makefile.am b/src/shared/libosmocore/include/osmocom/core/Makefile.am index 3c30362c..1ef37693 100644 --- a/src/shared/libosmocore/include/osmocom/core/Makefile.am +++ b/src/shared/libosmocore/include/osmocom/core/Makefile.am @@ -1,6 +1,6 @@ osmocore_HEADERS = signal.h linuxlist.h timer.h select.h msgb.h bits.h \ bitvec.h statistics.h utils.h socket.h \ - gsmtap.h write_queue.h \ + gsmtap.h write_queue.h prim.h \ logging.h rate_ctr.h gsmtap_util.h \ plugin.h crc16.h panic.h process.h msgfile.h \ backtrace.h conv.h application.h diff --git a/src/shared/libosmocore/include/osmocom/core/prim.h b/src/shared/libosmocore/include/osmocom/core/prim.h new file mode 100644 index 00000000..e892c62c --- /dev/null +++ b/src/shared/libosmocore/include/osmocom/core/prim.h @@ -0,0 +1,38 @@ +#ifndef OSMO_PRIMITIVE_H +#define OSMO_PRIMITIVE_H + +#include <stdint.h> +#include <osmocom/core/msgb.h> + +enum osmo_prim_operation { + PRIM_OP_REQUEST, + PRIM_OP_RESPONSE, + PRIM_OP_INDICATION, + PRIM_OP_CONFIRM, +}; + +#define _SAP_GSM_SHIFT 24 + +#define _SAP_GSM_BASE (0x01 << _SAP_GSM_SHIFT) +#define _SAP_TETRA_BASE (0x02 << _SAP_GSM_SHIFT) + +struct osmo_prim_hdr { + unsigned int sap; + unsigned int primitive; + enum osmo_prim_operation operation; + struct msgb *msg; /* message containing associated data */ +}; + +static inline void +osmo_prim_init(struct osmo_prim_hdr *oph, unsigned int sap, + unsigned int primitive, enum osmo_prim_operation operation, + struct msgb *msg) +{ + oph->sap = sap; + oph->primitive = primitive; + oph->operation = operation; + oph->msg = msg; +} + +typedef int (*osmo_prim_cb)(struct osmo_prim_hdr *oph, void *ctx); +#endif diff --git a/src/shared/libosmocore/include/osmocom/core/socket.h b/src/shared/libosmocore/include/osmocom/core/socket.h index b2601c76..612b12c8 100644 --- a/src/shared/libosmocore/include/osmocom/core/socket.h +++ b/src/shared/libosmocore/include/osmocom/core/socket.h @@ -5,14 +5,19 @@ struct sockaddr; +/* flags for osmo_sock_init. */ +#define OSMO_SOCK_F_CONNECT (1 << 0) +#define OSMO_SOCK_F_BIND (1 << 1) +#define OSMO_SOCK_F_NONBLOCK (1 << 2) + int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, - const char *host, uint16_t port, int connect0_bind1); + const char *host, uint16_t port, unsigned int flags); int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, - const char *host, uint16_t port, int connect0_bind1); + const char *host, uint16_t port, unsigned int flags); int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, - uint8_t proto, int connect0_bind1); + uint8_t proto, unsigned int flags); /* determine if the given address is a local address */ int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen); diff --git a/src/shared/libosmocore/include/osmocom/gsm/Makefile.am b/src/shared/libosmocore/include/osmocom/gsm/Makefile.am index 547933ec..aa7b1a9a 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/Makefile.am +++ b/src/shared/libosmocore/include/osmocom/gsm/Makefile.am @@ -1,6 +1,6 @@ osmogsm_HEADERS = a5.h comp128.h gsm0808.h gsm48_ie.h mncc.h rxlev_stat.h \ gsm0480.h gsm48.h gsm_utils.h rsl.h tlv.h abis_nm.h \ - sysinfo.h + sysinfo.h prim.h SUBDIRS = protocol diff --git a/src/shared/libosmocore/include/osmocom/gsm/abis_nm.h b/src/shared/libosmocore/include/osmocom/gsm/abis_nm.h index dcc8d4bb..3f5335e2 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/abis_nm.h +++ b/src/shared/libosmocore/include/osmocom/gsm/abis_nm.h @@ -2,8 +2,12 @@ #define _OSMO_GSM_ABIS_NM_H #include <osmocom/gsm/tlv.h> +#include <osmocom/gsm/gsm_utils.h> #include <osmocom/gsm/protocol/gsm_12_21.h> +enum abis_nm_msgtype; +enum gsm_phys_chan_config; + const enum abis_nm_msgtype abis_nm_reports[4]; const enum abis_nm_msgtype abis_nm_no_ack_nack[3]; const enum abis_nm_msgtype abis_nm_sw_load_msgs[9]; diff --git a/src/shared/libosmocore/include/osmocom/gsm/prim.h b/src/shared/libosmocore/include/osmocom/gsm/prim.h new file mode 100644 index 00000000..95cbb120 --- /dev/null +++ b/src/shared/libosmocore/include/osmocom/gsm/prim.h @@ -0,0 +1,13 @@ +#ifndef OSMO_GSM_PRIM_H +#define OSMO_GSM_PRIM_H + +#include <osmocom/core/prim.h> + +/* enumeration of GSM related SAPs */ +enum osmo_gsm_sap { + SAP_GSM_PH = _SAP_GSM_BASE, + SAP_GSM_DL, + SAP_GSM_MDL, +}; + +#endif diff --git a/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h index 74a4083b..9b641b34 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h +++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/gsm_08_58.h @@ -426,7 +426,7 @@ struct rsl_ie_chan_ident { #define RSL_SYSTEM_INFO_5bis 0x0d #define RSL_SYSTEM_INFO_5ter 0x0e #define RSL_SYSTEM_INFO_10 0x0f -#define REL_EXT_MEAS_ORDER 0x47 +#define RSL_EXT_MEAS_ORDER 0x47 #define RSL_MEAS_INFO 0x48 #define RSL_SYSTEM_INFO_13 0x28 #define RSL_SYSTEM_INFO_2quater 0x29 diff --git a/src/shared/libosmocore/include/osmocom/gsm/rsl.h b/src/shared/libosmocore/include/osmocom/gsm/rsl.h index 7e46330f..2eb045f2 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/rsl.h +++ b/src/shared/libosmocore/include/osmocom/gsm/rsl.h @@ -23,6 +23,7 @@ const char *rsl_chan_nr_str(uint8_t chan_nr); const char *rsl_err_name(uint8_t err); const char *rsl_rlm_cause_name(uint8_t err); +const char *rsl_msg_name(uint8_t err); /* Section 3.3.2.3 TS 05.02. I think this looks like a table */ int rsl_ccch_conf_to_bs_cc_chans(int ccch_conf); diff --git a/src/shared/libosmocore/include/osmocom/gsm/sysinfo.h b/src/shared/libosmocore/include/osmocom/gsm/sysinfo.h index a66f3f19..b808d6f9 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/sysinfo.h +++ b/src/shared/libosmocore/include/osmocom/gsm/sysinfo.h @@ -1,6 +1,7 @@ #ifndef _OSMO_GSM_SYSINFO_H #define _OSMO_GSM_SYSINFO_H +#include <osmocom/core/utils.h> #include <osmocom/gsm/protocol/gsm_04_08.h> enum osmo_sysinfo_type { @@ -26,6 +27,8 @@ enum osmo_sysinfo_type { SYSINFO_TYPE_2quater, SYSINFO_TYPE_5bis, SYSINFO_TYPE_5ter, + SYSINFO_TYPE_EMO, + SYSINFO_TYPE_MEAS_INFO, /* FIXME all the various bis and ter */ _MAX_SYSINFO_TYPE }; diff --git a/src/shared/libosmocore/src/gsm/rsl.c b/src/shared/libosmocore/src/gsm/rsl.c index 12ac0cfb..c497ba95 100644 --- a/src/shared/libosmocore/src/gsm/rsl.c +++ b/src/shared/libosmocore/src/gsm/rsl.c @@ -250,6 +250,82 @@ const char *rsl_err_name(uint8_t err) return get_value_string(rsl_err_vals, err); } +/* Names for Radio Link Layer Management */ +static const struct value_string rsl_msgt_names[] = { + { RSL_MT_DATA_REQ, "DATA_REQ" }, + { RSL_MT_DATA_IND, "DATA_IND" }, + { RSL_MT_ERROR_IND, "ERROR_IND" }, + { RSL_MT_EST_REQ, "EST_REQ" }, + { RSL_MT_EST_CONF, "EST_CONF" }, + { RSL_MT_EST_IND, "EST_IND" }, + { RSL_MT_REL_REQ, "REL_REQ" }, + { RSL_MT_REL_CONF, "REL_CONF" }, + { RSL_MT_REL_IND, "REL_IND" }, + { RSL_MT_UNIT_DATA_REQ, "UNIT_DATA_REQ" }, + { RSL_MT_UNIT_DATA_IND, "UNIT_DATA_IND" }, + { RSL_MT_SUSP_REQ, "SUSP_REQ" }, + { RSL_MT_SUSP_CONF, "SUSP_CONF" }, + { RSL_MT_RES_REQ, "RES_REQ" }, + { RSL_MT_RECON_REQ, "RECON_REQ" }, + + { RSL_MT_BCCH_INFO, "BCCH_INFO" }, + { RSL_MT_CCCH_LOAD_IND, "CCCH_LOAD_IND" }, + { RSL_MT_CHAN_RQD, "CHAN_RQD" }, + { RSL_MT_DELETE_IND, "DELETE_IND" }, + { RSL_MT_PAGING_CMD, "PAGING_CMD" }, + { RSL_MT_IMMEDIATE_ASSIGN_CMD, "IMM_ASS_CMD" }, + { RSL_MT_SMS_BC_REQ, "SMS_BC_REQ" }, + { RSL_MT_CHAN_CONF, "CHAN_CONF" }, + + { RSL_MT_RF_RES_IND, "RF_RES_IND" }, + { RSL_MT_SACCH_FILL, "SACCH_FILL" }, + { RSL_MT_OVERLOAD, "OVERLOAD" }, + { RSL_MT_ERROR_REPORT, "ERROR_REPORT" }, + { RSL_MT_SMS_BC_CMD, "SMS_BC_CMD" }, + { RSL_MT_CBCH_LOAD_IND, "CBCH_LOAD_IND" }, + { RSL_MT_NOT_CMD, "NOTIFY_CMD" }, + + { RSL_MT_CHAN_ACTIV, "CHAN_ACTIV" }, + { RSL_MT_CHAN_ACTIV_ACK, "CHAN_ACTIV_ACK" }, + { RSL_MT_CHAN_ACTIV_NACK, "CHAN_ACTIV_NACK" }, + { RSL_MT_CONN_FAIL, "CONN_FAIL" }, + { RSL_MT_DEACTIVATE_SACCH, "DEACTIVATE_SACCH" }, + { RSL_MT_ENCR_CMD, "ENCR_CMD" }, + { RSL_MT_HANDO_DET, "HANDOVER_DETECT" }, + { RSL_MT_MEAS_RES, "MEAS_RES" }, + { RSL_MT_MODE_MODIFY_REQ, "MODE_MODIFY_REQ" }, + { RSL_MT_MODE_MODIFY_ACK, "MODE_MODIFY_ACK" }, + { RSL_MT_MODE_MODIFY_NACK, "MODE_MODIFY_NACK" }, + { RSL_MT_PHY_CONTEXT_REQ, "PHY_CONTEXT_REQ" }, + { RSL_MT_PHY_CONTEXT_CONF, "PHY_CONTEXT_CONF" }, + { RSL_MT_RF_CHAN_REL, "RF_CHAN_REL" }, + { RSL_MT_MS_POWER_CONTROL, "MS_POWER_CONTROL" }, + { RSL_MT_BS_POWER_CONTROL, "BS_POWER_CONTROL" }, + { RSL_MT_PREPROC_CONFIG, "PREPROC_CONFIG" }, + { RSL_MT_PREPROC_MEAS_RES, "PREPROC_MEAS_RES" }, + { RSL_MT_RF_CHAN_REL_ACK, "RF_CHAN_REL_ACK" }, + { RSL_MT_SACCH_INFO_MODIFY, "SACCH_INFO_MODIFY" }, + { RSL_MT_TALKER_DET, "TALKER_DETECT" }, + { RSL_MT_LISTENER_DET, "LISTENER_DETECT" }, + { RSL_MT_REMOTE_CODEC_CONF_REP, "REM_CODEC_CONF_REP" }, + { RSL_MT_RTD_REP, "RTD_REQ" }, + { RSL_MT_PRE_HANDO_NOTIF, "HANDO_NOTIF" }, + { RSL_MT_MR_CODEC_MOD_REQ, "CODEC_MOD_REQ" }, + { RSL_MT_MR_CODEC_MOD_ACK, "CODEC_MOD_ACK" }, + { RSL_MT_MR_CODEC_MOD_NACK, "CODEC_MOD_NACK" }, + { RSL_MT_MR_CODEC_MOD_PER, "CODEC_MODE_PER" }, + { RSL_MT_TFO_REP, "TFO_REP" }, + { RSL_MT_TFO_MOD_REQ, "TFO_MOD_REQ" }, + { RSL_MT_LOCATION_INFO, "LOCATION_INFO" }, + { 0, NULL } +}; + + +const char *rsl_msg_name(uint8_t msg_type) +{ + return get_value_string(rsl_msgt_names, msg_type); +} + static const struct value_string rsl_rlm_cause_strs[] = { { RLL_CAUSE_T200_EXPIRED, "Timer T200 expired (N200+1) times" }, { RLL_CAUSE_REEST_REQ, "Re-establishment request" }, diff --git a/src/shared/libosmocore/src/gsm/sysinfo.c b/src/shared/libosmocore/src/gsm/sysinfo.c index 9df18877..1408f6bf 100644 --- a/src/shared/libosmocore/src/gsm/sysinfo.c +++ b/src/shared/libosmocore/src/gsm/sysinfo.c @@ -68,6 +68,8 @@ static const uint8_t sitype2rsl[_MAX_SYSINFO_TYPE] = { [SYSINFO_TYPE_2quater] = RSL_SYSTEM_INFO_2quater, [SYSINFO_TYPE_5bis] = RSL_SYSTEM_INFO_5bis, [SYSINFO_TYPE_5ter] = RSL_SYSTEM_INFO_5ter, + [SYSINFO_TYPE_EMO] = RSL_EXT_MEAS_ORDER, + [SYSINFO_TYPE_MEAS_INFO]= RSL_MEAS_INFO, }; static const uint8_t rsl2sitype[256] = { @@ -92,6 +94,8 @@ static const uint8_t rsl2sitype[256] = { [RSL_SYSTEM_INFO_2quater] = SYSINFO_TYPE_2quater, [RSL_SYSTEM_INFO_5bis] = SYSINFO_TYPE_5bis, [RSL_SYSTEM_INFO_5ter] = SYSINFO_TYPE_5ter, + [RSL_EXT_MEAS_ORDER] = SYSINFO_TYPE_EMO, + [RSL_MEAS_INFO] = SYSINFO_TYPE_MEAS_INFO, }; const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { @@ -116,6 +120,8 @@ const struct value_string osmo_sitype_strs[_MAX_SYSINFO_TYPE] = { { SYSINFO_TYPE_2quater, "2quater" }, { SYSINFO_TYPE_5bis, "5bis" }, { SYSINFO_TYPE_5ter, "5ter" }, + { SYSINFO_TYPE_EMO, "EMO" }, + { SYSINFO_TYPE_MEAS_INFO, "MI" }, { 0, NULL } }; diff --git a/src/shared/libosmocore/src/gsmtap_util.c b/src/shared/libosmocore/src/gsmtap_util.c index 95458657..c8c26c62 100644 --- a/src/shared/libosmocore/src/gsmtap_util.c +++ b/src/shared/libosmocore/src/gsmtap_util.c @@ -124,7 +124,8 @@ int gsmtap_source_init_fd(const char *host, uint16_t port) if (host == NULL) host = "localhost"; - return osmo_sock_init(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, host, port, 0); + return osmo_sock_init(AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, host, port, + OSMO_SOCK_F_CONNECT); } int gsmtap_source_add_sink_fd(int gsmtap_fd) @@ -138,7 +139,8 @@ int gsmtap_source_add_sink_fd(int gsmtap_fd) return rc; if (osmo_sockaddr_is_local((struct sockaddr *)&ss, ss_len) == 1) { - rc = osmo_sock_init_sa((struct sockaddr *)&ss, SOCK_DGRAM, IPPROTO_UDP, 1); + rc = osmo_sock_init_sa((struct sockaddr *)&ss, SOCK_DGRAM, + IPPROTO_UDP, OSMO_SOCK_F_BIND); if (rc >= 0) return rc; } diff --git a/src/shared/libosmocore/src/socket.c b/src/shared/libosmocore/src/socket.c index 014bbaa2..f1fcccd5 100644 --- a/src/shared/libosmocore/src/socket.c +++ b/src/shared/libosmocore/src/socket.c @@ -6,6 +6,7 @@ #include <osmocom/core/select.h> #include <osmocom/core/socket.h> +#include <sys/ioctl.h> #include <sys/socket.h> #include <sys/types.h> @@ -18,12 +19,16 @@ #include <ifaddrs.h> int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, - const char *host, uint16_t port, int connect0_bind1) + const char *host, uint16_t port, unsigned int flags) { struct addrinfo hints, *result, *rp; int sfd, rc, on = 1; char portbuf[16]; + if ((flags & (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) == + (OSMO_SOCK_F_BIND | OSMO_SOCK_F_CONNECT)) + return -EINVAL; + sprintf(portbuf, "%u", port); memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = family; @@ -31,6 +36,9 @@ int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, hints.ai_flags = 0; hints.ai_protocol = proto; + if (flags & OSMO_SOCK_F_BIND) + hints.ai_flags |= AI_PASSIVE; + rc = getaddrinfo(host, portbuf, &hints, &result); if (rc != 0) { perror("getaddrinfo returned NULL"); @@ -41,10 +49,24 @@ int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); if (sfd == -1) continue; - if (connect0_bind1 == 0) { - if (connect(sfd, rp->ai_addr, rp->ai_addrlen) != -1) + if (flags & OSMO_SOCK_F_NONBLOCK) { + if (ioctl(sfd, FIONBIO, (unsigned char *)&on) < 0) { + perror("cannot set this socket unblocking"); + close(sfd); + return -EINVAL; + } + } + if (flags & OSMO_SOCK_F_CONNECT) { + rc = connect(sfd, rp->ai_addr, rp->ai_addrlen); + if (rc != -1 || (rc == -1 && errno == EINPROGRESS)) break; } else { + rc = setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, + &on, sizeof(on)); + if (rc < 0) { + perror("cannot setsockopt socket"); + break; + } if (bind(sfd, rp->ai_addr, rp->ai_addrlen) != -1) break; } @@ -60,7 +82,7 @@ int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); /* Make sure to call 'listen' on a bound, connection-oriented sock */ - if (connect0_bind1 == 1) { + if (flags & OSMO_SOCK_F_BIND) { switch (type) { case SOCK_STREAM: case SOCK_SEQPACKET: @@ -72,11 +94,11 @@ int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, } int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, - const char *host, uint16_t port, int connect0_bind1) + const char *host, uint16_t port, unsigned int flags) { int sfd, rc; - sfd = osmo_sock_init(family, type, proto, host, port, connect0_bind1); + sfd = osmo_sock_init(family, type, proto, host, port, flags); if (sfd < 0) return sfd; @@ -93,7 +115,7 @@ int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, } int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, - uint8_t proto, int connect0_bind1) + uint8_t proto, unsigned int flags) { char host[NI_MAXHOST]; uint16_t port; @@ -124,8 +146,7 @@ int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, return s; } - return osmo_sock_init(ss->sa_family, type, proto, host, - port, connect0_bind1); + return osmo_sock_init(ss->sa_family, type, proto, host, port, flags); } static int sockaddr_equal(const struct sockaddr *a, |