From c8968f4318e10b232fe79a7c81855d5b60c594b4 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 6 Jul 2010 01:41:53 +0000 Subject: [PATCH] IGMP header files git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2775 42af7a65-404d-4744-a932-0658087f49c3 --- include/net/uip/igmp.h | 86 ++++++++++++++++++++++ include/net/uip/uip-igmp.h | 145 +++++++++++++++++++++++++++++++++++++ net/uip/uip_internal.h | 7 ++ 3 files changed, 238 insertions(+) create mode 100755 include/net/uip/igmp.h create mode 100755 include/net/uip/uip-igmp.h diff --git a/include/net/uip/igmp.h b/include/net/uip/igmp.h new file mode 100755 index 0000000000..8b28b2fedd --- /dev/null +++ b/include/net/uip/igmp.h @@ -0,0 +1,86 @@ +/**************************************************************************** + * net/uip/igmp.h + * User interface to IGMP + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * The NuttX implementation of IGMP was inspired by the IGMP add-on for the + * lwIP TCP/IP stack by Steve Reynolds: + * + * Copyright (c) 2002 CITEL Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __NET_UIP_IGMP_H +#define __NET_UIP_IGMP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#ifdef CONFIG_NET_IGMP + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv6 +# error "IGMP for IPv6 not supported" +#endif + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +EXTERN void igmp_joingroup(const FAR struct in_addr *grpaddr); +EXTERN void igmp_leavegroup(const FAR struct in_addr *grpaddr); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* CONFIG_NET_IGMP */ +#endif /* __NET_UIP_IGMP_H */ diff --git a/include/net/uip/uip-igmp.h b/include/net/uip/uip-igmp.h new file mode 100755 index 0000000000..869a7e7628 --- /dev/null +++ b/include/net/uip/uip-igmp.h @@ -0,0 +1,145 @@ +/**************************************************************************** + * net/uip/uip-igmp.h + * The definitions in this header file are intended only for internal use + * by the NuttX port of the uIP stack. + * + * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * The NuttX implementation of IGMP was inspired by the IGMP add-on for the + * lwIP TCP/IP stack by Steve Reynolds: + * + * Copyright (c) 2002 CITEL Technologies Ltd. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __NET_UIP_IGMP_H +#define __NET_UIP_IGMP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#ifdef CONFIG_NET_IGMP + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv6 +# error "IGMP for IPv6 not supported" +#endif + +/* IGMP packet types */ + +#define IGMP_MEMBERSHIP_QUERY 0x11 /* Membership Query */ +#define IGMPv1_MEMBERSHIP_REPORT 0x12 /* IGMP Ver. 1 Membership Report */ +#define IGMPv2_MEMBERSHIP_REPORT 0x16 /* IGMP Ver. 2 Membership Report */ +#define IGMPv3_MEMBERSHIP_REPORT 0x22 /* IGMP Ver. 3 Membership Report */ +#define IGMP_LEAVE_GROUP 0x17 /* Leave Group */ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* IGMPv2 packet structure as defined by RFC 2236. + * + * The Max Respone Time (maxresp) specifies the time limit for the + * corresponding report. The field has a resolution of 100 miliseconds, the + * value is taken directly. This field is meaningful only in Membership Query + * (0x11); in other messages it is set to 0 and ignored by the receiver. + */ + +struct uip_igmphdr_s +{ +#ifdef CONFIG_NET_IPv6 + + /* IPv6 Ip header */ + + uint8_t vtc; /* Bits 0-3: version, bits 4-7: traffic class (MS) */ + uint8_t tcf; /* Bits 0-3: traffic class (LS), bits 4-7: flow label (MS) */ + uint16_t flow; /* 16-bit flow label (LS) */ + uint8_t len[2]; /* 16-bit Payload length */ + uint8_t proto; /* 8-bit Next header (same as IPv4 protocol field) */ + uint8_t ttl; /* 8-bit Hop limit (like IPv4 TTL field) */ + uip_ip6addr_t srcipaddr; /* 128-bit Source address */ + uip_ip6addr_t destipaddr; /* 128-bit Destination address */ + +#else /* CONFIG_NET_IPv6 */ + + /* IPv4 IP header */ + + uint8_t vhl; /* 8-bit Version (4) and header length (5 or 6) */ + uint8_t tos; /* 8-bit Type of service (e.g., 6=TCP) */ + uint8_t len[2]; /* 16-bit Total length */ + uint8_t ipid[2]; /* 16-bit Identification */ + uint8_t ipoffset[2]; /* 16-bit IP flags + fragment offset */ + uint8_t ttl; /* 8-bit Time to Live */ + uint8_t proto; /* 8-bit Protocol */ + uint16_t ipchksum; /* 16-bit Header checksum */ + uint16_t srcipaddr[2]; /* 32-bit Source IP address */ + uint16_t destipaddr[2]; /* 32-bit Destination IP address */ + +#endif /* CONFIG_NET_IPv6 */ + + /* IGMP header */ + + uint8_t type; /* 8-bit IGMP packet type */ + uint8_t maxresp; /* 8-bit Max response time */ + uint16_t chksum; /* 16-bit Checksum */ + uint16_t grpaddr[2]; /* 32-bit Group address */ +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* CONFIG_NET_IGMP */ +#endif /* __NET_UIP_IGMP_H */ diff --git a/net/uip/uip_internal.h b/net/uip/uip_internal.h index 65928e01ae..487563c81e 100644 --- a/net/uip/uip_internal.h +++ b/net/uip/uip_internal.h @@ -209,6 +209,13 @@ EXTERN void uip_icmpsend(struct uip_driver_s *dev, uip_ipaddr_t *destaddr); #endif /* CONFIG_NET_ICMP_PING */ #endif /* CONFIG_NET_ICMP */ +#ifdef CONFIG_NET_IGMP +/* Defined in uip_igmpinput.c ***********************************************/ + +EXTERN void uip_igmpinput(struct uip_driver_s *dev); + +#endif /* CONFIG_NET_IGMP */ + #undef EXTERN #ifdef __cplusplus }