⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 igmp.h~

📁 igmp for switch in vxworks
💻 H~
📖 第 1 页 / 共 2 页
字号:
typedef enum
{
	NoMembersPresent = 0,
	MembersPresent = 1,
	V1MembersPresent = 2,
	CheckingMembership = 3
}
GroupPortStatus;

/*定义超时事件,根据事件发生得频率排序*/
typedef enum
{
	GeneralQueryTimeOutEvent = 1,
	GroupPortV2MembershipTimeOutEvent = 2,
	HostReportDelayTimeOutEvent = 3,
	GroupPortLastMemberQueryTimeOutEvent = 4,
	GroupPortV1HostTimeOutEvent = 5,
	GroupV1HostPresentTimeOutEvent = 6,
	StartupQueryTimeOutEvent = 7,
	V1RouterPresentTimeOutEvent = 8,
	OtherQuerierPresentTimeOutEvent = 9
}
TimeOutEvent;

typedef struct search_node
{
	struct search_node *pNext;
	USHORT usPort;
} SearchNode;

#define NoMembersPresent  0
#define	MembersPresent  1
#define	V1MembersPresent 2
#define	CheckingMembership 3

typedef struct GE
{
	struct GE *pNext;
	UINT unGroupAddress;		/*组播组IP地址 */
	UINT tGroupV1HostPresentTimer;	/*组播组V1主机存在定时器 */
	UINT tHostReportDelayTimer;	/*主机成员报告延时定时器 */
	HostStatus eHostStatus;		/*组播组主机状态 */
	USHORT usGroupUserNumber;	/*组播组成员个数 */
	BOOL bGroupV1HostPresentFlag;	/*组播组V1主机存在标志 */
	BOOL bHostLastMemberFlag[MAX_UPLINK_PORT + 1];	/*主机最后成员标志 */
	UCHAR eGroupPortStatus[MAX_UPLINK_PORT + 1];	/*端口状态 */
	USHORT tGroupPortV2MembershipTimer[MAX_UPLINK_PORT + 1];	/*端口V2成员存在定时器 */
	UCHAR tGroupPortV1HostTimer[MAX_UPLINK_PORT + 1];	/*端口V1成员存在定时器 */
	USHORT tGroupPortLastMemberQueryTimer[MAX_UPLINK_PORT + 1];	/*组播组最后成员查询定时器 */
	UCHAR ucGroupPortLastMemberQueryCount[MAX_UPLINK_PORT + 1];	/*组播组最后成员查询次数 */
	SearchNode *pNode;
	USHORT usSourcePort;
	USHORT OutVlanTag;
	int totaluser;				/*the number of users of a group have */
} GroupEntity;

extern GroupEntity *pGroupEntityList;

struct igmp_group_auth
{
	struct igmp_group_auth *pNext;
	struct igmp_group_auth *pPrv;
	unsigned int groupaddress;
	int authport[usMaxPort + 1][MAXPortNum2 + 1];
	int authsum;
};

struct preview_node
{
	struct preview_node *pNode;
	unsigned int groupaddress;
	int slot;
	int port;
	int previewtime1;
	unsigned int s_addr;
	unsigned int d_addr;
};

typedef struct
{
	UINT unGroupAddress;		/*组播组IP地址 */
	UINT unSourceAddress;		/*数据包的源IP地址 */
	UINT unDestinationAddress;	/*数据包的目的IP地址 */
	USHORT usPort;				/*IGMP包来自哪个端口(VCI-31) */
	UCHAR ucMaxResponseTime;	/*最大响应时间 */
	UCHAR ucIGMPType;			/*IGMP包类型 */
	USHORT usSessionId;			/*端口对应的PPPoE SessionId */
	USHORT VlanTag;
	int user;					/*线卡具体的用户端口aibin */
	int tick;
}
IGMPMsg;

typedef struct
{
	TimeOutEvent TimerType;
	GroupEntity *IgmpGroup;
	USHORT usPort;
}
TimerEntity;

/****************************************************************
Add for Pre-join and Preview IGMP Group 2005.7.10
*/
typedef struct PreJoinNode
{
	struct PreJoinNode *pNext;
	UINT unGroupAddress;
	USHORT usCount;
}
PreJoinNode;

extern PreJoinNode *pPreJoinList;

#ifdef __cplusplus
extern "C"
{
#endif

	void IgmpMain (void);
	BOOL IgmpInitParameters (void);
	void ProcessReceiveIgmpPkt (IGMPMsg ReceiveIgmpMsg);

	void HostProcessIgmpV1Query (IGMPMsg ReceiveIgmpMsg);
	void HostProcessIgmpV2Query (IGMPMsg ReceiveIgmpMsg);
	void HostProcessIgmpReport (IGMPMsg ReceiveIgmpMsg);

	void RouterProcessIgmpV1Query (IGMPMsg ReceiveIgmpMsg);
	void RouterProcessIgmpV2Query (IGMPMsg ReceiveIgmpMsg);
	void RouterProcessIgmpV1Report (IGMPMsg ReceiveIgmpMsg);
	void RouterProcessIgmpV2Report (IGMPMsg ReceiveIgmpMsg);
	void RouterProcessIgmpLeave (IGMPMsg ReceiveIgmpMsg);

	void AllGroupSendReport (UCHAR MaxResponseTime);
	void SpecificGroupSendV1Report (UINT unGroupAddress);
	void SpecificGroupSendV2Report (UINT unGroupAddress);
	void SpecificGroupSendLeaveGroup (UINT unGroupAddress);

	void RouterSendGroupSpecificQuery (UINT unGroupAddress,
		UCHAR MaxResponseTime, USHORT usPort);

	void RouterSendGenernalQueryToAllPort (void);

	void StartIgmpMembershipTimer (void);
	void StopIgmpMembershipTimer (void);
	void StartV1RouterPresentTimer (void);
	void StopV1RouterPresentTimer (void);

	void StartOtherQuerierPresentTimer (void);
	void StopOtherQuerierPresentTimer (void);

	void StartHostReportDelayTimer (GroupEntity * IgmpGroup,
		UCHAR ucMaxResponseTime);
	void StopHostReportDelayTimer (GroupEntity * IgmpGroup);

	void StartStartupQueryTimer (void);
	void StopStartupQueryTimer (void);

	void StartGeneralQueryTimer (void);
	void StopGeneralQueryTimer (void);

	void StartGroupV1HostPresentTimer (GroupEntity * IgmpGroup);
	void StopGroupV1HostPresentTimer (GroupEntity * IgmpGroup);

	void StartGroupPortV1HostTimer (GroupEntity * IgmpGroup, USHORT usPort);
	void StopGroupPortV1HostTimer (GroupEntity * IgmpGroup, USHORT usPort);

	void StartGroupPortV2MembershipTimer (GroupEntity * IgmpGroup,
		USHORT usPort);
	void StopGroupPortV2MembershipTimer (GroupEntity * IgmpGroup,
		USHORT usPort);

	void StartGroupPortLastMemberQueryTimer (GroupEntity * IgmpGroup,
		USHORT usPort);
	void StopGroupPortLastMemberQueryTimer (GroupEntity * IgmpGroup,
		USHORT usPort);

	GroupEntity *AddNewIgmpGroup (UINT unGroupAddress);
	void AddPortToSpecificGroup (UINT unGroupAddress, USHORT usPort);
	void AddPortToSearchGroup (GroupEntity * IgmpGroup, USHORT usPort);
	void DelPortFromSearchGroup (GroupEntity * IgmpGroup, USHORT usPort);

	void DeletePortFromSpecificGroup (GroupEntity * IgmpGroup, USHORT usPort,
		int user);
	void DeletePortFromSpecificGroupByConsole (GroupEntity * IgmpGroup,
		USHORT usPort);

	void DeleteSpecificIgmpGroup (GroupEntity * IgmpGroup);

	GroupEntity *FindIgmpGroupByAddress (UINT unGroupAddress);
	BOOL FindPortInSpecificGroup (GroupEntity * IgmpGroup, USHORT usPort);
	BOOL FindIgmpGroupFromList (GroupEntity * IgmpGroup);
	GroupEntity *FindPort (USHORT usPort);

	void CaculateChecksum (UCHAR * pBufferHeader, USHORT usBufferLength,
		USHORT usChecksumOffset);

	BOOL VerifyChecksum (UCHAR * pBufferHeader, USHORT usBufferLength,
		USHORT usChecksumOffset);

	void SendIgmpPkt (UCHAR ucIgmpType, UINT unGroupAddress, USHORT usPort,
		UCHAR ucMaxRespTime);

	static UINT TransformPortToPVC (USHORT usPort);
	static USHORT TransformPVCToPort (UINT unPVC);
	static void TransformPVC (UINT * pVPI, UINT * pVCI, UINT unPVC);

	UINT GetRandomTimeByMaxRespTime (UINT ucMaxResponseTime);
	void IgmpEtherMapIpMulticast (UINT ipaddr, UCHAR enaddr[6]);

	void AddGroupToGroupList (GroupEntity * IgmpGroup);
	void DeleteGroupFromList (GroupEntity * IgmpGroup);

	void ProcessIgmpTimerEvent (ULONG ulTimeOutPara);

	void HostProcessV1RouterPresentTimeOutEvent (void);
	void HostProcessHostReportDelayTimeOutEvent (GroupEntity * IgmpGroup);
	void RouterProcessStartupQueryTimeOutEvent (void);
	void RouterProcessGroupV1HostPresentTimeOutEvent (GroupEntity * IgmpGroup);
	void RouterProcessGroupPortV1HostTimeOutEvent (GroupEntity * IgmpGroup,
		USHORT usPort);
	void RouterProcessGroupPortLastMemberQueryTimeOutEvent (GroupEntity *
		IgmpGroup, USHORT usPort);
	void RouterProcessGroupPortV2MembershipTimeOutEvent (GroupEntity *
		IgmpGroup, USHORT usPort);

	void ParameterNotUse (UINT unPara);
	void get_ether_info ();
	void IpToMutimac1 (struct in_addr ipaddr, u_char * ether_addr);
	int IgmpInit (void);
	int IgmpReceive (USHORT usPort, char *IgmpPkt, USHORT usLength,
		short vlanid);
	void SetIgmpPara (void);
	void ShowIgmpPara (void);
	void ShowIgmpStat (void);
	void ShowIgmpGroupInfo (struct vty *vty);
	void ShowIgmpGroupDebugInfo (void);
	void ClearIgmpDebugInfo (void);
	void SetPortIgmp (void);
	void ShowPortIgmp (void);
	void ShowIgmpDebugInfo (void);
	void PPPoENotifyIGMPUserOffline (UINT unPVC);
	void AddIgmpGroup (UINT ipaddress, USHORT port);
	int AddPortList (UINT ipaddress, char *portlist);
	void AddIgmpGroupByConsole (void);
	long nos_timerout (long millsec, long larg, char *parg);
	long nos_deltimer (unsigned long timerid);
	/*以下是艾滨编写的外部调用函数 */
	int AddUserbyGroup (unsigned int groupaddress, int slot, int port,
		struct vty *vty);
	int DelUserbyGroup (unsigned int groupaddress, int slot, int port,
		struct vty *vty);
	int show_igmpstate_snmp (struct vty *vty);
	int set_igmpage_snmp (int slot, int newage, struct vty *vty);
	int igmp_enableport_snmp (char *act, int slot, int port);
	int start_igmpproxy_snmp (char *act, struct vty *vty);
	int AddPreJoinNode (UINT unGroupAddress);
	int get_prejoin_count (void);
	int get_prejoin_group (UINT * group);
	void DelAllPreJoinNode (void);
	void DelPreJoinNode (UINT unGroupAddress);
	void IgmpRotateExecute (char *buf);
	void turboshow (void);
	void turboclear (void);
	int IgmpRotateCollect (char *buf);
	int CheckUpLinksrc (UINT groupaddress);
	void VlanSwitch (unsigned short vlanid);
	void SendVlanMsg (int slot);
	void StartTestTimer (void);
	int get_igmpMulticastVlanVid (void);
	void SendIgmpPktbyCmd (int ucIgmpType, UINT unGroupAddress,
		unsigned long sourceip, USHORT usPort, UCHAR user);
	PreJoinNode *IfPreJoinNodeExist (UINT unGroupAddress);
	void sendQuery2Slot (char slot);

/*move*/

	extern int ConInit ();
	extern int ConCmd_install ();

#ifdef __cplusplus
}
#endif

/*消息结构*/
struct IS_MSG					/*add by aibin 2005-01-13 */
{
	int msg_type;
	void *p_data_buff;
};

struct IS_MSG_REPORT			/*add by aibin 2005-01-13 */
{
	int vid;
	int port;
	char buff[2048];
	int len;
};

struct Test_Mode
{
	USHORT interval;			/*发送频率 */
	USHORT gcount;				/*要加入的组数目 */
	USHORT joinsend;			/*发送的加入报文 */
	USHORT leavesend;			/*发送的离开报文 */
	USHORT slotsum;				/*从几块线卡发出 */
	USHORT testtimes;			/*测试次数 */
};

struct Time_Tick
{
	UINT groupaddress;
	int tick1;
	int tick2;
	int tick3;
	int tick4;
};

extern UINT groupid;
extern struct Time_Tick timeget[4096];

struct GroupAdd
{
	UINT groupaddress;
	UCHAR count;
	UCHAR slot[MAX_UPLINK_PORT];
	short outvlan;
	char tag;
};

/*
#define BEGIN_PARSE_PORT_LIST_VIRTUAL(portlist,portno) {short _slotno,_no1,_no2,_i,tmpno,cportsel; unsigned int _index;char *_cur,*_p,*_p1; char _tmp[20],_tmp1[20],_tmp2[20],_tmp_before_sub[20],cslot ;	_cur = portlist;  while (_cur){bzero(_tmp,20);bzero(_tmp1,20);bzero(_tmp2,20);bzero(_tmp_before_sub,20);_slotno = 0;_no1 = 0;_no2 = 0;_p = strchr(_cur,',');if(_p){strncpy(_tmp,_cur,_p - _cur);_cur = _p + 1;}else{strcpy(_tmp,_cur);_cur = NULL;}	_p = strchr(_tmp,'-');if (_p){strncpy(_tmp_before_sub,_tmp,_p - _tmp); _p = _p +1;{_p1 = strchr(_tmp_before_sub,':');if(_p1){strncpy(_tmp1,_tmp_before_sub,_p1 - _tmp_before_sub);_p1 = _p1 + 1;_slotno = atoi(_tmp1);portno = atoi(_p1);cslot=translateslot_in(_slotno&0xff);cportsel=portno&0xffff;portno=virtual_slotport2port(&_index,cslot,cportsel);}else{portno = -1; }_no1 = portno;}{_p1 = strchr(_p,':');if(_p1){strncpy(_tmp2,_p,_p1 - _p);_p1 = _p1 + 1;_slotno = atoi(_tmp2); portno = atoi(_p1);cslot=translateslot_in(_slotno&0xff);cportsel=portno&0xffff;portno=virtual_slotport2port(&_index,cslot,cportsel);  }else{portno = -1;}_no2 = portno;}} else{_p1 = strchr(_tmp,':'); if(_p1){strncpy(_tmp1,_tmp,_p1 - _tmp); _p1 = _p1 + 1;  _slotno = atoi(_tmp1);  portno = atoi(_p1);cslot=translateslot_in(_slotno&0xff);	cportsel=portno&0xffff;portno=virtual_slotport2port(&_index,cslot,cportsel);}else {portno = -1;}	_no1 = portno;_no2 = portno; }if (_no1 > _no2){ tmpno = _no1;  _no1 = _no2;  _no2 = tmpno;}if(_no1 == -1||_no2 == -1){_no2 = -1;_no1 = -1;}for(_i = _no1; _i<=_no2; _i++){portno = _i;

#define END_PARSE_PORT_LIST_VIRTUAL()   if(1==_i)_i+=15;} } }
#define BEGIN_PARSE_PORT_LIST(portlist,portno) {short _slotno,_no1,_no2,_i,tmpno; unsigned int _index;char *_cur,*_p,*_p1; char _tmp[20],_tmp1[20],_tmp2[20],_tmp_before_sub[20],cslot,cportsel ; _cur = portlist;  while (_cur){bzero(_tmp,20);bzero(_tmp1,20);bzero(_tmp2,20);bzero(_tmp_before_sub,20);_slotno = 0;_no1 = 0;_no2 = 0;_p = strchr(_cur,',');if(_p){strncpy(_tmp,_cur,_p - _cur);_cur = _p + 1;}else{strcpy(_tmp,_cur);_cur = NULL;} _p = strchr(_tmp,'-');if (_p){strncpy(_tmp_before_sub,_tmp,_p - _tmp); _p = _p +1;{_p1 = strchr(_tmp_before_sub,':');if(_p1){strncpy(_tmp1,_tmp_before_sub,_p1 - _tmp_before_sub);_p1 = _p1 + 1;_slotno = atoi(_tmp1);portno = atoi(_p1);cslot=_slotno&0xff;cportsel=portno&0xff;portno=cslot*(MAXPortNum2+1) + cportsel;}else{portno = -1; }_no1 = portno;}{_p1 = strchr(_p,':');if(_p1){strncpy(_tmp2,_p,_p1 - _p);_p1 = _p1 + 1;_slotno = atoi(_tmp2); portno = atoi(_p1);cslot=_slotno&0xff;cportsel=portno&0xff;portno = cslot*(MAXPortNum2+1) + cportsel;  }else{portno = -1;}_no2 = portno;}} else{_p1 = strchr(_tmp,':'); if(_p1){strncpy(_tmp1,_tmp,_p1 - _tmp); _p1 = _p1 + 1;  _slotno = atoi(_tmp1);  portno = atoi(_p1);cslot=_slotno&0xff; cportsel=portno&0xff;portno=cslot*(MAXPortNum2+1)  + cportsel;}else {portno = -1;} _no1 = portno;_no2 = portno; }if (_no1 > _no2){ tmpno = _no1;  _no1 = _no2;  _no2 = tmpno;}if(_no1 == -1||_no2 == -1){_no2 = -1;_no1 = -1;}for(_i = _no1; _i<=_no2; _i++){portno = _i;
#define END_PARSE_PORT_LIST()   if(1==_i)_i+=15;} } }
*/
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -