Changeset 264


Ignore:
Timestamp:
11/05/17 21:00:49 (2 weeks ago)
Author:
xchaos
Message:

code readability

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/prometheus.c

    r263 r264  
    396396} 
    397397 
     398#define IPv4 FALSE 
     399#define IPv6 TRUE 
     400 
     401 
    398402void run_iptables_restore(void) 
    399403{ 
     
    405409 /*-----------------------------------------------------------------*/ 
    406410 
    407  iptables_save_line("COMMIT", FALSE); 
     411 iptables_save_line("COMMIT", IPv4); 
    408412 fclose(iptables_file); 
    409413 if(dry_run)  
     
    424428  printf("Running %s <%s ...\n", ip6tablesrestore, ip6tablesfile); 
    425429  /*-----------------------------------------------------------------*/ 
    426   iptables_save_line("COMMIT", TRUE); 
     430  iptables_save_line("COMMIT", IPv6); 
    427431  fclose(ip6tables_file); 
    428432  if(dry_run)  
     
    706710    exit(-1); 
    707711  } 
    708   iptables_save_line(iptablespreamble, FALSE); 
     712  iptables_save_line(iptablespreamble, IPv4); 
    709713 
    710714  if(ip6prefix) 
     
    716720     exit(-1); 
    717721   } 
    718    iptables_save_line(iptablespreamble, TRUE); 
    719    iptables_save_line(ip6preamble, TRUE); 
     722   iptables_save_line(iptablespreamble, IPv6); 
     723   iptables_save_line(ip6preamble, IPv6); 
    720724  } 
    721725 
     
    736740   
    737741  iptables_file=fopen(iptablesfile,"w"); 
    738   iptables_save_line(iptablespreamble, FALSE); 
     742  iptables_save_line(iptablespreamble, IPv4); 
    739743  if(ip6prefix) 
    740744  { 
    741745   ip6tables_file=fopen(ip6tablesfile,"w"); 
    742    iptables_save_line(iptablespreamble, TRUE); 
    743    iptables_save_line(ip6preamble, TRUE); 
     746   iptables_save_line(iptablespreamble, IPv6); 
     747   iptables_save_line(ip6preamble, IPv6); 
    744748  } 
    745749 
     
    749753   { 
    750754    sprintf(str,"-A %s -%c %s -o %s -j ACCEPT", interface->chain, (interface->is_upstream?'d':'s'), qos_free_zone, interface->name); 
    751     iptables_save_line(str, FALSE); 
     755    iptables_save_line(str, IPv4); 
    752756   } 
    753757  } 
     
    761765   /*-----------------------------------------------------------------*/ 
    762766 
    763    iptables_save_line(":post_common - [0:0]", FALSE); 
    764    iptables_save_line(":forw_common - [0:0]", FALSE); 
     767   iptables_save_line(":post_common - [0:0]", IPv4); 
     768   iptables_save_line(":forw_common - [0:0]", IPv4); 
    765769   if(ip6prefix) 
    766770   { 
    767     iptables_save_line(":post_common - [0:0]", TRUE); 
    768     iptables_save_line(":forw_common - [0:0]", TRUE); 
     771    iptables_save_line(":post_common - [0:0]", IPv6); 
     772    iptables_save_line(":forw_common - [0:0]", IPv6); 
    769773   } 
    770774 
     
    883887   { 
    884888    sprintf(str,"-A %s -o %s -j %s_common", interface->chain, interface->name, interface->idxprefix); 
    885     iptables_save_line(str, FALSE); 
     889    iptables_save_line(str, IPv4); 
    886890    if(ip6prefix) 
    887891    { 
    888892     sprintf(str,"-A %s -o %s -j %s_common", interface->chain, interface->name, interface->idxprefix); 
    889      iptables_save_line(str, TRUE); 
     893     iptables_save_line(str, IPv6); 
    890894    } 
    891895   } 
     
    13491353   sprintf(str, "-A %s -o %s -j %s%d", 
    13501354                chain, interface->name, mark_iptables, FREE_CLASS); 
    1351    iptables_save_line(str, FALSE); /* only for IPv4 */ 
     1355   iptables_save_line(str, IPv4); /* only for IPv4 */ 
    13521356  } 
    13531357 
    13541358  sprintf(str,"-A %s -o %s -j %s", chain, interface->name, final_chain); 
    1355   iptables_save_line(str, FALSE); 
     1359  iptables_save_line(str, IPv4); 
    13561360  if(ip6prefix) 
    13571361  { 
    13581362   sprintf(str,"-A %s -o %s -j %s", chain, interface->name, final_chain); 
    1359    iptables_save_line(str, TRUE); 
     1363   iptables_save_line(str, IPv6); 
    13601364  } 
    13611365 
Note: See TracChangeset for help on using the changeset viewer.