1 /* 2 pmacct (Promiscuous mode IP Accounting package) 3 pmacct is Copyright (C) 2003-2019 by Paolo Lucente 4 */ 5 6 /* 7 This program is free software; you can redistribute it and/or modify 8 it under the terms of the GNU General Public License as published by 9 the Free Software Foundation; either version 2 of the License, or 10 (at your option) any later version. 11 12 This program is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 GNU General Public License for more details. 16 17 You should have received a copy of the GNU General Public License 18 along with this program; if not, write to the Free Software 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 20 */ 21 22 #ifndef CONNTRACK_H 23 #define CONNTRACK_H 24 25 /* defines */ 26 #define CONNTRACK_GENERIC_LIFETIME 20 27 #define DEFAULT_CONNTRACK_BUFFER_SIZE 8192000 /* 8 Mb */ 28 #define MAX_CONNTRACKS 256 29 30 /* structures */ 31 typedef void (*conntrack_helper)(time_t, struct packet_ptrs *); 32 33 struct conntrack_helper_entry { 34 char protocol[MAX_PROTOCOL_LEN]; 35 conntrack_helper ct_helper; 36 }; 37 38 struct conntrack_ipv4 { 39 u_int32_t ip_src; 40 u_int32_t ip_dst; 41 u_int16_t port_src; 42 u_int16_t port_dst; 43 u_int8_t proto; 44 pm_class_t class; 45 /* timestamp renewal flag ? */ 46 time_t stamp; 47 time_t expiration; 48 conntrack_helper helper; 49 struct conntrack_ipv4 *next; 50 }; 51 52 struct conntrack_ipv6 { 53 u_int32_t ip_src[4]; 54 u_int32_t ip_dst[4]; 55 u_int16_t port_src; 56 u_int16_t port_dst; 57 u_int8_t proto; 58 pm_class_t class; 59 /* timestamp renewal flag ? */ 60 time_t stamp; 61 time_t expiration; 62 conntrack_helper helper; 63 struct conntrack_ipv6 *next; 64 }; 65 66 extern void init_conntrack_table(); 67 extern void conntrack_ftp_helper(time_t, struct packet_ptrs *); 68 extern void conntrack_sip_helper(time_t, struct packet_ptrs *); 69 extern void conntrack_rtsp_helper(time_t, struct packet_ptrs *); 70 extern void search_conntrack(struct ip_flow_common *, struct packet_ptrs *, unsigned int); 71 extern void search_conntrack_ipv4(struct ip_flow_common *, struct packet_ptrs *, unsigned int); 72 extern void insert_conntrack_ipv4(time_t, u_int32_t, u_int32_t, u_int16_t, u_int16_t, u_int8_t, pm_class_t, conntrack_helper, time_t); 73 extern void search_conntrack_ipv6(struct ip_flow_common *, struct packet_ptrs *, unsigned int); 74 extern void insert_conntrack_ipv6(time_t, struct in6_addr *, struct in6_addr *, u_int16_t, u_int16_t, u_int8_t, pm_class_t, conntrack_helper, time_t); 75 76 77 extern struct conntrack_ipv4 *conntrack_ipv4_table; 78 extern struct conntrack_ipv6 *conntrack_ipv6_table; 79 extern struct conntrack_helper_entry __attribute__((unused)) conntrack_helper_list[4]; 80 81 #endif //CONNTRACK_H 82