Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From a1ef10d63b0ea34c788d5432e94c72b00ae55e04 Mon Sep 17 00:00:00 2001 |
| 2 | From: Joe MacDonald <joe_macdonald@mentor.com> |
| 3 | Date: Fri, 27 Feb 2015 12:04:10 -0500 |
| 4 | Subject: [PATCH] ipv4/ipv6: Provide an in-place version of mapv4v6addr.h |
| 5 | |
| 6 | mapv4v6addr.h isn't always available, depending on your build, but |
| 7 | nis-hosts.c only needs it for a single, inline function. So drop a copy |
| 8 | here rather than playing games with the include path that would |
| 9 | potentially lead to cross-compilation issues. |
| 10 | |
| 11 | Upstream-status: Inappropriate [embedded specific] |
| 12 | |
| 13 | Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com> |
| 14 | --- |
| 15 | nss_nis6/mapv4v6addr.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++ |
| 16 | nss_nis6/nis-hosts.c | 2 +- |
| 17 | 2 files changed, 70 insertions(+), 1 deletion(-) |
| 18 | create mode 100644 nss_nis6/mapv4v6addr.h |
| 19 | |
| 20 | diff --git a/nss_nis6/mapv4v6addr.h b/nss_nis6/mapv4v6addr.h |
| 21 | new file mode 100644 |
| 22 | index 0000000..7f85f7d |
| 23 | --- /dev/null |
| 24 | +++ b/nss_nis6/mapv4v6addr.h |
| 25 | @@ -0,0 +1,69 @@ |
| 26 | +/* |
| 27 | + * ++Copyright++ 1985, 1988, 1993 |
| 28 | + * - |
| 29 | + * Copyright (c) 1985, 1988, 1993 |
| 30 | + * The Regents of the University of California. All rights reserved. |
| 31 | + * |
| 32 | + * Redistribution and use in source and binary forms, with or without |
| 33 | + * modification, are permitted provided that the following conditions |
| 34 | + * are met: |
| 35 | + * 1. Redistributions of source code must retain the above copyright |
| 36 | + * notice, this list of conditions and the following disclaimer. |
| 37 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 38 | + * notice, this list of conditions and the following disclaimer in the |
| 39 | + * documentation and/or other materials provided with the distribution. |
| 40 | + * 4. Neither the name of the University nor the names of its contributors |
| 41 | + * may be used to endorse or promote products derived from this software |
| 42 | + * without specific prior written permission. |
| 43 | + * |
| 44 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 45 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 46 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 47 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 48 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 49 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 50 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 51 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 52 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 53 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 54 | + * SUCH DAMAGE. |
| 55 | + * - |
| 56 | + * Portions Copyright (c) 1993 by Digital Equipment Corporation. |
| 57 | + * |
| 58 | + * Permission to use, copy, modify, and distribute this software for any |
| 59 | + * purpose with or without fee is hereby granted, provided that the above |
| 60 | + * copyright notice and this permission notice appear in all copies, and that |
| 61 | + * the name of Digital Equipment Corporation not be used in advertising or |
| 62 | + * publicity pertaining to distribution of the document or software without |
| 63 | + * specific, written prior permission. |
| 64 | + * |
| 65 | + * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL |
| 66 | + * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES |
| 67 | + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT |
| 68 | + * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 69 | + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
| 70 | + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS |
| 71 | + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
| 72 | + * SOFTWARE. |
| 73 | + * - |
| 74 | + * --Copyright-- |
| 75 | + */ |
| 76 | + |
| 77 | +#include <string.h> |
| 78 | +#include <arpa/nameser.h> |
| 79 | + |
| 80 | +static void |
| 81 | +map_v4v6_address (const char *src, char *dst) |
| 82 | +{ |
| 83 | + u_char *p = (u_char *) dst; |
| 84 | + int i; |
| 85 | + |
| 86 | + /* Move the IPv4 part to the right position. */ |
| 87 | + memcpy (dst + 12, src, INADDRSZ); |
| 88 | + |
| 89 | + /* Mark this ipv6 addr as a mapped ipv4. */ |
| 90 | + for (i = 0; i < 10; i++) |
| 91 | + *p++ = 0x00; |
| 92 | + *p++ = 0xff; |
| 93 | + *p = 0xff; |
| 94 | +} |
| 95 | diff --git a/nss_nis6/nis-hosts.c b/nss_nis6/nis-hosts.c |
| 96 | index af99c74..96d8fa1 100644 |
| 97 | --- a/nss_nis6/nis-hosts.c |
| 98 | +++ b/nss_nis6/nis-hosts.c |
| 99 | @@ -36,7 +36,7 @@ |
| 100 | #include "nss-nis6.h" |
| 101 | |
| 102 | /* Get implementation for some internal functions. */ |
| 103 | -#include <resolv/mapv4v6addr.h> |
| 104 | +#include "mapv4v6addr.h" |
| 105 | |
| 106 | #define ENTNAME hostent |
| 107 | #define DATABASE "hosts" |
| 108 | -- |
| 109 | 1.9.1 |
| 110 | |