A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Committer:
root@mbed.org
Date:
Tue May 08 15:32:10 2012 +0100
Revision:
0:5e1631496985
initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
root@mbed.org 0:5e1631496985 1 /*
root@mbed.org 0:5e1631496985 2 * Copyright (c) 2002 CITEL Technologies Ltd.
root@mbed.org 0:5e1631496985 3 * All rights reserved.
root@mbed.org 0:5e1631496985 4 *
root@mbed.org 0:5e1631496985 5 * Redistribution and use in source and binary forms, with or without
root@mbed.org 0:5e1631496985 6 * modification, are permitted provided that the following conditions
root@mbed.org 0:5e1631496985 7 * are met:
root@mbed.org 0:5e1631496985 8 * 1. Redistributions of source code must retain the above copyright
root@mbed.org 0:5e1631496985 9 * notice, this list of conditions and the following disclaimer.
root@mbed.org 0:5e1631496985 10 * 2. Redistributions in binary form must reproduce the above copyright
root@mbed.org 0:5e1631496985 11 * notice, this list of conditions and the following disclaimer in the
root@mbed.org 0:5e1631496985 12 * documentation and/or other materials provided with the distribution.
root@mbed.org 0:5e1631496985 13 * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
root@mbed.org 0:5e1631496985 14 * may be used to endorse or promote products derived from this software
root@mbed.org 0:5e1631496985 15 * without specific prior written permission.
root@mbed.org 0:5e1631496985 16 *
root@mbed.org 0:5e1631496985 17 * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
root@mbed.org 0:5e1631496985 18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
root@mbed.org 0:5e1631496985 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
root@mbed.org 0:5e1631496985 20 * ARE DISCLAIMED. IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
root@mbed.org 0:5e1631496985 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
root@mbed.org 0:5e1631496985 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
root@mbed.org 0:5e1631496985 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
root@mbed.org 0:5e1631496985 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
root@mbed.org 0:5e1631496985 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
root@mbed.org 0:5e1631496985 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
root@mbed.org 0:5e1631496985 27 * SUCH DAMAGE.
root@mbed.org 0:5e1631496985 28 *
root@mbed.org 0:5e1631496985 29 * This file is a contribution to the lwIP TCP/IP stack.
root@mbed.org 0:5e1631496985 30 * The Swedish Institute of Computer Science and Adam Dunkels
root@mbed.org 0:5e1631496985 31 * are specifically granted permission to redistribute this
root@mbed.org 0:5e1631496985 32 * source code.
root@mbed.org 0:5e1631496985 33 */
root@mbed.org 0:5e1631496985 34
root@mbed.org 0:5e1631496985 35 #ifndef __LWIP_IGMP_H__
root@mbed.org 0:5e1631496985 36 #define __LWIP_IGMP_H__
root@mbed.org 0:5e1631496985 37
root@mbed.org 0:5e1631496985 38 #include "lwip/opt.h"
root@mbed.org 0:5e1631496985 39 #include "lwip/ip_addr.h"
root@mbed.org 0:5e1631496985 40 #include "lwip/netif.h"
root@mbed.org 0:5e1631496985 41 #include "lwip/pbuf.h"
root@mbed.org 0:5e1631496985 42
root@mbed.org 0:5e1631496985 43 #if LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
root@mbed.org 0:5e1631496985 44
root@mbed.org 0:5e1631496985 45 #ifdef __cplusplus
root@mbed.org 0:5e1631496985 46 extern "C" {
root@mbed.org 0:5e1631496985 47 #endif
root@mbed.org 0:5e1631496985 48
root@mbed.org 0:5e1631496985 49 /*
root@mbed.org 0:5e1631496985 50 * IGMP constants
root@mbed.org 0:5e1631496985 51 */
root@mbed.org 0:5e1631496985 52 #define IP_PROTO_IGMP 2
root@mbed.org 0:5e1631496985 53 #define IGMP_TTL 1
root@mbed.org 0:5e1631496985 54 #define IGMP_MINLEN 8
root@mbed.org 0:5e1631496985 55 #define ROUTER_ALERT 0x9404
root@mbed.org 0:5e1631496985 56 #define ROUTER_ALERTLEN 4
root@mbed.org 0:5e1631496985 57
root@mbed.org 0:5e1631496985 58 /*
root@mbed.org 0:5e1631496985 59 * IGMP message types, including version number.
root@mbed.org 0:5e1631496985 60 */
root@mbed.org 0:5e1631496985 61 #define IGMP_MEMB_QUERY 0x11 /* Membership query */
root@mbed.org 0:5e1631496985 62 #define IGMP_V1_MEMB_REPORT 0x12 /* Ver. 1 membership report */
root@mbed.org 0:5e1631496985 63 #define IGMP_V2_MEMB_REPORT 0x16 /* Ver. 2 membership report */
root@mbed.org 0:5e1631496985 64 #define IGMP_LEAVE_GROUP 0x17 /* Leave-group message */
root@mbed.org 0:5e1631496985 65
root@mbed.org 0:5e1631496985 66 /* IGMP timer */
root@mbed.org 0:5e1631496985 67 #define IGMP_TMR_INTERVAL 100 /* Milliseconds */
root@mbed.org 0:5e1631496985 68 #define IGMP_V1_DELAYING_MEMBER_TMR (1000/IGMP_TMR_INTERVAL)
root@mbed.org 0:5e1631496985 69 #define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
root@mbed.org 0:5e1631496985 70
root@mbed.org 0:5e1631496985 71 /* MAC Filter Actions */
root@mbed.org 0:5e1631496985 72 #define IGMP_DEL_MAC_FILTER 0
root@mbed.org 0:5e1631496985 73 #define IGMP_ADD_MAC_FILTER 1
root@mbed.org 0:5e1631496985 74
root@mbed.org 0:5e1631496985 75 /* Group membership states */
root@mbed.org 0:5e1631496985 76 #define IGMP_GROUP_NON_MEMBER 0
root@mbed.org 0:5e1631496985 77 #define IGMP_GROUP_DELAYING_MEMBER 1
root@mbed.org 0:5e1631496985 78 #define IGMP_GROUP_IDLE_MEMBER 2
root@mbed.org 0:5e1631496985 79
root@mbed.org 0:5e1631496985 80 /*
root@mbed.org 0:5e1631496985 81 * IGMP packet format.
root@mbed.org 0:5e1631496985 82 */
root@mbed.org 0:5e1631496985 83 #ifdef PACK_STRUCT_USE_INCLUDES
root@mbed.org 0:5e1631496985 84 # include "arch/bpstruct.h"
root@mbed.org 0:5e1631496985 85 #endif
root@mbed.org 0:5e1631496985 86 PACK_STRUCT_BEGIN
root@mbed.org 0:5e1631496985 87 struct igmp_msg {
root@mbed.org 0:5e1631496985 88 PACK_STRUCT_FIELD(u8_t igmp_msgtype);
root@mbed.org 0:5e1631496985 89 PACK_STRUCT_FIELD(u8_t igmp_maxresp);
root@mbed.org 0:5e1631496985 90 PACK_STRUCT_FIELD(u16_t igmp_checksum);
root@mbed.org 0:5e1631496985 91 PACK_STRUCT_FIELD(struct ip_addr igmp_group_address);
root@mbed.org 0:5e1631496985 92 } PACK_STRUCT_STRUCT;
root@mbed.org 0:5e1631496985 93 PACK_STRUCT_END
root@mbed.org 0:5e1631496985 94 #ifdef PACK_STRUCT_USE_INCLUDES
root@mbed.org 0:5e1631496985 95 # include "arch/epstruct.h"
root@mbed.org 0:5e1631496985 96 #endif
root@mbed.org 0:5e1631496985 97
root@mbed.org 0:5e1631496985 98 /*
root@mbed.org 0:5e1631496985 99 * now a group structure - there is
root@mbed.org 0:5e1631496985 100 * a list of groups for each interface
root@mbed.org 0:5e1631496985 101 * these should really be linked from the interface, but
root@mbed.org 0:5e1631496985 102 * if we keep them separate we will not affect the lwip original code
root@mbed.org 0:5e1631496985 103 * too much
root@mbed.org 0:5e1631496985 104 *
root@mbed.org 0:5e1631496985 105 * There will be a group for the all systems group address but this
root@mbed.org 0:5e1631496985 106 * will not run the state machine as it is used to kick off reports
root@mbed.org 0:5e1631496985 107 * from all the other groups
root@mbed.org 0:5e1631496985 108 */
root@mbed.org 0:5e1631496985 109
root@mbed.org 0:5e1631496985 110 struct igmp_group {
root@mbed.org 0:5e1631496985 111 struct igmp_group *next;
root@mbed.org 0:5e1631496985 112 struct netif *interface;
root@mbed.org 0:5e1631496985 113 struct ip_addr group_address;
root@mbed.org 0:5e1631496985 114 u8_t last_reporter_flag; /* signifies we were the last person to report */
root@mbed.org 0:5e1631496985 115 u8_t group_state;
root@mbed.org 0:5e1631496985 116 u16_t timer;
root@mbed.org 0:5e1631496985 117 u8_t use; /* counter of simultaneous uses */
root@mbed.org 0:5e1631496985 118 };
root@mbed.org 0:5e1631496985 119
root@mbed.org 0:5e1631496985 120
root@mbed.org 0:5e1631496985 121 /* Prototypes */
root@mbed.org 0:5e1631496985 122 void igmp_init(void);
root@mbed.org 0:5e1631496985 123
root@mbed.org 0:5e1631496985 124 err_t igmp_start( struct netif *netif);
root@mbed.org 0:5e1631496985 125
root@mbed.org 0:5e1631496985 126 err_t igmp_stop( struct netif *netif);
root@mbed.org 0:5e1631496985 127
root@mbed.org 0:5e1631496985 128 void igmp_report_groups( struct netif *netif);
root@mbed.org 0:5e1631496985 129
root@mbed.org 0:5e1631496985 130 struct igmp_group *igmp_lookfor_group( struct netif *ifp, struct ip_addr *addr);
root@mbed.org 0:5e1631496985 131
root@mbed.org 0:5e1631496985 132 struct igmp_group *igmp_lookup_group( struct netif *ifp, struct ip_addr *addr);
root@mbed.org 0:5e1631496985 133
root@mbed.org 0:5e1631496985 134 err_t igmp_remove_group( struct igmp_group *group);
root@mbed.org 0:5e1631496985 135
root@mbed.org 0:5e1631496985 136 void igmp_input( struct pbuf *p, struct netif *inp, struct ip_addr *dest);
root@mbed.org 0:5e1631496985 137
root@mbed.org 0:5e1631496985 138 err_t igmp_joingroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
root@mbed.org 0:5e1631496985 139
root@mbed.org 0:5e1631496985 140 err_t igmp_leavegroup( struct ip_addr *ifaddr, struct ip_addr *groupaddr);
root@mbed.org 0:5e1631496985 141
root@mbed.org 0:5e1631496985 142 void igmp_tmr(void);
root@mbed.org 0:5e1631496985 143
root@mbed.org 0:5e1631496985 144 void igmp_timeout( struct igmp_group *group);
root@mbed.org 0:5e1631496985 145
root@mbed.org 0:5e1631496985 146 void igmp_start_timer( struct igmp_group *group, u8_t max_time);
root@mbed.org 0:5e1631496985 147
root@mbed.org 0:5e1631496985 148 void igmp_stop_timer( struct igmp_group *group);
root@mbed.org 0:5e1631496985 149
root@mbed.org 0:5e1631496985 150 void igmp_delaying_member( struct igmp_group *group, u8_t maxresp);
root@mbed.org 0:5e1631496985 151
root@mbed.org 0:5e1631496985 152 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);
root@mbed.org 0:5e1631496985 153
root@mbed.org 0:5e1631496985 154 void igmp_send( struct igmp_group *group, u8_t type);
root@mbed.org 0:5e1631496985 155
root@mbed.org 0:5e1631496985 156 #ifdef __cplusplus
root@mbed.org 0:5e1631496985 157 }
root@mbed.org 0:5e1631496985 158 #endif
root@mbed.org 0:5e1631496985 159
root@mbed.org 0:5e1631496985 160 #endif /* LWIP_IGMP */
root@mbed.org 0:5e1631496985 161
root@mbed.org 0:5e1631496985 162 #endif /* __LWIP_IGMP_H__ */