3 * raw API (to be used from TCPIP thread)\n
4 * See also @ref raw_raw
8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
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.
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
33 * This file is part of the lwIP TCP/IP stack.
35 * Author: Adam Dunkels <adam@sics.se>
38 #ifndef LWIP_HDR_RAW_H
39 #define LWIP_HDR_RAW_H
43 #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
45 #include "lwip/pbuf.h"
48 #include "lwip/ip_addr.h"
49 #include "lwip/ip6_addr.h"
55 #define RAW_FLAGS_CONNECTED 0x01U
56 #define RAW_FLAGS_MULTICAST_LOOP 0x04U
60 /** Function prototype for raw pcb receive callback functions.
61 * @param arg user supplied argument (raw_pcb.recv_arg)
62 * @param pcb the raw_pcb which received data
63 * @param p the packet buffer that was received
64 * @param addr the remote IP address from which the packet was received
65 * @return 1 if the packet was 'eaten' (aka. deleted),
66 * 0 if the packet lives on
67 * If returning 1, the callback is responsible for freeing the pbuf
68 * if it's not used any more.
70 typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
71 const ip_addr_t *addr);
73 /** the RAW protocol control block */
75 /* Common members of all PCB types */
79 struct netif *intf_filter;
84 #if LWIP_MULTICAST_TX_OPTIONS
85 /** outgoing network interface for multicast packets, by interface index (if nonzero) */
87 /** TTL for outgoing multicast packets */
89 #endif /* LWIP_MULTICAST_TX_OPTIONS */
91 /** receive callback function */
93 /* user-supplied argument for the recv callback */
96 /* fields for handling checksum computations as per RFC3542. */
102 /* The following functions is the application layer interface to the
104 struct raw_pcb * raw_new (u8_t proto);
105 struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto);
106 void raw_remove (struct raw_pcb *pcb);
107 err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
108 void raw_bind_netif (struct raw_pcb *pcb, const struct netif *netif);
109 err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
110 void raw_disconnect (struct raw_pcb *pcb);
112 err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr);
113 err_t raw_sendto_if_src(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip, struct netif *netif, const ip_addr_t *src_ip);
114 err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
116 void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
118 #define raw_flags(pcb) ((pcb)->flags)
119 #define raw_setflags(pcb,f) ((pcb)->flags = (f))
121 #define raw_set_flags(pcb, set_flags) do { (pcb)->flags = (u8_t)((pcb)->flags | (set_flags)); } while(0)
122 #define raw_clear_flags(pcb, clr_flags) do { (pcb)->flags = (u8_t)((pcb)->flags & ~(clr_flags)); } while(0)
123 #define raw_is_flag_set(pcb, flag) (((pcb)->flags & (flag)) != 0)
125 /* The following functions are the lower layer interface to RAW. */
126 u8_t raw_input (struct pbuf *p, struct netif *inp);
127 #define raw_init() /* Compatibility define, no init needed. */
129 void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr);
131 /* for compatibility with older implementation */
132 #define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto)
134 #if LWIP_MULTICAST_TX_OPTIONS
135 #define raw_set_multicast_netif_index(pcb, idx) ((pcb)->mcast_ifindex = (idx))
136 #define raw_get_multicast_netif_index(pcb) ((pcb)->mcast_ifindex)
137 #define raw_set_multicast_ttl(pcb, value) ((pcb)->mcast_ttl = (value))
138 #define raw_get_multicast_ttl(pcb) ((pcb)->mcast_ttl)
139 #endif /* LWIP_MULTICAST_TX_OPTIONS */
145 #endif /* LWIP_RAW */
147 #endif /* LWIP_HDR_RAW_H */