1*10465441SEvalZero /** 2*10465441SEvalZero * @file 3*10465441SEvalZero * raw API (to be used from TCPIP thread)\n 4*10465441SEvalZero * See also @ref raw_raw 5*10465441SEvalZero */ 6*10465441SEvalZero 7*10465441SEvalZero /* 8*10465441SEvalZero * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9*10465441SEvalZero * All rights reserved. 10*10465441SEvalZero * 11*10465441SEvalZero * Redistribution and use in source and binary forms, with or without modification, 12*10465441SEvalZero * are permitted provided that the following conditions are met: 13*10465441SEvalZero * 14*10465441SEvalZero * 1. Redistributions of source code must retain the above copyright notice, 15*10465441SEvalZero * this list of conditions and the following disclaimer. 16*10465441SEvalZero * 2. Redistributions in binary form must reproduce the above copyright notice, 17*10465441SEvalZero * this list of conditions and the following disclaimer in the documentation 18*10465441SEvalZero * and/or other materials provided with the distribution. 19*10465441SEvalZero * 3. The name of the author may not be used to endorse or promote products 20*10465441SEvalZero * derived from this software without specific prior written permission. 21*10465441SEvalZero * 22*10465441SEvalZero * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23*10465441SEvalZero * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24*10465441SEvalZero * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25*10465441SEvalZero * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26*10465441SEvalZero * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27*10465441SEvalZero * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28*10465441SEvalZero * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29*10465441SEvalZero * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30*10465441SEvalZero * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31*10465441SEvalZero * OF SUCH DAMAGE. 32*10465441SEvalZero * 33*10465441SEvalZero * This file is part of the lwIP TCP/IP stack. 34*10465441SEvalZero * 35*10465441SEvalZero * Author: Adam Dunkels <[email protected]> 36*10465441SEvalZero * 37*10465441SEvalZero */ 38*10465441SEvalZero #ifndef LWIP_HDR_RAW_H 39*10465441SEvalZero #define LWIP_HDR_RAW_H 40*10465441SEvalZero 41*10465441SEvalZero #include "lwip/opt.h" 42*10465441SEvalZero 43*10465441SEvalZero #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 44*10465441SEvalZero 45*10465441SEvalZero #include "lwip/pbuf.h" 46*10465441SEvalZero #include "lwip/def.h" 47*10465441SEvalZero #include "lwip/ip.h" 48*10465441SEvalZero #include "lwip/ip_addr.h" 49*10465441SEvalZero #include "lwip/ip6_addr.h" 50*10465441SEvalZero 51*10465441SEvalZero #ifdef __cplusplus 52*10465441SEvalZero extern "C" { 53*10465441SEvalZero #endif 54*10465441SEvalZero 55*10465441SEvalZero struct raw_pcb; 56*10465441SEvalZero 57*10465441SEvalZero /** Function prototype for raw pcb receive callback functions. 58*10465441SEvalZero * @param arg user supplied argument (raw_pcb.recv_arg) 59*10465441SEvalZero * @param pcb the raw_pcb which received data 60*10465441SEvalZero * @param p the packet buffer that was received 61*10465441SEvalZero * @param addr the remote IP address from which the packet was received 62*10465441SEvalZero * @return 1 if the packet was 'eaten' (aka. deleted), 63*10465441SEvalZero * 0 if the packet lives on 64*10465441SEvalZero * If returning 1, the callback is responsible for freeing the pbuf 65*10465441SEvalZero * if it's not used any more. 66*10465441SEvalZero */ 67*10465441SEvalZero typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, 68*10465441SEvalZero const ip_addr_t *addr); 69*10465441SEvalZero 70*10465441SEvalZero /** the RAW protocol control block */ 71*10465441SEvalZero struct raw_pcb { 72*10465441SEvalZero /* Common members of all PCB types */ 73*10465441SEvalZero IP_PCB; 74*10465441SEvalZero 75*10465441SEvalZero struct raw_pcb *next; 76*10465441SEvalZero 77*10465441SEvalZero u8_t protocol; 78*10465441SEvalZero 79*10465441SEvalZero /** receive callback function */ 80*10465441SEvalZero raw_recv_fn recv; 81*10465441SEvalZero /* user-supplied argument for the recv callback */ 82*10465441SEvalZero void *recv_arg; 83*10465441SEvalZero #if LWIP_IPV6 84*10465441SEvalZero /* fields for handling checksum computations as per RFC3542. */ 85*10465441SEvalZero u16_t chksum_offset; 86*10465441SEvalZero u8_t chksum_reqd; 87*10465441SEvalZero #endif 88*10465441SEvalZero }; 89*10465441SEvalZero 90*10465441SEvalZero /* The following functions is the application layer interface to the 91*10465441SEvalZero RAW code. */ 92*10465441SEvalZero struct raw_pcb * raw_new (u8_t proto); 93*10465441SEvalZero struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto); 94*10465441SEvalZero void raw_remove (struct raw_pcb *pcb); 95*10465441SEvalZero err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr); 96*10465441SEvalZero err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr); 97*10465441SEvalZero 98*10465441SEvalZero err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr); 99*10465441SEvalZero err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); 100*10465441SEvalZero 101*10465441SEvalZero void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); 102*10465441SEvalZero 103*10465441SEvalZero /* The following functions are the lower layer interface to RAW. */ 104*10465441SEvalZero u8_t raw_input (struct pbuf *p, struct netif *inp); 105*10465441SEvalZero #define raw_init() /* Compatibility define, no init needed. */ 106*10465441SEvalZero 107*10465441SEvalZero void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); 108*10465441SEvalZero 109*10465441SEvalZero /* for compatibility with older implementation */ 110*10465441SEvalZero #define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto) 111*10465441SEvalZero 112*10465441SEvalZero #ifdef __cplusplus 113*10465441SEvalZero } 114*10465441SEvalZero #endif 115*10465441SEvalZero 116*10465441SEvalZero #endif /* LWIP_RAW */ 117*10465441SEvalZero 118*10465441SEvalZero #endif /* LWIP_HDR_RAW_H */ 119