17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22ba3594baSGarrett D'Amore /* 23ba3594baSGarrett D'Amore * Copyright 2014 Garrett D'Amore <garrett@damore.org> 24*48bbca81SDaniel Hoffman * Copyright (c) 2016 by Delphix. All rights reserved. 25ba3594baSGarrett D'Amore */ 267c478bd9Sstevel@tonic-gate /* Copyright (c) 1992 Sun Microsystems, Inc. */ 277c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 287c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate /* 317c478bd9Sstevel@tonic-gate * netdir.h 327c478bd9Sstevel@tonic-gate * 337c478bd9Sstevel@tonic-gate * This is the include file that defines various structures and 347c478bd9Sstevel@tonic-gate * constants used by the netdir routines. 357c478bd9Sstevel@tonic-gate */ 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate #ifndef _NETDIR_H 387c478bd9Sstevel@tonic-gate #define _NETDIR_H 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate /* 417c478bd9Sstevel@tonic-gate * This files uses struct netconfig, and netconfig.h must be included 427c478bd9Sstevel@tonic-gate * before this to avoid warnings. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #include <netconfig.h> 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #ifdef __cplusplus 487c478bd9Sstevel@tonic-gate extern "C" { 497c478bd9Sstevel@tonic-gate #endif 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate struct nd_addrlist { 527c478bd9Sstevel@tonic-gate int n_cnt; /* number of netbufs */ 537c478bd9Sstevel@tonic-gate struct netbuf *n_addrs; /* the netbufs */ 547c478bd9Sstevel@tonic-gate }; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate struct nd_hostservlist { 577c478bd9Sstevel@tonic-gate int h_cnt; /* number of nd_hostservs */ 587c478bd9Sstevel@tonic-gate struct nd_hostserv *h_hostservs; /* the entries */ 597c478bd9Sstevel@tonic-gate }; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate struct nd_hostserv { 627c478bd9Sstevel@tonic-gate char *h_host; /* the host name */ 637c478bd9Sstevel@tonic-gate char *h_serv; /* the service name */ 647c478bd9Sstevel@tonic-gate }; 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate struct nd_mergearg { 677c478bd9Sstevel@tonic-gate char *s_uaddr; /* servers universal address */ 687c478bd9Sstevel@tonic-gate char *c_uaddr; /* clients universal address */ 697c478bd9Sstevel@tonic-gate char *m_uaddr; /* merged universal address */ 707c478bd9Sstevel@tonic-gate }; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* 737c478bd9Sstevel@tonic-gate * _nderror is a private variable to the netdir system. 747c478bd9Sstevel@tonic-gate */ 757c478bd9Sstevel@tonic-gate #ifdef _REENTRANT 767c478bd9Sstevel@tonic-gate extern int *__nderror(); 777c478bd9Sstevel@tonic-gate #define _nderror (*(__nderror())) 787c478bd9Sstevel@tonic-gate #else 797c478bd9Sstevel@tonic-gate extern int _nderror; 807c478bd9Sstevel@tonic-gate #endif /* _REENTRANT */ 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate int netdir_options(struct netconfig *, int option, int fd, char *par); 847c478bd9Sstevel@tonic-gate int netdir_getbyname(struct netconfig *, struct nd_hostserv *, 857c478bd9Sstevel@tonic-gate struct nd_addrlist **); 867c478bd9Sstevel@tonic-gate int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **, 877c478bd9Sstevel@tonic-gate struct netbuf *); 887c478bd9Sstevel@tonic-gate int __netdir_getbyaddr_nosrv(struct netconfig *, struct nd_hostservlist **, 897c478bd9Sstevel@tonic-gate struct netbuf *); 907c478bd9Sstevel@tonic-gate int netdir_mergeaddr(struct netconfig *, char **muaddr, char *uaddr, 917c478bd9Sstevel@tonic-gate char *ruaddr); 927c478bd9Sstevel@tonic-gate void netdir_free(void *, int); 937c478bd9Sstevel@tonic-gate struct netbuf *uaddr2taddr(struct netconfig *, char *); 947c478bd9Sstevel@tonic-gate char *taddr2uaddr(struct netconfig *, struct netbuf *); 957c478bd9Sstevel@tonic-gate void netdir_perror(char *); 967c478bd9Sstevel@tonic-gate char *netdir_sperror(); 977c478bd9Sstevel@tonic-gate struct nd_addrlist *_netdir_getbyname(struct netconfig *, struct nd_hostserv *); 987c478bd9Sstevel@tonic-gate struct nd_hostservlist *_netdir_getbyaddr(struct netconfig *, struct netbuf *); 997c478bd9Sstevel@tonic-gate struct netbuf *_uaddr2taddr(struct netconfig *, char *); 1007c478bd9Sstevel@tonic-gate char *_taddr2uaddr(struct netconfig *, struct netbuf *); 1017c478bd9Sstevel@tonic-gate char *_netdir_mergeaddr(struct netconfig *, char *uaddr, char *ruaddr); 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * These are all objects that can be freed by netdir_free 1057c478bd9Sstevel@tonic-gate */ 1067c478bd9Sstevel@tonic-gate #define ND_HOSTSERV 0 1077c478bd9Sstevel@tonic-gate #define ND_HOSTSERVLIST 1 1087c478bd9Sstevel@tonic-gate #define ND_ADDR 2 1097c478bd9Sstevel@tonic-gate #define ND_ADDRLIST 3 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate /* 1127c478bd9Sstevel@tonic-gate * These are the various errors that can be encountered while attempting 1137c478bd9Sstevel@tonic-gate * to translate names to addresses. Note that none of them (except maybe 1147c478bd9Sstevel@tonic-gate * no memory) are truely fatal unless the ntoa deamon is on its last attempt 1157c478bd9Sstevel@tonic-gate * to translate the name. First four errors are to failitate return values 1167c478bd9Sstevel@tonic-gate * from DNS, that are used by mail and others. 1177c478bd9Sstevel@tonic-gate * 1187c478bd9Sstevel@tonic-gate * Negative errors terminate the search resolution process, positive errors 1197c478bd9Sstevel@tonic-gate * are treated as warnings. 1207c478bd9Sstevel@tonic-gate */ 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate #define ND_TRY_AGAIN -5 /* Non-Authoritive Host not found, or */ 1237c478bd9Sstevel@tonic-gate /* SERVERFAIL */ 1247c478bd9Sstevel@tonic-gate #define ND_NO_RECOVERY -4 /* Non recoverable errors, FORMERR, REFUSED, */ 1257c478bd9Sstevel@tonic-gate /* NOTIMP */ 1267c478bd9Sstevel@tonic-gate #define ND_NO_DATA -3 /* Valid name, no data record of requested */ 1277c478bd9Sstevel@tonic-gate /* type */ 1287c478bd9Sstevel@tonic-gate #define ND_NO_ADDRESS ND_NO_DATA /* no address, look for MX record */ 1297c478bd9Sstevel@tonic-gate #define ND_BADARG -2 /* Bad arguments passed */ 1307c478bd9Sstevel@tonic-gate #define ND_NOMEM -1 /* No virtual memory left */ 1317c478bd9Sstevel@tonic-gate #define ND_OK 0 /* Translation successful */ 1327c478bd9Sstevel@tonic-gate #define ND_NOHOST 1 /* Hostname was not resolvable */ 1337c478bd9Sstevel@tonic-gate #define ND_NOSERV 2 /* Service was unknown */ 1347c478bd9Sstevel@tonic-gate #define ND_NOSYM 3 /* Couldn't resolve symbol */ 1357c478bd9Sstevel@tonic-gate #define ND_OPEN 4 /* File couldn't be opened */ 1367c478bd9Sstevel@tonic-gate #define ND_ACCESS 5 /* File is not accessable */ 1377c478bd9Sstevel@tonic-gate #define ND_UKNWN 6 /* Unknown object to be freed */ 1387c478bd9Sstevel@tonic-gate #define ND_NOCTRL 7 /* Unknown option passed to netdir_options */ 1397c478bd9Sstevel@tonic-gate #define ND_FAILCTRL 8 /* Option failed in netdir_options */ 1407c478bd9Sstevel@tonic-gate #define ND_SYSTEM 9 /* Other System error */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate /* 1437c478bd9Sstevel@tonic-gate * The following netdir_options commands can be given to the fd. These is 1447c478bd9Sstevel@tonic-gate * a way of providing for any transport specific action which the caller 145*48bbca81SDaniel Hoffman * may want to initiate on its transport. It is up to the trasport provider 146*48bbca81SDaniel Hoffman * to support the netdir_options it wants to support. 1477c478bd9Sstevel@tonic-gate */ 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate #define ND_SET_BROADCAST 1 /* Do t_optmgmt to support broadcast */ 1507c478bd9Sstevel@tonic-gate #define ND_SET_RESERVEDPORT 2 /* bind it to reserve address */ 1517c478bd9Sstevel@tonic-gate #define ND_CHECK_RESERVEDPORT 3 /* check if address is reserved */ 1527c478bd9Sstevel@tonic-gate #define ND_MERGEADDR 4 /* Merge universal address */ 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * The following special case host names are used to give the underlying 1567c478bd9Sstevel@tonic-gate * transport provides a clue as to the intent of the request. 1577c478bd9Sstevel@tonic-gate */ 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate #define HOST_SELF "\\1" 1607c478bd9Sstevel@tonic-gate #define HOST_ANY "\\2" 1617c478bd9Sstevel@tonic-gate #define HOST_BROADCAST "\\3" 1627c478bd9Sstevel@tonic-gate #define HOST_SELF_BIND HOST_SELF 1637c478bd9Sstevel@tonic-gate #define HOST_SELF_CONNECT "\\4" 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1667c478bd9Sstevel@tonic-gate } 1677c478bd9Sstevel@tonic-gate #endif 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate #endif /* _NETDIR_H */ 170