[gprs] Use stdint.h types (uintXX_t instead of u_intXX_t)
libosmocore already uses them, it's time (at least for new code)
in openbsc to do the same.
diff --git a/openbsc/src/gprs_bssgp.c b/openbsc/src/gprs_bssgp.c
index 6bba1af..a3fa3ec 100644
--- a/openbsc/src/gprs_bssgp.c
+++ b/openbsc/src/gprs_bssgp.c
@@ -21,7 +21,7 @@
*/
#include <errno.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <netinet/in.h>
@@ -147,26 +147,26 @@
}
/* Transmit a simple response such as BLOCK/UNBLOCK/RESET ACK/NACK */
-static int bssgp_tx_simple_bvci(u_int8_t pdu_type, u_int16_t nsei,
- u_int16_t bvci, u_int16_t ns_bvci)
+static int bssgp_tx_simple_bvci(uint8_t pdu_type, uint16_t nsei,
+ uint16_t bvci, uint16_t ns_bvci)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
(struct bssgp_normal_hdr *) msgb_put(msg, sizeof(*bgph));
- u_int16_t _bvci;
+ uint16_t _bvci;
msgb_nsei(msg) = nsei;
msgb_bvci(msg) = ns_bvci;
bgph->pdu_type = pdu_type;
_bvci = htons(bvci);
- msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (u_int8_t *) &_bvci);
+ msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
return gprs_ns_sendmsg(bssgp_nsi, msg);
}
/* Chapter 10.4.5: Flow Control BVC ACK */
-static int bssgp_tx_fc_bvc_ack(u_int16_t nsei, u_int8_t tag, u_int16_t ns_bvci)
+static int bssgp_tx_fc_bvc_ack(uint16_t nsei, uint8_t tag, uint16_t ns_bvci)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -182,7 +182,7 @@
}
/* Chapter 10.4.14: Status */
-int bssgp_tx_status(u_int8_t cause, u_int16_t *bvci, struct msgb *orig_msg)
+int bssgp_tx_status(uint8_t cause, uint16_t *bvci, struct msgb *orig_msg)
{
struct msgb *msg = bssgp_msgb_alloc();
struct bssgp_normal_hdr *bgph =
@@ -195,8 +195,8 @@
bgph->pdu_type = BSSGP_PDUT_STATUS;
msgb_tvlv_put(msg, BSSGP_IE_CAUSE, 1, &cause);
if (bvci) {
- u_int16_t _bvci = htons(*bvci);
- msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (u_int8_t *) &_bvci);
+ uint16_t _bvci = htons(*bvci);
+ msgb_tvlv_put(msg, BSSGP_IE_BVCI, 2, (uint8_t *) &_bvci);
}
if (orig_msg)
msgb_tvlv_put(msg, BSSGP_IE_PDU_IN_ERROR,
@@ -223,7 +223,7 @@
uint16_t bvci;
int rc;
- bvci = ntohs(*(u_int16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI));
+ bvci = ntohs(*(uint16_t *)TLVP_VAL(tp, BSSGP_IE_BVCI));
DEBUGPC(DGPRS, "BVCI=%u, cause=%s\n", bvci,
bssgp_cause_str(*TLVP_VAL(tp, BSSGP_IE_CAUSE)));
@@ -413,7 +413,7 @@
if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI) ||
!TLVP_PRESENT(&tp, BSSGP_IE_CAUSE))
goto err_mand_ie;
- bvci = ntohs(*(u_int16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
+ bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
DEBUGPC(DGPRS, "BVCI=%u, cause=%s\n", bvci,
bssgp_cause_str(*TLVP_VAL(&tp, BSSGP_IE_CAUSE)));
/* We always acknowledge the BLOCKing */
@@ -425,7 +425,7 @@
DEBUGP(DGPRS, "BSSGP BVC UNBLOCK ");
if (!TLVP_PRESENT(&tp, BSSGP_IE_BVCI))
goto err_mand_ie;
- bvci = ntohs(*(u_int16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
+ bvci = ntohs(*(uint16_t *)TLVP_VAL(&tp, BSSGP_IE_BVCI));
DEBUGPC(DGPRS, "BVCI=%u\n", bvci);
/* We always acknowledge the unBLOCKing */
rc = bssgp_tx_simple_bvci(BSSGP_PDUT_BVC_UNBLOCK_ACK,
@@ -485,11 +485,11 @@
{
struct bssgp_bts_ctx *bctx;
struct bssgp_ud_hdr *budh;
- u_int8_t llc_pdu_tlv_hdr_len = 2;
- u_int8_t *llc_pdu_tlv, *qos_profile;
- u_int16_t pdu_lifetime = 1000; /* centi-seconds */
- u_int8_t qos_profile_default[3] = { 0x00, 0x00, 0x21 };
- u_int16_t msg_len = msg->len;
+ uint8_t llc_pdu_tlv_hdr_len = 2;
+ uint8_t *llc_pdu_tlv, *qos_profile;
+ uint16_t pdu_lifetime = 1000; /* centi-seconds */
+ uint8_t qos_profile_default[3] = { 0x00, 0x00, 0x21 };
+ uint16_t msg_len = msg->len;
uint16_t bvci = msgb_bvci(msg);
uint16_t nsei = msgb_nsei(msg);
@@ -522,7 +522,7 @@
/* prepend the pdu lifetime */
pdu_lifetime = htons(pdu_lifetime);
- msgb_tvlv_push(msg, BSSGP_IE_PDU_LIFETIME, 2, (u_int8_t *)&pdu_lifetime);
+ msgb_tvlv_push(msg, BSSGP_IE_PDU_LIFETIME, 2, (uint8_t *)&pdu_lifetime);
/* prepend the QoS profile, TLLI and pdu type */
budh = (struct bssgp_ud_hdr *) msgb_push(msg, sizeof(*budh));
diff --git a/openbsc/src/gprs_llc.c b/openbsc/src/gprs_llc.c
index ba031a2..fdaa7b3 100644
--- a/openbsc/src/gprs_llc.c
+++ b/openbsc/src/gprs_llc.c
@@ -21,6 +21,7 @@
*/
#include <errno.h>
+#include <stdint.h>
#include <osmocore/msgb.h>
#include <osmocore/linuxlist.h>
@@ -52,12 +53,12 @@
enum gprs_llc_ll_state state;
- u_int32_t tlli;
- u_int32_t sapi;
+ uint32_t tlli;
+ uint32_t sapi;
- u_int8_t v_sent;
- u_int8_t v_ack;
- u_int8_t v_recv;
+ uint8_t v_sent;
+ uint8_t v_ack;
+ uint8_t v_recv;
unsigned int n200;
unsigned int retrans_ctr;
@@ -113,15 +114,15 @@
};
struct gprs_llc_hdr_parsed {
- u_int8_t sapi;
- u_int8_t is_cmd:1,
+ uint8_t sapi;
+ uint8_t is_cmd:1,
ack_req:1,
is_encrypted:1;
- u_int32_t seq_rx;
- u_int32_t seq_tx;
- u_int32_t fcs;
- u_int32_t fcs_calc;
- u_int8_t *data;
+ uint32_t seq_rx;
+ uint32_t seq_tx;
+ uint32_t fcs;
+ uint32_t fcs_calc;
+ uint8_t *data;
enum gprs_llc_cmd cmd;
};
@@ -130,9 +131,9 @@
#define N202 4
#define CRC24_LENGTH 3
-static int gprs_llc_fcs(u_int8_t *data, unsigned int len)
+static int gprs_llc_fcs(uint8_t *data, unsigned int len)
{
- u_int32_t fcs_calc;
+ uint32_t fcs_calc;
fcs_calc = crc24_calc(INIT_CRC24, data, len);
fcs_calc = ~fcs_calc;
@@ -192,13 +193,13 @@
}
/* Transmit a UI frame over the given SAPI */
-int gprs_llc_tx_ui(struct msgb *msg, u_int8_t sapi, int command)
+int gprs_llc_tx_ui(struct msgb *msg, uint8_t sapi, int command)
{
struct gprs_llc_lle *lle;
- u_int8_t *fcs, *llch;
- u_int8_t addr, ctrl[2];
- u_int32_t fcs_calc;
- u_int16_t nu = 0;
+ uint8_t *fcs, *llch;
+ uint8_t addr, ctrl[2];
+ uint32_t fcs_calc;
+ uint16_t nu = 0;
/* Identifiers from UP: (TLLI, SAPI) + (BVCI, NSEI) */
@@ -291,12 +292,12 @@
/* parse a GPRS LLC header, also check for invalid frames */
static int gprs_llc_hdr_parse(struct gprs_llc_hdr_parsed *ghp,
- const u_int8_t *llc_hdr, int len)
+ const uint8_t *llc_hdr, int len)
{
- u_int8_t *ctrl = llc_hdr+1;
+ uint8_t *ctrl = llc_hdr+1;
int is_sack = 0;
unsigned int crc_length;
- u_int32_t fcs_calc;
+ uint32_t fcs_calc;
if (len <= CRC24_LENGTH)
return -EIO;
@@ -336,7 +337,7 @@
if ((ctrl[0] & 0x80) == 0) {
/* I (Information transfer + Supervisory) format */
- u_int8_t k;
+ uint8_t k;
ghp->data = ctrl + 3;
diff --git a/openbsc/src/gprs_ns.c b/openbsc/src/gprs_ns.c
index 1558ca1..0db06c3 100644
--- a/openbsc/src/gprs_ns.c
+++ b/openbsc/src/gprs_ns.c
@@ -47,7 +47,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/types.h>
+#include <stdint.h>
#include <arpa/inet.h>
@@ -74,7 +74,7 @@
/* Lookup struct gprs_nsvc based on NSVCI */
static struct gprs_nsvc *nsvc_by_nsvci(struct gprs_ns_inst *nsi,
- u_int16_t nsvci)
+ uint16_t nsvci)
{
struct gprs_nsvc *nsvc;
llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
@@ -86,7 +86,7 @@
/* Lookup struct gprs_nsvc based on NSVCI */
static struct gprs_nsvc *nsvc_by_nsei(struct gprs_ns_inst *nsi,
- u_int16_t nsei)
+ uint16_t nsei)
{
struct gprs_nsvc *nsvc;
llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
@@ -109,7 +109,7 @@
return NULL;
}
-static struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, u_int16_t nsvci)
+static struct gprs_nsvc *nsvc_create(struct gprs_ns_inst *nsi, uint16_t nsvci)
{
struct gprs_nsvc *nsvc;
@@ -163,7 +163,7 @@
return ret;
}
-static int gprs_ns_tx_simple(struct gprs_nsvc *nsvc, u_int8_t pdu_type)
+static int gprs_ns_tx_simple(struct gprs_nsvc *nsvc, uint8_t pdu_type)
{
struct msgb *msg = msgb_alloc(NS_ALLOC_SIZE, "GPRS/NS");
struct gprs_ns_hdr *nsh;
@@ -211,7 +211,7 @@
{
struct msgb *msg = msgb_alloc(NS_ALLOC_SIZE, "GPRS/NS");
struct gprs_ns_hdr *nsh;
- u_int16_t nsvci, nsei;
+ uint16_t nsvci, nsei;
if (!msg)
return -ENOMEM;
@@ -225,8 +225,8 @@
DEBUGP(DGPRS, "nsvci=%u, nsei=%u\n", nsvc->nsvci, nsvc->nsei);
- msgb_tvlv_put(msg, NS_IE_VCI, 2, (u_int8_t *)&nsvci);
- msgb_tvlv_put(msg, NS_IE_NSEI, 2, (u_int8_t *)&nsei);
+ msgb_tvlv_put(msg, NS_IE_VCI, 2, (uint8_t *)&nsvci);
+ msgb_tvlv_put(msg, NS_IE_NSEI, 2, (uint8_t *)&nsei);
return gprs_ns_tx(nsvc, msg);
}
@@ -236,7 +236,7 @@
{
struct gprs_nsvc *nsvc;
struct gprs_ns_hdr *nsh;
- u_int16_t bvci = msgb_bvci(msg);
+ uint16_t bvci = msgb_bvci(msg);
nsvc = nsvc_by_nsei(nsi, msgb_nsei(msg));
if (!nsvc) {
@@ -262,7 +262,7 @@
static int gprs_ns_rx_unitdata(struct gprs_nsvc *nsvc, struct msgb *msg)
{
struct gprs_ns_hdr *nsh = (struct gprs_ns_hdr *)msg->l2h;
- u_int16_t bvci;
+ uint16_t bvci;
/* spare octet in data[0] */
bvci = nsh->data[1] << 8 | nsh->data[2];
@@ -278,7 +278,7 @@
{
struct gprs_ns_hdr *nsh = (struct gprs_ns_hdr *) msg->l2h;
struct tlv_parsed tp;
- u_int8_t cause;
+ uint8_t cause;
int rc;
DEBUGP(DGPRS, "NS STATUS ");
@@ -301,8 +301,8 @@
{
struct gprs_ns_hdr *nsh = (struct gprs_ns_hdr *) msg->l2h;
struct tlv_parsed tp;
- u_int8_t *cause;
- u_int16_t *nsvci, *nsei;
+ uint8_t *cause;
+ uint16_t *nsvci, *nsei;
int rc;
DEBUGP(DGPRS, "NS RESET ");
@@ -317,9 +317,9 @@
return -EINVAL;
}
- cause = (u_int8_t *) TLVP_VAL(&tp, NS_IE_CAUSE);
- nsvci = (u_int16_t *) TLVP_VAL(&tp, NS_IE_VCI);
- nsei = (u_int16_t *) TLVP_VAL(&tp, NS_IE_NSEI);
+ cause = (uint8_t *) TLVP_VAL(&tp, NS_IE_CAUSE);
+ nsvci = (uint16_t *) TLVP_VAL(&tp, NS_IE_VCI);
+ nsei = (uint16_t *) TLVP_VAL(&tp, NS_IE_NSEI);
nsvc->state = NSE_S_BLOCKED | NSE_S_ALIVE;
nsvc->nsei = ntohs(*nsei);
@@ -517,7 +517,7 @@
/* FIXME: this is currently in input/ipaccess.c */
-extern int make_sock(struct bsc_fd *bfd, int proto, u_int16_t port,
+extern int make_sock(struct bsc_fd *bfd, int proto, uint16_t port,
int (*cb)(struct bsc_fd *fd, unsigned int what));
/* Listen for incoming GPRS packets */
diff --git a/openbsc/src/gprs_sgsn.c b/openbsc/src/gprs_sgsn.c
index 9844f88..ba46719 100644
--- a/openbsc/src/gprs_sgsn.c
+++ b/openbsc/src/gprs_sgsn.c
@@ -20,7 +20,7 @@
*
*/
-#include <sys/types.h>
+#include <stdint.h>
#include <osmocore/linuxlist.h>
#include <osmocore/talloc.h>
@@ -41,7 +41,7 @@
}
/* look-up a SGSN MM context based on TLLI + RAI */
-struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(u_int32_t tlli,
+struct sgsn_mm_ctx *sgsn_mm_ctx_by_tlli(uint32_t tlli,
const struct gprs_ra_id *raid)
{
struct sgsn_mm_ctx *ctx;
@@ -54,7 +54,7 @@
return NULL;
}
-struct sgsn_mm_ctx *sgsn_mm_ctx_by_ptmsi(u_int32_t p_tmsi)
+struct sgsn_mm_ctx *sgsn_mm_ctx_by_ptmsi(uint32_t p_tmsi)
{
struct sgsn_mm_ctx *ctx;
@@ -78,7 +78,7 @@
}
/* Allocate a new SGSN MM context */
-struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(u_int32_t tlli,
+struct sgsn_mm_ctx *sgsn_mm_ctx_alloc(uint32_t tlli,
const struct gprs_ra_id *raid)
{
struct sgsn_mm_ctx *ctx = talloc_zero(NULL, struct sgsn_mm_ctx);
diff --git a/openbsc/src/gsm_04_08_gprs.c b/openbsc/src/gsm_04_08_gprs.c
index db439da..7d24657 100644
--- a/openbsc/src/gsm_04_08_gprs.c
+++ b/openbsc/src/gsm_04_08_gprs.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <stdint.h>
#include <errno.h>
#include <netinet/in.h>
@@ -97,7 +98,7 @@
{ 0, NULL }
};
-static const char *att_name(u_int8_t type)
+static const char *att_name(uint8_t type)
{
switch (type) {
case GPRS_ATT_T_ATTACH:
@@ -111,7 +112,7 @@
}
}
-static const char *upd_name(u_int8_t type)
+static const char *upd_name(uint8_t type)
{
switch (type) {
case GPRS_UPD_T_RA:
@@ -160,7 +161,7 @@
}
/* Chapter 9.4.5: Attach reject */
-static int gsm48_tx_gmm_att_rej(struct msgb *old_msg, u_int8_t gmm_cause)
+static int gsm48_tx_gmm_att_rej(struct msgb *old_msg, uint8_t gmm_cause)
{
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
@@ -179,7 +180,7 @@
}
/* Transmit Chapter 9.4.12 Identity Request */
-static int gsm48_tx_gmm_id_req(struct msgb *old_msg, u_int8_t id_type)
+static int gsm48_tx_gmm_id_req(struct msgb *old_msg, uint8_t id_type)
{
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
@@ -218,7 +219,7 @@
static int gsm48_rx_gmm_id_resp(struct msgb *msg)
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
- u_int8_t mi_type = gh->data[1] & GSM_MI_TYPE_MASK;
+ uint8_t mi_type = gh->data[1] & GSM_MI_TYPE_MASK;
char mi_string[GSM48_MI_SIZE];
struct gprs_ra_id ra_id;
struct sgsn_mm_ctx *ctx;
@@ -275,10 +276,10 @@
static int gsm48_rx_gmm_att_req(struct msgb *msg)
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
- u_int8_t *cur = gh->data, *msnc, *mi, *old_ra_info;
- u_int8_t msnc_len, att_type, mi_len, mi_type;
- u_int16_t drx_par;
- u_int32_t tmsi;
+ uint8_t *cur = gh->data, *msnc, *mi, *old_ra_info;
+ uint8_t msnc_len, att_type, mi_len, mi_type;
+ uint16_t drx_par;
+ uint32_t tmsi;
char mi_string[GSM48_MI_SIZE];
struct gprs_ra_id ra_id;
struct sgsn_mm_ctx *ctx;
@@ -398,7 +399,7 @@
}
/* Chapter 9.4.17: Routing area update reject */
-static int gsm48_tx_gmm_ra_upd_rej(struct msgb *old_msg, u_int8_t cause)
+static int gsm48_tx_gmm_ra_upd_rej(struct msgb *old_msg, uint8_t cause)
{
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
@@ -423,9 +424,9 @@
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
struct sgsn_mm_ctx *mmctx;
- u_int8_t *cur = gh->data;
+ uint8_t *cur = gh->data;
struct gprs_ra_id old_ra_id;
- u_int8_t upd_type;
+ uint8_t upd_type;
/* Update Type 10.5.5.18 */
upd_type = *cur++ & 0x0f;
@@ -524,7 +525,7 @@
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_act_pdp_ctx_ack *act_ack;
struct gsm48_hdr *gh;
- u_int8_t transaction_id = ((old_gh->proto_discr >> 4) ^ 0x8); /* flip */
+ uint8_t transaction_id = ((old_gh->proto_discr >> 4) ^ 0x8); /* flip */
DEBUGP(DMM, "<- ACTIVATE PDP CONTEXT ACK\n");
@@ -549,7 +550,7 @@
struct gsm48_hdr *old_gh = (struct gsm48_hdr *) msgb_gmmh(old_msg);
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
- u_int8_t transaction_id = ((old_gh->proto_discr >> 4) ^ 0x8); /* flip */
+ uint8_t transaction_id = ((old_gh->proto_discr >> 4) ^ 0x8); /* flip */
DEBUGP(DMM, "<- DEACTIVATE PDP CONTEXT ACK\n");
@@ -568,7 +569,7 @@
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
struct gsm48_act_pdp_ctx_req *act_req = (struct gsm48_act_pdp_ctx_req *) gh->data;
- u_int8_t *pdp_addr_lv = act_req->data;
+ uint8_t *pdp_addr_lv = act_req->data;
DEBUGP(DMM, "ACTIVATE PDP CONTEXT REQ\n");
@@ -633,7 +634,7 @@
int gsm0408_gprs_rcvmsg(struct msgb *msg)
{
struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_gmmh(msg);
- u_int8_t pdisc = gh->proto_discr & 0x0f;
+ uint8_t pdisc = gh->proto_discr & 0x0f;
int rc = -EINVAL;
switch (pdisc) {
@@ -654,7 +655,7 @@
/* Determine the 'struct gsm_bts' from a RA ID */
struct gsm_bts *gsm48_bts_by_ra_id(struct gsm_network *net,
- const u_int8_t *buf, unsigned int len)
+ const uint8_t *buf, unsigned int len)
{
struct gprs_ra_id raid;
struct gsm_bts *bts;