diff options
Diffstat (limited to 'include/argot/sockaddr.h')
-rw-r--r-- | include/argot/sockaddr.h | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/include/argot/sockaddr.h b/include/argot/sockaddr.h new file mode 100644 index 0000000..e5325c1 --- /dev/null +++ b/include/argot/sockaddr.h @@ -0,0 +1,66 @@ +/* argot - Gray's Extensible Configuration System -*- c -*- + Copyright (C) 2007-2016 Sergey Poznyakoff + + Grecs 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 3 of the License, or (at your + option) any later version. + + Grecs 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 Grecs. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef _ARGOT_SOCKADDR_H +#define _ARGOT_SOCKADDR_H + +struct argot_sockaddr { +#if ARGOT_SOCKADDR_LIST + struct argot_sockaddr *next; +#endif + int len; + struct sockaddr *sa; +}; + +#if ARGOT_SOCKADDR_LIST + +#define ARGOT_AH_PASSIVE 0x01 +#define ARGOT_HINT_SERVICE 0x02 +#define ARGOT_HINT_PORT 0x04 + +struct argot_sockaddr_hints { + int flags; + char *service; + unsigned short port; +}; + +extern struct argot_sockaddr_hints *argot_sockaddr_hints; + +struct argot_sockaddr *argot_sockaddr_new(size_t s); +void argot_sockaddr_free(struct argot_sockaddr *p); + +int argot_str_to_sockaddr(struct argot_sockaddr **sap, + const char *arg, struct argot_sockaddr_hints *gh, + argot_locus_t const *locus); +#endif + +#define ARGOT_INADDR_BYTES 16 + +struct argot_cidr +{ + int family; + int len; + unsigned char address[ARGOT_INADDR_BYTES]; + unsigned char netmask[ARGOT_INADDR_BYTES]; +}; + +int argot_str_to_cidr(struct argot_cidr *pcidr, const char *str, + argot_locus_t const *locus); + +int argot_sockaddr_to_cidr(struct argot_cidr *cidr, const struct sockaddr *sa); +int argot_sockadd_cidr_match(struct sockaddr *sa, struct argot_cidr *cidr); + +#endif |