Thread: [Netadm-devel] gwc/gwclib confproc.c,1.10,1.11 confutil.c,1.2,1.3
Status: Beta
Brought to you by:
linuxpark
From: linuxpark <lin...@us...> - 2006-03-01 19:13:36
|
Update of /cvsroot/netadm/gwc/gwclib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16007/gwclib Modified Files: confproc.c confutil.c Log Message: FIX: fix a lot of cli interface bug about flow control. Index: confutil.c =================================================================== RCS file: /cvsroot/netadm/gwc/gwclib/confutil.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** confutil.c 28 Feb 2006 23:41:50 -0000 1.2 --- confutil.c 1 Mar 2006 19:13:24 -0000 1.3 *************** *** 114,118 **** map++; } ! return "Unknown..."; } --- 114,118 ---- map++; } ! return NULL; } Index: confproc.c =================================================================== RCS file: /cvsroot/netadm/gwc/gwclib/confproc.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** confproc.c 1 Mar 2006 04:06:33 -0000 1.10 --- confproc.c 1 Mar 2006 19:13:23 -0000 1.11 *************** *** 2130,2134 **** int slot = -1; int i; ! unsigned short port; if (argc == 3) { --- 2130,2134 ---- int slot = -1; int i; ! int port; if (argc == 3) { *************** *** 2172,2176 **** svc->u.icmptype = (unsigned short)strtol(argv[2], (char **)NULL, 16); ! if ( mapidtostr ( map_icmptype, svc->u.icmptype ) < 0 ) frerrmap(fr, RET_EUSAGE, "ICMP type", map_icmptype); --- 2172,2176 ---- svc->u.icmptype = (unsigned short)strtol(argv[2], (char **)NULL, 16); ! if ( !mapidtostr ( map_icmptype, svc->u.icmptype ) ) frerrmap(fr, RET_EUSAGE, "ICMP type", map_icmptype); *************** *** 2181,2197 **** else if (svc->proto == SYS_PROTO_ICMP) { ! if ((svc->proto = mapstrtoid(map_icmptype, argv[2])) == -1) frerrmap(fr, RET_EUSAGE, "ICMP type", map_icmptype); } else{ ! port = (unsigned short)atoi(argv[2]); if (port >= 65535){ frerr(fr, RET_EPORTRANGE, "[Port] cannot be greater than 65535\n"); } ! svc->u.port = port; } ! if (fr->ret != RET_OK) return; --- 2181,2218 ---- else if (svc->proto == SYS_PROTO_ICMP) { ! if ((svc->u.icmptype = mapstrtoid(map_icmptype, argv[2])) == -1) frerrmap(fr, RET_EUSAGE, "ICMP type", map_icmptype); } else{ ! port = atoi(argv[2]); if (port >= 65535){ frerr(fr, RET_EPORTRANGE, "[Port] cannot be greater than 65535\n"); } ! svc->u.port = (unsigned short)port; } ! for (i = 0; i < csm->fc_svc_cnt; i++) { ! if (i == slot) ! continue; ! ! if ( csm->fc_svc[i].proto != svc->proto ) ! continue; ! ! if ( csm->fc_svc[i].proto == SYS_PROTO_ICMP ) { ! if ( csm->fc_svc[i].u.icmptype != svc->u.icmptype ) ! continue; ! } ! else { ! if ( csm->fc_svc[i].u.port != svc->u.port ) ! continue; ! } ! ! frerr(fr, RET_ENOTUNIQ, ! "%s: Same service protocol already defined as %s\n", ! svc->name, csm->fc_svc[i].name); ! } ! ! if (fr->ret != RET_OK) return; *************** *** 2407,2412 **** strcpy(net->net_if,argv[4]); ! if (fr->ret != RET_OK) ! return; for (i = 0; i < csm->fc_net_cnt; i++) { --- 2428,2441 ---- strcpy(net->net_if,argv[4]); ! /* TODO */ ! for (i = 0; i < csm->ifcnt; i++) { ! if (!strcmp(csm->dev[i].if_name, net->net_if)) { ! break; ! } ! } ! ! if ( i == csm->ifcnt ) ! frerr(fr, RET_EUSAGE, "[Interface name] There is no such active interface \"%s\" " ! "in this localsystem.\n",net->net_if); for (i = 0; i < csm->fc_net_cnt; i++) { *************** *** 2420,2426 **** continue; frerr(fr, RET_ENOTUNIQ, ! "%s: Same Host/Network already defined as %s\n", net->name, csm->fc_net[i].name); } for (slot = 0, i = 0; i < csm->fc_net_cnt; i++) { --- 2449,2458 ---- continue; frerr(fr, RET_ENOTUNIQ, ! "%s: Same Network already defined as %s\n", net->name, csm->fc_net[i].name); } + + if (fr->ret != RET_OK) + return; for (slot = 0, i = 0; i < csm->fc_net_cnt; i++) { *************** *** 2624,2630 **** frerrmap(fr, RET_EUSAGE, "flow unit", map_thput_unit); - if (fr->ret != RET_OK) - return; - for (i = 0; i < csm->fc_fw_cnt; i++) { if (i == slot) --- 2656,2659 ---- *************** *** 2639,2642 **** --- 2668,2674 ---- return; } + + if (fr->ret != RET_OK) + return; for (slot = 0, i = 0; i < csm->fc_fw_cnt; i++) { *************** *** 2759,2766 **** } else { ! if (csm->polcnt == 0) return; start = 0; ! end = csm->polcnt; } --- 2791,2798 ---- } else { ! if (csm->fc_pol_cnt == 0) return; start = 0; ! end = csm->fc_pol_cnt; } *************** *** 2797,2800 **** --- 2829,2834 ---- int slot = -1; int i; + fc_svc_t *ssvc; + fc_svc_t *dsvc; if (argc == 8) { *************** *** 2818,2824 **** strcpy(pol->name, argv[0]); ! if ( !sys_ucmd_msg (_CMD_GET_FC_POL, argv[0], strlen(argv[0]))) frerr(fr, RET_ENOTUNIQ, ! "[FC/Network name] \"%s\" does not exists\n", argv[0]); if ((pol->enable = mapstrtoid(map_truefalse, argv[1])) == -1) --- 2852,2858 ---- strcpy(pol->name, argv[0]); ! if (sys_ucmd_msg (_CMD_GET_FC_POL, argv[0], strlen(argv[0]))) frerr(fr, RET_ENOTUNIQ, ! "[FC/policy name] \"%s\" already exists\n", argv[0]); if ((pol->enable = mapstrtoid(map_truefalse, argv[1])) == -1) *************** *** 2851,2855 **** strcpy(pol->ssvc, argv[3]); ! if ( !sys_ucmd_msg (_CMD_GET_FC_SVC, argv[3], strlen(argv[3]))) frerr(fr, RET_ENOTUNIQ, "[FC/source service protocol name] \"%s\" does not exists\n", argv[3]); --- 2885,2889 ---- strcpy(pol->ssvc, argv[3]); ! if ( !(ssvc = (fc_svc_t*)sys_ucmd_msg (_CMD_GET_FC_SVC, argv[3], strlen(argv[3]))) ) frerr(fr, RET_ENOTUNIQ, "[FC/source service protocol name] \"%s\" does not exists\n", argv[3]); *************** *** 2881,2888 **** strcpy(pol->dsvc, argv[5]); ! if ( !sys_ucmd_msg (_CMD_GET_FC_SVC, argv[5], strlen(argv[5]))) frerr(fr, RET_ENOTUNIQ, "[FC/destination service protocol name] \"%s\" does not exists\n",argv[5]); /* fw */ if (!str_nospace(argv[6])) --- 2915,2929 ---- strcpy(pol->dsvc, argv[5]); ! if ( !(dsvc = (fc_svc_t*)sys_ucmd_msg (_CMD_GET_FC_SVC, argv[5], strlen(argv[5]))) ) frerr(fr, RET_ENOTUNIQ, "[FC/destination service protocol name] \"%s\" does not exists\n",argv[5]); + if ( ssvc->proto != dsvc->proto ) + frerr(fr, RET_EINTERNAL, + "both source service proto and destination service proto must be same but" + " source service proto \"%s\" and destination service proto \"%s\"\n", + mapidtostr (map_prototype, ssvc->proto), + mapidtostr(map_prototype, dsvc->proto)); + /* fw */ if (!str_nospace(argv[6])) *************** *** 2903,2910 **** frerrmap(fr, RET_EUSAGE, "Rule", map_fc_rule); - - if (fr->ret != RET_OK) - return; - for (i = 0; i < csm->fc_pol_cnt; i++) { if (i == slot) --- 2944,2947 ---- *************** *** 2919,2929 **** if (strcmp(pol->dsvc, csm->fc_pol[i].dsvc)) continue; /* * FIXME: if only fw is different in a policy, we have to decide more low * whether in pf or fc_apply */ if (strcmp(pol->fw, csm->fc_pol[i].fw)) continue; - #if 0 /* * FIXME: if only rule is different in a policy, we have to decide more low --- 2956,2970 ---- if (strcmp(pol->dsvc, csm->fc_pol[i].dsvc)) continue; + /* WARNING! + * if snet/sport ->dnet/dport was determined already, + * any other rule will be consider as error + */ /* * FIXME: if only fw is different in a policy, we have to decide more low * whether in pf or fc_apply */ + #if 0 if (strcmp(pol->fw, csm->fc_pol[i].fw)) continue; /* * FIXME: if only rule is different in a policy, we have to decide more low *************** *** 2935,2941 **** #endif frerr(fr, RET_ENOTUNIQ, ! "%s: Same FC/policy already defined as %s\n", pol->name, csm->fc_pol[i].name); } for (slot = 0, i = 0; i < csm->fc_pol_cnt; i++) { --- 2976,2985 ---- #endif frerr(fr, RET_ENOTUNIQ, ! "%s: Same policy already defined as %s\n", pol->name, csm->fc_pol[i].name); } + + if (fr->ret != RET_OK) + return; for (slot = 0, i = 0; i < csm->fc_pol_cnt; i++) { |