1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _INET_NCADOORHDR_H 28*0Sstevel@tonic-gate #define _INET_NCADOORHDR_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifndef _KERNEL 37*0Sstevel@tonic-gate #include <stddef.h> 38*0Sstevel@tonic-gate #endif /* _KERNEL */ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #include <sys/types.h> 41*0Sstevel@tonic-gate #include <sys/socket.h> 42*0Sstevel@tonic-gate #include <netinet/in.h> 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define ONE_KB (1024) 45*0Sstevel@tonic-gate #define NCA_IO_MAX_SIZE (256 * ONE_KB) 46*0Sstevel@tonic-gate #define NCA_IO_OFFSET (sizeof (nca_io2_t)) 47*0Sstevel@tonic-gate 48*0Sstevel@tonic-gate #define NCA_IO_TRUE 1 49*0Sstevel@tonic-gate #define NCA_IO_FALSE 0 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate /* 52*0Sstevel@tonic-gate * Defines the data structures used by NCA and Webservers. 53*0Sstevel@tonic-gate */ 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate typedef enum { 56*0Sstevel@tonic-gate /* 57*0Sstevel@tonic-gate * NCA-to-HTTP-server protocol operation values: 58*0Sstevel@tonic-gate */ 59*0Sstevel@tonic-gate http_op = 100, /* NCA<>HTTP normal request/response */ 60*0Sstevel@tonic-gate error_op = 101, /* NCA<-HTTP server error */ 61*0Sstevel@tonic-gate error_retry_op = 102, /* NCA<-HTTP server transient error */ 62*0Sstevel@tonic-gate resource_op = 120, /* NCA->HTTP server release resources */ 63*0Sstevel@tonic-gate timeout_op = 150, /* NCA<-HTTP server timed out */ 64*0Sstevel@tonic-gate door_attach_op = 160, /* NCA->HTTP NCA supports door fattach */ 65*0Sstevel@tonic-gate /* 66*0Sstevel@tonic-gate * NCA-to-Logging-server protocol operation values: 67*0Sstevel@tonic-gate */ 68*0Sstevel@tonic-gate log_op = 10000, /* NCA->Logger normal request */ 69*0Sstevel@tonic-gate log_ok_op = 10001, /* NCA<-Logger request ok */ 70*0Sstevel@tonic-gate log_error_op = 10002, /* NCA<-Logger request error */ 71*0Sstevel@tonic-gate log_op_fiov = 10003 /* NCA<>Logger file i/o vector */ 72*0Sstevel@tonic-gate } nca_op_t; 73*0Sstevel@tonic-gate 74*0Sstevel@tonic-gate typedef enum { 75*0Sstevel@tonic-gate NCA_HTTP_VERSION1 = 1001, /* NCA-to-HTTP-server protocol */ 76*0Sstevel@tonic-gate NCA_HTTP_VERSION2 = 1002, /* NCA-to-HTTP-server protocol V2 */ 77*0Sstevel@tonic-gate NCA_LOG_VERSION1 = 5001, /* NCA-to-Logging-server protocol */ 78*0Sstevel@tonic-gate NCA_LOG_VERSION2 = 5002 /* with in-kernel logging support */ 79*0Sstevel@tonic-gate /* 80*0Sstevel@tonic-gate * Note: Other version values are reserved for other client-to-server 81*0Sstevel@tonic-gate * Solaris door base protocols and as these protocols may or may not 82*0Sstevel@tonic-gate * be for use with NCA a new datatype (door_version_t ?) will be 83*0Sstevel@tonic-gate * defined. 84*0Sstevel@tonic-gate * 85*0Sstevel@tonic-gate * Note: NCA_HTTP_VERSION1 has been deprecated, NCA_HTTP_VERSION2 must 86*0Sstevel@tonic-gate * be used instead and is functionally a superset of (however, requires 87*0Sstevel@tonic-gate * porting as some member names and symantics have changed). 88*0Sstevel@tonic-gate */ 89*0Sstevel@tonic-gate } nca_version_t; 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate #define HTTP_ERR (-1) 92*0Sstevel@tonic-gate #define HTTP_0_0 0x00000 93*0Sstevel@tonic-gate #define HTTP_0_9 0x00009 94*0Sstevel@tonic-gate #define HTTP_1_0 0x10000 95*0Sstevel@tonic-gate #define HTTP_1_1 0x10001 96*0Sstevel@tonic-gate 97*0Sstevel@tonic-gate typedef uint32_t nca_tag_t; /* Request id */ 98*0Sstevel@tonic-gate typedef uint32_t nca_offset_t; /* Offset */ 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate /* 101*0Sstevel@tonic-gate * Use pack(4) to make sizeof(struct nca_direct_cd_s) the same 102*0Sstevel@tonic-gate * on x86 and amd64. 103*0Sstevel@tonic-gate */ 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 106*0Sstevel@tonic-gate #pragma pack(4) 107*0Sstevel@tonic-gate #endif 108*0Sstevel@tonic-gate 109*0Sstevel@tonic-gate typedef struct nca_direct_cd_s { /* Direct i/o connection descriptor */ 110*0Sstevel@tonic-gate uint64_t cid; /* The connection id */ 111*0Sstevel@tonic-gate nca_tag_t tag; /* The connect tag */ 112*0Sstevel@tonic-gate } nca_direct_cd_t; 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 115*0Sstevel@tonic-gate #pragma pack() 116*0Sstevel@tonic-gate #endif 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * nca_io2_t.advisory values: 120*0Sstevel@tonic-gate * 121*0Sstevel@tonic-gate * NCA_IO_ADVISE - on cache miss upcall/return or preempted downcall 122*0Sstevel@tonic-gate * advise that on susequent cache hit an advise upcall is required. 123*0Sstevel@tonic-gate * 124*0Sstevel@tonic-gate * NCA_IO_ADVISE_REPLACE - on advisory upcall/return or unsolicited 125*0Sstevel@tonic-gate * downcall (for a ctag'ed object) replace the object data with 126*0Sstevel@tonic-gate * returned object data. 127*0Sstevel@tonic-gate * 128*0Sstevel@tonic-gate * NCA_IO_ADVISE_FLUSH - on advisory upcall/return or unsolicited downcall 129*0Sstevel@tonic-gate * (for a ctag'ed object) flush the object from the cache. 130*0Sstevel@tonic-gate * 131*0Sstevel@tonic-gate * NCA_IO_ADVISE_TEMP - on advisory upcall/return use the returned object 132*0Sstevel@tonic-gate * data instead of the cached object data, the cached object is unaltered. 133*0Sstevel@tonic-gate * 134*0Sstevel@tonic-gate * NCA_IO_ADVISE_NONE - on cache miss upcall/return or preempted downcall 135*0Sstevel@tonic-gate * no advise is needed and on advisory upcall/return no advise was needed. 136*0Sstevel@tonic-gate */ 137*0Sstevel@tonic-gate #define NCA_IO_ADVISE 0x01 138*0Sstevel@tonic-gate #define NCA_IO_ADVISE_REPLACE 0x02 139*0Sstevel@tonic-gate #define NCA_IO_ADVISE_FLUSH 0x04 140*0Sstevel@tonic-gate #define NCA_IO_ADVISE_TEMP 0x08 141*0Sstevel@tonic-gate #define NCA_IO_ADVISE_NONE 0x00 142*0Sstevel@tonic-gate 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate /* 145*0Sstevel@tonic-gate * nca_io2_t.direct_type values: 146*0Sstevel@tonic-gate * 147*0Sstevel@tonic-gate * For upcall or downcall/return: 148*0Sstevel@tonic-gate * 149*0Sstevel@tonic-gate * NCA_IO_DIRECT_NONE - none, any data is delivered via the optional 150*0Sstevel@tonic-gate * meta data specifiers data/data_len and/or trailer/trailer_len. 151*0Sstevel@tonic-gate * 152*0Sstevel@tonic-gate * NCA_IO_DIRECT_FILENAME - file name, Invalid. 153*0Sstevel@tonic-gate * 154*0Sstevel@tonic-gate * NCA_IO_DIRECT_SHMSEG - shared memory segment, Invalid. 155*0Sstevel@tonic-gate * 156*0Sstevel@tonic-gate * NCA_IO_DIRECT_FILEDESC - file descriptor, Invalid. 157*0Sstevel@tonic-gate * 158*0Sstevel@tonic-gate * NCA_IO_DIRECT_CTAG - cache tag(s), like NCA_IO_DIRECT_NONE any data 159*0Sstevel@tonic-gate * is delivered via the meta data specifiers data/data_len, in addition 160*0Sstevel@tonic-gate * the meta data specifiers direct/direct_len point to an array of ctag 161*0Sstevel@tonic-gate * uint64_t value(s) of previously returned ctag'ed response(s) for URI 162*0Sstevel@tonic-gate * relative pathnamed variant(s). 163*0Sstevel@tonic-gate * 164*0Sstevel@tonic-gate * NCA_IO_DIRECT_SPLICE - splice of a connection is complete, on last 165*0Sstevel@tonic-gate * transaction for a connection (i.e. when both the call and return 166*0Sstevel@tonic-gate * nca_io2_t.more values are set to zero) indicates splice to the 167*0Sstevel@tonic-gate * previously named preempted connection is complete. 168*0Sstevel@tonic-gate * 169*0Sstevel@tonic-gate * NCA_IO_DIRECT_TEE - tee of a connection is complete, on last 170*0Sstevel@tonic-gate * transaction for a connection (i.e. when both the call and return 171*0Sstevel@tonic-gate * nca_io2_t.more values are set to zero) indicates tee to the 172*0Sstevel@tonic-gate * previously named connection is complete. 173*0Sstevel@tonic-gate * 174*0Sstevel@tonic-gate * For upcall/return or downcall: 175*0Sstevel@tonic-gate * 176*0Sstevel@tonic-gate * NCA_IO_DIRECT_NONE - none, any data is delivered via the optional 177*0Sstevel@tonic-gate * meta data specifiers data/data_len and/or trailer/trailer_len. 178*0Sstevel@tonic-gate * 179*0Sstevel@tonic-gate * NCA_IO_DIRECT_FILENAME - file name, data is read from the named file, 180*0Sstevel@tonic-gate * the meta data specifiers direct/direct_len point to a zero byte 181*0Sstevel@tonic-gate * terminated string containing the path to the named file. 182*0Sstevel@tonic-gate * 183*0Sstevel@tonic-gate * NCA_IO_DIRECT_SHMSEG - shared memory segment, not implemented. 184*0Sstevel@tonic-gate * 185*0Sstevel@tonic-gate * NCA_IO_DIRECT_FILEDESC - file descriptor, not implemented. 186*0Sstevel@tonic-gate * 187*0Sstevel@tonic-gate * NCA_IO_DIRECT_CTAG - cache tag, data is to be gotten from the named 188*0Sstevel@tonic-gate * ctag value (a previously returned ctag'ed response). 189*0Sstevel@tonic-gate * 190*0Sstevel@tonic-gate * NCA_IO_DIRECT_SPLICE - splice a connection, response data from the 191*0Sstevel@tonic-gate * current connection is output to the named connection (previously 192*0Sstevel@tonic-gate * preempted connection), the meta data specifiers direct/direct_len 193*0Sstevel@tonic-gate * point to a nca_direct_cd_t (a cid/tag pair connection descriptor) 194*0Sstevel@tonic-gate * used to specify the named connection. Note, no repsonse data is 195*0Sstevel@tonic-gate * delivered to the current connection. 196*0Sstevel@tonic-gate * 197*0Sstevel@tonic-gate * NCA_IO_DIRECT_TEE - tee a connection, response data from the current 198*0Sstevel@tonic-gate * connection is output to the named connection (previously preempted 199*0Sstevel@tonic-gate * connection), the meta data specifiers direct/direct_len point to a 200*0Sstevel@tonic-gate * nca_direct_cd_t (a cid/tag pair connection descriptor) used to 201*0Sstevel@tonic-gate * specify the named connection. Note, response data is delivered to 202*0Sstevel@tonic-gate * the current connection as normal. 203*0Sstevel@tonic-gate */ 204*0Sstevel@tonic-gate #define NCA_IO_DIRECT_NONE 0 205*0Sstevel@tonic-gate #define NCA_IO_DIRECT_FILENAME 1 206*0Sstevel@tonic-gate #define NCA_IO_DIRECT_SHMSEG 2 207*0Sstevel@tonic-gate #define NCA_IO_DIRECT_FILEDESC 3 208*0Sstevel@tonic-gate #define NCA_IO_DIRECT_CTAG 4 209*0Sstevel@tonic-gate #define NCA_IO_DIRECT_SPLICE 5 210*0Sstevel@tonic-gate #define NCA_IO_DIRECT_TEE 6 211*0Sstevel@tonic-gate #define NCA_IO_DIRECT_FILE_FD 7 212*0Sstevel@tonic-gate 213*0Sstevel@tonic-gate /* 214*0Sstevel@tonic-gate * NCA_HTTP_VERSION2 nca_io definition: 215*0Sstevel@tonic-gate */ 216*0Sstevel@tonic-gate typedef struct nca_io2_s { 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate nca_version_t version; /* version number */ 219*0Sstevel@tonic-gate nca_op_t op; /* type of operation */ 220*0Sstevel@tonic-gate nca_tag_t tag; /* connect tag */ 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gate uint32_t sid; /* server instance id */ 223*0Sstevel@tonic-gate uint64_t ctag; /* user cache tag */ 224*0Sstevel@tonic-gate 225*0Sstevel@tonic-gate uint64_t tid; /* caller's thread id */ 226*0Sstevel@tonic-gate uint64_t cid; /* connection id */ 227*0Sstevel@tonic-gate 228*0Sstevel@tonic-gate uint8_t more; /* more chunks to follow */ 229*0Sstevel@tonic-gate uint8_t first; /* first chunk for tag */ 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate uint8_t advisory; /* ask before using cache */ 232*0Sstevel@tonic-gate uint8_t nocache; /* don't cache */ 233*0Sstevel@tonic-gate 234*0Sstevel@tonic-gate uint8_t preempt; /* preempt subsequent upcall */ 235*0Sstevel@tonic-gate uint8_t direct_type; /* direct specifier type */ 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gate uint8_t shadow; /* flag used by kernel when copyin */ 238*0Sstevel@tonic-gate uint8_t pad2; /* padd to 32 bit align */ 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate uint32_t peer_len; /* sockaddr of client */ 241*0Sstevel@tonic-gate nca_offset_t peer; /* offset into meta data area */ 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate uint32_t local_len; /* sockaddr of NCA server */ 244*0Sstevel@tonic-gate nca_offset_t local; /* offset into meta data area */ 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate uint32_t data_len; /* request/response data */ 247*0Sstevel@tonic-gate nca_offset_t data; /* offset into meta data area */ 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate uint32_t direct_len; /* direct data specifier */ 250*0Sstevel@tonic-gate nca_offset_t direct; /* offset into meta data area */ 251*0Sstevel@tonic-gate 252*0Sstevel@tonic-gate uint32_t trailer_len; /* request/response trailer data */ 253*0Sstevel@tonic-gate nca_offset_t trailer; /* offset into meta data area */ 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gate /* 256*0Sstevel@tonic-gate * Following this structure is optional meta data, peer and local 257*0Sstevel@tonic-gate * sockaddr, (header) data, direct data, and trailer data. 258*0Sstevel@tonic-gate * 259*0Sstevel@tonic-gate * All nca_offset_t's above are byte offsets from the begining of 260*0Sstevel@tonic-gate * this structure. A meta data length specifier of zero indicates 261*0Sstevel@tonic-gate * no meta data. 262*0Sstevel@tonic-gate * 263*0Sstevel@tonic-gate * Request (i.e. in-bound) data is specified by the data_len/data 264*0Sstevel@tonic-gate * members only. 265*0Sstevel@tonic-gate * 266*0Sstevel@tonic-gate * Response (i.e. out-bound) data is specified by the data_len/data, 267*0Sstevel@tonic-gate * direct_type/direct_len/direct, trailer_len/trailer members and is 268*0Sstevel@tonic-gate * processed in-order. 269*0Sstevel@tonic-gate * 270*0Sstevel@tonic-gate * Note: sockaddr meta data are IPv4 addresses, future revisions 271*0Sstevel@tonic-gate * of the NCA-to-HTTP-server protocol will support IPv6. So, the 272*0Sstevel@tonic-gate * length of the sockaddr meta data must be honored as it will be 273*0Sstevel@tonic-gate * increased for future IPv6 support. 274*0Sstevel@tonic-gate */ 275*0Sstevel@tonic-gate 276*0Sstevel@tonic-gate } nca_io2_t; 277*0Sstevel@tonic-gate 278*0Sstevel@tonic-gate #define DOWNCALLINFO_MAGIC 0x19121969 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gate typedef struct downcallinfo_s { 281*0Sstevel@tonic-gate uint32_t dci_magic; 282*0Sstevel@tonic-gate nca_io2_t *dci_iop; 283*0Sstevel@tonic-gate uio_t *dci_uiop; 284*0Sstevel@tonic-gate } downcallinfo_t; 285*0Sstevel@tonic-gate 286*0Sstevel@tonic-gate typedef enum { 287*0Sstevel@tonic-gate NCA_UNKNOWN, 288*0Sstevel@tonic-gate NCA_OPTIONS, 289*0Sstevel@tonic-gate NCA_GET, 290*0Sstevel@tonic-gate NCA_HEAD, 291*0Sstevel@tonic-gate NCA_POST, 292*0Sstevel@tonic-gate NCA_PUT, 293*0Sstevel@tonic-gate NCA_DELETE, 294*0Sstevel@tonic-gate NCA_TRACE, 295*0Sstevel@tonic-gate 296*0Sstevel@tonic-gate NCA_RAW /* Special case for active connections */ 297*0Sstevel@tonic-gate } nca_http_method_t; 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gate typedef enum { 300*0Sstevel@tonic-gate HS_OK = 200, 301*0Sstevel@tonic-gate HS_CREATED = 201, 302*0Sstevel@tonic-gate HS_ACCEPTED = 202, 303*0Sstevel@tonic-gate HS_PARTIAL_CONTENT = 206, 304*0Sstevel@tonic-gate HS_MOVED_PERMANENT = 301, 305*0Sstevel@tonic-gate HS_MOVED = 302, 306*0Sstevel@tonic-gate HS_NOT_MODIFIED = 304, 307*0Sstevel@tonic-gate HS_BAD_REQUEST = 400, 308*0Sstevel@tonic-gate HS_AUTH_REQUIRED = 401, 309*0Sstevel@tonic-gate HS_FORBIDDEN = 403, 310*0Sstevel@tonic-gate HS_NOT_FOUND = 404, 311*0Sstevel@tonic-gate HS_PRECONDITION_FAILED = 412, 312*0Sstevel@tonic-gate HS_SERVER_ERROR = 500, 313*0Sstevel@tonic-gate HS_NOT_IMPLEMENTED = 501, 314*0Sstevel@tonic-gate HS_SERVICE_UNAVAILABLE = 503, 315*0Sstevel@tonic-gate HS_CONNECTION_CLOSED = 1000 316*0Sstevel@tonic-gate } nca_http_status_code; 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate /* httpd (miss user space daemon) is attached to this door */ 319*0Sstevel@tonic-gate #define MISS_DOOR_FILE "/var/run/nca_httpd_1.door" 320*0Sstevel@tonic-gate 321*0Sstevel@tonic-gate /* httpd downcall door server name */ 322*0Sstevel@tonic-gate #define DOWNCALL_DOOR_FILE "/var/run/nca_httpd_1.down_door" 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate #ifdef __cplusplus 325*0Sstevel@tonic-gate } 326*0Sstevel@tonic-gate #endif 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gate #endif /* _INET_NCADOORHDR_H */ 329