Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/igmp.h need to be fixed.

0001 /*
0002  * Copyright (c) 2002 CITEL Technologies Ltd.
0003  * All rights reserved.
0004  *
0005  * Redistribution and use in source and binary forms, with or without 
0006  * modification, are permitted provided that the following conditions 
0007  * are met: 
0008  * 1. Redistributions of source code must retain the above copyright 
0009  *    notice, this list of conditions and the following disclaimer. 
0010  * 2. Redistributions in binary form must reproduce the above copyright 
0011  *    notice, this list of conditions and the following disclaimer in the 
0012  *    documentation and/or other materials provided with the distribution. 
0013  * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors 
0014  *    may be used to endorse or promote products derived from this software 
0015  *    without specific prior written permission. 
0016  *
0017  * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
0018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
0019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
0020  * ARE DISCLAIMED.  IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE 
0021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
0022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
0023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
0024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
0025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
0026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
0027  * SUCH DAMAGE. 
0028  *
0029  * This file is a contribution to the lwIP TCP/IP stack.
0030  * The Swedish Institute of Computer Science and Adam Dunkels
0031  * are specifically granted permission to redistribute this
0032  * source code.
0033 */
0034 
0035 #ifndef __LWIP_IGMP_H__
0036 #define __LWIP_IGMP_H__
0037 
0038 #include "lwip/opt.h"
0039 #include "lwip/ip_addr.h"
0040 #include "lwip/netif.h"
0041 #include "lwip/pbuf.h"
0042 
0043 #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
0044 
0045 #ifdef __cplusplus
0046 extern "C" {
0047 #endif
0048 
0049 /* 
0050  * IGMP constants
0051  */
0052 #define IP_PROTO_IGMP                  2
0053 #define IGMP_TTL                       1
0054 #define IGMP_MINLEN                    8
0055 #define ROUTER_ALERT                   0x9404
0056 #define ROUTER_ALERTLEN                4
0057 
0058 /*
0059  * IGMP message types, including version number.
0060  */
0061 #define IGMP_MEMB_QUERY                0x11 /* Membership query         */
0062 #define IGMP_V1_MEMB_REPORT            0x12 /* Ver. 1 membership report */
0063 #define IGMP_V2_MEMB_REPORT            0x16 /* Ver. 2 membership report */
0064 #define IGMP_LEAVE_GROUP               0x17 /* Leave-group message      */
0065 
0066 /* IGMP timer */
0067 #define IGMP_TMR_INTERVAL              100 /* Milliseconds */
0068 #define IGMP_V1_DELAYING_MEMBER_TMR   (1000/IGMP_TMR_INTERVAL)
0069 #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
0070 
0071 /* MAC Filter Actions */
0072 #define IGMP_DEL_MAC_FILTER            0
0073 #define IGMP_ADD_MAC_FILTER            1
0074 
0075 /* Group  membership states */
0076 #define IGMP_GROUP_NON_MEMBER          0
0077 #define IGMP_GROUP_DELAYING_MEMBER     1
0078 #define IGMP_GROUP_IDLE_MEMBER         2
0079 
0080 /*
0081  * IGMP packet format.
0082  */
0083 #ifdef PACK_STRUCT_USE_INCLUDES
0084 #  include "arch/bpstruct.h"
0085 #endif
0086 PACK_STRUCT_BEGIN
0087 struct igmp_msg {
0088  PACK_STRUCT_FIELD(u8_t           igmp_msgtype);
0089  PACK_STRUCT_FIELD(u8_t           igmp_maxresp);
0090  PACK_STRUCT_FIELD(u16_t          igmp_checksum);
0091  PACK_STRUCT_FIELD(struct ip_addr igmp_group_address);
0092 } PACK_STRUCT_STRUCT;
0093 PACK_STRUCT_END
0094 #ifdef PACK_STRUCT_USE_INCLUDES
0095 #  include "arch/epstruct.h"
0096 #endif
0097 
0098 /* 
0099  * now a group structure - there is
0100  * a list of groups for each interface
0101  * these should really be linked from the interface, but
0102  * if we keep them separate we will not affect the lwip original code
0103  * too much
0104  * 
0105  * There will be a group for the all systems group address but this 
0106  * will not run the state machine as it is used to kick off reports
0107  * from all the other groups
0108  */
0109 
0110 struct igmp_group {
0111   struct igmp_group *next;
0112   struct netif      *interface;
0113   struct ip_addr     group_address;
0114   u8_t               last_reporter_flag; /* signifies we were the last person to report */
0115   u8_t               group_state;
0116   u16_t              timer;
0117   u8_t               use; /* counter of simultaneous uses */
0118 };
0119 
0120 
0121 /*  Prototypes */
0122 void   igmp_init(void);
0123 
0124 err_t  igmp_start( struct netif *netif);
0125 
0126 err_t  igmp_stop( struct netif *netif);
0127 
0128 void   igmp_report_groups( struct netif *netif);
0129 
0130 struct igmp_group *igmp_lookfor_group( struct netif *ifp, struct ip_addr *addr);
0131 
0132 struct igmp_group *igmp_lookup_group( struct netif *ifp, struct ip_addr *addr);
0133 
0134 err_t  igmp_remove_group( struct igmp_group *group);
0135 
0136 void   igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);
0137 
0138 err_t  igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
0139 
0140 err_t  igmp_leavegroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
0141 
0142 void   igmp_tmr(void);
0143 
0144 void   igmp_timeout( struct igmp_group *group);
0145 
0146 void   igmp_start_timer( struct igmp_group *group, u8_t max_time);
0147 
0148 void   igmp_stop_timer( struct igmp_group *group);
0149 
0150 void   igmp_delaying_member( struct igmp_group *group, u8_t maxresp);
0151 
0152 err_t  igmp_ip_output_if( struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t proto, struct netif *netif);
0153 
0154 void   igmp_send( struct igmp_group *group, u8_t type);
0155 
0156 #ifdef __cplusplus
0157 }
0158 #endif
0159 
0160 #endif /* LWIP_IGMP */
0161 
0162 #endif /* __LWIP_IGMP_H__ */