Add linux-kpi wireless compat layer

Red Bear OS Team
This commit is contained in:
2026-04-16 12:43:33 +01:00
parent 6c418bb03b
commit f44940a562
10 changed files with 1245 additions and 0 deletions
@@ -0,0 +1,20 @@
#ifndef _LINUX_IEEE80211_H
#define _LINUX_IEEE80211_H
#include "types.h"
#define IEEE80211_MAX_SSID_LEN 32
#define IEEE80211_NUM_ACS 4
struct ieee80211_channel {
u16 center_freq;
u16 hw_value;
u32 flags;
};
struct ieee80211_rate {
u16 bitrate;
u16 hw_value;
};
#endif
@@ -0,0 +1,36 @@
#ifndef _LINUX_NETDEVICE_H
#define _LINUX_NETDEVICE_H
#include "device.h"
#include "types.h"
#include <stddef.h>
struct net_device {
char name[16];
unsigned char dev_addr[6];
unsigned char addr_len;
unsigned int mtu;
unsigned int flags;
int carrier;
void *ml_priv;
void *ieee80211_ptr;
void *priv_data;
int registered;
size_t __priv_alloc_size;
size_t __priv_alloc_align;
};
extern struct net_device *alloc_netdev_mqs(size_t sizeof_priv,
const char *name,
unsigned char name_assign_type,
void (*setup)(struct net_device *dev),
unsigned int txqs,
unsigned int rxqs);
extern void free_netdev(struct net_device *dev);
extern int register_netdev(struct net_device *dev);
extern void unregister_netdev(struct net_device *dev);
extern void netif_carrier_on(struct net_device *dev);
extern void netif_carrier_off(struct net_device *dev);
extern int netif_carrier_ok(const struct net_device *dev);
#endif
@@ -0,0 +1,25 @@
#ifndef _LINUX_NL80211_H
#define _LINUX_NL80211_H
enum nl80211_iftype {
NL80211_IFTYPE_UNSPECIFIED = 0,
NL80211_IFTYPE_ADHOC = 1,
NL80211_IFTYPE_STATION = 2,
NL80211_IFTYPE_AP = 3,
NL80211_IFTYPE_MONITOR = 6,
};
enum nl80211_commands {
NL80211_CMD_UNSPEC = 0,
NL80211_CMD_TRIGGER_SCAN = 33,
NL80211_CMD_NEW_SCAN_RESULTS = 34,
NL80211_CMD_AUTHENTICATE = 37,
NL80211_CMD_ASSOCIATE = 38,
NL80211_CMD_CONNECT = 46,
NL80211_CMD_DISCONNECT = 48,
NL80211_CMD_SET_KEY = 80,
};
#define NL80211_MAX_NR_CIPHER_SUITES 5
#endif
@@ -0,0 +1,24 @@
#ifndef _LINUX_SKBUFF_H
#define _LINUX_SKBUFF_H
#include "types.h"
struct sk_buff {
void *head;
void *data;
unsigned int len;
unsigned int tail;
unsigned int end;
};
extern struct sk_buff *alloc_skb(unsigned int size, gfp_t gfp_mask);
extern void kfree_skb(struct sk_buff *skb);
extern void skb_reserve(struct sk_buff *skb, unsigned int len);
extern void *skb_put(struct sk_buff *skb, unsigned int len);
extern void *skb_push(struct sk_buff *skb, unsigned int len);
extern void *skb_pull(struct sk_buff *skb, unsigned int len);
extern unsigned int skb_headroom(const struct sk_buff *skb);
extern unsigned int skb_tailroom(const struct sk_buff *skb);
extern void skb_trim(struct sk_buff *skb, unsigned int len);
#endif
@@ -0,0 +1,108 @@
#ifndef _NET_CFG80211_H
#define _NET_CFG80211_H
#include "../linux/device.h"
#include "../linux/ieee80211.h"
#include "../linux/netdevice.h"
#include "../linux/types.h"
#include <stddef.h>
#include <stdbool.h>
struct wiphy {
void *privid;
int registered;
u32 interface_modes;
int max_scan_ssids;
int max_scan_ie_len;
};
struct wireless_dev {
struct wiphy *wiphy;
struct net_device *netdev;
u32 iftype;
bool scan_in_flight;
bool scan_aborted;
bool connecting;
bool connected;
bool locally_generated;
u16 last_status;
u16 last_reason;
bool has_bssid;
u8 last_bssid[6];
};
struct cfg80211_scan_info {
bool aborted;
};
struct cfg80211_scan_request {
struct wiphy *wiphy;
struct wireless_dev *wdev;
u32 n_ssids;
u32 n_channels;
};
struct cfg80211_ssid {
u8 ssid[IEEE80211_MAX_SSID_LEN];
u8 ssid_len;
};
struct key_params {
const u8 *key;
u8 key_len;
u32 cipher;
};
struct cfg80211_connect_params {
const u8 *ssid;
size_t ssid_len;
const u8 *bssid;
const u8 *ie;
size_t ie_len;
struct key_params key;
};
struct station_parameters {
const u8 *supported_rates;
size_t supported_rates_len;
u32 sta_flags_mask;
u32 sta_flags_set;
};
extern struct wiphy *wiphy_new_nm(const void *ops, size_t sizeof_priv, const char *requested_name);
extern void wiphy_free(struct wiphy *wiphy);
extern int wiphy_register(struct wiphy *wiphy);
extern void wiphy_unregister(struct wiphy *wiphy);
extern void cfg80211_scan_done(struct cfg80211_scan_request *request,
const struct cfg80211_scan_info *info);
extern void cfg80211_connect_result(struct net_device *dev,
const u8 *bssid,
const u8 *req_ie,
size_t req_ie_len,
const u8 *resp_ie,
size_t resp_ie_len,
u16 status,
gfp_t gfp);
extern void cfg80211_disconnected(struct net_device *dev,
u16 reason,
const u8 *ie,
size_t ie_len,
bool locally_generated,
gfp_t gfp);
extern void cfg80211_connect_bss(struct net_device *dev,
const u8 *bssid,
const u8 *req_ie,
size_t req_ie_len,
const u8 *resp_ie,
size_t resp_ie_len,
u16 status,
gfp_t gfp);
extern void cfg80211_ready_on_channel(struct wireless_dev *wdev,
u64 cookie,
struct ieee80211_channel *chan,
u32 chan_type,
u32 duration,
gfp_t gfp);
#endif
@@ -0,0 +1,47 @@
#ifndef _NET_MAC80211_H
#define _NET_MAC80211_H
#include "../linux/device.h"
#include "../linux/netdevice.h"
#include "../linux/skbuff.h"
#include "../linux/types.h"
#include "cfg80211.h"
struct ieee80211_hw {
struct wiphy *wiphy;
void *priv;
int registered;
u32 extra_tx_headroom;
u16 queues;
};
struct ieee80211_vif {
u8 addr[6];
void *drv_priv;
u32 type;
bool cfg_assoc;
};
struct ieee80211_sta {
u8 addr[6];
void *drv_priv;
u16 aid;
};
struct ieee80211_bss_conf {
bool assoc;
u16 aid;
u16 beacon_int;
};
extern struct ieee80211_hw *ieee80211_alloc_hw_nm(size_t priv_data_len,
const void *ops,
const char *requested_name);
extern void ieee80211_free_hw(struct ieee80211_hw *hw);
extern int ieee80211_register_hw(struct ieee80211_hw *hw);
extern void ieee80211_unregister_hw(struct ieee80211_hw *hw);
extern void ieee80211_queue_work(struct ieee80211_hw *hw, void *work);
extern void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted);
extern void ieee80211_connection_loss(struct ieee80211_vif *vif);
#endif