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

Benoit Fouet benoit.fouet
Mon Sep 24 09:42:25 CEST 2007


Ronald S. Bultje wrote:
> Hi,
>
> 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).
>
>   

>Index: os_support.c
>===================================================================
>--- os_support.c    (revision 9789)
>+++ os_support.c    (working copy)
>@@ -58,16 +60,175 @@
> int resolve_host(struct in_addr *sin_addr, const char *hostname)
> {
>     struct hostent *hp;
>-
>-    if (!inet_aton(hostname, sin_addr)) {
>+
>+    if (!inet_aton(hostname, sin_addr)) {
>         hp = gethostbyname(hostname);
>         if (!hp)
>             return -1;
>-        memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr));
>+        memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr));
>     }

oops ? :)

>     return 0;
> }
>
>+/* resolve host with also IP address parsing */
>+int inetaddr_resolve(AVInetAddr **in_addr, int port, int passive,
>+                     int socket_stream, int parse_only, const char
*hostname)
>+{
>+    AVInetAddr *addr, *addri;
>+#ifdef CONFIG_IPV6
>+    struct addrinfo *resl, *res, hints;

hints = {0};

>+    int err, num = 0, size = 0;
>+    char sport[16];
>+    char *ptr;
>+
>+    memset(&hints, 0, sizeof(hints));

can be removed

-- 
Ben
Purple Labs S.A.
www.purplelabs.com




More information about the ffmpeg-devel mailing list