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