Data Structures |
struct | rule_s |
| Rule item. More...
|
struct | tracker_s |
| This structure is used to track information about open connections. More...
|
Defines |
#define | PARSE_LONG_OPT |
| Define to use getopt_long: GNU extension, should check _GNU_SOURCE.
|
#define | VERSION "1.2" |
| Current version (recovered by Makefile for several release checks).
|
#define | MAX_BUF 100000 |
| max size for buffers
|
#define | ERR(x...) fprintf(stderr,x) |
| printf to stderr
|
#define | DBG(x...) |
| Disabled debug prints.
|
#define | UDP_TIMEOUT 30 |
| Timeout for udp 'connections' in seconds.
|
Enumerations |
enum | { ALL = 0,
IN = 1,
OUT = 2
} |
| Direction specifier of replacement rule.
More...
|
enum | state_e { UNREPLIED,
ESTABLISHED,
DISCONNECTED,
TIMEOUT
} |
| Connection state.
More...
|
Functions |
void | short_usage_hints (const char *why) |
| Display an error message followed by short usage information.
|
void | usage_hints (const char *why) |
| Display an error message followed by usage information.
|
void | freetracker (struct tracker_s *conn) |
| Helper function to free a tracker_s item. csa will be freed if needed, sockets will be closed.
|
void | clean_socks (void) |
| Close all sockets to use before exit.
|
in_port_t | get_port (struct sockaddr *sa) |
| Extract the port information from a sockaddr for both IPv4 and IPv6.
|
void | set_port (struct sockaddr *sa, in_port_t port) |
| Set the port information in a sockaddr for both IPv4 and IPv6.
|
int | is_addr_any (struct sockaddr *sa) |
| Detect if address in the addr_any value for both IPv4 and IPv6.
|
void | error (const char *reason) |
| Display an error message and exit.
|
void | shrink_to_binary (struct rule_s *r) |
| Convert the % notation in rules to plain binary data.
|
void | parse_params (int argc, char *argv[]) |
| parse the command line parameters
|
void | bind_and_listen (int af, int tcp, const char *portstr) |
| Bind and optionally listen to a socket for netsed server port.
|
int | sed_the_buffer (int siz, int *live, int dir) |
| Applies the rules to global buffer buf.
|
void | b2server_sed (struct tracker_s *conn, ssize_t rd) |
| Send the content of global buffer b2 to the server as packet or datagram.
|
void | server2client_sed (struct tracker_s *conn) |
| Receive a packet or datagram from the server, 'sed' it, send it to the client.
|
void | client2server_sed (struct tracker_s *conn) |
| Receive a packet from the client, 'sed' it, send it to the server.
|
void | sig_int (int signo) |
| Handle SIGINT signal for clean exit.
|
int | main (int argc, char *argv[]) |
| This is main...
|
Variables |
time_t | now |
| Store current time (just after select returned).
|
int | lsock |
| Listening socket.
|
int | family = AF_UNSPEC |
| Address family used for parameter resolution.
|
int | tcp |
| TCP or UDP.
|
char * | lport |
| Local Port.
|
char * | rhost |
| Remote Host.
|
char * | rport |
| Remote Port.
|
int | rules |
| Number of rules.
|
struct rule_s * | rule |
| Array of all rules.
|
int * | rule_live |
| TTL part of the rule as a flat array to be able to copy it in tracker_s::live for each connections.
|
struct tracker_s * | connections = NULL |
| List of connections.
|
volatile int | stop = 0 |
| True when SIGINT signal was received.
|
char | hex [] = "0123456789ABCDEF" |
| Hex digit to parsing the % notation in rules.
|
char | buf [MAX_BUF] |
| Buffer for receiving a single packet or datagram.
|
char | b2 [MAX_BUF] |
| Buffer containing modified packet or datagram.
|
netsed is implemented in this single file.