Re: [xml] ipv6 and gnome-xml

Date view Thread view Subject view Author view

From: Bjorn Reese (breese@mail1.stofanet.dk)
Date: Sat Dec 16 2000 - 08:15:55 EST


Daniel Veillard wrote:

> If you could provide a brief summary of the changes needed to both
> the URI parsing algorithms and possibly the changes needed when dealing
> with the socket interfaces, that would be really useful.

A little bit of juggling with the appropriate data structures
are needed for the socket interface.

Enabling IPv6 support in the DNS resolver requires a bit of a
hack, and probably doesn't work on Windows at all.

I have attached a patch for nanohttp.c (2-2.2.10), that does the
above. The patch is only meant as an example (or a starting point)
of how IPv6 can be added. Define the SUPPORT_IP6 macro if your
machine supports IPv6. I have not tested it, as I don't have IPv6
here, nor do I need it myself -- I just adapted some of my other
code.

For further information see RFC 2553 and section 9 in "Unix
Network Programming" (2nd edition) by Stevens.

*** libxml2-2.2.10/nanohttp.c Sat Nov 25 11:39:36 2000
--- libxml2-2.2.10-breese/nanohttp.c Sat Dec 16 13:55:25 2000
***************
*** 60,65 ****
--- 60,68 ----
  #ifdef HAVE_STRINGS_H
  #include <strings.h>
  #endif
+ #ifdef SUPPORT_IP6
+ #include <resolv.h>
+ #endif
  
  #ifdef VMS
  #include <stropts>
***************
*** 643,652 ****
   */
  
  static int
! xmlNanoHTTPConnectAttempt(struct in_addr ia, int port)
  {
      SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- struct sockaddr_in sin;
      fd_set wfd;
      struct timeval tv;
      int status;
--- 646,654 ----
   */
  
  static int
! xmlNanoHTTPConnectAttempt(struct sockaddr *addr, int port)
  {
      SOCKET s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
      fd_set wfd;
      struct timeval tv;
      int status;
***************
*** 692,702 ****
  #endif /* !_WINSOCKAPI_ */
  
  
! sin.sin_family = AF_INET;
! sin.sin_addr = ia;
! sin.sin_port = htons(port);
!
! if ((connect(s, (struct sockaddr *)&sin, sizeof(sin))==-1)) {
          switch (socket_errno()) {
              case EINPROGRESS:
              case EWOULDBLOCK:
--- 694,700 ----
  #endif /* !_WINSOCKAPI_ */
  
  
! if ((connect(s, addr, sizeof(*addr))==-1)) {
          switch (socket_errno()) {
              case EINPROGRESS:
              case EWOULDBLOCK:
***************
*** 764,772 ****
--- 762,782 ----
  xmlNanoHTTPConnectHost(const char *host, int port)
  {
      struct hostent *h;
+ struct sockaddr *addr;
+ struct in_addr ia;
+ struct sockaddr_in sin;
+ #ifdef SUPPORT_IP6
+ struct in6_addr ia6;
+ struct sockaddr_in6 sin6;
+ #endif
      int i;
      int s;
      
+ #if defined(SUPPORT_IP6) && defined(RES_USE_INET6)
+ if (!(_res.options & RES_INIT))
+ res_init();
+ _res.options |= RES_USE_INET6;
+ #endif
      h=gethostbyname(host);
      if (h==NULL)
      {
***************
*** 778,786 ****
      
      for(i=0; h->h_addr_list[i]; i++)
      {
! struct in_addr ia;
! memcpy(&ia, h->h_addr_list[i],4);
! s = xmlNanoHTTPConnectAttempt(ia, port);
          if (s != -1)
              return(s);
      }
--- 788,813 ----
      
      for(i=0; h->h_addr_list[i]; i++)
      {
! if (h->h_addrtype == AF_INET) {
! /* A records (IPv4) */
! memcpy(&ia, h->h_addr_list[i], h->h_length);
! sin.sin_family = h->h_addrtype;
! sin.sin_addr = ia;
! sin.sin_port = htons(port);
! addr = (struct sockaddr *)&sin;
! #ifdef SUPPORT_IP6
! } else if (h->h_addrtype == AF_INET6) {
! /* AAAA records (IPv6) */
! memcpy(&ia6, h->h_addr_list[i], h->h_length);
! sin6.sin_family = h->h_addrtype;
! sin6.sin_addr = ia6;
! sin6.sin_port = htons(port);
! addr = (struct sockaddr *)&sin6;
! #endif
! } else
! break; /* for */
!
! s = xmlNanoHTTPConnectAttempt(addr, port);
          if (s != -1)
              return(s);
      }

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sat Dec 16 2000 - 09:43:39 EST