source: freewrt/package/aiccu/extra/common/dn_skipname.c@ 621d5d2

freewrt_2_0
Last change on this file since 621d5d2 was 3422ee7, checked in by Waldemar Brodkorb <wbx@…>, 19 years ago

update aiccu, reqested by markus thiesen, older versions does not work anymore with SIXXS

git-svn-id: svn://www.freewrt.org/branches/freewrt_1_0@1830 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 950 bytes
RevLine 
[3422ee7]1#include <errno.h>
2#include <resolv.h>
3
4/* Ripped from glibc 2.4 sources. */
5
6/*
7 * ns_name_skip(ptrptr, eom)
8 * Advance *ptrptr to skip over the compressed name it points at.
9 * return:
10 * 0 on success, -1 (with errno set) on failure.
11 */
12int ns_name_skip(const u_char **ptrptr, const u_char *eom)
13{
14 const u_char *cp;
15 u_int n;
16
17 cp = *ptrptr;
18 while (cp < eom && (n = *cp++) != 0)
19 {
20 /* Check for indirection. */
21 switch (n & NS_CMPRSFLGS) {
22 case 0: /* normal case, n == len */
23 cp += n;
24 continue;
25 case NS_CMPRSFLGS: /* indirection */
26 cp++;
27 break;
28 default: /* illegal type */
29 errno = EMSGSIZE;
30 return (-1);
31 }
32 break;
33 }
34 if (cp > eom)
35 {
36 errno = EMSGSIZE;
37 return (-1);
38 }
39 *ptrptr = cp;
40 return (0);
41}
42
43int dn_skipname(const u_char *ptr, const u_char *eom)
44{
45 const u_char *saveptr = ptr;
46
47 if(ns_name_skip(&ptr, eom) == -1)
48 return (-1);
49 return (ptr - saveptr);
50}
51
Note: See TracBrowser for help on using the repository browser.