mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-18 02:39:44 +00:00
New hton_in_addr() function
To silence warnings in struct in_addr assignments on Solaris, whose struct in_addr definition is a monstrosity.
This commit is contained in:
parent
ac18b895e3
commit
cfe4da687c
@ -278,7 +278,7 @@ END_STRUCT
|
||||
|
||||
STRUCT(rhizome_api_addfile)
|
||||
STRING(64, uri_path, "", cf_opt_absolute_path,, "URI path for HTTP add-file request")
|
||||
ATOM(struct in_addr, allow_host, (struct in_addr){htonl(INADDR_LOOPBACK)}, cf_opt_in_addr,, "IP address of host allowed to make HTTP add-file request")
|
||||
ATOM(struct in_addr, allow_host, hton_in_addr(INADDR_LOOPBACK), cf_opt_in_addr,, "IP address of host allowed to make HTTP add-file request")
|
||||
STRING(256, manifest_template_file, "", cf_opt_str_nonempty,, "Path of manifest template file, either absolute or relative to instance directory")
|
||||
ATOM(sid_t, default_author, SID_ANY, cf_opt_sid,, "Author of add-file bundle if sender not given")
|
||||
ATOM(rhizome_bk_t, bundle_secret_key, RHIZOME_BK_NONE, cf_opt_rhizome_bk,, "Secret key of add-file bundle to try if sender not given")
|
||||
@ -319,7 +319,7 @@ END_STRUCT
|
||||
STRUCT(host)
|
||||
STRING(INTERFACE_NAME_STRLEN, interface, "", cf_opt_str_nonempty,, "Interface name")
|
||||
STRING(256, host, "", cf_opt_str_nonempty,, "Host Name")
|
||||
ATOM(struct in_addr, address, (struct in_addr){htonl(INADDR_NONE)}, cf_opt_in_addr,, "Host IP address")
|
||||
ATOM(struct in_addr, address, hton_in_addr(INADDR_NONE), cf_opt_in_addr,, "Host IP address")
|
||||
ATOM(uint16_t, port, PORT_DNA, cf_opt_uint16_nonzero,, "Port number")
|
||||
END_STRUCT
|
||||
|
||||
@ -332,8 +332,8 @@ STRUCT(network_interface, vld_network_interface)
|
||||
ATOM(int, exclude, 0, cf_opt_int_boolean,, "If true, do not use matching interfaces")
|
||||
ATOM(struct pattern_list, match, PATTERN_LIST_EMPTY, cf_opt_pattern_list,, "Names that match network interface")
|
||||
STRING(256, dummy, "", cf_opt_str_nonempty,, "Path of dummy file, absolute or relative to server.dummy_interface_dir")
|
||||
ATOM(struct in_addr, dummy_address, (struct in_addr){htonl(0x7F000001)}, cf_opt_in_addr,, "Dummy interface address")
|
||||
ATOM(struct in_addr, dummy_netmask, (struct in_addr){htonl(0xFFFFFF00)}, cf_opt_in_addr,, "Dummy interface netmask")
|
||||
ATOM(struct in_addr, dummy_address, hton_in_addr(INADDR_LOOPBACK), cf_opt_in_addr,, "Dummy interface address")
|
||||
ATOM(struct in_addr, dummy_netmask, hton_in_addr(0xFFFFFF00), cf_opt_in_addr,, "Dummy interface netmask")
|
||||
ATOM(char, dummy_filter_broadcasts, 0, cf_opt_char_boolean,, "If true, drop all incoming broadcast packets")
|
||||
ATOM(char, dummy_filter_unicasts, 0, cf_opt_char_boolean,, "If true, drop all incoming unicast packets")
|
||||
ATOM(short, type, OVERLAY_INTERFACE_WIFI, cf_opt_interface_type,, "Type of network interface")
|
||||
|
7
net.c
7
net.c
@ -29,6 +29,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "net.h"
|
||||
#include "str.h"
|
||||
|
||||
struct in_addr hton_in_addr(in_addr_t addr)
|
||||
{
|
||||
struct in_addr a;
|
||||
a.s_addr = htonl(addr);
|
||||
return a;
|
||||
}
|
||||
|
||||
int _set_nonblock(int fd, struct __sourceloc __whence)
|
||||
{
|
||||
int flags;
|
||||
|
8
net.h
8
net.h
@ -21,8 +21,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
#include <sys/types.h> // for size_t, ssize_t
|
||||
#include <sys/socket.h> // for struct sockaddr, socklen_t
|
||||
#include <netinet/in.h> // for struct in_addr
|
||||
#include <arpa/inet.h> // for in_addr_t
|
||||
#include "log.h" // for __WHENCE__ and struct __sourceloc
|
||||
|
||||
/* 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);
|
||||
|
||||
#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__))
|
||||
|
@ -803,7 +803,7 @@ void overlay_interface_discover(struct sched_ent *alarm)
|
||||
}
|
||||
if (i >= overlay_interface_count) {
|
||||
// New dummy interface, so register it.
|
||||
struct in_addr dummyaddr = (struct in_addr){htonl(INADDR_NONE)};
|
||||
struct in_addr dummyaddr = hton_in_addr(INADDR_NONE);
|
||||
overlay_interface_init(ifconfig->dummy, dummyaddr, dummyaddr, dummyaddr, ifconfig);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user