summaryrefslogtreecommitdiff
path: root/src/network.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2007-07-18 20:04:00 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2007-07-18 20:04:00 +0000
commit18bbf19becaab7dc4137406928f96ad089192f69 (patch)
treec6d75df8591e20083044cbf07d73e8f6738fd1fd /src/network.c
parent96084e1a1f2e0a49c961bbddb9fffd2e03bfae3f (diff)
downloadconntrack-tools-18bbf19becaab7dc4137406928f96ad089192f69.tar.gz
conntrack-tools-18bbf19becaab7dc4137406928f96ad089192f69.zip
conntrackd:
- use buffer of MTU size conntrack: - better protocol argument checkings - fix per-protocol filtering, eg. conntrack -[L|E] -p tcp now works - show per-protocol help, ie. conntrack -h -p tcp - add alias --src for --orig-src and alias --dst for --orig-dst
Diffstat (limited to 'src/network.c')
-rw-r--r--src/network.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/network.c b/src/network.c
index d162839..a7843dc 100644
--- a/src/network.c
+++ b/src/network.c
@@ -90,9 +90,33 @@ int prepare_send_netmsg(struct mcast_sock *m, void *data)
return ret;
}
+static int tx_buflenmax;
static int tx_buflen = 0;
-/* XXX: use buffer size of interface MTU */
-static char __tx_buf[1460], *tx_buf = __tx_buf;
+static char *tx_buf;
+
+#define HEADERSIZ 28 /* IP header (20 bytes) + UDP header 8 (bytes) */
+
+int mcast_buffered_init(struct mcast_conf *conf)
+{
+ int mtu = conf->mtu - HEADERSIZ;
+
+ /* default to Ethernet MTU 1500 bytes */
+ if (mtu == 0)
+ mtu = 1500 - HEADERSIZ;
+
+ tx_buf = malloc(mtu);
+ if (tx_buf == NULL)
+ return -1;
+
+ tx_buflenmax = mtu;
+
+ return 0;
+}
+
+void mcast_buffered_destroy(void)
+{
+ free(tx_buf);
+}
/* return 0 if it is not sent, otherwise return 1 */
int mcast_buffered_send_netmsg(struct mcast_sock *m, void *data, int len)
@@ -101,8 +125,8 @@ int mcast_buffered_send_netmsg(struct mcast_sock *m, void *data, int len)
struct nethdr *net = data;
retry:
- if (tx_buflen + len < sizeof(__tx_buf)) {
- memcpy(__tx_buf + tx_buflen, net, len);
+ if (tx_buflen + len < tx_buflenmax) {
+ memcpy(tx_buf + tx_buflen, net, len);
tx_buflen += len;
} else {
__do_send(m, tx_buf, tx_buflen);