mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-08-03 21:14:40 +08:00
sio and PPP updates from Marc
This commit is contained in:
parent
2bfd55fd69
commit
26d9b28f77
@ -34,9 +34,30 @@
|
|||||||
|
|
||||||
#include "arch/cc.h"
|
#include "arch/cc.h"
|
||||||
|
|
||||||
void * sio_open(u8_t);
|
#ifndef __sio_fd_t_defined
|
||||||
void sio_send(u8_t, void*);
|
typedef void * sio_fd_t;
|
||||||
u8_t sio_recv(void *);
|
#endif
|
||||||
u32_t sio_read(void *, u8_t *, u32_t);
|
|
||||||
u32_t sio_write(void *, u8_t *, u32_t);
|
|
||||||
|
|
||||||
|
#ifndef sio_open
|
||||||
|
sio_fd_t sio_open(u8_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef sio_send
|
||||||
|
void sio_send(u8_t, sio_fd_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef sio_recv
|
||||||
|
u8_t sio_recv(sio_fd_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef sio_read
|
||||||
|
u32_t sio_read(sio_fd_t, u8_t *, u32_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef sio_write
|
||||||
|
u32_t sio_write(sio_fd_t, u8_t *, u32_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef sio_read_abort
|
||||||
|
void sio_read_abort(void);
|
||||||
|
#endif
|
||||||
|
@ -542,10 +542,10 @@ int check_passwd(
|
|||||||
*/
|
*/
|
||||||
if (attempts++ >= 10) {
|
if (attempts++ >= 10) {
|
||||||
ppp_trace(LOG_WARNING, "%d LOGIN FAILURES BY %s\n", attempts, user);
|
ppp_trace(LOG_WARNING, "%d LOGIN FAILURES BY %s\n", attempts, user);
|
||||||
ppp_panic("Excess Bad Logins");
|
/*ppp_panic("Excess Bad Logins");*/
|
||||||
}
|
}
|
||||||
if (attempts > 3) {
|
if (attempts > 3) {
|
||||||
ppp_msleep((attempts - 3) * 5);
|
sys_msleep((attempts - 3) * 5);
|
||||||
}
|
}
|
||||||
if (addrs != NULL) {
|
if (addrs != NULL) {
|
||||||
free_wordlist(addrs);
|
free_wordlist(addrs);
|
||||||
|
@ -593,12 +593,12 @@ static int ipcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
if (go->accept_local && ciaddr1) { /* Do we know our address? */
|
if (go->accept_local && ciaddr1) { /* Do we know our address? */
|
||||||
try.ouraddr = ciaddr1;
|
try.ouraddr = ciaddr1;
|
||||||
IPCPDEBUG((LOG_INFO, "local IP address %s\n",
|
IPCPDEBUG((LOG_INFO, "local IP address %s\n",
|
||||||
ip_ntoa(ciaddr1)));
|
inet_ntoa(ciaddr1)));
|
||||||
}
|
}
|
||||||
if (go->accept_remote && ciaddr2) { /* Does he know his? */
|
if (go->accept_remote && ciaddr2) { /* Does he know his? */
|
||||||
try.hisaddr = ciaddr2;
|
try.hisaddr = ciaddr2;
|
||||||
IPCPDEBUG((LOG_INFO, "remote IP address %s\n",
|
IPCPDEBUG((LOG_INFO, "remote IP address %s\n",
|
||||||
ip_ntoa(ciaddr2)));
|
inet_ntoa(ciaddr2)));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -633,12 +633,12 @@ static int ipcp_nakci(fsm *f, u_char *p, int len)
|
|||||||
|
|
||||||
NAKCIDNS(CI_MS_DNS1, req_dns1,
|
NAKCIDNS(CI_MS_DNS1, req_dns1,
|
||||||
try.dnsaddr[0] = cidnsaddr;
|
try.dnsaddr[0] = cidnsaddr;
|
||||||
IPCPDEBUG((LOG_INFO, "primary DNS address %s\n", ip_ntoa(cidnsaddr)));
|
IPCPDEBUG((LOG_INFO, "primary DNS address %s\n", inet_ntoa(cidnsaddr)));
|
||||||
);
|
);
|
||||||
|
|
||||||
NAKCIDNS(CI_MS_DNS2, req_dns2,
|
NAKCIDNS(CI_MS_DNS2, req_dns2,
|
||||||
try.dnsaddr[1] = cidnsaddr;
|
try.dnsaddr[1] = cidnsaddr;
|
||||||
IPCPDEBUG((LOG_INFO, "secondary DNS address %s\n", ip_ntoa(cidnsaddr)));
|
IPCPDEBUG((LOG_INFO, "secondary DNS address %s\n", inet_ntoa(cidnsaddr)));
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -898,7 +898,7 @@ static int ipcp_reqci(
|
|||||||
*/
|
*/
|
||||||
GETLONG(tl, p); /* Parse source address (his) */
|
GETLONG(tl, p); /* Parse source address (his) */
|
||||||
ciaddr1 = htonl(tl);
|
ciaddr1 = htonl(tl);
|
||||||
IPCPDEBUG((LOG_INFO, "his addr %s\n", ip_ntoa(ciaddr1)));
|
IPCPDEBUG((LOG_INFO, "his addr %s\n", inet_ntoa(ciaddr1)));
|
||||||
if (ciaddr1 != wo->hisaddr
|
if (ciaddr1 != wo->hisaddr
|
||||||
&& (ciaddr1 == 0 || !wo->accept_remote)) {
|
&& (ciaddr1 == 0 || !wo->accept_remote)) {
|
||||||
orc = CONFNAK;
|
orc = CONFNAK;
|
||||||
@ -922,7 +922,7 @@ static int ipcp_reqci(
|
|||||||
*/
|
*/
|
||||||
GETLONG(tl, p); /* Parse desination address (ours) */
|
GETLONG(tl, p); /* Parse desination address (ours) */
|
||||||
ciaddr2 = htonl(tl);
|
ciaddr2 = htonl(tl);
|
||||||
IPCPDEBUG((LOG_INFO, "our addr %s\n", ip_ntoa(ciaddr2)));
|
IPCPDEBUG((LOG_INFO, "our addr %s\n", inet_ntoa(ciaddr2)));
|
||||||
if (ciaddr2 != wo->ouraddr) {
|
if (ciaddr2 != wo->ouraddr) {
|
||||||
if (ciaddr2 == 0 || !wo->accept_local) {
|
if (ciaddr2 == 0 || !wo->accept_local) {
|
||||||
orc = CONFNAK;
|
orc = CONFNAK;
|
||||||
@ -970,12 +970,12 @@ static int ipcp_reqci(
|
|||||||
tl = ntohl(wo->hisaddr);
|
tl = ntohl(wo->hisaddr);
|
||||||
PUTLONG(tl, p);
|
PUTLONG(tl, p);
|
||||||
}
|
}
|
||||||
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Nak ADDR %s\n", ip_ntoa(ciaddr1)));
|
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Nak ADDR %s\n", inet_ntoa(ciaddr1)));
|
||||||
} else if (ciaddr1 == 0 && wo->hisaddr == 0) {
|
} else if (ciaddr1 == 0 && wo->hisaddr == 0) {
|
||||||
/*
|
/*
|
||||||
* Don't ACK an address of 0.0.0.0 - reject it instead.
|
* Don't ACK an address of 0.0.0.0 - reject it instead.
|
||||||
*/
|
*/
|
||||||
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Reject ADDR %s\n", ip_ntoa(ciaddr1)));
|
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Reject ADDR %s\n", inet_ntoa(ciaddr1)));
|
||||||
orc = CONFREJ;
|
orc = CONFREJ;
|
||||||
wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */
|
wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */
|
||||||
break;
|
break;
|
||||||
@ -983,7 +983,7 @@ static int ipcp_reqci(
|
|||||||
|
|
||||||
ho->neg_addr = 1;
|
ho->neg_addr = 1;
|
||||||
ho->hisaddr = ciaddr1;
|
ho->hisaddr = ciaddr1;
|
||||||
IPCPDEBUG((LOG_INFO, "ipcp_reqci: ADDR %s\n", ip_ntoa(ciaddr1)));
|
IPCPDEBUG((LOG_INFO, "ipcp_reqci: ADDR %s\n", inet_ntoa(ciaddr1)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CI_MS_DNS1:
|
case CI_MS_DNS1:
|
||||||
@ -1001,7 +1001,7 @@ static int ipcp_reqci(
|
|||||||
GETLONG(tl, p);
|
GETLONG(tl, p);
|
||||||
if (htonl(tl) != ao->dnsaddr[d]) {
|
if (htonl(tl) != ao->dnsaddr[d]) {
|
||||||
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Naking DNS%d Request %d\n",
|
IPCPDEBUG((LOG_INFO, "ipcp_reqci: Naking DNS%d Request %d\n",
|
||||||
d+1, ip_ntoa(tl)));
|
d+1, inet_ntoa(tl)));
|
||||||
DECPTR(sizeof(u32_t), p);
|
DECPTR(sizeof(u32_t), p);
|
||||||
tl = ntohl(ao->dnsaddr[d]);
|
tl = ntohl(ao->dnsaddr[d]);
|
||||||
PUTLONG(tl, p);
|
PUTLONG(tl, p);
|
||||||
@ -1211,7 +1211,7 @@ static void ipcp_up(fsm *f)
|
|||||||
*/
|
*/
|
||||||
if (!auth_ip_addr(f->unit, ho->hisaddr)) {
|
if (!auth_ip_addr(f->unit, ho->hisaddr)) {
|
||||||
ppp_trace(LOG_ERR, "Peer is not authorized to use remote address %s\n",
|
ppp_trace(LOG_ERR, "Peer is not authorized to use remote address %s\n",
|
||||||
ip_ntoa(ho->hisaddr));
|
inet_ntoa(ho->hisaddr));
|
||||||
ipcp_close(f->unit, "Unauthorized remote IP address");
|
ipcp_close(f->unit, "Unauthorized remote IP address");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1224,13 +1224,11 @@ static void ipcp_up(fsm *f)
|
|||||||
*/
|
*/
|
||||||
mask = GetMask(go->ouraddr);
|
mask = GetMask(go->ouraddr);
|
||||||
|
|
||||||
#if !(defined(SVR4) && (defined(SNI) || defined(__USLC__)))
|
if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask, go->dnsaddr[0], go->dnsaddr[1])) {
|
||||||
if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
|
|
||||||
IPCPDEBUG((LOG_WARNING, "sifaddr failed\n"));
|
IPCPDEBUG((LOG_WARNING, "sifaddr failed\n"));
|
||||||
ipcp_close(f->unit, "Interface configuration failed");
|
ipcp_close(f->unit, "Interface configuration failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/* bring the interface up for IP */
|
/* bring the interface up for IP */
|
||||||
if (!sifup(f->unit)) {
|
if (!sifup(f->unit)) {
|
||||||
@ -1239,13 +1237,6 @@ static void ipcp_up(fsm *f)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined(SVR4) && (defined(SNI) || defined(__USLC__)))
|
|
||||||
if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask)) {
|
|
||||||
IPCPDEBUG((LOG_WARNING, "sifaddr failed\n"));
|
|
||||||
ipcp_close(f->unit, "Interface configuration failed");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
|
sifnpmode(f->unit, PPP_IP, NPMODE_PASS);
|
||||||
|
|
||||||
/* assign a default route through the interface if required */
|
/* assign a default route through the interface if required */
|
||||||
@ -1253,13 +1244,13 @@ static void ipcp_up(fsm *f)
|
|||||||
if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
|
if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr))
|
||||||
default_route_set[f->unit] = 1;
|
default_route_set[f->unit] = 1;
|
||||||
|
|
||||||
IPCPDEBUG((LOG_NOTICE, "local IP address %s\n", ip_ntoa(go->ouraddr)));
|
IPCPDEBUG((LOG_NOTICE, "local IP address %s\n", inet_ntoa(go->ouraddr)));
|
||||||
IPCPDEBUG((LOG_NOTICE, "remote IP address %s\n", ip_ntoa(ho->hisaddr)));
|
IPCPDEBUG((LOG_NOTICE, "remote IP address %s\n", inet_ntoa(ho->hisaddr)));
|
||||||
if (go->dnsaddr[0]) {
|
if (go->dnsaddr[0]) {
|
||||||
IPCPDEBUG((LOG_NOTICE, "primary DNS address %s\n", ip_ntoa(go->dnsaddr[0])));
|
IPCPDEBUG((LOG_NOTICE, "primary DNS address %s\n", inet_ntoa(go->dnsaddr[0])));
|
||||||
}
|
}
|
||||||
if (go->dnsaddr[1]) {
|
if (go->dnsaddr[1]) {
|
||||||
IPCPDEBUG((LOG_NOTICE, "secondary DNS address %s\n", ip_ntoa(go->dnsaddr[1])));
|
IPCPDEBUG((LOG_NOTICE, "secondary DNS address %s\n", inet_ntoa(go->dnsaddr[1])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1880,8 +1880,8 @@ static void LcpEchoCheck (fsm *f)
|
|||||||
/*
|
/*
|
||||||
* Start the timer for the next interval.
|
* Start the timer for the next interval.
|
||||||
*/
|
*/
|
||||||
if (lcp_echo_timer_running != 0)
|
LWIP_ASSERT("lcp_echo_timer_running == 0", lcp_echo_timer_running == 0);
|
||||||
ppp_panic("LcpEchoCheck");
|
|
||||||
TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval);
|
TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval);
|
||||||
lcp_echo_timer_running = 1;
|
lcp_echo_timer_running = 1;
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "pppdebug.h"
|
#include "pppdebug.h"
|
||||||
#include "lwip/sio.h"
|
|
||||||
|
|
||||||
/*************************/
|
/*************************/
|
||||||
/*** LOCAL DEFINITIONS ***/
|
/*** LOCAL DEFINITIONS ***/
|
||||||
@ -132,7 +131,7 @@ typedef enum {
|
|||||||
typedef struct PPPControl_s {
|
typedef struct PPPControl_s {
|
||||||
char openFlag; /* True when in use. */
|
char openFlag; /* True when in use. */
|
||||||
char oldFrame; /* Old framing character for fd. */
|
char oldFrame; /* Old framing character for fd. */
|
||||||
ppp_sio_fd_t fd; /* File device ID of port. */
|
sio_fd_t fd; /* File device ID of port. */
|
||||||
int kill_link; /* Shut the link down. */
|
int kill_link; /* Shut the link down. */
|
||||||
int sig_hup; /* Carrier lost. */
|
int sig_hup; /* Carrier lost. */
|
||||||
int if_up; /* True when the interface is up. */
|
int if_up; /* True when the interface is up. */
|
||||||
@ -156,7 +155,7 @@ typedef struct PPPControl_s {
|
|||||||
|
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
|
|
||||||
struct ip_addr our_ipaddr, his_ipaddr, netmask;
|
struct ip_addr our_ipaddr, his_ipaddr, netmask, dns1, dns2;
|
||||||
|
|
||||||
void (*linkStatusCB)(void *arg, int errCode);
|
void (*linkStatusCB)(void *arg, int errCode);
|
||||||
void *linkStatusArg;
|
void *linkStatusArg;
|
||||||
@ -340,17 +339,11 @@ void pppSetAuth(const char *user, const char *passwd)
|
|||||||
* established before calling this.
|
* established before calling this.
|
||||||
* Return a new PPP connection descriptor on success or
|
* Return a new PPP connection descriptor on success or
|
||||||
* an error code (negative) on failure. */
|
* an error code (negative) on failure. */
|
||||||
int pppOpen(ppp_sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *linkStatusArg)
|
int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *linkStatusArg)
|
||||||
{
|
{
|
||||||
PPPControl *pc;
|
PPPControl *pc;
|
||||||
int pd;
|
int pd;
|
||||||
|
|
||||||
/* XXX
|
|
||||||
* Ensure that fd is not already used for PPP
|
|
||||||
* for now this is left for the lower layer to check
|
|
||||||
* so the arg passed to sio_open means nothing
|
|
||||||
*/
|
|
||||||
fd = sio_open(2);
|
|
||||||
/* Find a free PPP session descriptor. Critical region? */
|
/* Find a free PPP session descriptor. Critical region? */
|
||||||
for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++);
|
for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++);
|
||||||
if (pd >= NUM_PPP)
|
if (pd >= NUM_PPP)
|
||||||
@ -396,7 +389,7 @@ int pppOpen(ppp_sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void
|
|||||||
sys_thread_new(pppMain, (void*)pd, PPP_THREAD_PRIO);
|
sys_thread_new(pppMain, (void*)pd, PPP_THREAD_PRIO);
|
||||||
if(!linkStatusCB) {
|
if(!linkStatusCB) {
|
||||||
while(pd >= 0 && !pc->if_up) {
|
while(pd >= 0 && !pc->if_up) {
|
||||||
ppp_msleep(500);
|
sys_msleep(500);
|
||||||
if (lcp_phase[pd] == PHASE_DEAD) {
|
if (lcp_phase[pd] == PHASE_DEAD) {
|
||||||
pppClose(pd);
|
pppClose(pd);
|
||||||
if (pc->errCode)
|
if (pc->errCode)
|
||||||
@ -424,7 +417,7 @@ int pppClose(int pd)
|
|||||||
|
|
||||||
if(!pc->linkStatusCB) {
|
if(!pc->linkStatusCB) {
|
||||||
while(st >= 0 && lcp_phase[pd] != PHASE_DEAD) {
|
while(st >= 0 && lcp_phase[pd] != PHASE_DEAD) {
|
||||||
ppp_msleep(500);
|
sys_msleep(500);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -448,7 +441,7 @@ static void nPut(PPPControl *pc, struct pbuf *nb)
|
|||||||
for(b = nb; b != NULL; b = b->next) {
|
for(b = nb; b != NULL; b = b->next) {
|
||||||
if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) {
|
if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) {
|
||||||
PPPDEBUG((LOG_WARNING,
|
PPPDEBUG((LOG_WARNING,
|
||||||
"PPP nPut: incomplete ppp_sio_write(%d,, %u) = %d\n", pc->fd, b->len, c));
|
"PPP nPut: incomplete sio_write(%d,, %u) = %d\n", pc->fd, b->len, c));
|
||||||
#ifdef LINK_STATS
|
#ifdef LINK_STATS
|
||||||
lwip_stats.link.err++;
|
lwip_stats.link.err++;
|
||||||
#endif /* LINK_STATS */
|
#endif /* LINK_STATS */
|
||||||
@ -542,9 +535,9 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
|
|||||||
tailMB = headMB;
|
tailMB = headMB;
|
||||||
|
|
||||||
/* Build the PPP header. */
|
/* Build the PPP header. */
|
||||||
if ((ppp_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG)
|
if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG)
|
||||||
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
|
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
|
||||||
pc->lastXMit = ppp_jiffies();
|
pc->lastXMit = sys_jiffies();
|
||||||
if (!pc->accomp) {
|
if (!pc->accomp) {
|
||||||
fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS);
|
fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS);
|
||||||
tailMB = pppMPutC(PPP_ALLSTATIONS, &pc->outACCM, tailMB);
|
tailMB = pppMPutC(PPP_ALLSTATIONS, &pc->outACCM, tailMB);
|
||||||
@ -637,7 +630,7 @@ int pppIOCtl(int pd, int cmd, void *arg)
|
|||||||
break;
|
break;
|
||||||
case PPPCTLG_FD:
|
case PPPCTLG_FD:
|
||||||
if (arg)
|
if (arg)
|
||||||
*(ppp_sio_fd_t *)arg = pc->fd;
|
*(sio_fd_t *)arg = pc->fd;
|
||||||
else
|
else
|
||||||
st = PPPERR_PARAM;
|
st = PPPERR_PARAM;
|
||||||
break;
|
break;
|
||||||
@ -691,9 +684,9 @@ int pppWrite(int pd, const u_char *s, int n)
|
|||||||
|
|
||||||
/* If the link has been idle, we'll send a fresh flag character to
|
/* If the link has been idle, we'll send a fresh flag character to
|
||||||
* flush any noise. */
|
* flush any noise. */
|
||||||
if ((ppp_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG)
|
if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG)
|
||||||
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
|
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
|
||||||
pc->lastXMit = ppp_jiffies();
|
pc->lastXMit = sys_jiffies();
|
||||||
|
|
||||||
/* Load output buffer. */
|
/* Load output buffer. */
|
||||||
while (n-- > 0) {
|
while (n-- > 0) {
|
||||||
@ -938,6 +931,7 @@ int sifup(int pd)
|
|||||||
if(pc->netif) {
|
if(pc->netif) {
|
||||||
pc->if_up = 1;
|
pc->if_up = 1;
|
||||||
pc->errCode = 0;
|
pc->errCode = 0;
|
||||||
|
|
||||||
if(pc->linkStatusCB)
|
if(pc->linkStatusCB)
|
||||||
pc->linkStatusCB(pc->linkStatusArg, pc->errCode);
|
pc->linkStatusCB(pc->linkStatusArg, pc->errCode);
|
||||||
} else {
|
} else {
|
||||||
@ -989,7 +983,9 @@ int sifaddr(
|
|||||||
int pd, /* Interface unit ??? */
|
int pd, /* Interface unit ??? */
|
||||||
u32_t o, /* Our IP address ??? */
|
u32_t o, /* Our IP address ??? */
|
||||||
u32_t h, /* His IP address ??? */
|
u32_t h, /* His IP address ??? */
|
||||||
u32_t m /* IP subnet mask ??? */
|
u32_t m, /* IP subnet mask ??? */
|
||||||
|
u32_t ns1, /* Primary DNS */
|
||||||
|
u32_t ns2 /* Secondary DNS */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PPPControl *pc = &pppControl[pd];
|
PPPControl *pc = &pppControl[pd];
|
||||||
@ -1002,6 +998,8 @@ int sifaddr(
|
|||||||
memcpy(&pc->our_ipaddr, &o, sizeof(o));
|
memcpy(&pc->our_ipaddr, &o, sizeof(o));
|
||||||
memcpy(&pc->his_ipaddr, &h, sizeof(h));
|
memcpy(&pc->his_ipaddr, &h, sizeof(h));
|
||||||
memcpy(&pc->netmask, &m, sizeof(m));
|
memcpy(&pc->netmask, &m, sizeof(m));
|
||||||
|
memcpy(&pc->dns1, &ns1, sizeof(ns1));
|
||||||
|
memcpy(&pc->dns2, &ns2, sizeof(ns2));
|
||||||
}
|
}
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
@ -1028,6 +1026,8 @@ int cifaddr(
|
|||||||
IP4_ADDR(&pc->our_ipaddr, 0,0,0,0);
|
IP4_ADDR(&pc->our_ipaddr, 0,0,0,0);
|
||||||
IP4_ADDR(&pc->his_ipaddr, 0,0,0,0);
|
IP4_ADDR(&pc->his_ipaddr, 0,0,0,0);
|
||||||
IP4_ADDR(&pc->netmask, 255,255,255,0);
|
IP4_ADDR(&pc->netmask, 255,255,255,0);
|
||||||
|
IP4_ADDR(&pc->dns1, 0,0,0,0);
|
||||||
|
IP4_ADDR(&pc->dns2, 0,0,0,0);
|
||||||
}
|
}
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
@ -1121,10 +1121,14 @@ static void pppMain(void *arg)
|
|||||||
int pd = (int)arg;
|
int pd = (int)arg;
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
PPPControl* pc;
|
PPPControl* pc;
|
||||||
|
|
||||||
pc = &pppControl[pd];
|
pc = &pppControl[pd];
|
||||||
|
|
||||||
p = pbuf_alloc(PBUF_RAW, PPP_MRU+PPP_HDRLEN, PBUF_RAM);
|
p = pbuf_alloc(PBUF_RAW, PPP_MRU+PPP_HDRLEN, PBUF_RAM);
|
||||||
if(!p) {
|
if(!p) {
|
||||||
ppp_panic("pppMain: unable to allocate pbuf");
|
LWIP_ASSERT("p != NULL", p);
|
||||||
|
pc->errCode = PPPERR_ALLOC;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1150,6 +1154,8 @@ static void pppMain(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
|
|
||||||
|
out:
|
||||||
if(pc->linkStatusCB)
|
if(pc->linkStatusCB)
|
||||||
pc->linkStatusCB(pc->linkStatusArg, pc->errCode ? pc->errCode : PPPERR_PROTOCOL);
|
pc->linkStatusCB(pc->linkStatusArg, pc->errCode ? pc->errCode : PPPERR_PROTOCOL);
|
||||||
|
|
||||||
|
@ -34,9 +34,17 @@
|
|||||||
#ifndef PPP_H
|
#ifndef PPP_H
|
||||||
#define PPP_H
|
#define PPP_H
|
||||||
|
|
||||||
#include "target.h"
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
#if PPP_SUPPORT > 0
|
#if PPP_SUPPORT > 0
|
||||||
|
#include "lwip/sio.h"
|
||||||
|
#include "lwip/api.h"
|
||||||
|
#include "lwip/sockets.h"
|
||||||
|
#include "lwip/stats.h"
|
||||||
|
#include "lwip/mem.h"
|
||||||
|
#include "lwip/tcpip.h"
|
||||||
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* pppd.h - PPP daemon global declarations.
|
* pppd.h - PPP daemon global declarations.
|
||||||
*
|
*
|
||||||
@ -83,6 +91,20 @@
|
|||||||
* OR MODIFICATIONS.
|
* OR MODIFICATIONS.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define TIMEOUT(f, a, t) sys_untimeout((f), (a)), sys_timeout((t)*1000, (f), (a))
|
||||||
|
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
|
||||||
|
|
||||||
|
|
||||||
|
# ifndef __u_char_defined
|
||||||
|
|
||||||
|
/* Type definitions for BSD code. */
|
||||||
|
typedef unsigned long u_long;
|
||||||
|
typedef unsigned int u_int;
|
||||||
|
typedef unsigned short u_short;
|
||||||
|
typedef unsigned char u_char;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants and structures defined by the internet system,
|
* Constants and structures defined by the internet system,
|
||||||
* Per RFC 790, September 1981, and numerous additions.
|
* Per RFC 790, September 1981, and numerous additions.
|
||||||
@ -197,40 +219,6 @@ enum NPmode {
|
|||||||
PUTCHAR(PPP_UI, p); \
|
PUTCHAR(PPP_UI, p); \
|
||||||
PUTSHORT(t, p); }
|
PUTSHORT(t, p); }
|
||||||
|
|
||||||
/*
|
|
||||||
* Definitions of bits in internet address integers.
|
|
||||||
* On subnets, the decomposition of addresses to host and net parts
|
|
||||||
* is done according to subnet mask, not the masks here.
|
|
||||||
*/
|
|
||||||
#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
|
|
||||||
#define IN_CLASSA_NET 0xff000000
|
|
||||||
#define IN_CLASSA_NSHIFT 24
|
|
||||||
#define IN_CLASSA_HOST 0x00ffffff
|
|
||||||
#define IN_CLASSA_MAX 128
|
|
||||||
|
|
||||||
#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
|
|
||||||
#define IN_CLASSB_NET 0xffff0000
|
|
||||||
#define IN_CLASSB_NSHIFT 16
|
|
||||||
#define IN_CLASSB_HOST 0x0000ffff
|
|
||||||
#define IN_CLASSB_MAX 65536
|
|
||||||
|
|
||||||
#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000)
|
|
||||||
#define IN_CLASSC_NET 0xffffff00
|
|
||||||
#define IN_CLASSC_NSHIFT 8
|
|
||||||
#define IN_CLASSC_HOST 0x000000ff
|
|
||||||
|
|
||||||
#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000)
|
|
||||||
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
|
|
||||||
#define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
|
|
||||||
#define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */
|
|
||||||
#define IN_MULTICAST(i) IN_CLASSD(i)
|
|
||||||
|
|
||||||
#define IN_EXPERIMENTAL(i) (((long)(i) & 0xf0000000) == 0xf0000000)
|
|
||||||
#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000)
|
|
||||||
|
|
||||||
#define IN_LOOPBACKNET 127 /* official! */
|
|
||||||
|
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
*** PUBLIC DEFINITIONS ***
|
*** PUBLIC DEFINITIONS ***
|
||||||
*************************/
|
*************************/
|
||||||
@ -358,7 +346,7 @@ void pppSetAuth(const char *user, const char *passwd);
|
|||||||
* Return a new PPP connection descriptor on success or
|
* Return a new PPP connection descriptor on success or
|
||||||
* an error code (negative) on failure.
|
* an error code (negative) on failure.
|
||||||
*/
|
*/
|
||||||
int pppOpen(ppp_sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *linkStatusArg);
|
int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *linkStatusArg);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close a PPP connection and release the descriptor.
|
* Close a PPP connection and release the descriptor.
|
||||||
@ -410,7 +398,7 @@ int sifnpmode (int u, int proto, enum NPmode mode);
|
|||||||
/* Configure i/f down (for IP) */
|
/* Configure i/f down (for IP) */
|
||||||
int sifdown (int);
|
int sifdown (int);
|
||||||
/* Configure IP addresses for i/f */
|
/* Configure IP addresses for i/f */
|
||||||
int sifaddr (int, u32_t, u32_t, u32_t);
|
int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t);
|
||||||
/* Reset i/f IP addresses */
|
/* Reset i/f IP addresses */
|
||||||
int cifaddr (int, u32_t, u32_t);
|
int cifaddr (int, u32_t, u32_t);
|
||||||
/* Create default route through i/f */
|
/* Create default route through i/f */
|
||||||
|
@ -191,7 +191,7 @@ void avRandomInit()
|
|||||||
avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr
|
avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr
|
||||||
+ ppp_mtime() + ((u32_t)TM1 << 16) + TM1;
|
+ ppp_mtime() + ((u32_t)TM1 << 16) + TM1;
|
||||||
#else
|
#else
|
||||||
avRandomSeed += ppp_jiffies(); /* XXX */
|
avRandomSeed += sys_jiffies(); /* XXX */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize the Borland random number generator. */
|
/* Initialize the Borland random number generator. */
|
||||||
@ -215,9 +215,9 @@ void avRandomize(void)
|
|||||||
/* The initialization function also updates the seed. */
|
/* The initialization function also updates the seed. */
|
||||||
} else {
|
} else {
|
||||||
/* avRandomSeed += (avRandomSeed << 16) + TM1; */
|
/* avRandomSeed += (avRandomSeed << 16) + TM1; */
|
||||||
avRandomSeed += (ppp_jiffies() - last_jiffies); /* XXX */
|
avRandomSeed += (sys_jiffies() - last_jiffies); /* XXX */
|
||||||
}
|
}
|
||||||
last_jiffies = ppp_jiffies();
|
last_jiffies = sys_jiffies();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1,38 +0,0 @@
|
|||||||
#include "ppp.h"
|
|
||||||
|
|
||||||
void ppp_panic(char * msg)
|
|
||||||
{
|
|
||||||
LWIP_ASSERT("PPP panic: %s\n", msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ppp_msleep(unsigned long ms)
|
|
||||||
{
|
|
||||||
sys_sem_t delaysem = sys_sem_new(0);
|
|
||||||
|
|
||||||
sys_sem_wait_timeout(delaysem, ms);
|
|
||||||
|
|
||||||
sys_sem_free(delaysem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make a string representation of a network IP address.
|
|
||||||
* WARNING: NOT RE-ENTRANT!
|
|
||||||
*/
|
|
||||||
char *ip_ntoa(u32_t ipaddr)
|
|
||||||
{
|
|
||||||
static char b[20];
|
|
||||||
|
|
||||||
ipaddr = ntohl(ipaddr);
|
|
||||||
#if 0
|
|
||||||
FIXME
|
|
||||||
sprintf(b, "%d.%d.%d.%d",
|
|
||||||
(u_char)(ipaddr >> 24),
|
|
||||||
(u_char)(ipaddr >> 16),
|
|
||||||
(u_char)(ipaddr >> 8),
|
|
||||||
(u_char)(ipaddr));
|
|
||||||
#endif
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
|||||||
#ifndef TARGET_H_
|
|
||||||
#define TARGET_H_
|
|
||||||
|
|
||||||
#include "lwip/opt.h"
|
|
||||||
#include "lwip/debug.h"
|
|
||||||
#include "lwip/api.h"
|
|
||||||
#include "lwip/sockets.h"
|
|
||||||
#include "lwip/stats.h"
|
|
||||||
#include "lwip/mem.h"
|
|
||||||
#include "lwip/tcpip.h"
|
|
||||||
#include "lwip/netif.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* the following is temporary until sio_common.h defines SIO_ERROR */
|
|
||||||
#if defined(ERROR) && !defined(SIO_ERROR)
|
|
||||||
#define SIO_ERROR ERROR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define TIMEOUT(f, a, t) sys_untimeout((f), (a)), sys_timeout((t)*1000, (f), (a))
|
|
||||||
#define UNTIMEOUT(f, a) sys_untimeout((f), (a))
|
|
||||||
|
|
||||||
|
|
||||||
# ifndef __u_char_defined
|
|
||||||
|
|
||||||
/* Type definitions for BSD code. */
|
|
||||||
typedef unsigned long u_long;
|
|
||||||
typedef unsigned int u_int;
|
|
||||||
typedef unsigned short u_short;
|
|
||||||
typedef unsigned char u_char;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Sleep ms milliseconds. Note that this only has a (close to) 1 Jiffy
|
|
||||||
* resolution.
|
|
||||||
* Note: Since there may me less than a ms left before the next clock
|
|
||||||
* tick, 1 tick is added to ensure we delay at least ms time.
|
|
||||||
*/
|
|
||||||
void ppp_msleep(unsigned long ms);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Return the number of jiffies that have passed since power up.
|
|
||||||
*/
|
|
||||||
unsigned long ppp_jiffies(void);
|
|
||||||
|
|
||||||
/* Display a panic message and HALT the system. */
|
|
||||||
void ppp_panic(char *msg);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make a string representation of a network IP address.
|
|
||||||
* WARNING: NOT RE-ENTRANT!
|
|
||||||
*/
|
|
||||||
char *ip_ntoa(u32_t ipaddr);
|
|
||||||
|
|
||||||
typedef void * ppp_sio_fd_t;
|
|
||||||
|
|
||||||
/*FIXME */
|
|
||||||
#define sio_read_abort(fd) do { \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* TARGET_H */
|
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Definitions for tcp compression routines.
|
* Definitions for tcp compression routines.
|
||||||
*
|
*
|
||||||
* $Id: vj.h,v 1.1 2003/05/27 14:37:56 jani Exp $
|
* $Id: vj.h,v 1.2 2003/06/02 11:12:56 jani Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 1989 Regents of the University of California.
|
* Copyright (c) 1989 Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
@ -144,7 +144,7 @@ struct vjcompress {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* flag values */
|
/* flag values */
|
||||||
#define VJF_TOSS 1 /* tossing rcvd frames because of input err */
|
#define VJF_TOSS 1U /* tossing rcvd frames because of input err */
|
||||||
|
|
||||||
extern void vj_compress_init (struct vjcompress *comp);
|
extern void vj_compress_init (struct vjcompress *comp);
|
||||||
extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb);
|
extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user