Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/ntirpc/rpc/auth_inline.h
$ cat -n /usr/include/ntirpc/rpc/auth_inline.h 1 /* $NetBSD: auth.h,v 1.15 2000/06/02 22:57:55 fvdl Exp $ */ 2 3 /* 4 * Copyright (c) 2009, Sun Microsystems, Inc. 5 * Copyright (c) 2012-2017 Red Hat, Inc. and/or its affiliates. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * - Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * - Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * - Neither the name of Sun Microsystems, Inc. nor the names of its 16 * contributors may be used to endorse or promote products derived 17 * from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 * from: @(#)auth.h 1.17 88/02/08 SMI 32 * from: @(#)auth.h 2.3 88/08/07 4.0 RPCSRC 33 * from: @(#)auth.h 1.43 98/02/02 SMI 34 * $FreeBSD: src/include/rpc/auth.h,v 1.20 2003/01/01 18:48:42 schweikh Exp $ 35 */ 36 37 /* 38 * auth.h, Authentication interface. 39 * 40 * Copyright (C) 1984, Sun Microsystems, Inc. 41 * 42 * The data structures are completely opaque to the client. The client 43 * is required to pass an AUTH * to routines that create rpc 44 * "sessions". 45 */ 46 47 #ifndef _TIRPC_AUTH_INLINE_H 48 #define _TIRPC_AUTH_INLINE_H 49 50 #include
51 #include
52 53 /* 54 * encode auth opaque 55 */ 56 static inline bool 57 xdr_opaque_auth_encode_it(XDR *xdrs, struct opaque_auth *oa) 58 { 59 if (oa->oa_length > MAX_AUTH_BYTES) { 60 /* duplicate test, usually done earlier by caller */ 61 __warnx(TIRPC_DEBUG_FLAG_ERROR, 62 "%s:%u ERROR oa_length (%u) > %u", 63 __func__, __LINE__, 64 oa->oa_length, 65 MAX_AUTH_BYTES); 66 return (false); 67 } 68 69 return (xdr_opaque_encode(xdrs, oa->oa_body, oa->oa_length)); 70 } 71 72 /* 73 * encode an auth message 74 */ 75 static inline bool 76 xdr_opaque_auth_encode(XDR *xdrs, struct opaque_auth *oa) 77 { 78 /* 79 * XDR_INLINE is just as likely to do a function call, 80 * so don't bother with it here. 81 */ 82 if (!xdr_putenum(xdrs, oa->oa_flavor)) { 83 __warnx(TIRPC_DEBUG_FLAG_ERROR, 84 "%s:%u ERROR oa_flavor", 85 __func__, __LINE__); 86 return (false); 87 } 88 if (!xdr_putuint32(xdrs, oa->oa_length)) { 89 __warnx(TIRPC_DEBUG_FLAG_ERROR, 90 "%s:%u ERROR oa_length", 91 __func__, __LINE__); 92 return (false); 93 } 94 95 if (oa->oa_length) { 96 /* only call and alloc for > 0 length */ 97 return (xdr_opaque_auth_encode_it(xdrs, oa)); 98 } 99 return (true); /* 0 length succeeds */ 100 } 101 102 /* 103 * decode auth opaque 104 */ 105 static inline bool 106 xdr_opaque_auth_decode_it(XDR *xdrs, struct opaque_auth *oa) 107 { 108 if (oa->oa_length > MAX_AUTH_BYTES) { 109 /* duplicate test, usually done earlier by caller */ 110 __warnx(TIRPC_DEBUG_FLAG_ERROR, 111 "%s:%u ERROR oa_length (%u) > %u", 112 __func__, __LINE__, 113 oa->oa_length, 114 MAX_AUTH_BYTES); 115 return (false); 116 } 117 118 return (xdr_opaque_decode(xdrs, oa->oa_body, oa->oa_length)); 119 } 120 121 /* 122 * decode an auth message 123 * 124 * param[IN] buf 2 more inline 125 */ 126 static inline bool 127 xdr_opaque_auth_decode(XDR *xdrs, struct opaque_auth *oa, int32_t *buf) 128 { 129 if (buf != NULL) { 130 oa->oa_flavor = IXDR_GET_ENUM(buf, enum_t); 131 oa->oa_length = (u_int) IXDR_GET_U_INT32(buf); 132 } else if (!xdr_getenum(xdrs, (enum_t *)&oa->oa_flavor)) { 133 __warnx(TIRPC_DEBUG_FLAG_ERROR, 134 "%s:%u ERROR oa_flavor", 135 __func__, __LINE__); 136 return (false); 137 } else if (!xdr_getuint32(xdrs, &oa->oa_length)) { 138 __warnx(TIRPC_DEBUG_FLAG_ERROR, 139 "%s:%u ERROR oa_length", 140 __func__, __LINE__); 141 return (false); 142 } 143 144 if (oa->oa_length) { 145 /* only call and alloc for > 0 length */ 146 return xdr_opaque_auth_decode_it(xdrs, oa); 147 } 148 return (true); /* 0 length succeeds */ 149 } 150 151 /* 152 * XDR an auth message 153 */ 154 static inline bool 155 xdr_opaque_auth(XDR *xdrs, struct opaque_auth *oa) 156 { 157 switch (xdrs->x_op) { 158 case XDR_ENCODE: 159 return (xdr_opaque_auth_encode(xdrs, oa)); 160 case XDR_DECODE: 161 return (xdr_opaque_auth_decode(xdrs, oa, NULL)); 162 case XDR_FREE: 163 return (true); 164 default: 165 __warnx(TIRPC_DEBUG_FLAG_ERROR, 166 "%s:%u ERROR xdrs->x_op (%u)", 167 __func__, __LINE__, 168 xdrs->x_op); 169 break; 170 } /* x_op */ 171 172 return (false); 173 } 174 175 #endif /* !_TIRPC_AUTH_INLINE_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™