diff --git a/CHANGELOG b/CHANGELOG index cecd3fd8..7532beed 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,7 +5,7 @@ HISTORY ++ Bug fixes: * some debug formatters and casts fixed. - * numereous fixes in PPP. + * numerous fixes in PPP. ++ Changes: diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 9ce9ec25..80b2d088 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -44,7 +44,7 @@ netbuf *netbuf_new(void) { struct netbuf *buf; - buf = memp_mallocp(MEMP_NETBUF); + buf = memp_malloc(MEMP_NETBUF); if (buf != NULL) { buf->p = NULL; buf->ptr = NULL; @@ -62,7 +62,7 @@ netbuf_delete(struct netbuf *buf) pbuf_free(buf->p); buf->p = buf->ptr = NULL; } - memp_freep(MEMP_NETBUF, buf); + memp_free(MEMP_NETBUF, buf); } } /*-----------------------------------------------------------------------------------*/ @@ -107,7 +107,7 @@ netbuf_chain(struct netbuf *head, struct netbuf *tail) { pbuf_chain(head->p, tail->p); head->ptr = head->p; - memp_freep(MEMP_NETBUF, tail); + memp_free(MEMP_NETBUF, tail); } /*-----------------------------------------------------------------------------------*/ u16_t @@ -198,7 +198,7 @@ netconn *netconn_new(enum netconn_type t) { struct netconn *conn; - conn = memp_mallocp(MEMP_NETCONN); + conn = memp_malloc(MEMP_NETCONN); if (conn == NULL) { return NULL; } @@ -206,7 +206,7 @@ netconn *netconn_new(enum netconn_type t) conn->pcb.tcp = NULL; if ((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) { - memp_freep(MEMP_NETCONN, conn); + memp_free(MEMP_NETCONN, conn); return NULL; } conn->recvmbox = SYS_MBOX_NULL; @@ -243,7 +243,7 @@ netconn_delete(struct netconn *conn) return ERR_OK; } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return ERR_MEM; } @@ -251,7 +251,7 @@ netconn_delete(struct netconn *conn) msg->msg.conn = conn; api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); /* Drain the recvmbox. */ if (conn->recvmbox != SYS_MBOX_NULL) { @@ -353,7 +353,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr, } } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return (conn->err = ERR_MEM); } msg->type = API_MSG_BIND; @@ -362,7 +362,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr, msg->msg.msg.bc.port = port; api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -384,7 +384,7 @@ netconn_connect(struct netconn *conn, struct ip_addr *addr, } } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return ERR_MEM; } msg->type = API_MSG_CONNECT; @@ -393,7 +393,7 @@ netconn_connect(struct netconn *conn, struct ip_addr *addr, msg->msg.msg.bc.port = port; api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -406,14 +406,14 @@ netconn_disconnect(struct netconn *conn) return ERR_VAL; } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return ERR_MEM; } msg->type = API_MSG_DISCONNECT; msg->msg.conn = conn; api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); return conn->err; } @@ -434,14 +434,14 @@ netconn_listen(struct netconn *conn) } } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return (conn->err = ERR_MEM); } msg->type = API_MSG_LISTEN; msg->msg.conn = conn; api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); return conn->err; } /*-----------------------------------------------------------------------------------*/ @@ -490,7 +490,7 @@ netconn_recv(struct netconn *conn) } - buf = memp_mallocp(MEMP_NETBUF); + buf = memp_malloc(MEMP_NETBUF); if (buf == NULL) { conn->err = ERR_MEM; @@ -514,7 +514,7 @@ netconn_recv(struct netconn *conn) /* If we are closed, we indicate that we no longer wish to receive data by setting conn->recvmbox to SYS_MBOX_NULL. */ if (p == NULL) { - memp_freep(MEMP_NETBUF, buf); + memp_free(MEMP_NETBUF, buf); sys_mbox_free(conn->recvmbox); conn->recvmbox = SYS_MBOX_NULL; return NULL; @@ -526,7 +526,7 @@ netconn_recv(struct netconn *conn) buf->fromaddr = NULL; /* Let the stack know that we have taken the data. */ - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { conn->err = ERR_MEM; return buf; } @@ -540,7 +540,7 @@ netconn_recv(struct netconn *conn) api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); } else { sys_mbox_fetch(conn->recvmbox, (void **)&buf); conn->recv_avail -= buf->p->tot_len; @@ -571,7 +571,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf) return conn->err; } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return (conn->err = ERR_MEM); } @@ -582,7 +582,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf) api_msg_post(msg); sys_mbox_fetch(conn->mbox, NULL); - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); return conn->err; } /*-----------------------------------------------------------------------------------*/ @@ -607,7 +607,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy) } } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return (conn->err = ERR_MEM); } msg->type = API_MSG_WRITE; @@ -652,7 +652,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy) } } ret: - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); conn->state = NETCONN_NONE; if (conn->sem != SYS_SEM_NULL) { sys_sem_free(conn->sem); @@ -670,7 +670,7 @@ netconn_close(struct netconn *conn) if (conn == NULL) { return ERR_VAL; } - if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) { + if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) { return (conn->err = ERR_MEM); } @@ -686,7 +686,7 @@ netconn_close(struct netconn *conn) goto again; } conn->state = NETCONN_NONE; - memp_freep(MEMP_API_MSG, msg); + memp_free(MEMP_API_MSG, msg); return conn->err; } /*-----------------------------------------------------------------------------------*/ diff --git a/src/api/api_msg.c b/src/api/api_msg.c index 7dba5e17..de03dca9 100644 --- a/src/api/api_msg.c +++ b/src/api/api_msg.c @@ -52,7 +52,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, return; } if (conn->recvmbox != SYS_MBOX_NULL) { - buf = memp_mallocp(MEMP_NETBUF); + buf = memp_malloc(MEMP_NETBUF); if (buf == NULL) { pbuf_free(p); return; @@ -193,7 +193,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) #endif /* API_MSG_DEBUG */ conn = (struct netconn *)arg; mbox = conn->acceptmbox; - newconn = memp_mallocp(MEMP_NETCONN); + newconn = memp_malloc(MEMP_NETCONN); if (newconn == NULL) { return ERR_MEM; } diff --git a/src/api/tcpip.c b/src/api/tcpip.c index bcb114d6..32cdcdf5 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -110,7 +110,7 @@ tcpip_thread(void *arg) default: break; } - memp_freep(MEMP_TCPIP_MSG, msg); + memp_free(MEMP_TCPIP_MSG, msg); } } /*-----------------------------------------------------------------------------------*/ @@ -119,7 +119,7 @@ tcpip_input(struct pbuf *p, struct netif *inp) { struct tcpip_msg *msg; - msg = memp_mallocp(MEMP_TCPIP_MSG); + msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) { pbuf_free(p); return ERR_MEM; @@ -137,7 +137,7 @@ tcpip_callback(void (*f)(void *ctx), void *ctx) { struct tcpip_msg *msg; - msg = memp_mallocp(MEMP_TCPIP_MSG); + msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) { return ERR_MEM; } @@ -153,7 +153,7 @@ void tcpip_apimsg(struct api_msg *apimsg) { struct tcpip_msg *msg; - msg = memp_mallocp(MEMP_TCPIP_MSG); + msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) { memp_free(MEMP_API_MSG, apimsg); return; diff --git a/src/core/memp.c b/src/core/memp.c index 17b4d3af..26ae7e00 100644 --- a/src/core/memp.c +++ b/src/core/memp.c @@ -182,9 +182,18 @@ memp_malloc(memp_t type) { struct memp *memp; void *mem; +#ifdef SYS_LIGHTWEIGHT_PROT + SYS_ARCH_DECL_PROTECT(old_level); +#endif LWIP_ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX); +#ifdef SYS_LIGHTWEIGHT_PROT + SYS_ARCH_PROTECT(old_level); +#else /* SYS_LIGHTWEIGHT_PROT */ + sys_sem_wait(mutex); +#endif /* SYS_LIGHTWEIGHT_PROT */ + memp = memp_tab[type]; if (memp != NULL) { @@ -196,6 +205,11 @@ memp_malloc(memp_t type) lwip_stats.memp[type].max = lwip_stats.memp[type].used; } #endif /* MEMP_STATS */ +#ifdef SYS_LIGHTWEIGHT_PROT + SYS_ARCH_UNPROTECT(old_level); +#else /* SYS_LIGHTWEIGHT_PROT */ + sys_sem_signal(mutex); +#endif /* SYS_LIGHTWEIGHT_PROT */ LWIP_ASSERT("memp_malloc: memp properly aligned", ((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0); @@ -208,41 +222,34 @@ memp_malloc(memp_t type) #ifdef MEMP_STATS ++lwip_stats.memp[type].err; #endif /* MEMP_STATS */ - return NULL; - } -} -/*-----------------------------------------------------------------------------------*/ -void * -memp_mallocp(memp_t type) -{ - void *mem; -#if SYS_LIGHTWEIGHT_PROT - SYS_ARCH_DECL_PROTECT(old_level); - SYS_ARCH_PROTECT(old_level); -#else /* SYS_LIGHTWEIGHT_PROT */ - sys_sem_wait(mutex); -#endif /* SYS_LIGHTWEIGHT_PROT */ - - mem = memp_malloc(type); - #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ - return mem; + return NULL; + } } /*-----------------------------------------------------------------------------------*/ void memp_free(memp_t type, void *mem) { struct memp *memp; +#ifdef SYS_LIGHTWEIGHT_PROT + SYS_ARCH_DECL_PROTECT(old_level); +#endif /* SYS_LIGHTWEIGHT_PROT */ if (mem == NULL) { return; } memp = (struct memp *)((u8_t *)mem - sizeof(struct memp)); +#ifdef SYS_LIGHTWEIGHT_PROT + SYS_ARCH_PROTECT(old_level); +#else /* SYS_LIGHTWEIGHT_PROT */ + sys_sem_wait(mutex); +#endif /* SYS_LIGHTWEIGHT_PROT */ + #ifdef MEMP_STATS lwip_stats.memp[type].used--; #endif /* MEMP_STATS */ @@ -252,26 +259,10 @@ memp_free(memp_t type, void *mem) LWIP_ASSERT("memp sanity", memp_sanity()); - return; -} -/*-----------------------------------------------------------------------------------*/ -void -memp_freep(memp_t type, void *mem) -{ -#if SYS_LIGHTWEIGHT_PROT - SYS_ARCH_DECL_PROTECT(old_level); - SYS_ARCH_PROTECT(old_level); -#else /* SYS_LIGHTWEIGHT_PROT */ - sys_sem_wait(mutex); -#endif /* SYS_LIGHTWEIGHT_PROT */ - - memp_free(type, mem); - #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ - } /*-----------------------------------------------------------------------------------*/ diff --git a/src/core/pbuf.c b/src/core/pbuf.c index febfa788..b42bac14 100644 --- a/src/core/pbuf.c +++ b/src/core/pbuf.c @@ -300,7 +300,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) r = q; } /* end of chain */ - //r->next = NULL; + /*r->next = NULL;*/ break; case PBUF_RAM: @@ -323,7 +323,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) /* pbuf references existing (externally allocated) RAM payload? */ case PBUF_REF: /* only allocate memory for the pbuf structure */ - p = memp_mallocp(MEMP_PBUF); + p = memp_malloc(MEMP_PBUF); if (p == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF")); return NULL; @@ -576,7 +576,7 @@ pbuf_free(struct pbuf *p) PBUF_POOL_FREE(p); /* a ROM or RAM referencing pbuf */ } else if (p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF) { - memp_freep(MEMP_PBUF, p); + memp_free(MEMP_PBUF, p); /* p->flags == PBUF_FLAG_RAM */ } else { mem_free(p); diff --git a/src/core/udp.c b/src/core/udp.c index 063b3d56..b0873066 100644 --- a/src/core/udp.c +++ b/src/core/udp.c @@ -474,7 +474,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) listening to broadcast or multicast traffic (See SO_REUSE_ADDR and SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR combine with implementation of UDP PCB flags. Leon Woestenberg. */ -#if 0 +#ifdef LWIP_UDP_TODO /* port matches that of PCB in list? */ else if ((ipcb->local_port == port) && /* IP address matches, or one is IP_ADDR_ANY? */ @@ -552,7 +552,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) pcb->remote_port = port; pcb->flags |= UDP_FLAGS_CONNECTED; /** TODO: this functionality belongs in upper layers */ -#if 0 +#ifdef LWIP_UDP_TODO /* Nail down local IP for netconn_addr()/getsockname() */ if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) { struct netif *netif; diff --git a/src/include/ipv4/lwip/inet.h b/src/include/ipv4/lwip/inet.h index 0615b662..80524a72 100644 --- a/src/include/ipv4/lwip/inet.h +++ b/src/include/ipv4/lwip/inet.h @@ -67,6 +67,13 @@ u8_t *inet_ntoa(u32_t addr); /* returns ptr to static buffer; not reentrant! */ #define htonl(x) (x) #define ntohl(x) (x) #else +#ifdef LWIP_PREFIX_BYTEORDER_FUNCS +/* workaround for naming collisions on some platforms */ +#define htons lwip_htons +#define ntohs lwip_ntohs +#define htonl lwip_htonl +#define ntohl lwip_ntohl +#endif u16_t htons(u16_t x); u16_t ntohs(u16_t x); u32_t htonl(u32_t x); diff --git a/src/include/lwip/memp.h b/src/include/lwip/memp.h index 742ec3ac..2b58f0a1 100644 --- a/src/include/lwip/memp.h +++ b/src/include/lwip/memp.h @@ -58,8 +58,5 @@ void *memp_malloc(memp_t type); void *memp_realloc(memp_t fromtype, memp_t totype, void *mem); void memp_free(memp_t type, void *mem); -void *memp_mallocp(memp_t type); -void memp_freep(memp_t type, void *mem); - #endif /* __LWIP_MEMP_H__ */ diff --git a/src/include/lwip/udp.h b/src/include/lwip/udp.h index 4486d183..84d2bfde 100644 --- a/src/include/lwip/udp.h +++ b/src/include/lwip/udp.h @@ -38,8 +38,6 @@ #include "lwip/inet.h" #include "lwip/ip.h" -#include "lwip/err.h" - #define UDP_HLEN 8 struct udp_hdr { diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index 3c3ca7f0..f7c79760 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -122,7 +122,7 @@ static int get_pap_passwd (int, char *, char *); static int have_pap_secret (void); static int have_chap_secret (char *, char *, u32_t); static int ip_addr_check (u32_t, struct wordlist *); -#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 +#if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 */ static void set_allowed_addrs(int unit, struct wordlist *addrs); static void free_wordlist (struct wordlist *); #endif @@ -476,7 +476,7 @@ void auth_reset(int unit) AUTHDEBUG((LOG_INFO, "auth_reset: %d\n", unit)); ao->neg_upap = !ppp_settings.refuse_pap && (ppp_settings.passwd[0] != 0 || get_pap_passwd(unit, NULL, NULL)); - ao->neg_chap = !ppp_settings.refuse_chap && have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0); + ao->neg_chap = !ppp_settings.refuse_chap && ppp_settings.passwd[0] != 0 /*have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0)*/; if (go->neg_upap && !have_pap_secret()) go->neg_upap = 0; @@ -605,7 +605,24 @@ int get_secret( ) { #if 1 + int len; + struct wordlist *addrs; + + addrs = NULL; + + if(!client || !client[0] && strcmp(client, ppp_settings.user)) { return 0; + } + + len = strlen(ppp_settings.passwd); + if (len > MAXSECRETLEN) { + ppp_trace(LOG_ERR, "Secret for %s on %s is too long\n", client, server); + len = MAXSECRETLEN; + } + BCOPY(ppp_settings.passwd, secret, len); + *secret_len = len; + + return 1; #else int ret = 0, len; struct wordlist *addrs; @@ -841,7 +858,7 @@ static int have_chap_secret(char *client, char *server, u32_t remote) } -#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 +#if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 */ /* * set_allowed_addrs() - set the list of allowed addresses. */ @@ -891,7 +908,7 @@ static int ip_addr_check(u32_t addr, struct wordlist *addrs) return 1; } -#if PAP_SUPPORT > 0 || CHAP_SUPPORT +#if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT */ /* * free_wordlist - release memory allocated for a wordlist. */ diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 14cfb47f..1e07aaf8 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -290,7 +290,7 @@ void pppInit(void) memset(&ppp_settings, 0, sizeof(ppp_settings)); ppp_settings.usepeerdns = 1; - ppp_settings.refuse_chap = (CHAP_SUPPORT == 0); + pppSetAuth(PPPAUTHTYPE_NONE, NULL, NULL); magicInit(); @@ -313,19 +313,40 @@ void pppInit(void) #endif } -void pppSetAuth(const char *user, const char *passwd) +void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) { - if(user) { - strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1); - ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0'; - } else - ppp_settings.user[0] = '\0'; + switch(authType) { + case PPPAUTHTYPE_NONE: + default: +#ifdef LWIP_PPP_STRICT_PAP_REJECT + ppp_settings.refuse_pap = 1; +#else + /* some providers request pap and accept an empty login/pw */ + ppp_settings.refuse_pap = 0; +#endif + ppp_settings.refuse_chap = 1; + break; + case PPPAUTHTYPE_PAP: + ppp_settings.refuse_pap = 0; + ppp_settings.refuse_chap = 1; + break; + case PPPAUTHTYPE_CHAP: + ppp_settings.refuse_pap = 1; + ppp_settings.refuse_chap = 0; + break; + } - if(passwd) { - strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1); - ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0'; - } else - ppp_settings.passwd[0] = '\0'; + if(user) { + strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1); + ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0'; + } else + ppp_settings.user[0] = '\0'; + + if(passwd) { + strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1); + ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0'; + } else + ppp_settings.passwd[0] = '\0'; } /* Open a new PPP connection using the given I/O device. diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 224214a5..d4d14075 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -313,7 +313,7 @@ struct ppp_settings { int maxconnect; /* Maximum connect time (seconds) */ char user[MAXNAMELEN + 1];/* Username for PAP */ - char passwd[MAXNAMELEN + 1]; /* Password for PAP */ + char passwd[MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ char our_name[MAXNAMELEN + 1]; /* Our name for authentication purposes */ char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ }; @@ -340,7 +340,13 @@ extern struct protent *ppp_protocols[];/* Table of pointers to supported protoco /* Initialize the PPP subsystem. */ void pppInit(void); -void pppSetAuth(const char *user, const char *passwd); +enum pppAuthType { + PPPAUTHTYPE_NONE, + PPPAUTHTYPE_PAP, + PPPAUTHTYPE_CHAP +}; + +void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd); /* * Open a new PPP connection using the given I/O device.