Port of LwIP performed by Ralf in 2010. Not recommended for use with recent mbed libraries, but good demos of raw LwIP possible

Dependents:   LwIP_raw_API_serverExample tiny-dtls

Committer:
RodColeman
Date:
Tue Sep 18 14:41:24 2012 +0000
Revision:
0:0791c1fece8e
[mbed] converted /Eth_TCP_Wei_Server/lwip

Who changed what in which revision?

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