Blame


1 92ddd9f6 2022-10-30 thomas /*
2 92ddd9f6 2022-10-30 thomas * Copyright (c) 2022 Thomas Adam <thomas@xteddy.org>
3 92ddd9f6 2022-10-30 thomas *
4 92ddd9f6 2022-10-30 thomas * Permission to use, copy, modify, and distribute this software for any
5 92ddd9f6 2022-10-30 thomas * purpose with or without fee is hereby granted, provided that the above
6 92ddd9f6 2022-10-30 thomas * copyright notice and this permission notice appear in all copies.
7 92ddd9f6 2022-10-30 thomas *
8 92ddd9f6 2022-10-30 thomas * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 92ddd9f6 2022-10-30 thomas * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 92ddd9f6 2022-10-30 thomas * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 92ddd9f6 2022-10-30 thomas * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 92ddd9f6 2022-10-30 thomas * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 92ddd9f6 2022-10-30 thomas * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 92ddd9f6 2022-10-30 thomas * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 92ddd9f6 2022-10-30 thomas */
16 8f795179 2022-08-06 thomas
17 8f795179 2022-08-06 thomas #include <sys/socket.h>
18 8f795179 2022-08-06 thomas #include <netinet/in.h>
19 8f795179 2022-08-06 thomas
20 8f795179 2022-08-06 thomas #include <string.h>
21 8f795179 2022-08-06 thomas
22 8f795179 2022-08-06 thomas #include "got_sockaddr.h"
23 8f795179 2022-08-06 thomas
24 8f795179 2022-08-06 thomas /* These calls are found in lib/socketaddr.c, but are overriden here for
25 8f795179 2022-08-06 thomas * platform-specific reasons.
26 8f795179 2022-08-06 thomas */
27 8f795179 2022-08-06 thomas
28 8f795179 2022-08-06 thomas void
29 8f795179 2022-08-06 thomas got_sockaddr_inet_init(struct sockaddr_in *in, struct in_addr *ina)
30 8f795179 2022-08-06 thomas {
31 8f795179 2022-08-06 thomas in->sin_family = AF_INET;
32 8f795179 2022-08-06 thomas in->sin_addr.s_addr = ina->s_addr;
33 8f795179 2022-08-06 thomas }
34 8f795179 2022-08-06 thomas
35 8f795179 2022-08-06 thomas void
36 8f795179 2022-08-06 thomas got_sockaddr_inet6_init(struct sockaddr_in6 *in6, struct in6_addr *in6a,
37 8f795179 2022-08-06 thomas uint32_t sin6_scope_id)
38 8f795179 2022-08-06 thomas {
39 8f795179 2022-08-06 thomas in6->sin6_family = AF_INET6;
40 8f795179 2022-08-06 thomas memcpy(&in6->sin6_addr, in6a, sizeof(in6->sin6_addr));
41 8f795179 2022-08-06 thomas in6->sin6_scope_id = sin6_scope_id;
42 8f795179 2022-08-06 thomas }