1*c0b5d9fbSchristos /* $NetBSD: arpaname.c,v 1.6 2022/09/23 12:15:26 christos Exp $ */
2e2b1b9c0Schristos
3e2b1b9c0Schristos /*
4e2b1b9c0Schristos * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5e2b1b9c0Schristos *
6*c0b5d9fbSchristos * SPDX-License-Identifier: MPL-2.0
7*c0b5d9fbSchristos *
8e2b1b9c0Schristos * This Source Code Form is subject to the terms of the Mozilla Public
9e2b1b9c0Schristos * License, v. 2.0. If a copy of the MPL was not distributed with this
1073584a28Schristos * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11e2b1b9c0Schristos *
12e2b1b9c0Schristos * See the COPYRIGHT file distributed with this work for additional
13e2b1b9c0Schristos * information regarding copyright ownership.
14e2b1b9c0Schristos */
15e2b1b9c0Schristos
169742fdb4Schristos #include <stdio.h>
17e2b1b9c0Schristos
18e2b1b9c0Schristos #include <isc/net.h>
19e2b1b9c0Schristos #include <isc/print.h>
20e2b1b9c0Schristos
219742fdb4Schristos #define UNUSED(x) (void)(x)
22e2b1b9c0Schristos
23e2b1b9c0Schristos int
main(int argc,char * argv[])24e2b1b9c0Schristos main(int argc, char *argv[]) {
25e2b1b9c0Schristos unsigned char buf[16];
26e2b1b9c0Schristos int i;
27e2b1b9c0Schristos
28e2b1b9c0Schristos UNUSED(argc);
29e2b1b9c0Schristos
30e2b1b9c0Schristos while (argv[1]) {
31e2b1b9c0Schristos if (inet_pton(AF_INET6, argv[1], buf) == 1) {
329742fdb4Schristos for (i = 15; i >= 0; i--) {
33e2b1b9c0Schristos fprintf(stdout, "%X.%X.", buf[i] & 0xf,
34e2b1b9c0Schristos (buf[i] >> 4) & 0xf);
359742fdb4Schristos }
36e2b1b9c0Schristos fprintf(stdout, "IP6.ARPA\n");
37e2b1b9c0Schristos argv++;
38e2b1b9c0Schristos continue;
39e2b1b9c0Schristos }
40e2b1b9c0Schristos if (inet_pton(AF_INET, argv[1], buf) == 1) {
419742fdb4Schristos fprintf(stdout, "%u.%u.%u.%u.IN-ADDR.ARPA\n", buf[3],
429742fdb4Schristos buf[2], buf[1], buf[0]);
43e2b1b9c0Schristos argv++;
44e2b1b9c0Schristos continue;
45e2b1b9c0Schristos }
46e2b1b9c0Schristos return (1);
47e2b1b9c0Schristos }
48e2b1b9c0Schristos fflush(stdout);
49e2b1b9c0Schristos return (ferror(stdout));
50e2b1b9c0Schristos }
51