📄 igmpcon_snmp.c
字号:
{
typePkt (p, size);
}
t_len = size;
if (size%SNMP_MAX_PACKET_LENGTH)
return size/SNMP_MAX_PACKET_LENGTH + 2;
else
return size/SNMP_MAX_PACKET_LENGTH+1;
}
int get_group_parameters_size (void)
{
int size = 0;
size = 4+17*Totalauthgroup;
return size;
}
int group_parameters_get_new(int index, char *buf, /*int*/unsigned short *len)
{
char *p;
int maxlen= SNMP_MAX_PACKET_LENGTH;
if (index == 0)
return -1;
if (index == 1)
{
group_parameters_get_buf();
}
if (t_len > maxlen)
p = totalbuf;
else
p = tempbuf;
if (index*maxlen <= t_len)
{
memcpy (buf, p+ (index-1)*maxlen, maxlen);
*len = maxlen;
}
else if (index*maxlen-t_len < maxlen && index*maxlen-t_len >0)
{
memcpy (buf, p+(index-1)*maxlen, t_len- (index-1)*maxlen);
*len = t_len-(index-1)*maxlen;
}
else if (index*maxlen - t_len >= maxlen)
{
*len = 0;
printf ("end of group_parameters_get_new\r\n");
if (t_len > SNMP_MAX_PACKET_LENGTH && totalbuf)
{
free (totalbuf);
totalbuf = NULL;
}
else
{
memcpy (tempbuf, 0, sizeof (tempbuf));
}
t_len = 0;
}
else
{
*(int *)buf = 1;
*len = 6;
}
if (type_snmp)
typePkt (buf, *len);
return 0;
}
int igmp_mode_set (char *buf, short len, STRUCT_ERROR_INFO *err)
{
int i;
int mode;
short vlan;
set_error_code(err, SNMP_SUCCESS, 0,0);
(char )mode = *buf;
if (mode == gIGMPMODE)
return 0;
/*snoop mode change to no igmp mode, aibin 20080730*/
if (MODE_SNOOPING == mode )
{
driver_igmpdisable();
#ifdef _AN5116_06A_
driver_dtag_igmpdisable();
/* for (vlan = 1; vlan <= 4095; i++)
{
bcm_vlan_mcast_flood_set(0, vlan, 0);
}*/
#endif
}
else if (gIGMPMODE == MODE_SNOOPING )
{
driver_igmpenable();
#ifdef _AN5116_06A_
driver_dtag_igmpenable();
#endif
}
/* if (mode == MODE_CONTROL|| mode == MODE_PROXY)
{
if (gIGMPMODE == MODE_PROXY)
{
}
if (gIGMPMODE == MODE_SNOOPING)
{
driver_igmpenable();
}
}
if (mode == MODE_SNOOPING)
{
driver_igmpenable();
driver_igmpdisable();
}
*/
gIGMPMODE = mode;
for (i = 1; i <= MAX_DOWN_SLOT; i++)
SendCfgPkt(igmpmodemsg, i,1,1,0);
}
int igmp_mode_get (char *buf, short *len)
{
char *p;
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*p = gIGMPMODE;
p++;
*len = p-buf;
}
int force_leave_set (char slotno, char onuno, char portno,
unsigned int groupaddr, STRUCT_ERROR_INFO *err)
{
int i;
char inter_slot;
set_error_code(err, SNMP_SUCCESS, 0,0);
if (slotno > 8)
{
slotno -= 2;
}
if (bConDebugSnmp)
{
printf ("%d, %d, %d, %x\r\n", slotno, onuno, portno, groupaddr);
}
return SendForceLeaveMsg (slotno, onuno, portno, 0, groupaddr);
}
int flush ()
{
int slot;
int i;
for (slot = 1; slot <= MAX_DOWN_SLOT; slot++)
{
if (SlotType (slot) != -1)
SendCfg2Slot(slot);
}
return OK;
}
int snmp_clear_igmp_log (char *buf, char *err, short *errlen )
{
set_error_code((STRUCT_ERROR_INFO *)err, SNMP_SUCCESS, 0,0);
*errlen = 6;
ClearRecordList();
return 0;
}
int online_groups_Membercount_get (char *buf, unsigned short *len)
{
int size, portcount, *portnum;
char *p, slot;
GroupInfo *ptmp;
groupMember *pMember;
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*(short *) p = Totalgroup;
p += 2;
ptmp = infolist;
while (ptmp)
{
*(UINT *) p = ptmp->groupaddress;
p += 4;
*p = ptmp->totaluser;
portnum = (int *) p;
portcount = 0;
p += 4;
pMember = ptmp->member;
while (pMember)
{
portcount++;
if (pMember->slot > 8)
{
slot = pMember->slot + 2;
}
else
{
slot = pMember->slot;
}
*p = slot;
p++;
*p = pMember->onu;
p++;
*p = pMember->onuPort;
p++;
*p = pMember->state;
p++;
pMember = pMember->pNext;
}
*portnum = portcount;
ptmp = ptmp->pNext;
}
*len = p - buf;
return OK;
}
int online_port_groupnum_get (UCHAR slot, UCHAR onu, UCHAR onuPort, char *buf,
unsigned short *len)
{
char *p;
GroupInfo *ptmp;
UCHAR count;
short gcount, *gc;
short inter_slot;
groupMember *pMember;
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*p = slot;
p++;
*p = onu;
p++;
*p = onuPort;
p++;
*(short *) p = 0;
gc = (short *) p;
p += 2;
if (slot > 8)
{
inter_slot = slot - 2;
}
else
{
inter_slot = slot;
}
gcount = 0;
ptmp = infolist;
while (ptmp)
{
pMember = ptmp->member;
while (pMember)
{
if (pMember->slot == inter_slot && pMember->onu == onu
&& pMember->onuPort == onuPort)
{
*(UINT *) p = ptmp->groupaddress;
p += 4;
*p = pMember->state;
p++;
gcount++;
}
pMember = pMember->pNext;
}
ptmp = ptmp->pNext;
}
*gc = gcount;
*len = p - buf;
return OK;
}
int igmp_records_get (short logcount, char *buf, unsigned short *len)
{
short showcount;
char *p;
PortRecord *ptmp;
char exten_slot;
#if 0
if (!logcount || logcount > recordcount)
{
showcount = recordcount;
}
else
{
showcount = logcount;
}
#endif
showcount = recordcount;
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*(short *) p = showcount;
p += 2;
semTake (semConLog, WAIT_FOREVER);
ptmp = recordlist;
while (showcount)
{
memcpy (p, ptmp->time, 20);
p += 20;
if (ptmp->slot > 8)
{
exten_slot = ptmp->slot + 2;
}
else
{
exten_slot = ptmp->slot;
}
*p = exten_slot;
p++;
*p = ptmp->onu;
p++;
*p = ptmp->onuPort;
p++;
*p = ptmp->preview;
p++;
*(UINT *) p = ptmp->groupaddress;
p += 4;
*p = ptmp->cmd;
p++;
*p = ptmp->state;
p++;
*p = ptmp->staying;
p++;
ptmp = ptmp->pNext;
showcount--;
}
semGive (semConLog);
*len = p - buf;
return OK;
}
int statistic_information_bygroup_get_new (void)
{
GroupStat *ptmp;
char *p, *buf;
short count;
char max[10], time[10], every[10], prev[10];
int size;
size = 48*groupstatcount + 2 + 6;
t_len = size;
if (size > SNMP_MAX_PACKET_LENGTH)
{
if (totalbuf != NULL)
{
free (totalbuf);
totalbuf = NULL;
}
totalbuf = (char *)malloc (size);
if (NULL == totalbuf)
return -1;
memset (totalbuf, 0, sizeof (size));
buf = totalbuf;
}
else
{
memset (tempbuf, 0, sizeof (tempbuf));
buf = tempbuf;
}
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*(short *)p = groupstatcount;
p += 2;
count = groupstatcount;
ptmp = groupstatlist;
while (ptmp && count)
{
memset (max, 0, 10);
memset (time, 0, 10);
memset (every, 0, 10);
memset (prev, 0, 10);
TimeConvert (ptmp->totaltime, time);
TimeConvert (ptmp->previewtime, prev);
TimeConvert (ptmp->maxtime, max);
TimeConvert ((ptmp->totaltime / ptmp->totalcount), every);
*(UINT *) p = ptmp->groupaddress;
p += 4;
*(USHORT *) p = ptmp->totalcount;
p += 2;
memcpy (p, every, 10);
p += 10;
memcpy (p, max, 10);
p += 10;
memcpy (p, time, 10);
p += 10;
*(USHORT *) p = ptmp->previewcount;
p += 2;
memcpy (p, prev, 10);
p += 10;
ptmp = ptmp->pNext;
count--;
}
return t_len/SNMP_MAX_PACKET_LENGTH + 1;
}
int statistic_information_bygroup_get_size (void)
{
return 48*groupstatcount + 2;
}
int statistics_byport_get_new (void)
{
char max[10], time[10], every[10], prev[10];
char inter_slot;
int count, size, len;
int i, j, k;
char start, end;
char *p,*buf;
char temp[50];
count = 0;
PASS_ONU(i, j)
{
if (onulist[i][j].flag_ftth)
{
start = onulist[i][j].igmp_port;
end =start;
}
else
{
start = 1;
end = onulist[i][j].total_port;
}
for (k = start; k <= end; ++k)
{
/*printf ("port %d:%d:%d, totalcount=%d\r\n", i, j, k,portstatlist[i][j][k].totalcount);*/
if (portstatlist[i][j][k].totalcount)
count++;
}
}
END_PASS_ONU
size = 35*count + 2 + 4;
t_len = size;
/*printf ("size =%d, t_len=%d\r\n", size, t_len);*/
if (size > SNMP_MAX_PACKET_LENGTH)
{
if (totalbuf != NULL)
{
free (totalbuf);
totalbuf = NULL;
}
totalbuf = (char *)malloc (size);
if (NULL == totalbuf)
return -1;
memset (totalbuf, 0, sizeof (size));
buf = (char *)totalbuf;
}
else
{
memset (tempbuf, 0, sizeof (tempbuf));
buf = tempbuf;
}
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*(short *)p = count;
p += 2;
PASS_ONU(i, j)
{
if (onulist[i][j].flag_ftth)
{
start = onulist[i][j].igmp_port;
end =start;
}
else
{
start = 1;
end = onulist[i][j].total_port;
}
for (k = start; k <= end; ++k)
{
if (portstatlist[i][j][k].totalcount)
{
*p = translateslot_out(i);
p++;
*p = j;
p++;
*p = k;
p++;
*(short *) p = portstatlist[i][j][k].totalcount;
p += 2;
memset (max, 0, 10);
memset (time, 0, 10);
memset (every, 0, 10);
TimeConvert (portstatlist[i][j][k].totaltime, time);
TimeConvert (portstatlist[i][j][k].maxtime, max);
TimeConvert ((portstatlist[i][j][k].totaltime /
portstatlist[i][j][k].totalcount), every);
memcpy (p, every, 10);
p += 10;
memcpy (p, max, 10);
p += 10;
memcpy (p, time, 10);
p += 10;
}
}
}
END_PASS_ONU
return t_len/SNMP_MAX_PACKET_LENGTH + 1;
}
int statistics_byport_get_size (void)
{
char max[10], time[10], every[10], prev[10];
char inter_slot;
int count, size, len;
int i, j, k;
char start, end;
char *p,*buf;
char temp[50];
count = 0;
PASS_ONU(i, j)
{
if (onulist[i][j].flag_ftth)
{
start = onulist[i][j].igmp_port;
end =start;
}
else
{
start = 1;
end = onulist[i][j].total_port;
}
for (k = start; k <= end; ++k)
{
if (portstatlist[i][j][k].totalcount)
count++;
}
}
END_PASS_ONU
size = 35*count + 2;
return size;
}
int get_igmp_uplink_info (char *buf, short* len)
{
char *p, *g_count;
char gcount;
char port;
GroupEntity *ptmp;
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
*p = MAX_UPLINK_PORT-MIN_UPLINK_PORT+1;
p++;
for (port = MIN_UPLINK_PORT; port <= MAX_UPLINK_PORT; port++)
{
gcount = 0;
#ifdef _AN5116_06A_
if (port == 17)
*p = 8;
else if (port == 25)
*p = 9;
else if (port == 26)
*p = 10;
else
*p = port -17;
#else
*p = port -17;
#endif
p++;
*p = slot_module[port];
p++;
g_count = p;
*g_count = 0;
p += 2;
semTake (semIgmpDelete, WAIT_FOREVER);
ptmp = pGroupEntityList;
while (ptmp)
{
if (ptmp->eGroupPortStatus[port] != NoMembersPresent)
{
*(UINT *)p = ptmp->unGroupAddress;
p += 4;
gcount++;
}
ptmp = ptmp->pNext;
}
semGive(semIgmpDelete);
*(short *)g_count = gcount;
}
*len = p-buf;
}
int igmp_all_profilenum (char *buf, unsigned short *len)
{
char profile_num, *p_n;
char *p;
int i;
p = buf;
*(int *)p = SNMP_SUCCESS;
p += 4;
profile_num = 0;
*p = 0;
p_n = p;
p++;
for (i = 1; i <= MaxTemp; i++)
{
if (profile[i].used)
{
profile_num++;
memcpy (p, profile[i].name, 20);
p += 20;
}
}
*p_n = profile_num;
*len = p - buf;
return OK;
}
int onu_fastleave_capability_get (char slot, char onu, char *buf, unsigned short *len)
{
int count, i;
char *p;
char slottemp;
memset (buf, 0, 3);
*(buf+3) =1;
p = buf +4;
slottemp = translateslot_in(slot);
portstatlist[slottemp][onu][1].fast_leave_capability = 1;
/* gPortCfgResponse = 0;
SendCfgPkt (portcfgquerymsg, translateslot_in(slot),onu, 1, 0);
count = 2* (sysClkRateGet () / 10);
for (i = 0; i < count; i++)
{
taskDelay (10);
/*收到响应
if (gPortCfgResponse == 1)
{
break;
}
}
*/
*p = slot;
p++;
*p = onu;
p++;
slot = translateslot_in(slot);
*p = portstatlist[slot][onu][1].fast_leave_capability;
*len =7 ;
typePkt (buf, *len);
return 0;
}
int auto_upload_igmplog_set (char *buf, int len, STRUCT_ERROR_INFO *err)
{
int ip, ret;
char host[21], user[21], pass[21];
short interval;
struct vty *vty = NULL;
struct in_addr gip;
char *p;
if (type_snmp)
typePkt (buf, len);
set_error_code(err, SNMP_SUCCESS, 0,0);
/*disable*/
if (*buf == 0)
{
Set_auto_upload_dis_para(vty);
}
/*enable*/
else
{
interval = *(short *)(buf + 1);
gip.s_addr = *(unsigned int *)(buf+3);
inet_ntoa_b (gip, host);
strncpy (user, buf+7, 20);
strncpy (pass, buf+27, 20);
ret = Set_auto_upload_en_para(host, user, pass, interval, vty);
if (ret != 0)
set_error_code(err, SNMP_ERROR, 0,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -