12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
-
- // 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 usage (char*);
- int dhcp_check (struct nfq_data*, dp_conf*);
- dp_conf *load_config (dp_conf*, char*);
- void 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 *, ...);
|