STM32F7 Ethernet interface for nucleo STM32F767

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers icmp.h Source File

icmp.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * ICMP API
00004  */
00005 
00006 /*
00007  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00008  * All rights reserved.
00009  *
00010  * Redistribution and use in source and binary forms, with or without modification,
00011  * are permitted provided that the following conditions are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright notice,
00014  *    this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright notice,
00016  *    this list of conditions and the following disclaimer in the documentation
00017  *    and/or other materials provided with the distribution.
00018  * 3. The name of the author may not be used to endorse or promote products
00019  *    derived from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00022  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00023  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00024  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00026  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00029  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00030  * OF SUCH DAMAGE.
00031  *
00032  * This file is part of the lwIP TCP/IP stack.
00033  *
00034  * Author: Adam Dunkels <adam@sics.se>
00035  *
00036  */
00037 #ifndef LWIP_HDR_ICMP_H
00038 #define LWIP_HDR_ICMP_H
00039 
00040 #include "lwip/opt.h"
00041 #include "lwip/pbuf.h"
00042 #include "lwip/ip_addr.h"
00043 #include "lwip/netif.h"
00044 #include "lwip/prot/icmp.h"
00045 
00046 #if LWIP_IPV6 && LWIP_ICMP6
00047 #include "lwip/icmp6.h"
00048 #endif
00049 
00050 #ifdef __cplusplus
00051 extern "C" {
00052 #endif
00053 
00054 /** ICMP destination unreachable codes */
00055 enum icmp_dur_type {
00056   /** net unreachable */
00057   ICMP_DUR_NET   = 0,
00058   /** host unreachable */
00059   ICMP_DUR_HOST  = 1,
00060   /** protocol unreachable */
00061   ICMP_DUR_PROTO = 2,
00062   /** port unreachable */
00063   ICMP_DUR_PORT  = 3,
00064   /** fragmentation needed and DF set */
00065   ICMP_DUR_FRAG  = 4,
00066   /** source route failed */
00067   ICMP_DUR_SR    = 5
00068 };
00069 
00070 /** ICMP time exceeded codes */
00071 enum icmp_te_type {
00072   /** time to live exceeded in transit */
00073   ICMP_TE_TTL  = 0,
00074   /** fragment reassembly time exceeded */
00075   ICMP_TE_FRAG = 1
00076 };
00077 
00078 #if LWIP_IPV4 && LWIP_ICMP /* don't build if not configured for use in lwipopts.h */
00079 
00080 void icmp_input(struct pbuf *p, struct netif *inp);
00081 void icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t);
00082 void icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t);
00083 
00084 #endif /* LWIP_IPV4 && LWIP_ICMP */
00085 
00086 #if LWIP_IPV4 && LWIP_IPV6
00087 #if LWIP_ICMP && LWIP_ICMP6
00088 #define icmp_port_unreach(isipv6, pbuf) ((isipv6) ? \
00089                                          icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT) : \
00090                                          icmp_dest_unreach(pbuf, ICMP_DUR_PORT))
00091 #elif LWIP_ICMP
00092 #define icmp_port_unreach(isipv6, pbuf) do{ if(!(isipv6)) { icmp_dest_unreach(pbuf, ICMP_DUR_PORT);}}while(0)
00093 #elif LWIP_ICMP6
00094 #define icmp_port_unreach(isipv6, pbuf) do{ if(isipv6) { icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT);}}while(0)
00095 #else
00096 #define icmp_port_unreach(isipv6, pbuf)
00097 #endif
00098 #elif LWIP_IPV6 && LWIP_ICMP6
00099 #define icmp_port_unreach(isipv6, pbuf) icmp6_dest_unreach(pbuf, ICMP6_DUR_PORT)
00100 #elif LWIP_IPV4 && LWIP_ICMP
00101 #define icmp_port_unreach(isipv6, pbuf) icmp_dest_unreach(pbuf, ICMP_DUR_PORT)
00102 #else /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) */
00103 #define icmp_port_unreach(isipv6, pbuf)
00104 #endif /* (LWIP_IPV6 && LWIP_ICMP6) || (LWIP_IPV4 && LWIP_ICMP) LWIP_IPV4*/
00105 
00106 #ifdef __cplusplus
00107 }
00108 #endif
00109 
00110 #endif /* LWIP_HDR_ICMP_H */