mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
Removed timer dependency on sys.c (raw-API). Beautified indentation.
This commit is contained in:
parent
39c35732de
commit
3aea7bc053
@ -40,7 +40,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/sys.h"
|
/* #include "lwip/sys.h" */
|
||||||
#include "lwip/ip.h"
|
#include "lwip/ip.h"
|
||||||
#include "lwip/ip_frag.h"
|
#include "lwip/ip_frag.h"
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
@ -88,18 +88,26 @@ static u8_t ip_reassflags;
|
|||||||
|
|
||||||
static u8_t ip_reasstmr;
|
static u8_t ip_reasstmr;
|
||||||
|
|
||||||
/* Reassembly timer */
|
/**
|
||||||
static void
|
* Reassembly timer base function
|
||||||
ip_reass_timer(void *arg)
|
* for both NO_SYS == 0 and 1 (!).
|
||||||
|
*
|
||||||
|
* Should be called every 1000 msec.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ip_reass_tmr(void)
|
||||||
{
|
{
|
||||||
(void)arg;
|
if (ip_reasstmr > 0) {
|
||||||
if (ip_reasstmr > 1) {
|
|
||||||
ip_reasstmr--;
|
ip_reasstmr--;
|
||||||
sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
|
}
|
||||||
} else if (ip_reasstmr == 1)
|
|
||||||
ip_reasstmr = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reassembles incoming IP fragments into an IP datagram.
|
||||||
|
*
|
||||||
|
* @param p points to a pbuf chain of the fragment
|
||||||
|
* @return NULL if reassembly is incomplete, ? otherwise
|
||||||
|
*/
|
||||||
struct pbuf *
|
struct pbuf *
|
||||||
ip_reass(struct pbuf *p)
|
ip_reass(struct pbuf *p)
|
||||||
{
|
{
|
||||||
@ -119,7 +127,6 @@ ip_reass(struct pbuf *p)
|
|||||||
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n"));
|
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n"));
|
||||||
memcpy(iphdr, fraghdr, IP_HLEN);
|
memcpy(iphdr, fraghdr, IP_HLEN);
|
||||||
ip_reasstmr = IP_REASS_MAXAGE;
|
ip_reasstmr = IP_REASS_MAXAGE;
|
||||||
sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
|
|
||||||
ip_reassflags = 0;
|
ip_reassflags = 0;
|
||||||
/* Clear the bitmap. */
|
/* Clear the bitmap. */
|
||||||
memset(ip_reassbitmap, 0, sizeof(ip_reassbitmap));
|
memset(ip_reassbitmap, 0, sizeof(ip_reassbitmap));
|
||||||
@ -131,7 +138,8 @@ ip_reass(struct pbuf *p)
|
|||||||
if (ip_addr_cmp(&iphdr->src, &fraghdr->src) &&
|
if (ip_addr_cmp(&iphdr->src, &fraghdr->src) &&
|
||||||
ip_addr_cmp(&iphdr->dest, &fraghdr->dest) &&
|
ip_addr_cmp(&iphdr->dest, &fraghdr->dest) &&
|
||||||
IPH_ID(iphdr) == IPH_ID(fraghdr)) {
|
IPH_ID(iphdr) == IPH_ID(fraghdr)) {
|
||||||
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching old packet\n"));
|
LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching previous fragment ID=%"X16_F"\n",
|
||||||
|
ntohs(IPH_ID(fraghdr))));
|
||||||
IPFRAG_STATS_INC(ip_frag.cachehit);
|
IPFRAG_STATS_INC(ip_frag.cachehit);
|
||||||
/* Find out the offset in the reassembly buffer where we should
|
/* Find out the offset in the reassembly buffer where we should
|
||||||
copy the fragment. */
|
copy the fragment. */
|
||||||
@ -144,7 +152,6 @@ ip_reass(struct pbuf *p)
|
|||||||
LWIP_DEBUGF(IP_REASS_DEBUG,
|
LWIP_DEBUGF(IP_REASS_DEBUG,
|
||||||
("ip_reass: fragment outside of buffer (%"S16_F":%"S16_F"/%"S16_F").\n", offset,
|
("ip_reass: fragment outside of buffer (%"S16_F":%"S16_F"/%"S16_F").\n", offset,
|
||||||
offset + len, IP_REASS_BUFSIZE));
|
offset + len, IP_REASS_BUFSIZE));
|
||||||
sys_untimeout(ip_reass_timer, NULL);
|
|
||||||
ip_reasstmr = 0;
|
ip_reasstmr = 0;
|
||||||
goto nullreturn;
|
goto nullreturn;
|
||||||
}
|
}
|
||||||
@ -161,8 +168,7 @@ ip_reass(struct pbuf *p)
|
|||||||
if (offset / (8 * 8) == (offset + len) / (8 * 8)) {
|
if (offset / (8 * 8) == (offset + len) / (8 * 8)) {
|
||||||
LWIP_DEBUGF(IP_REASS_DEBUG,
|
LWIP_DEBUGF(IP_REASS_DEBUG,
|
||||||
("ip_reass: updating single byte in bitmap.\n"));
|
("ip_reass: updating single byte in bitmap.\n"));
|
||||||
/* If the two endpoints are in the same byte, we only update
|
/* If the two endpoints are in the same byte, we only update that byte. */
|
||||||
that byte. */
|
|
||||||
ip_reassbitmap[offset / (8 * 8)] |=
|
ip_reassbitmap[offset / (8 * 8)] |=
|
||||||
bitmap_bits[(offset / 8) & 7] &
|
bitmap_bits[(offset / 8) & 7] &
|
||||||
~bitmap_bits[((offset + len) / 8) & 7];
|
~bitmap_bits[((offset + len) / 8) & 7];
|
||||||
@ -232,7 +238,6 @@ ip_reass(struct pbuf *p)
|
|||||||
/* If we have come this far, we have a full packet in the
|
/* If we have come this far, we have a full packet in the
|
||||||
buffer, so we allocate a pbuf and copy the packet into it. We
|
buffer, so we allocate a pbuf and copy the packet into it. We
|
||||||
also reset the timer. */
|
also reset the timer. */
|
||||||
sys_untimeout(ip_reass_timer, NULL);
|
|
||||||
ip_reasstmr = 0;
|
ip_reasstmr = 0;
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
p = pbuf_alloc(PBUF_LINK, ip_reasslen, PBUF_POOL);
|
p = pbuf_alloc(PBUF_LINK, ip_reasslen, PBUF_POOL);
|
||||||
@ -240,8 +245,7 @@ ip_reass(struct pbuf *p)
|
|||||||
i = 0;
|
i = 0;
|
||||||
for (q = p; q != NULL; q = q->next) {
|
for (q = p; q != NULL; q = q->next) {
|
||||||
/* Copy enough bytes to fill this pbuf in the chain. The
|
/* Copy enough bytes to fill this pbuf in the chain. The
|
||||||
available data in the pbuf is given by the q->len
|
available data in the pbuf is given by the q->len variable. */
|
||||||
variable. */
|
|
||||||
LWIP_DEBUGF(IP_REASS_DEBUG,
|
LWIP_DEBUGF(IP_REASS_DEBUG,
|
||||||
("ip_reass: memcpy from %p (%"S16_F") to %p, %"S16_F" bytes\n",
|
("ip_reass: memcpy from %p (%"S16_F") to %p, %"S16_F" bytes\n",
|
||||||
(void *)&ip_reassbuf[i], i, q->payload,
|
(void *)&ip_reassbuf[i], i, q->payload,
|
||||||
@ -269,9 +273,9 @@ nullreturn:
|
|||||||
static u8_t buf[MEM_ALIGN_SIZE(MAX_MTU)];
|
static u8_t buf[MEM_ALIGN_SIZE(MAX_MTU)];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fragment an IP packet if too large
|
* Fragment an IP datagram if too large for the netif.
|
||||||
*
|
*
|
||||||
* Chop the packet in mtu sized chunks and send them in order
|
* Chop the datagram in MTU sized chunks and send them in order
|
||||||
* by using a fixed size static memory buffer (PBUF_ROM)
|
* by using a fixed size static memory buffer (PBUF_ROM)
|
||||||
*/
|
*/
|
||||||
err_t
|
err_t
|
||||||
|
@ -38,8 +38,9 @@
|
|||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#include "lwip/ip_addr.h"
|
#include "lwip/ip_addr.h"
|
||||||
|
|
||||||
struct pbuf * ip_reass(struct pbuf *);
|
void ip_reass_tmr(void);
|
||||||
err_t ip_frag(struct pbuf *, struct netif *, struct ip_addr *);
|
struct pbuf * ip_reass(struct pbuf *p);
|
||||||
|
err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest);
|
||||||
|
|
||||||
#endif /* __LWIP_IP_FRAG_H__ */
|
#endif /* __LWIP_IP_FRAG_H__ */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user