8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / cmd-inet / common / kcmd.h
blobb6bc8e9154d0c160b5f03315585c23761cf2c448
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _KCMD_H
28 #define _KCMD_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 #define OPTS_FORWARD_CREDS 0x00000002
37 #define OPTS_FORWARDABLE_CREDS 0x00000001
39 #define SERVER 0
40 #define CLIENT 1
42 enum kcmd_proto {
44 * Old protocol: DES encryption only. No subkeys.
45 * No protection for cleartext length. No ivec supplied.
46 * OOB hacks used for rlogin. Checksum may be omitted at
47 * connection startup.
49 KCMD_OLD_PROTOCOL = 1,
51 * New protocol: Any encryption scheme. Client-generated
52 * subkey required. Prepend cleartext-length to cleartext
53 * data (but don't include it in count). Starting ivec defined,
54 * chained. In-band signalling. Checksum required.
56 KCMD_NEW_PROTOCOL,
59 * Hack: Get credentials, and use the old protocol iff the session
60 * key type is single-DES.
62 KCMD_PROTOCOL_COMPAT_HACK,
63 /* Using Kerberos version 4. */
64 KCMD_V4_PROTOCOL,
65 KCMD_UNKNOWN_PROTOCOL
68 #define SOCK_FAMILY(ss) ((ss).ss_family)
70 #define SOCK_PORT(ss) ((ss).ss_family == AF_INET6 ? \
71 ((struct sockaddr_in6 *)&(ss))->sin6_port : \
72 ((struct sockaddr_in *)&(ss))->sin_port)
74 #define SOCK_ADDR(ss) ((ss).ss_family == AF_INET6 ? \
75 (void *)&((struct sockaddr_in6 *)&(ss))->sin6_addr : \
76 (void *)&((struct sockaddr_in *)&(ss))->sin_addr)
78 #define SET_SOCK_FAMILY(ss, family) (SOCK_FAMILY(ss) = (family))
80 #define SET_SOCK_PORT(ss, port) \
81 ((ss).ss_family == AF_INET6 ? \
82 (((struct sockaddr_in6 *)&(ss))->sin6_port = (port)) : \
83 (((struct sockaddr_in *)&(ss))->sin_port = (port)))
85 #define SET_SOCK_ADDR4(ss, addr) ((void)(sock_set_inaddr(&(ss), (addr))))
87 #define SET_SOCK_ADDR_ANY(ss) \
88 ((void) ((ss).ss_family == AF_INET6 ? \
89 (void) (((struct sockaddr_in6 *)&(ss))->sin6_addr = in6addr_any) : \
90 (void) (((struct sockaddr_in *)&(ss))->sin_addr.s_addr = \
91 htonl(INADDR_ANY))))
94 * Prototypes for functions in 'kcmd.c'
96 char *strsave(char *sp);
98 int kcmd(int *sock, char **ahost, ushort_t rport, char *locuser,
99 char *remuser, char *cmd, int *fd2p, char *service, char *realm,
100 krb5_context bsd_context, krb5_auth_context *authconp,
101 krb5_creds **cred, krb5_int32 *seqno, krb5_int32 *server_seqno,
102 krb5_flags authopts,
103 int anyport, enum kcmd_proto *kcmd_proto);
105 void init_encrypt(int, krb5_context, enum kcmd_proto,
106 krb5_data *, krb5_data *,
107 int, krb5_encrypt_block *);
109 int desread(int, char *, int, int);
110 int deswrite(int, char *, int, int);
112 #ifdef __cplusplus
114 #endif
116 #endif /* _KCMD_H */