source: vendor/current/lib/util/util_net.h

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 3.7 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3 Utility functions for Samba
4 Copyright (C) Andrew Tridgell 1992-1999
5 Copyright (C) Jelmer Vernooij 2005
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#ifndef _SAMBA_UTIL_NET_H_
22#define _SAMBA_UTIL_NET_H_
23
24#include "system/network.h"
25
26/* The following definitions come from lib/util/util_net.c */
27
28void zero_sockaddr(struct sockaddr_storage *pss);
29
30bool interpret_string_addr_internal(struct addrinfo **ppres,
31 const char *str, int flags);
32
33bool interpret_string_addr(struct sockaddr_storage *pss,
34 const char *str,
35 int flags);
36
37/*******************************************************************
38 Map a text hostname or IP address (IPv4 or IPv6) into a
39 struct sockaddr_storage. Version that prefers IPv4.
40******************************************************************/
41
42bool interpret_string_addr_prefer_ipv4(struct sockaddr_storage *pss,
43 const char *str,
44 int flags);
45
46void set_sockaddr_port(struct sockaddr *psa, uint16_t port);
47
48/**
49 Check if an IP is the 0.0.0.0.
50**/
51_PUBLIC_ bool is_zero_ip_v4(struct in_addr ip);
52
53void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
54 struct in_addr ip);
55#if defined(HAVE_IPV6)
56/**
57 * Convert an IPv6 struct in_addr to a struct sockaddr_storage.
58 */
59void in6_addr_to_sockaddr_storage(struct sockaddr_storage *ss,
60 struct in6_addr ip);
61#endif
62/**
63 Are two IPs on the same subnet?
64**/
65_PUBLIC_ bool same_net_v4(struct in_addr ip1,struct in_addr ip2,struct in_addr mask);
66
67/**
68 Return true if a string could be a pure IP address.
69**/
70_PUBLIC_ bool is_ipaddress(const char *str);
71
72bool is_broadcast_addr(const struct sockaddr *pss);
73bool is_loopback_ip_v4(struct in_addr ip);
74bool is_loopback_addr(const struct sockaddr *pss);
75bool is_zero_addr(const struct sockaddr_storage *pss);
76void zero_ip_v4(struct in_addr *ip);
77bool is_linklocal_addr(const struct sockaddr_storage *pss);
78/**
79 Interpret an internet address or name into an IP address in 4 byte form.
80**/
81_PUBLIC_ uint32_t interpret_addr(const char *str);
82
83/**
84 A convenient addition to interpret_addr().
85**/
86_PUBLIC_ struct in_addr interpret_addr2(const char *str);
87
88_PUBLIC_ bool is_ipaddress_v4(const char *str);
89_PUBLIC_ bool is_ipv6_literal(const char *str);
90_PUBLIC_ bool is_ipaddress_v6(const char *str);
91
92bool is_address_any(const struct sockaddr *psa);
93bool same_net(const struct sockaddr *ip1,
94 const struct sockaddr *ip2,
95 const struct sockaddr *mask);
96bool sockaddr_equal(const struct sockaddr *ip1,
97 const struct sockaddr *ip2);
98
99bool is_address_any(const struct sockaddr *psa);
100uint16_t get_sockaddr_port(const struct sockaddr_storage *pss);
101char *print_sockaddr_len(char *dest,
102 size_t destlen,
103 const struct sockaddr *psa,
104 socklen_t psalen);
105char *print_sockaddr(char *dest,
106 size_t destlen,
107 const struct sockaddr_storage *psa);
108char *print_canonical_sockaddr(TALLOC_CTX *ctx,
109 const struct sockaddr_storage *pss);
110int get_socket_port(int fd);
111const char *client_socket_addr(int fd, char *addr, size_t addr_len);
112
113void set_socket_options(int fd, const char *options);
114
115#endif /* _SAMBA_UTIL_NET_H_ */
Note: See TracBrowser for help on using the repository browser.