socket-util.h revision 54255c64e6d223deb7d3863e426e78c443fda37c
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering This file is part of systemd.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering Copyright 2010 Lennart Poettering
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering systemd is free software; you can redistribute it and/or modify it
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering under the terms of the GNU Lesser General Public License as published by
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering (at your option) any later version.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering systemd is distributed in the hope that it will be useful, but
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering Lesser General Public License for more details.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering You should have received a copy of the GNU Lesser General Public License
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering /* We store the size here explicitly due to the weird
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering * sockaddr_un semantics for abstract sockets */
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering /* Socket type, i.e. SOCK_STREAM, SOCK_DGRAM, ... */
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering /* Socket protocol, IPPROTO_xxx, usually 0, except for netlink */
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering _SOCKET_ADDRESS_BIND_IPV6_ONLY_INVALID = -1
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poettering#define socket_address_family(a) ((a)->sockaddr.sa.sa_family)
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socket_address_parse(SocketAddress *a, const char *s);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socket_address_parse_and_warn(SocketAddress *a, const char *s);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socket_address_parse_netlink(SocketAddress *a, const char *s);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socket_address_print(const SocketAddress *a, char **p);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socket_address_verify(const SocketAddress *a) _pure_;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socket_address_unlink(SocketAddress *a);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringbool socket_address_can_accept(const SocketAddress *a) _pure_;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint make_socket_fd(int log_level, const char* address, int flags);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringbool socket_address_is(const SocketAddress *a, const char *s, int type);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringbool socket_address_is_netlink(const SocketAddress *a, const char *s);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringbool socket_address_matches_fd(const SocketAddress *a, int fd);
6ad623a3f77e087e308f334525fd4046811f2a9aLennart Poetteringbool socket_address_equal(const SocketAddress *a, const SocketAddress *b) _pure_;
6ad623a3f77e087e308f334525fd4046811f2a9aLennart Poetteringconst char* socket_address_get_path(const SocketAddress *a);
6ad623a3f77e087e308f334525fd4046811f2a9aLennart Poetteringint sockaddr_port(const struct sockaddr *_sa) _pure_;
6ad623a3f77e087e308f334525fd4046811f2a9aLennart Poetteringint sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ipv6, bool include_port, char **ret);
6ad623a3f77e087e308f334525fd4046811f2a9aLennart Poetteringint getpeername_pretty(int fd, char **ret);
6ad623a3f77e087e308f334525fd4046811f2a9aLennart Poetteringint getsockname_pretty(int fd, char **ret);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint getnameinfo_pretty(int fd, char **ret);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringconst char* socket_address_bind_ipv6_only_to_string(SocketAddressBindIPv6Only b) _const_;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart PoetteringSocketAddressBindIPv6Only socket_address_bind_ipv6_only_from_string(const char *s) _pure_;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint netlink_family_to_string_alloc(int b, char **s);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringint netlink_family_from_string(const char *s) _pure_;
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringbool sockaddr_equal(const union sockaddr_union *a, const union sockaddr_union *b);
6bedfcbb2970e06a4d3280c8fb62083d252ede73Lennart Poetteringchar* ether_addr_to_string(const struct ether_addr *addr, char buffer[ETHER_ADDR_TO_STRING_MAX]);