WifiDog移植到Ralink_ApSoC_SDK_4210过程记录

configure的配置体系过于复杂,没有弄懂,只好动用brute force了。
借鉴了Ralink_ApSoC_SDK_4210(以后简称SDK)中ntfs-3g、snmpd的结构和Makefile
顶层Makefile内容:

#manfeel, port wifidog to ralink sdk
DIRS = libhttpd src

all romfs:
    for i in $(DIRS) ; do make -C $$i $@ || exit $?; done

clean:
    for i in $(DIRS) ; do make -C $$i clean ; done

libhttpd中的Makefile内容:

#manfeel, port wifidog to ralink sdk
OBJS = api.o ip_acl.o protocol.o version.o

LIBRARY = libhttpd.a

all: $(LIBRARY)

test:

romfs:

$(LIBRARY): $(OBJS)
    $(AR) rcv $@ $(OBJS)
    -$(RANLIB) $@

clean::
    $(RM) $(OBJS) $(LIBRARY)

src中的Makefile内容:

#manfeel, port wifidog to ralink sdk
WIFIDOG_OBJS =     auth.o client_list.o conf.o firewall.o gateway.o httpd_thread.o safe.o \
                centralserver.o  commandline.o  debug.o  fw_iptables.o  http.o     ping_thread.o   util.o  wdctl_thread.o

WDCTL_OBJS = wdctl.o

CFLAGS += -I../libhttpd 

USELIBS = ../libhttpd/libhttpd.a $(ROOTDIR)/lib/libpthread/libpthread.a

all: wifidog wdctl

test:

wifidog: $(WIFIDOG_OBJS) $(USELIBS)
    $(CC) $(LDFLAGS) -static -o $@ $(WIFIDOG_OBJS) $(USELIBS) $(LDLIBS)

wdctl: $(WDCTL_OBJS)
    $(CC) $(LDFLAGS) -static -o $@ $(WDCTL_OBJS) $(LDLIBS)

romfs:
    $(ROMFSINST) /usr/bin/wifidog
    $(ROMFSINST) /usr/bin/wdctl
    $(ROMFSINST) ../fs/wifidog-init /usr/bin/wifidog-init
    $(ROMFSINST) ../fs/wifidog.conf /etc_ro/wifidog.conf
    $(ROMFSINST) ../fs/wifidog-msg.html /etc_ro/wifidog-msg.html
    mkdir -p $(ROOTDIR)/romfs/etc_ro/init.d
    $(ROMFSINST) ../fs/init.d/wifidog /etc_ro/init.d/wifidog

clean:
    -rm -f $(EXEC) *.gdb *.elf *.o

注意:
1.SDK中没有init.d目录,只有/etc_ro/rcS脚本:
2.romfs中的内容,由vendors/Ralink/MT7620中的Makefile生成
3.ln命令默认没有打开!要在busybox的Coreutils里面打开。
4.rcS中加入wifidog相关内容

#!/bin/sh
mount -a
mkdir -p /var/run
cat /etc_ro/motd
#manfeel added

if [ ! -e /etc/wifidog.conf ] ; then
    ln -s /etc_ro/wifidog-msg.html /etc/wifidog-msg.html
    cp /etc_ro/wifidog.conf /etc/wifidog.conf
fi

nvram_daemon&

# run wifidog background and wait goahead finished
# but the following line does'nt work, cause goahead never finish
#(goahead& wait) && wifidog&

(sleep 30 & wait) && wifidog

#for telnet debugging
telnetd

#for syslogd
mkdir -p /var/log

#for cpe_app
ln -s /etc_ro/init.d /etc/init.d
ln -s /etc_ro/cron /etc/cron

编译之后,运行,发现iptables报错,原来是内核的iptables配置不全。

iptables v1.4.10: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
修改内核:

CONFIG_IP_NF_FILTER:                                                                                                                     │  
  │                                                                                                                                          │  
  │ Packet filtering defines a table `filter', which has a series of                                                                         │  
  │ rules for simple packet filtering at local input, forwarding and                                                                         │  
  │ local output.  See the man page for iptables(8).                                                                                         │  
  │                                                                                                                                          │  
  │ To compile it as a module, choose M here.  If unsure, say N.                                                                             │  
  │                                                                                                                                          │  
  │ Symbol: IP_NF_FILTER [=y]                                                                                                                │  
  │ Type  : tristate                                                                                                                         │  
  │ Prompt: Packet filtering                                                                                                                 │  
  │   Defined at net/ipv4/netfilter/Kconfig:106                                                                                              │  
  │   Depends on: NET [=y] && INET [=y] && NETFILTER [=y] && IP_NF_IPTABLES [=y]                                                             │  
  │   Location:                                                                                                                              │  
  │     -> Networking support (NET [=y])                                                                                                     │  
  │       -> Networking options                                                                                                              │  
  │         -> Network packet filtering framework (Netfilter) (NETFILTER [=y])                                                               │  
  │           -> IP: Netfilter Configuration                                                                                                 │  
  │             -> IP tables support (required for filtering/masq/NAT) (IP_NF_IPTABLES [=y])   

<*>   Packet filtering
<*>     REDIRECT target support 
<*>   Packet mangling 

烧录运行,又报:iptables: No chain/target/match by that name.

Symbol: NETFILTER_XT_MATCH_STATE [=n]                                                                                                    │  
 │ Type  : tristate                                                                                                                         │  
 │ Prompt: "state" match support                                                                                                            │  
 │   Defined at net/netfilter/Kconfig:979                                                                                                   │  
 │   Depends on: NET [=y] && INET [=y] && NETFILTER [=y] && NETFILTER_XTABLES [=y] && NF_CONNTRACK [=y]                                     │  
 │   Location:                                                                                                                              │  
 │     -> Networking support (NET [=y])                                                                                                     │  
 │       -> Networking options                                                                                                              │  
 │         -> Network packet filtering framework (Netfilter) (NETFILTER [=y])                                                               │  
 │           -> Core Netfilter Configuration                                                                                                │  
 │             -> Netfilter Xtables support (required for ip_tables) (NETFILTER_XTABLES [=y])                                               │ 

1.png

MARK,MAC都要选中,
Xtables matches 的所有match support最好全选中.
<*> "state" match support 必须选中(因为wifidog要用到-m state)

至此,整个移植过程结束。

本文章由 http://www.wifidog.pro/2015/01/27/wifidog%E7%A7%BB%E6%A4%8Dmtk.html 整理编辑,转载请注明出处

标签: wifidog认证 wifidog安装 wifidog原理 wifidog分析 wifidog配置 wifidog流程 wifidog服务器 wifidog-ddwrt wifidog openwrt