📄 igmpcon.h~
字号:
typedef struct Rec_Pkt
{
UCHAR type; /*类型 */
UCHAR port; /*端口号 */
UCHAR count; /*组的个数 */
UCHAR cmd; /*命令 */
} RecPkt;
typedef struct info_pkt
{
struct Rec_Pkt header;
UINT groupaddress;
} InfoPkt;
/*配置包的部分帧格式*/
typedef struct Group_Cfg
{
UINT gip; /*组地址 */
UCHAR state:4; /*权限,1表示可加入,2表示可预览 */
UCHAR count:4; /*预览次数 */
UCHAR pretime; /*预览持续时间 */
UCHAR preinterval; /*预览间隔 */
UCHAR prereset; /*预览复位时间 */
} GroupCfg;
/*配置使能帧帧格式*/
typedef struct Cfg_enable
{
UCHAR type; /*类型 */
UCHAR slot; /*槽位号 */
USHORT res;
UINT p1; /*1-32端口的使能 */
UINT p2; /*33-64端口 */
} Cfgen;
/*端口组播记录*/
typedef struct Port_Record
{
struct Port_Record *pNext;
struct Port_Record *pPrv;
char time[20]; /*时间 */
UCHAR slot; /*槽位号 */
UCHAR onu;
UCHAR onuPort; /*端口号 */
UCHAR cmd; /*1加入,0离开,2保持 */
UCHAR state; /*加入离开状态,加入时:0成功1失败;离开时:0正常,1强迫 */
UINT groupaddress; /*组播组地址 */
UINT ctime; /*日志产生的绝对时间(tic) */
UCHAR preview; /*预览标志 */
USHORT staying; /*在线时间 */
} PortRecord;
/*组播组统计*/
typedef struct Group_Stat
{
struct Group_Stat *pNext;
struct Group_Stat *pPrv;
UINT groupaddress;
USHORT failcount; /*失败的次数 */
UINT totalcount; /*加入总次数 */
UINT previewcount; /*预览次数 */
UINT previewtime; /*预览总时间sec */
UINT totaltime; /*观看的总时间sec */
USHORT maxtime; /*最长观看时间 sec */
char show; /*显示标志位,显示过为1,否则0 */
} GroupStat;
/*定时器节点*/
typedef struct TimerNode
{
char type;
char slot;
} timer_node;
/*组播用户统计*/
typedef struct Port_stat
{
UINT totaltime; /*观看的总时间sec */
UINT bandwidth; /*端口总带宽 */
UINT curbd; /*当前带宽 */
USHORT totalcount; /*加入总次数 */
USHORT maxtime; /*最长观看时间 sec */
USHORT gouplimit; /*端口最大组数 */
/*short trans_vlan; /*端口翻译vlan,0为无设置 */
char tmpno; /*端口所在模板号 */
char control; /*1控制打开,0,控制关闭 */
char vlanpeer; /*1 vlan剥离 0,不剥离 */
char fast_leave_capability; /*快速离开能力 */
char fast_leave_state; /*快速离开状态 */
/* short vlan[11]; *//*端口组播vlan */
/*char vlanmanage; /*端口的vlan管理功能,1表示协议报文只转入端口vlan中 */
} PortStat;
typedef struct igmp_onu
{
char slot;
unsigned char onu;
char flag_ftth;
char type;
char igmp_port;
char total_port;
char used;
} IgmpOnu;
#define SNMP_SUCCESS 0x1
#define SNMP_ERROR 0x41
#define ERROR_MALLOC 1
typedef struct error_unit
{
/*单个错误对象的结构 */
unsigned short length; /*对象1参数长度 (2B) 包含对象1错误原因、对象1保留内容和对象1参数。定长58B。 */
int code; /*对象1错误原因 (4B) 即错误编码,由命令ID和该命令下的错误ID组成,由设备方提供。 */
int reserved; /*对象1保留内容 (4B) 空 */
char para[50]; /*对象1参数 (50B) 定长50B。内容根据不同命令变化,如模板名(占30字节)、端口号(占2字节)... */
} STRUCT_ERROR_UNIT;
typedef struct error_Info
{
int returncode; /*命令返回代码(4B) 0x01 = 成功 0x41 = 命令失败 */
short errnum;
STRUCT_ERROR_UNIT errarray[50];
} STRUCT_ERROR_INFO;
int SendCfgPkt (UCHAR type, UCHAR slot, UCHAR onu, UCHAR onuPort, char start);
int RecConPktGsw (short slot, char *ConPkt, USHORT usLength);
int CheckGroupAddress (char *address);
/*接口函数*/
/*void dm_MakeCmdPkt_IGMP (int slotno, short cmd_id, char *pkt_data_argv, int len);*/
int comm_getTime (char *time);
int ConInit (void);
int ConfigSwitchCollect (UCHAR * buf);
int ConfigSwitchExecute (UCHAR * buf);
void getTime (char *time);
/*int InputPortCheck(char slot, char port, struct vty * vty);*/
/*extern int GetGroupVlan(UINT groupaddress);*/
void ProcessStartUpSend (void);
void ShowRunProfile (int tmpno);
/*inter interface*/
extern int del_all_cascade_port (void);
extern void free_grouplist (void);
/*extern int CheckUpBandwidth (UINT groupaddress);*/
/*extern int GetLeaveDelay (UINT groupaddress);*/
extern int GetOnlineGroupVlan (UINT groupaddress);
extern int stricmp (char *s1, char *s2);
extern void GetOnuList (char *str, char *onu, int len);
extern void delGroupFromOnlineList (GroupInfo * onlinegroup);
extern int SendForceLeaveMsg (UCHAR slot, UCHAR onu, UCHAR onuPort, UCHAR cmd,
UINT groupaddress);
extern void StartRecordTimer (void);
extern int GroupVlanExist (USHORT vlanid);
extern GroupAuth *GetAuthGroup (UINT groupaddress);
extern GroupInfo *GetCurGroup (UINT groupaddress);
extern void clear_port_config (void);
extern int get_max_slot_onu (char inter_slot);
extern void sendQuery2AllGroupvlan (char inter_slot, char *igmpPkt, short len);
#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*(MaxPort+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*(MaxPort+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*(MaxPort+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+=17;} } }
#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_ONU_LIST(onulist, onu) {short _no1,_no2,_i,tmpslot; char *_cur,*_p,*_p1; char _tmp[20],_tmp1[20],_tmp2[20],_tmp_before_sub[20]; _cur = onulist; while (_cur) { bzero(_tmp,20); bzero(_tmp1,20); bzero(_tmp2,20); bzero(_tmp_before_sub,20); _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; onu = atoi(_tmp_before_sub); _no1 = onu; onu = atoi(_p); _no2 = onu; } else{ onu = atoi(_tmp); _no1 = onu; _no2 = onu; } if (_no1 > _no2) { tmpslot = _no1; _no1 = _no2; _no2 = tmpslot; } for(_i = _no1; _i<=_no2; _i++) {onu = _i;
#define END_PARSE_ONU_LIST() } } }
#define PASS_PORT(slot, onu, port) for(slot=1;slot<=MAX_DOWN_SLOT;slot++){for(onu=1;onu<= MaxOnu;onu++){for(port=1;port<=MaxOnuPort;port++)
#define END_PASS_PORT }}
#define PASS_ONU(slot, onu) for(slot=1;slot<=MAX_DOWN_SLOT;slot++){for(onu=1;onu<= MaxOnu;onu++)
#define END_PASS_ONU }
#define showsysinfo "Show system informations.\n"
#define showigmpinfo "Show igmp informations.\n"
#define showportinfo "Show igmp port infomations.\n"
#define setsysinfo "Set system configuration.\n"
#define setigmpinfo "Set igmp configuration.\n"
#define setportinfo "Set igmp port configuration.\n"
#define inputslot "Please input slot no.\n"
#define inputonu "Please input onu list.\n"
#define inputport "Please input onu port no.\n"
#define inputenable "Enable service.\n"
#define inputedisable "Disable service.\n"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -