?? menu.c
字號:
/*
*menu.c
* Original Author: zhough@ruijie.com.cn 2007-8-30
* 主要包括調試的信息
*/
#include<stdio.h>
#include<stdlib.h>
#include"vlan.h"
int main()
{
int pid,vid;
int speed;
char flag ;
char name[10];
init_vlan();
init_port();
menu();
while(1)
{
flag=getchar();
switch (flag)
{
case 'p':
printf("input the of the port id that you want to create \n");
scanf("%d", &vid);
if( add_port(vid , 1000,1)!=NULL)
printf("port %d create success \n",vid);
menu();
break;
case 'v':
printf("input the of the port id that you want to create \n");
scanf("%d", &vid);
if( create_vlan(vid , "star-net")!=NULL)
printf("vlan %d create success \n",vid);
menu();
break;
case 'a':
printf("input the port id and the vlan id ,so you can add the port to the vlan \n");
printf("vid=");
scanf("%d", &vid);
printf("\npid=");
scanf("%d", &pid);
if( add_port_to_vlan(vid,pid)==1)
printf("port= %d add to vlan=%d successfully \n",pid, vid);
else
printf(" add failure \n");
break;
menu();
case 'c':
printf("input the vlan that you want to check \n");
scanf("%d", &vid);
printf("input the port that you want to check \n");
scanf("%d", &pid);
if( is_contain( vid, pid)==1)
printf("port=%d in vid=%d \n",pid ,vid);
else
printf("port=%d not in vid=%d \n",pid ,vid);
menu();
break;
case 'd':
printf("input the vlan that you want to delete the port \n");
scanf("%d", &vid);
printf("input the port that you want to delete \n");
scanf("%d", &pid);
del_port_from_vlan(vid,pid);
menu();
break;
case 'P':
printf("can print allthe port of a vlan \n");
printf("can input the vlan num \n");
scanf("%d", &vid);
print_vlan(vid );
menu();
break;
case 10:
break;
default:
printf("input illegal \n ");
menu();
break;
}
}
}
menu()
{
printf("=============================MENU=======================\n");
printf("1.create a port ,press 'p' \n");
printf("2.create a vlan ,press 'v' \n");
printf("3.add a created port to a vlan ,press 'a' \n");
printf("4.check a port is contined in a vlan, press 'c' \n");
printf("5.delete a vlan press 'd' \n");
printf("6.print all port in a vlan press 'P' \n");
printf("=========================================================\n");
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -