Android pppoe

来源:互联网 发布:淘宝手机p图软件哪个好 编辑:程序博客网 时间:2024/06/02 04:05
1.android已经自带pppd程序,所以就不用移植pppd了

2.下载rp-pppoe代码
  wget -c http://www.roaringpenguin.com/files/download/rp-pppoe-3.10.tar.gz

3.把rp-pppoe-3.10.tar.gz解压到android的 external目录下

4.cd external/rp-pppoe-3.10/src
  1) ./configure --host=arm-linux
  2) vi config.h
    一、注释掉 #define HAVE_SYS_UIO_H 1 要不然会提示重定义的警告
    二、如果提示 if.c:34:26: error: net/ethernet.h: No such file or directory
       注释掉 #define HAVE_NET_ETHERNET_H 1
    三、我的config.h 内容如下

-------------------- config.h ---------------------------------------------
/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated automatically from configure.in by autoheader.  */
/* LIC: GPL */

/* Define to empty if the keyword does not work.  */
/* #undef const */

/* Define if you have <sys/wait.h> that is POSIX.1 compatible.  */
#define HAVE_SYS_WAIT_H 1

/* Define to `int' if <sys/types.h> doesn't define.  */
/* #undef pid_t */

/* Define as the return type of signal handlers (int or void).  */
#define RETSIGTYPE void

/* Define if the setvbuf function takes the buffering type as its second
   argument and the buffer pointer as the third, as on System V
   before release 3.  */
/* #undef SETVBUF_REVERSED */

/* Define if you have the ANSI C header files.  */
#define STDC_HEADERS 1

/* Define if you can safely include both <sys/time.h> and <time.h>.  */
#define TIME_WITH_SYS_TIME 1

/* Define if your <sys/time.h> declares struct tm.  */
/* #undef TM_IN_SYS_TIME */

#define HAVE_STRUCT_SOCKADDR_LL 1

/* The number of bytes in a unsigned int.  */
#define SIZEOF_UNSIGNED_INT 4

/* The number of bytes in a unsigned long.  */
#define SIZEOF_UNSIGNED_LONG 4

/* The number of bytes in a unsigned short.  */
#define SIZEOF_UNSIGNED_SHORT 2

/* Define if you have the select function.  */
#define HAVE_SELECT 1

/* Define if you have the socket function.  */
#define HAVE_SOCKET 1

/* Define if you have the strerror function.  */
#define HAVE_STRERROR 1

/* Define if you have the strtol function.  */
#define HAVE_STRTOL 1

/* Define if you have the <asm/types.h> header file.  */
#define HAVE_ASM_TYPES_H 1

/* Define if you have the <fcntl.h> header file.  */
#define HAVE_FCNTL_H 1

/* Define if you have the <getopt.h> header file.  */
#define HAVE_GETOPT_H 1

/* Define if you have the <linux/if_ether.h> header file.  */
#define HAVE_LINUX_IF_ETHER_H 1

/* Define if you have kernel-mode PPPoE in Linux file.  */
/* #undef HAVE_LINUX_KERNEL_PPPOE */

/* Define if you have the <linux/if_packet.h> header file.  */
#define HAVE_LINUX_IF_PACKET_H 1

/* Define if you have the <linux/if_pppox.h> header file.  */
#define HAVE_LINUX_IF_PPPOX_H 1

/* Define if you have the <net/bpf.h> header file.  */
/* #undef HAVE_NET_BPF_H */

/* Define if you have the <net/if_arp.h> header file.  */
#define HAVE_NET_IF_ARP_H 1

/* Define if you have the <net/ethernet.h> header file.  */
//#define HAVE_NET_ETHERNET_H 1

/* Define if you have the <net/if.h> header file.  */
#define HAVE_NET_IF_H 1

/* Define if you have the <linux/if.h> header file.  */
#define HAVE_LINUX_IF_H 1

/* Define if you have the <net/if_dl.h> header file.  */
/* #undef HAVE_NET_IF_DL_H */

/* Define if you have the <net/if_ether.h> header file.  */
/* #undef HAVE_NET_IF_ETHER_H */

/* Define if you have the <net/if_types.h> header file.  */
/* #undef HAVE_NET_IF_TYPES_H */

/* Define if you have the <netinet/if_ether.h> header file.  */
#define HAVE_NETINET_IF_ETHER_H 1

/* Define if you have the <netpacket/packet.h> header file.  */
#define HAVE_NETPACKET_PACKET_H 1

/* Define if you have the <sys/cdefs.h> header file.  */
#define HAVE_SYS_CDEFS_H 1

/* Define if you have the <sys/dlpi.h> header file.  */
/* #undef HAVE_SYS_DLPI_H */

/* Define if you have the <sys/ioctl.h> header file.  */
#define HAVE_SYS_IOCTL_H 1

/* Define if you have the <sys/param.h> header file.  */
#define HAVE_SYS_PARAM_H 1

/* Define if you have the <sys/socket.h> header file.  */
#define HAVE_SYS_SOCKET_H 1

/* Define if you have the <sys/time.h> header file.  */
#define HAVE_SYS_TIME_H 1

/* Define if you have the <sys/uio.h> header file.  */
//#define HAVE_SYS_UIO_H 1

/* Define if you have the <syslog.h> header file.  */
#define HAVE_SYSLOG_H 1

/* Define if you have the <unistd.h> header file.  */
#define HAVE_UNISTD_H 1

/* Define if you have the N_HDLC line discipline in linux/termios.h */
/* #undef HAVE_N_HDLC */

/* Define if bitfields are packed in reverse order */
#define PACK_BITFIELDS_REVERSED 1

/* Define to include debugging code */
#define DEBUGGING_ENABLED 1

/* Solaris moans if we don't do this... */
#ifdef __sun
#define __EXTENSIONS__ 1
#endif

-----------------------end of config.h -------------------------------------


5.external/rp-pppoe-3.10下创建Android.mk文件, 内容如下

-------------------- Android.mk --------------------------------------------
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_SRC_FILES:=\
    src/pppoe.c \
    src/if.c \
    src/debug.c \
    src/common.c \
    src/ppp.c \
    src/discovery.c \


LOCAL_STATIC_LIBRARIES :=

LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE := pppoe
LOCAL_C_INCLUDES += $(LOCAL_PATH)/src
LOCAL_CFLAGS += '-DVERSION="3.10"' \
    '-DPPPD_PATH="/system/bin/pppd"'

include $(BUILD_EXECUTABLE)

include $(call all-makefiles-under,$(LOCAL_PATH))

-------------------- end of Android.mk -------------------------------------



错误及解决方法:
1) /dev/pts/目录为空, pppoe 提示找不到文件 /dev.pts/0
  内核配置添加如下选项
CONFIG_SERIAL_CORE=y
CONFIG_SERIAL_CORE_CONSOLE=y
CONFIG_UNIX98_PTYS=y
CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
CONFIG_LEGACY_PTYS=y
CONFIG_LEGACY_PTY_COUNT=256


2) 提示 pppoe: read (asyncReadFromPPP): Session 8: I/O error
   把内核中PPPOE的所有选项都支持上就万事大吉了
# CONFIG_WAN is not set
CONFIG_PPP=y
CONFIG_PPP_MULTILINK=y
CONFIG_PPP_FILTER=y
CONFIG_PPP_ASYNC=y
CONFIG_PPP_SYNC_TTY=y
CONFIG_PPP_DEFLATE=y
CONFIG_PPP_BSDCOMP=y
CONFIG_PPP_MPPE=y
CONFIG_PPPOE=y
CONFIG_PPPOL2TP=y
CONFIG_PPPOLAC=y
CONFIG_PPPOPNS=y
# CONFIG_SLIP is not set
CONFIG_SLHC=y