ReactOS 0.4.16-dev-297-gc569aee
raw.h
Go to the documentation of this file.
1
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 <adam@sics.se>
36 *
37 */
38#ifndef LWIP_HDR_RAW_H
39#define LWIP_HDR_RAW_H
40
41#include "lwip/opt.h"
42
43#if LWIP_RAW /* don't build if not configured for use in lwipopts.h */
44
45#include "lwip/pbuf.h"
46#include "lwip/def.h"
47#include "lwip/ip.h"
48#include "lwip/ip_addr.h"
49#include "lwip/ip6_addr.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#define RAW_FLAGS_CONNECTED 0x01U
56#define RAW_FLAGS_HDRINCL 0x02U
57#define RAW_FLAGS_MULTICAST_LOOP 0x04U
58
59struct raw_pcb;
60
71typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p,
72 const ip_addr_t *addr);
73
75struct raw_pcb {
76 /* Common members of all PCB types */
77 IP_PCB;
78
79 struct raw_pcb *next;
80
82 u8_t flags;
83
84#if LWIP_MULTICAST_TX_OPTIONS
86 u8_t mcast_ifindex;
88 u8_t mcast_ttl;
89#endif /* LWIP_MULTICAST_TX_OPTIONS */
90
92 raw_recv_fn recv;
93 /* user-supplied argument for the recv callback */
94 void *recv_arg;
95#if LWIP_IPV6
96 /* fields for handling checksum computations as per RFC3542. */
97 u16_t chksum_offset;
98 u8_t chksum_reqd;
99#endif
100};
101
102/* The following functions is the application layer interface to the
103 RAW code. */
104struct raw_pcb * raw_new (u8_t proto);
105struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto);
106void raw_remove (struct raw_pcb *pcb);
107err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
108void raw_bind_netif (struct raw_pcb *pcb, const struct netif *netif);
109err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr);
110void raw_disconnect (struct raw_pcb *pcb);
111
112err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr);
113err_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);
114err_t raw_send (struct raw_pcb *pcb, struct pbuf *p);
115
116void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg);
117
118#define raw_flags(pcb) ((pcb)->flags)
119#define raw_setflags(pcb,f) ((pcb)->flags = (f))
120
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 & (u8_t)(~(clr_flags) & 0xff)); } while(0)
123#define raw_is_flag_set(pcb, flag) (((pcb)->flags & (flag)) != 0)
124
125#define raw_init() /* Compatibility define, no init needed. */
126
127/* for compatibility with older implementation */
128#define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto)
129
130#if LWIP_MULTICAST_TX_OPTIONS
131#define raw_set_multicast_netif_index(pcb, idx) ((pcb)->mcast_ifindex = (idx))
132#define raw_get_multicast_netif_index(pcb) ((pcb)->mcast_ifindex)
133#define raw_set_multicast_ttl(pcb, value) ((pcb)->mcast_ttl = (value))
134#define raw_get_multicast_ttl(pcb) ((pcb)->mcast_ttl)
135#endif /* LWIP_MULTICAST_TX_OPTIONS */
136
137#ifdef __cplusplus
138}
139#endif
140
141#endif /* LWIP_RAW */
142
143#endif /* LWIP_HDR_RAW_H */
INT WSAAPI recv(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags)
Definition: recv.c:23
#define IP_PCB
Definition: ip.h:76
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLbitfield flags
Definition: glext.h:7161
GLenum const GLvoid * addr
Definition: glext.h:9621
GLfloat GLfloat p
Definition: glext.h:8902
uint8_t u8_t
Definition: arch.h:125
uint16_t u16_t
Definition: arch.h:127
s8_t err_t
Definition: err.h:96
ip6_addr_t ip_addr_t
Definition: ip_addr.h:344
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: netif.h:269
Definition: pbuf.h:186
void * arg
Definition: msvc.h:10