Move generic definitions away from hostapd.h
authorJouni Malinen <j@w1.fi>
Thu, 8 Jan 2009 18:14:05 +0000 (20:14 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 8 Jan 2009 18:14:05 +0000 (20:14 +0200)
This is an initial step in trying to make hostapd.h not needed to be
included in so many files.

hostapd/ctrl_iface.c
hostapd/driver.h
hostapd/driver_nl80211.c
hostapd/driver_wired.c
hostapd/hostapd.h
hostapd/hostapd_defs.h [new file with mode: 0644]

index 7afd859..82c3d51 100644 (file)
@@ -30,6 +30,7 @@
 #include "sta_info.h"
 #include "accounting.h"
 #include "wps_hostapd.h"
+#include "driver.h"
 
 
 struct wpa_ctrl_dst {
index 8a6d91b..edf12e3 100644 (file)
 #ifndef DRIVER_H
 #define DRIVER_H
 
+struct hostapd_data;
+
+struct hostap_sta_driver_data {
+       unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
+       unsigned long current_tx_rate;
+       unsigned long inactive_msec;
+       unsigned long flags;
+       unsigned long num_ps_buf_frames;
+       unsigned long tx_retry_failed;
+       unsigned long tx_retry_count;
+       int last_rssi;
+       int last_ack_rssi;
+};
+
 struct hostapd_sta_add_params {
        const u8 *addr;
        u16 aid;
@@ -197,4 +211,7 @@ struct wpa_driver_ops {
                                     const u8 *ie, size_t len);
 };
 
+void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
+                          int reassoc);
+
 #endif /* DRIVER_H */
index 9f26d5d..3ed7652 100644 (file)
@@ -529,7 +529,7 @@ static int i802_set_rts(void *priv, int rts)
        struct iwreq iwr;
 
        memset(&iwr, 0, sizeof(iwr));
-       os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
        iwr.u.rts.value = rts;
        iwr.u.rts.fixed = 1;
 
@@ -548,7 +548,7 @@ static int i802_get_rts(void *priv, int *rts)
        struct iwreq iwr;
 
        memset(&iwr, 0, sizeof(iwr));
-       os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
 
        if (ioctl(drv->ioctl_sock, SIOCGIWRTS, &iwr) < 0) {
                perror("ioctl[SIOCGIWRTS]");
@@ -567,7 +567,7 @@ static int i802_set_frag(void *priv, int frag)
        struct iwreq iwr;
 
        memset(&iwr, 0, sizeof(iwr));
-       os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
        iwr.u.frag.value = frag;
        iwr.u.frag.fixed = 1;
 
@@ -586,7 +586,7 @@ static int i802_get_frag(void *priv, int *frag)
        struct iwreq iwr;
 
        memset(&iwr, 0, sizeof(iwr));
-       os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
 
        if (ioctl(drv->ioctl_sock, SIOCGIWFRAG, &iwr) < 0) {
                perror("ioctl[SIOCGIWFRAG]");
@@ -605,7 +605,7 @@ static int i802_set_retry(void *priv, int short_retry, int long_retry)
        struct iwreq iwr;
 
        memset(&iwr, 0, sizeof(iwr));
-       os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
 
        iwr.u.retry.value = short_retry;
        iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
@@ -631,7 +631,7 @@ static int i802_get_retry(void *priv, int *short_retry, int *long_retry)
        struct iwreq iwr;
 
        memset(&iwr, 0, sizeof(iwr));
-       os_strlcpy(iwr.ifr_name, drv->hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(iwr.ifr_name, drv->iface, IFNAMSIZ);
 
        iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
        if (ioctl(drv->ioctl_sock, SIOCGIWRETRY, &iwr) < 0) {
@@ -1009,8 +1009,7 @@ static int nl80211_create_iface(struct i802_driver_data *drv,
 
        genlmsg_put(msg, 0, 0, genl_family_get_id(drv->nl80211), 0,
                    0, NL80211_CMD_NEW_INTERFACE, 0);
-       NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX,
-                   if_nametoindex(drv->hapd->conf->iface));
+       NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, if_nametoindex(drv->iface));
        NLA_PUT_STRING(msg, NL80211_ATTR_IFNAME, ifname);
        NLA_PUT_U32(msg, NL80211_ATTR_IFTYPE, iftype);
 
index 61cb667..60b036e 100644 (file)
@@ -38,6 +38,7 @@
 
 struct wired_driver_data {
        struct hostapd_data *hapd;
+       char iface[IFNAMSIZ + 1];
 
        int sock; /* raw packet socket for driver access */
        int dhcp_sock; /* socket for dhcp packets */
@@ -197,7 +198,7 @@ static int wired_init_sockets(struct wired_driver_data *drv)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       os_strlcpy(ifr.ifr_name, hapd->conf->iface, sizeof(ifr.ifr_name));
+       os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
        if (ioctl(drv->sock, SIOCGIFINDEX, &ifr) != 0) {
                perror("ioctl(SIOCGIFINDEX)");
                return -1;
@@ -229,7 +230,7 @@ static int wired_init_sockets(struct wired_driver_data *drv)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       os_strlcpy(ifr.ifr_name, hapd->conf->iface, sizeof(ifr.ifr_name));
+       os_strlcpy(ifr.ifr_name, drv->iface, sizeof(ifr.ifr_name));
        if (ioctl(drv->sock, SIOCGIFHWADDR, &ifr) != 0) {
                perror("ioctl(SIOCGIFHWADDR)");
                return -1;
@@ -271,7 +272,7 @@ static int wired_init_sockets(struct wired_driver_data *drv)
        }
 
        memset(&ifr, 0, sizeof(ifr));
-       os_strlcpy(ifr.ifr_ifrn.ifrn_name, hapd->conf->iface, IFNAMSIZ);
+       os_strlcpy(ifr.ifr_ifrn.ifrn_name, drv->iface, IFNAMSIZ);
        if (setsockopt(drv->dhcp_sock, SOL_SOCKET, SO_BINDTODEVICE,
                       (char *) &ifr, sizeof(ifr)) < 0) {
                perror("setsockopt[SOL_SOCKET,SO_BINDTODEVICE]");
@@ -339,6 +340,7 @@ static void * wired_driver_init(struct hostapd_data *hapd)
        }
 
        drv->hapd = hapd;
+       os_strlcpy(drv->iface, hapd->conf->iface, sizeof(drv->iface));
        drv->use_pae_group_addr = hapd->conf->use_pae_group_addr;
 
        if (wired_init_sockets(drv)) {
index 85bcf0b..e368aae 100644 (file)
 
 #include "common.h"
 #include "ap.h"
-
-#ifndef ETH_ALEN
-#define ETH_ALEN 6
-#endif
-#ifndef IFNAMSIZ
-#define IFNAMSIZ 16
-#endif
-#ifndef ETH_P_ALL
-#define ETH_P_ALL 0x0003
-#endif
-#ifndef ETH_P_PAE
-#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
-#endif /* ETH_P_PAE */
-#ifndef ETH_P_EAPOL
-#define ETH_P_EAPOL ETH_P_PAE
-#endif /* ETH_P_EAPOL */
-
-#ifndef ETH_P_RRB
-#define ETH_P_RRB 0x890D
-#endif /* ETH_P_RRB */
-
+#include "hostapd_defs.h"
 #include "config.h"
 
-#ifdef _MSC_VER
-#pragma pack(push, 1)
-#endif /* _MSC_VER */
-
-#define MAX_VLAN_ID 4094
-
-struct ieee8023_hdr {
-       u8 dest[6];
-       u8 src[6];
-       u16 ethertype;
-} STRUCT_PACKED;
-
-
-struct ieee80211_hdr {
-       le16 frame_control;
-       le16 duration_id;
-       u8 addr1[6];
-       u8 addr2[6];
-       u8 addr3[6];
-       le16 seq_ctrl;
-       /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
-        */
-} STRUCT_PACKED;
-
-#ifdef _MSC_VER
-#pragma pack(pop)
-#endif /* _MSC_VER */
-
-#define IEEE80211_DA_FROMDS addr1
-#define IEEE80211_BSSID_FROMDS addr2
-#define IEEE80211_SA_FROMDS addr3
-
-#define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
-
-#define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
-
-/* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
- * frames that might be longer than normal default MTU and they are not
- * fragmented */
-#define HOSTAPD_MTU 2290
-
 extern unsigned char rfc1042_header[6];
 
-struct hostap_sta_driver_data {
-       unsigned long rx_packets, tx_packets, rx_bytes, tx_bytes;
-       unsigned long current_tx_rate;
-       unsigned long inactive_msec;
-       unsigned long flags;
-       unsigned long num_ps_buf_frames;
-       unsigned long tx_retry_failed;
-       unsigned long tx_retry_count;
-       int last_rssi;
-       int last_ack_rssi;
-};
-
 struct wpa_driver_ops;
 struct wpa_ctrl_dst;
 struct radius_server_data;
@@ -228,8 +155,6 @@ struct hostapd_iface {
 #endif /* CONFIG_IEEE80211N */
 };
 
-void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
-                          int reassoc);
 int hostapd_reload_config(struct hostapd_iface *iface);
 
 #endif /* HOSTAPD_H */
diff --git a/hostapd/hostapd_defs.h b/hostapd/hostapd_defs.h
new file mode 100644 (file)
index 0000000..d18483a
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * hostapd / Initialization and configuration
+ * Host AP kernel driver
+ * Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#ifndef HOSTAPD_DEFS_H
+#define HOSTAPD_DEFS_H
+
+#ifndef ETH_ALEN
+#define ETH_ALEN 6
+#endif
+#ifndef IFNAMSIZ
+#define IFNAMSIZ 16
+#endif
+#ifndef ETH_P_ALL
+#define ETH_P_ALL 0x0003
+#endif
+#ifndef ETH_P_PAE
+#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
+#endif /* ETH_P_PAE */
+#ifndef ETH_P_EAPOL
+#define ETH_P_EAPOL ETH_P_PAE
+#endif /* ETH_P_EAPOL */
+
+#ifndef ETH_P_RRB
+#define ETH_P_RRB 0x890D
+#endif /* ETH_P_RRB */
+
+#ifdef _MSC_VER
+#pragma pack(push, 1)
+#endif /* _MSC_VER */
+
+#define MAX_VLAN_ID 4094
+
+struct ieee8023_hdr {
+       u8 dest[6];
+       u8 src[6];
+       u16 ethertype;
+} STRUCT_PACKED;
+
+
+struct ieee80211_hdr {
+       le16 frame_control;
+       le16 duration_id;
+       u8 addr1[6];
+       u8 addr2[6];
+       u8 addr3[6];
+       le16 seq_ctrl;
+       /* followed by 'u8 addr4[6];' if ToDS and FromDS is set in data frame
+        */
+} STRUCT_PACKED;
+
+#ifdef _MSC_VER
+#pragma pack(pop)
+#endif /* _MSC_VER */
+
+#define IEEE80211_DA_FROMDS addr1
+#define IEEE80211_BSSID_FROMDS addr2
+#define IEEE80211_SA_FROMDS addr3
+
+#define IEEE80211_HDRLEN (sizeof(struct ieee80211_hdr))
+
+#define IEEE80211_FC(type, stype) host_to_le16((type << 2) | (stype << 4))
+
+/* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
+ * frames that might be longer than normal default MTU and they are not
+ * fragmented */
+#define HOSTAPD_MTU 2290
+
+#endif /* HOSTAPD_DEFS_H */