Files
m241Neelima/components/ip_net2-6.9/ipmcp/src/ipmcp_mcast.h
T
2026-07-30 11:19:44 +05:30

263 lines
8.8 KiB
C

/*
******************************************************************************
* INTERPEAK API HEADER FILE
*
* Document no: @(#) $Name: VXWORKS_ITER40_2019102207 $ $RCSfile: ipmcp_mcast.h,v $ $Revision: 1.3 $
* $Source: /home/interpeak/CVSRoot/ipmcp/src/ipmcp_mcast.h,v $
* $Author: kenneth $ $Date: 2010-12-17 15:39:19 $
* $State: Exp $ $Locker: $
*
* INTERPEAK_COPYRIGHT_STRING
* Design and implementation by Kenneth Jonsson <kenneth@interpeak.se>
******************************************************************************
*/
#ifndef IPMCP_MCAST_H
#define IPMCP_MCAST_H
/*
****************************************************************************
* 1 DESCRIPTION
****************************************************************************
* Generic functions that can operate on both IPv4 and IPv6 addresses.
* Implements most of the processing described in RFC3376 and RFC3810
*/
/*
****************************************************************************
* 2 CONFIGURATION
****************************************************************************
*/
#include "ipmcp_config.h"
/*
****************************************************************************
* 3 INCLUDE FILES
****************************************************************************
*/
#include <ipcom_cstyle.h>
#include <ipcom_hash.h>
#include <ipcom_set.h>
#include <ipcom_type.h>
#include <ipcom_tmo2.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
****************************************************************************
* 4 DEFINES
****************************************************************************
*/
/* IGMPv3 and MLDv2 Group record types */
#define IPMCP_GROUP_REC_TYPE_MODE_IS_INCLUDE 1
#define IPMCP_GROUP_REC_TYPE_MODE_IS_EXCLUDE 2
#define IPMCP_GROUP_REC_TYPE_MODE_CHANGE_TO_INCLUDE_MODE 3
#define IPMCP_GROUP_REC_TYPE_MODE_CHANGE_TO_EXCLUDE_MODE 4
#define IPMCP_GROUP_REC_TYPE_MODE_ALLOW_NEW_SOURCES 5
#define IPMCP_GROUP_REC_TYPE_MODE_BLOCK_OLD_SOURCES 6
/* Group compatibility modes */
#define IPMCP_MCAST_COMPAT_IGMPV1 1
#define IPMCP_MCAST_COMPAT_IGMPV2_MLDV1 2
#define IPMCP_MCAST_COMPAT_IGMPV3_MLDV2 3
/*
****************************************************************************
* 5 TYPES
****************************************************************************
*/
/*
*===========================================================================
* Ipmcp_rec_t
*===========================================================================
* Base class for IGMPv3 and MLDv2 membership report record
*/
struct Ipmcp_rec_struct;
#define RTHIS struct Ipmcp_rec_struct *self
typedef struct Ipmcp_rec_ops_struct
{
/* Returns the record type */
Ip_u8 (*get_type)(RTHIS);
/* Returns a pointer to the group address */
void * (*get_maddr)(RTHIS);
/* Returns the number of source addresses */
unsigned (*get_num_saddrs)(RTHIS);
/* Returns a pointer to the source address with index 'i' */
void * (*get_saddr)(RTHIS, unsigned i);
/* Returns a IPCOM set with all source address in this record */
Ipcom_set * (*as_set)(RTHIS);
/* Removes all source addresses from the record */
void (*clear_source_list)(RTHIS);
} Ipmcp_rec_ops_t;
typedef struct Ipmcp_rec_struct
{
Ipmcp_rec_ops_t *ops;
} Ipmcp_rec_t;
/*
*===========================================================================
* Ipmcp_saddr_t
*===========================================================================
* Base class a multicast source address entry
*/
struct Ipmcp_saddr_struct;
#define STHIS struct Ipmcp_saddr_struct *self
typedef struct Ipmcp_saddr_ops_struct
{
void (*dtor)(STHIS);
void (*set_timer)(STHIS, Ip_u32 msec);
void * (*get_addr)(STHIS);
} Ipmcp_saddr_ops_t;
typedef struct Ipmcp_saddr_struct
{
Ipmcp_saddr_ops_t *ops;
Ipcom_tmo2 timer; /* Source timer, entry is remove when this expires */
struct Ipmcp_maddr_struct *maddr; /* The multicast address this entry is part of */
} Ipmcp_saddr_t;
/*
*===========================================================================
* Ipmcp_maddr_t
*===========================================================================
* Base class a multicast address entry
*/
struct Ipmcp_maddr_struct;
#define MTHIS struct Ipmcp_maddr_struct *self
typedef struct Ipmcp_maddr_ops_struct
{
void (*dtor)(MTHIS);
void * (*get_addr)(MTHIS);
int (*compatibility_mode)(MTHIS);
Ipmcp_saddr_t * (*add_saddr)(MTHIS, IP_CONST void *saddr, Ip_bool is_include_set);
Ipmcp_saddr_t * (*get_saddr)(MTHIS, IP_CONST void *saddr, Ip_bool is_include_set);
void (*del_saddrs_not_in_rec)(MTHIS, Ipmcp_rec_t *rec, Ip_bool is_include_set);
void (*send_query)(MTHIS, Ip_u32 max_response_msec, Ipcom_set *saddr_set);
Ip_u32 (*get_group_timer) (MTHIS);
void (*set_group_timer)(MTHIS, Ip_u32 msec);
Ip_u32 (*group_membership_interval)(MTHIS);
void (*update_upstream_if_filter)(MTHIS);
} Ipmcp_maddr_ops_t;
typedef struct Ipmcp_maddr_struct
{
Ipmcp_maddr_ops_t *ops;
int domain;
unsigned addr_len; /* Address length for this domain */
Ipcom_tmo2 group_timer; /* Will switch to INCLUDE mode when this expires */
/* Fields use in specific queries on this group */
unsigned query_count; /* Number of times the current specific query will be resent */
Ipcom_tmo2 query_timer; /* Will send a specific query when expires */
Ip_u8 query_suppress_router_side_processing; /* Set to IP_TRUE if the S bit should be set in
the next specific query for this address */
/* Fields use in source specific queries on this group */
Ip_u8 source_query_suppress_router_side_processing; /* Set to IP_TRUE if the S bit should be set in
the next source specific query for this address */
unsigned source_query_count; /* Number of times the current specific query will be resent */
Ipcom_tmo2 source_query_timer; /* Will send a specific query when expires */
Ipcom_set *report_set; /* Set of sources to include in the next source specific query */
/* Multicast source addresses sets */
Ip_bool mode_is_include;
Ipcom_hash *include_set; /* Set of sources that at least one listener want */
Ipcom_hash *exclude_set; /* Set of sources that at least one listener do not want */
/* Downstream interface for which this entry is valid */
struct Ipmcp_netif_struct *netif;
} Ipmcp_maddr_t;
/*
*===========================================================================
* Ipmcp_upstream_maddr_t
*===========================================================================
* Base class a multicast address entry
*/
struct Ipmcp_upstream_maddr_struct;
#define UTHIS struct Ipmcp_upstream_maddr_struct *self
typedef struct Ipmcp_upstream_maddr_ops_struct
{
void (*dtor)(UTHIS);
void * (*get_addr)(UTHIS);
void (*change_mode)(UTHIS, Ip_bool to_exclude);
void (*add_source)(UTHIS, void *saddr);
void (*del_source)(UTHIS, void *saddr);
} Ipmcp_upstream_maddr_ops_t;
typedef struct Ipmcp_upstream_maddr_struct
{
Ipmcp_upstream_maddr_ops_t *ops; /* Upstream operations */
Ipcom_set *filter; /* Current source filter */
} Ipmcp_upstream_maddr_t;
/*
****************************************************************************
* 6 FUNCTIONS
****************************************************************************
*/
IP_GLOBAL int
ipmcp_handle_membership_report_rec(Ipmcp_maddr_t *maddr_obj, Ipmcp_rec_t *rec_obj);
IP_GLOBAL Ip_u32
ipmcp_last_member_query_time(void);
IP_GLOBAL void
ipmcp_update_upstream_if_filter(Ipmcp_upstream_maddr_t *maddr_obj,
Ipcom_hash*(*get_maddr_head)(struct Ipmcp_netif_struct *));
IP_GLOBAL Ip_u32
ipmcp_qqic_to_msec(Ip_u8 code);
IP_GLOBAL Ip_u8
ipmcp_qqic_from_msec(Ip_u32 msec, int version);
/* Source address methods */
IP_GLOBAL void
ipmcp_saddr_ops_init(Ipmcp_saddr_ops_t *ops);
/* Multicast address methods */
IP_GLOBAL void
ipmcp_maddr_drop(Ipmcp_maddr_t *maddr, void *unused);
IP_GLOBAL void
ipmcp_maddr_cleanup(Ipmcp_maddr_t *maddr);
IP_GLOBAL void
ipmcp_maddr_ops_init(Ipmcp_maddr_ops_t *ops);
#ifdef __cplusplus
}
#endif
#endif
/*
****************************************************************************
* END OF FILE
****************************************************************************
*/