19fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 29fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * CDDL HEADER START 39fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 49fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * The contents of this file are subject to the terms of the 59fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Common Development and Distribution License (the "License"). 69fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * You may not use this file except in compliance with the License. 79fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 89fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 99fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * or http://www.opensolaris.org/os/licensing. 109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * See the License for the specific language governing permissions 119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * and limitations under the License. 129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * When distributing Covered Code, include this CDDL HEADER in each 149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * If applicable, add the following below this CDDL HEADER, with the 169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * fields enclosed by brackets "[]" replaced with your own identifying 179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * information: Portions Copyright [yyyy] [name of copyright owner] 189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * CDDL HEADER END 209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 21*148c5f43SAlan Wright 229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 23*148c5f43SAlan Wright * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <netdb.h> 279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <sys/types.h> 289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <string.h> 299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <strings.h> 309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/libsmb.h> 319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/libmlsvc.h> 329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/smbinfo.h> 339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/nmpipes.h> 349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/ndl/srvsvc.ndl> 359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int wkssvc_s_NetWkstaGetInfo(void *, ndr_xa_t *); 379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int wkssvc_s_NetWkstaTransportEnum(void *, ndr_xa_t *); 389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static ndr_stub_table_t wkssvc_stub_table[] = { 409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { wkssvc_s_NetWkstaGetInfo, WKSSVC_OPNUM_NetWkstaGetInfo }, 419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { wkssvc_s_NetWkstaTransportEnum, WKSSVC_OPNUM_NetWkstaTransportEnum }, 429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States {0} 439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States }; 449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static ndr_service_t wkssvc_service = { 469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States "Workstation", /* name (WKSSVC or WKSTA) */ 479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States "Workstation services", /* desc */ 489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States "\\wkssvc", /* endpoint */ 499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States PIPE_NTSVCS, /* sec_addr_port */ 509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States "6bffd098-a112-3610-9833-46c3f87e345a", 1, /* abstract */ 519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States NDR_TRANSFER_SYNTAX_UUID, 2, /* transfer */ 529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* no bind_instance_size */ 539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* no bind_req() */ 549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* no unbind_and_close() */ 559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 0, /* use generic_call_stub() */ 569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States &TYPEINFO(wkssvc_interface), /* interface ti */ 579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States wkssvc_stub_table /* stub_table */ 589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States }; 599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void 619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States wkssvc_initialize(void) 629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) ndr_svc_register(&wkssvc_service); 649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * WKSSVC NetWkstaGetInfo 689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int 709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States wkssvc_s_NetWkstaGetInfo(void *arg, ndr_xa_t *mxa) 719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States struct mslm_NetWkstaGetInfo *param = arg; 739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States mslm_NetWkstaGetInfo_rb *rb; 749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char hostname[MAXHOSTNAMELEN]; 759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char resource_domain[SMB_PI_MAX_DOMAIN]; 769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_version_t version; 779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *name; 789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *domain; 799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States DWORD status; 809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int rc; 819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) smb_getdomainname(resource_domain, SMB_PI_MAX_DOMAIN); 839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb = NDR_NEW(mxa, mslm_NetWkstaGetInfo_rb); 859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((rc = smb_getnetbiosname(hostname, MAXHOSTNAMELEN)) == 0) { 879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States name = NDR_STRDUP(mxa, hostname); 889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States domain = NDR_STRDUP(mxa, resource_domain); 899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((rc != 0) || (rb == NULL) || (name == NULL) || (domain == NULL)) { 929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(param, sizeof (struct mslm_NetWkstaGetInfo)); 939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_ENOUGH_MEMORY; 949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_config_get_version(&version); 989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->result.level = param->level; 1009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->result.bufptr.nullptr = (void *)rb; 1019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (param->level) { 1039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 100: 1049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf100.wki100_platform_id = SV_PLATFORM_ID_NT; 1059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf100.wki100_ver_major = version.sv_major; 1069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf100.wki100_ver_minor = version.sv_minor; 1079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf100.wki100_computername = (unsigned char *)name; 1089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf100.wki100_langroup = (unsigned char *)domain; 1099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_SUCCESS; 1109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 101: 1139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf101.wki101_platform_id = SV_PLATFORM_ID_NT; 1149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf101.wki101_ver_major = version.sv_major; 1159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf101.wki101_ver_minor = version.sv_minor; 1169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf101.wki101_computername = (unsigned char *)name; 1179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf101.wki101_langroup = (unsigned char *)domain; 1189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf101.wki101_lanroot = (unsigned char *)""; 1199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_SUCCESS; 1209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 102: 1239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_platform_id = SV_PLATFORM_ID_NT; 1249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_ver_major = version.sv_major; 1259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_ver_minor = version.sv_minor; 1269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_computername = (unsigned char *)name; 1279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_langroup = (unsigned char *)domain; 1289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_lanroot = (unsigned char *)""; 1299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf102.wki102_logged_on_users = 1; 1309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_SUCCESS; 1319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 502: 1349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&rb->buf502, sizeof (struct mslm_WKSTA_INFO_502)); 1359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.keep_connection = 600; 1369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.max_commands = 1024; 1379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.session_timeout = 5400; 1389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.size_char_buf = 1024; 1399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.max_threads = 1024; 1409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.use_opportunistic_locking = 1; 1419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.use_unlock_behind = 1; 1429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.use_close_behind = 1; 1439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.buf_named_pipes = 1; 1449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.use_lock_read_unlock = 1; 1459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.utilize_nt_caching = 1; 1469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.use_raw_read = 1; 1479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States rb->buf502.use_raw_write = 1; 1489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_SUCCESS; 1499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States default: 1529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->result.bufptr.nullptr = 0; 1539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_INVALID_LEVEL; 1549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) { 1589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(param, sizeof (struct mslm_NetWkstaGetInfo)); 1599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 1609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 1639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 1669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * WKSSVC NetWkstaTransportEnum 1679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 1689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int 1699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States wkssvc_s_NetWkstaTransportEnum(void *arg, ndr_xa_t *mxa) 1709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 1719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States struct mslm_NetWkstaTransportEnum *param = arg; 1729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States struct mslm_NetWkstaTransportCtr0 *info0; 1739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States struct mslm_NetWkstaTransportInfo0 *ti0; 1749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (param->info.level) { 1769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 0: 1779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info0 = NDR_NEW(mxa, struct mslm_NetWkstaTransportCtr0); 1789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ti0 = NDR_NEW(mxa, struct mslm_NetWkstaTransportInfo0); 1799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (info0 == NULL || ti0 == NULL) { 1819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(param, sizeof (struct mslm_NetWkstaGetInfo)); 1829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_ENOUGH_MEMORY; 1839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 1849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ti0->quality_of_service = 65535; 1879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ti0->num_vcs = 0; 1889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ti0->transport_name = (unsigned char *)"\\Device\\NetbiosSmb"; 1899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ti0->transport_address = (unsigned char *)"000000000000"; 1909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ti0->wan_ish = 1024; 1919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info0->count = 1; 1939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info0->ti0 = ti0; 1949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.ru.info0 = info0; 1959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->total_entries = 1; 1969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (param->resume_handle) 1989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *param->resume_handle = 0; 1999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS; 2019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States default: 2049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(param, sizeof (struct mslm_NetWkstaGetInfo)); 2059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_LEVEL; 2069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 210