Back to index

glibc  2.9
mapv4v6addr.h
Go to the documentation of this file.
00001 /*
00002  * ++Copyright++ 1985, 1988, 1993
00003  * -
00004  * Copyright (c) 1985, 1988, 1993
00005  *    The Regents of the University of California.  All rights reserved.
00006  *
00007  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  * 1. Redistributions of source code must retain the above copyright
00011  *    notice, this list of conditions and the following disclaimer.
00012  * 2. Redistributions in binary form must reproduce the above copyright
00013  *    notice, this list of conditions and the following disclaimer in the
00014  *    documentation and/or other materials provided with the distribution.
00015  * 4. Neither the name of the University nor the names of its contributors
00016  *    may be used to endorse or promote products derived from this software
00017  *    without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00020  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00023  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00024  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00025  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00026  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00027  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00028  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00029  * SUCH DAMAGE.
00030  * -
00031  * Portions Copyright (c) 1993 by Digital Equipment Corporation.
00032  *
00033  * Permission to use, copy, modify, and distribute this software for any
00034  * purpose with or without fee is hereby granted, provided that the above
00035  * copyright notice and this permission notice appear in all copies, and that
00036  * the name of Digital Equipment Corporation not be used in advertising or
00037  * publicity pertaining to distribution of the document or software without
00038  * specific, written prior permission.
00039  *
00040  * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
00041  * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
00042  * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
00043  * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
00044  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
00045  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
00046  * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
00047  * SOFTWARE.
00048  * -
00049  * --Copyright--
00050  */
00051 
00052 #include <string.h>
00053 #include <arpa/nameser.h>
00054 
00055 static void
00056 map_v4v6_address (const char *src, char *dst)
00057 {
00058   u_char *p = (u_char *) dst;
00059   int i;
00060 
00061   /* Move the IPv4 part to the right position.  */
00062   memcpy (dst + 12, src, INADDRSZ);
00063 
00064   /* Mark this ipv6 addr as a mapped ipv4. */
00065   for (i = 0; i < 10; i++)
00066     *p++ = 0x00;
00067   *p++ = 0xff;
00068   *p = 0xff;
00069 }