Multicast listener discovery for IPv6.
Aims to be compliant with RFC 2710. No support for MLDv2.
#include "lwip/opt.h"
#include "lwip/mld6.h"
#include "lwip/icmp6.h"
#include "lwip/ip6.h"
#include "lwip/ip6_addr.h"
#include "lwip/ip.h"
#include "lwip/inet_chksum.h"
#include "lwip/pbuf.h"
#include "lwip/netif.h"
#include "lwip/memp.h"
#include "lwip/stats.h"
#include <string.h>
Macros | |
#define | MLD6_GROUP_DELAYING_MEMBER 1 |
#define | MLD6_GROUP_IDLE_MEMBER 2 |
#define | MLD6_GROUP_NON_MEMBER 0 |
#define | MLD6_HL 1 |
#define | MLD6_JOIN_DELAYING_MEMBER_TMR_MS (500) |
Functions | |
static void | mld6_delayed_report (struct mld_group *group, u16_t maxresp) |
Schedule a delayed membership report for a group. More... | |
static err_t | mld6_free_group (struct mld_group *group) |
Remove a group in the mld_group_list and free. More... | |
void | mld6_input (struct pbuf *p, struct netif *inp) |
Process an input MLD message. More... | |
err_t | mld6_joingroup (ip6_addr_t *srcaddr, ip6_addr_t *groupaddr) |
Join a group on a network interface. More... | |
err_t | mld6_leavegroup (ip6_addr_t *srcaddr, ip6_addr_t *groupaddr) |
Leave a group on a network interface. More... | |
struct mld_group * | mld6_lookfor_group (struct netif *ifp, ip6_addr_t *addr) |
Search for a group that is joined on a netif. More... | |
static struct mld_group * | mld6_new_group (struct netif *ifp, ip6_addr_t *addr) |
create a new group More... | |
void | mld6_report_groups (struct netif *netif) |
Report MLD memberships for this interface. More... | |
static void | mld6_send (struct mld_group *group, u8_t type) |
Send a MLD message (report or done). More... | |
err_t | mld6_stop (struct netif *netif) |
Stop MLD processing on interface. More... | |
void | mld6_tmr (void) |
Periodic timer for mld processing. More... | |
Variables | |
static struct mld_group * | mld_group_list |
#define MLD6_GROUP_DELAYING_MEMBER 1 |
Referenced by mld6_delayed_report(), mld6_input(), and mld6_tmr().
#define MLD6_GROUP_IDLE_MEMBER 2 |
Referenced by mld6_delayed_report(), mld6_input(), mld6_new_group(), and mld6_tmr().
#define MLD6_GROUP_NON_MEMBER 0 |
#define MLD6_HL 1 |
Referenced by mld6_send().
#define MLD6_JOIN_DELAYING_MEMBER_TMR_MS (500) |
Referenced by mld6_joingroup(), and mld6_report_groups().
Schedule a delayed membership report for a group.
group | the mld_group for which "delaying" membership report should be sent |
maxresp | the max resp delay provided in the query |
References mld_group::group_state, LWIP_RAND, MLD6_GROUP_DELAYING_MEMBER, MLD6_GROUP_IDLE_MEMBER, MLD6_TMR_INTERVAL, mld_group::timer, and timer.
Referenced by mld6_input(), mld6_joingroup(), and mld6_report_groups().
Remove a group in the mld_group_list and free.
group | the group to remove |
References ERR_ARG, ERR_OK, memp_free(), mld_group::next, and NULL.
Referenced by mld6_leavegroup().
Process an input MLD message.
Called by icmp6_input.
p | the mld packet, p->payload pointing to the icmpv6 header |
inp | the netif on which this packet was received |
References mld_group::group_address, mld_group::group_state, ICMP6_TYPE_MLD, ICMP6_TYPE_MLQ, ICMP6_TYPE_MLR, ip6_addr_isallnodes_linklocal, ip6_addr_isany, ip6_addr_ismulticast_iflocal, ip6_current_dest_addr, mld_group::last_reporter_flag, pbuf::len, mld6_delayed_report(), MLD6_GROUP_DELAYING_MEMBER, MLD6_GROUP_IDLE_MEMBER, mld6_lookfor_group(), MLD6_STATS_INC, mld_group_list, mld_group::netif, mld_group::next, NULL, pbuf::payload, pbuf_free(), and mld_group::timer.
Referenced by icmp6_input().
err_t mld6_joingroup | ( | ip6_addr_t * | srcaddr, |
ip6_addr_t * | groupaddr | ||
) |
Join a group on a network interface.
srcaddr | ipv6 address of the network interface which should join a new group. If IP6_ADDR_ANY, join on all netifs |
groupaddr | the ipv6 address of the group to join |
References ERR_MEM, ERR_OK, ERR_VAL, ICMP6_TYPE_MLR, ip6_addr_cmp, ip6_addr_isany, MLD6_ADD_MAC_FILTER, mld6_delayed_report(), MLD6_JOIN_DELAYING_MEMBER_TMR_MS, mld6_lookfor_group(), mld6_new_group(), mld6_send(), MLD6_STATS_INC, netif::mld_mac_filter, netif_ip6_addr, netif_list, netif::next, NULL, and mld_group::use.
Referenced by lwip_netconn_do_join_leave_group(), and nd6_tmr().
err_t mld6_leavegroup | ( | ip6_addr_t * | srcaddr, |
ip6_addr_t * | groupaddr | ||
) |
Leave a group on a network interface.
srcaddr | ipv6 address of the network interface which should leave the group. If IP6_ISANY, leave on all netifs |
groupaddr | the ipv6 address of the group to leave |
References ERR_OK, ERR_VAL, ICMP6_TYPE_MLD, ip6_addr_cmp, ip6_addr_isany, mld_group::last_reporter_flag, MLD6_DEL_MAC_FILTER, mld6_free_group(), mld6_lookfor_group(), mld6_send(), MLD6_STATS_INC, netif::mld_mac_filter, netif_ip6_addr, netif_list, netif::next, NULL, and mld_group::use.
Referenced by lwip_netconn_do_join_leave_group(), and nd6_input().
struct mld_group* mld6_lookfor_group | ( | struct netif * | ifp, |
ip6_addr_t * | addr | ||
) |
Search for a group that is joined on a netif.
ifp | the network interface for which to look |
addr | the group ipv6 address to search for |
References mld_group::group_address, ip6_addr_cmp, mld_group_list, mld_group::netif, mld_group::next, and NULL.
Referenced by ip6_input(), mld6_input(), mld6_joingroup(), and mld6_leavegroup().
|
static |
create a new group
ifp | the network interface for which to create |
addr | the new group ipv6 |
References mld_group::group_address, mld_group::group_state, ip6_addr_set, mld_group::last_reporter_flag, memp_malloc(), MLD6_GROUP_IDLE_MEMBER, mld_group_list, mld_group::netif, mld_group::next, NULL, mld_group::timer, and mld_group::use.
Referenced by mld6_joingroup().
Report MLD memberships for this interface.
netif | network interface on which report MLD memberships |
References mld6_delayed_report(), MLD6_JOIN_DELAYING_MEMBER_TMR_MS, mld_group_list, mld_group::netif, mld_group::next, and NULL.
Referenced by netif_set_link_up(), and netif_set_up().
Send a MLD message (report or done).
An IPv6 hop-by-hop options header with a router alert option is prepended.
group | the group to report or quit |
type | ICMP6_TYPE_MLR (report) or ICMP6_TYPE_MLD (done) |
References mld_group::group_address, IP6_ADDR_ANY, ip6_addr_isany, ip6_addr_isvalid, ip6_addr_set, ip6_chksum_pseudo(), IP6_HBH_HLEN, IP6_NEXTH_HOPBYHOP, IP6_NEXTH_ICMP6, ip6_options_add_hbh_ra(), ip6_output_if(), IP6_ROUTER_ALERT_VALUE_MLD, pbuf::len, MLD6_HL, MLD6_STATS_INC, mld_group::netif, netif_ip6_addr, netif_ip6_addr_state, NULL, pbuf::payload, pbuf_alloc(), pbuf_free(), pbuf_header(), PBUF_IP, and PBUF_RAM.
Referenced by mld6_joingroup(), mld6_leavegroup(), and mld6_tmr().
Stop MLD processing on interface.
netif | network interface on which stop MLD processing |
References ERR_OK, mld_group::group_address, memp_free(), MLD6_DEL_MAC_FILTER, mld_group_list, netif::mld_mac_filter, mld_group::netif, mld_group::next, next, and NULL.
Referenced by netif_remove().
Periodic timer for mld processing.
Must be called every MLD6_TMR_INTERVAL milliseconds (100).
When a delaying member expires, a membership report is sent.
References mld_group::group_state, ICMP6_TYPE_MLR, MLD6_GROUP_DELAYING_MEMBER, MLD6_GROUP_IDLE_MEMBER, mld6_send(), MLD6_STATS_INC, mld_group_list, mld_group::next, NULL, and mld_group::timer.
Referenced by mld6_timer().
|
static |
Referenced by mld6_input(), mld6_lookfor_group(), mld6_new_group(), mld6_report_groups(), mld6_stop(), and mld6_tmr().