Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
raw.h
00001 /** 00002 * @file 00003 * raw API (to be used from TCPIP thread)\n 00004 * See also @ref raw_raw 00005 */ 00006 00007 /* 00008 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00009 * All rights reserved. 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 00014 * 1. Redistributions of source code must retain the above copyright notice, 00015 * this list of conditions and the following disclaimer. 00016 * 2. Redistributions in binary form must reproduce the above copyright notice, 00017 * this list of conditions and the following disclaimer in the documentation 00018 * and/or other materials provided with the distribution. 00019 * 3. The name of the author may not be used to endorse or promote products 00020 * derived from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00023 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00025 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00026 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00027 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00028 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00029 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00030 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00031 * OF SUCH DAMAGE. 00032 * 00033 * This file is part of the lwIP TCP/IP stack. 00034 * 00035 * Author: Adam Dunkels <adam@sics.se> 00036 * 00037 */ 00038 #ifndef LWIP_HDR_RAW_H 00039 #define LWIP_HDR_RAW_H 00040 00041 #include "lwip/opt.h" 00042 00043 #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 00044 00045 #include "lwip/pbuf.h" 00046 #include "lwip/def.h" 00047 #include "lwip/ip.h" 00048 #include "lwip/ip_addr.h" 00049 #include "lwip/ip6_addr.h" 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 00055 struct raw_pcb; 00056 00057 /** Function prototype for raw pcb receive callback functions. 00058 * @param arg user supplied argument (raw_pcb.recv_arg) 00059 * @param pcb the raw_pcb which received data 00060 * @param p the packet buffer that was received 00061 * @param addr the remote IP address from which the packet was received 00062 * @return 1 if the packet was 'eaten' (aka. deleted), 00063 * 0 if the packet lives on 00064 * If returning 1, the callback is responsible for freeing the pbuf 00065 * if it's not used any more. 00066 */ 00067 typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, 00068 const ip_addr_t *addr); 00069 00070 /** the RAW protocol control block */ 00071 struct raw_pcb { 00072 /* Common members of all PCB types */ 00073 IP_PCB; 00074 00075 struct raw_pcb *next; 00076 00077 u8_t protocol; 00078 00079 /** receive callback function */ 00080 raw_recv_fn recv; 00081 /* user-supplied argument for the recv callback */ 00082 void *recv_arg; 00083 #if LWIP_IPV6 00084 /* fields for handling checksum computations as per RFC3542. */ 00085 u16_t chksum_offset; 00086 u8_t chksum_reqd; 00087 #endif 00088 }; 00089 00090 /* The following functions is the application layer interface to the 00091 RAW code. */ 00092 struct raw_pcb * raw_new (u8_t proto); 00093 struct raw_pcb * raw_new_ip_type(u8_t type, u8_t proto); 00094 void raw_remove (struct raw_pcb *pcb); 00095 err_t raw_bind (struct raw_pcb *pcb, const ip_addr_t *ipaddr); 00096 err_t raw_connect (struct raw_pcb *pcb, const ip_addr_t *ipaddr); 00097 00098 err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr); 00099 err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); 00100 00101 void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg); 00102 00103 /* The following functions are the lower layer interface to RAW. */ 00104 u8_t raw_input (struct pbuf *p, struct netif *inp); 00105 #define raw_init() /* Compatibility define, no init needed. */ 00106 00107 void raw_netif_ip_addr_changed(const ip_addr_t* old_addr, const ip_addr_t* new_addr); 00108 00109 /* for compatibility with older implementation */ 00110 #define raw_new_ip6(proto) raw_new_ip_type(IPADDR_TYPE_V6, proto) 00111 00112 #ifdef __cplusplus 00113 } 00114 #endif 00115 00116 #endif /* LWIP_RAW */ 00117 00118 #endif /* LWIP_HDR_RAW_H */
Generated on Tue Jul 12 2022 14:24:32 by
