summaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 7a15427..9272ef5 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -29,6 +29,13 @@
#include <netdb.h>
#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+
+#define UDP_CORK 1
+
#include "log.h"
#include "utils.h"
@@ -144,6 +151,30 @@ int set_nonblocking(int fd)
return err;
}
+int udp_cork(int fd, int corked)
+{
+ int tmp;
+
+ tmp = setsockopt(fd, IPPROTO_UDP, UDP_CORK, &corked, sizeof(corked));
+ if (tmp < 0) {
+ log_error("setsockopt UDP_CORK failed");
+ }
+
+ return -1;
+}
+
+int tcp_cork(int fd, int corked)
+{
+ int tmp;
+
+ tmp = setsockopt(fd, IPPROTO_TCP, TCP_CORK, &corked, sizeof(corked));
+ if (tmp < 0) {
+ log_error("setsockopt TCP_CORK failed");
+ }
+
+ return -1;
+}
+
int host_to_inet(const char *host, struct in_addr *in)
{
struct hostent h;