12345678910111213141516171819202122232425262728293031 |
- /*
- * 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"
- sock_t get_dryrun_socket(void)
- {
- // we need a socket in order to gather details about the system
- // such as source MAC address and IP address. However, because
- // we don't want to require root access in order to run dryrun,
- // we just create a TCP socket.
- int sock = socket(AF_INET, SOCK_STREAM, 0);
- if (sock <= 0) {
- log_fatal("send", "couldn't create socket. Error: %s\n",
- strerror(errno));
- }
- sock_t s;
- s.sock = sock;
- return s;
- }
|