summaryrefslogtreecommitdiffstats
path: root/src/shared/libosmocore/src
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2011-06-25 22:26:49 +0200
committerSylvain Munaut <tnt@246tNt.com>2011-06-25 22:26:49 +0200
commit9be610aaba9e53ac53dff61281987d2488a7c95f (patch)
tree004b5feff78d7650dc413dd33a23aa0910a61d4f /src/shared/libosmocore/src
parent4a8fb6111b467c88c3c59f1aa9caffddad697366 (diff)
parent620f7ab35034f78f894319e027a151568c331eea (diff)
Merge commit '620f7ab35034f78f894319e027a151568c331eea'
Diffstat (limited to 'src/shared/libosmocore/src')
-rw-r--r--src/shared/libosmocore/src/gsm/rsl.c76
-rw-r--r--src/shared/libosmocore/src/gsm/sysinfo.c6
-rw-r--r--src/shared/libosmocore/src/gsmtap_util.c6
-rw-r--r--src/shared/libosmocore/src/socket.c39
4 files changed, 116 insertions, 11 deletions
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,