1/*
2#-------------------------------------------------------------------------------
3#
4# $Id: netstat-nat.h,v 1.14 2007/11/24 13:18:48 danny Exp $
5#
6#
7# Copyright (c) 2006 by D.Wijsman (danny@tweegy.nl).
8# All rights reserved.
9#
10# This program is free software; you can redistribute it and/or modify it
11# under the terms of the GNU General Public License as published by the Free
12# Software Foundation; either version 2 of the License, or (at your option)
13# any later version.
14#
15# This program is distributed in the hope that it will be useful, but WITHOUT
16# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18# more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; see the file COPYING.  If not, write to
22# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24#
25#-------------------------------------------------------------------------------
26*/
27
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31//#include <regex.h>
32#include <netdb.h>
33#include <unistd.h>
34#include <arpa/inet.h>
35#include <errno.h>
36#include <strings.h>
37#include <net/if.h>
38#include <sys/ioctl.h>
39
40#define ROWS			8
41#define IP_CONNTRACK_LOCATION	"/proc/net/ip_conntrack"
42#define NF_CONNTRACK_LOCATION	"/proc/net/nf_conntrack"
43
44
45int get_protocol(char *line, char *protocol);
46int get_connection_state(char *line, char *state);
47void process_entry(char *line);
48void check_src_dst(char *protocol, char *src_ip, char *dst_ip, char *src_port, char *dst_port, char *nathostip, char *nathostport, char *status);
49void store_data(char *protocol, char *src_ip, char *dst_ip, char *src_port, char *dst_port, char *nathostip, char *nathostport, char *status);
50void extract_ip(char *gen_buffer);
51void display_help();
52int lookup_hostname(char **r_host);
53int lookup_ip(char *hostname, size_t hostname_size);
54//int match(char *string, char *pattern);
55int check_if_source(char *host);
56int check_if_destination(char *host);
57void lookup_portname(char **port, char *proto);
58void oopsy(int size);
59static void *xrealloc(void *oldbuf, size_t newbufsize);
60static void *xcalloc(size_t bufsize);
61void get_protocol_name(char *protocol_name, int protocol_nr);
62char *xstrdup (const char *dup);
63void ip_addresses_add(struct _ip_addresses **list, const char *dev, const char *ip);
64int ip_addresses_search(struct _ip_addresses *list, const char *ip);
65void ip_addresses_free(struct _ip_addresses **list);
66
67
68#define strcopy(dst, dst_size, src) \
69	strncpy(dst, src, (dst_size - 1));
70
71/* The End */
72