#include "firewall.h" #include "firewall.m" #include #include extern HELP_FILE help_ipfw; /* Edit all firewalling rules */ PUBLIC int IPFW_RULES::edit() { if (perm_rootaccess("edit firewalling rules")){ IPFW_RULES *rules; glocal.rules = this; (MSG_U(T_EDITFIRE,"Edit firewalling rules") ,MSG_U(I_EDITFIRE ,"You are allowed to edit/add/delete rules") ,help_ipfw); newf_head (MSG_U(H_IPFWRULES ,"No.\tEnable\tPolicy\tProto\tIface\tFrom\t<->\tIface\tTo\tWeight\tRedir\tComment")); setkeyformat (HTML_KEY_INDEX); addwhat (MSG_U(I_NEWRULES,"Select [Add] to define a new rule")); sortable(); sortpolicy ("naaaaaaaanaa"); sethdispo ("rllllllllrcl"); sortcolumn (10,SORT_ASC); int nb = glocal.rules->getnb(); for (int i=0; igetitem(i); r->present (buf1,5,buf2,sizeof(buf2)); sprintf (line,"%d",i+1); new_menuitemf (line,"%s\t%s",buf1,buf2); } if (perm_rootaccess("modify firewalling rules")){ IPFW_RULE *item = glocal.rules->getitem(no); int ok = item->edit(); if (ok >= 0){ if (ok == 1){ glocal.rules->remove_del(item); } glocal.rules->save(); } } IPFW_RULE *a = glocal.rules->newrule(); if (a->edit() == 0){ glocal.rules->add (a); glocal.rules->save(); }else{ delete a; } } return 0; }