2012-08-23 03:01:07 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2012 Serval Project Inc.
|
|
|
|
|
|
|
|
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#ifndef __SERVAL_DNA__NET_H
|
|
|
|
#define __SERVAL_DNA__NET_H
|
2012-08-23 03:01:07 +00:00
|
|
|
|
|
|
|
#include <sys/types.h> // for size_t, ssize_t
|
2012-12-03 23:42:35 +00:00
|
|
|
#include <sys/socket.h> // for struct sockaddr, socklen_t
|
2013-11-12 01:09:06 +00:00
|
|
|
#ifdef HAVE_NETINET_IN_H
|
2013-02-05 06:26:37 +00:00
|
|
|
#include <netinet/in.h> // for struct in_addr
|
2013-11-12 01:09:06 +00:00
|
|
|
#endif
|
2014-05-23 08:19:00 +00:00
|
|
|
|
|
|
|
#if !defined(FORASTERISK) && !defined(s_addr)
|
|
|
|
#ifdef HAVE_ARPA_INET_H
|
2013-02-05 06:26:37 +00:00
|
|
|
#include <arpa/inet.h> // for in_addr_t
|
2014-05-23 08:19:00 +00:00
|
|
|
#else
|
|
|
|
typedef uint32_t in_addr_t;
|
|
|
|
struct in_addr {
|
|
|
|
in_addr_t s_addr;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2015-07-13 08:54:16 +00:00
|
|
|
#include "whence.h" // for __WHENCE__ and struct __sourceloc
|
2012-08-23 03:01:07 +00:00
|
|
|
|
2013-02-05 06:26:37 +00:00
|
|
|
/* Build a struct in_addr from a host-byte-order integer.
|
|
|
|
*
|
|
|
|
* @author Andrew Bettison <andrew@servalproject.com>
|
|
|
|
*/
|
|
|
|
struct in_addr hton_in_addr(in_addr_t);
|
|
|
|
|
2012-10-16 06:16:52 +00:00
|
|
|
#define set_nonblock(fd) (_set_nonblock(fd, __WHENCE__))
|
|
|
|
#define set_block(fd) (_set_block(fd, __WHENCE__))
|
|
|
|
#define read_nonblock(fd,buf,len) (_read_nonblock(fd, buf, len, __WHENCE__))
|
|
|
|
#define write_all(fd,buf,len) (_write_all(fd, buf, len, __WHENCE__))
|
2013-10-11 17:24:18 +00:00
|
|
|
#define writev_all(fd,iov,cnt) (_writev_all(fd, (iov), (cnt), __WHENCE__))
|
2012-10-16 06:16:52 +00:00
|
|
|
#define write_nonblock(fd,buf,len) (_write_nonblock(fd, buf, len, __WHENCE__))
|
|
|
|
#define write_all_nonblock(fd,buf,len) (_write_all_nonblock(fd, buf, len, __WHENCE__))
|
|
|
|
#define write_str(fd,str) (_write_str(fd, str, __WHENCE__))
|
|
|
|
#define write_str_nonblock(fd,str) (_write_str_nonblock(fd, str, __WHENCE__))
|
2012-08-23 03:01:07 +00:00
|
|
|
|
2012-10-16 06:16:52 +00:00
|
|
|
int _set_nonblock(int fd, struct __sourceloc __whence);
|
|
|
|
int _set_block(int fd, struct __sourceloc __whence);
|
|
|
|
ssize_t _read_nonblock(int fd, void *buf, size_t len, struct __sourceloc __whence);
|
|
|
|
ssize_t _write_all(int fd, const void *buf, size_t len, struct __sourceloc __whence);
|
|
|
|
ssize_t _write_nonblock(int fd, const void *buf, size_t len, struct __sourceloc __whence);
|
|
|
|
ssize_t _write_all_nonblock(int fd, const void *buf, size_t len, struct __sourceloc __whence);
|
2013-10-11 17:24:18 +00:00
|
|
|
ssize_t _writev_all(int fd, const struct iovec *iov, int iovcnt, struct __sourceloc __whence);
|
2012-10-16 06:16:52 +00:00
|
|
|
ssize_t _write_str(int fd, const char *str, struct __sourceloc __whence);
|
|
|
|
ssize_t _write_str_nonblock(int fd, const char *str, struct __sourceloc __whence);
|
2012-08-23 03:01:07 +00:00
|
|
|
|
2013-12-04 06:44:14 +00:00
|
|
|
#endif // __SERVAL_DNA__NET_H
|