diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-09 06:30:21 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2013-03-09 06:30:21 +0100 |
commit | 3705dc02cc18b79c77d8f5aba934e02c7a91467f (patch) | |
tree | 71d97898c3f7ae3b7d1e879c974100b413627ac2 /util.h | |
parent | 6072fb8c6569189f22a0b000fc68534ce0e500df (diff) | |
download | econ-3705dc02cc18b79c77d8f5aba934e02c7a91467f.tar.gz econ-3705dc02cc18b79c77d8f5aba934e02c7a91467f.tar.bz2 econ-3705dc02cc18b79c77d8f5aba934e02c7a91467f.zip |
Add util mostly for socket-based tasks
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -0,0 +1,28 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include <stdint.h> + +#define MAX(a, b) (((a) > (b)) ? (a) : (b)) +#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof ((arr)[0])) + +#define STR_EXPAND(tok) #tok +#define STR(str) STR_EXPAND(str) + +uint32_t +sock_get_ipv4_addr(int fd); +uint32_t +sock_get_peer_ipv4_addr(int fd); +uint32_t +sock_get_netmask(int fd); + +void +set_ip(uint8_t *ipbuf, uint32_t ip); +int +bind_socket(int socktype, const char *host, const char *port); +int +connect_to_host(int socktype, const char *host, const char *port); +ssize_t +loop_read(int fd, void *buf, size_t nbytes, uint8_t do_poll); + +#endif /* _UTIL_H_ */ |