[FFmpeg-devel] [PATCH] ipv6-compatible resolve_host() replacement

Michael Niedermayer michaelni
Sat Sep 29 01:46:00 CEST 2007


Hi

On Fri, Sep 28, 2007 at 08:45:20AM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On 9/23/07, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> >
> > See $subj:
> > - add a new API to replace the (now deprecated) resolve_host(), which I
> > call AVInetAddr / inetaddr_*()
> > - convert tcp.c (easiest proof-of-concept, only a few lines of code) to
> > use it
> > - deprecate (but not remove) resolve_host()
> >
> > this is about the simplest patch I can give you to implement ipv6 support.
> > udp.c / ffserver.c / rtsp.c follow later, followed by removal of
> > resolve_host() (and probably also making inet_aton() private to os_support.c
> > instead of exporting it in avformat.h; all should use inetaddr_parse/str()
> > now).
> 
> 
> Attached is a slightly modified version that takes comments from Luca /
> Benoit into account (or: ping :-) ).
> 
> Ronald

> Index: os_support.c
> ===================================================================
> --- os_support.c	(revision 9789)
> +++ os_support.c	(working copy)
> @@ -21,6 +21,7 @@
>   */
>  #include "config.h"
>  #include "avformat.h"
> +#include "avstring.h"
>  #include <unistd.h>
>  #include <fcntl.h>
>  
> @@ -34,6 +35,7 @@
>  
>  #ifdef CONFIG_NETWORK
>  #include "network.h"
> +#include <sys/socket.h>
>  
>  #if !defined(HAVE_INET_ATON)
>  #include <stdlib.h>
> @@ -68,6 +70,164 @@
>      return 0;
>  }
>  
> +/* resolve host with also IP address parsing */
> +int inetaddr_resolve(AVInetAddr **in_addr, int port, int passive,

not doxygen compatible

[...]

> +struct sockaddr;
> +typedef struct AVInetAddr AVInetAddr;
> +/**
> + * Structure containing internet hostname lookup data in a way that
> + * can be used to create sockets for use with connect().
> + */
> +struct AVInetAddr {
> +    int family, socket_type, protocol, port, addr_len;
> +    struct sockaddr *addr;
> +    AVInetAddr *next;
> +};
> +
> +/**
> + * Resolve a host, includes parsing of numeric hosts. Supports both
> + * IPv4 and IPv6 (if the OS supports it).
> + *
> + * @param in_addr pointer where the filled-in (and newly allocated)
> + *                list of addresses that the hostname resolved to will
> + *                be placed after a successful call to this function.
> + *                Should be free'ed with av_free() after use.
> + * @param port the port number that will be connected to.
> + * @param passive 1 if the port will be used to bind() to, else 0.
> + * @param socket_stream 1 if the returned address will be used for a
> + *                      TCP/IP stream-based connection, 0 for others.
> + * @param parse_only 1 if we should only parse numeric IPv4/6 host
> + *                   addresses without resolving it using a name server.
> + * @param hostname the hostname (or numeric IPv4/6 string) to be parsed
> + *                 or looked up.
> + * return 0 on success, an error code otherwise.
> + */
> +int inetaddr_resolve(AVInetAddr **in_addr, int port, int passive,
> +                     int socket_stream, int parse_only, const char *hostname);

this does NOT belong in a public header of libavformat
libavformat is for (de)muxing not for resolving hosts

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070929/0252f72b/attachment.pgp>



More information about the ffmpeg-devel mailing list