--------------------- PatchSet 4217 Date: 2007/04/10 10:45:33 Author: amosjeffries Branch: squid3-ipv6 Tag: (none) Log: complete missing driver section code. Members: lib/rfc3596.c:1.1.2.1->1.1.2.2 Index: squid3/lib/rfc3596.c =================================================================== RCS file: /cvsroot/squid-sf//squid3/lib/Attic/rfc3596.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid3/lib/rfc3596.c 10 Apr 2007 10:16:31 -0000 1.1.2.1 +++ squid3/lib/rfc3596.c 10 Apr 2007 10:45:33 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: rfc3596.c,v 1.1.2.1 2007/04/10 10:16:31 amosjeffries Exp $ + * $Id: rfc3596.c,v 1.1.2.2 2007/04/10 10:45:33 amosjeffries Exp $ * * Low level DNS protocol routines * AUTHOR: Amos Jeffries, Rafael Martinez Torres @@ -228,7 +228,7 @@ char buf[512]; char rbuf[512]; size_t sz = 512; - unsigned short sid; + unsigned short sid, sidb; int s; int rl; @@ -267,24 +267,26 @@ memset(&S, '\0', sizeof(S)); if(prefer == 6) { - S.sin6_family = AF_INET6; - S.sin6_port = htons(atoi(argv[2])); + S = (struct sockaddr *) new sockaddr_in6; + memset(S,0,sizeof(struct sockaddr_in6)); - if( strchr(argv[1], ':') ) - inet_pton(AF_INET6, argv[1], &S.sin6_addr.s_addr ); - else { + ((struct sockaddr_in6 *)S)->sin6_family = AF_INET6; + ((struct sockaddr_in6 *)S)->sin6_port = htons(atoi(argv[var+1])); + + if( ! inet_pton(AF_INET6, argv[var], &((struct sockaddr_in6 *)S)->sin6_addr.s_addr) ) perror("listen address"); return 1; } s = socket(PF_INET6, SOCK_DGRAM, 0); } else { - S.sin_family = AF_INET; - S.sin_port = htons(atoi(argv[2])); + S = (struct sockaddr *) new sockaddr_in; + memset(S,0,sizeof(struct sockaddr_in)); - if( ! strchr(argv[1], ':') ) - S.sin_addr.s_addr = inet_addr(argv[1]); - else { + ((struct sockaddr_in *)S)->sin_family = AF_INET; + ((struct sockaddr_in *)S)->sin_port = htons(atoi(argv[var+1])); + + if( ! inet_pton(AF_INET, argv[var], &((struct sockaddr_in *)S)->sin_addr.s_addr) ) perror("listen address"); return 1; } @@ -301,11 +303,13 @@ if (inet_pton(AF_INET6, input, &junk6)) { sid = rfc1035BuildPTRQuery6(junk6, buf, &sz); + sidb=0; } else if (inet_pton(AF_INET, input, &junk4)) { sid = rfc1035BuildPTRQuery4(junk4, buf, &sz); + sidb=0; } else { - sid = rfc1035BuildAQuery(input, buf, &sz); sid = rfc1035BuildAAAAQuery(input, buf, &sz); + sidb = rfc1035BuildAQuery(input, buf, &sz); } sendto(s, buf, sz, 0, S, sizeof(*S)); @@ -340,8 +344,9 @@ if (n < 0) { printf("ERROR %d\n", rfc1035_errno); - } else if (rid != sid) { + } else if (rid != sid && rid != sidb) { printf("ERROR, ID mismatch (%#hx, %#hx)\n", sid, rid); + printf("ERROR, ID mismatch (%#hx, %#hx)\n", sidb, rid); } else { printf("%d answers\n", n);