📄 cli.c
字号:
typeOption[4] = SWI_MIRROR1_OPT_SHORT;
if (strcmp(argv[4+i], "-u") == 0)
typeOption[5] = SWI_MIRROR1_OPT_TXPKT_UMON;
if (strcmp(argv[4+i], "-d") == 0)
typeOption[6] = SWI_MIRROR1_OPT_MIRRORDIS;
if (strcmp(argv[4+i], "-k") == 0)
typeOption[7] = SWI_MIRROR1_KEEP_TYPEOPT;
}
}
SWMirrorSetConfig(port_no, receiveOption, transmitOption, typeOption);
printf("CmdMirrorSetConfig: port[%d], rxop=%d, txop=%d\n", port_no, receiveOption, transmitOption);
for (i = 0; i < 7; i++) {
printf("typeop[%d]=%d,", i, typeOption[i]);
if (i == 2)
printf("\n");
}
printf("\n");
}
/************************************************************************************/
/* CmdPortVLANConfig: */
/************************************************************************************/
void CmdPortVLANConfig(int argc, char **argv)
{
int i;
int group_no, portMapOpt[SWI_MAX_PORT_NUMBER];
// option description:
// group_no: the group number (0..5)
// portMapOpt[]: the forward port group (pd-d-d-d-d-d: 6 digits option)
group_no = 0;
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++)
portMapOpt[i] = 0;
// Get the port_no.
sscanf(argv[1], "%d", &group_no);
if ((group_no < 0) || (group_no > 5)) {
printf("ArgErr: the port_no must be in 0..5 !\n");
return;
}
// Get the port member map.
sscanf(argv[2], "p%d-%d-%d-%d-%d-%d", &portMapOpt[0], &portMapOpt[1], &portMapOpt[2], &portMapOpt[3],
&portMapOpt[4], &portMapOpt[5]);
SWPortVLANConfig(group_no, portMapOpt);
printf("PortVLANConfig: group[%d]\n", group_no);
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
printf("portMap[%d]=%d,", i, portMapOpt[i]);
if (i == 2)
printf("\n");
}
printf("\n");
}
/************************************************************************************/
/* CmdTagVLANConfig: */
/************************************************************************************/
void CmdTagVLANConfig(int argc, char **argv)
{
int i, filterIndex, vid, fid, filterValid, priQ;
int tagMapOpt[SWI_MAX_PORT_NUMBER], portMapOpt[SWI_MAX_PORT_NUMBER];
// option description:
// filterIndex: the index for the VLAN filter table (0..15) // add - 05/06/05,bolo
// vid: the VLAN ID (v0..v4095)
// fid: the FID value (f0..f15)
// filterValid: the VLAN filter valid (-v/-V)
// priQ: the VLAN queue priority (q0..q7)
// tagMapOpt[]: the tagged VLAN member (td-d-d-d-d-d: 6 digits option)
// portMapOpt[]: the port VLAN member (pd-d-d-d-d-d: 6 digits option)
vid = filterValid = 1;
filterIndex = fid = priQ = 0;
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
tagMapOpt[i] = portMapOpt[i] = 0;
}
// Get the filterIndex.
sscanf(argv[1], "%d", &filterIndex);
if ((filterIndex < 0) || (filterIndex > 15)) {
printf("ArgErr: the index of the VLAN filter table must be in 0..15 !\n");
return;
}
// Get the vid.
sscanf(argv[2], "v%d", &vid);
if ((vid < 0) || (vid > 4095)) {
printf("ArgErr: VLAN ID must be in 0..4095 !\n");
return;
}
// Get the fid.
sscanf(argv[3], "f%d", &fid);
if ((fid < 0) || (fid > 15)) {
printf("ArgErr: FID must be in 0..15 !\n");
return;
}
// Get the VLAN filter valid value
if (strcmp(argv[4], "-V") == 0)
filterValid = 0;
// Get the queue priority.
sscanf(argv[5], "q%d", &priQ);
if ((priQ < 0) || (priQ > 7)) {
printf("ArgErr: the queue priority must be in 0..7 !\n");
return;
}
// Get the tagged member map.
sscanf(argv[6], "t%d-%d-%d-%d-%d-%d", &tagMapOpt[0], &tagMapOpt[1], &tagMapOpt[2], &tagMapOpt[3],
&tagMapOpt[4], &tagMapOpt[5]);
// Get the port member map.
sscanf(argv[7], "p%d-%d-%d-%d-%d-%d", &portMapOpt[0], &portMapOpt[1], &portMapOpt[2], &portMapOpt[3],
&portMapOpt[4], &portMapOpt[5]);
SWTagVLANConfig(filterIndex, vid, fid, filterValid, priQ, tagMapOpt, portMapOpt);
printf("TagVLANConfig: index=%d, vid=%d, fid=%d, valid=%d, priQ=%d\n", filterIndex, vid, fid, filterValid, priQ);
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
printf("tagMap[%d]=%d,portMap[%d]=%d,", i, tagMapOpt[i], i, portMapOpt[i]);
if (i == 2)
printf("\n");
}
printf("\n");
}
/************************************************************************************/
/* CmdVLANOptionConfig: */
/************************************************************************************/
void CmdVLANOptionConfig(int argc, char **argv)
{
int i, optionItem;
int optionValue[SWI_MAX_PORT_NUMBER];
// option description:
// optionItem: the VLAN option item number (0..8)
// 0: VID check, 1: Default VLAN Member, 2: Default FID, 3: Back to Port VLAN
// 4: Input Force No Tag, 5: Ingress Filter, 6: Admit Only VLAN_TAGGED, 7: Output Tag Pass
// 8: VLAN Security
// optionValue: the VLAN option value (vd-d-d-d for item-2: Default FID, other items: vd-d-d-d-d-d)
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
optionValue[i] = 0;
}
// Get the option item number.
sscanf(argv[1], "%d", &optionItem);
if ((optionItem < 0) || (optionItem > 8)) {
printf("ArgErr: the option item number must be in 0..8 !\n");
return;
}
// Get the option value.
if (optionItem == 2)
sscanf(argv[2], "v%d-%d-%d-%d", &optionValue[0], &optionValue[1], &optionValue[2], &optionValue[3]);
else
sscanf(argv[2], "v%d-%d-%d-%d-%d-%d", &optionValue[0], &optionValue[1], &optionValue[2],
&optionValue[3], &optionValue[4], &optionValue[5]);
SWVLANOptionConfig(optionItem, optionValue);
printf("PortVLANConfig: option[%d]: \n", optionItem);
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
printf("optVal[%d]=%d,", i, optionValue[i]);
if (i == 2)
printf("\n");
}
printf("\n");
}
/************************************************************************************/
/* CmdPortPriConfig: */
/************************************************************************************/
void CmdPortPriConfig(int argc, char **argv)
{
int port_no, portPriQOpt, portPriEn, portVID; // mod - 08/12/05 for the port VID;
// option description:
// port_no: the port number (0..5)
// portPriEn: the port priority enable selection (-o or -O)
// portPriQOpt: the port priority queue option (m0..m3)
// portVID: the private VID for each port (v0..v4095) // add - 08/12/05 for the port VID
portPriEn = 1;
portVID = -1; // add - 08/12/05 for the port VID;
// Get the port_no.
sscanf(argv[1], "%d", &port_no);
if ((port_no < 0) || (port_no > 5)) {
printf("ArgErr: the port_no must be in 0..5 !\n");
return;
}
if (strcmp(argv[2], "-O") == 0)
portPriEn = 0;
// Get the port priority queue option
sscanf(argv[3], "m%d", &portPriQOpt);
if ((portPriQOpt < 0) || (portPriQOpt > 3)) {
printf("ArgErr: the port priority queue option must be in 0..3 !\n");
return;
}
if (argc > 4) { // add - 08/12/05 for the port VID
// Get the vid.
sscanf(argv[4], "v%d", &portVID);
if ((portVID < 0) || (portVID > 4095)) {
printf("ArgErr: the port VID must be in 0..4095 !\n");
return;
}
}
SWPortPriConfig(port_no, portPriEn, portPriQOpt, portVID); // mod - 08/12/05 for the port VID
if (portVID >= 0) { // add - 08/12/05 for the port VID
printf("PortPriConfig: port[%d], PriEn=%d, QOpt=%d, portVID=%d\n", port_no, portPriEn, portPriQOpt, portVID);
} else {
printf("PortPriConfig: port[%d], PriEn=%d, QOpt=%d\n", port_no, portPriEn, portPriQOpt);
}
}
/************************************************************************************/
/* CmdVLANPriConfig: */
/************************************************************************************/
void CmdVLANPriConfig(int argc, char **argv)
{
int i, port_no, priQID, vlanQOpt, ipoVlan;
int vlanPriEn[SWI_MAX_PORT_NUMBER];
// option description:
// port_no: the port number (0..5)
// vlanPriEn[]: the VLAN priority enable map (vd-d-d-d-d-d: 6 digits option)
// priQID: the priority queue ID (q0..q7)
// vlanQOpt: the VLAN priority queue option (m0..m3)
// ipoVlan: the IP over VLAN PRI selection (-ip or -vp)
ipoVlan = 0;
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
vlanPriEn[i] = 0;
}
// Get the port_no.
sscanf(argv[1], "%d", &port_no);
if ((port_no < 0) || (port_no > 5)) {
printf("ArgErr: the port_no must be in 0..5 !\n",port_no);
return;
}
// Get the VLAN priority enable map.
sscanf(argv[2], "v%d-%d-%d-%d-%d-%d", &vlanPriEn[0], &vlanPriEn[1], &vlanPriEn[2], &vlanPriEn[3],
&vlanPriEn[4], &vlanPriEn[5]);
// Get the priority queue ID.
sscanf(argv[3], "q%d", &priQID);
if ((priQID < 0) || (priQID > 7)) {
printf("ArgErr: the priority queue ID must be in 0..7 !\n");
return;
}
// Get the VLAN priority queue option
sscanf(argv[4], "m%d", &vlanQOpt);
if ((vlanQOpt < 0) || (vlanQOpt > 3)) {
printf("ArgErr: the VLAN priority queue option must be in 0..3 !\n");
return;
}
if (strcmp(argv[5], "-ip") == 0)
ipoVlan = 1;
SWVLANPriConfig(port_no, vlanPriEn, priQID, vlanQOpt, ipoVlan);
printf("VLANPriConfig: port[%d], QID=%d, QOpt=%d, ipoV=%d\n", port_no, priQID, vlanQOpt, ipoVlan);
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
printf("PriEn[%d]=%d,", i, vlanPriEn[i]);
if (i == 2)
printf("\n");
}
printf("\n");
}
/************************************************************************************/
/* CmdTOSPriConfig: */
/************************************************************************************/
void CmdTOSPriConfig(int argc, char **argv)
{
int i, tospriQID, tosQOpt;
int tosPriEn[SWI_MAX_PORT_NUMBER];
// option description:
// tosPriEn[]: the service priority enable map (sd-d-d-d-d-d: 6 digits option)
// tospriQID: the TOS priority queue ID (q0..q7)
// tosQOpt: the TOS priority queue option (m0..m3)
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
tosPriEn[i] = 0;
}
// Get the service priority enable map.
sscanf(argv[1], "s%d-%d-%d-%d-%d-%d", &tosPriEn[0], &tosPriEn[1], &tosPriEn[2], &tosPriEn[3],
&tosPriEn[4], &tosPriEn[5]);
// Get the TOS priority queue ID.
sscanf(argv[2], "q%d", &tospriQID);
if ((tospriQID < 0) || (tospriQID > 7)) {
printf("ArgErr: the TOS priority queue ID must be in 0..7 !\n");
return;
}
// Get the TOS priority queue option
sscanf(argv[3], "m%d", &tosQOpt);
if ((tosQOpt < 0) || (tosQOpt > 3)) {
printf("ArgErr: the TOS priority queue option must be in 0..3 !\n");
return;
}
SWTOSPriConfig(tosPriEn, tospriQID, tosQOpt);
printf("TOSPriConfig: QID=%d, QOpt=%d\n", tospriQID, tosQOpt);
for (i = 0; i < SWI_MAX_PORT_NUMBER; i++) {
printf("PriEn[%d]=%d,", i, tosPriEn[i]);
if (i == 2)
printf("\n");
}
printf("\n");
}
/************************************************************************************/
/* CmdSrvPriConfig: */
/************************************************************************************/
void CmdSrvPriConfig(int argc, char **argv)
{
int i, tsrvpriQID, tsrvQOpt;
int tsrvPriEn[SWI_MAX_PORT_NUMBER];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -