187189Spdeuskar/**
287189Spdeuskar * @file
3103895Spdeuskar * IGMP API
487189Spdeuskar */
587189Spdeuskar
6103895Spdeuskar/*
7103895Spdeuskar * Copyright (c) 2002 CITEL Technologies Ltd.
887189Spdeuskar * All rights reserved.
9103895Spdeuskar *
10103895Spdeuskar * Redistribution and use in source and binary forms, with or without
1187189Spdeuskar * modification, are permitted provided that the following conditions
12103895Spdeuskar * are met:
13103895Spdeuskar * 1. Redistributions of source code must retain the above copyright
14103895Spdeuskar *    notice, this list of conditions and the following disclaimer.
1587189Spdeuskar * 2. Redistributions in binary form must reproduce the above copyright
1687189Spdeuskar *    notice, this list of conditions and the following disclaimer in the
17103895Spdeuskar *    documentation and/or other materials provided with the distribution.
18103895Spdeuskar * 3. Neither the name of CITEL Technologies Ltd nor the names of its contributors
1987189Spdeuskar *    may be used to endorse or promote products derived from this software
2087189Spdeuskar *    without specific prior written permission.
2187189Spdeuskar *
2287189Spdeuskar * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES AND CONTRIBUTORS ``AS IS''
23103895Spdeuskar * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24103895Spdeuskar * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25103895Spdeuskar * ARE DISCLAIMED.  IN NO EVENT SHALL CITEL TECHNOLOGIES OR CONTRIBUTORS BE LIABLE
26103895Spdeuskar * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27103895Spdeuskar * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28103895Spdeuskar * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29103895Spdeuskar * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30103895Spdeuskar * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3187189Spdeuskar * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3287189Spdeuskar * SUCH DAMAGE.
3387189Spdeuskar *
3490628Spdeuskar * This file is a contribution to the lwIP TCP/IP stack.
3590628Spdeuskar * The Swedish Institute of Computer Science and Adam Dunkels
3687189Spdeuskar * are specifically granted permission to redistribute this
3787189Spdeuskar * source code.
3887189Spdeuskar*/
3987189Spdeuskar
4087189Spdeuskar#ifndef LWIP_HDR_IGMP_H
4187189Spdeuskar#define LWIP_HDR_IGMP_H
4287189Spdeuskar
4387189Spdeuskar#include "lwip/opt.h"
4487189Spdeuskar#include "lwip/ip_addr.h"
4587189Spdeuskar#include "lwip/netif.h"
4687189Spdeuskar#include "lwip/pbuf.h"
4797785Spdeuskar
4887189Spdeuskar#if LWIP_IPV4 && LWIP_IGMP /* don't build if not configured for use in lwipopts.h */
4987189Spdeuskar
5097785Spdeuskar#ifdef __cplusplus
5197785Spdeuskarextern "C" {
5287189Spdeuskar#endif
5387189Spdeuskar
5497785Spdeuskar/* IGMP timer */
5587189Spdeuskar#define IGMP_TMR_INTERVAL              100 /* Milliseconds */
5697785Spdeuskar#define IGMP_V1_DELAYING_MEMBER_TMR   (1000/IGMP_TMR_INTERVAL)
5797785Spdeuskar#define IGMP_JOIN_DELAYING_MEMBER_TMR (500 /IGMP_TMR_INTERVAL)
5887189Spdeuskar
5987189Spdeuskar/* Compatibility defines (don't use for new code) */
6087189Spdeuskar#define IGMP_DEL_MAC_FILTER            NETIF_DEL_MAC_FILTER
6187189Spdeuskar#define IGMP_ADD_MAC_FILTER            NETIF_ADD_MAC_FILTER
6287189Spdeuskar
6387189Spdeuskar/**
6487189Spdeuskar * igmp group structure - there is
6587189Spdeuskar * a list of groups for each interface
6687189Spdeuskar * these should really be linked from the interface, but
6787189Spdeuskar * if we keep them separate we will not affect the lwip original code
6887189Spdeuskar * too much
6987189Spdeuskar *
7087189Spdeuskar * There will be a group for the all systems group address but this
7187189Spdeuskar * will not run the state machine as it is used to kick off reports
7287189Spdeuskar * from all the other groups
7387189Spdeuskar */
7487189Spdeuskarstruct igmp_group {
7587189Spdeuskar  /** next link */
7697785Spdeuskar  struct igmp_group *next;
7787189Spdeuskar  /** multicast address */
78108229Spdeuskar  ip4_addr_t         group_address;
79108229Spdeuskar  /** signifies we were the last person to report */
80108229Spdeuskar  u8_t               last_reporter_flag;
81106649Spdeuskar  /** current state of the group */
82106649Spdeuskar  u8_t               group_state;
83106649Spdeuskar  /** timer for reporting, negative is OFF */
84106649Spdeuskar  u16_t              timer;
85106649Spdeuskar  /** counter of simultaneous uses */
86106649Spdeuskar  u8_t               use;
87108229Spdeuskar};
88108229Spdeuskar
89108229Spdeuskar/*  Prototypes */
90106649Spdeuskarvoid   igmp_init(void);
91106649Spdeuskarerr_t  igmp_start(struct netif *netif);
92106649Spdeuskarerr_t  igmp_stop(struct netif *netif);
93106649Spdeuskarvoid   igmp_report_groups(struct netif *netif);
94106649Spdeuskarstruct igmp_group *igmp_lookfor_group(struct netif *ifp, const ip4_addr_t *addr);
95106649Spdeuskarvoid   igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest);
96108229Spdeuskarerr_t  igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr);
97108229Spdeuskarerr_t  igmp_joingroup_netif(struct netif *netif, const ip4_addr_t *groupaddr);
98106649Spdeuskarerr_t  igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr);
99106649Spdeuskarerr_t  igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr);
100106649Spdeuskarvoid   igmp_tmr(void);
101106649Spdeuskar
102106649Spdeuskar/** @ingroup igmp
103106649Spdeuskar * Get list head of IGMP groups for netif.
104108229Spdeuskar * Note: The allsystems group IP is contained in the list as first entry.
105106649Spdeuskar * @see @ref netif_set_igmp_mac_filter()
106106649Spdeuskar */
107106649Spdeuskar#define netif_igmp_data(netif) ((struct igmp_group *)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_IGMP))
108106649Spdeuskar
109108229Spdeuskar#ifdef __cplusplus
110106649Spdeuskar}
111106649Spdeuskar#endif
112106649Spdeuskar
113106649Spdeuskar#endif /* LWIP_IPV4 && LWIP_IGMP */
114106649Spdeuskar
115106649Spdeuskar#endif /* LWIP_HDR_IGMP_H */
116106649Spdeuskar