Changeset View
Changeset View
Standalone View
Standalone View
sys/sys/counter.h
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | for (int i = 0; i < (n); i++) \ | ||||
counter_u64_zero((a)[i]); \ | counter_u64_zero((a)[i]); \ | ||||
} while (0) | } while (0) | ||||
/* | /* | ||||
* counter(9) based rate checking. | * counter(9) based rate checking. | ||||
*/ | */ | ||||
struct counter_rate { | struct counter_rate { | ||||
counter_u64_t cr_rate; /* Events since last second */ | counter_u64_t cr_rate; /* Events since last second */ | ||||
int *cr_limitp; /* Pointer to limit */ | |||||
const char *cr_descr; /* Description */ | |||||
int *cr_logp; /* Whether to log failures */ | |||||
volatile int cr_lock; /* Lock to clean the struct */ | volatile int cr_lock; /* Lock to clean the struct */ | ||||
int cr_ticks; /* Ticks on last clean */ | int cr_ticks; /* Ticks on last clean */ | ||||
int cr_over; /* Over limit since cr_ticks? */ | int cr_over; /* Over limit since cr_ticks? */ | ||||
}; | }; | ||||
int64_t counter_ratecheck(struct counter_rate *, int64_t); | int64_t counter_ratecheck(int which); | ||||
void counter_rate_register(int which, const char *descr, int *limitp, | |||||
int *logp); | |||||
void counter_rate_unregister(int which); | |||||
#define BANDLIM_UNLIMITED -1 | |||||
enum counter_rate_specs { | |||||
BANDLIM_ICMP_UNREACH = 0, | |||||
BANDLIM_ICMP_ECHO, | |||||
BANDLIM_ICMP_TSTAMP, | |||||
BANDLIM_RST_CLOSEDPORT, | |||||
BANDLIM_RST_OPENPORT, | |||||
BANDLIM_SCTP_OOTB, | |||||
BANDLIM_ICMP6_INFOREPLIES, | |||||
BANDLIM_ICMP6_ERRORS, | |||||
/* Add new entries before BANDLIM_MAX. */ | |||||
BANDLIM_MAX | |||||
}; | |||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* ! __SYS_COUNTER_H__ */ | #endif /* ! __SYS_COUNTER_H__ */ |