Commit f1806e88 authored by Bruno Randolf's avatar Bruno Randolf

Use C99 stdint.h

parent 90a85af5
......@@ -22,6 +22,8 @@
#ifndef _NET_BATMAN_ADV_PACKET_H_
#define _NET_BATMAN_ADV_PACKET_H_
#include <stdint.h>
#define ETH_ALEN 6
#define ETH_P_BATMAN 0x4305 /* unofficial/not registered Ethertype */
......
......@@ -18,9 +18,11 @@
#ifndef _NET_BATMAN_ADV_PACKET_H_
#define _NET_BATMAN_ADV_PACKET_H_
#include <stdint.h>
#define BIT(_x) (1<_x)
typedef u_int16_t __be16;
typedef u_int32_t __be32;
typedef uint16_t __be16;
typedef uint32_t __be32;
#define ETH_ALEN 6
#define __BIG_ENDIAN_BITFIELD /* todo */
......
......@@ -129,9 +129,9 @@ filter_input(WINDOW *win, int c)
int i, t;
switch (c) {
case 'm': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_MGMT], 0xffff, u_int16_t); break;
case 'c': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_CTRL], 0xffff, u_int16_t); break;
case 'd': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_DATA], 0xffff, u_int16_t); break;
case 'm': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_MGMT], 0xffff, uint16_t); break;
case 'c': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_CTRL], 0xffff, uint16_t); break;
case 'd': TOGGLE_BITSET(conf.filter_stype[WLAN_FRAME_TYPE_DATA], 0xffff, uint16_t); break;
case 'r': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ARP); break;
case 'M': TOGGLE_BIT(conf.filter_pkt, PKT_TYPE_ICMP); break;
......
......@@ -2,7 +2,6 @@
#include <net/if.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <err.h>
......
......@@ -23,7 +23,6 @@
#include <net/if.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#include <netlink/attr.h>
......@@ -398,7 +397,7 @@ static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
list->band[b].max_chan_width = CHAN_WIDTH_20_NOHT; /* default */
if (bands[NL80211_BAND_ATTR_HT_CAPA]) {
u_int16_t cap = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
uint16_t cap = nla_get_u16(bands[NL80211_BAND_ATTR_HT_CAPA]);
if (cap & WLAN_IE_HT_CAPAB_INFO_CHAN_WIDTH_40)
list->band[b].max_chan_width = CHAN_WIDTH_40;
else
......@@ -412,7 +411,7 @@ static int nl80211_get_freqlist_cb(struct nl_msg *msg, void *arg)
}
if (bands[NL80211_BAND_ATTR_VHT_CAPA]) {
u_int32_t vht = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
uint32_t vht = nla_get_u32(bands[NL80211_BAND_ATTR_VHT_CAPA]);
list->band[b].max_chan_width = chan_width_from_vht_capab(vht);
}
......
......@@ -110,12 +110,12 @@ struct packet_info {
/* wlan mac */
unsigned int wlan_len; /* packet length */
u_int16_t wlan_type; /* frame control field */
uint16_t wlan_type; /* frame control field */
unsigned char wlan_src[MAC_LEN]; /* transmitter (TA) */
unsigned char wlan_dst[MAC_LEN]; /* receiver (RA) */
unsigned char wlan_bssid[MAC_LEN];
char wlan_essid[WLAN_MAX_SSID_LEN];
u_int64_t wlan_tsf; /* timestamp from beacon */
uint64_t wlan_tsf; /* timestamp from beacon */
unsigned int wlan_bintval; /* beacon interval */
unsigned int wlan_mode; /* AP, STA or IBSS */
unsigned char wlan_channel; /* channel from beacon, probe */
......@@ -176,7 +176,7 @@ struct node_info {
unsigned char wlan_bssid[MAC_LEN];
unsigned int wlan_channel; /* channel from beacon, probe frames */
unsigned int wlan_mode; /* AP, STA or IBSS */
u_int64_t wlan_tsf;
uint64_t wlan_tsf;
unsigned int wlan_bintval;
unsigned int wlan_retries_all;
unsigned int wlan_retries_last;
......@@ -315,7 +315,7 @@ struct config {
char filtermac_enabled[MAX_FILTERMAC];
unsigned char filterbssid[MAC_LEN];
unsigned int filter_pkt;
u_int16_t filter_stype[WLAN_NUM_TYPES]; /* one for MGMT, CTRL, DATA */
uint16_t filter_stype[WLAN_NUM_TYPES]; /* one for MGMT, CTRL, DATA */
unsigned int filter_mode;
unsigned int filter_off:1,
filter_badfcs:1,
......
......@@ -77,7 +77,7 @@ struct net_conf_filter {
unsigned char filtermac[MAX_FILTERMAC][MAC_LEN];
char filtermac_enabled[MAX_FILTERMAC];
unsigned char filterbssid[MAC_LEN];
u_int16_t filter_stype[WLAN_NUM_TYPES];
uint16_t filter_stype[WLAN_NUM_TYPES];
int filter_pkt;
int filter_mode;
......@@ -128,7 +128,7 @@ struct net_packet_info {
unsigned char wlan_dst[MAC_LEN];
unsigned char wlan_bssid[MAC_LEN];
char wlan_essid[WLAN_MAX_SSID_LEN];
u_int64_t wlan_tsf; /* timestamp from beacon */
uint64_t wlan_tsf; /* timestamp from beacon */
unsigned int wlan_bintval; /* beacon interval */
unsigned int wlan_mode; /* AP, STA or IBSS */
unsigned char wlan_channel; /* channel from beacon, probe */
......
......@@ -44,12 +44,11 @@
#ifndef _OLSR_HEADER_H_
#define _OLSR_HEADER_H_
#include <sys/types.h>
#include <netinet/in.h>
typedef u_int8_t olsr_u8_t;
typedef u_int16_t olsr_u16_t;
typedef u_int32_t olsr_u32_t;
typedef uint8_t olsr_u8_t;
typedef uint16_t olsr_u16_t;
typedef uint32_t olsr_u32_t;
/* from olsr olsr_protocol.h */
......
......@@ -32,7 +32,7 @@
#ifndef _PRISM_HEADER_H_
#define _PRISM_HEADER_H_
#include <sys/types.h>
#include <stdint.h>
enum {
DIDmsg_lnxind_wlansniffrm = 0x00000044,
......@@ -56,17 +56,17 @@ enum {
};
typedef struct {
u_int32_t did;
u_int16_t status;
u_int16_t len;
u_int32_t data;
uint32_t did;
uint16_t status;
uint16_t len;
uint32_t data;
} p80211item_uint32_t;
typedef struct {
u_int32_t msgcode;
u_int32_t msglen;
uint32_t msgcode;
uint32_t msglen;
#define WLAN_DEVNAMELEN_MAX 16
u_int8_t devname[WLAN_DEVNAMELEN_MAX];
uint8_t devname[WLAN_DEVNAMELEN_MAX];
p80211item_uint32_t hosttime;
p80211item_uint32_t mactime;
p80211item_uint32_t channel;
......
......@@ -379,10 +379,10 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
{
struct wlan_frame* wh;
int hdrlen;
u_int8_t* ra = NULL;
u_int8_t* ta = NULL;
u_int8_t* bssid = NULL;
u_int16_t fc, cap_i;
uint8_t* ra = NULL;
uint8_t* ta = NULL;
uint8_t* bssid = NULL;
uint16_t fc, cap_i;
if (len < 10) /* minimum frame size (CTS/ACK) */
return -1;
......@@ -415,7 +415,7 @@ parse_80211_header(unsigned char** buf, int len, struct packet_info* p)
p->wlan_mode = WLAN_MODE_4ADDR;
hdrlen += 6;
if (WLAN_FRAME_IS_QOS(fc)) {
u_int16_t qos = le16toh(wh->u.addr4_qos_ht.qos);
uint16_t qos = le16toh(wh->u.addr4_qos_ht.qos);
DEBUG("4ADDR A-MSDU %x\n", qos & WLAN_FRAME_QOS_AMSDU_PRESENT);
if (qos & WLAN_FRAME_QOS_AMSDU_PRESENT)
bssid = wh->addr3;
......
......@@ -128,7 +128,7 @@ kilo_mega_ize(unsigned int val);
* TOGGLE_BITSET() - toggle set of bits as a whole
* @_x: an integer variable
* @_s: an integer variable interpreted as a bitset
* @_t: type (e.g. u_int16_t)
* @_t: type (e.g. uint16_t)
* If any of the bits are set, all bits will be unset. Otherwise, if
* none of the bits are set, all bits will be set.
*/
......
......@@ -20,26 +20,26 @@
#ifndef _WLAN_HEADER_H_
#define _WLAN_HEADER_H_
#include <sys/types.h>
#include <stdint.h>
struct wlan_frame {
u_int16_t fc;
u_int16_t duration;
u_int8_t addr1[6];
u_int8_t addr2[6];
u_int8_t addr3[6];
u_int16_t seq;
uint16_t fc;
uint16_t duration;
uint8_t addr1[6];
uint8_t addr2[6];
uint8_t addr3[6];
uint16_t seq;
union {
u_int16_t qos;
u_int8_t addr4[6];
uint16_t qos;
uint8_t addr4[6];
struct {
u_int16_t qos;
u_int32_t ht;
uint16_t qos;
uint32_t ht;
} __attribute__ ((packed)) ht;
struct {
u_int8_t addr4[6];
u_int16_t qos;
u_int32_t ht;
uint8_t addr4[6];
uint16_t qos;
uint32_t ht;
} __attribute__ ((packed)) addr4_qos_ht;
} u;
} __attribute__ ((packed));
......@@ -139,9 +139,9 @@ struct wlan_frame {
/* beacon + probe response */
struct wlan_frame_beacon {
u_int64_t tsf;
u_int16_t bintval;
u_int16_t capab;
uint64_t tsf;
uint16_t bintval;
uint16_t capab;
unsigned char ie[0];
} __attribute__ ((packed));
......@@ -166,8 +166,8 @@ struct wlan_frame_beacon {
/*** information elements ***/
struct information_element {
u_int8_t id;
u_int8_t len;
uint8_t id;
uint8_t len;
unsigned char var[0];
};
......
......@@ -82,7 +82,7 @@ static struct pkt_name unknow = { '?', "UNKNOW", 0, "Unknown" };
static struct pkt_name badfcs = { '*', "BADFCS", 0, "Bad FCS" };
struct pkt_name
get_packet_struct(u_int16_t type) {
get_packet_struct(uint16_t type) {
int t = WLAN_FRAME_TYPE(type);
if (type == 1) /* special case for bad FCS */
......@@ -97,14 +97,14 @@ get_packet_struct(u_int16_t type) {
char
get_packet_type_char(u_int16_t type)
get_packet_type_char(uint16_t type)
{
return get_packet_struct(type).c;
}
const char*
get_packet_type_name(u_int16_t type)
get_packet_type_name(uint16_t type)
{
return get_packet_struct(type).name;
}
......@@ -197,7 +197,7 @@ mcs_index_to_rate(int mcs, int ht20, int lgi)
}
enum chan_width chan_width_from_vht_capab(u_int32_t vht) {
enum chan_width chan_width_from_vht_capab(uint32_t vht) {
switch (((vht & WLAN_IE_VHT_CAPAB_INFO_CHAN_WIDTH) >> 2)) {
case WLAN_IE_VHT_CAPAB_INFO_CHAN_WIDTH_80: return CHAN_WIDTH_80;
case WLAN_IE_VHT_CAPAB_INFO_CHAN_WIDTH_160: return CHAN_WIDTH_160;
......@@ -230,7 +230,7 @@ void ht_streams_from_mcs_set(unsigned char* mcs, unsigned char* rx, unsigned cha
void vht_streams_from_mcs_set(unsigned char* mcs, unsigned char* rx, unsigned char* tx) {
int i;
/* RX */
u_int16_t tmp = mcs[0] | (mcs[1] << 8);
uint16_t tmp = mcs[0] | (mcs[1] << 8);
for (i = 0; i < 8; i++) {
if (((tmp >> (i*2)) & 3) == 3)
break;
......
......@@ -23,7 +23,7 @@
struct pkt_name {
const char c;
const char* name;
const u_int16_t fc;
const uint16_t fc;
const char* desc;
};
......@@ -34,13 +34,13 @@ struct pkt_name {
struct pkt_name stype_names[WLAN_NUM_TYPES][WLAN_NUM_STYPES];
struct pkt_name
get_packet_struct(u_int16_t type);
get_packet_struct(uint16_t type);
char
get_packet_type_char(u_int16_t type);
get_packet_type_char(uint16_t type);
const char*
get_packet_type_name(u_int16_t type);
get_packet_type_name(uint16_t type);
int
rate_to_index(int rate);
......@@ -52,7 +52,7 @@ int
mcs_index_to_rate(int mcs, int ht20, int lgi);
enum chan_width
chan_width_from_vht_capab(u_int32_t vht);
chan_width_from_vht_capab(uint32_t vht);
void
ht_streams_from_mcs_set(unsigned char* mcs, unsigned char* rx, unsigned char* tx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment