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])                                               │ 

image

MARK,MAC都要選中,

*** Xtables matches ***     的所有match support最好全選中.

<*>   "state" match support 必須選中(因爲wifidog要用到-m state)

 

  至此,整個移植過程結束。

發佈了59 篇原創文章 · 獲贊 12 · 訪問量 43萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章