Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/ipfw/ip_fw_sockopt.c
Show First 20 Lines • Show All 389 Lines • ▼ Show 20 Lines | swap_map(struct ip_fw_chain *chain, struct ip_fw **new_map, int new_len) | ||||
IPFW_WUNLOCK(chain); | IPFW_WUNLOCK(chain); | ||||
return old_map; | return old_map; | ||||
} | } | ||||
static void | static void | ||||
export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) | export_cntr1_base(struct ip_fw *krule, struct ip_fw_bcounter *cntr) | ||||
{ | { | ||||
struct timeval boottime; | |||||
cntr->size = sizeof(*cntr); | cntr->size = sizeof(*cntr); | ||||
if (krule->cntr != NULL) { | if (krule->cntr != NULL) { | ||||
cntr->pcnt = counter_u64_fetch(krule->cntr); | cntr->pcnt = counter_u64_fetch(krule->cntr); | ||||
cntr->bcnt = counter_u64_fetch(krule->cntr + 1); | cntr->bcnt = counter_u64_fetch(krule->cntr + 1); | ||||
cntr->timestamp = krule->timestamp; | cntr->timestamp = krule->timestamp; | ||||
} | } | ||||
if (cntr->timestamp > 0) | if (cntr->timestamp > 0) { | ||||
getboottime(&boottime); | |||||
cntr->timestamp += boottime.tv_sec; | cntr->timestamp += boottime.tv_sec; | ||||
} | } | ||||
} | |||||
static void | static void | ||||
export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) | export_cntr0_base(struct ip_fw *krule, struct ip_fw_bcounter0 *cntr) | ||||
{ | { | ||||
struct timeval boottime; | |||||
if (krule->cntr != NULL) { | if (krule->cntr != NULL) { | ||||
cntr->pcnt = counter_u64_fetch(krule->cntr); | cntr->pcnt = counter_u64_fetch(krule->cntr); | ||||
cntr->bcnt = counter_u64_fetch(krule->cntr + 1); | cntr->bcnt = counter_u64_fetch(krule->cntr + 1); | ||||
cntr->timestamp = krule->timestamp; | cntr->timestamp = krule->timestamp; | ||||
} | } | ||||
if (cntr->timestamp > 0) | if (cntr->timestamp > 0) { | ||||
getboottime(&boottime); | |||||
cntr->timestamp += boottime.tv_sec; | cntr->timestamp += boottime.tv_sec; | ||||
} | } | ||||
} | |||||
/* | /* | ||||
* Copies rule @urule from v1 userland format (current). | * Copies rule @urule from v1 userland format (current). | ||||
* to kernel @krule. | * to kernel @krule. | ||||
* Assume @krule is zeroed. | * Assume @krule is zeroed. | ||||
*/ | */ | ||||
static void | static void | ||||
import_rule1(struct rule_check_info *ci) | import_rule1(struct rule_check_info *ci) | ||||
▲ Show 20 Lines • Show All 1,620 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static size_t | static size_t | ||||
ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) | ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space) | ||||
{ | { | ||||
char *bp = buf; | char *bp = buf; | ||||
char *ep = bp + space; | char *ep = bp + space; | ||||
struct ip_fw *rule; | struct ip_fw *rule; | ||||
struct ip_fw_rule0 *dst; | struct ip_fw_rule0 *dst; | ||||
struct timeval boottime; | |||||
int error, i, l, warnflag; | int error, i, l, warnflag; | ||||
time_t boot_seconds; | time_t boot_seconds; | ||||
warnflag = 0; | warnflag = 0; | ||||
getboottime(&boottime); | |||||
boot_seconds = boottime.tv_sec; | boot_seconds = boottime.tv_sec; | ||||
for (i = 0; i < chain->n_rules; i++) { | for (i = 0; i < chain->n_rules; i++) { | ||||
rule = chain->map[i]; | rule = chain->map[i]; | ||||
if (is7) { | if (is7) { | ||||
/* Convert rule to FreeBSd 7.2 format */ | /* Convert rule to FreeBSd 7.2 format */ | ||||
l = RULESIZE7(rule); | l = RULESIZE7(rule); | ||||
if (bp + l + sizeof(uint32_t) <= ep) { | if (bp + l + sizeof(uint32_t) <= ep) { | ||||
▲ Show 20 Lines • Show All 2,527 Lines • Show Last 20 Lines |