chan_sip: Add TLS and SRTP status to CLI command 'sip show channel'
[asterisk/asterisk.git] / include / asterisk / netsock2.h
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2010, Digium, Inc.
5  *
6  * ViagĂ©nie <asteriskv6@viagenie.ca>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18
19 /*! \file
20  * \brief Network socket handling
21  */
22
23 #ifndef _ASTERISK_NETSOCK2_H
24 #define _ASTERISK_NETSOCK2_H
25
26 #if defined(__cplusplus) || defined(c_plusplus)
27 extern "C" {
28 #endif
29
30 #include <sys/socket.h>
31
32 #include <netinet/in.h>
33
34 /*!
35  * Values for address families that we support. This is reproduced from socket.h
36  * because we do not want users to include that file. Only netsock2.c should
37  * ever include socket.h.
38  */
39 enum {
40         AST_AF_UNSPEC = AF_UNSPEC,
41         AST_AF_INET   = AF_INET,
42         AST_AF_INET6  = AF_INET6,
43 };
44
45 enum ast_transport {
46         AST_TRANSPORT_UDP   = 1,
47         AST_TRANSPORT_TCP   = 1 << 1,
48         AST_TRANSPORT_TLS   = 1 << 2,
49         AST_TRANSPORT_WS    = 1 << 3,
50         AST_TRANSPORT_WSS   = 1 << 4,
51 };
52
53 /*!
54  * \brief
55  * Isolate a 32-bit section of an IPv6 address
56  *
57  * An IPv6 address can be divided into 4 32-bit chunks. This gives
58  * easy access to one of these chunks.
59  *
60  * \param sin6 A pointer to a struct sockaddr_in6
61  * \param index Which 32-bit chunk to operate on. Must be in the range 0-3.
62  */
63 #define V6_WORD(sin6, index) ((uint32_t *)&((sin6)->sin6_addr))[(index)]
64
65 /*!
66  * \brief Socket address structure.
67  *
68  * \details
69  * The first member is big enough to contain addresses of any
70  * family. The second member contains the length (in bytes) used
71  * in the first member.
72  *
73  * \note
74  * Some BSDs have the length embedded in sockaddr structs. We
75  * ignore them. (This is the right thing to do.)
76  *
77  * \note
78  * It is important to always initialize ast_sockaddr before use
79  * -- even if they are passed to ast_sockaddr_copy() as the
80  * underlying storage could be bigger than what ends up being
81  * copied -- leaving part of the data unitialized.
82  */
83 struct ast_sockaddr {
84         struct sockaddr_storage  ss;
85         socklen_t len;
86 };
87
88 /*!
89  * \brief
90  * Convert an IPv4-mapped IPv6 address into an IPv4 address.
91  *
92  * \warning You should rarely need this function. Only call this
93  * if you know what you're doing.
94  *
95  * \param addr The IPv4-mapped address to convert
96  * \param ast_mapped The resulting IPv4 address
97  * \retval 0 Unable to make the conversion
98  * \retval 1 Successful conversion
99  */
100 int ast_sockaddr_ipv4_mapped(const struct ast_sockaddr *addr, struct ast_sockaddr *ast_mapped);
101
102 /*!
103  * \since 1.8
104  *
105  * \brief
106  * Checks if the ast_sockaddr is null. "null" in this sense essentially
107  * means uninitialized, or having a 0 length.
108  *
109  * \param addr Pointer to the ast_sockaddr we wish to check
110  * \retval 1 \a addr is null
111  * \retval 0 \a addr is non-null.
112  */
113 static inline int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
114 {
115         return !addr || addr->len == 0;
116 }
117
118 /*!
119  * \since 1.8
120  *
121  * \brief
122  * Sets address \a addr to null.
123  *
124  * \retval void
125  */
126 static inline void ast_sockaddr_setnull(struct ast_sockaddr *addr)
127 {
128         addr->len = 0;
129 }
130
131 /*!
132  * \since 1.8
133  *
134  * \brief
135  * Copies the data from one ast_sockaddr to another
136  *
137  * \param dst The destination ast_sockaddr
138  * \param src The source ast_sockaddr
139  * \retval void
140  */
141 static inline void ast_sockaddr_copy(struct ast_sockaddr *dst,
142                 const struct ast_sockaddr *src)
143 {
144         memcpy(dst, src, src->len);
145         dst->len = src->len;
146 };
147
148 /*!
149  * \since 1.8
150  *
151  * \brief
152  * Compares two ast_sockaddr structures
153  *
154  * \retval -1 \a a is lexicographically smaller than \a b
155  * \retval 0 \a a is equal to \a b
156  * \retval 1 \a b is lexicographically smaller than \a a
157  */
158 int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b);
159
160 /*!
161  * \since 1.8
162  *
163  * \brief
164  * Compares the addresses of two ast_sockaddr structures.
165  *
166  * \retval -1 \a a is lexicographically smaller than \a b
167  * \retval 0 \a a is equal to \a b
168  * \retval 1 \a b is lexicographically smaller than \a a
169  */
170 int ast_sockaddr_cmp_addr(const struct ast_sockaddr *a, const struct ast_sockaddr *b);
171
172 #define AST_SOCKADDR_STR_ADDR           (1 << 0)
173 #define AST_SOCKADDR_STR_PORT           (1 << 1)
174 #define AST_SOCKADDR_STR_BRACKETS       (1 << 2)
175 #define AST_SOCKADDR_STR_REMOTE         (1 << 3)
176 #define AST_SOCKADDR_STR_HOST           (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_BRACKETS)
177 #define AST_SOCKADDR_STR_DEFAULT        (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT)
178 #define AST_SOCKADDR_STR_ADDR_REMOTE     (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_REMOTE)
179 #define AST_SOCKADDR_STR_HOST_REMOTE     (AST_SOCKADDR_STR_HOST | AST_SOCKADDR_STR_REMOTE)
180 #define AST_SOCKADDR_STR_DEFAULT_REMOTE  (AST_SOCKADDR_STR_DEFAULT | AST_SOCKADDR_STR_REMOTE)
181 #define AST_SOCKADDR_STR_FORMAT_MASK     (AST_SOCKADDR_STR_ADDR | AST_SOCKADDR_STR_PORT | AST_SOCKADDR_STR_BRACKETS)
182
183 /*!
184  * \since 1.8
185  *
186  * \brief
187  * Convert a socket address to a string.
188  *
189  * \details
190  * This will be of the form a.b.c.d:xyz
191  * for IPv4 and [a:b:c:...:d]:xyz for IPv6.
192  *
193  * This function is thread-safe. The returned string is on static
194  * thread-specific storage.
195  *
196  * \param addr The input to be stringified
197  * \param format one of the following:
198  * AST_SOCKADDR_STR_DEFAULT:
199  *    a.b.c.d:xyz for IPv4
200  *    [a:b:c:...:d]:xyz for IPv6.
201  * AST_SOCKADDR_STR_ADDR: address only
202  *    a.b.c.d for IPv4
203  *    a:b:c:...:d for IPv6.
204  * AST_SOCKADDR_STR_HOST: address only, suitable for a URL
205  *    a.b.c.d for IPv4
206  *    [a:b:c:...:d] for IPv6.
207  * AST_SOCKADDR_STR_PORT: port only
208  *
209  * \note The string pointer returned by this function will point to a string that
210  * will be changed whenever any form of ast_sockaddr_stringify_fmt is called on that
211  * thread. Because of this, it is important that if you use this function, you use the
212  * string before another use of this function is made elsewhere in the same thread.
213  * The easiest way to accomplish this is by immediately copying the string to a buffer
214  * with something like ast_strdupa.
215  *
216  * \retval "(null)" \a addr is null
217  * \retval "" An error occurred during processing
218  * \retval string The stringified form of the address
219  */
220 char *ast_sockaddr_stringify_fmt(const struct ast_sockaddr *addr, int format);
221
222 /*!
223  * \since 1.8
224  *
225  * \brief
226  * Wrapper around ast_sockaddr_stringify_fmt() with default format
227  *
228  * \return same as ast_sockaddr_stringify_fmt()
229  */
230 static inline char *ast_sockaddr_stringify(const struct ast_sockaddr *addr)
231 {
232         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT);
233 }
234
235 /*!
236  * \since 1.8
237  *
238  * \brief
239  * Wrapper around ast_sockaddr_stringify_fmt() with default format
240  *
241  * \note This address will be suitable for passing to a remote machine via the
242  * application layer. For example, the scope-id on a link-local IPv6 address
243  * will be stripped.
244  *
245  * \return same as ast_sockaddr_stringify_fmt()
246  */
247 static inline char *ast_sockaddr_stringify_remote(const struct ast_sockaddr *addr)
248 {
249         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_DEFAULT_REMOTE);
250 }
251
252 /*!
253  * \since 1.8
254  *
255  * \brief
256  * Wrapper around ast_sockaddr_stringify_fmt() to return an address only
257  *
258  * \return same as ast_sockaddr_stringify_fmt()
259  */
260 static inline char *ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
261 {
262         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR);
263 }
264
265 /*!
266  * \since 1.8
267  *
268  * \brief
269  * Wrapper around ast_sockaddr_stringify_fmt() to return an address only
270  *
271  * \note This address will be suitable for passing to a remote machine via the
272  * application layer. For example, the scope-id on a link-local IPv6 address
273  * will be stripped.
274  *
275  * \return same as ast_sockaddr_stringify_fmt()
276  */
277 static inline char *ast_sockaddr_stringify_addr_remote(const struct ast_sockaddr *addr)
278 {
279         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_ADDR_REMOTE);
280 }
281
282 /*!
283  * \since 1.8
284  *
285  * \brief
286  * Wrapper around ast_sockaddr_stringify_fmt() to return an address only,
287  * suitable for a URL (with brackets for IPv6).
288  *
289  * \return same as ast_sockaddr_stringify_fmt()
290  */
291 static inline char *ast_sockaddr_stringify_host(const struct ast_sockaddr *addr)
292 {
293         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST);
294 }
295
296 /*!
297  * \since 1.8
298  *
299  * \brief
300  * Wrapper around ast_sockaddr_stringify_fmt() to return an address only,
301  * suitable for a URL (with brackets for IPv6).
302  *
303  * \note This address will be suitable for passing to a remote machine via the
304  * application layer. For example, the scope-id on a link-local IPv6 address
305  * will be stripped.
306  *
307  * \return same as ast_sockaddr_stringify_fmt()
308  */
309 static inline char *ast_sockaddr_stringify_host_remote(const struct ast_sockaddr *addr)
310 {
311         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_HOST_REMOTE);
312 }
313
314 /*!
315  * \since 1.8
316  *
317  * \brief
318  * Wrapper around ast_sockaddr_stringify_fmt() to return a port only
319  *
320  * \return same as ast_sockaddr_stringify_fmt()
321  */
322 static inline char *ast_sockaddr_stringify_port(const struct ast_sockaddr *addr)
323 {
324         return ast_sockaddr_stringify_fmt(addr, AST_SOCKADDR_STR_PORT);
325 }
326
327 /*!
328  * \since 1.8
329  *
330  * \brief
331  * Splits a string into its host and port components
332  *
333  * \param[in] str The string to parse. May be modified by writing a NUL at the end of
334  *                  the host part.
335  * \param[out] host Pointer to the host component within \a str.
336  * \param[out] port Pointer to the port component within \a str.
337  * \param flags     If set to zero, a port MAY be present. If set to PARSE_PORT_IGNORE, a
338  *                  port MAY be present but will be ignored. If set to PARSE_PORT_REQUIRE,
339  *                  a port MUST be present. If set to PARSE_PORT_FORBID, a port MUST NOT
340  *                  be present.
341  *
342  * \retval 1 Success
343  * \retval 0 Failure
344  */
345 int ast_sockaddr_split_hostport(char *str, char **host, char **port, int flags);
346
347 /*!
348  * \since 1.8
349  *
350  * \brief
351  * Parse an IPv4 or IPv6 address string.
352  *
353  * \details
354  * Parses a string containing an IPv4 or IPv6 address followed by an optional
355  * port (separated by a colon) into a struct ast_sockaddr. The allowed formats
356  * are the following:
357  *
358  * a.b.c.d
359  * a.b.c.d:port
360  * a:b:c:...:d
361  * [a:b:c:...:d]
362  * [a:b:c:...:d]:port
363  *
364  * Host names are NOT allowed.
365  *
366  * \param[out] addr The resulting ast_sockaddr. This MAY be NULL from 
367  * functions that are performing validity checks only, e.g. ast_parse_arg().
368  * \param str The string to parse
369  * \param flags If set to zero, a port MAY be present. If set to
370  * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to
371  * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a
372  * port MUST NOT be present.
373  *
374  * \retval 1 Success
375  * \retval 0 Failure
376  */
377 int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags);
378
379 /*!
380  * \since 1.8
381  *
382  * \brief
383  * Parses a string with an IPv4 or IPv6 address and place results into an array
384  *
385  * \details
386  * Parses a string containing a host name or an IPv4 or IPv6 address followed
387  * by an optional port (separated by a colon).  The result is returned into a
388  * array of struct ast_sockaddr. Allowed formats for str are the following:
389  *
390  * hostname:port
391  * host.example.com:port
392  * a.b.c.d
393  * a.b.c.d:port
394  * a:b:c:...:d
395  * [a:b:c:...:d]
396  * [a:b:c:...:d]:port
397  *
398  * \param[out] addrs The resulting array of ast_sockaddrs
399  * \param str The string to parse
400  * \param flags If set to zero, a port MAY be present. If set to
401  * PARSE_PORT_IGNORE, a port MAY be present but will be ignored. If set to
402  * PARSE_PORT_REQUIRE, a port MUST be present. If set to PARSE_PORT_FORBID, a
403  * port MUST NOT be present.
404  *
405  * \param family Only addresses of the given family will be returned. Use 0 or
406  * AST_AF_UNSPEC to get addresses of all families.
407  *
408  * \retval 0 Failure
409  * \retval non-zero The number of elements in addrs array.
410  */
411 int ast_sockaddr_resolve(struct ast_sockaddr **addrs, const char *str,
412                          int flags, int family);
413
414 /*!
415  * \brief
416  * Apply a netmask to an address and store the result in a separate structure.
417  *
418  * When dealing with IPv6 addresses, one cannot apply a netmask with a simple
419  * logical AND operation.  Futhermore, the incoming address may be an IPv4
420  * address and needs to be mapped properly before attempting to apply a rule.
421  *
422  * \param addr The IP address to apply the mask to.
423  * \param netmask The netmask configured in the host access rule.
424  * \param result The resultant address after applying the netmask to the given address
425  * \retval 0 Successfully applied netmask
426  * \retval -1 Failed to apply netmask
427  */
428 int ast_sockaddr_apply_netmask(const struct ast_sockaddr *addr, const struct ast_sockaddr *netmask,
429                 struct ast_sockaddr *result);
430
431 /*!
432  * \since 1.8
433  *
434  * \brief
435  * Get the port number of a socket address.
436  *
437  * \warning Do not use this function unless you really know what you are doing.
438  * And "I want the port number" is not knowing what you are doing.
439  *
440  * \retval 0 Address is null
441  * \retval non-zero The port number of the ast_sockaddr
442  */
443 #define ast_sockaddr_port(addr) _ast_sockaddr_port(addr, __FILE__, __LINE__, __PRETTY_FUNCTION__)
444 uint16_t _ast_sockaddr_port(const struct ast_sockaddr *addr, const char *file, int line, const char *func);
445
446 /*!
447  * \since 1.8
448  *
449  * \brief
450  * Sets the port number of a socket address.
451  *
452  * \warning Do not use this function unless you really know what you are doing.
453  * And "I want the port number" is not knowing what you are doing.
454  *
455  * \param addr Address on which to set the port
456  * \param port The port you wish to set the address to use
457  * \retval void
458  */
459 #define ast_sockaddr_set_port(addr,port)        _ast_sockaddr_set_port(addr,port,__FILE__,__LINE__,__PRETTY_FUNCTION__)
460 void _ast_sockaddr_set_port(struct ast_sockaddr *addr, uint16_t port, const char *file, int line, const char *func);
461
462 /*!
463  * \since 1.8
464  *
465  * \brief
466  * Get an IPv4 address of an ast_sockaddr
467  *
468  * \warning You should rarely need this function. Only use if you know what
469  * you're doing.
470  * \return IPv4 address in network byte order
471  */
472 uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr);
473
474 /*!
475  * \since 1.8
476  *
477  * \brief
478  * Determine if the address is an IPv4 address
479  *
480  * \warning You should rarely need this function. Only use if you know what
481  * you're doing.
482  * \retval 1 This is an IPv4 address
483  * \retval 0 This is an IPv6 or IPv4-mapped IPv6 address
484  */
485 int ast_sockaddr_is_ipv4(const struct ast_sockaddr *addr);
486
487 /*!
488  * \since 1.8
489  *
490  * \brief
491  * Determine if this is an IPv4-mapped IPv6 address
492  *
493  * \warning You should rarely need this function. Only use if you know what
494  * you're doing.
495  *
496  * \retval 1 This is an IPv4-mapped IPv6 address.
497  * \retval 0 This is not an IPv4-mapped IPv6 address.
498  */
499 int ast_sockaddr_is_ipv4_mapped(const struct ast_sockaddr *addr);
500
501 /*!
502  * \since 10.0
503  *
504  * \brief
505  * Determine if an IPv4 address is a multicast address
506  *
507  * \param addr the address to check
508  *
509  * This function checks if an address is in the 224.0.0.0/4 network block.
510  *
511  * \return non-zero if this is a multicast address
512  */
513 int ast_sockaddr_is_ipv4_multicast(const struct ast_sockaddr *addr);
514
515 /*!
516  * \since 1.8
517  *
518  * \brief
519  * Determine if this is a link-local IPv6 address
520  *
521  * \warning You should rarely need this function. Only use if you know what
522  * you're doing.
523  *
524  * \retval 1 This is a link-local IPv6 address.
525  * \retval 0 This is link-local IPv6 address.
526  */
527 int ast_sockaddr_is_ipv6_link_local(const struct ast_sockaddr *addr);
528
529 /*!
530  * \since 1.8
531  *
532  * \brief
533  * Determine if this is an IPv6 address
534  *
535  * \warning You should rarely need this function. Only use if you know what
536  * you're doing.
537  *
538  * \retval 1 This is an IPv6 or IPv4-mapped IPv6 address.
539  * \retval 0 This is an IPv4 address.
540  */
541 int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr);
542
543 /*!
544  * \since 1.8
545  *
546  * \brief
547  * Determine if the address type is unspecified, or "any" address.
548  *
549  * \details
550  * For IPv4, this would be the address 0.0.0.0, and for IPv6,
551  * this would be the address ::. The port number is ignored.
552  *
553  * \retval 1 This is an "any" address
554  * \retval 0 This is not an "any" address
555  */
556 int ast_sockaddr_is_any(const struct ast_sockaddr *addr);
557
558 /*!
559  * \since 1.8
560  *
561  * \brief
562  * Computes a hash value from the address. The port is ignored.
563  *
564  * \retval 0 Unknown address family
565  * \retval other A 32-bit hash derived from the address
566  */
567 int ast_sockaddr_hash(const struct ast_sockaddr *addr);
568
569 /*!
570  * \since 12.3
571  *
572  * \brief
573  * Returns a string representation of an ast_transport
574  *
575  * \retval Name of the tranpsort if it is defined
576  * \retval Undefined if the transport is undefined
577  */
578 const char *ast_transport2str(enum ast_transport transport);
579
580 /*!
581  * \since 1.8
582  *
583  * \brief
584  * Wrapper around accept(2) that uses struct ast_sockaddr.
585  *
586  * \details
587  * For parameter and return information, see the man page for
588  * accept(2).
589  */
590 int ast_accept(int sockfd, struct ast_sockaddr *addr);
591
592 /*!
593  * \since 1.8
594  *
595  * \brief
596  * Wrapper around bind(2) that uses struct ast_sockaddr.
597  *
598  * \details
599  * For parameter and return information, see the man page for
600  * bind(2).
601  */
602 int ast_bind(int sockfd, const struct ast_sockaddr *addr);
603
604 /*!
605  * \since 1.8
606  *
607  * \brief
608  * Wrapper around connect(2) that uses struct ast_sockaddr.
609  *
610  * \details
611  * For parameter and return information, see the man page for
612  * connect(2).
613  */
614 int ast_connect(int sockfd, const struct ast_sockaddr *addr);
615
616 /*!
617  * \since 1.8
618  *
619  * \brief
620  * Wrapper around getsockname(2) that uses struct ast_sockaddr.
621  *
622  * \details
623  * For parameter and return information, see the man page for
624  * getsockname(2).
625  */
626 int ast_getsockname(int sockfd, struct ast_sockaddr *addr);
627
628 /*!
629  * \since 1.8
630  *
631  * \brief
632  * Wrapper around recvfrom(2) that uses struct ast_sockaddr.
633  *
634  * \details
635  * For parameter and return information, see the man page for
636  * recvfrom(2).
637  */
638 ssize_t ast_recvfrom(int sockfd, void *buf, size_t len, int flags,
639                      struct ast_sockaddr *src_addr);
640
641 /*!
642  * \since 1.8
643  *
644  * \brief
645  * Wrapper around sendto(2) that uses ast_sockaddr.
646  *
647  * \details
648  * For parameter and
649  * return information, see the man page for sendto(2)
650  */
651 ssize_t ast_sendto(int sockfd, const void *buf, size_t len, int flags,
652                    const struct ast_sockaddr *dest_addr);
653
654 /*!
655  * \since 1.8
656  *
657  * \brief
658  * Set type of service
659  *
660  * \details
661  * Set ToS ("Type of Service for IPv4 and "Traffic Class for IPv6) and
662  * CoS (Linux's SO_PRIORITY)
663  *
664  * \param sockfd File descriptor for socket on which to set the parameters
665  * \param tos The type of service for the socket
666  * \param cos The cost of service for the socket
667  * \param desc A text description of the socket in question.
668  * \retval 0 Success
669  * \retval -1 Error, with errno set to an appropriate value
670  */
671 int ast_set_qos(int sockfd, int tos, int cos, const char *desc);
672
673 /*!
674  * These are backward compatibility functions that may be used by subsystems
675  * that have not yet been converted to IPv6. They will be removed when all
676  * subsystems are IPv6-ready.
677  */
678 /*@{*/
679
680 /*!
681  * \since 1.8
682  *
683  * \brief
684  * Converts a struct ast_sockaddr to a struct sockaddr_in.
685  *
686  * \param addr The ast_sockaddr to convert
687  * \param[out] sin The resulting sockaddr_in struct
688  * \retval nonzero Success
689  * \retval zero Failure
690  */
691 #define ast_sockaddr_to_sin(addr,sin)   _ast_sockaddr_to_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__)
692 int _ast_sockaddr_to_sin(const struct ast_sockaddr *addr,
693                         struct sockaddr_in *sin, const char *file, int line, const char *func);
694
695 /*!
696  * \since 1.8
697  *
698  * \brief Converts a struct sockaddr_in to a struct ast_sockaddr.
699  *
700  * \param addr
701  * \param sin The sockaddr_in to convert
702  * \return an ast_sockaddr structure
703  */
704 #define ast_sockaddr_from_sin(addr,sin) _ast_sockaddr_from_sin(addr,sin, __FILE__, __LINE__, __PRETTY_FUNCTION__)
705 void _ast_sockaddr_from_sin(struct ast_sockaddr *addr, const struct sockaddr_in *sin,
706                 const char *file, int line, const char *func);
707
708 /*@}*/
709
710 #if defined(__cplusplus) || defined(c_plusplus)
711 }
712 #endif
713
714 #endif /* _ASTERISK_NETSOCK2_H */