summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gsm/gsm0341.c5
-rw-r--r--src/gsm/gsm0808.c11
-rw-r--r--src/gsm/gsm0808_utils.c6
-rw-r--r--src/gsm/gsm48.c17
-rw-r--r--src/gsm/ipa.c6
-rw-r--r--src/gsm/lapd_core.c1
-rw-r--r--src/gsm/lapdm.c1
-rw-r--r--src/gsmtap_util.c7
-rw-r--r--src/logging_gsmtap.c8
-rw-r--r--src/stats.c3
10 files changed, 31 insertions, 34 deletions
diff --git a/src/gsm/gsm0341.c b/src/gsm/gsm0341.c
index cc773824..1c14d3ed 100644
--- a/src/gsm/gsm0341.c
+++ b/src/gsm/gsm0341.c
@@ -23,8 +23,7 @@
#include <stdlib.h>
#include <string.h>
-#include <arpa/inet.h>
-
+#include <osmocom/core/byteswap.h>
#include <osmocom/core/talloc.h>
#include <osmocom/gsm/protocol/gsm_03_41.h>
@@ -36,7 +35,7 @@ gsm0341_build_msg(void *ctx, uint8_t geo_scope, uint8_t msg_code,
{
struct gsm341_ms_message *cbmsg;
- msg_id = htons(msg_id);
+ msg_id = osmo_htons(msg_id);
if (len > 88)
return NULL;
diff --git a/src/gsm/gsm0808.c b/src/gsm/gsm0808.c
index be58939d..04c2f018 100644
--- a/src/gsm/gsm0808.c
+++ b/src/gsm/gsm0808.c
@@ -18,13 +18,12 @@
*
*/
+#include <osmocom/core/byteswap.h>
#include <osmocom/gsm/gsm0808.h>
#include <osmocom/gsm/gsm0808_utils.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
#include <osmocom/gsm/gsm48.h>
-#include <arpa/inet.h>
-
#define BSSMAP_MSG_SIZE 512
#define BSSMAP_MSG_HEADROOM 128
@@ -51,7 +50,7 @@ struct msgb *gsm0808_create_layer3_aoip(const struct msgb *msg_l3, uint16_t nc,
/* create the cell header */
lai_ci.ident = CELL_IDENT_WHOLE_GLOBAL;
gsm48_generate_lai(&lai_ci.lai, cc, nc, lac);
- lai_ci.ci = htons(_ci);
+ lai_ci.ci = osmo_htons(_ci);
msgb_tlv_put(msg, GSM0808_IE_CELL_IDENTIFIER, sizeof(lai_ci),
(uint8_t *) &lai_ci);
@@ -266,7 +265,7 @@ struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
/* Circuit Identity Code 3.2.2.2 */
if (cic) {
- cic_sw = htons(*cic);
+ cic_sw = osmo_htons(*cic);
msgb_tv_fixed_put(msg, GSM0808_IE_CIRCUIT_IDENTITY_CODE,
sizeof(cic_sw), (uint8_t *) & cic_sw);
}
@@ -282,7 +281,7 @@ struct msgb *gsm0808_create_ass(const struct gsm0808_channel_type *ct,
/* AoIP: Call Identifier 3.2.2.105 */
if (ci) {
- ci_sw = htonl(*ci);
+ ci_sw = osmo_htonl(*ci);
msgb_tv_fixed_put(msg, GSM0808_IE_CALL_ID, sizeof(ci_sw),
(uint8_t *) & ci_sw);
}
@@ -433,7 +432,7 @@ struct msgb *gsm0808_create_paging(const char *imsi, const uint32_t *tmsi,
/* TMSI 3.2.2.7 */
if (tmsi) {
- tmsi_sw = htonl(*tmsi);
+ tmsi_sw = osmo_htonl(*tmsi);
msgb_tlv_put(msg, GSM0808_IE_TMSI, sizeof(*tmsi),
(uint8_t *) & tmsi_sw);
}
diff --git a/src/gsm/gsm0808_utils.c b/src/gsm/gsm0808_utils.c
index b4bb8789..2fa265a9 100644
--- a/src/gsm/gsm0808_utils.c
+++ b/src/gsm/gsm0808_utils.c
@@ -20,10 +20,10 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/msgb.h>
+#include <osmocom/core/byteswap.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
-#include <arpa/inet.h>
#include <errno.h>
#include <osmocom/gsm/protocol/gsm_08_08.h>
@@ -58,13 +58,13 @@ uint8_t gsm0808_enc_aoip_trasp_addr(struct msgb *msg,
switch (ss->ss_family) {
case AF_INET:
sin = (struct sockaddr_in *)ss;
- port = ntohs(sin->sin_port);
+ port = osmo_ntohs(sin->sin_port);
ptr = msgb_put(msg, IP_V4_ADDR_LEN);
memcpy(ptr, &sin->sin_addr.s_addr, IP_V4_ADDR_LEN);
break;
case AF_INET6:
sin6 = (struct sockaddr_in6 *)ss;
- port = ntohs(sin6->sin6_port);
+ port = osmo_ntohs(sin6->sin6_port);
ptr = msgb_put(msg, IP_V6_ADDR_LEN);
memcpy(ptr, sin6->sin6_addr.s6_addr, IP_V6_ADDR_LEN);
break;
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 757a8550..543c9c00 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -26,9 +26,11 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
-#include <arpa/inet.h>
#include <osmocom/core/utils.h>
+#include <osmocom/core/byteswap.h>
+#include <osmocom/core/bit16gen.h>
+#include <osmocom/core/bit32gen.h>
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/gsm48.h>
#include <osmocom/gsm/gsm0502.h>
@@ -479,7 +481,7 @@ void gsm48_generate_lai(struct gsm48_loc_area_id *lai48, uint16_t mcc,
uint16_t mnc, uint16_t lac)
{
gsm48_mcc_mnc_to_bcd(&lai48->digits[0], mcc, mnc);
- lai48->lac = htons(lac);
+ lai48->lac = osmo_htons(lac);
}
/* Attention: this function returns true integers, not hex! */
@@ -487,7 +489,7 @@ int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc,
uint16_t *mnc, uint16_t *lac)
{
gsm48_mcc_mnc_from_bcd(&lai->digits[0], mcc, mnc);
- *lac = ntohs(lai->lac);
+ *lac = osmo_ntohs(lai->lac);
return 0;
}
@@ -537,7 +539,7 @@ void gsm48_set_dtx(struct gsm48_cell_options *op, enum gsm48_dtx_mode full,
int gsm48_generate_mid_from_tmsi(uint8_t *buf, uint32_t tmsi)
{
- uint32_t tmsi_be = htonl(tmsi);
+ uint32_t tmsi_be = osmo_htonl(tmsi);
buf[0] = GSM48_IE_MOBILE_ID;
buf[1] = GSM48_TMSI_LEN;
@@ -593,8 +595,7 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi,
case GSM_MI_TYPE_TMSI:
/* Table 10.5.4.3, reverse generate_mid_from_tmsi */
if (mi_len == GSM48_TMSI_LEN && mi[0] == (0xf0 | GSM_MI_TYPE_TMSI)) {
- memcpy(&tmsi, &mi[1], 4);
- tmsi = ntohl(tmsi);
+ tmsi = osmo_load32be(&mi[1]);
return snprintf(string, str_len, "%u", tmsi);
}
break;
@@ -637,7 +638,7 @@ void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf)
raid->mnc += (buf[1] >> 4) * 1;
}
- raid->lac = ntohs(*(uint16_t *)(buf + 3));
+ raid->lac = osmo_load16be(buf + 3);
raid->rac = buf[5];
}
@@ -660,7 +661,7 @@ int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid)
buf[2] = ((mnc / 100) % 10) | (((mnc / 10) % 10) << 4);
}
- _lac = htons(raid->lac);
+ _lac = osmo_htons(raid->lac);
memcpy(buf + 3, &_lac, 2);
buf[5] = raid->rac;
diff --git a/src/gsm/ipa.c b/src/gsm/ipa.c
index 2c0880ae..90cf0eb6 100644
--- a/src/gsm/ipa.c
+++ b/src/gsm/ipa.c
@@ -26,10 +26,10 @@
#include <errno.h>
#include <stdlib.h>
-#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
+#include <osmocom/core/byteswap.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
#include <osmocom/core/logging.h>
@@ -431,7 +431,7 @@ void ipa_prepend_header(struct msgb *msg, int proto)
/* prepend the ip.access header */
hh = (struct ipaccess_head *) msgb_push(msg, sizeof(*hh));
- hh->len = htons(msg->len - sizeof(*hh));
+ hh->len = osmo_htons(msg->len - sizeof(*hh));
hh->proto = proto;
}
@@ -502,7 +502,7 @@ int ipa_msg_recv_buffered(int fd, struct msgb **rmsg, struct msgb **tmp_msg)
hh = (struct ipaccess_head *) msg->data;
/* then read the length as specified in header */
- len = ntohs(hh->len);
+ len = osmo_ntohs(hh->len);
if (len < 0 || IPA_ALLOC_SIZE < len + sizeof(*hh)) {
LOGP(DLINP, LOGL_ERROR, "bad message length of %d bytes, "
diff --git a/src/gsm/lapd_core.c b/src/gsm/lapd_core.c
index c81b2a05..310df653 100644
--- a/src/gsm/lapd_core.c
+++ b/src/gsm/lapd_core.c
@@ -74,7 +74,6 @@
#include <stdint.h>
#include <string.h>
#include <errno.h>
-#include <arpa/inet.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/timer.h>
diff --git a/src/gsm/lapdm.c b/src/gsm/lapdm.c
index 1fdf311c..99099d19 100644
--- a/src/gsm/lapdm.c
+++ b/src/gsm/lapdm.c
@@ -31,7 +31,6 @@
#include <stdint.h>
#include <string.h>
#include <errno.h>
-#include <arpa/inet.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/timer.h>
diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index ab4a28eb..74f3b48d 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -29,13 +29,12 @@
#include <osmocom/core/talloc.h>
#include <osmocom/core/select.h>
#include <osmocom/core/socket.h>
+#include <osmocom/core/byteswap.h>
#include <osmocom/gsm/protocol/gsm_04_08.h>
#include <osmocom/gsm/rsl.h>
#include <sys/types.h>
-#include <arpa/inet.h>
-
#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
@@ -123,10 +122,10 @@ struct msgb *gsmtap_makemsg_ex(uint8_t type, uint16_t arfcn, uint8_t ts, uint8_t
gh->type = type;
gh->timeslot = ts;
gh->sub_slot = ss;
- gh->arfcn = htons(arfcn);
+ gh->arfcn = osmo_htons(arfcn);
gh->snr_db = snr;
gh->signal_dbm = signal_dbm;
- gh->frame_number = htonl(fn);
+ gh->frame_number = osmo_htonl(fn);
gh->sub_type = chan_type;
gh->antenna_nr = 0;
diff --git a/src/logging_gsmtap.c b/src/logging_gsmtap.c
index 85f8c28b..f37f8e7d 100644
--- a/src/logging_gsmtap.c
+++ b/src/logging_gsmtap.c
@@ -32,7 +32,6 @@
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
-#include <arpa/inet.h>
#ifdef HAVE_STRINGS_H
#include <strings.h>
@@ -44,6 +43,7 @@
#include <osmocom/core/gsmtap_util.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/timer.h>
+#include <osmocom/core/byteswap.h>
#define GSMTAP_LOG_MAX_SIZE 4096
@@ -81,12 +81,12 @@ static void _gsmtap_raw_output(struct log_target *target, int subsys,
else
golh->subsys[0] = '\0';
osmo_strlcpy(golh->src_file.name, file, sizeof(golh->src_file.name));
- golh->src_file.line_nr = htonl(line);
+ golh->src_file.line_nr = osmo_htonl(line);
golh->level = level;
/* we always store the timestamp in the message, irrespective
* of hat prrint_[ext_]timestamp say */
- golh->ts.sec = htonl(tv.tv_sec);
- golh->ts.usec = htonl(tv.tv_usec);
+ golh->ts.sec = osmo_htonl(tv.tv_sec);
+ golh->ts.usec = osmo_htonl(tv.tv_usec);
rc = vsnprintf((char *) msg->tail, msgb_tailroom(msg), format, ap);
if (rc < 0)
diff --git a/src/stats.c b/src/stats.c
index dee5d81a..9c826ccf 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -21,6 +21,7 @@
*
*/
+#include <osmocom/core/byteswap.h>
#include <osmocom/core/stats.h>
#include <unistd.h>
@@ -195,7 +196,7 @@ int osmo_stats_reporter_set_remote_port(struct osmo_stats_reporter *srep, int po
return -ENOTSUP;
srep->dest_port = port;
- sock_addr->sin_port = htons(port);
+ sock_addr->sin_port = osmo_htons(port);
return update_srep_config(srep);
}