BigW Consortium Gitlab

Commit 9e531c86 by David Clark

Updates after getting encryption working

parent cf879ddc
......@@ -257,6 +257,7 @@ static int mt7697_wext_siwessid(struct net_device *ndev,
struct iw_point *data,
char *ssid)
{
u8 pmk[MT7697_WIFI_LENGTH_PMK] = {0};
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct wireless_dev *wdev = ndev->ieee80211_ptr;
struct mt7697_vif *vif = mt7697_vif_from_wdev(wdev);
......@@ -317,11 +318,25 @@ static int mt7697_wext_siwessid(struct net_device *ndev,
}
}
ret = mt7697_wr_set_pmk_req(cfg, vif->pmk);
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_wr_set_pmk_req() failed(%d)\n",
__func__, ret);
goto cleanup;
if (memcmp(pmk, vif->pmk, sizeof(pmk))) {
ret = mt7697_wr_set_pmk_req(cfg, vif->pmk);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_set_pmk_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
else {
ret = mt7697_wr_set_security_mode_req(cfg,
MT7697_WIFI_AUTH_MODE_OPEN,
MT7697_WIFI_ENCRYPT_TYPE_ENCRYPT_DISABLED);
if (ret < 0) {
dev_err(cfg->dev,
"%s(): mt7697_wr_set_security_mode_req() failed(%d)\n",
__func__, ret);
goto cleanup;
}
}
if (len > 0) {
......
......@@ -34,7 +34,7 @@ static int mt7697_open(struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
int ret;
int ret = 0;
dev_dbg(cfg->dev, "%s(): open net device\n", __func__);
......@@ -57,7 +57,7 @@ static int mt7697_open(struct net_device *ndev)
netif_carrier_on(ndev);
netif_wake_queue(ndev);
} else
netif_carrier_off(ndev);
netif_carrier_on(ndev);
cleanup:
return ret;
......@@ -97,7 +97,8 @@ static void mt7697_set_multicast_list(struct net_device *ndev)
bool mc_all_on = false;
int mc_count = netdev_mc_count(ndev);
dev_dbg(cfg->dev, "%s(): net device set multicast\n", __func__);
dev_dbg(cfg->dev, "%s(): net device set multicast flags(0x%08x)\n",
__func__, ndev->flags);
/* Enable multicast-all filter. */
mc_all_on = !!(ndev->flags & IFF_PROMISC) ||
......
sources:
{
wmi.c
cfg80211.c
main.c
txrx.c
ioctl.c
}
cflags:
{
// -DDEBUG
-DCONFIG_WIRELESS_EXT
-DCONFIG_CFG80211_WEXT
-I$MANGOH_ROOT/linux_kernel_modules/mt7697q
}
......@@ -11,17 +11,31 @@ export ITF_WAN="rmnet0" # 3G/4G interface as WLAN interface
export WIFIAPIP="192.168.20.1"
export WIFIAPMASK="255.255.255.0"
export SUBNET="192.168.0.0/24"
#export SUBNET="192.168.0.0/24"
export WIFIAPSTART="192.168.20.10"
export WIFIAPSTOP="192.168.20.100"
# DHCP config file
export DHCP_CFG_FILE=dnsmasq.wlan.conf
/sbin/ifup wlan1
echo "Mounting of $ITF_LAN..."
/sbin/ifup $ITF_LAN
ifconfig $ITF_LAN $WIFIAPIP netmask $WIFIAPMASK up
echo "Reconfiguring the DHCP server..."
/etc/init.d/dnsmasq stop || echo -ne ">>>>>>>>>>>>>>>>>>> UNABLE TO STOP THE DHCP server"
### Configure the IP addresses range for DHCP (dnsmasq)
test -L /etc/dnsmasq.d/$DHCP_CFG_FILE || ln -s /tmp/$DHCP_CFG_FILE /etc/dnsmasq.d/$DHCP_CFG_FILE
echo "Generating the configuration file for the DHCP server..."
echo -ne "log-dhcp\nlog-queries\n" \
"log-facility=/tmp/dnsmasq.log\n" \
"interface=$ITF_LAN\n" \
"dhcp-option=$ITF_LAN,3,$WIFIAPIP\n" \
"dhcp-option=$ITF_LAN,6,$WIFIAPIP\n" \
"dhcp-range=$WIFIAPSTART,$WIFIAPSTOP,24h\n" \
"server=8.8.8.8\n" >> /tmp/$DHCP_CFG_FILE
echo "Mounting the relay interface $ITF_WAN..."
case "$ITF_WAN" in
eth*)
......@@ -38,56 +52,30 @@ case "$ITF_WAN" in
echo "Waiting for data connection on $ITF_WAN..."
;;
esac
RETRY=0
while [ $RETRY -lt 30 ] ; do
ITF_WAN_ADDR=$(ifconfig $ITF_WAN | grep "inet addr" | cut -d ':' -f 2 | cut -d ' ' -f 1)
if [ "$ITF_WAN_ADDR" == "" ]; then
sleep 1
RETRY=$(($RETRY + 1))
else
break
fi
done
if [ "$ITF_WAN_ADDR" == "" ]; then
echo "Mounting of relay interface $ITF_WAN failed..."
else
echo "Relay interface $ITF_WAN IP address is $ITF_WAN_ADDR"
route add default gw $ITF_WAN_ADDR $ITF_WAN
fi
### Start the DHCP server
echo "Restarting the DHCP server..."
/etc/init.d/dnsmasq start || echo ">>>>>>>>>>>>>>>>>>> UNABLE TO START THE DHCP server"
echo "Enabling IP forwarding..."
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Configuring the NAT..."
modprobe ipt_MASQUERADE
iptables -A POSTROUTING -t nat -o $ITF_WAN -j MASQUERADE
iptables -A FORWARD --match state --state RELATED,ESTABLISHED --jump ACCEPT
iptables -A FORWARD -i $ITF_LAN --destination $SUBNET --match state --state NEW --jump ACCEPT
iptables -A INPUT -s $SUBNET --jump ACCEPT
echo "Check SIM inserted..."
cm sim
echo "Moving IP tables rules..."
if [ ! -d /etc/iptables/backup ]; then
mkdir /etc/iptables/backup
fi
if [ ! -f /etc/iptables/rules.v4 ]; then
mv /etc/iptables/rules.v4 /etc/iptables/backup/.
fi
if [ ! -f /etc/iptables/rules.v4 ]; then
mv /etc/iptables/rules.v6 /etc/iptables/backup/.
fi
echo "Cleaning IP tables..."
iptables --flush
iptables --table nat --flush
iptables --table nat --delete-chain
echo "Reconfiguring the DHCP server..."
/etc/init.d/dnsmasq stop || echo -ne ">>>>>>>>>>>>>>>>>>> UNABLE TO STOP THE DHCP server"
### Configure the IP addresses range for DHCP (dnsmasq)
test -L /etc/dnsmasq.d/$DHCP_CFG_FILE || ln -s /tmp/$DHCP_CFG_FILE /etc/dnsmasq.d/$DHCP_CFG_FILE
echo "Configuring the NAT..."
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables --table nat -A POSTROUTING -o $ITF_WAN -j MASQUERADE
iptables -A FORWARD -i $ITF_WAN -o $ITF_LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i $ITF_LAN -o $ITF_WAN -m state --state NEW -j ACCEPT
echo "Generating the configuration file for the DHCP server..."
echo -ne "log-dhcp\nlog-queries\nlog-facility=/tmp/dnsmasq.log\ndhcp-range=$ITF_LAN,$WIFIAPSTART,$WIFIAPSTOP,24h\nserver=8.8.8.8\n" >> /tmp/$DHCP_CFG_FILE
### Start the DHCP server
echo "Restarting the DHCP server..."
/etc/init.d/dnsmasq start || echo ">>>>>>>>>>>>>>>>>>> UNABLE TO START THE DHCP server"
echo "Enabling IP forwarding..."
sysctl -w net.ipv4.ip_forward=1
echo "Start wpa supplicant...."
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/flash/wifi
/mnt/flash/mtwifi/wpa_supplicant -Dwext -i wlan1 -c /etc/mt7697-ap -B
/mnt/flash/mtwifi/wpa_supplicant -Dwext -i $ITF_LAN -c /etc/mt7697-ap -B
......@@ -14,31 +14,19 @@ mt_wifi_start() {
lsmod | grep 0_cp2130 >/dev/null
if [ $? -eq 1 ]; then
insmod /mnt/flash/mtwifi/0-cp2130.ko || exit 127
insmod /legato/systems/current/modules/0-cp2130.ko || exit 127
echo "Initialized CP2130";
fi
lsmod | grep 1_mt7697q >/dev/null
if [ $? -eq 1 ]; then
insmod /mnt/flash/mtwifi/1-mt7697q.ko || exit 127
insmod /legato/systems/current/modules/1-mt7697q.ko || exit 127
echo "Initialized MT7697 queues";
fi
lsmod | grep cfg80211 >/dev/null
if [ $? -eq 1 ]; then
insmod /mnt/flash/mtwifi/cfg80211.ko || exit 127
echo "Initialized cfg80211";
fi
lsmod | grep mac80211 >/dev/null
if [ $? -eq 1 ]; then
insmod /mnt/flash/mtwifi/mac80211.ko || exit 127
echo "Initialized mac80211";
fi
fi
lsmod | grep 2_mt7697wifi_core >/dev/null
if [ $? -eq 1 ]; then
insmod /mnt/flash/mtwifi/2-mt7697wifi_core.ko itf_idx_start=$1 || exit 127
insmod /legato/systems/current/modules/2-mt7697wifi_core.ko itf_idx_start=$1 || exit 127
echo "Initialized MT7697 80211 core";
sleep 2
fi
......
......@@ -18,82 +18,6 @@
#include "common.h"
#include "core.h"
static int mt7697_ethernet_to_80211(struct sk_buff *skb,
struct net_device *ndev)
{
struct ieee80211_hdr hdr;
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
struct mt7697_vif *vif = netdev_priv(ndev);
struct ethhdr *eth_hdr = (struct ethhdr*)skb->data;
struct mt7697_llc_snap_hdr *llc_hdr;
u8 *datap;
int ret = 0;
__be16 type = eth_hdr->h_proto;
__le16 fc;
u16 hdrlen;
dev_dbg(cfg->dev, "%s(): Tx 802.3 Frame len(%u)\n",
__func__, skb->len);
// print_hex_dump(KERN_DEBUG, DRVNAME" 802.3 Frame ", DUMP_PREFIX_OFFSET,
// 16, 1, skb->data, skb->len, 0);
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
switch (vif->wdev.iftype) {
case NL80211_IFTYPE_STATION:
fc |= cpu_to_le16(IEEE80211_FCTL_TODS);
/* BSSID SA DA */
hdr.frame_control = fc;
memcpy(hdr.addr1, vif->bssid, ETH_ALEN);
memcpy(hdr.addr2, eth_hdr->h_source, ETH_ALEN);
memcpy(hdr.addr3, eth_hdr->h_dest, ETH_ALEN);
break;
case NL80211_IFTYPE_AP:
fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS);
/* DA BSSID SA */
hdr.frame_control = fc;
memcpy(hdr.addr1, eth_hdr->h_dest, ETH_ALEN);
memcpy(hdr.addr2, cfg->mac_addr.addr, ETH_ALEN);
memcpy(hdr.addr3, eth_hdr->h_source, ETH_ALEN);
break;
default:
dev_warn(cfg->dev, "%s(): unsupported iftype(%d)\n",
__func__, vif->wdev.iftype);
ret = -EINVAL;
goto cleanup;
}
hdr.duration_id = 0;
hdr.seq_ctrl = 0;
hdrlen = sizeof(struct ieee80211_hdr_3addr);
datap = skb_push(skb, hdrlen +
sizeof(struct mt7697_llc_snap_hdr) -
sizeof(struct ethhdr));
memcpy(datap, &hdr, hdrlen);
llc_hdr = (struct mt7697_llc_snap_hdr*)(datap + hdrlen);
llc_hdr->dsap = 0xAA;
llc_hdr->ssap = 0xAA;
llc_hdr->cntl = 0x03;
llc_hdr->org_code[0] = 0x0;
llc_hdr->org_code[1] = 0x0;
llc_hdr->org_code[2] = 0x0;
llc_hdr->eth_type = type;
dev_dbg(cfg->dev, "%s(): Tx 802.11 Frame len(%u)\n",
__func__, skb->len);
// print_hex_dump(KERN_DEBUG, DRVNAME" <-- Tx 802.11 Frame ",
// DUMP_PREFIX_OFFSET, 16, 1, skb->data, skb->len, 0);
cleanup:
return ret;
}
int mt7697_data_tx(struct sk_buff *skb, struct net_device *ndev)
{
struct mt7697_cfg80211_info *cfg = mt7697_priv(ndev);
......@@ -125,13 +49,6 @@ int mt7697_data_tx(struct sk_buff *skb, struct net_device *ndev)
}
}
ret = mt7697_ethernet_to_80211(skb, ndev);
if (ret < 0) {
dev_err(cfg->dev, "%s(): mt7697_ethernet_to_80211() failed(%d)\n",
__func__, ret);
goto cleanup;
}
cookie = mt7697_alloc_cookie(cfg);
if (cookie == NULL) {
ret = -ENOMEM;
......@@ -263,6 +180,8 @@ int mt7697_rx_data(struct mt7697_cfg80211_info *cfg, u32 len, u32 if_idx)
vif->net_stats.rx_bytes += len;
skb->protocol = eth_type_trans(skb, skb->dev);
dev_dbg(cfg->dev, "%s(): rx frame protocol(%u) type(%u)\n",
__func__, skb->protocol, skb->pkt_type);
ret = netif_rx_ni(skb);
if (ret != NET_RX_SUCCESS) {
......
......@@ -792,8 +792,8 @@ static int mt7697_rx_raw(const struct mt7697q_rsp_hdr* rsp,
goto cleanup;
}
// print_hex_dump(KERN_DEBUG, DRVNAME" RX ", DUMP_PREFIX_OFFSET,
// 16, 1, cfg->rx_data, rsp->result, 0);
print_hex_dump(KERN_DEBUG, DRVNAME" RX ", DUMP_PREFIX_OFFSET,
16, 1, cfg->rx_data, rsp->result, 0);
if (list_empty(&cfg->vif_list)) {
dev_dbg(cfg->dev, "%s(): no interfaces\n", __func__);
......
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