0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-23 18:21:54 +00:00
bird/proto/igmp/igmp.h

111 lines
2.8 KiB
C
Raw Normal View History

2016-05-27 00:40:30 +00:00
/*
2018-03-11 23:15:13 +00:00
* BIRD -- IGMP protocol
2016-05-27 00:40:30 +00:00
*
2018-03-11 23:15:13 +00:00
* (c) 2016 Ondrej Hlavaty <aearsis@eideo.cz>
* (c) 2018 Ondrej Zajicek <santiago@crfreenet.org>
* (c) 2018 CZ.NIC z.s.p.o.
2016-05-27 00:40:30 +00:00
*
2018-03-11 23:15:13 +00:00
* Can be freely distributed and used under the terms of the GNU GPL.
2016-05-27 00:40:30 +00:00
*/
#ifndef _BIRD_IGMP_H_
#define _BIRD_IGMP_H_
#include "nest/bird.h"
#include "nest/iface.h"
#include "nest/locks.h"
#include "nest/protocol.h"
#include "nest/route.h"
#include "conf/conf.h"
2018-03-11 23:15:13 +00:00
#include "lib/lists.h"
2016-05-27 00:40:30 +00:00
#include "lib/hash.h"
#include "lib/socket.h"
2018-03-11 23:15:13 +00:00
#include "lib/timer.h"
2016-05-27 00:40:30 +00:00
2018-03-11 23:15:13 +00:00
#define IGMP_PROTO 2
#define IGMP_DEFAULT_ROBUSTNESS 2
#define IGMP_DEFAULT_QUERY_INT (125 S_)
#define IGMP_DEFAULT_RESPONSE_INT (10 S_)
#define IGMP_DEFAULT_LAST_MEMBER_INT (1 S_)
struct igmp_config
{
struct proto_config c;
list iface_list; /* List of ifaces (struct igmp_iface_config) */
};
2016-05-27 00:40:30 +00:00
struct igmp_iface_config
{
struct iface_patt i;
/* These are configurable */
uint robustness, startup_query_cnt, last_member_query_cnt;
2018-03-11 23:15:13 +00:00
btime query_int, query_response_int, startup_query_int, last_member_query_int;
2016-05-27 00:40:30 +00:00
/* These are not */
2018-03-11 23:15:13 +00:00
btime group_member_int, other_querier_int;
2016-05-27 00:40:30 +00:00
};
2018-03-11 23:15:13 +00:00
struct igmp_proto
2016-05-27 00:40:30 +00:00
{
2018-03-11 23:15:13 +00:00
struct proto p;
list iface_list; /* List of interfaces (struct igmp_iface) */
struct mif_group *mif_group; /* Associated MIF group for multicast routes */
2016-05-27 00:40:30 +00:00
2018-03-11 23:15:13 +00:00
struct tbf log_pkt_tbf; /* TBF for packet messages */
2016-05-27 00:40:30 +00:00
};
struct igmp_iface
{
2018-03-11 23:15:13 +00:00
node n; /* Member of igmp_proto->iface_list */
2016-05-27 00:40:30 +00:00
struct igmp_proto *proto;
2018-03-11 23:15:13 +00:00
struct iface *iface; /* Underyling core interface */
struct mif *mif; /* Associated multicast iface */
struct igmp_iface_config *cf; /* Related config, must be updated in reconfigure */
struct object_lock *lock; /* Interface lock */
sock *sk; /* IGMP socket */
HASH(struct igmp_group) groups;
2016-05-27 00:40:30 +00:00
uint query_state; /* initial / querier / non-querier */
2018-03-11 23:15:13 +00:00
int startup_query_cnt; /* Remaining startup queries to send */
timer *query_timer, *other_present;
};
2016-05-27 00:40:30 +00:00
2018-03-11 23:15:13 +00:00
struct igmp_group
{
struct igmp_group *next; /* Member of igmp_iface->groups */
struct igmp_iface *ifa;
ip4_addr address;
2016-05-27 00:40:30 +00:00
2018-03-11 23:15:13 +00:00
uint join_state;
timer *join_timer, *v1_host_timer, *rxmt_timer;
2016-05-27 00:40:30 +00:00
};
2018-03-11 23:15:13 +00:00
#define IGMP_JS_NO_MEMBERS 0
#define IGMP_JS_MEMBERS 1
#define IGMP_JS_V1_MEMBERS 2
#define IGMP_JS_CHECKING 3
2016-05-27 00:40:30 +00:00
#define IGMP_QS_INIT 0
#define IGMP_QS_QUERIER 1
#define IGMP_QS_NONQUERIER 2
/* igmp.c */
2018-03-11 23:15:13 +00:00
void igmp_handle_query(struct igmp_iface *ifa, ip4_addr addr, ip4_addr from, btime resp_time);
void igmp_handle_report(struct igmp_iface *ifa, ip4_addr addr, int version);
void igmp_handle_leave(struct igmp_iface *ifa, ip4_addr addr);
void igmp_finish_iface_config(struct igmp_iface_config *cf);
2016-05-27 00:40:30 +00:00
/* packets.c */
2018-03-11 23:15:13 +00:00
int igmp_open_socket(struct igmp_iface *ifa);
void igmp_send_query(struct igmp_iface *ifa, ip4_addr addr, btime resp_time);
2016-05-27 00:40:30 +00:00
#endif