diff options
-rw-r--r-- | openbsc/include/openbsc/gprs_bssgp.h | 16 | ||||
-rw-r--r-- | openbsc/include/openbsc/gprs_ns.h | 16 | ||||
-rw-r--r-- | openbsc/src/gprs_bssgp.c | 36 | ||||
-rw-r--r-- | openbsc/src/gprs_ns.c | 34 |
4 files changed, 53 insertions, 49 deletions
diff --git a/openbsc/include/openbsc/gprs_bssgp.h b/openbsc/include/openbsc/gprs_bssgp.h index a00481e4..c70868af 100644 --- a/openbsc/include/openbsc/gprs_bssgp.h +++ b/openbsc/include/openbsc/gprs_bssgp.h @@ -1,6 +1,8 @@ #ifndef _GPRS_BSSGP_H #define _GPRS_BSSGP_H +#include <stdint.h> + /* Section 11.3.26 / Table 11.27 */ enum bssgp_pdu_type { /* PDUs between RL and BSSGP SAPs */ @@ -49,15 +51,15 @@ enum bssgp_pdu_type { /* Section 10.2.1 and 10.2.2 */ struct bssgp_ud_hdr { - u_int8_t pdu_type; - u_int32_t tlli; - u_int8_t qos_profile[3]; - u_int8_t data[0]; /* TLV's */ + uint8_t pdu_type; + uint32_t tlli; + uint8_t qos_profile[3]; + uint8_t data[0]; /* TLV's */ } __attribute__((packed)); struct bssgp_normal_hdr { - u_int8_t pdu_type; - u_int8_t data[0]; /* TLV's */ + uint8_t pdu_type; + uint8_t data[0]; /* TLV's */ }; enum bssgp_iei_type { @@ -140,7 +142,7 @@ enum gprs_bssgp_cause { extern int gprs_bssgp_rcvmsg(struct msgb *msg); /* Wrapper around TLV parser to parse BSSGP IEs */ -static inline int bssgp_tlv_parse(struct tlv_parsed *tp, u_int8_t *buf, int len) +static inline int bssgp_tlv_parse(struct tlv_parsed *tp, uint8_t *buf, int len) { return tlv_parse(tp, &tvlv_att_def, buf, len, 0, 0); } diff --git a/openbsc/include/openbsc/gprs_ns.h b/openbsc/include/openbsc/gprs_ns.h index ca02c4b5..573536d1 100644 --- a/openbsc/include/openbsc/gprs_ns.h +++ b/openbsc/include/openbsc/gprs_ns.h @@ -1,13 +1,15 @@ #ifndef _GPRS_NS_H #define _GPRS_NS_H +#include <stdint.h> + /* GPRS Networks Service (NS) messages on the Gb interface * 3GPP TS 08.16 version 8.0.1 Release 1999 / ETSI TS 101 299 V8.0.1 (2002-05) * 3GPP TS 48.016 version 6.5.0 Release 6 / ETSI TS 148 016 V6.5.0 (2005-11) */ struct gprs_ns_hdr { - u_int8_t pdu_type; - u_int8_t data[0]; + uint8_t pdu_type; + uint8_t data[0]; } __attribute__((packed)); /* TS 08.16, Section 10.3.7, Table 14 */ @@ -95,7 +97,7 @@ enum gprs_ns_evt { struct gprs_nsvc; typedef int gprs_ns_cb_t(enum gprs_ns_evt event, struct gprs_nsvc *nsvc, - struct msgb *msg, u_int16_t bvci); + struct msgb *msg, uint16_t bvci); /* An instance of the NS protocol stack */ struct gprs_ns_inst { @@ -120,11 +122,11 @@ struct gprs_nsvc { struct llist_head list; struct gprs_ns_inst *nsi; - u_int16_t nsei; /* end-to-end significance */ - u_int16_t nsvci; /* uniquely identifies NS-VC at SGSN */ + uint16_t nsei; /* end-to-end significance */ + uint16_t nsvci; /* uniquely identifies NS-VC at SGSN */ - u_int32_t state; - u_int32_t remote_state; + uint32_t state; + uint32_t remote_state; struct timer_list alive_timer; int timer_is_tns_alive; diff --git a/openbsc/src/gprs_bssgp.c b/openbsc/src/gprs_bssgp.c index 6bba1af8..a3fa3ecc 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 @@ static inline struct msgb *bssgp_msgb_alloc(void) } /* 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 @@ static int bssgp_tx_fc_bvc_ack(u_int16_t nsei, u_int8_t tag, u_int16_t ns_bvci) } /* 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 @@ int bssgp_tx_status(u_int8_t cause, u_int16_t *bvci, struct msgb *orig_msg) 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 @@ static int bssgp_rx_bvc_reset(struct msgb *msg, struct tlv_parsed *tp, 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 @@ int gprs_bssgp_rcvmsg(struct msgb *msg) 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 @@ int gprs_bssgp_rcvmsg(struct msgb *msg) 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 @@ int gprs_bssgp_tx_dl_ud(struct msgb *msg) { 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 @@ int gprs_bssgp_tx_dl_ud(struct msgb *msg) /* 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_ns.c b/openbsc/src/gprs_ns.c index 1558ca14..0db06c3f 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 @@ static const struct tlv_definition ns_att_tlvdef = { /* 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 @@ static struct gprs_nsvc *nsvc_by_nsvci(struct gprs_ns_inst *nsi, /* 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 @@ static struct gprs_nsvc *nsvc_by_rem_addr(struct gprs_ns_inst *nsi, 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 @@ static int gprs_ns_tx(struct gprs_nsvc *nsvc, struct msgb *msg) 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 @@ static int gprs_ns_tx_reset_ack(struct gprs_nsvc *nsvc) { 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 @@ static int gprs_ns_tx_reset_ack(struct gprs_nsvc *nsvc) 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 @@ int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg) { 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 @@ int gprs_ns_sendmsg(struct gprs_ns_inst *nsi, struct msgb *msg) 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 @@ static int gprs_ns_rx_status(struct gprs_nsvc *nsvc, struct msgb *msg) { 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 @@ static int gprs_ns_rx_reset(struct gprs_nsvc *nsvc, struct msgb *msg) { 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 @@ static int gprs_ns_rx_reset(struct gprs_nsvc *nsvc, struct msgb *msg) 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 @@ static int nsip_fd_cb(struct bsc_fd *bfd, unsigned int what) /* 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 */ |