strcpy(co[from].mess.Data,message1.Data);//构造源主机所发消息的数据部分 }
char* InputMAC() {
int i; string temp;
bool error=true;
while(error)//直到输入正确的MAC形式如\
{ cout<<\
if(temp.length()!=17)//输入的字符长度不是17立刻跳到最后
{
error=true; goto last; }
for(i=0;i<5;i++)//只要有一个错误立刻跳到最后 if(temp.at(3*i+2)!='-') {
error=true; goto last; }
for(i=0;i<18;i=i+3)//只要一个不在\中产生错误
if(!( (temp.at(i)>='0'&&temp.at(i)<='9')||
(temp.at(i)>='A'&&temp.at(i)<='F')||
(temp.at(i)>='a'&&temp.at(i)<='f') )
&&
!((temp.at(i+1)>='0'&&temp.at(i+1)<='9')||
(temp.at(i+1)>='A'&&temp.at(i+1)<='F')||
(temp.at(i+1)>='a'&&temp.at(i+1)<='f'))
) {
error=true; goto last; }
error=false;//没有error
last: if(error) {
cout<<\ } else
如果程度执行到这里肯定是正确的MAC,输入有错误\\n\ {
for(i=0;i }//正确的MAC,退出while(error)返回MAC return MAC; } void Start() { bool flag=true; char num_select; while(flag) { system(\ Graph(); Menu(); num_select=SelectNum(); switch(num_select) { case'1': cout< cin.clear();//清空输入流 MakeMessage(); Working(); cout.flush(); system(\ break; case'2': cout< sw.PrintTable(); cout.flush();//刷新输出流 system(\暂停 break; case'3': cout< if(port>0&&port<6)//构造消息以后从交换机哪个port进入是确定的1~5 { //才能工作 Working(); } else cout<<\先构造消息\\n\ cout.flush(); system(\ break; case'4': cout< SetComputer(); cout.flush(); system(\ break; case'5': cout< SetSwitcher(); cout.flush(); system(\ break; case'6': //退出程序结束while(flag) cout< flag=false; break; default: cout< cout<<\选择错误重新选择\ system(\ break; } } } void Working() {