5 * Copyright (C) 2001-2003 FhG Fokus
7 * This file is part of ser, a free SIP server.
9 * ser is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version
14 * For a license to use the ser software under conditions
15 * other than those described here, or to purchase support for this
16 * software, please contact iptel.org by e-mail at the following addresses:
19 * ser is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 * 2003-02-13 added proto to struct proxy_l & to *_proxy functions (andrei)
45 str name; /* original name */
46 struct hostent host; /* addresses */
48 unsigned short reserved; /*align*/
53 int addr_idx; /* crt. addr. idx. */
54 int ok; /* 0 on error */
61 extern struct proxy_l* proxies;
63 struct proxy_l* add_proxy(str* name, unsigned short port, int proto);
64 struct proxy_l* mk_proxy(str* name, unsigned short port, int proto);
65 struct proxy_l* mk_shm_proxy(str* name, unsigned short port, int proto);
66 struct proxy_l* mk_proxy_from_ip(struct ip_addr* ip, unsigned short port,
68 void free_proxy(struct proxy_l* p);
69 void free_shm_proxy(struct proxy_l* p);
73 /* returns 0 on success, -1 on error (unknown af/bug) */
74 inline static int proxy2su(union sockaddr_union* su, struct proxy_l* p)
76 /* if error try next ip address if possible */
78 if (p->host.h_addr_list[p->addr_idx+1])
84 return hostent2su(su, &p->host, p->addr_idx,
85 (p->port)?p->port:((p->proto==PROTO_TLS)?SIPS_PORT:SIP_PORT) );
90 /* mark as proxy either as ok (err>=0) or as bad (err<0) */
91 inline static void proxy_mark(struct proxy_l* p, int err)