1 /* 2 * ZMap Copyright 2013 Regents of the University of Michigan 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy 6 * of the License at http://www.apache.org/licenses/LICENSE-2.0 7 */ 8 9 #include "socket.h" 10 11 #include <string.h> 12 #include <errno.h> 13 14 #include "../lib/includes.h" 15 #include "../lib/logger.h" 16 get_socket(UNUSED uint32_t id)17sock_t get_socket(UNUSED uint32_t id) 18 { 19 int sock = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); 20 if (sock <= 0) { 21 log_fatal("send", "couldn't create socket. " 22 "Are you root? Error: %s\n", strerror(errno)); 23 } 24 sock_t s; 25 s.sock = sock; 26 return s; 27 } 28