1 /* 2 * CDDL HEADER START 3 * 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. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _LX_THUNK_SERVER_H 28 #define _LX_THUNK_SERVER_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <netdb.h> 37 #include <procfs.h> 38 39 /* 40 * Binary that should be exec'd to start up the thunking server 41 */ 42 #define LXT_SERVER_BINARY "/native/usr/lib/brand/lx/lx_thunk" 43 44 /* 45 * When the thunking server is started it will need to communicate 46 * to the client via two fifos. These fifos will be passed to the 47 * thunking server via the following file descriptors: 48 */ 49 #define LXT_SERVER_FIFO_RD_FD 3 50 #define LXT_SERVER_FIFO_WR_FD 4 51 52 /* 53 * Operations supported by the thunking server 54 */ 55 #define LXT_SERVER_OP_MIN 0 56 #define LXT_SERVER_OP_PING 0 57 #define LXT_SERVER_OP_NAME2HOST 1 58 #define LXT_SERVER_OP_ADDR2HOST 2 59 #define LXT_SERVER_OP_NAME2SERV 3 60 #define LXT_SERVER_OP_PORT2SERV 4 61 #define LXT_SERVER_OP_OPENLOG 5 62 #define LXT_SERVER_OP_SYSLOG 6 63 #define LXT_SERVER_OP_CLOSELOG 7 64 #define LXT_SERVER_OP_MAX 8 65 66 /* 67 * Macros used to translate pointer into offsets for when they are 68 * being transmitted between the client and server processes. 69 * 70 * NOTE: We're going to add 1 to every offset value. The reason 71 * for this is that some of the pointers we're converting to offsets are 72 * stored in NULL terminated arrays, and if one of the members of 73 * one of these arrays happened to be at the beginning of the storage 74 * buffer it would have an offset of 0 and when the client tries to 75 * translate the offsets back into pointers it wouldn't be able 76 * to differentiate between the 0 offset from the end of the array. 77 */ 78 #define LXT_PTR_TO_OFFSET(ptr, base) \ 79 ((void *)((uintptr_t)(ptr) - (uintptr_t)(base) + 1)) 80 #define LXT_OFFSET_TO_PTR(offset, base) \ 81 ((void *)((uintptr_t)(offset) + (uintptr_t)(base) - 1)) 82 83 /* 84 * Structures passed to the thunking server via door calls 85 */ 86 typedef struct lxt_server_arg { 87 int lxt_sa_op; 88 int lxt_sa_success; 89 int lxt_sa_errno; 90 char lxt_sa_data[1]; 91 } lxt_server_arg_t; 92 93 typedef struct lxt_gethost_arg { 94 struct hostent lxt_gh_result; 95 96 int lxt_gh_h_errno; 97 98 int lxt_gh_type; 99 int lxt_gh_token_len; 100 int lxt_gh_buf_len; 101 102 int lxt_gh_storage_len; 103 char lxt_gh_storage[1]; 104 } lxt_gethost_arg_t; 105 106 typedef struct lxt_getserv_arg { 107 struct servent lxt_gs_result; 108 109 int lxt_gs_token_len; 110 int lxt_gs_buf_len; 111 char lxt_gs_proto[5]; 112 113 int lxt_gs_storage_len; 114 char lxt_gs_storage[1]; 115 } lxt_getserv_arg_t; 116 117 typedef struct lxt_openlog_arg { 118 int lxt_ol_logopt; 119 int lxt_ol_facility; 120 char lxt_ol_ident[128]; 121 } lxt_openlog_arg_t; 122 123 typedef struct lxt_syslog_arg { 124 int lxt_sl_priority; 125 pid_t lxt_sl_pid; 126 char lxt_sl_progname[PRFNSZ]; 127 char lxt_sl_message[1024]; 128 } lxt_syslog_arg_t; 129 130 131 /* 132 * Functions called by the brand library to manage startup of the 133 * thunk server process. 134 */ 135 void lxt_server_init(int, char *[]); 136 int lxt_server_pid(int *pid); 137 void lxt_server_exec_check(void); 138 139 #ifdef __cplusplus 140 } 141 #endif 142 143 #endif /* _LX_THUNK_SERVER_H */