Modify

Opened 6 years ago

Closed 5 years ago

#9092 closed enhancement (fixed)

native PING6 working again

Reported by: ßŋø Owned by: developers
Priority: normal Milestone: Backfire 10.03.1
Component: packages Version: Trunk
Keywords: ping6 iputils Cc:

Description

Native ping 6 again (remember ping6 ff02::1%br-lan ??),
needs functions not in uclibc, so dnstiny.h brings em up..
bin is 106k here..so if tracepath6 etc follow, dnstiny.h could become a
shlib

Signed off by: Benjamin Freitag <benjamin@…>

patch appended as file as well as cleartext
---

Index: feeds/packages/net/iputils/patches/004-ping6mod.patch
===================================================================
--- feeds/packages/net/iputils/patches/004-ping6mod.patch    (Revision 0)
+++ feeds/packages/net/iputils/patches/004-ping6mod.patch    (Revision 0)
@@ -0,0 +1,353 @@
+--- iputils-s20100418.old/dnstiny.h    1970-01-01 01:00:00.000000000 +0100
++++ iputils-s20100418/dnstiny.h    2011-03-14 23:29:40.000000000 +0100
+@@ -0,0 +1,338 @@
++#include <sys/types.h>
++#include <sys/param.h>
++#include <netinet/in.h>
++#include <arpa/nameser.h>
++#include <ctype.h>
++#include <resolv.h>
++#include <stdio.h>
++#include <string.h>
++// #include <unistd.h>
++// #include <netdb.h>
++
++
++static const char    digits[] = "0123456789";
++
++#define __set_errno(val) ((errno) = (val))
++
++/*
++     *      Thinking in noninternationalized USASCII (per the DNS spec),
++     *      convert this character to lower case if it's upper case.
++     */
++    static int
++    mklower(int ch) {
++            if (ch >= 0x41 && ch <= 0x5A)
++                    return (ch + 0x20);
++            return (ch);
++    }
++
++/*
++ * dn_find(domain, msg, dnptrs, lastdnptr)
++ *    Search for the counted-label name in an array of compressed names.
++ * return:
++ *    offset from msg if found, or -1.
++ * notes:
++ *    dnptrs is the pointer to the first name on the list,
++ *    not the pointer to the start of the message.
++ */
++static int
++dn_find(const u_char *domain, const u_char *msg,
++    const u_char * const *dnptrs,
++    const u_char * const *lastdnptr)
++{
++    const u_char *dn, *cp, *sp;
++    const u_char * const *cpp;
++    u_int n;
++
++    for (cpp = dnptrs; cpp < lastdnptr; cpp++) {
++        sp = *cpp;
++        /*
++         * terminate search on:
++         * root label
++         * compression pointer
++         * unusable offset
++         */
++        while (*sp != 0 && (*sp & NS_CMPRSFLGS) == 0 &&
++               (sp - msg) < 0x4000) {
++            dn = domain;
++            cp = sp;
++            while ((n = *cp++) != 0) {
++                /*
++                 * check for indirection
++                 */
++                switch (n & NS_CMPRSFLGS) {
++                case 0:        /* normal case, n == len */
++                    if (n != *dn++)
++                        goto next;
++                    for ((void)NULL; n > 0; n--)
++                        if (mklower(*dn++) !=
++                            mklower(*cp++))
++                            goto next;
++                    /* Is next root for both ? */
++                    if (*dn == '\0' && *cp == '\0')
++                        return (sp - msg);
++                    if (*dn)
++                        continue;
++                    goto next;
++
++                case NS_CMPRSFLGS:    /* indirection */
++                    cp = msg + (((n & 0x3f) << 8) | *cp);
++                    break;
++
++                default:    /* illegal type */
++                    __set_errno (EMSGSIZE);
++                    return (-1);
++                }
++            }
++ next:
++            sp += *sp + 1;
++        }
++    }
++    __set_errno (ENOENT);
++    return (-1);
++}
++
++/*
++ * ns_name_compress(src, dst, dstsiz, dnptrs, lastdnptr)
++ *    Compress a domain name into wire format, using compression pointers.
++ * return:
++ *    Number of bytes consumed in `dst' or -1 (with errno set).
++ * notes:
++ *    'dnptrs' is an array of pointers to previous compressed names.
++ *    dnptrs[0] is a pointer to the beginning of the message.
++ *    The list ends with NULL.  'lastdnptr' is a pointer to the end of the
++ *    array pointed to by 'dnptrs'. Side effect is to update the list of
++ *    pointers for labels inserted into the message as we compress the
name.
++ *    If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
++ *    is NULL, we don't update the list.
++ */
++int ns_name_compress(const char *src, u_char *dst, size_t dstsiz,
++         const u_char **dnptrs, const u_char **lastdnptr)
++{
++    u_char tmp[NS_MAXCDNAME];
++
++    if (ns_name_pton(src, tmp, sizeof tmp) == -1)
++        return (-1);
++    return (ns_name_pack(tmp, dst, dstsiz, dnptrs, lastdnptr));
++}
++
++
++int
++dn_comp(const char *src, u_char *dst, int dstsiz,
++        u_char **dnptrs, u_char **lastdnptr)
++{
++        return (ns_name_compress(src, dst, (size_t)dstsiz,
++                                 (const u_char **)dnptrs,
++                                 (const u_char **)lastdnptr));
++}
++
++/*
++ * ns_name_pack(src, dst, dstsiz, dnptrs, lastdnptr)
++ *    Pack domain name 'domain' into 'comp_dn'.
++ * return:
++ *    Size of the compressed name, or -1.
++ * notes:
++ *    'dnptrs' is an array of pointers to previous compressed names.
++ *    dnptrs[0] is a pointer to the beginning of the message. The array
++ *    ends with NULL.
++ *    'lastdnptr' is a pointer to the end of the array pointed to
++ *    by 'dnptrs'.
++ * Side effects:
++ *    The list of pointers in dnptrs is updated for labels inserted into
++ *    the message as we compress the name.  If 'dnptr' is NULL, we don't
++ *    try to compress names. If 'lastdnptr' is NULL, we don't update the
++ *    list.
++ */
++int
++ns_name_pack(const u_char *src, u_char *dst, int dstsiz,
++         const u_char **dnptrs, const u_char **lastdnptr)
++{
++    u_char *dstp;
++    const u_char **cpp, **lpp, *eob, *msg;
++    const u_char *srcp;
++    int n, l, first = 1;
++
++    srcp = src;
++    dstp = dst;
++    eob = dstp + dstsiz;
++    lpp = cpp = NULL;
++    if (dnptrs != NULL) {
++        if ((msg = *dnptrs++) != NULL) {
++            for (cpp = dnptrs; *cpp != NULL; cpp++)
++                (void)NULL;
++            lpp = cpp;    /* end of list to search */
++        }
++    } else
++        msg = NULL;
++
++    /* make sure the domain we are about to add is legal */
++    l = 0;
++    do {
++        n = *srcp;
++        if ((n & NS_CMPRSFLGS) != 0) {
++            __set_errno (EMSGSIZE);
++            return (-1);
++        }
++        l += n + 1;
++        if (l > MAXCDNAME) {
++            __set_errno (EMSGSIZE);
++            return (-1);
++        }
++        srcp += n + 1;
++    } while (n != 0);
++
++    /* from here on we need to reset compression pointer array on error */
++    srcp = src;
++    do {
++        /* Look to see if we can use pointers. */
++        n = *srcp;
++        if (n != 0 && msg != NULL) {
++            l = dn_find(srcp, msg, (const u_char * const *)dnptrs,
++                    (const u_char * const *)lpp);
++            if (l >= 0) {
++                if (dstp + 1 >= eob) {
++                    goto cleanup;
++                }
++                *dstp++ = (l >> 8) | NS_CMPRSFLGS;
++                *dstp++ = l % 256;
++                return (dstp - dst);
++            }
++            /* Not found, save it. */
++            if (lastdnptr != NULL && cpp < lastdnptr - 1 &&
++                (dstp - msg) < 0x4000 && first) {
++                *cpp++ = dstp;
++                *cpp = NULL;
++                first = 0;
++            }
++        }
++        /* copy label to buffer */
++        if (n & NS_CMPRSFLGS) {        /* Should not happen. */
++            goto cleanup;
++        }
++        if (dstp + 1 + n >= eob) {
++            goto cleanup;
++        }
++        memcpy(dstp, srcp, n + 1);
++        srcp += n + 1;
++        dstp += n + 1;
++    } while (n != 0);
++
++    if (dstp > eob) {
++cleanup:
++        if (msg != NULL)
++            *lpp = NULL;
++        __set_errno (EMSGSIZE);
++        return (-1);
++    }
++    return (dstp - dst);
++}
++
++/*
++ * ns_name_pton(src, dst, dstsiz)
++ *    Convert a ascii string into an encoded domain name as per RFC1035.
++ * return:
++ *    -1 if it fails
++ *    1 if string was fully qualified
++ *    0 is string was not fully qualified
++ * notes:
++ *    Enforces label and domain length limits.
++ */
++
++int
++ns_name_pton(const char *src, u_char *dst, size_t dstsiz) {
++    u_char *label, *bp, *eom;
++    int c, n, escaped;
++    char *cp;
++
++    escaped = 0;
++    bp = dst;
++    eom = dst + dstsiz;
++    label = bp++;
++
++    while ((c = *src++) != 0) {
++        if (escaped) {
++            if ((cp = strchr(digits, c)) != NULL) {
++                n = (cp - digits) * 100;
++                if ((c = *src++) == 0 ||
++                    (cp = strchr(digits, c)) == NULL) {
++                    __set_errno (EMSGSIZE);
++                    return (-1);
++                }
++                n += (cp - digits) * 10;
++                if ((c = *src++) == 0 ||
++                    (cp = strchr(digits, c)) == NULL) {
++                    __set_errno (EMSGSIZE);
++                    return (-1);
++                }
++                n += (cp - digits);
++                if (n > 255) {
++                    __set_errno (EMSGSIZE);
++                    return (-1);
++                }
++                c = n;
++            }
++            escaped = 0;
++        } else if (c == '\\') {
++            escaped = 1;
++            continue;
++        } else if (c == '.') {
++            c = (bp - label - 1);
++            if ((c & NS_CMPRSFLGS) != 0) {    /* Label too big. */
++                __set_errno (EMSGSIZE);
++                return (-1);
++            }
++            if (label >= eom) {
++                __set_errno (EMSGSIZE);
++                return (-1);
++            }
++            *label = c;
++            /* Fully qualified ? */
++            if (*src == '\0') {
++                if (c != 0) {
++                    if (bp >= eom) {
++                        __set_errno (EMSGSIZE);
++                        return (-1);
++                    }
++                    *bp++ = '\0';
++                }
++                if ((bp - dst) > MAXCDNAME) {
++                    __set_errno (EMSGSIZE);
++                    return (-1);
++                }
++                return (1);
++            }
++            if (c == 0 || *src == '.') {
++                __set_errno (EMSGSIZE);
++                return (-1);
++            }
++            label = bp++;
++            continue;
++        }
++        if (bp >= eom) {
++            __set_errno (EMSGSIZE);
++            return (-1);
++        }
++        *bp++ = (u_char)c;
++    }
++    c = (bp - label - 1);
++    if ((c & NS_CMPRSFLGS) != 0) {        /* Label too big. */
++        __set_errno (EMSGSIZE);
++        return (-1);
++    }
++    if (label >= eom) {
++        __set_errno (EMSGSIZE);
++        return (-1);
++    }
++    *label = c;
++    if (c != 0) {
++        if (bp >= eom) {
++            __set_errno (EMSGSIZE);
++            return (-1);
++        }
++        *bp++ = 0;
++    }
++    if ((bp - dst) > MAXCDNAME) {    /* src too big */
++        __set_errno (EMSGSIZE);
++        return (-1);
++    }
++    return (0);
++}
+diff -urN iputils-s20100418/ping6.c iputils-s20100418.gehtdoch/ping6.c
+--- iputils-s20100418/ping6.c    2010-04-18 06:45:45.000000000 +0200
++++ iputils-s20100418.gehtdoch/ping6.c    2011-03-14 23:29:27.000000000
+0100
+@@ -67,7 +67,7 @@
+  *    This program has to run SUID to ROOT to access the ICMP socket.
+  */
+ #include "ping_common.h"
+-
++#include "dnstiny.h"
+ #include <linux/filter.h>
+ #include <netinet/ip6.h>
+ #include <netinet/icmp6.h>
Index: feeds/packages/net/iputils/Makefile
===================================================================
--- feeds/packages/net/iputils/Makefile    (Revision 26169)
+++ feeds/packages/net/iputils/Makefile    (Arbeitskopie)
@@ -20,6 +20,7 @@
 
 include $(INCLUDE_DIR)/package.mk
 
+MAKE_FLAGS += CONFIG_IPV6="$(CONFIG_IPV6)"
 
 define Package/iputils/Default
   SECTION:=net
@@ -66,7 +67,7 @@
 define Package/iputils-ping6
 $(call Package/iputils/Default)
   TITLE:=iputils - ping6
-  DEPENDS+= @IPV6 @BROKEN
+  DEPENDS+= @IPV6
 endef
 
 define Package/iputils-ping6/description
@@ -170,6 +171,6 @@
 $(eval $(call BuildPackage,iputils-ping))
 $(eval $(call BuildPackage,iputils-tftpd))
 $(eval $(call BuildPackage,iputils-tracepath))
-#$(eval $(call BuildPackage,iputils-ping6))
+$(eval $(call BuildPackage,iputils-ping6))
 #$(eval $(call BuildPackage,iputils-tracepath6))
 #$(eval $(call BuildPackage,iputils-traceroute6))

Attachments (1)

iputils-ping6patch.svn (10.1 KB) - added by ß ŋø 6 years ago.
svn diff of native ping6 changes in backfire

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by ß ŋø

svn diff of native ping6 changes in backfire

comment:1 Changed 5 years ago by jogo

  • Resolution set to fixed
  • Status changed from new to closed

Iputils was fixed in r26994 and r27108 and ping6 is available again.

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.