From 8e0608d31d988333ff04f3faaa6e851c0ecdbc6e Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Thu, 22 Apr 2010 16:52:29 +0200 Subject: Fourth stage to ipset-5 Add new userspace files: include/, lib/ and plus new files in src/. --- include/libipset/utils.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 include/libipset/utils.h (limited to 'include/libipset/utils.h') diff --git a/include/libipset/utils.h b/include/libipset/utils.h new file mode 100644 index 0000000..2d12e91 --- /dev/null +++ b/include/libipset/utils.h @@ -0,0 +1,45 @@ +/* Copyright 2007-2010 Jozsef Kadlecsik (kadlec@blackhole.kfki.hu) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef LIBIPSET_UTILS_H +#define LIBIPSET_UTILS_H + +#include /* bool */ +#include /* strcmp */ +#include /* struct in[6]_addr */ + +/* String equality tests */ +#define STREQ(a,b) (strcmp(a,b) == 0) +#define STRNEQ(a,b,n) (strncmp(a,b,n) == 0) + +/* Stringify tokens */ +#define _STR(c) #c +#define STR(c) _STR(c) + +/* Min/max */ +#define MIN(a, b) (a < b ? a : b) +#define MAX(a, b) (a > b ? a : b) + +#define UNUSED __attribute__ ((unused)) + +static inline void +in4cpy(struct in_addr *dest, const struct in_addr *src) +{ + dest->s_addr = src->s_addr; +} + +static inline void +in6cpy(struct in6_addr *dest, const struct in6_addr *src) +{ + memcpy(dest, src, sizeof(struct in6_addr)); +} + +extern char * ipset_strchr(const char *str, const char *sep); +extern bool ipset_name_match(const char *arg, const char * const name[]); +extern void ipset_shift_argv(int *argc, char *argv[], int from); +extern void ipset_strncpy(char *dst, const char *src, size_t len); + +#endif /* LIBIPSET_UTILS_H */ -- cgit v1.2.3