igmp.h
来自「AMLOGIC DPF source code」· C头文件 代码 · 共 189 行
H
189 行
/*******************************************************************
*
* Copyright C 2004 by Amlogic, Inc. All Rights Reserved.
*
* Description: IGMP handling
*
* Created: Tue Oct 12 12:07:20 2004, Eric Knudstrup
*
*******************************************************************/
/* $NetBSD: igmp.h,v 1.8 1999/11/20 00:37:58 thorpej Exp $ */
/*
* Copyright (c) 1988 Stephen Deering.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Stephen Deering of Stanford University.
*
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University 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 THE REGENTS 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 THE REGENTS 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.
*
* @(#)igmp.h 8.1 (Berkeley) 6/10/93
*/
#ifndef IGMP_H
#define IGMP_H
#include <lwip/arch.h>
#include <lwip/ip_addr.h>
#include <lwip/pbuf.h>
#include <listop.h>
/*
* Internet Group Management Protocol (IGMP) definitions.
*
* MULTICAST 1.3
*/
/*
* Internet multicast address structure. There is one of these for each IP
* multicast group to which this host belongs on a given network interface.
* They are kept in a linked list, rooted in the interface's in_ifaddr
* structure.
*/
struct in_multi {
list_t head;
struct ip_addr inm_addr; /* IP multicast address */
struct netif *inm_netif; /* back pointer to ifnet */
unsigned int inm_refcount; /* no. membership claims by sockets */
unsigned int inm_timer; /* IGMP membership report timer */
unsigned int inm_state; /* state of membership */
struct router_info *inm_rti; /* router version info */
};
/*
* IGMP packet format.
*/
PACK_STRUCT_BEGIN
struct igmp {
PACK_STRUCT_FIELD(u8_t igmp_type); /* version & type of IGMP message */
PACK_STRUCT_FIELD(u8_t igmp_code); /* code for routing sub-messages */
PACK_STRUCT_FIELD(u16_t igmp_cksum); /* IP-style checksum */
PACK_STRUCT_FIELD(struct ip_addr igmp_group); /* group address being reported */
} PACK_STRUCT_STRUCT; /* (zero for queries) */
PACK_STRUCT_END
struct igmpstat {
unsigned long igps_rcv_total; /* total IGMP messages received */
unsigned long igps_rcv_tooshort; /* received with too few bytes */
unsigned long igps_rcv_badsum; /* received with bad checksum */
unsigned long igps_rcv_queries; /* received membership queries */
unsigned long igps_rcv_badqueries; /* received invalid queries */
unsigned long igps_rcv_reports; /* received membership reports */
unsigned long igps_rcv_badreports; /* received invalid reports */
unsigned long igps_rcv_ourreports; /* received reports for our groups */
unsigned long igps_snd_reports; /* sent membership reports */
};
#define IGMP_MINLEN 8
#define IGMP_HOST_MEMBERSHIP_QUERY 0x11 /* membership query */
#define IGMP_v1_HOST_MEMBERSHIP_REPORT 0x12 /* v1 membership report */
#define IGMP_DVMRP 0x13 /* DVMRP routing message */
#define IGMP_PIM 0x14 /* PIM routing message */
#define IGMP_v2_HOST_MEMBERSHIP_REPORT 0x16 /* v2 membership report */
#define IGMP_HOST_LEAVE_MESSAGE 0x17 /* leave-group message */
#define IGMP_MTRACE_REPLY 0x1e /* traceroute reply */
#define IGMP_MTRACE_QUERY 0x1f /* traceroute query */
#define IGMP_MAX_HOST_REPORT_DELAY 10 /* max delay for response to */
/* query (in seconds) */
#define IGMP_TIMER_SCALE 10 /* denominator for igmp_timer */
/*
* States for the IGMP v2 state table.
*/
#define IGMP_DELAYING_MEMBER 1
#define IGMP_IDLE_MEMBER 2
#define IGMP_LAZY_MEMBER 3
#define IGMP_SLEEPING_MEMBER 4
#define IGMP_AWAKENING_MEMBER 5
/*
* States for IGMP router version cache.
*/
#define IGMP_v1_ROUTER 1
#define IGMP_v2_ROUTER 2
/*
* Revert to v2 if we haven't heard from the router in this amount of time.
*/
#define IGMP_AGE_THRESHOLD 540
#define IGMP_RANDOM_DELAY(X) (random() % (X) + 1)
#ifndef INADDR_ALLHOSTS_GROUP
#define INADDR_ALLHOSTS_GROUP htonl(0xe0000001)
#endif
#define IN_LOCAL_GROUP(i) (((u32_t)(i) & htonl(0xffffff00)) == htonl(0xe0000000))
/*
* Translate a multicast IP address into its L2 form in buf.
* buf must be ETHER_ADDR_LEN bytes long
*/
static inline void ip_mc_addr_to_eth(u32_t addr, u8_t *buf)
{
buf[0] = 0x01;
buf[1] = 0x00;
buf[2] = 0x5e;
addr = ntohl(addr);
buf[5] = (addr&0xff);
addr >>= 8;
buf[4] = (addr&0xff);
addr >>= 8;
buf[3] = (addr&0xff);
}
/*;emacs generated header for file igmp.c. Global function declarations only. */
extern void
igmp_purgeif(struct netif *netif);
extern void
igmp_leavegroup(struct in_multi *inm);
extern void
igmp_joingroup(struct in_multi *inm);
extern void
igmp_input(struct pbuf *pbuf, struct netif *netif);
extern void
igmp_init(void);
/*;end emacs generated header for file igmp.c. Global function declarations only. */
#endif /* IGMP_H_ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?