... | ... |
@@ -13,6 +13,10 @@ |
13 | 13 |
#include <sys/socket.h> |
14 | 14 |
#include <netinet/in.h> |
15 | 15 |
#include <arpa/inet.h> |
16 |
+#ifdef __linux__ |
|
17 |
+#include <linux/types.h> |
|
18 |
+#include <linux/errqueue.h> |
|
19 |
+#endif |
|
16 | 20 |
|
17 | 21 |
|
18 | 22 |
static char *id="$Id$"; |
... | ... |
@@ -48,6 +52,9 @@ int main (int argc, char** argv) |
48 | 52 |
char *fname; |
49 | 53 |
char *dst; |
50 | 54 |
int port; |
55 |
+#ifdef __linux__ |
|
56 |
+ int optval; |
|
57 |
+#endif |
|
51 | 58 |
|
52 | 59 |
/* init */ |
53 | 60 |
count=0; |
... | ... |
@@ -164,12 +171,14 @@ int main (int argc, char** argv) |
164 | 171 |
fprintf(stderr, "ERROR: socket: %s\n", strerror(errno)); |
165 | 172 |
goto error; |
166 | 173 |
} |
167 |
-/* |
|
168 |
- if (connect(sock, (struct sockaddr*) &addr, sizeof(struct sockaddr))!=0){ |
|
169 |
- fprintf(stderr, "ERROR: connect: %s\n", strerror(errno)); |
|
170 |
- goto error; |
|
174 |
+#ifdef __linux__ |
|
175 |
+ /* enable error receiving on unconnected sockets*/ |
|
176 |
+ optval=1; |
|
177 |
+ if(setsockopt(sock,SOL_IP,IP_RECVERR,(void*)&optval,sizeof(optval))==-1){ |
|
178 |
+ fprintf(stderr, "Error: setsockopt: %s\n", strerror(errno)); |
|
179 |
+ exit(1); |
|
171 | 180 |
} |
172 |
-*/ |
|
181 |
+#endif |
|
173 | 182 |
|
174 | 183 |
|
175 | 184 |
/* flood loop */ |
... | ... |
@@ -9,6 +9,10 @@ |
9 | 9 |
#include <netinet/in.h> |
10 | 10 |
#include <errno.h> |
11 | 11 |
#include <arpa/inet.h> |
12 |
+#ifdef __linux__ |
|
13 |
+ #include <linux/types.h> |
|
14 |
+ #include <linux/errqueue.h> |
|
15 |
+#endif |
|
12 | 16 |
|
13 | 17 |
|
14 | 18 |
#include "udp_server.h" |
... | ... |
@@ -137,11 +141,20 @@ int udp_init(struct socket_info* sock_info) |
137 | 141 |
/* set sock opts? */ |
138 | 142 |
optval=1; |
139 | 143 |
if (setsockopt(sock_info->socket, SOL_SOCKET, SO_REUSEADDR , |
140 |
- (void*)&optval, sizeof(optval)) ==-1) |
|
141 |
- { |
|
144 |
+ (void*)&optval, sizeof(optval)) ==-1){ |
|
145 |
+ LOG(L_ERR, "ERROR: udp_init: setsockopt: %s\n", strerror(errno)); |
|
146 |
+ goto error; |
|
147 |
+ } |
|
148 |
+#ifdef __linux__ |
|
149 |
+ optval=1; |
|
150 |
+ /* enable error receiving on unconnected sockets */ |
|
151 |
+ if(setsockopt(sock_info->socket, SOL_IP, IP_RECVERR, |
|
152 |
+ (void*)&optval, sizeof(optval)) ==-1){ |
|
142 | 153 |
LOG(L_ERR, "ERROR: udp_init: setsockopt: %s\n", strerror(errno)); |
143 | 154 |
goto error; |
144 | 155 |
} |
156 |
+#endif |
|
157 |
+ |
|
145 | 158 |
|
146 | 159 |
if ( probe_max_receive_buffer(sock_info->socket)==-1) goto error; |
147 | 160 |
|