2 * initialize address structure
3 * Copyright (C) 2000 Henry Spencer.
5 * This library is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Library General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/lgpl.txt>.
10 * This library is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 * License for more details.
15 * RCSID $Id: initaddr.c,v 1.2 2000/08/25 14:40:05 henry Exp $
21 - initaddr - initialize ip_address from bytes
23 err_t /* NULL for success, else string literal */
24 initaddr(src, srclen, af, dst)
25 const unsigned char *src;
27 int af; /* address family */
33 return "IPv4 address must be exactly 4 bytes";
34 dst->u.v4.sin_family = af;
35 dst->u.v4.sin_port = 0; /* unused */
36 memcpy((char *)&dst->u.v4.sin_addr.s_addr, src, srclen);
40 return "IPv6 address must be exactly 16 bytes";
41 dst->u.v6.sin6_family = af;
42 dst->u.v6.sin6_flowinfo = 0; /* unused */
43 dst->u.v6.sin6_port = 0; /* unused */
44 memcpy((char *)&dst->u.v6.sin6_addr, src, srclen);
47 return "unknown address family in initaddr";