The Pedigree Project  0.1
raw.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
26 /*
27  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
28  * All rights reserved.
29  *
30  * Redistribution and use in source and binary forms, with or without modification,
31  * are permitted provided that the following conditions are met:
32  *
33  * 1. Redistributions of source code must retain the above copyright notice,
34  * this list of conditions and the following disclaimer.
35  * 2. Redistributions in binary form must reproduce the above copyright notice,
36  * this list of conditions and the following disclaimer in the documentation
37  * and/or other materials provided with the distribution.
38  * 3. The name of the author may not be used to endorse or promote products
39  * derived from this software without specific prior written permission.
40  *
41  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
42  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
43  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
44  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
46  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
47  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
48  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
49  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
50  * OF SUCH DAMAGE.
51  *
52  * This file is part of the lwIP TCP/IP stack.
53  *
54  * Author: Adam Dunkels <adam@sics.se>
55  *
56  */
57 #ifndef LWIP_HDR_RAW_H
58 #define LWIP_HDR_RAW_H
59 
60 #include "lwip/opt.h"
61 
62 #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
63 
64 #include "lwip/pbuf.h"
65 #include "lwip/def.h"
66 #include "lwip/ip.h"
67 #include "lwip/ip_addr.h"
68 #include "lwip/ip6_addr.h"
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 struct raw_pcb;
75 
86 typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
87  const ip_addr_t *addr);
88 
90 struct raw_pcb {
91  /* Common members of all PCB types */
92  IP_PCB;
93 
94  struct raw_pcb *next;
95 
96  u8_t protocol;
97 
99  raw_recv_fn recv;
100  /* user-supplied argument for the recv callback */
101  void *recv_arg;
102 #if LWIP_IPV6
103  /* fields for handling checksum computations as per RFC3542. */
104  u16_t chksum_offset;
105  u8_t chksum_reqd;
106 #endif
107 };
108 
109 /* The following functions is the application layer interface to the
110  RAW code. */
111 struct raw_pcb * raw_new (u8_t proto);
112 struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto);
113 void raw_remove (struct raw_pcb *pcb);
114 err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
115 err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
116 
117 err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr);
118 err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
119 
120 void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
121 
122 /* The following functions are the lower layer interface to RAW. */
123 u8_t raw_input (struct pbuf *p, struct netif *inp);
124 #define raw_init() /* Compatibility define, no init needed. */
125 
126 void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
127 
128 /* for compatibility with older implementation */
129 #define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto)
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* LWIP_RAW */
136 
137 #endif /* LWIP_HDR_RAW_H */
#define IP_PCB
Definition: ip.h:95
Definition: pbuf.h:161
Definition: netif.h:244
s8_t err_t
Definition: err.h:76