summaryrefslogtreecommitdiff
path: root/rdns_scan/zmap4rdns/src/socket-linux.c
diff options
context:
space:
mode:
Diffstat (limited to 'rdns_scan/zmap4rdns/src/socket-linux.c')
-rw-r--r--rdns_scan/zmap4rdns/src/socket-linux.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/rdns_scan/zmap4rdns/src/socket-linux.c b/rdns_scan/zmap4rdns/src/socket-linux.c
new file mode 100644
index 0000000..b1710c7
--- /dev/null
+++ b/rdns_scan/zmap4rdns/src/socket-linux.c
@@ -0,0 +1,36 @@
+/*
+ * ZMap Copyright 2013 Regents of the University of Michigan
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
+ */
+
+#include "socket.h"
+
+#include <string.h>
+#include <errno.h>
+
+#include "../lib/includes.h"
+#include "../lib/logger.h"
+
+#include "state.h"
+
+sock_t get_socket(UNUSED uint32_t id)
+{
+ int sock;
+ if (zconf.send_ip_pkts) {
+ sock = socket(AF_PACKET, SOCK_DGRAM, htons(ETH_P_ALL));
+ } else {
+ sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
+ }
+ if (sock <= 0) {
+ log_fatal("send",
+ "couldn't create socket. "
+ "Are you root? Error: %s\n",
+ strerror(errno));
+ }
+ sock_t s;
+ s.sock = sock;
+ return s;
+}