Handle EAGAIN and EWOULDBLOCK more gracefully when dealing with safe_read(). All occurrences of safe_read() should only be invoked on fds that have signaled ready-to-read state via the epoll() mechanism, so this change should not result in any observable difference, but it is best to be safe. Additionally, a constant stack variable is converted to an equivalent macro define for cleanliness. Finally, print the error type encountered if reading data from an ARP response fails with a read error.
31 lines
1.0 KiB
C
31 lines
1.0 KiB
C
/* socket.h - raw and kernel socket creation functions
|
|
* Time-stamp: <2011-03-30 23:47:34 nk>
|
|
*
|
|
* (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
*/
|
|
|
|
#ifndef SOCKET_H_
|
|
#define SOCKET_H_
|
|
|
|
#include <stdint.h>
|
|
|
|
int set_sock_nonblock(int fd);
|
|
int listen_socket(unsigned int ip, int port, char *inf);
|
|
int raw_socket(int ifindex);
|
|
|
|
#endif
|