Compare commits

...

8 Commits

Author SHA1 Message Date
leonwoestenberg
45756246b9 Merged from DEVEL. 2003-06-23 18:06:26 +00:00
marcbou
611fb3a1f9 Merged from DEVEL. 2003-06-19 11:50:54 +00:00
marcbou
ec1c2a714e merged from DEVEL. 2003-06-19 11:35:26 +00:00
marcbou
55f64f13c7 Important bug fixes and improvements. 2003-06-19 11:31:25 +00:00
marcbou
bbc33080e7 Merged from DEVEL. 2003-06-19 11:15:39 +00:00
marcbou
506a57392c Merged from DEVEL 2003-06-19 11:08:57 +00:00
marcbou
f0e0e72e4d Patch #1623: Add missing pbuf_free() call after pbuf_chain() in slipif_input() 2003-06-19 10:30:13 +00:00
likewise
7108c57876 Merged with DEVEL. 2003-06-13 12:16:29 +00:00
11 changed files with 270 additions and 208 deletions

View File

@@ -2,12 +2,21 @@ HISTORY
(current)
++ Bug fixes:
* some debug formatters and casts fixed.
* numereous fixes in PPP.
++ Changes:
* DEBUGF now is LWIP_DEBUGF
* pbuf_dechain() has been re-enabled.
* Mentioned the changed use of CVS branches in README.
(STABLE-0_6_3)
++ Bug fixes:
* Fixed pool pbuf memory leak in pbuf_alloc().
Occured if not enough PBUF_POOL pbufs for a packet pbuf chain.
Reported by Savin Zlobec.
@@ -20,11 +29,11 @@ HISTORY
* Added PPP stack contributed by Marc Boucher
++ Changes:
* Now drops short packets for ICMP/UDP/TCP protocols. More robust.
* ARP queueuing now queues the latest packet instead of the first.
This is the recommended behaviour, but can be overridden in
This is the RFC recommended behaviour, but can be overridden in
lwipopts.h.
(0.6.2)
@@ -80,10 +89,10 @@ HISTORY
* netif's have a dhcp field that must be initialized to NULL by the driver.
See the contrib/ports/c16x cs8900 driver as a driver example.
(0.5.x) This file has been unmaintained up to 0.6.1. All changes are
logged in CVS but have not been explained here.
(0.5.3) Changes since version 0.5.2
++ Bugfixes:
@@ -115,7 +124,7 @@ HISTORY
* pbuf_dechain() did not update the ->tot_len field of the tail.
* Aborted TCP connections were not handled correctly in all
situations.
situations.
++ Other changes:
@@ -123,7 +132,7 @@ HISTORY
* The ->len field in the tcp_seg structure now counts the actual
amount of data, and does not add one for SYN and FIN segments.
(0.5.1) Changes since version 0.5.0
++ New features:
@@ -133,16 +142,16 @@ HISTORY
* Preliminary support for cross platform packed structs.
* ARP timer now implemented.
++ Bugfixes:
* TCP output queue length was badly initialized when opening
connections.
* TCP delayed ACKs were not sent correctly.
* Explicit initialization of BSS segment variables.
* read() in BSD socket library could drop data.
* Problems with memory alignment.
@@ -156,7 +165,7 @@ HISTORY
* IP multicast address tests had endianess problems.
* ARP requests had wrong destination hardware address.
* ARP requests had wrong destination hardware address.
++ Other changes:
@@ -166,8 +175,8 @@ HISTORY
* TCP and UDP ->dest_* struct members where changed to ->remote_*.
* ntoh* macros are now null definitions for big endian CPUs.
* ntoh* macros are now null definitions for big endian CPUs.
(0.5.0) Changes since version 0.4.2
++ New features:
@@ -175,9 +184,9 @@ HISTORY
* Redesigned operating system emulation layer to make porting easier.
* Better control over TCP output buffers.
* Documenation added.
++ Bugfixes:
* Locking issues in buffer management.
@@ -190,7 +199,7 @@ HISTORY
* Directory structure somewhat changed; the core/ tree has been
collapsed.
(0.4.2) Changes since version 0.4.1
++ New features:
@@ -213,7 +222,7 @@ HISTORY
* Variable++ have in appliciable cases been translated to ++variable
since some compilers generate better code in the latter case.
(0.4.1) Changes since version 0.4
++ New features:
@@ -225,43 +234,43 @@ HISTORY
* UDP: experimental support for UDP-Lite extensions.
++ Bugfixes:
* TCP: out of order segments were in some cases handled incorrectly,
and this has now been fixed. Delayed acknowledgements was broken
in 0.4, has now been fixed. Binding to an address that is in use
now results in an error. Reset connections sometimes hung an
application; this has been fixed.
application; this has been fixed.
* Checksum calculation sometimes failed for chained pbufs with odd
lengths. This has been fixed.
* API: a lot of bug fixes in the API. The UDP API has been improved
and tested. Error reporting and handling has been
improved. Logical flaws and race conditions for incoming TCP
connections has been found and removed.
connections has been found and removed.
* Memory manager: alignment issues. Reallocating memory sometimes
failed, this has been fixed.
* Generic library: bcopy was flawed and has been fixed.
* Generic library: bcopy was flawed and has been fixed.
++ Other changes:
* API: all datatypes has been changed from generic ones such as
ints, to specified ones such as u16_t. Functions that return
errors now have the correct type (err_t).
* General: A lot of code cleaned up and debugging code removed. Many
portability issues have been fixed.
* The license was changed; the advertising clause was removed.
* The license was changed; the advertising clause was removed.
* C64 port added.
* Thanks: Huge thanks go to Dagan Galarneau, Horst Garnetzke, Petri
Kosunen, Mikael Caleres, and Frits Wilmink for reporting and
fixing bugs!
(0.4) Changes since version 0.3.1
* Memory management has been radically changed; instead of
@@ -269,14 +278,14 @@ HISTORY
rapidly allocated and deallocated is now kept in pools. Allocation
and deallocation from those memory pools is very fast. The shared
heap is still present but is used less frequently.
* The memory, memory pool, and packet buffer subsystems now support
4-, 2-, or 1-byte alignment.
* "Out of memory" situations are handled in a more robust way.
* Stack usage has been reduced.
* Easier configuration of lwIP parameters such as memory usage,
TTLs, statistics gathering, etc. All configuration parameters are
now kept in a single header file "lwipopts.h".
@@ -290,7 +299,7 @@ HISTORY
* The code for the RTXC architecture has been implemented, tested
and put to use.
* Bugs have been found and corrected in the TCP, UDP, IP, API, and
the Internet checksum modules.
@@ -299,7 +308,7 @@ HISTORY
* The license has been changed slightly to conform more with the
original BSD license, including the advertisement clause.
(0.3.1) Changes since version 0.3
* Fix of a fatal bug in the buffer management. Pbufs with allocated
@@ -325,10 +334,10 @@ HISTORY
to free some memory and retry the allocation.
* Much testing has been done with limited memory
configurations. lwIP now does a better job when overloaded.
configurations. lwIP now does a better job when overloaded.
* Some bugfixes and improvements to the buffer (pbuf) subsystem.
* Many bugfixes in the TCP code:
- Fixed a bug in tcp_close().
@@ -355,15 +364,15 @@ HISTORY
- TCP retransmission timeout backoffs are not correctly computed
(ala BSD). After a number of retransmissions, TCP now gives up
the connection.
* TCP connections now are kept on three lists, one for active
connections, one for listening connections, and one for
connections that are in TIME-WAIT. This greatly speeds up the fast
timeout processing for sending delayed ACKs.
* TCP now provides proper feedback to the application when a
connection has been successfully set up.
* More comments have been added to the code. The code has also been
somewhat cleaned up.

24
README
View File

@@ -34,16 +34,31 @@ and developers using the stack often submit bug fixes, improvements,
and additions to the stack to further increase its usefulness.
Development of lwIP is hosted on Savannah, a central point for
software development, maintenance and distribution. A core team
will improve lwIP by the use of Savannah's interface and CVS.
software development, maintenance and distribution. Everyone can
help improve lwIP by use of Savannah's interface, CVS and the
mailing list. A core team of developers will commit changes to the
CVS source tree.
The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and
contributions (such as platform ports) are in the 'contrib' module.
The current lwIP CVS tree can be checked out by doing:
The CVS main trunk is the stable branch, which contains bug fixes and
tested features. The latest stable branch can be checked out by doing:
cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login
cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co lwip
The 'STABLE' tag in the stable branch will represent the most stable
revision (which may be somewhat older to protect us from errors
introduced by merges). This 'STABLE' tagged version can be checked out
by doing:
cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login
cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co -r STABLE lwip
The 'DEVEL' branch is the active development branch, which contains
bleeding edge changes, and may be instable. It can be checkout by doing:
cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login
cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co -r DEVEL lwip
The current contrib CVS tree can be checked out by doing:
cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login
cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co contrib
@@ -58,9 +73,6 @@ The current CVS trees are web-browsable:
Submit patches and bugs via the lwIP project page:
http://savannah.nongnu.org/projects/lwip/
The main branch is the active development branch, whereas the 'STABLE'
branch aims to be bug-free, without the latest changes. Keep track of
the lwIP users mailing list for the statusses of both.
DOCUMENTATION

View File

@@ -4,7 +4,8 @@ Table of Contents:
1 - Anonymous CVS checkouts and updates (to be elaborated)
2 - Committers/developers CVS access using SSH (to be written)
3 - How to release lwIP
3 - Merging from DEVEL branch to main trunk (stable branch)
4 - How to release lwIP
1 Anonymous CVS checkouts and updates
@@ -25,7 +26,29 @@ Or, obtain a development branch as follows:
cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login
cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip checkout -r DEVEL -d lwip-devel lwip
3 How to release lwIP
3 Merging from DEVEL branch to main trunk (stable branch)
---------------------------------------------------------
Merging from DEVEL to main requires that the DEVEL branch
has a tag indicating the previous merger. This tag is
called 'merged_from_DEVEL_to_main'.
IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE
REPOSITORY, THE TAG MUST BE SET ON THE SOURCE OF THE
MERGE BRANCH (REPLACING EXISTING TAGS WITH THE SAME NAME).
Merge all changes in DEVEL since our last merge to main:
In the working copy of the main trunk:
cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL
Now move the tag in the DEVEL branch to this merge point,
so we can use this for future merges.
cvs -z4 rtag -F -r DEVEL merged_from_DEVEL_to_main lwip
4 How to release lwIP
---------------------
First, checkout a clean copy of the branch to be released. Tag this set with

View File

@@ -853,7 +853,6 @@ pbuf_take(struct pbuf *p)
return head;
}
#if 0 /* TODO: See if we might need this for future features */
/**
* Dechains the first pbuf from its succeeding pbufs in the chain.
*
@@ -890,7 +889,6 @@ pbuf_dechain(struct pbuf *p)
LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len);
return (tail_gone > 0? NULL: q);
}
#endif /* pbuf_dechain() */
/* TODO: This function is unused in the lwIP stack and will be deprecated. This is due
* to the new way chains are built. */

View File

@@ -457,7 +457,9 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
{
struct udp_pcb *ipcb;
u8_t rebind;
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = %lx, port = %u)\n", ipaddr->addr, port));
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = "));
ip_addr_debug_print(UDP_DEBUG, ipaddr);
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %u)\n", port));
rebind = 0;
/* Check for double bind and rebind of the same pcb */
for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {

View File

@@ -118,11 +118,11 @@ extern const struct ip_addr ip_addr_broadcast;
#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
#define ip_addr_debug_print(ipaddr) LWIP_DEBUGF(LWIP_DEBUG, ("%d.%d.%d.%d", \
(unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff, \
(unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff, \
(unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff, \
(unsigned int)ntohl((ipaddr)->addr) & 0xff))
#define ip_addr_debug_print(debug, ipaddr) LWIP_DEBUGF(debug, ("%u.%u.%u.%u", \
ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff:0, \
ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff:0, \
ipaddr?(unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff:0, \
ipaddr?(unsigned int)ntohl((ipaddr)->addr) & 0xff:0U))
/* cast to unsigned int, as it is used as argument to printf functions
* which expect integer arguments */

View File

@@ -110,8 +110,6 @@ u8_t pbuf_free(struct pbuf *p);
u8_t pbuf_clen(struct pbuf *p);
void pbuf_chain(struct pbuf *h, struct pbuf *t);
struct pbuf *pbuf_take(struct pbuf *f);
#if 0 /* see remark in code */
struct pbuf *pbuf_dechain(struct pbuf *p);
#endif
#endif /* __LWIP_PBUF_H__ */

View File

@@ -121,6 +121,7 @@ typedef enum {
PDDATA /* Process data byte. */
} PPPDevStates;
#define ESCAPE_P(accm, c) ((accm)[(c) >> 3] & pppACCMMask[c & 0x07])
/************************/
/*** LOCAL DATA TYPES ***/
@@ -141,7 +142,6 @@ typedef struct PPPControl_s {
char inEscaped; /* Escape next character. */
u16_t inProtocol; /* The input protocol code. */
u16_t inFCS; /* Input Frame Check Sequence value. */
u16_t inLen; /* Input packet length. */
int mtu; /* Peer's mru */
int pcomp; /* Does peer accept protocol compression? */
int accomp; /* Does peer accept addr/ctl compression? */
@@ -155,10 +155,10 @@ typedef struct PPPControl_s {
struct netif *netif;
struct ip_addr our_ipaddr, his_ipaddr, netmask, dns1, dns2;
struct ppp_addrs addrs;
void (*linkStatusCB)(void *arg, int errCode);
void *linkStatusArg;
void (*linkStatusCB)(void *ctx, int errCode, void *arg);
void *linkStatusCtx;
} PPPControl;
@@ -180,10 +180,6 @@ struct npioctl {
static void pppMain(void *pd);
static void pppDrop(PPPControl *pc);
static void pppInProc(int pd, u_char *s, int l);
static struct pbuf *pppMPutC(u_char c, ext_accm *outACCM, struct pbuf *nb);
static struct pbuf *pppMPutRaw(u_char c, struct pbuf *nb);
#define ESCAPE_P(accm, c) ((accm)[(c) >> 3] & pppACCMMask[c & 0x07])
/******************************/
@@ -339,7 +335,7 @@ void pppSetAuth(const char *user, const char *passwd)
* established before calling this.
* Return a new PPP connection descriptor on success or
* an error code (negative) on failure. */
int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *linkStatusArg)
int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx)
{
PPPControl *pc;
int pd;
@@ -384,7 +380,7 @@ int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *lin
pc->outACCM[15] = 0x60;
pc->linkStatusCB = linkStatusCB;
pc->linkStatusArg = linkStatusArg;
pc->linkStatusCtx = linkStatusCtx;
sys_thread_new(pppMain, (void*)pd, PPP_THREAD_PRIO);
if(!linkStatusCB) {
@@ -456,6 +452,44 @@ static void nPut(PPPControl *pc, struct pbuf *nb)
#endif /* LINK_STATS */
}
/*
* pppAppend - append given character to end of given pbuf. If outACCM
* is not NULL and the character needs to be escaped, do so.
* If pbuf is full, append another.
* Return the current pbuf.
*/
static struct pbuf *pppAppend(u_char c, struct pbuf *nb, ext_accm *outACCM)
{
struct pbuf *tb = nb;
/* Make sure there is room for the character and an escape code.
* Sure we don't quite fill the buffer if the character doesn't
* get escaped but is one character worth complicating this? */
/* Note: We assume no packet header. */
if (nb && (PBUF_POOL_BUFSIZE - nb->len) < 2) {
tb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL);
if (tb) {
nb->next = tb;
}
#ifdef LINK_STATS
else {
lwip_stats.link.memerr++;
}
#endif /* LINK_STATS */
nb = tb;
}
if (nb) {
if (outACCM && ESCAPE_P(*outACCM, c)) {
*((u_char*)nb->payload + nb->len++) = PPP_ESCAPE;
*((u_char*)nb->payload + nb->len++) = c ^ PPP_TRANS;
}
else
*((u_char*)nb->payload + nb->len++) = c;
}
return tb;
}
/* Send a packet on the given connection. */
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *ipaddr)
{
@@ -536,22 +570,22 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
/* Build the PPP header. */
if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG)
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
tailMB = pppAppend(PPP_FLAG, tailMB, NULL);
pc->lastXMit = sys_jiffies();
if (!pc->accomp) {
fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS);
tailMB = pppMPutC(PPP_ALLSTATIONS, &pc->outACCM, tailMB);
tailMB = pppAppend(PPP_ALLSTATIONS, tailMB, &pc->outACCM);
fcsOut = PPP_FCS(fcsOut, PPP_UI);
tailMB = pppMPutC(PPP_UI, &pc->outACCM, tailMB);
tailMB = pppAppend(PPP_UI, tailMB, &pc->outACCM);
}
if (!pc->pcomp || protocol > 0xFF) {
c = (protocol >> 8) & 0xFF;
fcsOut = PPP_FCS(fcsOut, c);
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
}
c = protocol & 0xFF;
fcsOut = PPP_FCS(fcsOut, c);
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
/* Load packet. */
for(p = pb; p; p = p->next) {
@@ -567,16 +601,16 @@ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *i
fcsOut = PPP_FCS(fcsOut, c);
/* Copy to output buffer escaping special characters. */
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
}
}
/* Add FCS and trailing flag. */
c = ~fcsOut & 0xFF;
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
c = (~fcsOut >> 8) & 0xFF;
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
tailMB = pppAppend(PPP_FLAG, tailMB, NULL);
/* If we failed to complete the packet, throw it away. */
if (!tailMB) {
@@ -685,7 +719,7 @@ int pppWrite(int pd, const u_char *s, int n)
/* If the link has been idle, we'll send a fresh flag character to
* flush any noise. */
if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG)
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
tailMB = pppAppend(PPP_FLAG, tailMB, NULL);
pc->lastXMit = sys_jiffies();
/* Load output buffer. */
@@ -696,21 +730,21 @@ int pppWrite(int pd, const u_char *s, int n)
fcsOut = PPP_FCS(fcsOut, c);
/* Copy to output buffer escaping special characters. */
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
}
/* Add FCS and trailing flag. */
c = ~fcsOut & 0xFF;
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
c = (~fcsOut >> 8) & 0xFF;
tailMB = pppMPutC(c, &pc->outACCM, tailMB);
tailMB = pppMPutRaw(PPP_FLAG, tailMB);
tailMB = pppAppend(c, tailMB, &pc->outACCM);
tailMB = pppAppend(PPP_FLAG, tailMB, NULL);
/* If we failed to complete the packet, throw it away.
* Otherwise send it. */
if (!tailMB) {
PPPDEBUG((LOG_WARNING,
"pppWrite[%d]: Alloc err - dropping nBuf len=%d\n", pd, headMB->len));
"pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->len));
/* "pppWrite[%d]: Alloc err - dropping %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */
pbuf_free(headMB);
#ifdef LINK_STATS
@@ -927,13 +961,14 @@ int sifup(int pd)
} else {
if(pc->netif)
netif_remove(pc->netif);
pc->netif = netif_add(&pc->our_ipaddr, &pc->netmask, &pc->his_ipaddr, (void *)pd, pppifNetifInit, ip_input);
pc->netif = netif_add(&pc->addrs.our_ipaddr, &pc->addrs.netmask, &pc->addrs.his_ipaddr, (void *)pd, pppifNetifInit, ip_input);
if(pc->netif) {
pc->if_up = 1;
pc->errCode = 0;
pc->errCode = PPPERR_NONE;
if(pc->linkStatusCB)
pc->linkStatusCB(pc->linkStatusArg, pc->errCode);
PPPDEBUG((LOG_DEBUG, "sifup: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
if(pc->linkStatusCB)
pc->linkStatusCB(pc->linkStatusCtx, pc->errCode, &pc->addrs);
} else {
st = 0;
PPPDEBUG((LOG_ERR, "sifup[%d]: netif_add failed\n", pd));
@@ -948,10 +983,10 @@ int sifup(int pd)
*/
int sifnpmode(int u, int proto, enum NPmode mode)
{
(void)u;
(void)proto;
(void)mode;
return 0;
(void)u;
(void)proto;
(void)mode;
return 0;
}
/*
@@ -970,8 +1005,9 @@ int sifdown(int pd)
if(pc->netif)
netif_remove(pc->netif);
pc->netif = NULL;
PPPDEBUG((LOG_DEBUG, "sifdown: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
if(pc->linkStatusCB)
pc->linkStatusCB(pc->linkStatusArg, PPPERR_CONNECT);
pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, NULL);
}
return st;
}
@@ -995,11 +1031,11 @@ int sifaddr(
st = 0;
PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd));
} else {
memcpy(&pc->our_ipaddr, &o, sizeof(o));
memcpy(&pc->his_ipaddr, &h, sizeof(h));
memcpy(&pc->netmask, &m, sizeof(m));
memcpy(&pc->dns1, &ns1, sizeof(ns1));
memcpy(&pc->dns2, &ns2, sizeof(ns2));
memcpy(&pc->addrs.our_ipaddr, &o, sizeof(o));
memcpy(&pc->addrs.his_ipaddr, &h, sizeof(h));
memcpy(&pc->addrs.netmask, &m, sizeof(m));
memcpy(&pc->addrs.dns1, &ns1, sizeof(ns1));
memcpy(&pc->addrs.dns2, &ns2, sizeof(ns2));
}
return st;
}
@@ -1023,11 +1059,11 @@ int cifaddr(
st = 0;
PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd));
} else {
IP4_ADDR(&pc->our_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->dns1, 0,0,0,0);
IP4_ADDR(&pc->dns2, 0,0,0,0);
IP4_ADDR(&pc->addrs.our_ipaddr, 0,0,0,0);
IP4_ADDR(&pc->addrs.his_ipaddr, 0,0,0,0);
IP4_ADDR(&pc->addrs.netmask, 255,255,255,0);
IP4_ADDR(&pc->addrs.dns1, 0,0,0,0);
IP4_ADDR(&pc->addrs.dns2, 0,0,0,0);
}
return st;
}
@@ -1077,6 +1113,7 @@ int cifdefaultroute(int pd, u32_t l, u32_t g)
void
pppMainWakeup(int pd)
{
PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d\n", pd));
sio_read_abort(pppControl[pd].fd);
}
@@ -1091,6 +1128,7 @@ pppStartCB(void *arg)
{
int pd = (int)arg;
PPPDEBUG((LOG_DEBUG, "pppStartCB: unit %d\n", pd));
lcp_lowerup(pd);
lcp_open(pd); /* Start protocol */
}
@@ -1100,6 +1138,7 @@ pppStopCB(void *arg)
{
int pd = (int)arg;
PPPDEBUG((LOG_DEBUG, "pppStopCB: unit %d\n", pd));
lcp_close(pd, "User request");
}
@@ -1108,6 +1147,7 @@ pppHupCB(void *arg)
{
int pd = (int)arg;
PPPDEBUG((LOG_DEBUG, "pppHupCB: unit %d\n", pd));
lcp_lowerdown(pd);
link_terminated(pd);
}
@@ -1134,30 +1174,37 @@ static void pppMain(void *arg)
/*
* Start the connection and handle incoming events (packet or timeout).
*/
ppp_trace(LOG_NOTICE, "Connecting\n");
PPPDEBUG((LOG_INFO, "pppMain: unit %d: Connecting\n", pd));
tcpip_callback(pppStartCB, arg);
while (lcp_phase[pd] != PHASE_DEAD) {
if (pc->kill_link) {
PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d kill_link -> pppStopCB\n", pd));
pc->errCode = PPPERR_USER;
/* This will leave us at PHASE_DEAD. */
tcpip_callback(pppStopCB, arg);
pc->kill_link = 0;
}
else if (pc->sig_hup) {
PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d sig_hup -> pppHupCB\n", pd));
pc->sig_hup = 0;
tcpip_callback(pppHupCB, arg);
} else {
int c = sio_read(pc->fd, p->payload, p->len);
if(c > 0) {
pppInProc(pd, p->payload, c);
} else {
PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d sio_read len=%d returned %d\n", pd, p->len, c));
sys_msleep(250); /* give other tasks a chance to run */
}
}
}
PPPDEBUG((LOG_INFO, "pppMain: unit %d: PHASE_DEAD\n", pd));
pbuf_free(p);
out:
PPPDEBUG((LOG_DEBUG, "pppMain: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode));
if(pc->linkStatusCB)
pc->linkStatusCB(pc->linkStatusArg, pc->errCode ? pc->errCode : PPPERR_PROTOCOL);
pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, NULL);
pc->openFlag = 0;
}
@@ -1227,7 +1274,7 @@ static void pppInput(void *arg)
switch(protocol) {
case PPP_VJC_COMP: /* VJ compressed TCP */
#if VJ_SUPPORT > 0
PPPDEBUG((LOG_INFO, "pppInput[%d]: vj_comp in nBuf len=%d\n", pd, nb->len));
PPPDEBUG((LOG_INFO, "pppInput[%d]: vj_comp in pbuf len=%d\n", pd, nb->len));
/*
* Clip off the VJ header and prepend the rebuilt TCP/IP header and
* pass the result to IP.
@@ -1245,7 +1292,7 @@ static void pppInput(void *arg)
break;
case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */
#if VJ_SUPPORT > 0
PPPDEBUG((LOG_INFO, "pppInput[%d]: vj_un in nBuf len=%d\n", pd, nb->len));
PPPDEBUG((LOG_INFO, "pppInput[%d]: vj_un in pbuf len=%d\n", pd, nb->len));
/*
* Process the TCP/IP header for VJ header compression and then pass
* the packet to IP.
@@ -1264,7 +1311,7 @@ static void pppInput(void *arg)
#endif /* VJ_SUPPORT > 0 */
break;
case PPP_IP: /* Internet Protocol */
PPPDEBUG((LOG_INFO, "pppInput[%d]: ip in nBuf len=%d", pd, nb->len));
PPPDEBUG((LOG_INFO, "pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len));
pppControl[pd].netif->input(nb, pppControl[pd].netif);
return;
default:
@@ -1316,7 +1363,9 @@ static void pppDrop(PPPControl *pc)
#if 0
PPPDEBUG((LOG_INFO, "pppDrop: %d:%.*H\n", pc->inHead->len, min(60, pc->inHead->len * 2), pc->inHead->payload));
#endif
PPPDEBUG((LOG_INFO, "pppDrop: nBuf len=%d\n", pc->inHead->len));
PPPDEBUG((LOG_INFO, "pppDrop: pbuf len=%d\n", pc->inHead->len));
if (pc->inTail && (pc->inTail != pc->inHead))
pbuf_free(pc->inTail);
pbuf_free(pc->inHead);
pc->inHead = NULL;
pc->inTail = NULL;
@@ -1382,26 +1431,33 @@ static void pppInProc(int pd, u_char *s, int l)
else {
/* Trim off the checksum. */
if(pc->inTail->len >= 2) {
pc->inTail->len -= 2;
pc->inLen -= 2;
if(pc->inTail->len >= 2) {
pc->inTail->len -= 2;
/* Update the packet header. */
pc->inHead->tot_len = pc->inLen;
} else {
pc->inHead->tot_len = pc->inLen;
pbuf_realloc(pc->inHead, pc->inLen - 2);
}
pc->inTail->tot_len = pc->inTail->len;
if (pc->inTail != pc->inHead) {
pbuf_chain(pc->inHead, pc->inTail);
pbuf_free(pc->inTail);
}
} else {
pc->inTail->tot_len = pc->inTail->len;
if (pc->inTail != pc->inHead) {
pbuf_chain(pc->inHead, pc->inTail);
pbuf_free(pc->inTail);
}
pbuf_realloc(pc->inHead, pc->inHead->tot_len - 2);
}
/* Dispatch the packet thereby consuming it. */
if(tcpip_callback(pppInput, pc->inHead) != ERR_OK) {
if(tcpip_callback(pppInput, pc->inHead) != ERR_OK) {
PPPDEBUG((LOG_ERR,
"pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pd));
pbuf_free(pc->inHead);
"pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pd));
pbuf_free(pc->inHead);
#ifdef LINK_STATS
lwip_stats.link.drop++;
lwip_stats.link.drop++;
#endif
}
}
pc->inHead = NULL;
pc->inTail = NULL;
}
@@ -1480,12 +1536,19 @@ static void pppInProc(int pd, u_char *s, int l)
case PDDATA: /* Process data byte. */
/* Make space to receive processed data. */
if (pc->inTail == NULL || pc->inTail->len == PBUF_POOL_BUFSIZE) {
if(pc->inTail) {
pc->inTail->tot_len = pc->inTail->len;
if (pc->inTail != pc->inHead) {
pbuf_chain(pc->inHead, pc->inTail);
pbuf_free(pc->inTail);
}
}
/* If we haven't started a packet, we need a packet header. */
nextNBuf = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL);
if (nextNBuf == NULL) {
/* No free buffers. Drop the input packet and let the
* higher layers deal with it. Continue processing
* the received nBuf chain in case a new packet starts. */
* the received pbuf chain in case a new packet starts. */
PPPDEBUG((LOG_ERR, "pppInProc[%d]: NO FREE MBUFS!\n", pd));
#ifdef LINK_STATS
lwip_stats.link.memerr++;
@@ -1493,27 +1556,21 @@ static void pppInProc(int pd, u_char *s, int l)
pppDrop(pc);
pc->inState = PDSTART; /* Wait for flag sequence. */
break;
} else {
if (pc->inHead == NULL) {
struct pppInputHeader *pih = nextNBuf->payload;
pih->unit = pd;
pih->proto = pc->inProtocol;
nextNBuf->len += sizeof(*pih);
pc->inLen = nextNBuf->len;
pc->inHead = nextNBuf;
}
else { /* Since if inHead is not NULL, then neither is inTail! */
pc->inTail->next = nextNBuf;
}
pc->inTail = nextNBuf;
}
if (pc->inHead == NULL) {
struct pppInputHeader *pih = nextNBuf->payload;
pih->unit = pd;
pih->proto = pc->inProtocol;
nextNBuf->len += sizeof(*pih);
pc->inHead = nextNBuf;
}
pc->inTail = nextNBuf;
}
/* Load character into buffer. */
((u_char*)pc->inTail->payload)[pc->inTail->len++] = curChar;
pc->inLen++;
break;
}
@@ -1524,74 +1581,4 @@ static void pppInProc(int pd, u_char *s, int l)
avRandomize();
}
/*
* pppMPutC - append given character to end of given nBuf. If the character
* needs to be escaped, do so. If nBuf is full, append another.
* Return the current nBuf.
*/
static struct pbuf *pppMPutC(u_char c, ext_accm *outACCM, struct pbuf *nb)
{
struct pbuf *tb = nb;
/* Make sure there is room for the character and an escape code.
* Sure we don't quite fill the buffer if the character doesn't
* get escaped but is one character worth complicating this? */
/* Note: We assume no packet header. */
if (nb && (PBUF_POOL_BUFSIZE - nb->len) < 2) {
tb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL);
if (tb) {
nb->next = tb;
}
#ifdef LINK_STATS
else {
lwip_stats.link.memerr++;
}
#endif /* LINK_STATS */
nb = tb;
}
if (nb) {
if (ESCAPE_P(*outACCM, c)) {
*((u_char*)nb->payload + nb->len++) = PPP_ESCAPE;
*((u_char*)nb->payload + nb->len++) = c ^ PPP_TRANS;
}
else
*((u_char*)nb->payload + nb->len++) = c;
}
return tb;
}
/*
* pppMPutRaw - append given character to end of given nBuf without escaping
* it. If nBuf is full, append another.
* This is normally used to add the flag character to a packet.
* Return the current nBuf.
*/
static struct pbuf *pppMPutRaw(u_char c, struct pbuf *nb)
{
struct pbuf *tb = nb;
/* Make sure there is room for the character and an escape code.
* Sure we don't quite fill the buffer if the character doesn't
* get escaped but is one character worth complicating this? */
/* Note: We assume no packet header. */
if (nb && (PBUF_POOL_BUFSIZE - nb->len) < 2) {
tb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL);
if (tb) {
nb->next = tb;
}
#ifdef LINK_STATS
else {
lwip_stats.link.memerr++;
}
#endif /* LINK_STATS */
nb = tb;
}
if (nb) {
*((u_char*)nb->payload + nb->len++) = c;
}
return tb;
}
#endif /* PPP_SUPPORT */

View File

@@ -318,6 +318,9 @@ struct ppp_settings {
char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
};
struct ppp_addrs {
struct ip_addr our_ipaddr, his_ipaddr, netmask, dns1, dns2;
};
/*****************************
*** PUBLIC DATA STRUCTURES ***
@@ -346,7 +349,7 @@ void pppSetAuth(const char *user, const char *passwd);
* Return a new PPP connection descriptor on success or
* an error code (negative) on failure.
*/
int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *arg, int errCode), void *linkStatusArg);
int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx);
/*
* Close a PPP connection and release the descriptor.

View File

@@ -574,6 +574,33 @@ int vj_uncompress_tcp(
/* Remove the compressed header and prepend the uncompressed header. */
pbuf_header(n0, -vjlen);
if(MEM_ALIGN(n0->payload) != n0->payload) {
struct pbuf *np, *q;
u8_t *bufptr;
np = pbuf_alloc(PBUF_RAW, n0->len + cs->cs_hlen, PBUF_POOL);
if(!np) {
PPPDEBUG((LOG_WARNING, "vj_uncompress_tcp: realign failed\n"));
*nb = NULL;
goto bad;
}
pbuf_header(np, -cs->cs_hlen);
bufptr = n0->payload;
for(q = np; q != NULL; q = q->next) {
memcpy(q->payload, bufptr, q->len);
bufptr += q->len;
}
if(n0->next) {
pbuf_chain(np, n0->next);
pbuf_dechain(n0);
}
pbuf_free(n0);
n0 = np;
}
if(pbuf_header(n0, cs->cs_hlen)) {
struct pbuf *np;
@@ -585,8 +612,10 @@ int vj_uncompress_tcp(
goto bad;
}
pbuf_chain(np, n0);
pbuf_free(n0);
n0 = np;
}
LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen);
memcpy(n0->payload, &cs->cs_ip, cs->cs_hlen);
*nb = n0;

View File

@@ -150,6 +150,7 @@ slipif_input( struct netif * netif )
if (q != NULL) {
pbuf_chain(q, p);
pbuf_free(p);
} else {
q = p;
}