12264Sjacobs /* 22264Sjacobs * CDDL HEADER START 32264Sjacobs * 42264Sjacobs * The contents of this file are subject to the terms of the 5*11262SRajagopal.Andra@Sun.COM * Common Development and Distribution License (the "License"). 6*11262SRajagopal.Andra@Sun.COM * You may not use this file except in compliance with the License. 72264Sjacobs * 82264Sjacobs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 92264Sjacobs * or http://www.opensolaris.org/os/licensing. 102264Sjacobs * See the License for the specific language governing permissions 112264Sjacobs * and limitations under the License. 122264Sjacobs * 132264Sjacobs * When distributing Covered Code, include this CDDL HEADER in each 142264Sjacobs * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 152264Sjacobs * If applicable, add the following below this CDDL HEADER, with the 162264Sjacobs * fields enclosed by brackets "[]" replaced with your own identifying 172264Sjacobs * information: Portions Copyright [yyyy] [name of copyright owner] 182264Sjacobs * 192264Sjacobs * CDDL HEADER END 202264Sjacobs */ 212264Sjacobs /* 22*11262SRajagopal.Andra@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 232264Sjacobs * Use is subject to license terms. 242264Sjacobs */ 252264Sjacobs 262264Sjacobs #ifndef _NS_H 272264Sjacobs #define _NS_H 282264Sjacobs 292264Sjacobs #ifdef __cplusplus 302264Sjacobs extern "C" { 312264Sjacobs #endif 322264Sjacobs 332264Sjacobs /* 342264Sjacobs * Name Service Common Keys/types for lookup 352264Sjacobs */ 362264Sjacobs #define NS_KEY_BSDADDR "bsdaddr" 372264Sjacobs #define NS_KEY_USE "use" 382264Sjacobs #define NS_KEY_ALL "all" 392264Sjacobs #define NS_KEY_GROUP "group" 402264Sjacobs #define NS_KEY_LIST "list" 412264Sjacobs 422264Sjacobs #define NS_KEY_PRINTER_TYPE "printer-type" 432264Sjacobs #define NS_KEY_DESCRIPTION "description" 442264Sjacobs 452264Sjacobs /* 462264Sjacobs * Name Service reserved names for lookup 472264Sjacobs */ 482264Sjacobs #define NS_NAME_DEFAULT "_default" 492264Sjacobs #define NS_NAME_ALL "_all" 502264Sjacobs 512264Sjacobs /* 522264Sjacobs * Name Services supported 532264Sjacobs */ 542264Sjacobs #define NS_SVC_USER "user" 552264Sjacobs #define NS_SVC_PRINTCAP "printcap" 562264Sjacobs #define NS_SVC_ETC "etc" 572264Sjacobs #define NS_SVC_NIS "nis" 582264Sjacobs #define NS_SVC_LDAP "ldap" 592264Sjacobs 602264Sjacobs /* 612264Sjacobs * Known Protocol Extensions 622264Sjacobs */ 632264Sjacobs #define NS_EXT_SOLARIS "solaris" 642264Sjacobs #define NS_EXT_GENERIC "extensions" /* same as SOLARIS */ 652264Sjacobs #define NS_EXT_HPUX "hpux" 662264Sjacobs #define NS_EXT_DEC "dec" 672264Sjacobs 682264Sjacobs /* 692264Sjacobs * get unique or full list of printer bindings 702264Sjacobs */ 712264Sjacobs #define NOTUNIQUE 0 722264Sjacobs #define UNIQUE 1 732264Sjacobs #define LOCAL_UNIQUE 2 /* include alias names */ 742264Sjacobs 752264Sjacobs /* BSD binding address structure */ 762264Sjacobs struct ns_bsd_addr { 772264Sjacobs char *server; /* server name */ 782264Sjacobs char *printer; /* printer name or NULL */ 792264Sjacobs char *extension; /* RFC-1179 conformance */ 802264Sjacobs char *pname; /* Local printer name */ 812264Sjacobs }; 822264Sjacobs typedef struct ns_bsd_addr ns_bsd_addr_t; 832264Sjacobs 842264Sjacobs /* Key/Value pair structure */ 852264Sjacobs struct ns_kvp { 862264Sjacobs char *key; /* key */ 872264Sjacobs char *value; /* value string */ 882264Sjacobs }; 892264Sjacobs typedef struct ns_kvp ns_kvp_t; 902264Sjacobs 912264Sjacobs 922264Sjacobs /* LDAP specific result codes */ 932264Sjacobs 942264Sjacobs typedef enum NSL_RESULT 952264Sjacobs { 962264Sjacobs NSL_OK = 0, /* Operation successful */ 972264Sjacobs NSL_ERR_INTERNAL = 1, /* Internal coding Error */ 982264Sjacobs NSL_ERR_ADD_FAILED = 2, /* LDAP add failed */ 992264Sjacobs NSL_ERR_MOD_FAILED = 3, /* LDAP modify failed */ 1002264Sjacobs NSL_ERR_DEL_FAILED = 4, /* LDAP delete failed */ 1012264Sjacobs NSL_ERR_UNKNOWN_PRINTER = 5, /* Unknown Printer object */ 1022264Sjacobs NSL_ERR_CREDENTIALS = 6, /* LDAP credentials invalid */ 1032264Sjacobs NSL_ERR_CONNECT = 7, /* LDAP server connect failed */ 1042264Sjacobs NSL_ERR_BIND = 8, /* LDAP bind failed */ 1052264Sjacobs NSL_ERR_RENAME = 9, /* Object rename is not allowed */ 1062264Sjacobs NSL_ERR_KVP = 10, /* sun-printer-kvp not allowed */ 1072264Sjacobs NSL_ERR_BSDADDR = 11, /* sun-printer-bsdaddr not allowed */ 1082264Sjacobs NSL_ERR_PNAME = 12, /* printer-name not allowed */ 1092264Sjacobs NSL_ERR_MEMORY = 13, /* memory allocation failed */ 1102264Sjacobs NSL_ERR_MULTIOP = 14, /* Replace and delete operation */ 1112264Sjacobs NSL_ERR_NOTALLOWED = 15, /* KVP attribute not allowed */ 1122264Sjacobs NSL_ERROR = -1 /* General error */ 1132264Sjacobs } NSL_RESULT; 1142264Sjacobs 1152264Sjacobs 1162264Sjacobs /* LDAP bind password security type */ 1172264Sjacobs 1182264Sjacobs typedef enum NS_PASSWD_TYPE { 1192264Sjacobs NS_PW_INSECURE = 0, 1202264Sjacobs NS_PW_SECURE = 1 1212264Sjacobs } NS_PASSWD_TYPE; 1222264Sjacobs 1232264Sjacobs 1242264Sjacobs /* 1252264Sjacobs * Information needed to update a name service. 1262264Sjacobs * Currently only used for ldap. 1272264Sjacobs */ 1282264Sjacobs struct ns_cred { 1292264Sjacobs char *binddn; 1302264Sjacobs char *passwd; 1312264Sjacobs char *host; 1322264Sjacobs int port; /* LDAP port, 0 = default */ 1332264Sjacobs NS_PASSWD_TYPE passwdType; /* password security type */ 1342264Sjacobs uchar_t *domainDN; /* NS domain DN */ 1352264Sjacobs }; 1362264Sjacobs typedef struct ns_cred ns_cred_t; 1372264Sjacobs 1382264Sjacobs /* LDAP specific NS Data */ 1392264Sjacobs 1402264Sjacobs typedef struct NS_LDAPDATA { 1412264Sjacobs char **attrList; /* list of user defined Key Value Pairs */ 1422264Sjacobs } NS_LDAPDATA; 1432264Sjacobs 1442264Sjacobs /* Printer Object structure */ 1452264Sjacobs struct ns_printer { 1462264Sjacobs char *name; /* primary name of printer */ 1472264Sjacobs char **aliases; /* aliases for printer */ 1482264Sjacobs char *source; /* name service derived from */ 1492264Sjacobs ns_kvp_t **attributes; /* key/value pairs. */ 1502264Sjacobs ns_cred_t *cred; /* info to update name service */ 1512264Sjacobs void *nsdata; /* name service specific data */ 1522264Sjacobs }; 1532264Sjacobs typedef struct ns_printer ns_printer_t; 1542264Sjacobs 1552264Sjacobs /* functions to get/put printer objects */ 1562264Sjacobs extern ns_printer_t *ns_printer_create(char *, char **, char *, ns_kvp_t **); 1572264Sjacobs extern ns_printer_t *ns_printer_get_name(const char *, const char *); 1582264Sjacobs extern ns_printer_t **ns_printer_get_list(const char *); 1592264Sjacobs extern int ns_printer_put(const ns_printer_t *); 1602264Sjacobs extern void ns_printer_destroy(ns_printer_t *); 1612264Sjacobs 1622264Sjacobs extern int setprinterentry(int, char *); 1632264Sjacobs extern int endprinterentry(); 1642264Sjacobs extern int getprinterentry(char *, int, char *); 1652264Sjacobs extern int getprinterbyname(char *, char *, int, char *); 1662264Sjacobs 1672264Sjacobs extern char *_cvt_printer_to_entry(ns_printer_t *, char *, int); 1682264Sjacobs 1692264Sjacobs extern ns_printer_t *_cvt_nss_entry_to_printer(char *, char *); 1702264Sjacobs extern ns_printer_t *posix_name(const char *); 1712264Sjacobs 1722264Sjacobs 1732264Sjacobs 1742264Sjacobs /* functions to manipulate key/value pairs */ 1752264Sjacobs extern void *ns_get_value(const char *, const ns_printer_t *); 1762264Sjacobs extern char *ns_get_value_string(const char *, const ns_printer_t *); 1772264Sjacobs extern int ns_set_value(const char *, const void *, ns_printer_t *); 1782264Sjacobs extern int ns_set_value_from_string(const char *, const char *, 1792264Sjacobs ns_printer_t *); 1802264Sjacobs extern ns_kvp_t *ns_kvp_create(const char *, const char *); 1812264Sjacobs 1822264Sjacobs /* for BSD bindings only */ 1832264Sjacobs extern ns_bsd_addr_t *ns_bsd_addr_get_default(); 1842264Sjacobs extern ns_bsd_addr_t *ns_bsd_addr_get_name(char *name); 1852264Sjacobs extern ns_bsd_addr_t **ns_bsd_addr_get_all(int); 1862264Sjacobs extern ns_bsd_addr_t **ns_bsd_addr_get_list(int); 1872264Sjacobs 1882264Sjacobs /* others */ 1892264Sjacobs extern int ns_printer_match_name(ns_printer_t *, const char *); 1902264Sjacobs extern char *ns_printer_name_list(const ns_printer_t *); 1912264Sjacobs extern char *value_to_string(const char *, void *); 1922264Sjacobs extern void *string_to_value(const char *, char *); 1932264Sjacobs extern char *normalize_ns_name(char *); 1942264Sjacobs extern char *strncat_escaped(char *, char *, int, char *); 1952264Sjacobs 1962264Sjacobs 1972264Sjacobs 1982264Sjacobs #ifdef __cplusplus 1992264Sjacobs } 2002264Sjacobs #endif 2012264Sjacobs 2022264Sjacobs #endif /* _NS_H */ 203