2 This software is available to you under a choice of one of two
3 licenses. You may choose to be licensed under the terms of the GNU
4 General Public License (GPL) Version 2, available at
5 <http://www.fsf.org/copyleft/gpl.html>, or the OpenIB.org BSD
6 license, available in the LICENSE.TXT file accompanying this
7 software. These details are also available at
8 <http://openib.org/license.html>.
10 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
11 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
12 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
13 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
14 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
15 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 Copyright (c) 2004 Topspin Communications. All rights reserved.
20 Copyright (c) 2005-2006 Mellanox Technologies Ltd. All rights reserved.
25 #include <netinet/in.h>
28 * SDP specific includes
30 #include "linux/sdp_inet.h"
32 /* --------------------------------------------------------------------- */
33 /* library static and global variables */
34 /* --------------------------------------------------------------------- */
36 /* max string length to store any IPv4/IPv6 address */
37 #define MAX_ADDR_STR_LEN 49
46 /* some state to string functions */
62 return ( "unknown-family" );
65 /* data structure for holding address family mapoping rules */
66 /* note we filter non relevant programs during parsing ... */
67 struct use_family_rule
69 struct use_family_rule *prev, *next;
70 int match_by_addr; /* if 0 ignore address match */
71 struct in_addr ipv4; /* IPv4 address for mapping */
72 unsigned char prefixlen; /* length of CIDR prefix (ie /24) */
73 int match_by_port; /* if 0 ignore port match */
74 unsigned short sport, eport; /* start port - end port, inclusive */
75 use_family_t target_family; /* if match - use this family */
76 char *prog_name_expr; /* expression for program name */
79 extern struct use_family_rule *__sdp_clients_family_rules_head;
80 extern struct use_family_rule *__sdp_clients_family_rules_tail;
81 extern struct use_family_rule *__sdp_servers_family_rules_head;
82 extern struct use_family_rule *__sdp_servers_family_rules_tail;
84 #define SDP_NETMASK(n) ((n == 0) ? 0 : ~((1UL<<(32 - n)) - 1))
87 use_family_t __sdp_match_connect(
88 const struct sockaddr *sin,
89 const socklen_t addrlen );
91 use_family_t __sdp_match_listen(
92 const struct sockaddr *sin,
93 const socklen_t addrlen );
96 int __sdp_config_empty(
99 int __sdp_parse_config(
100 const char *config_file );
102 use_family_t __sdp_match_by_program(
111 int __sdp_log_get_level(
114 void __sdp_log_set_min_level(
117 int __sdp_log_set_log_stderr(
120 int __sdp_log_set_log_syslog(
123 int __sdp_log_set_log_file(
127 int __sdp_sockaddr_to_sdp(
128 const struct sockaddr *addr_in,
130 struct sockaddr_in *addr_out,