1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
-
- // Copyright 2019 Pascal Gloor
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
-
- typedef struct dp_conf {
- int pktint;
- int interval;
- int debug;
- int bltime;
- int queue;
- int dryrun;
- } dp_conf;
-
- typedef struct dp_accounting {
- unsigned char remoteid[256];
- int len;
- int count;
- UT_hash_handle hh;
- } dp_accounting;
-
- typedef struct dp_blacklist {
- unsigned char remoteid[256];
- int len;
- time_t expire;
- UT_hash_handle hh;
- } dp_blacklist;
-
- // global hash lists
- static dp_accounting *accountings = NULL;
- static dp_blacklist *blacklists = NULL;
- // timestamp for cleanup interval
- static time_t dp_accountingtime = 0;
- static time_t dp_cleanuptime = 0;
-
- static int dp_callback (
- struct nfq_q_handle*,
- struct nfgenmsg*,
- struct nfq_data*,
- void*);
-
- void dp_usage (char*);
- dp_conf *dp_load_config (dp_conf*, char*);
- void dp_nfq_start (dp_conf*);
- void dp_accounting_add (dp_conf*, unsigned char *, int);
- int dp_accounting_check (dp_conf*, unsigned char *, int);
- void dp_blacklist_add (dp_conf*, unsigned char *, int);
- int dp_blacklist_check (dp_conf*, unsigned char *, int);
- void dp_hash_cleanup (dp_conf*);
- void dp_log (unsigned char *, int, char *, ...);
- int dp_dhcp_check (struct nfq_data*, dp_conf*);
-
- void dp_dhcpv4_check (
- dp_conf*,
- unsigned char*,
- int,
- int,
- unsigned char**,
- int*);
-
- void dp_dhcpv6_check (
- dp_conf*,
- unsigned char*,
- int,
- int,
- unsigned char**,
- int*);
|