Most cases have analogous format as case 10, so I only pasted case 10.
It seems that the first two statements are skipped, no matter what they are,
while the case number is above 10.
Therefore, I thought that the problem may be caused by the codes in case 10,
but I can not figure out how could this happen.
-------------
scanf("%d",&cmd);
switch(cmd){
case 1: similar as case 10
case 2: similar as case 10
case 3: similar as case 10
case 10: /*insert inbound SPD*/
spd_udp.opcode = SPD_IN_INSERT;
printf("please input the addr1 & addr2 (XX XX, XX=00-3F): ");
scanf("%x %x",&addr1,&addr2);
printf("please select an action : \n");
printf("1: bypass \n");
printf("2: IPsec \n");
printf("3: disard \n");
scanf("%d",&sel);
if(sel == 1)
{
entry_spd.ctrl.action_index = 0;
entry_spd.ctrl.next_index = 0;
}
else if(sel == 2)
{
entry_spd.ctrl.action_index = 64;
entry_spd.ctrl.next_index = 0;
}
else if(sel == 3)
{
entry_spd.ctrl.action_index = 128;
entry_spd.ctrl.next_index = 0;
}
else
{
printf("error selection!! \n");
break;
}
spd_udp.oper.operand_addr1 = addr1;
spd_udp.oper.operand_addr2 = addr2;
sendstring[0] = spd_udp.opcode;
sendstring[1] = spd_udp.oper.operand_addr1;
sendstring[2] = spd_udp.oper.operand_addr2;
sendstring[3] = entry_spd.ctrl.action_index;
sendstring[4] = entry_spd.ctrl.next_index;
sendstring[5] = 0;
sendstring[6] = entry_spd.protocol;
printf("please input sip value (XX XX XX XX, XX=00-FF): ");
scanf("%x %x %x %x", &b[0], &b[1], &b[2], &b[3]);
entry_spd.sip = word_build(b[0],b[1],b[2],b[3]);
for (i=7; i<11; i++)
{
sendstring = b[i-7];
}
printf("please input sip Mask value (XX XX XX XX, XX=00-FF): ");
scanf("%x %x %x %x", &b[0], &b[1], &b[2], &b[3]);
entry_spd.sipMask = word_build(b[0],b[1],b[2],b[3]);
for (i=11; i<15; i++)
{
sendstring = b[i-11];
}
printf("please input dip value (XX XX XX XX, XX=00-FF): ");
scanf("%x %x %x %x", &b[0], &b[1], &b[2], &b[3]);
entry_spd.dip = word_build(b[0],b[1],b[2],b[3]);
for (i=15; i<19; i++)
{
sendstring = b[i-16];
}
printf("please input dip Mask value (XX XX XX XX, XX=00-FF): ");
scanf("%x %x %x %x", &b[0], &b[1], &b[2], &b[3]);
entry_spd.dipMask = word_build(b[0],b[1],b[2],b[3]);
for (i=19; i<23; i++)
{
sendstring = b[i-19];
}
printf("please input spMaxMin value (XX XX XX XX, XX=00-FF): ");
scanf("%x %x %x %x", &b[0], &b[1], &b[2], &b[3]);;
entry_spd.spMaxMin = word_build(b[0],b[1],b[2],b[3]);
for (i=23; i<27; i++)
{
sendstring = b[i-23];
}
printf("please input dpMaxMin value (XX XX XX XX, XX=00-FF): ");
scanf("%x %x %x %x", &b[0], &b[1], &b[2], &b[3]);
entry_spd.dpMaxMin = word_build(b[0],b[1],b[2],b[3]);
for (i=27; i<31; i++)
{
sendstring = b[i-27];
}
insert_isp(spd_udp.oper,entry_spd);
sendsocket(sendstring,SPD_INTPAC_LEN);
c=getchar();
break;
}