From e7fb399b3c3ac2caec2896d0680f772ddd7e917f Mon Sep 17 00:00:00 2001 From: fbernon Date: Mon, 3 Dec 2007 22:10:46 +0000 Subject: [PATCH] PPP support for win32 port (need to add some files). --- ports/win32/include/arch/cc.h | 3 + ports/win32/include/arch/sys_arch.h | 3 + ports/win32/lwipopts.h | 58 ++-------------- ports/win32/msvc8/lwIP.vcproj | 104 ++++++++++------------------ ports/win32/test.c | 78 +++++++++++++++++++++ 5 files changed, 124 insertions(+), 122 deletions(-) diff --git a/ports/win32/include/arch/cc.h b/ports/win32/include/arch/cc.h index a668d70..e06bd33 100644 --- a/ports/win32/include/arch/cc.h +++ b/ports/win32/include/arch/cc.h @@ -77,4 +77,7 @@ typedef u32_t mem_ptr_t; #define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) +/* C runtime functions redefined */ +#define snprintf _snprintf + #endif /* __ARCH_CC_H__ */ diff --git a/ports/win32/include/arch/sys_arch.h b/ports/win32/include/arch/sys_arch.h index 6912918..f21eacd 100644 --- a/ports/win32/include/arch/sys_arch.h +++ b/ports/win32/include/arch/sys_arch.h @@ -45,5 +45,8 @@ typedef struct lwip_mbox* sys_mbox_t; /* DWORD (thread id) is used for sys_thread_t but we won't include windows.h */ typedef u32_t sys_thread_t; +/* sys_jiffies */ +#define sys_jiffies() sys_now() + #endif /* __ARCH_SYS_ARCH_H__ */ diff --git a/ports/win32/lwipopts.h b/ports/win32/lwipopts.h index b631096..fa8f55c 100644 --- a/ports/win32/lwipopts.h +++ b/ports/win32/lwipopts.h @@ -258,13 +258,16 @@ a lot of data that needs to be copied, this should be set high. */ #if PPP_SUPPORT -#define NUM_PPP 1 /* Max PPP sessions. */ +#define NUM_PPP 1 /* Max PPP sessions. */ /* Select modules to enable. Ideally these would be set in the makefile but * we're limited by the command line length so you need to modify the settings * in this file. */ +#define PPPOE_SUPPORT 1 +#define PPPOS_SUPPORT 1 + #define PAP_SUPPORT 1 /* Set > 0 for PAP. */ #define CHAP_SUPPORT 1 /* Set > 0 for CHAP. */ #define MSCHAP_SUPPORT 0 /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */ @@ -273,59 +276,6 @@ a lot of data that needs to be copied, this should be set high. */ #define VJ_SUPPORT 1 /* Set > 0 for VJ header compression. */ #define MD5_SUPPORT 1 /* Set > 0 for MD5 (see also CHAP) */ - -/* - * Timeouts. - */ -#define FSM_DEFTIMEOUT 6 /* Timeout time in seconds */ -#define FSM_DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ -#define FSM_DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ -#define FSM_DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */ - -#define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */ -#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ - -#define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */ -#define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ - - -/* Interval in seconds between keepalive echo requests, 0 to disable. */ -#if 1 -#define LCP_ECHOINTERVAL 0 -#else -#define LCP_ECHOINTERVAL 10 -#endif - -/* Number of unanswered echo requests before failure. */ -#define LCP_MAXECHOFAILS 3 - -/* Max Xmit idle time (in jiffies) before resend flag char. */ -#define PPP_MAXIDLEFLAG 100 - -/* - * Packet sizes - * - * Note - lcp shouldn't be allowed to negotiate stuff outside these - * limits. See lcp.h in the pppd directory. - * (XXX - these constants should simply be shared by lcp.c instead - * of living in lcp.h) - */ -#define PPP_MTU 1500 /* Default MTU (size of Info field) */ -#if 0 -#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) -#else -#define PPP_MAXMTU 1500 /* Largest MTU we allow */ -#endif -#define PPP_MINMTU 64 -#define PPP_MRU 1500 /* default MRU = max length of info field */ -#define PPP_MAXMRU 1500 /* Largest MRU we allow */ -#define PPP_DEFMRU 296 /* Try for this */ -#define PPP_MINMRU 128 /* No MRUs below this */ - - -#define MAXNAMELEN 256 /* max length of hostname or name for auth */ -#define MAXSECRETLEN 256 /* max length of password or secret */ - #endif /* PPP_SUPPORT */ #endif /* __LWIPOPTS_H__ */ diff --git a/ports/win32/msvc8/lwIP.vcproj b/ports/win32/msvc8/lwIP.vcproj index 3978f63..befbe3b 100644 --- a/ports/win32/msvc8/lwIP.vcproj +++ b/ports/win32/msvc8/lwIP.vcproj @@ -1078,13 +1078,8 @@ - - + + + + + + + + - - + + + + + + + + our_ipaddr.addr))); + printf(" his_ipaddr=%s", inet_ntoa(*(struct in_addr*)&(ppp_addrs->his_ipaddr.addr))); + printf(" netmask=%s", inet_ntoa(*(struct in_addr*)&(ppp_addrs->netmask.addr))); + printf(" dns1=%s", inet_ntoa(*(struct in_addr*)&(ppp_addrs->dns1.addr))); + printf(" dns2=%s\n", inet_ntoa(*(struct in_addr*)&(ppp_addrs->dns2.addr))); + break; + } + case PPPERR_PARAM: { /* Invalid parameter. */ + printf("pppLinkStatusCallback: PPPERR_PARAM\n"); + break; + } + case PPPERR_OPEN: { /* Unable to open PPP session. */ + printf("pppLinkStatusCallback: PPPERR_OPEN\n"); + break; + } + case PPPERR_DEVICE: { /* Invalid I/O device for PPP. */ + printf("pppLinkStatusCallback: PPPERR_DEVICE\n"); + break; + } + case PPPERR_ALLOC: { /* Unable to allocate resources. */ + printf("pppLinkStatusCallback: PPPERR_ALLOC\n"); + break; + } + case PPPERR_USER: { /* User interrupt. */ + printf("pppLinkStatusCallback: PPPERR_USER\n"); + break; + } + case PPPERR_CONNECT: { /* Connection lost. */ + printf("pppLinkStatusCallback: PPPERR_CONNECT\n"); + break; + } + case PPPERR_AUTHFAIL: { /* Failed authentication challenge. */ + printf("pppLinkStatusCallback: PPPERR_AUTHFAIL\n"); + break; + } + case PPPERR_PROTOCOL: { /* Failed to meet protocol. */ + printf("pppLinkStatusCallback: PPPERR_PROTOCOL\n"); + break; + } + default: { + printf("pppLinkStatusCallback: unknown errCode %d\n", errCode); + break; + } + } +} +#endif /* PPP_SUPPORT */ + /* This function initializes all network interfaces */ static void msvc_netif_init() @@ -203,6 +265,22 @@ msvc_netif_init() #else /* NO_SYS */ netif_set_default(netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ethernetif_init, tcpip_input)); #endif /* NO_SYS */ + +#if PPP_SUPPORT +{ sio_fd_t ppp_sio; + ppp_sio = sio_open(0); + if (ppp_sio != NULL) { + printf("pppInit\n"); + pppInit(); + pppSetAuth(PPPAUTHTYPE_CHAP, "lwip", "mysecret"); + printf("pppOpen\n"); + pppOpen(ppp_sio, pppLinkStatusCallback, NULL); + } else { + printf("sio_open error\n"); + } +} +#endif /* PPP_SUPPORT */ + #if LWIP_DHCP dhcp_start(&netif); #else /* LWIP_DHCP */