├── app
├── http.c
└── http2.c
├── lwip
├── api
│ ├── api_lib.c
│ ├── api_msg.c
│ ├── err.c
│ ├── netbuf.c
│ ├── netdb.c
│ ├── netifapi.c
│ ├── sockets.c
│ └── tcpip.c
├── arch
│ ├── queue.c
│ └── sys_arch.c
├── core
│ ├── dhcp.c
│ ├── dns.c
│ ├── init.c
│ ├── ipv4
│ │ ├── autoip.c
│ │ ├── icmp.c
│ │ ├── igmp.c
│ │ ├── inet.c
│ │ ├── inet_chksum.c
│ │ ├── ip.c
│ │ ├── ip_addr.c
│ │ └── ip_frag.c
│ ├── ipv6
│ │ ├── README
│ │ ├── icmp6.c
│ │ ├── inet6.c
│ │ ├── ip6.c
│ │ └── ip6_addr.c
│ ├── mem.c
│ ├── memp.c
│ ├── netif.c
│ ├── pbuf.c
│ ├── raw.c
│ ├── snmp
│ │ ├── asn1_dec.c
│ │ ├── asn1_enc.c
│ │ ├── mib2.c
│ │ ├── mib_structs.c
│ │ ├── msg_in.c
│ │ └── msg_out.c
│ ├── stats.c
│ ├── sys.c
│ ├── tcp.c
│ ├── tcp_in.c
│ ├── tcp_out.c
│ └── udp.c
├── include
│ ├── arch
│ │ ├── cc.h
│ │ ├── perf.h
│ │ ├── queue.h
│ │ └── sys_arch.h
│ ├── ipv4
│ │ └── lwip
│ │ │ ├── autoip.h
│ │ │ ├── icmp.h
│ │ │ ├── igmp.h
│ │ │ ├── inet.h
│ │ │ ├── inet_chksum.h
│ │ │ ├── ip.h
│ │ │ ├── ip_addr.h
│ │ │ └── ip_frag.h
│ ├── ipv6
│ │ └── lwip
│ │ │ ├── icmp.h
│ │ │ ├── inet.h
│ │ │ ├── ip.h
│ │ │ └── ip_addr.h
│ ├── lwip
│ │ ├── api.h
│ │ ├── api_msg.h
│ │ ├── arch.h
│ │ ├── debug.h
│ │ ├── def.h
│ │ ├── dhcp.h
│ │ ├── dns.h
│ │ ├── err.h
│ │ ├── init.h
│ │ ├── mem.h
│ │ ├── memp.h
│ │ ├── memp_std.h
│ │ ├── netbuf.h
│ │ ├── netdb.h
│ │ ├── netif.h
│ │ ├── netifapi.h
│ │ ├── opt.h
│ │ ├── pbuf.h
│ │ ├── raw.h
│ │ ├── sio.h
│ │ ├── snmp.h
│ │ ├── snmp_asn1.h
│ │ ├── snmp_msg.h
│ │ ├── snmp_structs.h
│ │ ├── sockets.h
│ │ ├── stats.h
│ │ ├── sys.h
│ │ ├── tcp.h
│ │ ├── tcpip.h
│ │ └── udp.h
│ ├── lwipopts.h
│ └── netif
│ │ ├── etharp.h
│ │ ├── loopif.h
│ │ ├── ppp_oe.h
│ │ └── slipif.h
└── netif
│ ├── etharp.c
│ ├── ethernetif.c
│ ├── loopif.c
│ ├── ppp
│ ├── auth.c
│ ├── auth.h
│ ├── chap.c
│ ├── chap.h
│ ├── chpms.c
│ ├── chpms.h
│ ├── fsm.c
│ ├── fsm.h
│ ├── ipcp.c
│ ├── ipcp.h
│ ├── lcp.c
│ ├── lcp.h
│ ├── magic.c
│ ├── magic.h
│ ├── md5.c
│ ├── md5.h
│ ├── pap.c
│ ├── pap.h
│ ├── ppp.c
│ ├── ppp.h
│ ├── ppp_oe.c
│ ├── pppdebug.h
│ ├── randm.c
│ ├── randm.h
│ ├── vj.c
│ ├── vj.h
│ └── vjbsdhdr.h
│ └── slipif.c
├── lwipwin32.c
├── lwipwin32.sln
├── lwipwin32.vcproj
└── pcap
├── Include
├── Devioctl.h
├── Gnuc.h
├── Ntddndis.h
├── Ntddpack.h
├── Packet32.h
├── Win32-Extensions.h
├── bittypes.h
├── bucket_lookup.h
├── count_packets.h
├── ip6_misc.h
├── memory_t.h
├── net_tap.h
├── normal_lookup.h
├── pcap-bpf.h
├── pcap-int.h
├── pcap-stdinc.h
├── pcap.h
├── remote-ext.h
├── tcp_session.h
├── time_calls.h
└── tme.h
├── Lib
├── Packet.lib
└── wpcap.lib
└── net_tap.c
/app/http.c:
--------------------------------------------------------------------------------
1 | #include "lwip/tcp.h"
2 | #include "lwip/ip_addr.h"
3 | /* This is the data for the actual web page. */
4 | static char indexdata[] =
5 | "HTTP/1.0 200 OK\r\n\
6 | Content-type: text/html\r\n\
7 | \r\n\
8 | \
9 |
A test page \
10 | \
11 | This is a small test page. \
12 | \
13 | ";
14 |
15 | /* This is the callback function that is called
16 | when a TCP segment has arrived in the connection. */
17 | static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
18 | {
19 | char *rq;
20 | /* If we got a NULL pbuf in p, the remote end has closed
21 | the connection. */
22 | if(p != NULL) {
23 | /* The payload pointer in the pbuf contains the data
24 | in the TCP segment. */
25 | rq = p->payload;
26 | /* Check if the request was an HTTP "GET / HTTP/1.1". */
27 | if(rq[0] == 'G' && rq[1] == 'E' && rq[2] == 'T') {
28 | /* Send the web page to the remote host. A zero
29 | in the last argument means that the data should
30 | not be copied into internal buffers. */
31 | tcp_write(pcb, indexdata, sizeof(indexdata), 0);
32 | }
33 | /* Free the pbuf. */
34 | pbuf_free(p);
35 | }
36 | /* Close the connection. */
37 | tcp_close(pcb);
38 | return ERR_OK;
39 | }
40 |
41 | /* This is the callback function that is called when
42 | a connection has been accepted. */
43 | static err_t http_accept(void *arg, struct tcp_pcb *pcb, err_t err)
44 | {
45 | /* Set up the function http_recv() to be called when data
46 | arrives. */
47 | tcp_recv(pcb, http_recv);
48 | return ERR_OK;
49 | }
50 |
51 | /* The initialization function. */
52 | void http_init(void)
53 | {
54 | struct tcp_pcb *pcb;
55 | /* Create a new TCP PCB. */
56 | pcb = tcp_new();
57 | /* Bind the PCB to TCP port 80. */
58 | tcp_bind(pcb, NULL, 80);
59 | /* Change TCP state to LISTEN. */
60 | pcb = tcp_listen(pcb);
61 | /* Set up http_accet() function to be called
62 | when a new connection arrives. */
63 | tcp_accept(pcb, http_accept);
64 | }
65 |
66 |
--------------------------------------------------------------------------------
/app/http2.c:
--------------------------------------------------------------------------------
1 | #include "lwip/api.h"
2 | #include "lwip/memp.h"
3 |
4 | const static char indexdata[] =
5 | " \
6 | A test page \
7 | \
8 | This is a small test page. \
9 | \
10 | ";
11 | const static char http_html_hdr[] =
12 | "HTTP/1.0 200 OK\r\n\
13 | Content-type: text/html\r\n\r\n";
14 |
15 | static void process_connection(struct netconn *conn)
16 | {
17 | struct netbuf *inbuf;
18 | char *rq;
19 | u16_t len;
20 |
21 | inbuf = netconn_recv(conn);
22 | netbuf_data(inbuf, &rq, &len);
23 | /* HTTP "GET /\r\n" */
24 | if(rq[0] == 'G' && rq[1] == 'E' && rq[2] == 'T') {
25 | netconn_write(conn, http_html_hdr, sizeof(http_html_hdr),
26 | NETCONN_NOCOPY);
27 | netconn_write(conn, indexdata, sizeof(indexdata),
28 | NETCONN_NOCOPY);
29 | netconn_close(conn);
30 | }
31 | memp_free(MEMP_NETBUF, inbuf);
32 | }
33 |
34 | void http_task()
35 | {
36 | struct netconn *conn, *newconn;
37 | conn = netconn_new(NETCONN_TCP);
38 | netconn_bind(conn, NULL, 80);
39 | netconn_listen(conn);
40 |
41 | while(1) {
42 | newconn = netconn_accept(conn);
43 | process_connection(newconn);
44 | if (newconn == NULL)
45 | continue;
46 | netconn_delete(newconn);
47 | }
48 | }
49 |
50 |
--------------------------------------------------------------------------------
/lwip/api/err.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Error Management module
4 | *
5 | */
6 |
7 | /*
8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9 | * All rights reserved.
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | *
14 | * 1. Redistributions of source code must retain the above copyright notice,
15 | * this list of conditions and the following disclaimer.
16 | * 2. Redistributions in binary form must reproduce the above copyright notice,
17 | * this list of conditions and the following disclaimer in the documentation
18 | * and/or other materials provided with the distribution.
19 | * 3. The name of the author may not be used to endorse or promote products
20 | * derived from this software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 | * OF SUCH DAMAGE.
32 | *
33 | * This file is part of the lwIP TCP/IP stack.
34 | *
35 | * Author: Adam Dunkels
36 | *
37 | */
38 |
39 | #include "lwip/err.h"
40 |
41 | #ifdef LWIP_DEBUG
42 |
43 | static const char *err_strerr[] = {
44 | "Ok.", /* ERR_OK 0 */
45 | "Out of memory error.", /* ERR_MEM -1 */
46 | "Buffer error.", /* ERR_BUF -2 */
47 | "Timeout.", /* ERR_TIMEOUT -3 */
48 | "Routing problem.", /* ERR_RTE -4 */
49 | "Connection aborted.", /* ERR_ABRT -5 */
50 | "Connection reset.", /* ERR_RST -6 */
51 | "Connection closed.", /* ERR_CLSD -7 */
52 | "Not connected.", /* ERR_CONN -8 */
53 | "Illegal value.", /* ERR_VAL -9 */
54 | "Illegal argument.", /* ERR_ARG -10 */
55 | "Address in use.", /* ERR_USE -11 */
56 | "Low-level netif error.", /* ERR_IF -12 */
57 | "Already connected.", /* ERR_ISCONN -13 */
58 | "Operation in progress." /* ERR_INPROGRESS -14 */
59 | };
60 |
61 | /**
62 | * Convert an lwip internal error to a string representation.
63 | *
64 | * @param err an lwip internal err_t
65 | * @return a string representation for err
66 | */
67 | const char *
68 | lwip_strerr(err_t err)
69 | {
70 | return err_strerr[-err];
71 |
72 | }
73 |
74 | #endif /* LWIP_DEBUG */
75 |
--------------------------------------------------------------------------------
/lwip/api/netifapi.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Network Interface Sequential API module
4 | *
5 | */
6 |
7 | /*
8 | * Redistribution and use in source and binary forms, with or without modification,
9 | * are permitted provided that the following conditions are met:
10 | *
11 | * 1. Redistributions of source code must retain the above copyright notice,
12 | * this list of conditions and the following disclaimer.
13 | * 2. Redistributions in binary form must reproduce the above copyright notice,
14 | * this list of conditions and the following disclaimer in the documentation
15 | * and/or other materials provided with the distribution.
16 | * 3. The name of the author may not be used to endorse or promote products
17 | * derived from this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
20 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
22 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
28 | * OF SUCH DAMAGE.
29 | *
30 | * This file is part of the lwIP TCP/IP stack.
31 | *
32 | */
33 |
34 | #include "lwip/opt.h"
35 |
36 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
37 |
38 | #include "lwip/netifapi.h"
39 | #include "lwip/tcpip.h"
40 |
41 | /**
42 | * Call netif_add() inside the tcpip_thread context.
43 | */
44 | void
45 | do_netifapi_netif_add( struct netifapi_msg_msg *msg)
46 | {
47 | if (!netif_add( msg->netif,
48 | msg->msg.add.ipaddr,
49 | msg->msg.add.netmask,
50 | msg->msg.add.gw,
51 | msg->msg.add.state,
52 | msg->msg.add.init,
53 | msg->msg.add.input)) {
54 | msg->err = ERR_IF;
55 | } else {
56 | msg->err = ERR_OK;
57 | }
58 | TCPIP_NETIFAPI_ACK(msg);
59 | }
60 |
61 | /**
62 | * Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
63 | * tcpip_thread context.
64 | */
65 | void
66 | do_netifapi_netif_common( struct netifapi_msg_msg *msg)
67 | {
68 | if (msg->msg.common.errtfunc!=NULL) {
69 | msg->err =
70 | msg->msg.common.errtfunc(msg->netif);
71 | } else {
72 | msg->err = ERR_OK;
73 | msg->msg.common.voidfunc(msg->netif);
74 | }
75 | TCPIP_NETIFAPI_ACK(msg);
76 | }
77 |
78 | /**
79 | * Call netif_add() in a thread-safe way by running that function inside the
80 | * tcpip_thread context.
81 | *
82 | * @note for params @see netif_add()
83 | */
84 | err_t
85 | netifapi_netif_add(struct netif *netif,
86 | struct ip_addr *ipaddr,
87 | struct ip_addr *netmask,
88 | struct ip_addr *gw,
89 | void *state,
90 | err_t (* init)(struct netif *netif),
91 | err_t (* input)(struct pbuf *p, struct netif *netif))
92 | {
93 | struct netifapi_msg msg;
94 | msg.function = do_netifapi_netif_add;
95 | msg.msg.netif = netif;
96 | msg.msg.msg.add.ipaddr = ipaddr;
97 | msg.msg.msg.add.netmask = netmask;
98 | msg.msg.msg.add.gw = gw;
99 | msg.msg.msg.add.state = state;
100 | msg.msg.msg.add.init = init;
101 | msg.msg.msg.add.input = input;
102 | TCPIP_NETIFAPI(&msg);
103 | return msg.msg.err;
104 | }
105 |
106 | /**
107 | * call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
108 | * way by running that function inside the tcpip_thread context.
109 | *
110 | * @note use only for functions where there is only "netif" parameter.
111 | */
112 | err_t
113 | netifapi_netif_common( struct netif *netif,
114 | void (* voidfunc)(struct netif *netif),
115 | err_t (* errtfunc)(struct netif *netif) )
116 | {
117 | struct netifapi_msg msg;
118 | msg.function = do_netifapi_netif_common;
119 | msg.msg.netif = netif;
120 | msg.msg.msg.common.voidfunc = voidfunc;
121 | msg.msg.msg.common.errtfunc = errtfunc;
122 | TCPIP_NETIFAPI(&msg);
123 | return msg.msg.err;
124 | }
125 |
126 | #endif /* LWIP_NETIF_API */
127 |
--------------------------------------------------------------------------------
/lwip/arch/queue.c:
--------------------------------------------------------------------------------
1 | #include "lwip/mem.h"
2 | #include "arch/sys_arch.h"
3 | #include "arch/queue.h"
4 |
5 | void queue_push(queue_t* q, void* msg)
6 | {
7 | queue_node_t* node;
8 | SYS_ARCH_DECL_PROTECT(old_level);
9 |
10 | node = (queue_node_t *)mem_malloc(sizeof(queue_node_t));
11 | node->msg = msg;
12 | node->next = NULL;
13 |
14 | SYS_ARCH_PROTECT(old_level);
15 | if (q->head == NULL)
16 | {
17 | q->head = q->tail = node;
18 | sys_sem_signal(q->sem);
19 | }
20 | else
21 | {
22 | q->tail->next = node;
23 | q->tail = node;
24 | }
25 | q->enqueue += 1;
26 | SYS_ARCH_UNPROTECT(old_level);
27 | }
28 |
29 | void* queue_pop(queue_t* q, u32_t timeout)
30 | {
31 | void* msg;
32 | queue_node_t* node;
33 | SYS_ARCH_DECL_PROTECT(old_level);
34 |
35 | if (q->head == NULL)
36 | {
37 | if (SYS_ARCH_TIMEOUT == sys_arch_sem_wait(q->sem, timeout) || q->head == NULL)
38 | return NULL;
39 | }
40 |
41 | node = q->head;
42 | msg = node->msg;
43 |
44 | SYS_ARCH_PROTECT(old_level);
45 | q->head = node->next;
46 | if (q->head == NULL) q->tail = q->head;
47 | q->dequeue += 1;
48 | mem_free(node);
49 | SYS_ARCH_UNPROTECT(old_level);
50 |
51 | node = NULL;
52 | return msg;
53 | }
54 |
55 | queue_t* queue_create()
56 | {
57 | queue_t* q;
58 | q = (queue_t *)mem_malloc(sizeof(queue_t));
59 | q->head = q->tail = NULL;
60 | q->enqueue = q->dequeue = 0;
61 | q->sem = sys_sem_new(0);
62 | return q;
63 | }
64 |
65 | void queue_free(queue_t* q)
66 | {
67 | queue_node_t* node;
68 | queue_node_t* next;
69 | SYS_ARCH_DECL_PROTECT(old_level);
70 |
71 | node = q->head;
72 |
73 | SYS_ARCH_PROTECT(old_level);
74 | while(node != NULL)
75 | {
76 | next = node->next;
77 | mem_free(node);
78 | node = next;
79 | }
80 | sys_sem_free(q->sem);
81 | mem_free(q);
82 | q = NULL;
83 | SYS_ARCH_UNPROTECT(old_level);
84 | }
85 |
86 |
--------------------------------------------------------------------------------
/lwip/arch/sys_arch.c:
--------------------------------------------------------------------------------
1 | #define WIN32_LEAN_AND_MEAN
2 | #include
3 | #include
4 | #include
5 |
6 | #include "lwip/def.h"
7 | #include "lwip/sys.h"
8 | #include "lwip/mem.h"
9 |
10 | #include "arch/sys_arch.h"
11 | #include "arch/queue.h"
12 |
13 | static struct sys_timeouts lwip_timeouts[LWIP_TASK_MAX + 1];
14 |
15 | void sys_init(void)
16 | {
17 | u8_t i;
18 | for(i = 0; i < sizeof(lwip_timeouts) / sizeof(struct sys_timeouts); i++)
19 | lwip_timeouts[i].next = NULL;
20 | }
21 |
22 | /*----------------------------------------------------------------------*/
23 | sys_sem_t sys_sem_new(u8_t count)
24 | {
25 | sys_sem_t sem = CreateSemaphore(NULL, count, MAXLONG, NULL);
26 |
27 | if (sem == INVALID_HANDLE_VALUE)
28 | {
29 | fprintf(stderr, "CreateSemaphore error: %d\n", GetLastError());
30 | return SYS_SEM_NULL;
31 | }
32 | return sem;
33 | }
34 |
35 | /*----------------------------------------------------------------------*/
36 | void sys_sem_free(sys_sem_t sem)
37 | {
38 | CloseHandle(sem);
39 | }
40 |
41 | /*----------------------------------------------------------------------*/
42 | void sys_sem_signal(sys_sem_t sem)
43 | {
44 | if (!ReleaseSemaphore(sem, 1, NULL))
45 | {
46 | fprintf(stderr, "ReleaseSemaphore error: %d\n", GetLastError());
47 | }
48 | }
49 |
50 |
51 | /*----------------------------------------------------------------------*/
52 | u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout)
53 | {
54 | DWORD dwWaitResult = WaitForSingleObject(sem, (timeout != 0) ? timeout : INFINITE);
55 | switch (dwWaitResult)
56 | {
57 | case WAIT_OBJECT_0:
58 | return ERR_OK;
59 | case WAIT_ABANDONED:
60 | case WAIT_TIMEOUT:
61 | default:
62 | return SYS_ARCH_TIMEOUT;
63 | }
64 | }
65 |
66 |
67 | /*----------------------------------------------------------------------*/
68 | sys_mbox_t sys_mbox_new(int size)
69 | {
70 | return queue_create();
71 | }
72 |
73 | /*----------------------------------------------------------------------*/
74 | void sys_mbox_free(sys_mbox_t mbox)
75 | {
76 | queue_free(mbox);
77 | }
78 |
79 | /*----------------------------------------------------------------------*/
80 | void sys_mbox_post(sys_mbox_t mbox, void *msg)
81 | {
82 | sys_mbox_trypost(mbox, msg);
83 | }
84 |
85 | err_t sys_mbox_trypost(sys_mbox_t mbox, void *msg)
86 | {
87 | queue_push(mbox, msg);
88 | return ERR_OK;
89 | }
90 |
91 | /*----------------------------------------------------------------------*/
92 | u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout)
93 | {
94 | *msg = queue_pop(mbox, timeout);
95 | if (*msg == NULL)
96 | return SYS_ARCH_TIMEOUT;
97 | return 0;
98 | }
99 |
100 | u32_t sys_arch_mbox_tryfetch(sys_mbox_t mbox, void **msg)
101 | {
102 | return sys_arch_mbox_fetch(mbox, msg, 0);
103 | }
104 |
105 | /*----------------------------------------------------------------------*/
106 | struct sys_timeouts * sys_arch_timeouts(void)
107 | {
108 | u8_t prio = GetThreadPriority(GetCurrentThread());
109 | u8_t offset = prio - LWIP_START_PRIO;
110 | if (prio == THREAD_PRIORITY_ERROR_RETURN)
111 | {
112 | fprintf(stderr, "CreateThread failed with %d.\n", GetLastError());
113 | return &lwip_timeouts[LWIP_TASK_MAX];
114 | }
115 | if (offset >= 0 && offset < LWIP_TASK_MAX)
116 | return &lwip_timeouts[offset];
117 | return &lwip_timeouts[LWIP_TASK_MAX];
118 | }
119 |
120 |
121 | /*------------------------------------------------------------------------*/
122 | sys_thread_t sys_thread_new(char *name, void (* thread)(void *arg), void *arg, int stacksize, int prio)
123 | {
124 | sys_thread_t t = (sys_thread_t)_beginthreadex(
125 | NULL, // security attributes
126 | stacksize, // stack size
127 | (LPTHREAD_START_ROUTINE)thread, // thread function name
128 | arg, // argument to thread function
129 | 0, // creation flags
130 | NULL); // returns the thread identifier
131 |
132 | if (t == NULL)
133 | {
134 | fprintf(stderr, "CreateThread failed with %d.\n", GetLastError());
135 | ExitProcess(3);
136 | }
137 | if (!SetThreadPriority(t, prio))
138 | fprintf(stderr, "SetThreadPriority failed with %d\n", GetLastError());
139 |
140 | return t;
141 | }
--------------------------------------------------------------------------------
/lwip/core/ipv4/ip_addr.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * This is the IPv4 address tools implementation.
4 | *
5 | */
6 |
7 | /*
8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9 | * All rights reserved.
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | *
14 | * 1. Redistributions of source code must retain the above copyright notice,
15 | * this list of conditions and the following disclaimer.
16 | * 2. Redistributions in binary form must reproduce the above copyright notice,
17 | * this list of conditions and the following disclaimer in the documentation
18 | * and/or other materials provided with the distribution.
19 | * 3. The name of the author may not be used to endorse or promote products
20 | * derived from this software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 | * OF SUCH DAMAGE.
32 | *
33 | * This file is part of the lwIP TCP/IP stack.
34 | *
35 | * Author: Adam Dunkels
36 | *
37 | */
38 |
39 | #include "lwip/opt.h"
40 | #include "lwip/ip_addr.h"
41 | #include "lwip/inet.h"
42 | #include "lwip/netif.h"
43 |
44 | #define IP_ADDR_ANY_VALUE 0x00000000UL
45 | #define IP_ADDR_BROADCAST_VALUE 0xffffffffUL
46 |
47 | /* used by IP_ADDR_ANY and IP_ADDR_BROADCAST in ip_addr.h */
48 | const struct ip_addr ip_addr_any = { IP_ADDR_ANY_VALUE };
49 | const struct ip_addr ip_addr_broadcast = { IP_ADDR_BROADCAST_VALUE };
50 |
51 | /**
52 | * Determine if an address is a broadcast address on a network interface
53 | *
54 | * @param addr address to be checked
55 | * @param netif the network interface against which the address is checked
56 | * @return returns non-zero if the address is a broadcast address
57 | */
58 | u8_t ip_addr_isbroadcast(struct ip_addr *addr, struct netif *netif)
59 | {
60 | u32_t addr2test;
61 |
62 | addr2test = addr->addr;
63 | /* all ones (broadcast) or all zeroes (old skool broadcast) */
64 | if ((~addr2test == IP_ADDR_ANY_VALUE) ||
65 | (addr2test == IP_ADDR_ANY_VALUE))
66 | return 1;
67 | /* no broadcast support on this network interface? */
68 | else if ((netif->flags & NETIF_FLAG_BROADCAST) == 0)
69 | /* the given address cannot be a broadcast address
70 | * nor can we check against any broadcast addresses */
71 | return 0;
72 | /* address matches network interface address exactly? => no broadcast */
73 | else if (addr2test == netif->ip_addr.addr)
74 | return 0;
75 | /* on the same (sub) network... */
76 | else if (ip_addr_netcmp(addr, &(netif->ip_addr), &(netif->netmask))
77 | /* ...and host identifier bits are all ones? =>... */
78 | && ((addr2test & ~netif->netmask.addr) ==
79 | (IP_ADDR_BROADCAST_VALUE & ~netif->netmask.addr)))
80 | /* => network broadcast address */
81 | return 1;
82 | else
83 | return 0;
84 | }
85 |
--------------------------------------------------------------------------------
/lwip/core/ipv6/README:
--------------------------------------------------------------------------------
1 | IPv6 support in lwIP is very experimental.
2 |
--------------------------------------------------------------------------------
/lwip/core/ipv6/inet6.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Functions common to all TCP/IPv6 modules, such as the Internet checksum and the
4 | * byte order functions.
5 | *
6 | */
7 |
8 | /*
9 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
10 | * All rights reserved.
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice,
16 | * this list of conditions and the following disclaimer.
17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
18 | * this list of conditions and the following disclaimer in the documentation
19 | * and/or other materials provided with the distribution.
20 | * 3. The name of the author may not be used to endorse or promote products
21 | * derived from this software without specific prior written permission.
22 | *
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 | * OF SUCH DAMAGE.
33 | *
34 | * This file is part of the lwIP TCP/IP stack.
35 | *
36 | * Author: Adam Dunkels
37 | *
38 | */
39 |
40 | #include "lwip/opt.h"
41 |
42 | #include "lwip/def.h"
43 | #include "lwip/inet.h"
44 |
45 | /* chksum:
46 | *
47 | * Sums up all 16 bit words in a memory portion. Also includes any odd byte.
48 | * This function is used by the other checksum functions.
49 | *
50 | * For now, this is not optimized. Must be optimized for the particular processor
51 | * arcitecture on which it is to run. Preferebly coded in assembler.
52 | */
53 |
54 | static u32_t
55 | chksum(void *dataptr, u16_t len)
56 | {
57 | u16_t *sdataptr = dataptr;
58 | u32_t acc;
59 |
60 |
61 | for(acc = 0; len > 1; len -= 2) {
62 | acc += *sdataptr++;
63 | }
64 |
65 | /* add up any odd byte */
66 | if (len == 1) {
67 | acc += htons((u16_t)(*(u8_t *)dataptr) << 8);
68 | }
69 |
70 | return acc;
71 |
72 | }
73 |
74 | /* inet_chksum_pseudo:
75 | *
76 | * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain.
77 | */
78 |
79 | u16_t
80 | inet_chksum_pseudo(struct pbuf *p,
81 | struct ip_addr *src, struct ip_addr *dest,
82 | u8_t proto, u32_t proto_len)
83 | {
84 | u32_t acc;
85 | struct pbuf *q;
86 | u8_t swapped, i;
87 |
88 | acc = 0;
89 | swapped = 0;
90 | for(q = p; q != NULL; q = q->next) {
91 | acc += chksum(q->payload, q->len);
92 | while (acc >> 16) {
93 | acc = (acc & 0xffff) + (acc >> 16);
94 | }
95 | if (q->len % 2 != 0) {
96 | swapped = 1 - swapped;
97 | acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
98 | }
99 | }
100 |
101 | if (swapped) {
102 | acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
103 | }
104 |
105 | for(i = 0; i < 8; i++) {
106 | acc += ((u16_t *)src->addr)[i] & 0xffff;
107 | acc += ((u16_t *)dest->addr)[i] & 0xffff;
108 | while (acc >> 16) {
109 | acc = (acc & 0xffff) + (acc >> 16);
110 | }
111 | }
112 | acc += (u16_t)htons((u16_t)proto);
113 | acc += ((u16_t *)&proto_len)[0] & 0xffff;
114 | acc += ((u16_t *)&proto_len)[1] & 0xffff;
115 |
116 | while (acc >> 16) {
117 | acc = (acc & 0xffff) + (acc >> 16);
118 | }
119 | return ~(acc & 0xffff);
120 | }
121 |
122 | /* inet_chksum:
123 | *
124 | * Calculates the Internet checksum over a portion of memory. Used primarely for IP
125 | * and ICMP.
126 | */
127 |
128 | u16_t
129 | inet_chksum(void *dataptr, u16_t len)
130 | {
131 | u32_t acc, sum;
132 |
133 | acc = chksum(dataptr, len);
134 | sum = (acc & 0xffff) + (acc >> 16);
135 | sum += (sum >> 16);
136 | return ~(sum & 0xffff);
137 | }
138 |
139 | u16_t
140 | inet_chksum_pbuf(struct pbuf *p)
141 | {
142 | u32_t acc;
143 | struct pbuf *q;
144 | u8_t swapped;
145 |
146 | acc = 0;
147 | swapped = 0;
148 | for(q = p; q != NULL; q = q->next) {
149 | acc += chksum(q->payload, q->len);
150 | while (acc >> 16) {
151 | acc = (acc & 0xffff) + (acc >> 16);
152 | }
153 | if (q->len % 2 != 0) {
154 | swapped = 1 - swapped;
155 | acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8);
156 | }
157 | }
158 |
159 | if (swapped) {
160 | acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8);
161 | }
162 | return ~(acc & 0xffff);
163 | }
164 |
--------------------------------------------------------------------------------
/lwip/core/ipv6/ip6_addr.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 |
33 | #include "lwip/opt.h"
34 | #include "lwip/ip_addr.h"
35 | #include "lwip/inet.h"
36 |
37 | u8_t
38 | ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2,
39 | struct ip_addr *mask)
40 | {
41 | return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) &&
42 | (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) &&
43 | (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) &&
44 | (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3]));
45 |
46 | }
47 |
48 | u8_t
49 | ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2)
50 | {
51 | return(addr1->addr[0] == addr2->addr[0] &&
52 | addr1->addr[1] == addr2->addr[1] &&
53 | addr1->addr[2] == addr2->addr[2] &&
54 | addr1->addr[3] == addr2->addr[3]);
55 | }
56 |
57 | void
58 | ip_addr_set(struct ip_addr *dest, struct ip_addr *src)
59 | {
60 | SMEMCPY(dest, src, sizeof(struct ip_addr));
61 | /* dest->addr[0] = src->addr[0];
62 | dest->addr[1] = src->addr[1];
63 | dest->addr[2] = src->addr[2];
64 | dest->addr[3] = src->addr[3];*/
65 | }
66 |
67 | u8_t
68 | ip_addr_isany(struct ip_addr *addr)
69 | {
70 | if (addr == NULL) return 1;
71 | return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0);
72 | }
73 |
--------------------------------------------------------------------------------
/lwip/include/arch/cc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the lwIP TCP/IP stack.
30 | *
31 | * Author: Adam Dunkels
32 | *
33 | * $Id: cc.h,v 1.2 2005/01/09 13:58:06 millin Exp $
34 | */
35 | #ifndef __CC_H__
36 | #define __CC_H__
37 |
38 | #include "stdio.h"
39 | #include "stdlib.h"
40 |
41 | typedef unsigned char u8_t;
42 | typedef signed char s8_t;
43 | typedef unsigned short u16_t;
44 | typedef signed short s16_t;
45 | typedef unsigned int u32_t;
46 | typedef signed int s32_t;
47 |
48 | typedef u32_t mem_ptr_t;
49 |
50 | #define BYTE_ORDER LITTLE_ENDIAN
51 |
52 | #define PACK_STRUCT_FIELD(x) x//; #pragma STRUCT_ALIGN(x,1)
53 | #define PACK_STRUCT_STRUCT
54 | #define PACK_STRUCT_BEGIN
55 | #define PACK_STRUCT_END
56 |
57 | #ifndef LWIP_PLATFORM_DIAG
58 | #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0)
59 | #endif
60 |
61 | #ifndef LWIP_PLATFORM_ASSERT
62 | #define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", x, __LINE__, __FILE__); fflush(NULL); abort();} while(0)
63 | #endif
64 |
65 | #define U16_F "u"
66 | #define U32_F "u"
67 | #define S16_F "d"
68 | #define S32_F "d"
69 | #define X16_F "X"
70 | #define X32_F "X"
71 |
72 | #endif /* __CC_H__ */
73 |
74 |
--------------------------------------------------------------------------------
/lwip/include/arch/perf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the lwIP TCP/IP stack.
30 | *
31 | * Author: Adam Dunkels
32 | *
33 | * $Id: perf.h,v 1.1 2005/01/02 19:44:56 millin Exp $
34 | */
35 | #ifndef __PERF_H__
36 | #define __PERF_H__
37 |
38 | #define PERF_START /* null definition */
39 | #define PERF_STOP(x) /* null definition */
40 |
41 | #endif /* __PERF_H__ */
42 |
--------------------------------------------------------------------------------
/lwip/include/arch/queue.h:
--------------------------------------------------------------------------------
1 | #ifndef __QUEUE_H__
2 | #define __QUEUE_H__
3 |
4 | #include "lwip/sys.h"
5 |
6 | typedef struct queue_node
7 | {
8 | void* msg;
9 | struct queue_node* next;
10 | } queue_node_t;
11 |
12 | typedef struct queue
13 | {
14 | struct queue_node* head;
15 | struct queue_node* tail;
16 | u32_t enqueue; // enqueue counter
17 | u32_t dequeue; // dequeue counter
18 | sys_sem_t sem; // semaphore for dequeue
19 | } queue_t;
20 |
21 | void queue_push(queue_t* q, void* msg);
22 | void* queue_pop(queue_t* q, u32_t timeout);
23 | queue_t* queue_create();
24 | void queue_free(queue_t* q);
25 |
26 | #endif
--------------------------------------------------------------------------------
/lwip/include/arch/sys_arch.h:
--------------------------------------------------------------------------------
1 | #ifndef __SYS_ARCH_H__
2 | #define __SYS_ARCH_H__
3 |
4 | #define WIN32_LEAN_AND_MEAN
5 | #include
6 |
7 | #define LWIP_STK_SIZE 4096
8 |
9 | #define LWIP_TASK_MAX 5 //max number of lwip tasks
10 | #define LWIP_START_PRIO -1 //first prio of lwip tasks
11 |
12 | typedef HANDLE sys_sem_t;
13 | typedef struct queue *sys_mbox_t;
14 | typedef HANDLE sys_thread_t;
15 |
16 | #define SYS_MBOX_NULL (sys_mbox_t)0
17 | #define SYS_SEM_NULL (sys_sem_t)0
18 |
19 | /* Global Critical Region Protection */
20 | CRITICAL_SECTION gCriticalSection;
21 |
22 | #define SYS_ARCH_DECL_PROTECT(x)
23 | #define SYS_ARCH_PROTECT(x) EnterCriticalSection(&gCriticalSection)
24 | #define SYS_ARCH_UNPROTECT(x) LeaveCriticalSection(&gCriticalSection)
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/lwip/include/ipv4/lwip/autoip.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | *
4 | * AutoIP Automatic LinkLocal IP Configuration
5 | */
6 |
7 | /*
8 | *
9 | * Copyright (c) 2007 Dominik Spies
10 | * All rights reserved.
11 | *
12 | * Redistribution and use in source and binary forms, with or without modification,
13 | * are permitted provided that the following conditions are met:
14 | *
15 | * 1. Redistributions of source code must retain the above copyright notice,
16 | * this list of conditions and the following disclaimer.
17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
18 | * this list of conditions and the following disclaimer in the documentation
19 | * and/or other materials provided with the distribution.
20 | * 3. The name of the author may not be used to endorse or promote products
21 | * derived from this software without specific prior written permission.
22 | *
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
24 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
26 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
28 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
31 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32 | * OF SUCH DAMAGE.
33 | *
34 | * Author: Dominik Spies
35 | *
36 | * This is a AutoIP implementation for the lwIP TCP/IP stack. It aims to conform
37 | * with RFC 3927.
38 | *
39 | *
40 | * Please coordinate changes and requests with Dominik Spies
41 | *
42 | */
43 |
44 | #ifndef __LWIP_AUTOIP_H__
45 | #define __LWIP_AUTOIP_H__
46 |
47 | #include "lwip/opt.h"
48 |
49 | #if LWIP_AUTOIP /* don't build if not configured for use in lwipopts.h */
50 |
51 | #include "lwip/netif.h"
52 | #include "lwip/udp.h"
53 | #include "netif/etharp.h"
54 |
55 | /* AutoIP Timing */
56 | #define AUTOIP_TMR_INTERVAL 100
57 | #define AUTOIP_TICKS_PER_SECOND (1000 / AUTOIP_TMR_INTERVAL)
58 |
59 | /* RFC 3927 Constants */
60 | #define PROBE_WAIT 1 /* second (initial random delay) */
61 | #define PROBE_MIN 1 /* second (minimum delay till repeated probe) */
62 | #define PROBE_MAX 2 /* seconds (maximum delay till repeated probe) */
63 | #define PROBE_NUM 3 /* (number of probe packets) */
64 | #define ANNOUNCE_NUM 2 /* (number of announcement packets) */
65 | #define ANNOUNCE_INTERVAL 2 /* seconds (time between announcement packets) */
66 | #define ANNOUNCE_WAIT 2 /* seconds (delay before announcing) */
67 | #define MAX_CONFLICTS 10 /* (max conflicts before rate limiting) */
68 | #define RATE_LIMIT_INTERVAL 60 /* seconds (delay between successive attempts) */
69 | #define DEFEND_INTERVAL 10 /* seconds (min. wait between defensive ARPs) */
70 |
71 | /* AutoIP client states */
72 | #define AUTOIP_STATE_OFF 0
73 | #define AUTOIP_STATE_PROBING 1
74 | #define AUTOIP_STATE_ANNOUNCING 2
75 | #define AUTOIP_STATE_BOUND 3
76 |
77 | struct autoip
78 | {
79 | struct ip_addr llipaddr; /* the currently selected, probed, announced or used LL IP-Address */
80 | u8_t state; /* current AutoIP state machine state */
81 | u8_t sent_num; /* sent number of probes or announces, dependent on state */
82 | u16_t ttw; /* ticks to wait, tick is AUTOIP_TMR_INTERVAL long */
83 | u8_t lastconflict; /* ticks until a conflict can be solved by defending */
84 | u8_t tried_llipaddr; /* total number of probed/used Link Local IP-Addresses */
85 | };
86 |
87 |
88 | /** Init srand, has to be called before entering mainloop */
89 | void autoip_init(void);
90 |
91 | /** Start AutoIP client */
92 | err_t autoip_start(struct netif *netif);
93 |
94 | /** Stop AutoIP client */
95 | err_t autoip_stop(struct netif *netif);
96 |
97 | /** Handles every incoming ARP Packet, called by etharp_arp_input */
98 | void autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr);
99 |
100 | /** Has to be called in loop every AUTOIP_TMR_INTERVAL milliseconds */
101 | void autoip_tmr(void);
102 |
103 | #endif /* LWIP_AUTOIP */
104 |
105 | #endif /* __LWIP_AUTOIP_H__ */
106 |
--------------------------------------------------------------------------------
/lwip/include/ipv4/lwip/icmp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_ICMP_H__
33 | #define __LWIP_ICMP_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
38 |
39 | #include "lwip/pbuf.h"
40 | #include "lwip/ip_addr.h"
41 | #include "lwip/netif.h"
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | #define ICMP_ER 0 /* echo reply */
48 | #define ICMP_DUR 3 /* destination unreachable */
49 | #define ICMP_SQ 4 /* source quench */
50 | #define ICMP_RD 5 /* redirect */
51 | #define ICMP_ECHO 8 /* echo */
52 | #define ICMP_TE 11 /* time exceeded */
53 | #define ICMP_PP 12 /* parameter problem */
54 | #define ICMP_TS 13 /* timestamp */
55 | #define ICMP_TSR 14 /* timestamp reply */
56 | #define ICMP_IRQ 15 /* information request */
57 | #define ICMP_IR 16 /* information reply */
58 |
59 | enum icmp_dur_type {
60 | ICMP_DUR_NET = 0, /* net unreachable */
61 | ICMP_DUR_HOST = 1, /* host unreachable */
62 | ICMP_DUR_PROTO = 2, /* protocol unreachable */
63 | ICMP_DUR_PORT = 3, /* port unreachable */
64 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
65 | ICMP_DUR_SR = 5 /* source route failed */
66 | };
67 |
68 | enum icmp_te_type {
69 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */
70 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
71 | };
72 |
73 | void icmp_input(struct pbuf *p, struct netif *inp);
74 |
75 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
76 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
77 |
78 | #ifdef PACK_STRUCT_USE_INCLUDES
79 | # include "arch/bpstruct.h"
80 | #endif
81 | /** This is the standard ICMP header only that the u32_t data
82 | * is splitted to two u16_t like ICMP echo needs it.
83 | * This header is also used for other ICMP types that do not
84 | * use the data part.
85 | */
86 | PACK_STRUCT_BEGIN
87 | struct icmp_echo_hdr {
88 | PACK_STRUCT_FIELD(u8_t type);
89 | PACK_STRUCT_FIELD(u8_t code);
90 | PACK_STRUCT_FIELD(u16_t chksum);
91 | PACK_STRUCT_FIELD(u16_t id);
92 | PACK_STRUCT_FIELD(u16_t seqno);
93 | } PACK_STRUCT_STRUCT;
94 | PACK_STRUCT_END
95 | #ifdef PACK_STRUCT_USE_INCLUDES
96 | # include "arch/epstruct.h"
97 | #endif
98 |
99 | #define ICMPH_TYPE(hdr) ((hdr)->type)
100 | #define ICMPH_CODE(hdr) ((hdr)->code)
101 |
102 | /** Combines type and code to an u16_t */
103 | #define ICMPH_TYPE_SET(hdr, t) ((hdr)->type = (t))
104 | #define ICMPH_CODE_SET(hdr, c) ((hdr)->code = (c))
105 |
106 | #ifdef __cplusplus
107 | }
108 | #endif
109 |
110 | #endif /* LWIP_ICMP */
111 |
112 | #endif /* __LWIP_ICMP_H__ */
113 |
--------------------------------------------------------------------------------
/lwip/include/ipv4/lwip/inet.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_INET_H__
33 | #define __LWIP_INET_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | /* For compatibility with BSD code */
42 | struct in_addr {
43 | u32_t s_addr;
44 | };
45 |
46 | #define INADDR_NONE ((u32_t)0xffffffffUL) /* 255.255.255.255 */
47 | #define INADDR_LOOPBACK ((u32_t)0x7f000001UL) /* 127.0.0.1 */
48 | #define INADDR_ANY ((u32_t)0x00000000UL) /* 0.0.0.0 */
49 | #define INADDR_BROADCAST ((u32_t)0xffffffffUL) /* 255.255.255.255 */
50 |
51 | u32_t inet_addr(const char *cp);
52 | int inet_aton(const char *cp, struct in_addr *addr);
53 | char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */
54 |
55 | #ifdef htons
56 | #undef htons
57 | #endif /* htons */
58 | #ifdef htonl
59 | #undef htonl
60 | #endif /* htonl */
61 | #ifdef ntohs
62 | #undef ntohs
63 | #endif /* ntohs */
64 | #ifdef ntohl
65 | #undef ntohl
66 | #endif /* ntohl */
67 |
68 | #ifndef LWIP_PLATFORM_BYTESWAP
69 | #define LWIP_PLATFORM_BYTESWAP 0
70 | #endif
71 |
72 | #if BYTE_ORDER == BIG_ENDIAN
73 | #define htons(x) (x)
74 | #define ntohs(x) (x)
75 | #define htonl(x) (x)
76 | #define ntohl(x) (x)
77 | #else /* BYTE_ORDER != BIG_ENDIAN */
78 | #ifdef LWIP_PREFIX_BYTEORDER_FUNCS
79 | /* workaround for naming collisions on some platforms */
80 | #define htons lwip_htons
81 | #define ntohs lwip_ntohs
82 | #define htonl lwip_htonl
83 | #define ntohl lwip_ntohl
84 | #endif /* LWIP_PREFIX_BYTEORDER_FUNCS */
85 | #if LWIP_PLATFORM_BYTESWAP
86 | #define htons(x) LWIP_PLATFORM_HTONS(x)
87 | #define ntohs(x) LWIP_PLATFORM_HTONS(x)
88 | #define htonl(x) LWIP_PLATFORM_HTONL(x)
89 | #define ntohl(x) LWIP_PLATFORM_HTONL(x)
90 | #else /* LWIP_PLATFORM_BYTESWAP */
91 | u16_t htons(u16_t x);
92 | u16_t ntohs(u16_t x);
93 | u32_t htonl(u32_t x);
94 | u32_t ntohl(u32_t x);
95 | #endif /* LWIP_PLATFORM_BYTESWAP */
96 |
97 | #endif /* BYTE_ORDER == BIG_ENDIAN */
98 |
99 | #ifdef __cplusplus
100 | }
101 | #endif
102 |
103 | #endif /* __LWIP_INET_H__ */
104 |
--------------------------------------------------------------------------------
/lwip/include/ipv4/lwip/inet_chksum.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_INET_CHKSUM_H__
33 | #define __LWIP_INET_CHKSUM_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #include "lwip/pbuf.h"
38 | #include "lwip/ip_addr.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | u16_t inet_chksum(void *dataptr, u16_t len);
45 | u16_t inet_chksum_pbuf(struct pbuf *p);
46 | u16_t inet_chksum_pseudo(struct pbuf *p,
47 | struct ip_addr *src, struct ip_addr *dest,
48 | u8_t proto, u16_t proto_len);
49 | #if LWIP_UDPLITE
50 | u16_t inet_chksum_pseudo_partial(struct pbuf *p,
51 | struct ip_addr *src, struct ip_addr *dest,
52 | u8_t proto, u16_t proto_len, u16_t chksum_len);
53 | #endif
54 |
55 | #ifdef __cplusplus
56 | }
57 | #endif
58 |
59 | #endif /* __LWIP_INET_H__ */
60 |
61 |
--------------------------------------------------------------------------------
/lwip/include/ipv4/lwip/ip_frag.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Jani Monoses
30 | *
31 | */
32 |
33 | #ifndef __LWIP_IP_FRAG_H__
34 | #define __LWIP_IP_FRAG_H__
35 |
36 | #include "lwip/opt.h"
37 | #include "lwip/err.h"
38 | #include "lwip/pbuf.h"
39 | #include "lwip/netif.h"
40 | #include "lwip/ip_addr.h"
41 | #include "lwip/ip.h"
42 |
43 | #ifdef __cplusplus
44 | extern "C" {
45 | #endif
46 |
47 | #if IP_REASSEMBLY
48 | /* The IP reassembly timer interval in milliseconds. */
49 | #define IP_TMR_INTERVAL 1000
50 |
51 | /* IP reassembly helper struct.
52 | * This is exported because memp needs to know the size.
53 | */
54 | struct ip_reassdata {
55 | struct ip_reassdata *next;
56 | struct pbuf *p;
57 | struct ip_hdr iphdr;
58 | u16_t datagram_len;
59 | u8_t flags;
60 | u8_t timer;
61 | };
62 |
63 | void ip_reass_init(void);
64 | void ip_reass_tmr(void);
65 | struct pbuf * ip_reass(struct pbuf *p);
66 | #endif /* IP_REASSEMBLY */
67 |
68 | #if IP_FRAG
69 | err_t ip_frag(struct pbuf *p, struct netif *netif, struct ip_addr *dest);
70 | #endif /* IP_FRAG */
71 |
72 | #ifdef __cplusplus
73 | }
74 | #endif
75 |
76 | #endif /* __LWIP_IP_FRAG_H__ */
77 |
--------------------------------------------------------------------------------
/lwip/include/ipv6/lwip/icmp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_ICMP_H__
33 | #define __LWIP_ICMP_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #if LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
38 |
39 | #include "lwip/pbuf.h"
40 | #include "lwip/netif.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | #define ICMP6_DUR 1
47 | #define ICMP6_TE 3
48 | #define ICMP6_ECHO 128 /* echo */
49 | #define ICMP6_ER 129 /* echo reply */
50 |
51 |
52 | enum icmp_dur_type {
53 | ICMP_DUR_NET = 0, /* net unreachable */
54 | ICMP_DUR_HOST = 1, /* host unreachable */
55 | ICMP_DUR_PROTO = 2, /* protocol unreachable */
56 | ICMP_DUR_PORT = 3, /* port unreachable */
57 | ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */
58 | ICMP_DUR_SR = 5 /* source route failed */
59 | };
60 |
61 | enum icmp_te_type {
62 | ICMP_TE_TTL = 0, /* time to live exceeded in transit */
63 | ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */
64 | };
65 |
66 | void icmp_input(struct pbuf *p, struct netif *inp);
67 |
68 | void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
69 | void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
70 |
71 | struct icmp_echo_hdr {
72 | u8_t type;
73 | u8_t icode;
74 | u16_t chksum;
75 | u16_t id;
76 | u16_t seqno;
77 | };
78 |
79 | struct icmp_dur_hdr {
80 | u8_t type;
81 | u8_t icode;
82 | u16_t chksum;
83 | u32_t unused;
84 | };
85 |
86 | struct icmp_te_hdr {
87 | u8_t type;
88 | u8_t icode;
89 | u16_t chksum;
90 | u32_t unused;
91 | };
92 |
93 | #ifdef __cplusplus
94 | }
95 | #endif
96 |
97 | #endif /* LWIP_ICMP */
98 |
99 | #endif /* __LWIP_ICMP_H__ */
100 |
101 |
--------------------------------------------------------------------------------
/lwip/include/ipv6/lwip/inet.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_INET_H__
33 | #define __LWIP_INET_H__
34 |
35 | #include "lwip/opt.h"
36 | #include "lwip/pbuf.h"
37 | #include "lwip/ip_addr.h"
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | u16_t inet_chksum(void *data, u16_t len);
44 | u16_t inet_chksum_pbuf(struct pbuf *p);
45 | u16_t inet_chksum_pseudo(struct pbuf *p,
46 | struct ip_addr *src, struct ip_addr *dest,
47 | u8_t proto, u32_t proto_len);
48 |
49 | u32_t inet_addr(const char *cp);
50 | s8_t inet_aton(const char *cp, struct in_addr *addr);
51 |
52 | #ifndef _MACHINE_ENDIAN_H_
53 | #ifndef _NETINET_IN_H
54 | #ifndef _LINUX_BYTEORDER_GENERIC_H
55 | u16_t htons(u16_t n);
56 | u16_t ntohs(u16_t n);
57 | u32_t htonl(u32_t n);
58 | u32_t ntohl(u32_t n);
59 | #endif /* _LINUX_BYTEORDER_GENERIC_H */
60 | #endif /* _NETINET_IN_H */
61 | #endif /* _MACHINE_ENDIAN_H_ */
62 |
63 | #ifdef __cplusplus
64 | }
65 | #endif
66 |
67 | #endif /* __LWIP_INET_H__ */
68 |
69 |
--------------------------------------------------------------------------------
/lwip/include/ipv6/lwip/ip.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_IP_H__
33 | #define __LWIP_IP_H__
34 |
35 | #include "lwip/opt.h"
36 | #include "lwip/def.h"
37 | #include "lwip/pbuf.h"
38 | #include "lwip/ip_addr.h"
39 |
40 | #include "lwip/err.h"
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | #define IP_HLEN 40
47 |
48 | #define IP_PROTO_ICMP 58
49 | #define IP_PROTO_UDP 17
50 | #define IP_PROTO_UDPLITE 136
51 | #define IP_PROTO_TCP 6
52 |
53 | /* This is passed as the destination address to ip_output_if (not
54 | to ip_output), meaning that an IP header already is constructed
55 | in the pbuf. This is used when TCP retransmits. */
56 | #ifdef IP_HDRINCL
57 | #undef IP_HDRINCL
58 | #endif /* IP_HDRINCL */
59 | #define IP_HDRINCL NULL
60 |
61 | #if LWIP_NETIF_HWADDRHINT
62 | #define IP_PCB_ADDRHINT ;u8_t addr_hint
63 | #else
64 | #define IP_PCB_ADDRHINT
65 | #endif /* LWIP_NETIF_HWADDRHINT */
66 |
67 | /* This is the common part of all PCB types. It needs to be at the
68 | beginning of a PCB type definition. It is located here so that
69 | changes to this common part are made in one location instead of
70 | having to change all PCB structs. */
71 | #define IP_PCB struct ip_addr local_ip; \
72 | struct ip_addr remote_ip; \
73 | /* Socket options */ \
74 | u16_t so_options; \
75 | /* Type Of Service */ \
76 | u8_t tos; \
77 | /* Time To Live */ \
78 | u8_t ttl; \
79 | /* link layer address resolution hint */ \
80 | IP_PCB_ADDRHINT
81 |
82 |
83 | /* The IPv6 header. */
84 | struct ip_hdr {
85 | #if BYTE_ORDER == LITTLE_ENDIAN
86 | u8_t tclass1:4, v:4;
87 | u8_t flow1:4, tclass2:4;
88 | #else
89 | u8_t v:4, tclass1:4;
90 | u8_t tclass2:8, flow1:4;
91 | #endif
92 | u16_t flow2;
93 | u16_t len; /* payload length */
94 | u8_t nexthdr; /* next header */
95 | u8_t hoplim; /* hop limit (TTL) */
96 | struct ip_addr src, dest; /* source and destination IP addresses */
97 | };
98 |
99 | #define IPH_PROTO(hdr) (iphdr->nexthdr)
100 |
101 | void ip_init(void);
102 |
103 | #include "lwip/netif.h"
104 |
105 | struct netif *ip_route(struct ip_addr *dest);
106 |
107 | void ip_input(struct pbuf *p, struct netif *inp);
108 |
109 | /* source and destination addresses in network byte order, please */
110 | err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
111 | u8_t ttl, u8_t proto);
112 |
113 | err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
114 | u8_t ttl, u8_t proto,
115 | struct netif *netif);
116 |
117 | #define ip_current_netif() NULL
118 | #define ip_current_header() NULL
119 |
120 | #if IP_DEBUG
121 | void ip_debug_print(struct pbuf *p);
122 | #endif /* IP_DEBUG */
123 |
124 | #ifdef __cplusplus
125 | }
126 | #endif
127 |
128 | #endif /* __LWIP_IP_H__ */
129 |
130 |
131 |
--------------------------------------------------------------------------------
/lwip/include/ipv6/lwip/ip_addr.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_IP_ADDR_H__
33 | #define __LWIP_IP_ADDR_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | #define IP_ADDR_ANY 0
42 |
43 | #ifdef PACK_STRUCT_USE_INCLUDES
44 | # include "arch/bpstruct.h"
45 | #endif
46 | PACK_STRUCT_BEGIN
47 | struct ip_addr {
48 | PACK_STRUCT_FIELD(u32_t addr[4]);
49 | } PACK_STRUCT_STRUCT;
50 | PACK_STRUCT_END
51 | #ifdef PACK_STRUCT_USE_INCLUDES
52 | # include "arch/epstruct.h"
53 | #endif
54 |
55 | /*
56 | * struct ipaddr2 is used in the definition of the ARP packet format in
57 | * order to support compilers that don't have structure packing.
58 | */
59 | #ifdef PACK_STRUCT_USE_INCLUDES
60 | # include "arch/bpstruct.h"
61 | #endif
62 | PACK_STRUCT_BEGIN
63 | struct ip_addr2 {
64 | PACK_STRUCT_FIELD(u16_t addrw[2]);
65 | } PACK_STRUCT_STRUCT;
66 | PACK_STRUCT_END
67 | #ifdef PACK_STRUCT_USE_INCLUDES
68 | # include "arch/epstruct.h"
69 | #endif
70 |
71 | #define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)((a & 0xffff) << 16) | (b & 0xffff)); \
72 | (ipaddr)->addr[1] = htonl(((c & 0xffff) << 16) | (d & 0xffff)); \
73 | (ipaddr)->addr[2] = htonl(((e & 0xffff) << 16) | (f & 0xffff)); \
74 | (ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0)
75 |
76 | u8_t ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2,
77 | struct ip_addr *mask);
78 | u8_t ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2);
79 | void ip_addr_set(struct ip_addr *dest, struct ip_addr *src);
80 | u8_t ip_addr_isany(struct ip_addr *addr);
81 |
82 | #define ip_addr_debug_print(debug, ipaddr) \
83 | LWIP_DEBUGF(debug, ("%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F":%"X32_F"\n", \
84 | (ntohl(ipaddr->addr[0]) >> 16) & 0xffff, \
85 | ntohl(ipaddr->addr[0]) & 0xffff, \
86 | (ntohl(ipaddr->addr[1]) >> 16) & 0xffff, \
87 | ntohl(ipaddr->addr[1]) & 0xffff, \
88 | (ntohl(ipaddr->addr[2]) >> 16) & 0xffff, \
89 | ntohl(ipaddr->addr[2]) & 0xffff, \
90 | (ntohl(ipaddr->addr[3]) >> 16) & 0xffff, \
91 | ntohl(ipaddr->addr[3]) & 0xffff));
92 |
93 | #ifdef __cplusplus
94 | }
95 | #endif
96 |
97 | #endif /* __LWIP_IP_ADDR_H__ */
98 |
--------------------------------------------------------------------------------
/lwip/include/lwip/debug.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_DEBUG_H__
33 | #define __LWIP_DEBUG_H__
34 |
35 | #include "lwip/arch.h"
36 |
37 | /** lower two bits indicate debug level
38 | * - 0 off
39 | * - 1 warning
40 | * - 2 serious
41 | * - 3 severe
42 | */
43 | #define LWIP_DBG_LEVEL_OFF 0x00
44 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */
45 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */
46 | #define LWIP_DBG_LEVEL_SEVERE 0x03
47 | #define LWIP_DBG_MASK_LEVEL 0x03
48 |
49 | /** flag for LWIP_DEBUGF to enable that debug message */
50 | #define LWIP_DBG_ON 0x80U
51 | /** flag for LWIP_DEBUGF to disable that debug message */
52 | #define LWIP_DBG_OFF 0x00U
53 |
54 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
55 | #define LWIP_DBG_TRACE 0x40U
56 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
57 | #define LWIP_DBG_STATE 0x20U
58 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
59 | #define LWIP_DBG_FRESH 0x10U
60 | /** flag for LWIP_DEBUGF to halt after printing this debug message */
61 | #define LWIP_DBG_HALT 0x08U
62 |
63 | #ifndef LWIP_NOASSERT
64 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
65 | LWIP_PLATFORM_ASSERT(message); } while(0)
66 | #else /* LWIP_NOASSERT */
67 | #define LWIP_ASSERT(message, assertion)
68 | #endif /* LWIP_NOASSERT */
69 |
70 | /** if "expression" isn't true, then print "message" and execute "handler" expression */
71 | #ifndef LWIP_ERROR
72 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \
73 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0)
74 | #endif /* LWIP_ERROR */
75 |
76 | #ifdef LWIP_DEBUG
77 | /** print debug message only if debug message type is enabled...
78 | * AND is of correct type AND is at least LWIP_DBG_LEVEL
79 | */
80 | #define LWIP_DEBUGF(debug, message) do { \
81 | if ( \
82 | ((debug) & LWIP_DBG_ON) && \
83 | ((debug) & LWIP_DBG_TYPES_ON) && \
84 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
85 | LWIP_PLATFORM_DIAG(message); \
86 | if ((debug) & LWIP_DBG_HALT) { \
87 | while(1); \
88 | } \
89 | } \
90 | } while(0)
91 |
92 | #else /* LWIP_DEBUG */
93 | #define LWIP_DEBUGF(debug, message)
94 | #endif /* LWIP_DEBUG */
95 |
96 | #endif /* __LWIP_DEBUG_H__ */
97 |
98 |
--------------------------------------------------------------------------------
/lwip/include/lwip/def.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_DEF_H__
33 | #define __LWIP_DEF_H__
34 |
35 | /* this might define NULL already */
36 | #include "lwip/arch.h"
37 |
38 | #define LWIP_MAX(x , y) (((x) > (y)) ? (x) : (y))
39 | #define LWIP_MIN(x , y) (((x) < (y)) ? (x) : (y))
40 |
41 | #ifndef NULL
42 | #define NULL ((void *)0)
43 | #endif
44 |
45 |
46 | #endif /* __LWIP_DEF_H__ */
47 |
48 |
--------------------------------------------------------------------------------
/lwip/include/lwip/dns.h:
--------------------------------------------------------------------------------
1 | /**
2 | * lwip DNS resolver header file.
3 |
4 | * Author: Jim Pettinato
5 | * April 2007
6 |
7 | * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels.
8 | *
9 | * Redistribution and use in source and binary forms, with or without
10 | * modification, are permitted provided that the following conditions
11 | * are met:
12 | * 1. Redistributions of source code must retain the above copyright
13 | * notice, this list of conditions and the following disclaimer.
14 | * 2. Redistributions in binary form must reproduce the above copyright
15 | * notice, this list of conditions and the following disclaimer in the
16 | * documentation and/or other materials provided with the distribution.
17 | * 3. The name of the author may not be used to endorse or promote
18 | * products derived from this software without specific prior
19 | * written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
22 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 | */
33 |
34 | #ifndef __LWIP_DNS_H__
35 | #define __LWIP_DNS_H__
36 |
37 | #include "lwip/opt.h"
38 |
39 | #if LWIP_DNS /* don't build if not configured for use in lwipopts.h */
40 |
41 | /** DNS timer period */
42 | #define DNS_TMR_INTERVAL 1000
43 |
44 | /** DNS field TYPE used for "Resource Records" */
45 | #define DNS_RRTYPE_A 1 /* a host address */
46 | #define DNS_RRTYPE_NS 2 /* an authoritative name server */
47 | #define DNS_RRTYPE_MD 3 /* a mail destination (Obsolete - use MX) */
48 | #define DNS_RRTYPE_MF 4 /* a mail forwarder (Obsolete - use MX) */
49 | #define DNS_RRTYPE_CNAME 5 /* the canonical name for an alias */
50 | #define DNS_RRTYPE_SOA 6 /* marks the start of a zone of authority */
51 | #define DNS_RRTYPE_MB 7 /* a mailbox domain name (EXPERIMENTAL) */
52 | #define DNS_RRTYPE_MG 8 /* a mail group member (EXPERIMENTAL) */
53 | #define DNS_RRTYPE_MR 9 /* a mail rename domain name (EXPERIMENTAL) */
54 | #define DNS_RRTYPE_NULL 10 /* a null RR (EXPERIMENTAL) */
55 | #define DNS_RRTYPE_WKS 11 /* a well known service description */
56 | #define DNS_RRTYPE_PTR 12 /* a domain name pointer */
57 | #define DNS_RRTYPE_HINFO 13 /* host information */
58 | #define DNS_RRTYPE_MINFO 14 /* mailbox or mail list information */
59 | #define DNS_RRTYPE_MX 15 /* mail exchange */
60 | #define DNS_RRTYPE_TXT 16 /* text strings */
61 |
62 | /** DNS field CLASS used for "Resource Records" */
63 | #define DNS_RRCLASS_IN 1 /* the Internet */
64 | #define DNS_RRCLASS_CS 2 /* the CSNET class (Obsolete - used only for examples in some obsolete RFCs) */
65 | #define DNS_RRCLASS_CH 3 /* the CHAOS class */
66 | #define DNS_RRCLASS_HS 4 /* Hesiod [Dyer 87] */
67 | #define DNS_RRCLASS_FLUSH 0x800 /* Flush bit */
68 |
69 | /** Callback which is invoked when a hostname is found.
70 | * A function of this type must be implemented by the application using the DNS resolver.
71 | * @param name pointer to the name that was looked up.
72 | * @param ipaddr pointer to a struct ip_addr containing the IP address of the hostname,
73 | * or NULL if the name could not be found (or on any other error).
74 | * @param callback_arg a user-specified callback argument passed to dns_gethostbyname
75 | */
76 | typedef void (*dns_found_callback)(const char *name, struct ip_addr *ipaddr, void *callback_arg);
77 |
78 |
79 | void dns_init(void);
80 |
81 | void dns_tmr(void);
82 |
83 | void dns_setserver(u8_t numdns, struct ip_addr *dnsserver);
84 |
85 | struct ip_addr dns_getserver(u8_t numdns);
86 |
87 | err_t dns_gethostbyname(const char *hostname, struct ip_addr *addr,
88 | dns_found_callback found, void *callback_arg);
89 |
90 | #if DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC
91 | int dns_local_removehost(const char *hostname, const struct ip_addr *addr);
92 | err_t dns_local_addhost(const char *hostname, const struct ip_addr *addr);
93 | #endif /* DNS_LOCAL_HOSTLIST && DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
94 |
95 | #endif /* LWIP_DNS */
96 |
97 | #endif /* __LWIP_DNS_H__ */
98 |
--------------------------------------------------------------------------------
/lwip/include/lwip/err.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_ERR_H__
33 | #define __LWIP_ERR_H__
34 |
35 | #include "lwip/opt.h"
36 | #include "lwip/arch.h"
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | /** Define LWIP_ERR_T in cc.h if you want to use
43 | * a different type for your platform (must be signed). */
44 | #ifdef LWIP_ERR_T
45 | typedef LWIP_ERR_T err_t;
46 | #else /* LWIP_ERR_T */
47 | typedef s8_t err_t;
48 | #endif /* LWIP_ERR_T*/
49 |
50 | /* Definitions for error constants. */
51 |
52 | #define ERR_OK 0 /* No error, everything OK. */
53 | #define ERR_MEM -1 /* Out of memory error. */
54 | #define ERR_BUF -2 /* Buffer error. */
55 | #define ERR_TIMEOUT -3 /* Timeout. */
56 | #define ERR_RTE -4 /* Routing problem. */
57 |
58 | #define ERR_IS_FATAL(e) ((e) < ERR_RTE)
59 |
60 | #define ERR_ABRT -5 /* Connection aborted. */
61 | #define ERR_RST -6 /* Connection reset. */
62 | #define ERR_CLSD -7 /* Connection closed. */
63 | #define ERR_CONN -8 /* Not connected. */
64 |
65 | #define ERR_VAL -9 /* Illegal value. */
66 |
67 | #define ERR_ARG -10 /* Illegal argument. */
68 |
69 | #define ERR_USE -11 /* Address in use. */
70 |
71 | #define ERR_IF -12 /* Low-level netif error */
72 | #define ERR_ISCONN -13 /* Already connected. */
73 |
74 | #define ERR_INPROGRESS -14 /* Operation in progress */
75 |
76 |
77 | #ifdef LWIP_DEBUG
78 | extern const char *lwip_strerr(err_t err);
79 | #else
80 | #define lwip_strerr(x) ""
81 | #endif /* LWIP_DEBUG */
82 |
83 | #ifdef __cplusplus
84 | }
85 | #endif
86 |
87 | #endif /* __LWIP_ERR_H__ */
88 |
--------------------------------------------------------------------------------
/lwip/include/lwip/init.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_INIT_H__
33 | #define __LWIP_INIT_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | /** X.x.x: Major version of the stack */
42 | #define LWIP_VERSION_MAJOR 1U
43 | /** x.X.x: Minor version of the stack */
44 | #define LWIP_VERSION_MINOR 3U
45 | /** x.x.X: Revision of the stack */
46 | #define LWIP_VERSION_REVISION 1U
47 | /** For release candidates, this is set to 1..254
48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE)
49 | * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */
50 | #define LWIP_VERSION_RC 255U
51 |
52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
53 | #define LWIP_RC_RELEASE 255U
54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */
55 | #define LWIP_RC_DEVELOPMENT 0U
56 |
57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE)
58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT)
59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT))
60 |
61 | /** Provides the version of the stack */
62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \
63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC)
64 |
65 | /* Modules initialization */
66 | void lwip_init(void);
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 | #endif /* __LWIP_INIT_H__ */
73 |
--------------------------------------------------------------------------------
/lwip/include/lwip/mem.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_MEM_H__
33 | #define __LWIP_MEM_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | #if MEM_LIBC_MALLOC
42 |
43 | #include /* for size_t */
44 |
45 | typedef size_t mem_size_t;
46 |
47 | /* aliases for C library malloc() */
48 | #define mem_init()
49 | /* in case C library malloc() needs extra protection,
50 | * allow these defines to be overridden.
51 | */
52 | #ifndef mem_free
53 | #define mem_free free
54 | #endif
55 | #ifndef mem_malloc
56 | #define mem_malloc malloc
57 | #endif
58 | #ifndef mem_calloc
59 | #define mem_calloc calloc
60 | #endif
61 | #ifndef mem_realloc
62 | static void *mem_realloc(void *mem, mem_size_t size)
63 | {
64 | LWIP_UNUSED_ARG(size);
65 | return mem;
66 | }
67 | #endif
68 | #else /* MEM_LIBC_MALLOC */
69 |
70 | /* MEM_SIZE would have to be aligned, but using 64000 here instead of
71 | * 65535 leaves some room for alignment...
72 | */
73 | #if MEM_SIZE > 64000l
74 | typedef u32_t mem_size_t;
75 | #else
76 | typedef u16_t mem_size_t;
77 | #endif /* MEM_SIZE > 64000 */
78 |
79 | #if MEM_USE_POOLS
80 | /** mem_init is not used when using pools instead of a heap */
81 | #define mem_init()
82 | /** mem_realloc is not used when using pools instead of a heap:
83 | we can't free part of a pool element and don't want to copy the rest */
84 | #define mem_realloc(mem, size) (mem)
85 | #else /* MEM_USE_POOLS */
86 | /* lwIP alternative malloc */
87 | void mem_init(void);
88 | void *mem_realloc(void *mem, mem_size_t size);
89 | #endif /* MEM_USE_POOLS */
90 | void *mem_malloc(mem_size_t size);
91 | void *mem_calloc(mem_size_t count, mem_size_t size);
92 | void mem_free(void *mem);
93 | #endif /* MEM_LIBC_MALLOC */
94 |
95 | #ifndef LWIP_MEM_ALIGN_SIZE
96 | #define LWIP_MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1))
97 | #endif
98 |
99 | #ifndef LWIP_MEM_ALIGN
100 | #define LWIP_MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1)))
101 | #endif
102 |
103 | #ifdef __cplusplus
104 | }
105 | #endif
106 |
107 | #endif /* __LWIP_MEM_H__ */
108 |
--------------------------------------------------------------------------------
/lwip/include/lwip/memp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 |
33 | #ifndef __LWIP_MEMP_H__
34 | #define __LWIP_MEMP_H__
35 |
36 | #include "lwip/opt.h"
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | /* Create the list of all memory pools managed by memp. MEMP_MAX represents a NULL pool at the end */
43 | typedef enum {
44 | #define LWIP_MEMPOOL(name,num,size,desc) MEMP_##name,
45 | #include "lwip/memp_std.h"
46 | MEMP_MAX
47 | } memp_t;
48 |
49 | #if MEM_USE_POOLS
50 | /* Use a helper type to get the start and end of the user "memory pools" for mem_malloc */
51 | typedef enum {
52 | /* Get the first (via:
53 | MEMP_POOL_HELPER_START = ((u8_t) 1*MEMP_POOL_A + 0*MEMP_POOL_B + 0*MEMP_POOL_C + 0)*/
54 | MEMP_POOL_HELPER_FIRST = ((u8_t)
55 | #define LWIP_MEMPOOL(name,num,size,desc)
56 | #define LWIP_MALLOC_MEMPOOL_START 1
57 | #define LWIP_MALLOC_MEMPOOL(num, size) * MEMP_POOL_##size + 0
58 | #define LWIP_MALLOC_MEMPOOL_END
59 | #include "lwip/memp_std.h"
60 | ) ,
61 | /* Get the last (via:
62 | MEMP_POOL_HELPER_END = ((u8_t) 0 + MEMP_POOL_A*0 + MEMP_POOL_B*0 + MEMP_POOL_C*1) */
63 | MEMP_POOL_HELPER_LAST = ((u8_t)
64 | #define LWIP_MEMPOOL(name,num,size,desc)
65 | #define LWIP_MALLOC_MEMPOOL_START
66 | #define LWIP_MALLOC_MEMPOOL(num, size) 0 + MEMP_POOL_##size *
67 | #define LWIP_MALLOC_MEMPOOL_END 1
68 | #include "lwip/memp_std.h"
69 | )
70 | } memp_pool_helper_t;
71 |
72 | /* The actual start and stop values are here (cast them over)
73 | We use this helper type and these defines so we can avoid using const memp_t values */
74 | #define MEMP_POOL_FIRST ((memp_t) MEMP_POOL_HELPER_FIRST)
75 | #define MEMP_POOL_LAST ((memp_t) MEMP_POOL_HELPER_LAST)
76 | #endif /* MEM_USE_POOLS */
77 |
78 | #if MEMP_MEM_MALLOC || MEM_USE_POOLS
79 | extern const u16_t memp_sizes[MEMP_MAX];
80 | #endif /* MEMP_MEM_MALLOC || MEM_USE_POOLS */
81 |
82 | #if MEMP_MEM_MALLOC
83 |
84 | #include "mem.h"
85 |
86 | #define memp_init()
87 | #define memp_malloc(type) mem_malloc(memp_sizes[type])
88 | #define memp_free(type, mem) mem_free(mem)
89 |
90 | #else /* MEMP_MEM_MALLOC */
91 |
92 | #if MEM_USE_POOLS
93 | /** This structure is used to save the pool one element came from. */
94 | struct memp_malloc_helper
95 | {
96 | memp_t poolnr;
97 | };
98 | #endif /* MEM_USE_POOLS */
99 |
100 | void memp_init(void);
101 |
102 | #if MEMP_OVERFLOW_CHECK
103 | void *memp_malloc_fn(memp_t type, const char* file, const int line);
104 | #define memp_malloc(t) memp_malloc_fn((t), __FILE__, __LINE__)
105 | #else
106 | void *memp_malloc(memp_t type);
107 | #endif
108 | void memp_free(memp_t type, void *mem);
109 |
110 | #endif /* MEMP_MEM_MALLOC */
111 |
112 | #ifdef __cplusplus
113 | }
114 | #endif
115 |
116 | #endif /* __LWIP_MEMP_H__ */
117 |
--------------------------------------------------------------------------------
/lwip/include/lwip/memp_std.h:
--------------------------------------------------------------------------------
1 | /*
2 | * SETUP: Make sure we define everything we will need.
3 | *
4 | * We have create three types of pools:
5 | * 1) MEMPOOL - standard pools
6 | * 2) MALLOC_MEMPOOL - to be used by mem_malloc in mem.c
7 | * 3) PBUF_MEMPOOL - a mempool of pbuf's, so include space for the pbuf struct
8 | *
9 | * If the include'r doesn't require any special treatment of each of the types
10 | * above, then will declare #2 & #3 to be just standard mempools.
11 | */
12 | #ifndef LWIP_MALLOC_MEMPOOL
13 | /* This treats "malloc pools" just like any other pool.
14 | The pools are a little bigger to provide 'size' as the amount of user data. */
15 | #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size)
16 | #define LWIP_MALLOC_MEMPOOL_START
17 | #define LWIP_MALLOC_MEMPOOL_END
18 | #endif /* LWIP_MALLOC_MEMPOOL */
19 |
20 | #ifndef LWIP_PBUF_MEMPOOL
21 | /* This treats "pbuf pools" just like any other pool.
22 | * Allocates buffers for a pbuf struct AND a payload size */
23 | #define LWIP_PBUF_MEMPOOL(name, num, payload, desc) LWIP_MEMPOOL(name, num, (MEMP_ALIGN_SIZE(sizeof(struct pbuf)) + MEMP_ALIGN_SIZE(payload)), desc)
24 | #endif /* LWIP_PBUF_MEMPOOL */
25 |
26 |
27 | /*
28 | * A list of internal pools used by LWIP.
29 | *
30 | * LWIP_MEMPOOL(pool_name, number_elements, element_size, pool_description)
31 | * creates a pool name MEMP_pool_name. description is used in stats.c
32 | */
33 | #if LWIP_RAW
34 | LWIP_MEMPOOL(RAW_PCB, MEMP_NUM_RAW_PCB, sizeof(struct raw_pcb), "RAW_PCB")
35 | #endif /* LWIP_RAW */
36 |
37 | #if LWIP_UDP
38 | LWIP_MEMPOOL(UDP_PCB, MEMP_NUM_UDP_PCB, sizeof(struct udp_pcb), "UDP_PCB")
39 | #endif /* LWIP_UDP */
40 |
41 | #if LWIP_TCP
42 | LWIP_MEMPOOL(TCP_PCB, MEMP_NUM_TCP_PCB, sizeof(struct tcp_pcb), "TCP_PCB")
43 | LWIP_MEMPOOL(TCP_PCB_LISTEN, MEMP_NUM_TCP_PCB_LISTEN, sizeof(struct tcp_pcb_listen), "TCP_PCB_LISTEN")
44 | LWIP_MEMPOOL(TCP_SEG, MEMP_NUM_TCP_SEG, sizeof(struct tcp_seg), "TCP_SEG")
45 | #endif /* LWIP_TCP */
46 |
47 | #if IP_REASSEMBLY
48 | LWIP_MEMPOOL(REASSDATA, MEMP_NUM_REASSDATA, sizeof(struct ip_reassdata), "REASSDATA")
49 | #endif /* IP_REASSEMBLY */
50 |
51 | #if LWIP_NETCONN
52 | LWIP_MEMPOOL(NETBUF, MEMP_NUM_NETBUF, sizeof(struct netbuf), "NETBUF")
53 | LWIP_MEMPOOL(NETCONN, MEMP_NUM_NETCONN, sizeof(struct netconn), "NETCONN")
54 | #endif /* LWIP_NETCONN */
55 |
56 | #if NO_SYS==0
57 | LWIP_MEMPOOL(TCPIP_MSG_API, MEMP_NUM_TCPIP_MSG_API, sizeof(struct tcpip_msg), "TCPIP_MSG_API")
58 | LWIP_MEMPOOL(TCPIP_MSG_INPKT,MEMP_NUM_TCPIP_MSG_INPKT, sizeof(struct tcpip_msg), "TCPIP_MSG_INPKT")
59 | #endif /* NO_SYS==0 */
60 |
61 | #if ARP_QUEUEING
62 | LWIP_MEMPOOL(ARP_QUEUE, MEMP_NUM_ARP_QUEUE, sizeof(struct etharp_q_entry), "ARP_QUEUE")
63 | #endif /* ARP_QUEUEING */
64 |
65 | #if LWIP_IGMP
66 | LWIP_MEMPOOL(IGMP_GROUP, MEMP_NUM_IGMP_GROUP, sizeof(struct igmp_group), "IGMP_GROUP")
67 | #endif /* LWIP_IGMP */
68 |
69 | #if NO_SYS==0
70 | LWIP_MEMPOOL(SYS_TIMEOUT, MEMP_NUM_SYS_TIMEOUT, sizeof(struct sys_timeo), "SYS_TIMEOUT")
71 | #endif /* NO_SYS==0 */
72 |
73 |
74 | /*
75 | * A list of pools of pbuf's used by LWIP.
76 | *
77 | * LWIP_PBUF_MEMPOOL(pool_name, number_elements, pbuf_payload_size, pool_description)
78 | * creates a pool name MEMP_pool_name. description is used in stats.c
79 | * This allocates enough space for the pbuf struct and a payload.
80 | * (Example: pbuf_payload_size=0 allocates only size for the struct)
81 | */
82 | LWIP_PBUF_MEMPOOL(PBUF, MEMP_NUM_PBUF, 0, "PBUF_REF/ROM")
83 | LWIP_PBUF_MEMPOOL(PBUF_POOL, PBUF_POOL_SIZE, PBUF_POOL_BUFSIZE, "PBUF_POOL")
84 |
85 |
86 | /*
87 | * Allow for user-defined pools; this must be explicitly set in lwipopts.h
88 | * since the default is to NOT look for lwippools.h
89 | */
90 | #if MEMP_USE_CUSTOM_POOLS
91 | #include "lwippools.h"
92 | #endif /* MEMP_USE_CUSTOM_POOLS */
93 |
94 | /*
95 | * REQUIRED CLEANUP: Clear up so we don't get "multiply defined" error later
96 | * (#undef is ignored for something that is not defined)
97 | */
98 | #undef LWIP_MEMPOOL
99 | #undef LWIP_MALLOC_MEMPOOL
100 | #undef LWIP_MALLOC_MEMPOOL_START
101 | #undef LWIP_MALLOC_MEMPOOL_END
102 | #undef LWIP_PBUF_MEMPOOL
103 |
--------------------------------------------------------------------------------
/lwip/include/lwip/netbuf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_NETBUF_H__
33 | #define __LWIP_NETBUF_H__
34 |
35 | #include "lwip/opt.h"
36 | #include "lwip/pbuf.h"
37 |
38 | #ifdef __cplusplus
39 | extern "C" {
40 | #endif
41 |
42 | struct netbuf {
43 | struct pbuf *p, *ptr;
44 | struct ip_addr *addr;
45 | u16_t port;
46 | };
47 |
48 | /* Network buffer functions: */
49 | struct netbuf * netbuf_new (void);
50 | void netbuf_delete (struct netbuf *buf);
51 | void * netbuf_alloc (struct netbuf *buf, u16_t size);
52 | void netbuf_free (struct netbuf *buf);
53 | err_t netbuf_ref (struct netbuf *buf,
54 | const void *dataptr, u16_t size);
55 | void netbuf_chain (struct netbuf *head,
56 | struct netbuf *tail);
57 |
58 | u16_t netbuf_len (struct netbuf *buf);
59 | err_t netbuf_data (struct netbuf *buf,
60 | void **dataptr, u16_t *len);
61 | s8_t netbuf_next (struct netbuf *buf);
62 | void netbuf_first (struct netbuf *buf);
63 |
64 |
65 | #define netbuf_copy_partial(buf, dataptr, len, offset) \
66 | pbuf_copy_partial((buf)->p, (dataptr), (len), (offset))
67 | #define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
68 | #define netbuf_take(buf, dataptr, len) pbuf_take((buf)->p, dataptr, len)
69 | #define netbuf_len(buf) ((buf)->p->tot_len)
70 | #define netbuf_fromaddr(buf) ((buf)->addr)
71 | #define netbuf_fromport(buf) ((buf)->port)
72 |
73 | #ifdef __cplusplus
74 | }
75 | #endif
76 |
77 | #endif /* __LWIP_NETBUF_H__ */
78 |
--------------------------------------------------------------------------------
/lwip/include/lwip/netdb.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Redistribution and use in source and binary forms, with or without modification,
3 | * are permitted provided that the following conditions are met:
4 | *
5 | * 1. Redistributions of source code must retain the above copyright notice,
6 | * this list of conditions and the following disclaimer.
7 | * 2. Redistributions in binary form must reproduce the above copyright notice,
8 | * this list of conditions and the following disclaimer in the documentation
9 | * and/or other materials provided with the distribution.
10 | * 3. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
22 | * OF SUCH DAMAGE.
23 | *
24 | * This file is part of the lwIP TCP/IP stack.
25 | *
26 | * Author: Simon Goldschmidt
27 | *
28 | */
29 |
30 | #include "lwip/opt.h"
31 |
32 | #if LWIP_DNS && LWIP_SOCKET
33 |
34 | #include /* for size_t */
35 |
36 | #include "lwip/sockets.h"
37 |
38 | /* some rarely used options */
39 | #ifndef LWIP_DNS_API_DECLARE_H_ERRNO
40 | #define LWIP_DNS_API_DECLARE_H_ERRNO 1
41 | #endif
42 |
43 | #ifndef LWIP_DNS_API_DEFINE_ERRORS
44 | #define LWIP_DNS_API_DEFINE_ERRORS 1
45 | #endif
46 |
47 | #ifndef LWIP_DNS_API_DECLARE_STRUCTS
48 | #define LWIP_DNS_API_DECLARE_STRUCTS 1
49 | #endif
50 |
51 | #if LWIP_DNS_API_DEFINE_ERRORS
52 | /** Errors used by the DNS API functions, h_errno can be one of them */
53 | #define EAI_NONAME 200
54 | #define EAI_SERVICE 201
55 | #define EAI_FAIL 202
56 | #define EAI_MEMORY 203
57 |
58 | #define HOST_NOT_FOUND 210
59 | #define NO_DATA 211
60 | #define NO_RECOVERY 212
61 | #define TRY_AGAIN 213
62 | #endif /* LWIP_DNS_API_DEFINE_ERRORS */
63 |
64 | #if LWIP_DNS_API_DECLARE_STRUCTS
65 | struct hostent {
66 | char *h_name; /* Official name of the host. */
67 | char **h_aliases; /* A pointer to an array of pointers to alternative host names,
68 | terminated by a null pointer. */
69 | int h_addrtype; /* Address type. */
70 | int h_length; /* The length, in bytes, of the address. */
71 | char **h_addr_list; /* A pointer to an array of pointers to network addresses (in
72 | network byte order) for the host, terminated by a null pointer. */
73 | #define h_addr h_addr_list[0] /* for backward compatibility */
74 | };
75 |
76 | struct addrinfo {
77 | int ai_flags; /* Input flags. */
78 | int ai_family; /* Address family of socket. */
79 | int ai_socktype; /* Socket type. */
80 | int ai_protocol; /* Protocol of socket. */
81 | socklen_t ai_addrlen; /* Length of socket address. */
82 | struct sockaddr *ai_addr; /* Socket address of socket. */
83 | char *ai_canonname; /* Canonical name of service location. */
84 | struct addrinfo *ai_next; /* Pointer to next in list. */
85 | };
86 | #endif /* LWIP_DNS_API_DECLARE_STRUCTS */
87 |
88 | #if LWIP_DNS_API_DECLARE_H_ERRNO
89 | /* application accessable error code set by the DNS API functions */
90 | extern int h_errno;
91 | #endif /* LWIP_DNS_API_DECLARE_H_ERRNO*/
92 |
93 | struct hostent *lwip_gethostbyname(const char *name);
94 | int lwip_gethostbyname_r(const char *name, struct hostent *ret, char *buf,
95 | size_t buflen, struct hostent **result, int *h_errnop);
96 | void lwip_freeaddrinfo(struct addrinfo *ai);
97 | int lwip_getaddrinfo(const char *nodename,
98 | const char *servname,
99 | const struct addrinfo *hints,
100 | struct addrinfo **res);
101 |
102 | #if LWIP_COMPAT_SOCKETS
103 | #define gethostbyname(name) lwip_gethostbyname(name)
104 | #define gethostbyname_r(name, ret, buf, buflen, result, h_errnop) \
105 | lwip_gethostbyname_r(name, ret, buf, buflen, result, h_errnop)
106 | #define freeaddrinfo(addrinfo) lwip_freeaddrinfo(a)
107 | #define getaddrinfo(nodname, servname, hints, res) \
108 | lwip_getaddrinfo(nodname, servname, hints, res)
109 | #endif /* LWIP_COMPAT_SOCKETS */
110 |
111 | #endif /* LWIP_DNS && LWIP_SOCKET */
112 |
--------------------------------------------------------------------------------
/lwip/include/lwip/netifapi.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Redistribution and use in source and binary forms, with or without modification,
3 | * are permitted provided that the following conditions are met:
4 | *
5 | * 1. Redistributions of source code must retain the above copyright notice,
6 | * this list of conditions and the following disclaimer.
7 | * 2. Redistributions in binary form must reproduce the above copyright notice,
8 | * this list of conditions and the following disclaimer in the documentation
9 | * and/or other materials provided with the distribution.
10 | * 3. The name of the author may not be used to endorse or promote products
11 | * derived from this software without specific prior written permission.
12 | *
13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
22 | * OF SUCH DAMAGE.
23 | *
24 | * This file is part of the lwIP TCP/IP stack.
25 | *
26 | */
27 |
28 | #ifndef __LWIP_NETIFAPI_H__
29 | #define __LWIP_NETIFAPI_H__
30 |
31 | #include "lwip/opt.h"
32 |
33 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
34 |
35 | #include "lwip/sys.h"
36 | #include "lwip/netif.h"
37 | #include "lwip/dhcp.h"
38 | #include "lwip/autoip.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | struct netifapi_msg_msg {
45 | #if !LWIP_TCPIP_CORE_LOCKING
46 | sys_sem_t sem;
47 | #endif /* !LWIP_TCPIP_CORE_LOCKING */
48 | err_t err;
49 | struct netif *netif;
50 | union {
51 | struct {
52 | struct ip_addr *ipaddr;
53 | struct ip_addr *netmask;
54 | struct ip_addr *gw;
55 | void *state;
56 | err_t (* init) (struct netif *netif);
57 | err_t (* input)(struct pbuf *p, struct netif *netif);
58 | } add;
59 | struct {
60 | void (* voidfunc)(struct netif *netif);
61 | err_t (* errtfunc)(struct netif *netif);
62 | } common;
63 | } msg;
64 | };
65 |
66 | struct netifapi_msg {
67 | void (* function)(struct netifapi_msg_msg *msg);
68 | struct netifapi_msg_msg msg;
69 | };
70 |
71 |
72 | /* API for application */
73 | err_t netifapi_netif_add ( struct netif *netif,
74 | struct ip_addr *ipaddr,
75 | struct ip_addr *netmask,
76 | struct ip_addr *gw,
77 | void *state,
78 | err_t (* init)(struct netif *netif),
79 | err_t (* input)(struct pbuf *p, struct netif *netif) );
80 |
81 | err_t netifapi_netif_common ( struct netif *netif,
82 | void (* voidfunc)(struct netif *netif),
83 | err_t (* errtfunc)(struct netif *netif) );
84 |
85 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL)
86 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL)
87 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL)
88 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL)
89 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start)
90 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL)
91 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start)
92 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop)
93 |
94 | #ifdef __cplusplus
95 | }
96 | #endif
97 |
98 | #endif /* LWIP_NETIF_API */
99 |
100 | #endif /* __LWIP_NETIFAPI_H__ */
101 |
--------------------------------------------------------------------------------
/lwip/include/lwip/pbuf.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 |
33 | #ifndef __LWIP_PBUF_H__
34 | #define __LWIP_PBUF_H__
35 |
36 | #include "lwip/opt.h"
37 | #include "lwip/err.h"
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | #define PBUF_TRANSPORT_HLEN 20
44 | #define PBUF_IP_HLEN 20
45 |
46 | typedef enum {
47 | PBUF_TRANSPORT,
48 | PBUF_IP,
49 | PBUF_LINK,
50 | PBUF_RAW
51 | } pbuf_layer;
52 |
53 | typedef enum {
54 | PBUF_RAM, /* pbuf data is stored in RAM */
55 | PBUF_ROM, /* pbuf data is stored in ROM */
56 | PBUF_REF, /* pbuf comes from the pbuf pool */
57 | PBUF_POOL /* pbuf payload refers to RAM */
58 | } pbuf_type;
59 |
60 |
61 | /** indicates this packet's data should be immediately passed to the application */
62 | #define PBUF_FLAG_PUSH 0x01U
63 |
64 | struct pbuf {
65 | /** next pbuf in singly linked pbuf chain */
66 | struct pbuf *next;
67 |
68 | /** pointer to the actual data in the buffer */
69 | void *payload;
70 |
71 | /**
72 | * total length of this buffer and all next buffers in chain
73 | * belonging to the same packet.
74 | *
75 | * For non-queue packet chains this is the invariant:
76 | * p->tot_len == p->len + (p->next? p->next->tot_len: 0)
77 | */
78 | u16_t tot_len;
79 |
80 | /** length of this buffer */
81 | u16_t len;
82 |
83 | /** pbuf_type as u8_t instead of enum to save space */
84 | u8_t /*pbuf_type*/ type;
85 |
86 | /** misc flags */
87 | u8_t flags;
88 |
89 | /**
90 | * the reference count always equals the number of pointers
91 | * that refer to this pbuf. This can be pointers from an application,
92 | * the stack itself, or pbuf->next pointers from a chain.
93 | */
94 | u16_t ref;
95 |
96 | };
97 |
98 | /* Initializes the pbuf module. This call is empty for now, but may not be in future. */
99 | #define pbuf_init()
100 |
101 | struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_type type);
102 | void pbuf_realloc(struct pbuf *p, u16_t size);
103 | u8_t pbuf_header(struct pbuf *p, s16_t header_size);
104 | void pbuf_ref(struct pbuf *p);
105 | void pbuf_ref_chain(struct pbuf *p);
106 | u8_t pbuf_free(struct pbuf *p);
107 | u8_t pbuf_clen(struct pbuf *p);
108 | void pbuf_cat(struct pbuf *head, struct pbuf *tail);
109 | void pbuf_chain(struct pbuf *head, struct pbuf *tail);
110 | struct pbuf *pbuf_dechain(struct pbuf *p);
111 | err_t pbuf_copy(struct pbuf *p_to, struct pbuf *p_from);
112 | u16_t pbuf_copy_partial(struct pbuf *p, void *dataptr, u16_t len, u16_t offset);
113 | err_t pbuf_take(struct pbuf *buf, const void *dataptr, u16_t len);
114 | struct pbuf *pbuf_coalesce(struct pbuf *p, pbuf_layer layer);
115 |
116 | #ifdef __cplusplus
117 | }
118 | #endif
119 |
120 | #endif /* __LWIP_PBUF_H__ */
121 |
--------------------------------------------------------------------------------
/lwip/include/lwip/raw.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_RAW_H__
33 | #define __LWIP_RAW_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
38 |
39 | #include "lwip/pbuf.h"
40 | #include "lwip/inet.h"
41 | #include "lwip/ip.h"
42 | #include "lwip/ip_addr.h"
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | struct raw_pcb {
49 | /* Common members of all PCB types */
50 | IP_PCB;
51 |
52 | struct raw_pcb *next;
53 |
54 | u8_t protocol;
55 |
56 | /* receive callback function
57 | * @param arg user supplied argument (raw_pcb.recv_arg)
58 | * @param pcb the raw_pcb which received data
59 | * @param p the packet buffer that was received
60 | * @param addr the remote IP address from which the packet was received
61 | * @return 1 if the packet was 'eaten' (aka. deleted),
62 | * 0 if the packet lives on
63 | * If returning 1, the callback is responsible for freeing the pbuf
64 | * if it's not used any more.
65 | */
66 | u8_t (* recv)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
67 | struct ip_addr *addr);
68 | /* user-supplied argument for the recv callback */
69 | void *recv_arg;
70 | };
71 |
72 | /* The following functions is the application layer interface to the
73 | RAW code. */
74 | struct raw_pcb * raw_new (u8_t proto);
75 | void raw_remove (struct raw_pcb *pcb);
76 | err_t raw_bind (struct raw_pcb *pcb, struct ip_addr *ipaddr);
77 | err_t raw_connect (struct raw_pcb *pcb, struct ip_addr *ipaddr);
78 |
79 | void raw_recv (struct raw_pcb *pcb,
80 | u8_t (* recv)(void *arg, struct raw_pcb *pcb,
81 | struct pbuf *p,
82 | struct ip_addr *addr),
83 | void *recv_arg);
84 | err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr);
85 | err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
86 |
87 | /* The following functions are the lower layer interface to RAW. */
88 | u8_t raw_input (struct pbuf *p, struct netif *inp);
89 | #define raw_init() /* Compatibility define, not init needed. */
90 |
91 | #ifdef __cplusplus
92 | }
93 | #endif
94 |
95 | #endif /* LWIP_RAW */
96 |
97 | #endif /* __LWIP_RAW_H__ */
98 |
--------------------------------------------------------------------------------
/lwip/include/lwip/sio.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | */
29 |
30 | /*
31 | * This is the interface to the platform specific serial IO module
32 | * It needs to be implemented by those platforms which need SLIP or PPP
33 | */
34 |
35 | #ifndef __SIO_H__
36 | #define __SIO_H__
37 |
38 | #include "lwip/arch.h"
39 |
40 | #ifdef __cplusplus
41 | extern "C" {
42 | #endif
43 |
44 | /* If you want to define sio_fd_t elsewhere or differently,
45 | define this in your cc.h file. */
46 | #ifndef __sio_fd_t_defined
47 | typedef void * sio_fd_t;
48 | #endif
49 |
50 | /* The following functions can be defined to something else in your cc.h file
51 | or be implemented in your custom sio.c file. */
52 |
53 | #ifndef sio_open
54 | sio_fd_t sio_open(u8_t);
55 | #endif
56 |
57 | #ifndef sio_send
58 | void sio_send(u8_t, sio_fd_t);
59 | #endif
60 |
61 | #ifndef sio_recv
62 | u8_t sio_recv(sio_fd_t);
63 | #endif
64 |
65 | #ifndef sio_read
66 | u32_t sio_read(sio_fd_t, u8_t *, u32_t);
67 | #endif
68 |
69 | #ifndef sio_write
70 | u32_t sio_write(sio_fd_t, u8_t *, u32_t);
71 | #endif
72 |
73 | #ifndef sio_read_abort
74 | void sio_read_abort(sio_fd_t);
75 | #endif
76 |
77 | #ifdef __cplusplus
78 | }
79 | #endif
80 |
81 | #endif /* __SIO_H__ */
82 |
--------------------------------------------------------------------------------
/lwip/include/lwip/snmp_asn1.h:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Abstract Syntax Notation One (ISO 8824, 8825) codec.
4 | */
5 |
6 | /*
7 | * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
8 | * All rights reserved.
9 | *
10 | * Redistribution and use in source and binary forms, with or without modification,
11 | * are permitted provided that the following conditions are met:
12 | *
13 | * 1. Redistributions of source code must retain the above copyright notice,
14 | * this list of conditions and the following disclaimer.
15 | * 2. Redistributions in binary form must reproduce the above copyright notice,
16 | * this list of conditions and the following disclaimer in the documentation
17 | * and/or other materials provided with the distribution.
18 | * 3. The name of the author may not be used to endorse or promote products
19 | * derived from this software without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
30 | * OF SUCH DAMAGE.
31 | *
32 | * Author: Christiaan Simons
33 | */
34 |
35 | #ifndef __LWIP_SNMP_ASN1_H__
36 | #define __LWIP_SNMP_ASN1_H__
37 |
38 | #include "lwip/opt.h"
39 | #include "lwip/err.h"
40 | #include "lwip/pbuf.h"
41 | #include "lwip/snmp.h"
42 |
43 | #if LWIP_SNMP
44 |
45 | #ifdef __cplusplus
46 | extern "C" {
47 | #endif
48 |
49 | #define SNMP_ASN1_UNIV (!0x80 | !0x40)
50 | #define SNMP_ASN1_APPLIC (!0x80 | 0x40)
51 | #define SNMP_ASN1_CONTXT ( 0x80 | !0x40)
52 |
53 | #define SNMP_ASN1_CONSTR (0x20)
54 | #define SNMP_ASN1_PRIMIT (!0x20)
55 |
56 | /* universal tags */
57 | #define SNMP_ASN1_INTEG 2
58 | #define SNMP_ASN1_OC_STR 4
59 | #define SNMP_ASN1_NUL 5
60 | #define SNMP_ASN1_OBJ_ID 6
61 | #define SNMP_ASN1_SEQ 16
62 |
63 | /* application specific (SNMP) tags */
64 | #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */
65 | #define SNMP_ASN1_COUNTER 1 /* u32_t */
66 | #define SNMP_ASN1_GAUGE 2 /* u32_t */
67 | #define SNMP_ASN1_TIMETICKS 3 /* u32_t */
68 | #define SNMP_ASN1_OPAQUE 4 /* octet string */
69 |
70 | /* context specific (SNMP) tags */
71 | #define SNMP_ASN1_PDU_GET_REQ 0
72 | #define SNMP_ASN1_PDU_GET_NEXT_REQ 1
73 | #define SNMP_ASN1_PDU_GET_RESP 2
74 | #define SNMP_ASN1_PDU_SET_REQ 3
75 | #define SNMP_ASN1_PDU_TRAP 4
76 |
77 | err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type);
78 | err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length);
79 | err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value);
80 | err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value);
81 | err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid);
82 | err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw);
83 |
84 | void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed);
85 | void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed);
86 | void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed);
87 | void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed);
88 | err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type);
89 | err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
90 | err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, u32_t value);
91 | err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u8_t octets_needed, s32_t value);
92 | err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident);
93 | err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u8_t raw_len, u8_t *raw);
94 |
95 | #ifdef __cplusplus
96 | }
97 | #endif
98 |
99 | #endif /* LWIP_SNMP */
100 |
101 | #endif /* __LWIP_SNMP_ASN1_H__ */
102 |
--------------------------------------------------------------------------------
/lwip/include/lwip/tcpip.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_TCPIP_H__
33 | #define __LWIP_TCPIP_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
38 |
39 | #include "lwip/api_msg.h"
40 | #include "lwip/netifapi.h"
41 | #include "lwip/pbuf.h"
42 | #include "lwip/api.h"
43 | #include "lwip/sys.h"
44 | #include "lwip/netif.h"
45 |
46 | #ifdef __cplusplus
47 | extern "C" {
48 | #endif
49 |
50 | #if LWIP_TCPIP_CORE_LOCKING
51 | /** The global semaphore to lock the stack. */
52 | extern sys_sem_t lock_tcpip_core;
53 | #define LOCK_TCPIP_CORE() sys_sem_wait(lock_tcpip_core)
54 | #define UNLOCK_TCPIP_CORE() sys_sem_signal(lock_tcpip_core)
55 | #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
56 | #define TCPIP_APIMSG_ACK(m)
57 | #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
58 | #define TCPIP_NETIFAPI_ACK(m)
59 | #else
60 | #define LOCK_TCPIP_CORE()
61 | #define UNLOCK_TCPIP_CORE()
62 | #define TCPIP_APIMSG(m) tcpip_apimsg(m)
63 | #define TCPIP_APIMSG_ACK(m) sys_sem_signal(m->conn->op_completed)
64 | #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
65 | #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
66 | #endif /* LWIP_TCPIP_CORE_LOCKING */
67 |
68 | void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
69 |
70 | #if LWIP_NETCONN
71 | err_t tcpip_apimsg(struct api_msg *apimsg);
72 | #if LWIP_TCPIP_CORE_LOCKING
73 | err_t tcpip_apimsg_lock(struct api_msg *apimsg);
74 | #endif /* LWIP_TCPIP_CORE_LOCKING */
75 | #endif /* LWIP_NETCONN */
76 |
77 | err_t tcpip_input(struct pbuf *p, struct netif *inp);
78 |
79 | #if LWIP_NETIF_API
80 | err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
81 | #if LWIP_TCPIP_CORE_LOCKING
82 | err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
83 | #endif /* LWIP_TCPIP_CORE_LOCKING */
84 | #endif /* LWIP_NETIF_API */
85 |
86 | err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
87 | #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
88 |
89 | /* free pbufs or heap memory from another context without blocking */
90 | err_t pbuf_free_callback(struct pbuf *p);
91 | err_t mem_free_callback(void *m);
92 |
93 | err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
94 | err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
95 |
96 | enum tcpip_msg_type {
97 | #if LWIP_NETCONN
98 | TCPIP_MSG_API,
99 | #endif /* LWIP_NETCONN */
100 | TCPIP_MSG_INPKT,
101 | #if LWIP_NETIF_API
102 | TCPIP_MSG_NETIFAPI,
103 | #endif /* LWIP_NETIF_API */
104 | TCPIP_MSG_CALLBACK,
105 | TCPIP_MSG_TIMEOUT,
106 | TCPIP_MSG_UNTIMEOUT
107 | };
108 |
109 | struct tcpip_msg {
110 | enum tcpip_msg_type type;
111 | sys_sem_t *sem;
112 | union {
113 | #if LWIP_NETCONN
114 | struct api_msg *apimsg;
115 | #endif /* LWIP_NETCONN */
116 | #if LWIP_NETIF_API
117 | struct netifapi_msg *netifapimsg;
118 | #endif /* LWIP_NETIF_API */
119 | struct {
120 | struct pbuf *p;
121 | struct netif *netif;
122 | } inp;
123 | struct {
124 | void (*f)(void *ctx);
125 | void *ctx;
126 | } cb;
127 | struct {
128 | u32_t msecs;
129 | sys_timeout_handler h;
130 | void *arg;
131 | } tmo;
132 | } msg;
133 | };
134 |
135 | #ifdef __cplusplus
136 | }
137 | #endif
138 |
139 | #endif /* !NO_SYS */
140 |
141 | #endif /* __LWIP_TCPIP_H__ */
142 |
--------------------------------------------------------------------------------
/lwip/include/lwip/udp.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __LWIP_UDP_H__
33 | #define __LWIP_UDP_H__
34 |
35 | #include "lwip/opt.h"
36 |
37 | #if LWIP_UDP /* don't build if not configured for use in lwipopts.h */
38 |
39 | #include "lwip/pbuf.h"
40 | #include "lwip/netif.h"
41 | #include "lwip/ip_addr.h"
42 | #include "lwip/ip.h"
43 |
44 | #ifdef __cplusplus
45 | extern "C" {
46 | #endif
47 |
48 | #define UDP_HLEN 8
49 |
50 | /* Fields are (of course) in network byte order. */
51 | #ifdef PACK_STRUCT_USE_INCLUDES
52 | # include "arch/bpstruct.h"
53 | #endif
54 | PACK_STRUCT_BEGIN
55 | struct udp_hdr {
56 | PACK_STRUCT_FIELD(u16_t src);
57 | PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */
58 | PACK_STRUCT_FIELD(u16_t len);
59 | PACK_STRUCT_FIELD(u16_t chksum);
60 | } PACK_STRUCT_STRUCT;
61 | PACK_STRUCT_END
62 | #ifdef PACK_STRUCT_USE_INCLUDES
63 | # include "arch/epstruct.h"
64 | #endif
65 |
66 | #define UDP_FLAGS_NOCHKSUM 0x01U
67 | #define UDP_FLAGS_UDPLITE 0x02U
68 | #define UDP_FLAGS_CONNECTED 0x04U
69 |
70 | struct udp_pcb {
71 | /* Common members of all PCB types */
72 | IP_PCB;
73 |
74 | /* Protocol specific PCB members */
75 |
76 | struct udp_pcb *next;
77 |
78 | u8_t flags;
79 | /* ports are in host byte order */
80 | u16_t local_port, remote_port;
81 |
82 | #if LWIP_IGMP
83 | /* outgoing network interface for multicast packets */
84 | struct ip_addr multicast_ip;
85 | #endif /* LWIP_IGMP */
86 |
87 | #if LWIP_UDPLITE
88 | /* used for UDP_LITE only */
89 | u16_t chksum_len_rx, chksum_len_tx;
90 | #endif /* LWIP_UDPLITE */
91 |
92 | /* receive callback function
93 | * addr and port are in same byte order as in the pcb
94 | * The callback is responsible for freeing the pbuf
95 | * if it's not used any more.
96 | *
97 | * @param arg user supplied argument (udp_pcb.recv_arg)
98 | * @param pcb the udp_pcb which received data
99 | * @param p the packet buffer that was received
100 | * @param addr the remote IP address from which the packet was received
101 | * @param port the remote port from which the packet was received
102 | */
103 | void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
104 | struct ip_addr *addr, u16_t port);
105 | /* user-supplied argument for the recv callback */
106 | void *recv_arg;
107 | };
108 | /* udp_pcbs export for exernal reference (e.g. SNMP agent) */
109 | extern struct udp_pcb *udp_pcbs;
110 |
111 | /* The following functions is the application layer interface to the
112 | UDP code. */
113 | struct udp_pcb * udp_new (void);
114 | void udp_remove (struct udp_pcb *pcb);
115 | err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr,
116 | u16_t port);
117 | err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr,
118 | u16_t port);
119 | void udp_disconnect (struct udp_pcb *pcb);
120 | void udp_recv (struct udp_pcb *pcb,
121 | void (* recv)(void *arg, struct udp_pcb *upcb,
122 | struct pbuf *p,
123 | struct ip_addr *addr,
124 | u16_t port),
125 | void *recv_arg);
126 | err_t udp_sendto_if (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif);
127 | err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port);
128 | err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
129 |
130 | #define udp_flags(pcb) ((pcb)->flags)
131 | #define udp_setflags(pcb, f) ((pcb)->flags = (f))
132 |
133 | /* The following functions are the lower layer interface to UDP. */
134 | void udp_input (struct pbuf *p, struct netif *inp);
135 |
136 | #define udp_init() /* Compatibility define, not init needed. */
137 |
138 | #if UDP_DEBUG
139 | void udp_debug_print(struct udp_hdr *udphdr);
140 | #else
141 | #define udp_debug_print(udphdr)
142 | #endif
143 |
144 | #ifdef __cplusplus
145 | }
146 | #endif
147 |
148 | #endif /* LWIP_UDP */
149 |
150 | #endif /* __LWIP_UDP_H__ */
151 |
--------------------------------------------------------------------------------
/lwip/include/lwipopts.h:
--------------------------------------------------------------------------------
1 | #ifndef __LWIP_OPTS_H__
2 | #define __LWIP_OPTS_H__
3 |
4 | #define LWIP_PROVIDE_ERRNO
5 | #define MEM_SIZE 64001l
6 | //#define ICMP_DEBUG LWIP_DBG_ON
7 | //#define ETHARP_DEBUG LWIP_DBG_ON
8 |
9 | #endif
--------------------------------------------------------------------------------
/lwip/include/netif/loopif.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without modification,
6 | * are permitted provided that the following conditions are met:
7 | *
8 | * 1. Redistributions of source code must retain the above copyright notice,
9 | * this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright notice,
11 | * this list of conditions and the following disclaimer in the documentation
12 | * and/or other materials provided with the distribution.
13 | * 3. The name of the author may not be used to endorse or promote products
14 | * derived from this software without specific prior written permission.
15 | *
16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
25 | * OF SUCH DAMAGE.
26 | *
27 | * This file is part of the lwIP TCP/IP stack.
28 | *
29 | * Author: Adam Dunkels
30 | *
31 | */
32 | #ifndef __NETIF_LOOPIF_H__
33 | #define __NETIF_LOOPIF_H__
34 |
35 | #include "lwip/opt.h"
36 | #include "lwip/netif.h"
37 | #include "lwip/err.h"
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | #if !LWIP_NETIF_LOOPBACK_MULTITHREADING
44 | #define loopif_poll netif_poll
45 | #endif /* !LWIP_NETIF_LOOPBACK_MULTITHREADING */
46 |
47 | err_t loopif_init(struct netif *netif);
48 |
49 | #ifdef __cplusplus
50 | }
51 | #endif
52 |
53 | #endif /* __NETIF_LOOPIF_H__ */
54 |
--------------------------------------------------------------------------------
/lwip/include/netif/slipif.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001, Swedish Institute of Computer Science.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the Institute nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | *
29 | * This file is part of the lwIP TCP/IP stack.
30 | *
31 | * Author: Adam Dunkels
32 | *
33 | */
34 | #ifndef __NETIF_SLIPIF_H__
35 | #define __NETIF_SLIPIF_H__
36 |
37 | #include "lwip/netif.h"
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | err_t slipif_init(struct netif * netif);
44 |
45 | #ifdef __cplusplus
46 | }
47 | #endif
48 |
49 | #endif
50 |
51 |
--------------------------------------------------------------------------------
/lwip/netif/loopif.c:
--------------------------------------------------------------------------------
1 | /**
2 | * @file
3 | * Loop Interface
4 | *
5 | */
6 |
7 | /*
8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9 | * All rights reserved.
10 | *
11 | * Redistribution and use in source and binary forms, with or without modification,
12 | * are permitted provided that the following conditions are met:
13 | *
14 | * 1. Redistributions of source code must retain the above copyright notice,
15 | * this list of conditions and the following disclaimer.
16 | * 2. Redistributions in binary form must reproduce the above copyright notice,
17 | * this list of conditions and the following disclaimer in the documentation
18 | * and/or other materials provided with the distribution.
19 | * 3. The name of the author may not be used to endorse or promote products
20 | * derived from this software without specific prior written permission.
21 | *
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 | * OF SUCH DAMAGE.
32 | *
33 | * This file is part of the lwIP TCP/IP stack.
34 | *
35 | * Author: Adam Dunkels
36 | *
37 | */
38 | #include "lwip/opt.h"
39 |
40 | #if LWIP_HAVE_LOOPIF
41 |
42 | #include "netif/loopif.h"
43 | #include "lwip/snmp.h"
44 |
45 | /**
46 | * Initialize a lwip network interface structure for a loopback interface
47 | *
48 | * @param netif the lwip network interface structure for this loopif
49 | * @return ERR_OK if the loopif is initialized
50 | * ERR_MEM if private data couldn't be allocated
51 | */
52 | err_t
53 | loopif_init(struct netif *netif)
54 | {
55 | /* initialize the snmp variables and counters inside the struct netif
56 | * ifSpeed: no assumption can be made!
57 | */
58 | NETIF_INIT_SNMP(netif, snmp_ifType_softwareLoopback, 0);
59 |
60 | netif->name[0] = 'l';
61 | netif->name[1] = 'o';
62 | netif->output = netif_loop_output;
63 | return ERR_OK;
64 | }
65 |
66 | #endif /* LWIP_HAVE_LOOPIF */
67 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/auth.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * auth.h - PPP Authentication and phase control header file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1998 Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc.
31 | * Original derived from BSD pppd.h.
32 | *****************************************************************************/
33 | /*
34 | * pppd.h - PPP daemon global declarations.
35 | *
36 | * Copyright (c) 1989 Carnegie Mellon University.
37 | * All rights reserved.
38 | *
39 | * Redistribution and use in source and binary forms are permitted
40 | * provided that the above copyright notice and this paragraph are
41 | * duplicated in all such forms and that any documentation,
42 | * advertising materials, and other materials related to such
43 | * distribution and use acknowledge that the software was developed
44 | * by Carnegie Mellon University. The name of the
45 | * University may not be used to endorse or promote products derived
46 | * from this software without specific prior written permission.
47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
50 | *
51 | */
52 |
53 | #ifndef AUTH_H
54 | #define AUTH_H
55 |
56 | /***********************
57 | *** PUBLIC FUNCTIONS ***
58 | ***********************/
59 |
60 | /* we are starting to use the link */
61 | void link_required (int);
62 |
63 | /* we are finished with the link */
64 | void link_terminated (int);
65 |
66 | /* the LCP layer has left the Opened state */
67 | void link_down (int);
68 |
69 | /* the link is up; authenticate now */
70 | void link_established (int);
71 |
72 | /* a network protocol has come up */
73 | void np_up (int, u16_t);
74 |
75 | /* a network protocol has gone down */
76 | void np_down (int, u16_t);
77 |
78 | /* a network protocol no longer needs link */
79 | void np_finished (int, u16_t);
80 |
81 | /* peer failed to authenticate itself */
82 | void auth_peer_fail (int, u16_t);
83 |
84 | /* peer successfully authenticated itself */
85 | void auth_peer_success (int, u16_t, char *, int);
86 |
87 | /* we failed to authenticate ourselves */
88 | void auth_withpeer_fail (int, u16_t);
89 |
90 | /* we successfully authenticated ourselves */
91 | void auth_withpeer_success (int, u16_t);
92 |
93 | /* check authentication options supplied */
94 | void auth_check_options (void);
95 |
96 | /* check what secrets we have */
97 | void auth_reset (int);
98 |
99 | /* Check peer-supplied username/password */
100 | int check_passwd (int, char *, int, char *, int, char **, int *);
101 |
102 | /* get "secret" for chap */
103 | int get_secret (int, char *, char *, char *, int *, int);
104 |
105 | /* check if IP address is authorized */
106 | int auth_ip_addr (int, u32_t);
107 |
108 | /* check if IP address is unreasonable */
109 | int bad_ip_adrs (u32_t);
110 |
111 | #endif /* AUTH_H */
112 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/chpms.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * chpms.h - Network Microsoft Challenge Handshake Protocol header file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1998 Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 98-01-30 Guy Lancaster , Global Election Systems Inc.
31 | * Original built from BSD network code.
32 | ******************************************************************************/
33 | /*
34 | * chap.h - Challenge Handshake Authentication Protocol definitions.
35 | *
36 | * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited.
37 | * http://www.strataware.com/
38 | *
39 | * All rights reserved.
40 | *
41 | * Redistribution and use in source and binary forms are permitted
42 | * provided that the above copyright notice and this paragraph are
43 | * duplicated in all such forms and that any documentation,
44 | * advertising materials, and other materials related to such
45 | * distribution and use acknowledge that the software was developed
46 | * by Eric Rosenquist. The name of the author may not be used to
47 | * endorse or promote products derived from this software without
48 | * specific prior written permission.
49 | *
50 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
51 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
52 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
53 | *
54 | * $Id: chpms.h,v 1.5 2007/12/19 20:47:23 fbernon Exp $
55 | */
56 |
57 | #ifndef CHPMS_H
58 | #define CHPMS_H
59 |
60 | #define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */
61 |
62 | void ChapMS (chap_state *, char *, int, char *, int);
63 |
64 | #endif /* CHPMS_H */
65 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/ipcp.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * ipcp.h - PPP IP NCP: Internet Protocol Network Control Protocol header file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1997 Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc.
31 | * Original derived from BSD codes.
32 | *****************************************************************************/
33 | /*
34 | * ipcp.h - IP Control Protocol definitions.
35 | *
36 | * Copyright (c) 1989 Carnegie Mellon University.
37 | * All rights reserved.
38 | *
39 | * Redistribution and use in source and binary forms are permitted
40 | * provided that the above copyright notice and this paragraph are
41 | * duplicated in all such forms and that any documentation,
42 | * advertising materials, and other materials related to such
43 | * distribution and use acknowledge that the software was developed
44 | * by Carnegie Mellon University. The name of the
45 | * University may not be used to endorse or promote products derived
46 | * from this software without specific prior written permission.
47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
50 | *
51 | * $Id: ipcp.h,v 1.3 2007/12/19 20:47:23 fbernon Exp $
52 | */
53 |
54 | #ifndef IPCP_H
55 | #define IPCP_H
56 |
57 | /*************************
58 | *** PUBLIC DEFINITIONS ***
59 | *************************/
60 | /*
61 | * Options.
62 | */
63 | #define CI_ADDRS 1 /* IP Addresses */
64 | #define CI_COMPRESSTYPE 2 /* Compression Type */
65 | #define CI_ADDR 3
66 |
67 | #define CI_MS_WINS1 128 /* Primary WINS value */
68 | #define CI_MS_DNS1 129 /* Primary DNS value */
69 | #define CI_MS_WINS2 130 /* Secondary WINS value */
70 | #define CI_MS_DNS2 131 /* Secondary DNS value */
71 |
72 | #define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
73 | #define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
74 | #define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
75 | /* maxslot and slot number compression) */
76 |
77 | #define IPCP_VJ_COMP 0x002d /* current value for VJ compression option */
78 | #define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
79 | /* compression option */
80 |
81 |
82 | /************************
83 | *** PUBLIC DATA TYPES ***
84 | ************************/
85 |
86 | typedef struct ipcp_options {
87 | u_int neg_addr : 1; /* Negotiate IP Address? */
88 | u_int old_addrs : 1; /* Use old (IP-Addresses) option? */
89 | u_int req_addr : 1; /* Ask peer to send IP address? */
90 | u_int default_route : 1; /* Assign default route through interface? */
91 | u_int proxy_arp : 1; /* Make proxy ARP entry for peer? */
92 | u_int neg_vj : 1; /* Van Jacobson Compression? */
93 | u_int old_vj : 1; /* use old (short) form of VJ option? */
94 | u_int accept_local : 1; /* accept peer's value for ouraddr */
95 | u_int accept_remote : 1; /* accept peer's value for hisaddr */
96 | u_int req_dns1 : 1; /* Ask peer to send primary DNS address? */
97 | u_int req_dns2 : 1; /* Ask peer to send secondary DNS address? */
98 | u_short vj_protocol; /* protocol value to use in VJ option */
99 | u_char maxslotindex; /* VJ slots - 1. */
100 | u_char cflag; /* VJ slot compression flag. */
101 | u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
102 | u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
103 | u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
104 | } ipcp_options;
105 |
106 |
107 | /*****************************
108 | *** PUBLIC DATA STRUCTURES ***
109 | *****************************/
110 |
111 | extern fsm ipcp_fsm[];
112 | extern ipcp_options ipcp_wantoptions[];
113 | extern ipcp_options ipcp_gotoptions[];
114 | extern ipcp_options ipcp_allowoptions[];
115 | extern ipcp_options ipcp_hisoptions[];
116 |
117 | extern struct protent ipcp_protent;
118 |
119 |
120 | /***********************
121 | *** PUBLIC FUNCTIONS ***
122 | ***********************/
123 |
124 | #endif /* IPCP_H */
125 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/magic.c:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * magic.c - Network Random Number Generator program file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1997 by Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc.
31 | * Original based on BSD magic.c.
32 | *****************************************************************************/
33 | /*
34 | * magic.c - PPP Magic Number routines.
35 | *
36 | * Copyright (c) 1989 Carnegie Mellon University.
37 | * All rights reserved.
38 | *
39 | * Redistribution and use in source and binary forms are permitted
40 | * provided that the above copyright notice and this paragraph are
41 | * duplicated in all such forms and that any documentation,
42 | * advertising materials, and other materials related to such
43 | * distribution and use acknowledge that the software was developed
44 | * by Carnegie Mellon University. The name of the
45 | * University may not be used to endorse or promote products derived
46 | * from this software without specific prior written permission.
47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
50 | */
51 |
52 | #include "lwip/opt.h"
53 |
54 | #if PPP_SUPPORT
55 |
56 | #include "ppp.h"
57 | #include "randm.h"
58 | #include "magic.h"
59 |
60 | /***********************************/
61 | /*** PUBLIC FUNCTION DEFINITIONS ***/
62 | /***********************************/
63 | /*
64 | * magicInit - Initialize the magic number generator.
65 | *
66 | * Since we use another random number generator that has its own
67 | * initialization, we do nothing here.
68 | */
69 | void magicInit()
70 | {
71 | return;
72 | }
73 |
74 | /*
75 | * magic - Returns the next magic number.
76 | */
77 | u32_t magic()
78 | {
79 | return avRandom();
80 | }
81 |
82 | #endif /* PPP_SUPPORT */
83 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/magic.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * magic.h - Network Random Number Generator header file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1997 Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc.
31 | * Original derived from BSD codes.
32 | *****************************************************************************/
33 | /*
34 | * magic.h - PPP Magic Number definitions.
35 | *
36 | * Copyright (c) 1989 Carnegie Mellon University.
37 | * All rights reserved.
38 | *
39 | * Redistribution and use in source and binary forms are permitted
40 | * provided that the above copyright notice and this paragraph are
41 | * duplicated in all such forms and that any documentation,
42 | * advertising materials, and other materials related to such
43 | * distribution and use acknowledge that the software was developed
44 | * by Carnegie Mellon University. The name of the
45 | * University may not be used to endorse or promote products derived
46 | * from this software without specific prior written permission.
47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
50 | *
51 | * $Id: magic.h,v 1.2 2007/12/02 22:35:55 fbernon Exp $
52 | */
53 |
54 | #ifndef MAGIC_H
55 | #define MAGIC_H
56 |
57 | /*****************************************************************************
58 | ************************** PUBLIC FUNCTIONS **********************************
59 | *****************************************************************************/
60 |
61 | /* Initialize the magic number generator */
62 | void magicInit(void);
63 |
64 | /* Returns the next magic number */
65 | u32_t magic(void);
66 |
67 | #endif /* MAGIC_H */
68 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/md5.h:
--------------------------------------------------------------------------------
1 | /*
2 | ***********************************************************************
3 | ** md5.h -- header file for implementation of MD5 **
4 | ** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
5 | ** Created: 2/17/90 RLR **
6 | ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
7 | ** Revised (for MD5): RLR 4/27/91 **
8 | ** -- G modified to have y&~z instead of y&z **
9 | ** -- FF, GG, HH modified to add in last register done **
10 | ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
11 | ** -- distinct additive constant for each step **
12 | ** -- round 4 added, working mod 7 **
13 | ***********************************************************************
14 | */
15 |
16 | /*
17 | ***********************************************************************
18 | ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
19 | ** **
20 | ** License to copy and use this software is granted provided that **
21 | ** it is identified as the "RSA Data Security, Inc. MD5 Message- **
22 | ** Digest Algorithm" in all material mentioning or referencing this **
23 | ** software or this function. **
24 | ** **
25 | ** License is also granted to make and use derivative works **
26 | ** provided that such works are identified as "derived from the RSA **
27 | ** Data Security, Inc. MD5 Message-Digest Algorithm" in all **
28 | ** material mentioning or referencing the derived work. **
29 | ** **
30 | ** RSA Data Security, Inc. makes no representations concerning **
31 | ** either the merchantability of this software or the suitability **
32 | ** of this software for any particular purpose. It is provided "as **
33 | ** is" without express or implied warranty of any kind. **
34 | ** **
35 | ** These notices must be retained in any copies of any part of this **
36 | ** documentation and/or software. **
37 | ***********************************************************************
38 | */
39 |
40 | #ifndef MD5_H
41 | #define MD5_H
42 |
43 | /* Data structure for MD5 (Message-Digest) computation */
44 | typedef struct {
45 | u32_t i[2]; /* number of _bits_ handled mod 2^64 */
46 | u32_t buf[4]; /* scratch buffer */
47 | unsigned char in[64]; /* input buffer */
48 | unsigned char digest[16]; /* actual digest after MD5Final call */
49 | } MD5_CTX;
50 |
51 | void MD5Init ( MD5_CTX *mdContext);
52 | void MD5Update( MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen);
53 | void MD5Final ( unsigned char hash[], MD5_CTX *mdContext);
54 |
55 | #endif /* MD5_H */
56 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/pap.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * pap.h - PPP Password Authentication Protocol header file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1997 Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 97-12-04 Guy Lancaster , Global Election Systems Inc.
31 | * Original derived from BSD codes.
32 | *****************************************************************************/
33 | /*
34 | * upap.h - User/Password Authentication Protocol definitions.
35 | *
36 | * Copyright (c) 1989 Carnegie Mellon University.
37 | * All rights reserved.
38 | *
39 | * Redistribution and use in source and binary forms are permitted
40 | * provided that the above copyright notice and this paragraph are
41 | * duplicated in all such forms and that any documentation,
42 | * advertising materials, and other materials related to such
43 | * distribution and use acknowledge that the software was developed
44 | * by Carnegie Mellon University. The name of the
45 | * University may not be used to endorse or promote products derived
46 | * from this software without specific prior written permission.
47 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
48 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
49 | * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
50 | */
51 |
52 | #ifndef PAP_H
53 | #define PAP_H
54 |
55 | #if PAP_SUPPORT /* don't build if not configured for use in lwipopts.h */
56 |
57 | /*************************
58 | *** PUBLIC DEFINITIONS ***
59 | *************************/
60 | /*
61 | * Packet header = Code, id, length.
62 | */
63 | #define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short))
64 |
65 |
66 | /*
67 | * UPAP codes.
68 | */
69 | #define UPAP_AUTHREQ 1 /* Authenticate-Request */
70 | #define UPAP_AUTHACK 2 /* Authenticate-Ack */
71 | #define UPAP_AUTHNAK 3 /* Authenticate-Nak */
72 |
73 | /*
74 | * Client states.
75 | */
76 | #define UPAPCS_INITIAL 0 /* Connection down */
77 | #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */
78 | #define UPAPCS_PENDING 2 /* Connection down, have requested auth */
79 | #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */
80 | #define UPAPCS_OPEN 4 /* We've received an Ack */
81 | #define UPAPCS_BADAUTH 5 /* We've received a Nak */
82 |
83 | /*
84 | * Server states.
85 | */
86 | #define UPAPSS_INITIAL 0 /* Connection down */
87 | #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */
88 | #define UPAPSS_PENDING 2 /* Connection down, have requested auth */
89 | #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */
90 | #define UPAPSS_OPEN 4 /* We've sent an Ack */
91 | #define UPAPSS_BADAUTH 5 /* We've sent a Nak */
92 |
93 |
94 | /************************
95 | *** PUBLIC DATA TYPES ***
96 | ************************/
97 |
98 | /*
99 | * Each interface is described by upap structure.
100 | */
101 | typedef struct upap_state {
102 | int us_unit; /* Interface unit number */
103 | const char *us_user; /* User */
104 | int us_userlen; /* User length */
105 | const char *us_passwd; /* Password */
106 | int us_passwdlen; /* Password length */
107 | int us_clientstate; /* Client state */
108 | int us_serverstate; /* Server state */
109 | u_char us_id; /* Current id */
110 | int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */
111 | int us_transmits; /* Number of auth-reqs sent */
112 | int us_maxtransmits; /* Maximum number of auth-reqs to send */
113 | int us_reqtimeout; /* Time to wait for auth-req from peer */
114 | } upap_state;
115 |
116 |
117 | /***********************
118 | *** PUBLIC FUNCTIONS ***
119 | ***********************/
120 |
121 | extern upap_state upap[];
122 |
123 | void upap_setloginpasswd(int unit, const char *luser, const char *lpassword);
124 | void upap_authwithpeer (int, char *, char *);
125 | void upap_authpeer (int);
126 |
127 | extern struct protent pap_protent;
128 |
129 | #endif /* PAP_SUPPORT */
130 |
131 | #endif /* PAP_H */
132 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/pppdebug.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * pppdebug.h - System debugging utilities.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * portions Copyright (c) 1998 Global Election Systems Inc.
6 | * portions Copyright (c) 2001 by Cognizant Pty Ltd.
7 | *
8 | * The authors hereby grant permission to use, copy, modify, distribute,
9 | * and license this software and its documentation for any purpose, provided
10 | * that existing copyright notices are retained in all copies and that this
11 | * notice and the following disclaimer are included verbatim in any
12 | * distributions. No written agreement, license, or royalty fee is required
13 | * for any of the authorized uses.
14 | *
15 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 | *
26 | ******************************************************************************
27 | * REVISION HISTORY (please don't use tabs!)
28 | *
29 | * 03-01-01 Marc Boucher
30 | * Ported to lwIP.
31 | * 98-07-29 Guy Lancaster , Global Election Systems Inc.
32 | * Original.
33 | *
34 | *****************************************************************************
35 | */
36 | #ifndef PPPDEBUG_H
37 | #define PPPDEBUG_H
38 |
39 | /************************
40 | *** PUBLIC DATA TYPES ***
41 | ************************/
42 | /* Trace levels. */
43 | typedef enum {
44 | LOG_CRITICAL = 0,
45 | LOG_ERR = 1,
46 | LOG_NOTICE = 2,
47 | LOG_WARNING = 3,
48 | LOG_INFO = 5,
49 | LOG_DETAIL = 6,
50 | LOG_DEBUG = 7
51 | } LogCodes;
52 |
53 |
54 | /***********************
55 | *** PUBLIC FUNCTIONS ***
56 | ***********************/
57 | /*
58 | * ppp_trace - a form of printf to send tracing information to stderr
59 | */
60 | void ppp_trace(int level, const char *format,...);
61 |
62 | #define TRACELCP PPP_DEBUG
63 |
64 | #if PPP_DEBUG
65 |
66 | #define AUTHDEBUG(a) ppp_trace a
67 | #define IPCPDEBUG(a) ppp_trace a
68 | #define UPAPDEBUG(a) ppp_trace a
69 | #define LCPDEBUG(a) ppp_trace a
70 | #define FSMDEBUG(a) ppp_trace a
71 | #define CHAPDEBUG(a) ppp_trace a
72 | #define PPPDEBUG(a) ppp_trace a
73 |
74 | #else /* PPP_DEBUG */
75 |
76 | #define AUTHDEBUG(a)
77 | #define IPCPDEBUG(a)
78 | #define UPAPDEBUG(a)
79 | #define LCPDEBUG(a)
80 | #define FSMDEBUG(a)
81 | #define CHAPDEBUG(a)
82 | #define PPPDEBUG(a)
83 |
84 | #endif /* PPP_DEBUG */
85 |
86 | #endif /* PPPDEBUG_H */
87 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/randm.h:
--------------------------------------------------------------------------------
1 | /*****************************************************************************
2 | * randm.h - Random number generator header file.
3 | *
4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
5 | * Copyright (c) 1998 Global Election Systems Inc.
6 | *
7 | * The authors hereby grant permission to use, copy, modify, distribute,
8 | * and license this software and its documentation for any purpose, provided
9 | * that existing copyright notices are retained in all copies and that this
10 | * notice and the following disclaimer are included verbatim in any
11 | * distributions. No written agreement, license, or royalty fee is required
12 | * for any of the authorized uses.
13 | *
14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR
15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 | *
25 | ******************************************************************************
26 | * REVISION HISTORY
27 | *
28 | * 03-01-01 Marc Boucher
29 | * Ported to lwIP.
30 | * 98-05-29 Guy Lancaster , Global Election Systems Inc.
31 | * Extracted from avos.
32 | *****************************************************************************/
33 |
34 | #ifndef RANDM_H
35 | #define RANDM_H
36 |
37 | /***********************
38 | *** PUBLIC FUNCTIONS ***
39 | ***********************/
40 | /*
41 | * Initialize the random number generator.
42 | */
43 | void avRandomInit(void);
44 |
45 | /*
46 | * Churn the randomness pool on a random event. Call this early and often
47 | * on random and semi-random system events to build randomness in time for
48 | * usage. For randomly timed events, pass a null pointer and a zero length
49 | * and this will use the system timer and other sources to add randomness.
50 | * If new random data is available, pass a pointer to that and it will be
51 | * included.
52 | */
53 | void avChurnRand(char *randData, u32_t randLen);
54 |
55 | /*
56 | * Randomize our random seed value. To be called for truely random events
57 | * such as user operations and network traffic.
58 | */
59 | #if MD5_SUPPORT
60 | #define avRandomize() avChurnRand(NULL, 0)
61 | #else /* MD5_SUPPORT */
62 | void avRandomize(void);
63 | #endif /* MD5_SUPPORT */
64 |
65 | /*
66 | * Use the random pool to generate random data. This degrades to pseudo
67 | * random when used faster than randomness is supplied using churnRand().
68 | * Thus it's important to make sure that the results of this are not
69 | * published directly because one could predict the next result to at
70 | * least some degree. Also, it's important to get a good seed before
71 | * the first use.
72 | */
73 | void avGenRand(char *buf, u32_t bufLen);
74 |
75 | /*
76 | * Return a new random number.
77 | */
78 | u32_t avRandom(void);
79 |
80 |
81 | #endif /* RANDM_H */
82 |
--------------------------------------------------------------------------------
/lwip/netif/ppp/vjbsdhdr.h:
--------------------------------------------------------------------------------
1 | #ifndef VJBSDHDR_H
2 | #define VJBSDHDR_H
3 |
4 | #include "lwip/tcp.h"
5 |
6 | /*
7 | * Structure of an internet header, naked of options.
8 | *
9 | * We declare ip_len and ip_off to be short, rather than u_short
10 | * pragmatically since otherwise unsigned comparisons can result
11 | * against negative integers quite easily, and fail in subtle ways.
12 | */
13 | PACK_STRUCT_BEGIN
14 | struct ip
15 | {
16 | #if defined(NO_CHAR_BITFIELDS)
17 | u_char ip_hl_v; /* bug in GCC for mips means the bitfield stuff will sometimes break - so we use a char for both and get round it with macro's instead... */
18 | #else
19 | #if BYTE_ORDER == LITTLE_ENDIAN
20 | unsigned ip_hl:4, /* header length */
21 | ip_v :4; /* version */
22 | #elif BYTE_ORDER == BIG_ENDIAN
23 | unsigned ip_v :4, /* version */
24 | ip_hl:4; /* header length */
25 | #else
26 | COMPLAIN - NO BYTE ORDER SELECTED!
27 | #endif
28 | #endif
29 | u_char ip_tos; /* type of service */
30 | u_short ip_len; /* total length */
31 | u_short ip_id; /* identification */
32 | u_short ip_off; /* fragment offset field */
33 | #define IP_DF 0x4000 /* dont fragment flag */
34 | #define IP_MF 0x2000 /* more fragments flag */
35 | #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
36 | u_char ip_ttl; /* time to live */
37 | u_char ip_p; /* protocol */
38 | u_short ip_sum; /* checksum */
39 | struct in_addr ip_src,ip_dst; /* source and dest address */
40 | };
41 | PACK_STRUCT_END
42 |
43 | typedef u32_t tcp_seq;
44 |
45 | /*
46 | * TCP header.
47 | * Per RFC 793, September, 1981.
48 | */
49 | PACK_STRUCT_BEGIN
50 | struct tcphdr
51 | {
52 | u_short th_sport; /* source port */
53 | u_short th_dport; /* destination port */
54 | tcp_seq th_seq; /* sequence number */
55 | tcp_seq th_ack; /* acknowledgement number */
56 | #if defined(NO_CHAR_BITFIELDS)
57 | u_char th_x2_off;
58 | #else
59 | #if BYTE_ORDER == LITTLE_ENDIAN
60 | unsigned th_x2 :4, /* (unused) */
61 | th_off:4; /* data offset */
62 | #endif
63 | #if BYTE_ORDER == BIG_ENDIAN
64 | unsigned th_off:4, /* data offset */
65 | th_x2 :4; /* (unused) */
66 | #endif
67 | #endif
68 | u_char th_flags;
69 | u_short th_win; /* window */
70 | u_short th_sum; /* checksum */
71 | u_short th_urp; /* urgent pointer */
72 | };
73 | PACK_STRUCT_END
74 |
75 | #endif /* VJBSDHDR_H */
76 |
--------------------------------------------------------------------------------
/lwipwin32.c:
--------------------------------------------------------------------------------
1 | // lwipwin32.cpp : Defines the entry point for the console application.
2 | //
3 | #include
4 |
5 | #include "lwip/netif.h"
6 | #include "lwip/tcpip.h"
7 | #include "lwip/mem.h"
8 | #include "lwip/memp.h"
9 | #include "net_tap.h"
10 |
11 | extern err_t ethernetif_init(struct netif *netif);
12 | extern void http_init();
13 | extern void http_task();
14 |
15 | void init()
16 | {
17 | struct ip_addr ip, mask, gw;
18 | static struct netif netif;
19 |
20 | // see SYS_ARCH_PROTECT
21 | InitializeCriticalSection(&gCriticalSection);
22 |
23 | tcpip_init(NULL, NULL);
24 |
25 | // simple server
26 | sys_thread_new("http thread", http_task, NULL, 0, 0);
27 | //http_init();
28 |
29 | IP4_ADDR(&ip, 192, 168, 80, 161);
30 | IP4_ADDR(&mask, 255, 255, 255, 0);
31 | IP4_ADDR(&gw, 192, 168, 80, 201);
32 |
33 | netif_add(&netif, &ip, &mask, &gw, NULL, ethernetif_init, tcpip_input);
34 | netif_set_default(&netif);
35 | netif_set_up(&netif);
36 | }
37 |
38 | int main(int argc, char* argv[])
39 | {
40 | if (ERR_IF == open_tap())
41 | exit(1);
42 |
43 | init();
44 |
45 | while(TRUE)
46 | Sleep(1000);
47 |
48 | // Todo close_dev();
49 |
50 | return 0;
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/lwipwin32.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 10.00
3 | # Visual Studio 2008
4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lwipwin32", "lwipwin32.vcproj", "{E6268586-30C6-413F-A12C-5018A83B4593}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Win32 = Debug|Win32
9 | Release|Win32 = Release|Win32
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {E6268586-30C6-413F-A12C-5018A83B4593}.Debug|Win32.ActiveCfg = Debug|Win32
13 | {E6268586-30C6-413F-A12C-5018A83B4593}.Debug|Win32.Build.0 = Debug|Win32
14 | {E6268586-30C6-413F-A12C-5018A83B4593}.Release|Win32.ActiveCfg = Release|Win32
15 | {E6268586-30C6-413F-A12C-5018A83B4593}.Release|Win32.Build.0 = Release|Win32
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | EndGlobal
21 |
--------------------------------------------------------------------------------
/pcap/Include/Devioctl.h:
--------------------------------------------------------------------------------
1 | /*++ BUILD Version: 0004 // Increment this if a change has global effects
2 | Copyright (c) 1992-1993 Microsoft Corporation
3 | Module Name:
4 | devioctl.h
5 | Revision History:
6 | -- */
7 | // begin_winioctl
8 | #ifndef _DEVIOCTL_
9 | #define _DEVIOCTL_
10 | // begin_ntddk begin_nthal begin_ntifs
11 | //
12 | // Define the various device type values. Note that values used by Microsoft
13 | // Corporation are in the range 0-32767, and 32768-65535 are reserved for use
14 | // by customers.
15 | //
16 | #define DEVICE_TYPE ULONG
17 | #define FILE_DEVICE_BEEP 0x00000001
18 | #define FILE_DEVICE_CD_ROM 0x00000002
19 | #define FILE_DEVICE_CD_ROM_FILE_SYSTEM 0x00000003
20 | #define FILE_DEVICE_CONTROLLER 0x00000004
21 | #define FILE_DEVICE_DATALINK 0x00000005
22 | #define FILE_DEVICE_DFS 0x00000006
23 | #define FILE_DEVICE_DISK 0x00000007
24 | #define FILE_DEVICE_DISK_FILE_SYSTEM 0x00000008
25 | #define FILE_DEVICE_FILE_SYSTEM 0x00000009
26 | #define FILE_DEVICE_INPORT_PORT 0x0000000a
27 | #define FILE_DEVICE_KEYBOARD 0x0000000b
28 | #define FILE_DEVICE_MAILSLOT 0x0000000c
29 | #define FILE_DEVICE_MIDI_IN 0x0000000d
30 | #define FILE_DEVICE_MIDI_OUT 0x0000000e
31 | #define FILE_DEVICE_MOUSE 0x0000000f
32 | #define FILE_DEVICE_MULTI_UNC_PROVIDER 0x00000010
33 | #define FILE_DEVICE_NAMED_PIPE 0x00000011
34 | #define FILE_DEVICE_NETWORK 0x00000012
35 | #define FILE_DEVICE_NETWORK_BROWSER 0x00000013
36 | #define FILE_DEVICE_NETWORK_FILE_SYSTEM 0x00000014
37 | #define FILE_DEVICE_NULL 0x00000015
38 | #define FILE_DEVICE_PARALLEL_PORT 0x00000016
39 | #define FILE_DEVICE_PHYSICAL_NETCARD 0x00000017
40 | #define FILE_DEVICE_PRINTER 0x00000018
41 | #define FILE_DEVICE_SCANNER 0x00000019
42 | #define FILE_DEVICE_SERIAL_MOUSE_PORT 0x0000001a
43 | #define FILE_DEVICE_SERIAL_PORT 0x0000001b
44 | #define FILE_DEVICE_SCREEN 0x0000001c
45 | #define FILE_DEVICE_SOUND 0x0000001d
46 | #define FILE_DEVICE_STREAMS 0x0000001e
47 | #define FILE_DEVICE_TAPE 0x0000001f
48 | #define FILE_DEVICE_TAPE_FILE_SYSTEM 0x00000020
49 | #define FILE_DEVICE_TRANSPORT 0x00000021
50 | #define FILE_DEVICE_UNKNOWN 0x00000022
51 | #define FILE_DEVICE_VIDEO 0x00000023
52 | #define FILE_DEVICE_VIRTUAL_DISK 0x00000024
53 | #define FILE_DEVICE_WAVE_IN 0x00000025
54 | #define FILE_DEVICE_WAVE_OUT 0x00000026
55 | #define FILE_DEVICE_8042_PORT 0x00000027
56 | #define FILE_DEVICE_NETWORK_REDIRECTOR 0x00000028
57 | #define FILE_DEVICE_BATTERY 0x00000029
58 | #define FILE_DEVICE_BUS_EXTENDER 0x0000002a
59 | #define FILE_DEVICE_MODEM 0x0000002b
60 | #define FILE_DEVICE_VDM 0x0000002c
61 | #define FILE_DEVICE_MASS_STORAGE 0x0000002d
62 | //
63 | // Macro definition for defining IOCTL and FSCTL function control codes. Note
64 | // that function codes 0-2047 are reserved for Microsoft Corporation, and
65 | // 2048-4095 are reserved for customers.
66 | //
67 | #define CTL_CODE( DeviceType, Function, Method, Access ) ( \
68 | ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
69 | )
70 | //
71 | // Define the method codes for how buffers are passed for I/O and FS controls
72 | //
73 | #define METHOD_BUFFERED 0
74 | #define METHOD_IN_DIRECT 1
75 | #define METHOD_OUT_DIRECT 2
76 | #define METHOD_NEITHER 3
77 | //
78 | // Define the access check value for any access
79 | //
80 | //
81 | // The FILE_READ_ACCESS and FILE_WRITE_ACCESS constants are also defined in
82 | // ntioapi.h as FILE_READ_DATA and FILE_WRITE_DATA. The values for these
83 | // constants *MUST* always be in sync.
84 | //
85 | #define FILE_ANY_ACCESS 0
86 | #define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
87 | #define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe
88 | // end_ntddk end_nthal end_ntifs
89 | #endif // _DEVIOCTL_
90 | // end_winioctl
91 |
--------------------------------------------------------------------------------
/pcap/Include/Gnuc.h:
--------------------------------------------------------------------------------
1 | /* @(#) $Header: /tcpdump/master/libpcap/Win32/Include/Gnuc.h,v 1.1 2002/08/01 08:33:05 risso Exp $ (LBL) */
2 |
3 | /* Define __P() macro, if necessary */
4 |
5 | #ifndef __P
6 | #if __STDC__
7 | #define __P(protos) protos
8 | #else
9 | #define __P(protos) ()
10 | #endif
11 | #endif
12 |
13 | /* inline foo */
14 | #ifndef __cplusplus
15 | #ifdef __GNUC__
16 | #define inline __inline
17 | #else
18 | #define inline
19 | #endif
20 | #endif
21 |
22 | /*
23 | * Handle new and old "dead" routine prototypes
24 | *
25 | * For example:
26 | *
27 | * __dead void foo(void) __attribute__((volatile));
28 | *
29 | */
30 | #ifdef __GNUC__
31 | #ifndef __dead
32 | #define __dead volatile
33 | #endif
34 | #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
35 | #ifndef __attribute__
36 | #define __attribute__(args)
37 | #endif
38 | #endif
39 | #else
40 | #ifndef __dead
41 | #define __dead
42 | #endif
43 | #ifndef __attribute__
44 | #define __attribute__(args)
45 | #endif
46 | #endif
47 |
--------------------------------------------------------------------------------
/pcap/Include/Ntddpack.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef __NTDDPACKET
3 | #define __NTDDPACKET 1
4 | #include "devioctl.h"
5 | /*#include */
6 | struct _PACKET_OID_DATA {
7 | ULONG Oid;
8 | ULONG Length;
9 | UCHAR Data[1];
10 | };
11 |
12 | typedef struct _PACKET_OID_DATA PACKET_OID_DATA, *PPACKET_OID_DATA;
13 |
14 | /*#include */
15 | #define FILE_DEVICE_PROTOCOL 0x8000
16 | #define IOCTL_PROTOCOL_QUERY_OID CTL_CODE(FILE_DEVICE_PROTOCOL, 0 , METHOD_BUFFERED, FILE_ANY_ACCESS)
17 | #define IOCTL_PROTOCOL_SET_OID CTL_CODE(FILE_DEVICE_PROTOCOL, 1 , METHOD_BUFFERED, FILE_ANY_ACCESS)
18 | #define IOCTL_PROTOCOL_STATISTICS CTL_CODE(FILE_DEVICE_PROTOCOL, 2 , METHOD_BUFFERED, FILE_ANY_ACCESS)
19 | #define IOCTL_PROTOCOL_RESET CTL_CODE(FILE_DEVICE_PROTOCOL, 3 , METHOD_BUFFERED, FILE_ANY_ACCESS)
20 | #define IOCTL_PROTOCOL_READ CTL_CODE(FILE_DEVICE_PROTOCOL, 4 , METHOD_BUFFERED, FILE_ANY_ACCESS)
21 | #define IOCTL_PROTOCOL_WRITE CTL_CODE(FILE_DEVICE_PROTOCOL, 5 , METHOD_BUFFERED, FILE_ANY_ACCESS)
22 | #define IOCTL_PROTOCOL_MACNAME CTL_CODE(FILE_DEVICE_PROTOCOL, 6 , METHOD_BUFFERED, FILE_ANY_ACCESS)
23 | #define IOCTL_OPEN CTL_CODE(FILE_DEVICE_PROTOCOL, 7 , METHOD_BUFFERED, FILE_ANY_ACCESS)
24 | #define IOCTL_CLOSE CTL_CODE(FILE_DEVICE_PROTOCOL, 8 , METHOD_BUFFERED, FILE_ANY_ACCESS)
25 |
26 | #endif
27 |
--------------------------------------------------------------------------------
/pcap/Include/Win32-Extensions.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies
16 | * nor the names of its contributors may be used to endorse or promote
17 | * products derived from this software without specific prior written
18 | * permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | *
32 | */
33 |
34 | #ifndef __WIN32_EXTENSIONS_H__
35 | #define __WIN32_EXTENSIONS_H__
36 |
37 | #ifdef __cplusplus
38 | extern "C" {
39 | #endif
40 |
41 | /* Definitions */
42 |
43 | /*!
44 | \brief A queue of raw packets that will be sent to the network with pcap_sendqueue_transmit().
45 | */
46 | struct pcap_send_queue
47 | {
48 | u_int maxlen; ///< Maximum size of the the queue, in bytes. This variable contains the size of the buffer field.
49 | u_int len; ///< Current size of the queue, in bytes.
50 | char *buffer; ///< Buffer containing the packets to be sent.
51 | };
52 |
53 | typedef struct pcap_send_queue pcap_send_queue;
54 |
55 | /*!
56 | \brief This typedef is a support for the pcap_get_airpcap_handle() function
57 | */
58 | #if !defined(AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_)
59 | #define AIRPCAP_HANDLE__EAE405F5_0171_9592_B3C2_C19EC426AD34__DEFINED_
60 | typedef struct _AirpcapHandle *PAirpcapHandle;
61 | #endif
62 |
63 | #define BPF_MEM_EX_IMM 0xc0
64 | #define BPF_MEM_EX_IND 0xe0
65 |
66 | /*used for ST*/
67 | #define BPF_MEM_EX 0xc0
68 | #define BPF_TME 0x08
69 |
70 | #define BPF_LOOKUP 0x90
71 | #define BPF_EXECUTE 0xa0
72 | #define BPF_INIT 0xb0
73 | #define BPF_VALIDATE 0xc0
74 | #define BPF_SET_ACTIVE 0xd0
75 | #define BPF_RESET 0xe0
76 | #define BPF_SET_MEMORY 0x80
77 | #define BPF_GET_REGISTER_VALUE 0x70
78 | #define BPF_SET_REGISTER_VALUE 0x60
79 | #define BPF_SET_WORKING 0x50
80 | #define BPF_SET_ACTIVE_READ 0x40
81 | #define BPF_SET_AUTODELETION 0x30
82 | #define BPF_SEPARATION 0xff
83 |
84 | /* Prototypes */
85 | pcap_send_queue* pcap_sendqueue_alloc(u_int memsize);
86 |
87 | void pcap_sendqueue_destroy(pcap_send_queue* queue);
88 |
89 | int pcap_sendqueue_queue(pcap_send_queue* queue, const struct pcap_pkthdr *pkt_header, const u_char *pkt_data);
90 |
91 | u_int pcap_sendqueue_transmit(pcap_t *p, pcap_send_queue* queue, int sync);
92 |
93 | HANDLE pcap_getevent(pcap_t *p);
94 |
95 | struct pcap_stat *pcap_stats_ex(pcap_t *p, int *pcap_stat_size);
96 |
97 | int pcap_setuserbuffer(pcap_t *p, int size);
98 |
99 | int pcap_live_dump(pcap_t *p, char *filename, int maxsize, int maxpacks);
100 |
101 | int pcap_live_dump_ended(pcap_t *p, int sync);
102 |
103 | int pcap_offline_filter(struct bpf_program *prog, const struct pcap_pkthdr *header, const u_char *pkt_data);
104 |
105 | int pcap_start_oem(char* err_str, int flags);
106 |
107 | PAirpcapHandle pcap_get_airpcap_handle(pcap_t *p);
108 |
109 | #ifdef __cplusplus
110 | }
111 | #endif
112 |
113 | #endif //__WIN32_EXTENSIONS_H__
114 |
--------------------------------------------------------------------------------
/pcap/Include/bittypes.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 1999 WIDE Project.
3 | * All rights reserved.
4 | *
5 | * Redistribution and use in source and binary forms, with or without
6 | * modification, are permitted provided that the following conditions
7 | * are met:
8 | * 1. Redistributions of source code must retain the above copyright
9 | * notice, this list of conditions and the following disclaimer.
10 | * 2. Redistributions in binary form must reproduce the above copyright
11 | * notice, this list of conditions and the following disclaimer in the
12 | * documentation and/or other materials provided with the distribution.
13 | * 3. Neither the name of the project nor the names of its contributors
14 | * may be used to endorse or promote products derived from this software
15 | * without specific prior written permission.
16 | *
17 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 | * SUCH DAMAGE.
28 | */
29 | #ifndef _BITTYPES_H
30 | #define _BITTYPES_H
31 |
32 | #ifndef HAVE_U_INT8_T
33 |
34 | #if SIZEOF_CHAR == 1
35 | typedef unsigned char u_int8_t;
36 | typedef signed char int8_t;
37 | #elif SIZEOF_INT == 1
38 | typedef unsigned int u_int8_t;
39 | typedef signed int int8_t;
40 | #else /* XXX */
41 | #error "there's no appropriate type for u_int8_t"
42 | #endif
43 | #define HAVE_U_INT8_T 1
44 | #define HAVE_INT8_T 1
45 |
46 | #endif /* HAVE_U_INT8_T */
47 |
48 | #ifndef HAVE_U_INT16_T
49 |
50 | #if SIZEOF_SHORT == 2
51 | typedef unsigned short u_int16_t;
52 | typedef signed short int16_t;
53 | #elif SIZEOF_INT == 2
54 | typedef unsigned int u_int16_t;
55 | typedef signed int int16_t;
56 | #elif SIZEOF_CHAR == 2
57 | typedef unsigned char u_int16_t;
58 | typedef signed char int16_t;
59 | #else /* XXX */
60 | #error "there's no appropriate type for u_int16_t"
61 | #endif
62 | #define HAVE_U_INT16_T 1
63 | #define HAVE_INT16_T 1
64 |
65 | #endif /* HAVE_U_INT16_T */
66 |
67 | #ifndef HAVE_U_INT32_T
68 |
69 | #if SIZEOF_INT == 4
70 | typedef unsigned int u_int32_t;
71 | typedef signed int int32_t;
72 | #elif SIZEOF_LONG == 4
73 | typedef unsigned long u_int32_t;
74 | typedef signed long int32_t;
75 | #elif SIZEOF_SHORT == 4
76 | typedef unsigned short u_int32_t;
77 | typedef signed short int32_t;
78 | #else /* XXX */
79 | #error "there's no appropriate type for u_int32_t"
80 | #endif
81 | #define HAVE_U_INT32_T 1
82 | #define HAVE_INT32_T 1
83 |
84 | #endif /* HAVE_U_INT32_T */
85 |
86 | #ifndef HAVE_U_INT64_T
87 | #if SIZEOF_LONG_LONG == 8
88 | typedef unsigned long long u_int64_t;
89 | #elif defined(_MSC_EXTENSIONS)
90 | typedef unsigned _int64 u_int64_t;
91 | #elif SIZEOF_INT == 8
92 | typedef unsigned int u_int64_t;
93 | #elif SIZEOF_LONG == 8
94 | typedef unsigned long u_int64_t;
95 | #elif SIZEOF_SHORT == 8
96 | typedef unsigned short u_int64_t;
97 | #else /* XXX */
98 | #error "there's no appropriate type for u_int64_t"
99 | #endif
100 |
101 | #endif /* HAVE_U_INT64_T */
102 |
103 | #ifndef PRId64
104 | #ifdef _MSC_EXTENSIONS
105 | #define PRId64 "I64d"
106 | #else /* _MSC_EXTENSIONS */
107 | #define PRId64 "lld"
108 | #endif /* _MSC_EXTENSIONS */
109 | #endif /* PRId64 */
110 |
111 | #ifndef PRIo64
112 | #ifdef _MSC_EXTENSIONS
113 | #define PRIo64 "I64o"
114 | #else /* _MSC_EXTENSIONS */
115 | #define PRIo64 "llo"
116 | #endif /* _MSC_EXTENSIONS */
117 | #endif /* PRIo64 */
118 |
119 | #ifndef PRIx64
120 | #ifdef _MSC_EXTENSIONS
121 | #define PRIx64 "I64x"
122 | #else /* _MSC_EXTENSIONS */
123 | #define PRIx64 "llx"
124 | #endif /* _MSC_EXTENSIONS */
125 | #endif /* PRIx64 */
126 |
127 | #ifndef PRIu64
128 | #ifdef _MSC_EXTENSIONS
129 | #define PRIu64 "I64u"
130 | #else /* _MSC_EXTENSIONS */
131 | #define PRIu64 "llu"
132 | #endif /* _MSC_EXTENSIONS */
133 | #endif /* PRIu64 */
134 |
135 | #endif /* _BITTYPES_H */
136 |
--------------------------------------------------------------------------------
/pcap/Include/bucket_lookup.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001 - 2003
3 | * NetGroup, Politecnico di Torino (Italy)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino nor the names of its
16 | * contributors may be used to endorse or promote products derived from
17 | * this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | */
32 |
33 | #ifndef __bucket_lookup
34 | #define __bucket_lookup
35 | #ifdef WIN32
36 | #include "tme.h"
37 | #endif
38 |
39 | #ifdef __FreeBSD__
40 |
41 | #ifdef _KERNEL
42 | #include
43 | #else
44 | #include
45 | #endif
46 |
47 | #endif
48 |
49 | #define BUCKET_LOOKUP_INSERT 0x00000011
50 | uint32 bucket_lookup_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref);
51 | #define BUCKET_LOOKUP 0x00000010
52 | uint32 bucket_lookup(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref);
53 |
54 | #endif
--------------------------------------------------------------------------------
/pcap/Include/count_packets.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001 - 2003
3 | * NetGroup, Politecnico di Torino (Italy)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino nor the names of its
16 | * contributors may be used to endorse or promote products derived from
17 | * this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | */
32 |
33 | #ifndef __count_packets
34 | #define __count_packets
35 |
36 | #ifdef WIN32
37 | #include "tme.h"
38 | #endif
39 |
40 | #ifdef __FreeBSD__
41 |
42 | #ifdef _KERNEL
43 | #include
44 | #else
45 | #include
46 | #endif
47 |
48 | #endif
49 |
50 | typedef struct __c_p_data
51 | {
52 | struct timeval timestamp;
53 | uint64 packets;
54 | uint64 bytes;
55 | }
56 | c_p_data;
57 |
58 | #define COUNT_PACKETS 0x00000000
59 | uint32 count_packets(uint8 *block, uint32 pkt_size, TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data);
60 |
61 | #endif
62 |
63 |
--------------------------------------------------------------------------------
/pcap/Include/memory_t.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001 - 2005 NetGroup, Politecnico di Torino (Italy)
3 | * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino, CACE Technologies
16 | * nor the names of its contributors may be used to endorse or promote
17 | * products derived from this software without specific prior written
18 | * permission.
19 | *
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | *
32 | */
33 |
34 | #ifndef __memory_t
35 | #define __memory_t
36 |
37 | #define uint8 UCHAR
38 | #define int8 CHAR
39 | #define uint16 USHORT
40 | #define int16 SHORT
41 | #define uint32 ULONG
42 | #define int32 LONG
43 | #define uint64 ULONGLONG
44 | #define int64 LONGLONG
45 |
46 | /*memory type*/
47 | typedef struct __MEM_TYPE
48 | {
49 | uint8 *buffer;
50 | uint32 size;
51 | } MEM_TYPE, *PMEM_TYPE;
52 |
53 | #define LONG_AT(base,offset) (*(int32*)((uint8*)base+(uint32)offset))
54 |
55 | #define ULONG_AT(base,offset) (*(uint32*)((uint8*)base+(uint32)offset))
56 |
57 | #define SHORT_AT(base,offset) (*(int16*)((uint8*)base+(uint32)offset))
58 |
59 | #define USHORT_AT(base,offset) (*(uint16*)((uint8*)base+(uint32)offset))
60 |
61 | __inline int32 SW_LONG_AT(void *b, uint32 c)
62 | {
63 | return ((int32)*((uint8 *)b+c)<<24|
64 | (int32)*((uint8 *)b+c+1)<<16|
65 | (int32)*((uint8 *)b+c+2)<<8|
66 | (int32)*((uint8 *)b+c+3)<<0);
67 | }
68 |
69 |
70 | __inline uint32 SW_ULONG_AT(void *b, uint32 c)
71 | {
72 | return ((uint32)*((uint8 *)b+c)<<24|
73 | (uint32)*((uint8 *)b+c+1)<<16|
74 | (uint32)*((uint8 *)b+c+2)<<8|
75 | (uint32)*((uint8 *)b+c+3)<<0);
76 | }
77 |
78 | __inline int16 SW_SHORT_AT(void *b, uint32 os)
79 | {
80 | return ((int16)
81 | ((int16)*((uint8 *)b+os+0)<<8|
82 | (int16)*((uint8 *)b+os+1)<<0));
83 | }
84 |
85 | __inline uint16 SW_USHORT_AT(void *b, uint32 os)
86 | {
87 | return ((uint16)
88 | ((uint16)*((uint8 *)b+os+0)<<8|
89 | (uint16)*((uint8 *)b+os+1)<<0));
90 | }
91 |
92 | __inline VOID SW_ULONG_ASSIGN(void *dst, uint32 src)
93 | {
94 | *((uint8*)dst+0)=*((uint8*)&src+3);
95 | *((uint8*)dst+1)=*((uint8*)&src+2);
96 | *((uint8*)dst+2)=*((uint8*)&src+1);
97 | *((uint8*)dst+3)=*((uint8*)&src+0);
98 |
99 | }
100 |
101 | #ifdef WIN_NT_DRIVER
102 |
103 | #define ALLOCATE_MEMORY(dest,type,amount) \
104 | (dest)=ExAllocatePoolWithTag(NonPagedPool,sizeof(type)*(amount), '0TWA');
105 | #define ALLOCATE_ZERO_MEMORY(dest,type,amount) \
106 | { \
107 | (dest)=ExAllocatePoolWithTag(NonPagedPool,sizeof(type)*(amount), '1TWA'); \
108 | if ((dest)!=NULL) \
109 | RtlZeroMemory((dest),sizeof(type)*(amount)); \
110 | }
111 |
112 | #define FREE_MEMORY(dest) ExFreePool(dest);
113 | #define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount);
114 | #define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount);
115 |
116 | #else
117 |
118 | #define ALLOCATE_MEMORY(dest,type,amount) \
119 | (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount));
120 | #define ALLOCATE_ZERO_MEMORY(dest,type,amount) \
121 | (dest)=(type*)GlobalAlloc(GPTR, sizeof(type)*(amount));
122 |
123 | #define FREE_MEMORY(dest) GlobalFree(dest);
124 | #define ZERO_MEMORY(dest,amount) RtlZeroMemory(dest,amount);
125 | #define COPY_MEMORY(dest,src,amount) RtlCopyMemory(dest,src,amount);
126 |
127 |
128 | #endif /*WIN_NT_DRIVER*/
129 |
130 |
131 |
132 | #endif
133 |
134 |
--------------------------------------------------------------------------------
/pcap/Include/net_tap.h:
--------------------------------------------------------------------------------
1 | #ifndef __PCAP_IF_H__
2 | #define __PCAP_IF_H__
3 |
4 | #ifdef __cplusplus
5 | extern "C" {
6 | #endif
7 |
8 | err_t open_tap();
9 | err_t close_tap();
10 | err_t get_packet(unsigned int* len, char** pkt_data);
11 | err_t send_packet(char** buf, int len);
12 |
13 | #ifdef __cplusplus
14 | }
15 | #endif
16 |
17 | #endif
--------------------------------------------------------------------------------
/pcap/Include/normal_lookup.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001 - 2003
3 | * NetGroup, Politecnico di Torino (Italy)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino nor the names of its
16 | * contributors may be used to endorse or promote products derived from
17 | * this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | */
32 |
33 | #ifndef __normal_lookup
34 | #define __normal_lookup
35 |
36 | #ifdef WIN32
37 | #include "tme.h"
38 | #endif
39 |
40 | #ifdef __FreeBSD__
41 |
42 | #ifdef _KERNEL
43 | #include
44 | #else
45 | #include
46 | #endif
47 |
48 | #endif
49 |
50 | #define NORMAL_LUT_W_INSERT 0x00000000
51 | uint32 normal_lut_w_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref);
52 | #define NORMAL_LUT_WO_INSERT 0x00000001
53 | uint32 normal_lut_wo_insert(uint8 *key, TME_DATA *data, MEM_TYPE *mem_ex, struct time_conv *time_ref);
54 | #define DUMMY_INSERT 1234
55 |
56 | #endif
--------------------------------------------------------------------------------
/pcap/Include/pcap-stdinc.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2002 - 2003
3 | * NetGroup, Politecnico di Torino (Italy)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino nor the names of its
16 | * contributors may be used to endorse or promote products derived from
17 | * this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | */
32 |
33 | #define SIZEOF_CHAR 1
34 | #define SIZEOF_SHORT 2
35 | #define SIZEOF_INT 4
36 | #ifndef _MSC_EXTENSIONS
37 | #define SIZEOF_LONG_LONG 8
38 | #endif
39 |
40 | /*
41 | * Avoids a compiler warning in case this was already defined
42 | * (someone defined _WINSOCKAPI_ when including 'windows.h', in order
43 | * to prevent it from including 'winsock.h')
44 | */
45 | #ifdef _WINSOCKAPI_
46 | #undef _WINSOCKAPI_
47 | #endif
48 | #include
49 |
50 | #include
51 |
52 | #include "bittypes.h"
53 | #include
54 | #include
55 |
56 | #ifndef __MINGW32__
57 | #include "IP6_misc.h"
58 | #endif
59 |
60 | #define caddr_t char*
61 |
62 | #define snprintf _snprintf
63 | #define vsnprintf _vsnprintf
64 | #define inline __inline
65 |
--------------------------------------------------------------------------------
/pcap/Include/tcp_session.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2001 - 2003
3 | * NetGroup, Politecnico di Torino (Italy)
4 | * All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * 1. Redistributions of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | * 2. Redistributions in binary form must reproduce the above copyright
13 | * notice, this list of conditions and the following disclaimer in the
14 | * documentation and/or other materials provided with the distribution.
15 | * 3. Neither the name of the Politecnico di Torino nor the names of its
16 | * contributors may be used to endorse or promote products derived from
17 | * this software without specific prior written permission.
18 | *
19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 | *
31 | */
32 |
33 | #ifndef __tcp_session
34 | #define __tcp_session
35 |
36 | #ifdef WIN32
37 | #include "tme.h"
38 | #endif
39 |
40 | #ifdef __FreeBSD__
41 |
42 | #ifdef _KERNEL
43 | #include
44 | #else
45 | #include
46 | #endif
47 |
48 | #endif
49 |
50 | #define UNKNOWN 0
51 | #define SYN_RCV 1
52 | #define SYN_ACK_RCV 2
53 | #define ESTABLISHED 3
54 | #define CLOSED_RST 4
55 | #define FIN_CLN_RCV 5
56 | #define FIN_SRV_RCV 6
57 | #define CLOSED_FIN 7
58 | #define ERROR_TCP 8
59 | #define FIRST_IS_CLN 0
60 | #define FIRST_IS_SRV 0xffffffff
61 | #define FIN_CLN 1
62 | #define FIN_SRV 2
63 |
64 | #define MAX_WINDOW 65536
65 |
66 | typedef struct __tcp_data
67 | {
68 | struct timeval timestamp_block; /*DO NOT MOVE THIS VALUE*/
69 | struct timeval syn_timestamp;
70 | struct timeval last_timestamp;
71 | struct timeval syn_ack_timestamp;
72 | uint32 direction;
73 | uint32 seq_n_0_srv;
74 | uint32 seq_n_0_cln;
75 | uint32 ack_srv; /* acknowledge of (data sent by server) */
76 | uint32 ack_cln; /* acknowledge of (data sent by client) */
77 | uint32 status;
78 | uint32 pkts_cln_to_srv;
79 | uint32 pkts_srv_to_cln;
80 | uint32 bytes_srv_to_cln;
81 | uint32 bytes_cln_to_srv;
82 | uint32 close_state;
83 | }
84 | tcp_data;
85 |
86 | #define FIN 1
87 | #define SYN 2
88 | #define RST 4
89 | #define PSH 8
90 | #define ACK 16
91 | #define URG 32
92 |
93 | #define TCP_SESSION 0x00000800
94 | uint32 tcp_session(uint8 *block, uint32 pkt_size, TME_DATA *data, MEM_TYPE *mem_ex, uint8 *mem_data);
95 |
96 | #endif
--------------------------------------------------------------------------------
/pcap/Lib/Packet.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaEngine/lwip-win32/7493a3b53da5c1e5a1e1d33979517fcbc3389531/pcap/Lib/Packet.lib
--------------------------------------------------------------------------------
/pcap/Lib/wpcap.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MetaEngine/lwip-win32/7493a3b53da5c1e5a1e1d33979517fcbc3389531/pcap/Lib/wpcap.lib
--------------------------------------------------------------------------------
/pcap/net_tap.c:
--------------------------------------------------------------------------------
1 | #include "lwip/err.h"
2 |
3 | #include "pcap.h"
4 |
5 | pcap_t *tap;
6 |
7 | err_t open_tap()
8 | {
9 | pcap_if_t *alldevs;
10 | pcap_if_t *d;
11 | char errbuf[PCAP_ERRBUF_SIZE];
12 | int inum, i=0;
13 |
14 | /* Retrieve the device list */
15 | if(pcap_findalldevs(&alldevs, errbuf) == -1)
16 | {
17 | fprintf(stderr, "Error in pcap_findalldevs: %s\n", errbuf);
18 | return ERR_IF;
19 | }
20 |
21 | /* Print the list */
22 | for(d = alldevs; d; d = d->next)
23 | {
24 | printf("%d. %s", ++i, d->name);
25 | if (d->description)
26 | printf(" (%s)\n", d->description);
27 | else
28 | printf(" (No description available)\n");
29 | }
30 |
31 | if(i == 0)
32 | {
33 | printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
34 | return ERR_IF;
35 | }
36 |
37 | printf("Enter the interface number (1-%d):",i);
38 | scanf("%d", &inum);
39 |
40 | if(inum < 1 || inum > i)
41 | {
42 | printf("\nInterface number out of range.\n");
43 | pcap_freealldevs(alldevs);
44 | return ERR_IF;
45 | }
46 |
47 | /* Jump to the selected adapter */
48 | for(d = alldevs, i = 0; i < inum-1 ;d = d->next, i++);
49 |
50 | /* Open the adapter */
51 | if ((tap = pcap_open_live(d->name,
52 | 65536, // portion of the packet to capture.
53 | 1, // promiscuous mode (nonzero means promiscuous)
54 | 1, // read timeout, 0 blocked, -1 no timeout
55 | errbuf // error buffer
56 | )) == NULL)
57 | {
58 | fprintf(stderr, "\nUnable to open the adapter. %s is not supported by WinPcap\n", d->name);
59 | pcap_freealldevs(alldevs);
60 | return ERR_IF;
61 | }
62 |
63 | printf("\nlistening on %s...\n", d->description);
64 |
65 | pcap_freealldevs(alldevs);
66 | return ERR_OK;
67 | }
68 |
69 | err_t close_tap()
70 | {
71 | pcap_close(tap);
72 | tap = NULL;
73 | return ERR_OK;
74 | }
75 |
76 | err_t get_packet(unsigned int* len, char** pkt_data)
77 | {
78 | int res;
79 | struct pcap_pkthdr *header;
80 | while((res = pcap_next_ex(tap, &header, pkt_data)) >= 0){
81 | /* Timeout elapsed */
82 | if(res == 0)
83 | continue;
84 |
85 | *len = header->len;
86 | return ERR_OK;
87 | }
88 |
89 | fprintf(stderr, "Error reading the packets: %s\n", pcap_geterr(tap));
90 | exit(1);
91 | return ERR_IF;
92 | }
93 |
94 | err_t send_packet(char** buf, int len)
95 | {
96 | if (pcap_sendpacket(tap, *buf, len) != 0)
97 | {
98 | fprintf(stderr, "\nError sending the packet: \n", pcap_geterr(tap));
99 | return ERR_IF;
100 | }
101 | return ERR_OK;
102 | }
--------------------------------------------------------------------------------