19c9af259SGordon Ross /* 29c9af259SGordon Ross * Copyright (c) 2000-2001 Boris Popov 39c9af259SGordon Ross * All rights reserved. 49c9af259SGordon Ross * 59c9af259SGordon Ross * Redistribution and use in source and binary forms, with or without 69c9af259SGordon Ross * modification, are permitted provided that the following conditions 79c9af259SGordon Ross * are met: 89c9af259SGordon Ross * 1. Redistributions of source code must retain the above copyright 99c9af259SGordon Ross * notice, this list of conditions and the following disclaimer. 109c9af259SGordon Ross * 2. Redistributions in binary form must reproduce the above copyright 119c9af259SGordon Ross * notice, this list of conditions and the following disclaimer in the 129c9af259SGordon Ross * documentation and/or other materials provided with the distribution. 139c9af259SGordon Ross * 3. All advertising materials mentioning features or use of this software 149c9af259SGordon Ross * must display the following acknowledgement: 159c9af259SGordon Ross * This product includes software developed by Boris Popov. 169c9af259SGordon Ross * 4. Neither the name of the author nor the names of any co-contributors 179c9af259SGordon Ross * may be used to endorse or promote products derived from this software 189c9af259SGordon Ross * without specific prior written permission. 199c9af259SGordon Ross * 209c9af259SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 219c9af259SGordon Ross * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 229c9af259SGordon Ross * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 239c9af259SGordon Ross * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 249c9af259SGordon Ross * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 259c9af259SGordon Ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 269c9af259SGordon Ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 279c9af259SGordon Ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 289c9af259SGordon Ross * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 299c9af259SGordon Ross * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 309c9af259SGordon Ross * SUCH DAMAGE. 319c9af259SGordon Ross */ 329c9af259SGordon Ross 339c9af259SGordon Ross /* 34613a2f6bSGordon Ross * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 359c9af259SGordon Ross * Use is subject to license terms. 36*40c0e231SGordon Ross * 37*40c0e231SGordon Ross * Copyright 2018 Nexenta Systems, Inc. All rights reserved. 389c9af259SGordon Ross */ 399c9af259SGordon Ross 409c9af259SGordon Ross #ifndef _PRIVATE_H 419c9af259SGordon Ross #define _PRIVATE_H 429c9af259SGordon Ross 439c9af259SGordon Ross /* 449c9af259SGordon Ross * Private declarations for this library. 459c9af259SGordon Ross * Moved from smb_lib.h 469c9af259SGordon Ross */ 479c9af259SGordon Ross 489c9af259SGordon Ross #include <inttypes.h> 49613a2f6bSGordon Ross #include <sys/byteorder.h> 50613a2f6bSGordon Ross #include <sys/ccompile.h> 51613a2f6bSGordon Ross 5202d09e03SGordon Ross #include <netsmb/mchain.h> 53613a2f6bSGordon Ross #include <netsmb/netbios.h> 54613a2f6bSGordon Ross 55613a2f6bSGordon Ross extern void dprint(const char *, const char *, ...) 56613a2f6bSGordon Ross __PRINTFLIKE(2); 57613a2f6bSGordon Ross 58613a2f6bSGordon Ross #if defined(DEBUG) || defined(__lint) 59613a2f6bSGordon Ross #define DPRINT(...) dprint(__func__, __VA_ARGS__) 60613a2f6bSGordon Ross #else 61613a2f6bSGordon Ross #define DPRINT(...) ((void)0) 62613a2f6bSGordon Ross #endif 63613a2f6bSGordon Ross 649c9af259SGordon Ross /* 6502d09e03SGordon Ross * This library extends the mchain.h function set a little. 669c9af259SGordon Ross */ 6702d09e03SGordon Ross int m_getm(struct mbuf *, int, struct mbuf **); 689c9af259SGordon Ross int m_lineup(struct mbuf *, struct mbuf **); 69613a2f6bSGordon Ross size_t m_totlen(struct mbuf *); 70613a2f6bSGordon Ross 7102d09e03SGordon Ross int mb_init_sz(struct mbdata *, int); 7202d09e03SGordon Ross int mb_fit(struct mbdata *mbp, int size, char **pp); 7302d09e03SGordon Ross 7402d09e03SGordon Ross int mb_put_string(struct mbdata *mbp, const char *s, int); 75613a2f6bSGordon Ross int mb_put_astring(struct mbdata *mbp, const char *s); 76613a2f6bSGordon Ross int mb_put_ustring(struct mbdata *mbp, const char *s); 779c9af259SGordon Ross 7802d09e03SGordon Ross int md_get_string(struct mbdata *, char **, int); 7902d09e03SGordon Ross int md_get_astring(struct mbdata *, char **); 8002d09e03SGordon Ross int md_get_ustring(struct mbdata *, char **); 819c9af259SGordon Ross 829c9af259SGordon Ross /* 839c9af259SGordon Ross * Network stuff (NetBIOS and otherwise) 849c9af259SGordon Ross */ 85613a2f6bSGordon Ross struct nb_name; 86613a2f6bSGordon Ross struct sockaddr_nb; 87613a2f6bSGordon Ross 88613a2f6bSGordon Ross extern int smb_recv_timeout; /* seconds */ 89613a2f6bSGordon Ross 90613a2f6bSGordon Ross void dump_ctx(char *, struct smb_ctx *); 91613a2f6bSGordon Ross void dump_addrinfo(struct addrinfo *); 92613a2f6bSGordon Ross void dump_sockaddr(struct sockaddr *); 93613a2f6bSGordon Ross int nb_ssn_request(struct smb_ctx *, char *); 949c9af259SGordon Ross 959c9af259SGordon Ross int nb_name_len(struct nb_name *); 96613a2f6bSGordon Ross int nb_name_encode(struct mbdata *, struct nb_name *); 979c9af259SGordon Ross int nb_encname_len(const uchar_t *); 989c9af259SGordon Ross 99613a2f6bSGordon Ross int nb_snballoc(struct sockaddr_nb **); 1009c9af259SGordon Ross void nb_snbfree(struct sockaddr *); 1019c9af259SGordon Ross int nb_sockaddr(struct sockaddr *, struct nb_name *, struct sockaddr_nb **); 1029c9af259SGordon Ross 103613a2f6bSGordon Ross int nbns_getaddrinfo(const char *name, struct nb_ctx *nbc, 104613a2f6bSGordon Ross struct addrinfo **res); 1059c9af259SGordon Ross int nbns_resolvename(const char *, struct nb_ctx *, struct sockaddr **); 106613a2f6bSGordon Ross int get_xti_err(int); 107613a2f6bSGordon Ross 108613a2f6bSGordon Ross 109613a2f6bSGordon Ross /* 110613a2f6bSGordon Ross * Private SMB stuff 111613a2f6bSGordon Ross */ 112613a2f6bSGordon Ross 113613a2f6bSGordon Ross struct smb_bitname { 114613a2f6bSGordon Ross uint_t bn_bit; 115613a2f6bSGordon Ross char *bn_name; 116613a2f6bSGordon Ross }; 117613a2f6bSGordon Ross typedef struct smb_bitname smb_bitname_t; 118613a2f6bSGordon Ross char *smb_printb(char *, int, const struct smb_bitname *); 119613a2f6bSGordon Ross 120613a2f6bSGordon Ross int smb_ctx_getaddr(struct smb_ctx *ctx); 121613a2f6bSGordon Ross int smb_ctx_gethandle(struct smb_ctx *ctx); 122613a2f6bSGordon Ross 123430b4c46SGordon Ross int smb_iod_start(struct smb_ctx *); 124*40c0e231SGordon Ross const char *smb_iod_state_name(enum smbiod_state st); 125613a2f6bSGordon Ross 126613a2f6bSGordon Ross void smb_time_local2server(struct timeval *, int, long *); 127613a2f6bSGordon Ross void smb_time_server2local(ulong_t, int, struct timeval *); 128613a2f6bSGordon Ross void smb_time_NT2local(uint64_t, int, struct timeval *); 129613a2f6bSGordon Ross void smb_time_local2NT(struct timeval *, int, uint64_t *); 130613a2f6bSGordon Ross 131613a2f6bSGordon Ross int smb_getlocalname(char **); 132613a2f6bSGordon Ross int smb_get_authentication(struct smb_ctx *); 133613a2f6bSGordon Ross int smb_get_keychain(struct smb_ctx *ctx); 134613a2f6bSGordon Ross void smb_hexdump(const void *buf, int len); 135613a2f6bSGordon Ross 136613a2f6bSGordon Ross /* See ssp.c */ 137613a2f6bSGordon Ross int ssp_ctx_create_client(struct smb_ctx *, struct mbdata *); 138613a2f6bSGordon Ross int ssp_ctx_next_token(struct smb_ctx *, struct mbdata *, struct mbdata *); 139613a2f6bSGordon Ross void ssp_ctx_destroy(struct smb_ctx *); 1409c9af259SGordon Ross 141613a2f6bSGordon Ross #ifdef KICONV_SUPPORT 142613a2f6bSGordon Ross /* See nls.c (get rid of this?) */ 1439c9af259SGordon Ross extern uchar_t nls_lower[256], nls_upper[256]; 144613a2f6bSGordon Ross #endif /* KICONV_SUPPORT */ 1459c9af259SGordon Ross 1469c9af259SGordon Ross #endif /* _PRIVATE_H */ 147