mirror of
https://github.com/open-sdr/openwifi.git
synced 2025-04-17 15:28:53 +00:00
Update setup and modules
This commit is contained in:
parent
9439ded3b1
commit
045a2300f1
10
driver/wp4/Makefile
Executable file
10
driver/wp4/Makefile
Executable file
@ -0,0 +1,10 @@
|
||||
# Paul Zanna
|
||||
|
||||
obj-m += wp4-p4.o
|
||||
|
||||
all:
|
||||
make -C $(KDIR) M=$(PWD) modules
|
||||
# ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
|
||||
|
||||
clean:
|
||||
rm -f *.ko *.o *.mod.o *.mod.c *.symvers *.order
|
243
driver/wp4/wp4-p4.c
Normal file
243
driver/wp4/wp4-p4.c
Normal file
@ -0,0 +1,243 @@
|
||||
/* Automatically generated by p4c-wp4 from test_wp4.p4 on Thu Dec 10 15:00:42 2020
|
||||
*/
|
||||
#include <linux/module.h> // included for all kernel modules
|
||||
#include <linux/kernel.h> // included for KERN_INFO
|
||||
#include <linux/init.h> // included for __init and __exit macros
|
||||
#include <linux/fs.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/skbuff.h>
|
||||
#include <linux/netdevice.h>
|
||||
|
||||
|
||||
#include "wp4-p4.h"
|
||||
|
||||
#define WP4_MASK(t, w) ((((t)(1)) << (w)) - (t)1)
|
||||
#define BYTES(w) ((w) / 8)
|
||||
|
||||
static int __init wp4_init(void) {
|
||||
printk(KERN_INFO "WP4: Loading WP4 LKM!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit wp4_exit(void) {
|
||||
printk(KERN_INFO "WP4: Removing WP4 LKM!\n");
|
||||
}
|
||||
|
||||
static inline void dump_rx_packet(u8 *ptr)
|
||||
{
|
||||
int i;
|
||||
printk("\n");
|
||||
printk("***********************************************\n");
|
||||
for (i = 0; i < 64; i = i + 16)
|
||||
printk("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n", *(ptr + i),
|
||||
*(ptr + i + 1), *(ptr + i + 2) , *(ptr + i + 3) , *(ptr + i + 4), *(ptr + i + 5), *(ptr + i + 6), *(ptr + i + 7),
|
||||
*(ptr + i + 8), *(ptr + i + 9), *(ptr + i + 10) , *(ptr + i + 11) , *(ptr + i + 12), *(ptr + i + 13), *(ptr + i + 14), *(ptr + i + 15));
|
||||
printk("***********************************************\n");
|
||||
}
|
||||
|
||||
int wp4_packet_in(u8 *p_uc_data, u16 wp4_ul_size, u8 port){
|
||||
|
||||
struct Headers_t headers = {
|
||||
.rfFeatures = {
|
||||
.wp4_valid = 0
|
||||
},
|
||||
.frameCtrl = {
|
||||
.wp4_valid = 0
|
||||
},
|
||||
.mac80211 = {
|
||||
.wp4_valid = 0
|
||||
},
|
||||
};
|
||||
|
||||
u16 wp4_packetOffsetInBits = 0;
|
||||
u8 *wp4_packetStart = p_uc_data;
|
||||
struct wp4_output wp4out;
|
||||
struct wp4_input wp4in;
|
||||
wp4in.input_port = port;
|
||||
|
||||
goto start;
|
||||
|
||||
// Start of Parser
|
||||
start: {
|
||||
/* extract(headers.rfFeatures)*/
|
||||
if ((wp4_ul_size * 8) < 256) {
|
||||
|
||||
goto accept;
|
||||
}
|
||||
memcpy(&headers.rfFeatures.timestamp, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(64));
|
||||
//headers.rfFeatures.timestamp = htonll(headers.rfFeatures.timestamp);
|
||||
wp4_packetOffsetInBits += 64;
|
||||
|
||||
memcpy(&headers.rfFeatures.rssi, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(16));
|
||||
//headers.rfFeatures.rssi = htons(headers.rfFeatures.rssi);
|
||||
wp4_packetOffsetInBits += 16;
|
||||
|
||||
memcpy(&headers.rfFeatures.blank, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(16));
|
||||
//headers.rfFeatures.blank = htons(headers.rfFeatures.blank);
|
||||
wp4_packetOffsetInBits += 16;
|
||||
|
||||
memcpy(&headers.rfFeatures.len, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(16));
|
||||
//headers.rfFeatures.len = htons(headers.rfFeatures.len);
|
||||
wp4_packetOffsetInBits += 16;
|
||||
|
||||
memcpy(&headers.rfFeatures.rate_idx, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(16));
|
||||
//headers.rfFeatures.rate_idx = htons(headers.rfFeatures.rate_idx);
|
||||
wp4_packetOffsetInBits += 16;
|
||||
|
||||
memcpy(&headers.rfFeatures.aux_1, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(32));
|
||||
//headers.rfFeatures.aux_1 = htonl(headers.rfFeatures.aux_1);
|
||||
wp4_packetOffsetInBits += 32;
|
||||
|
||||
memcpy(&headers.rfFeatures.freqOffset, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(32));
|
||||
//headers.rfFeatures.freqOffset = htonl(headers.rfFeatures.freqOffset);
|
||||
wp4_packetOffsetInBits += 32;
|
||||
|
||||
memcpy(&headers.rfFeatures.aux_3, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(32));
|
||||
//headers.rfFeatures.aux_3 = htonl(headers.rfFeatures.aux_3);
|
||||
wp4_packetOffsetInBits += 32;
|
||||
|
||||
memcpy(&headers.rfFeatures.aux_4, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(32));
|
||||
//headers.rfFeatures.aux_4 = htonl(headers.rfFeatures.aux_4);
|
||||
wp4_packetOffsetInBits += 32;
|
||||
|
||||
headers.rfFeatures.wp4_valid = 1;
|
||||
switch (headers.rfFeatures.aux_1) {
|
||||
case 0xccccdddd: goto mac;
|
||||
default: goto accept;
|
||||
}
|
||||
}
|
||||
mac: {
|
||||
/* extract(headers.frameCtrl)*/
|
||||
if ((wp4_ul_size * 8) < 16) {
|
||||
|
||||
goto accept;
|
||||
}
|
||||
memcpy(&headers.frameCtrl.protoVer, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.protoVer >>= 6;
|
||||
headers.frameCtrl.protoVer &= WP4_MASK(u8, 2);
|
||||
wp4_packetOffsetInBits += 2;
|
||||
|
||||
memcpy(&headers.frameCtrl.frameType, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.frameType >>= 4;
|
||||
headers.frameCtrl.frameType &= WP4_MASK(u8, 2);
|
||||
wp4_packetOffsetInBits += 2;
|
||||
|
||||
memcpy(&headers.frameCtrl.subType, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.subType &= WP4_MASK(u8, 4);
|
||||
wp4_packetOffsetInBits += 4;
|
||||
|
||||
memcpy(&headers.frameCtrl.toDS, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.toDS >>= 7;
|
||||
headers.frameCtrl.toDS &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.fromDS, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.fromDS >>= 6;
|
||||
headers.frameCtrl.fromDS &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.moreFrag, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.moreFrag >>= 5;
|
||||
headers.frameCtrl.moreFrag &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.retry, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.retry >>= 4;
|
||||
headers.frameCtrl.retry &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.pwrMgmt, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.pwrMgmt >>= 3;
|
||||
headers.frameCtrl.pwrMgmt &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.moreData, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.moreData >>= 2;
|
||||
headers.frameCtrl.moreData &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.protFrame, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.protFrame >>= 1;
|
||||
headers.frameCtrl.protFrame &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
memcpy(&headers.frameCtrl.order, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(8));
|
||||
headers.frameCtrl.order &= WP4_MASK(u8, 1);
|
||||
wp4_packetOffsetInBits += 1;
|
||||
|
||||
headers.frameCtrl.wp4_valid = 1;
|
||||
switch (headers.frameCtrl.frameType) {
|
||||
case 0x0: goto mgnt;
|
||||
default: goto accept;
|
||||
}
|
||||
}
|
||||
mgnt: {
|
||||
/* extract(headers.mac80211)*/
|
||||
if ((wp4_ul_size * 8) < 224) {
|
||||
|
||||
goto accept;
|
||||
}
|
||||
memcpy(&headers.mac80211.durID, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(16));
|
||||
headers.mac80211.durID = htons(headers.mac80211.durID);
|
||||
wp4_packetOffsetInBits += 16;
|
||||
|
||||
memcpy(&headers.mac80211.Addr1, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(64));
|
||||
headers.mac80211.Addr1 = htonll(headers.mac80211.Addr1) >> 16;
|
||||
headers.mac80211.Addr1 &= WP4_MASK(u64, 48);
|
||||
wp4_packetOffsetInBits += 48;
|
||||
|
||||
memcpy(&headers.mac80211.Addr2, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(64));
|
||||
headers.mac80211.Addr2 = htonll(headers.mac80211.Addr2) >> 16;
|
||||
headers.mac80211.Addr2 &= WP4_MASK(u64, 48);
|
||||
wp4_packetOffsetInBits += 48;
|
||||
|
||||
memcpy(&headers.mac80211.Addr3, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(64));
|
||||
headers.mac80211.Addr3 = htonll(headers.mac80211.Addr3) >> 16;
|
||||
headers.mac80211.Addr3 &= WP4_MASK(u64, 48);
|
||||
wp4_packetOffsetInBits += 48;
|
||||
|
||||
memcpy(&headers.mac80211.seqCtrl, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(16));
|
||||
headers.mac80211.seqCtrl = htons(headers.mac80211.seqCtrl);
|
||||
wp4_packetOffsetInBits += 16;
|
||||
|
||||
memcpy(&headers.mac80211.Addr4, wp4_packetStart + BYTES(wp4_packetOffsetInBits), BYTES(64));
|
||||
headers.mac80211.Addr4 = htonll(headers.mac80211.Addr4) >> 16;
|
||||
headers.mac80211.Addr4 &= WP4_MASK(u64, 48);
|
||||
wp4_packetOffsetInBits += 48;
|
||||
|
||||
headers.mac80211.wp4_valid = 1;
|
||||
goto accept;
|
||||
}
|
||||
|
||||
reject: { return 1; }
|
||||
|
||||
|
||||
// Start of Pipeline
|
||||
accept:
|
||||
{
|
||||
u8 hit;
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Start of Deparser
|
||||
dump_rx_packet(wp4_packetStart);
|
||||
printk("** WP4 Packet received - Size = %d **\n", wp4_ul_size);
|
||||
printk("** aux_vals: %08X %d %08X %08X **\n\n", headers.rfFeatures.aux_1, headers.rfFeatures.freqOffset, headers.rfFeatures.aux_3, headers.rfFeatures.aux_4);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Kernel module functions
|
||||
EXPORT_SYMBOL(wp4_packet_in);
|
||||
|
||||
module_init(wp4_init);
|
||||
module_exit(wp4_exit);
|
||||
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_AUTHOR("test_wp4.p4");
|
||||
MODULE_DESCRIPTION("WP4");
|
||||
MODULE_VERSION("0.1");
|
||||
|
65
driver/wp4/wp4-p4.h
Normal file
65
driver/wp4/wp4-p4.h
Normal file
@ -0,0 +1,65 @@
|
||||
/* Automatically generated by p4c-wp4 from test_wp4.p4 on Thu Dec 10 15:00:42 2020
|
||||
*/
|
||||
#ifndef _P4_GEN_HEADER_
|
||||
#define _P4_GEN_HEADER_
|
||||
|
||||
#define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((x) >> 32))
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
int wp4_packet_in(u8 *p_uc_data, u16 wp4_ul_size, u8 port);
|
||||
|
||||
struct wp4_input {
|
||||
u32 input_port; /* bit<32> */
|
||||
};
|
||||
|
||||
struct wp4_output {
|
||||
u32 output_port; /* bit<32> */
|
||||
};
|
||||
|
||||
struct rfFeatures_t {
|
||||
u64 timestamp; /* bit<64> */
|
||||
u16 rssi; /* bit<16> */
|
||||
u16 blank; /* bit<16> */
|
||||
u16 len; /* bit<16> */
|
||||
u16 rate_idx; /* bit<16> */
|
||||
u32 aux_1; /* bit<32> */
|
||||
s32 freqOffset; /* int<32> */
|
||||
u32 aux_3; /* bit<32> */
|
||||
u32 aux_4; /* bit<32> */
|
||||
u8 wp4_valid;
|
||||
};
|
||||
|
||||
struct frameCtrl_t {
|
||||
u8 protoVer; /* bit<2> */
|
||||
u8 frameType; /* bit<2> */
|
||||
u8 subType; /* bit<4> */
|
||||
u8 toDS; /* bit<1> */
|
||||
u8 fromDS; /* bit<1> */
|
||||
u8 moreFrag; /* bit<1> */
|
||||
u8 retry; /* bit<1> */
|
||||
u8 pwrMgmt; /* bit<1> */
|
||||
u8 moreData; /* bit<1> */
|
||||
u8 protFrame; /* bit<1> */
|
||||
u8 order; /* bit<1> */
|
||||
u8 wp4_valid;
|
||||
};
|
||||
|
||||
struct mac80211_t {
|
||||
u16 durID; /* bit<16> */
|
||||
u64 Addr1; /* macAddr_t */
|
||||
u64 Addr2; /* macAddr_t */
|
||||
u64 Addr3; /* macAddr_t */
|
||||
u16 seqCtrl; /* bit<16> */
|
||||
u64 Addr4; /* macAddr_t */
|
||||
u8 wp4_valid;
|
||||
};
|
||||
|
||||
struct Headers_t {
|
||||
struct rfFeatures_t rfFeatures; /* rfFeatures_t */
|
||||
struct frameCtrl_t frameCtrl; /* frameCtrl_t */
|
||||
struct mac80211_t mac80211; /* mac80211_t */
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -7,7 +7,7 @@ cd ~/openwifi
|
||||
service network-manager stop
|
||||
./wgd.sh
|
||||
ifconfig sdr0 192.168.13.1
|
||||
route add default gw 192.168.10.1
|
||||
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
||||
service isc-dhcp-server restart
|
||||
hostapd hostapd-openwifi.conf &
|
||||
sleep 5
|
||||
|
@ -1,8 +1,8 @@
|
||||
|
||||
#!/bin/bash
|
||||
if [ "$#" -ne 4 ]; then
|
||||
if [ "$#" -ne 7 ]; then
|
||||
echo "You have input $# arguments."
|
||||
echo "You must enter exactly 4 arguments: \$OPENWIFI_DIR \$XILINX_DIR \$BOARD_NAME \$SDCARD_DIR"
|
||||
echo "You must enter exactly 7 arguments: \$OPENWIFI_DIR \$XILINX_DIR \$BOARD_NAME \$SDCARD_DIR \$OPENWIFI_IP \$OPENWIFI_NETMASK \$OPENWIFI_GW"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -10,6 +10,9 @@ OPENWIFI_DIR=$1
|
||||
XILINX_DIR=$2
|
||||
BOARD_NAME=$3
|
||||
SDCARD_DIR=$4
|
||||
OPENWIFI_IP=$5
|
||||
OPENWIFI_NETMASK=$6
|
||||
OPENWIFI_GW=$7
|
||||
|
||||
if [ -f "$OPENWIFI_DIR/LICENSE" ]; then
|
||||
echo "\$OPENWIFI_DIR is found!"
|
||||
@ -152,7 +155,7 @@ sudo cp $OPENWIFI_DIR/kernel_boot/70-persistent-net.rules $SDCARD_DIR/rootfs/etc
|
||||
sudo mv $SDCARD_DIR/rootfs/lib/udev/rules.d/75-persistent-net-generator.rules $SDCARD_DIR/rootfs/lib/udev/rules.d/75-persistent-net-generator.rules.bak
|
||||
|
||||
# Some setup
|
||||
sudo echo -e "\nauto lo eth0\niface lo inet loopback\niface eth0 inet static\naddress 192.168.10.122\nnetmask 255.255.255.0\n" | sudo tee -a $SDCARD_DIR/rootfs/etc/network/interfaces
|
||||
sudo echo -e "\nauto lo eth0\niface lo inet loopback\niface eth0 inet static\naddress "$OPENWIFI_IP"\nnetmask "$OPENWIFI_NETMASK"\ngateway "$OPENWIFI_GW"\n" | sudo tee -a $SDCARD_DIR/rootfs/etc/network/interfaces
|
||||
sudo echo -e "\nnameserver 8.8.8.8\nnameserver 4.4.4.4\n" | sudo tee -a $SDCARD_DIR/rootfs/etc/resolv.conf
|
||||
sudo echo -e "\nUseDNS no\n" | sudo tee -a $SDCARD_DIR/rootfs/etc/ssh/sshd_config
|
||||
sudo echo -e "\nnet.ipv4.ip_forward=1\n" | sudo tee -a $SDCARD_DIR/rootfs/etc/sysctl.conf
|
||||
|
@ -188,6 +188,24 @@ then
|
||||
fi
|
||||
sleep 0.5
|
||||
|
||||
SUBMODULE=wp4-p4
|
||||
if [ $last_input == "remote" ]
|
||||
then
|
||||
rm $SUBMODULE.ko
|
||||
sync
|
||||
wget ftp://192.168.10.1/driver/$SUBMODULE/$SUBMODULE.ko
|
||||
sync
|
||||
fi
|
||||
rmmod $SUBMODULE
|
||||
insmod $SUBMODULE.ko
|
||||
|
||||
echo check $SUBMODULE module is loaded or not
|
||||
checkModule $SUBMODULE
|
||||
if [ $? -eq 1 ]
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
PROG=sdr
|
||||
if [ $last_input == "remote" ]
|
||||
then
|
||||
|
Loading…
x
Reference in New Issue
Block a user