sipcalc/sipcalc.patch

Mon, 28 Jan 2013 17:37:18 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 28 Jan 2013 17:37:18 +0100
changeset 758
a2c6460cfb16
permissions
-rw-r--r--

Correct socket error reporting improvement with IPv6 portable code,
after helpful recommendation by Saúl Ibarra Corretgé on OSips devlist.

michael@700 1 --- src/sub-func.c.orig 2003-03-19 13:28:15.000000000 +0100
michael@700 2 +++ src/sub-func.c 2003-07-28 10:35:53.000000000 +0200
michael@700 3 @@ -1267,7 +1267,7 @@
michael@700 4 }
michael@700 5 #endif
michael@700 6
michael@700 7 -#if defined(HAVE_GETHOSTBYNAME2) && defined(HAVE_INET_NTOP)
michael@700 8 +#if defined(HAVE_GETHOSTBYNAME2) && defined(HAVE_INET_NTOP) && defined(AF_INET6)
michael@700 9 char *
michael@700 10 _resolv_v6_ghbn2 (char *raddr, struct dnsresp *d_resp, char *extra)
michael@700 11 {
michael@700 12 @@ -1308,7 +1308,7 @@
michael@700 13 }
michael@700 14 #endif
michael@700 15
michael@700 16 -#if defined(HAVE_GETADDRINFO) && defined(HAVE_INET_NTOP)
michael@700 17 +#if defined(HAVE_GETADDRINFO) && defined(HAVE_INET_NTOP) && defined(AF_INET6)
michael@700 18 char *
michael@700 19 _resolv_v6_gai (char *raddr, struct dnsresp *d_resp, char *extra)
michael@700 20 {
michael@700 21 @@ -1393,13 +1393,19 @@
michael@700 22 snprintf(d_resp->str, 127, "%s%s", inet_ntoa (sin->sin_addr), extra);
michael@700 23 d_resp->type = AF_INET;
michael@700 24 }
michael@700 25 +#ifdef AF_INET6
michael@700 26 if (res->ai_family == PF_INET6) {
michael@700 27 sin6 = (struct sockaddr_in6 *) res->ai_addr;
michael@700 28 snprintf (retaddr, 1023, "%s%s", inet_ntop (AF_INET6, &sin6->sin6_addr, ip6addr, 128), extra);
michael@700 29 snprintf (d_resp->str, 127, "%s%s", inet_ntop (AF_INET6, &sin6->sin6_addr, ip6addr, 128), extra);
michael@700 30 d_resp->type = AF_INET6;
michael@700 31 }
michael@700 32 +#endif
michael@700 33 +#ifdef AF_INET6
michael@700 34 if (res->ai_next && (res->ai_family == PF_INET || res->ai_family == PF_INET6))
michael@700 35 +#else
michael@700 36 + if (res->ai_next && res->ai_family == PF_INET)
michael@700 37 +#endif
michael@700 38 d_resp = new_dnsresp (d_resp);
michael@700 39 res = res->ai_next;
michael@700 40 }
michael@700 41 @@ -1460,14 +1466,20 @@
michael@700 42 if ((f_gethostbyname2 || f_getaddrinfo) && f_inet_ntop)
michael@700 43 ipv6_cap = 1;
michael@700 44
michael@700 45 +#ifdef AF_INET6
michael@700 46 if (family != PF_INET && family != PF_INET6 && family != PF_UNSPEC)
michael@700 47 +#else
michael@700 48 + if (family != PF_INET && family != PF_UNSPEC)
michael@700 49 +#endif
michael@700 50 return NULL;
michael@700 51
michael@700 52 if (family == PF_INET && !ipv4_cap)
michael@700 53 return NULL;
michael@700 54
michael@700 55 +#ifdef AF_INET6
michael@700 56 if (family == PF_INET6 && !ipv6_cap)
michael@700 57 return NULL;
michael@700 58 +#endif
michael@700 59
michael@700 60 if (family == PF_UNSPEC && (!ipv4_cap && !ipv6_cap))
michael@700 61 return NULL;
michael@700 62 @@ -1475,8 +1487,10 @@
michael@700 63 if (strlen (addr) > 1023)
michael@700 64 return NULL;
michael@700 65
michael@700 66 +#ifdef AF_INET6
michael@700 67 if (family == PF_UNSPEC && !ipv4_cap)
michael@700 68 family = PF_INET6;
michael@700 69 +#endif
michael@700 70
michael@700 71 if (family == PF_UNSPEC && !ipv6_cap)
michael@700 72 family = PF_INET;
michael@700 73 @@ -1508,6 +1522,7 @@
michael@700 74 return retaddr;
michael@700 75 }
michael@700 76
michael@700 77 +#ifdef AF_INET6
michael@700 78 if (family == PF_INET6) {
michael@700 79 if (f_getaddrinfo) {
michael@700 80 tmpstr = _resolv_v6_gai (raddr, d_resp, extra);
michael@700 81 @@ -1525,6 +1540,7 @@
michael@700 82 return retaddr;
michael@700 83 }
michael@700 84 }
michael@700 85 +#endif
michael@700 86
michael@700 87 if (family == PF_UNSPEC) {
michael@700 88 if (f_getaddrinfo) {
michael@700 89 --- src/sub.c.orig 2003-03-19 13:28:16.000000000 +0100
michael@700 90 +++ src/sub.c 2003-07-28 10:37:10.000000000 +0200
michael@700 91 @@ -496,6 +496,7 @@
michael@700 92 ifarg_cur->type = IFT_V6;
michael@700 93 }
michael@700 94
michael@700 95 +#if AF_INET6
michael@700 96 if (abox->type == AT_V6 && abox->resolv) {
michael@700 97 d_resp_start = d_resp_cur = (struct dnsresp *) malloc (sizeof (struct dnsresp));
michael@700 98 d_resp_start->next = NULL;
michael@700 99 @@ -526,6 +527,7 @@
michael@700 100
michael@700 101 free_dnsresp (d_resp_start);
michael@700 102 }
michael@700 103 +#endif
michael@700 104
michael@700 105 if (abox->type == AT_INT) {
michael@700 106 if_cur = if_start;
michael@700 107 @@ -585,12 +587,14 @@
michael@700 108 d_resp_cur = d_resp_start;
michael@700 109 while (d_resp_cur) {
michael@700 110 strncpy (ifarg_cur->cmdstr, abox->str, 127);
michael@700 111 +#if AF_INET6
michael@700 112 if (d_resp_cur->type == AF_INET6) {
michael@700 113 strncpy (ifarg_cur->p_v6addr, d_resp_cur->str, 43);
michael@700 114 ifarg_cur->type = IFT_V6;
michael@700 115
michael@700 116 mk_ipv6addr (&ifarg_cur->v6ad, ifarg_cur->p_v6addr);
michael@700 117 }
michael@700 118 +#endif
michael@700 119 if (d_resp_cur->type == AF_INET) {
michael@700 120 tmpstr = strstr (d_resp_cur->str, " ");
michael@700 121 if (tmpstr != NULL && (strlen (tmpstr) > 0)) {

mercurial