Grid Community Toolkit  6.2.1705709074 (tag: v6.2.20240202)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_i_gram_protocol.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
18 
24 #include "globus_common.h"
25 #include "globus_gram_protocol.h"
26 #include "globus_io.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /* Strings used in protocol framing, packing, unframing, and unpacking */
33 
34 #define CRLF "\015\012"
35 #define GLOBUS_GRAM_HTTP_REQUEST_LINE \
36  "POST %s HTTP/1.1" CRLF
37 
38 #define GLOBUS_GRAM_HTTP_HOST_LINE \
39  "Host: %s" CRLF
40 
41 #define GLOBUS_GRAM_HTTP_CONTENT_TYPE_LINE \
42  "Content-Type: application/x-globus-gram" CRLF
43 
44 #define GLOBUS_GRAM_HTTP_CONTENT_LENGTH_LINE \
45  "Content-Length: %ld" CRLF
46 
47 #define GLOBUS_GRAM_HTTP_REPLY_LINE \
48  "HTTP/1.1 %3d %s" CRLF
49 #define GLOBUS_GRAM_HTTP_PARSE_REPLY_LINE \
50  "HTTP/1.1 %3d %[^" CRLF "]" CRLF
51 #define GLOBUS_GRAM_HTTP_CONNECTION_LINE \
52  "Connection: Close" CRLF
53 
54 #define GLOBUS_GRAM_HTTP_PACK_PROTOCOL_VERSION_LINE \
55  "protocol-version: %d" CRLF
56 
57 #define GLOBUS_GRAM_HTTP_PACK_JOB_STATE_MASK_LINE \
58  "job-state-mask: %d" CRLF
59 
60 #define GLOBUS_GRAM_HTTP_PACK_CALLBACK_URL_LINE \
61  "callback-url: %s" CRLF
62 
63 #define GLOBUS_GRAM_HTTP_PACK_STATUS_LINE \
64  "status: %d" CRLF
65 
66 #define GLOBUS_GRAM_HTTP_PACK_FAILURE_CODE_LINE \
67  "failure-code: %d" CRLF
68 
69 #define GLOBUS_GRAM_HTTP_PACK_JOB_FAILURE_CODE_LINE \
70  "job-failure-code: %d" CRLF
71 
72 #define GLOBUS_GRAM_HTTP_PACK_JOB_MANAGER_URL_LINE \
73  "job-manager-url: %s" CRLF
74 
75 #define GLOBUS_GRAM_HTTP_PACK_CLIENT_REQUEST_LINE \
76  "%s" CRLF
77 
78 #define GLOBUS_GRAM_ATTR_PROTOCOL_VERSION "protocol-version"
79 #define GLOBUS_GRAM_ATTR_JOB_STATE_MASK "job-state-mask"
80 #define GLOBUS_GRAM_ATTR_CALLBACK_URL "callback-url"
81 #define GLOBUS_GRAM_ATTR_RSL "rsl"
82 #define GLOBUS_GRAM_ATTR_STATUS "status"
83 #define GLOBUS_GRAM_ATTR_JOB_MANAGER_URL "job-manager-url"
84 #define GLOBUS_GRAM_ATTR_FAILURE_CODE "failure-code"
85 typedef enum
86 {
87  GLOBUS_GRAM_PROTOCOL_REQUEST,
88  GLOBUS_GRAM_PROTOCOL_REPLY
89 }
90 globus_gram_protocol_read_type_t;
91 
92 typedef struct
93 {
94  unsigned short port;
95  globus_bool_t allow_attach;
96  globus_io_handle_t * handle;
97  globus_gram_protocol_callback_t callback;
98  void * callback_arg;
99  volatile int connection_count;
100  globus_cond_t cond;
101  globus_bool_t listen_registered;
102 }
103 globus_i_gram_protocol_listener_t;
104 
105 typedef struct
106 {
107  globus_bool_t got_header;
108  globus_bool_t accepting;
109  globus_byte_t * buf;
110  globus_size_t bufsize;
111  globus_gram_protocol_read_type_t read_type;
112  globus_size_t payload_length;
113  globus_size_t n_read;
114  globus_gram_protocol_callback_t callback;
115  void * callback_arg;
116  globus_byte_t * replybuf;
117  globus_size_t replybufsize;
118 
119  globus_io_handle_t * io_handle;
121  globus_i_gram_protocol_listener_t * listener;
122  int rc;
123  char * uri;
124 
125  /* added for delegation support */
126  globus_bool_t keep_open;
127  globus_size_t token_length;
128  globus_gram_protocol_delegation_callback_t
129  delegation_callback;
130  OM_uint32 delegation_major_status;
131  OM_uint32 delegation_minor_status;
132  void * delegation_arg;
133  gss_cred_id_t delegation_cred;
134  gss_OID_set delegation_restriction_oids;
135  gss_buffer_set_t delegation_restriction_buffers;
136  OM_uint32 delegation_req_flags;
137  OM_uint32 delegation_time_req;
138  gss_buffer_desc delegation_input_token;
139  gss_buffer_desc delegation_output_token;
140 
141  /* added for gram authz callout support */
142 
143  gss_ctx_id_t context;
144 }
145 globus_i_gram_protocol_connection_t;
146 
147 int
148 globus_i_gram_protocol_callback_disallow(
149  globus_i_gram_protocol_listener_t * listener);
150 
151 void
152 globus_i_gram_protocol_error_hack_replace_message(
153  int error_code,
154  const char * message);
155 
156 void
157 globus_i_gram_protocol_error_destroy(
158  void * arg);
159 
160 extern globus_mutex_t globus_i_gram_protocol_mutex;
161 extern globus_cond_t globus_i_gram_protocol_cond;
162 
163 extern globus_list_t * globus_i_gram_protocol_listeners;
164 extern globus_list_t * globus_i_gram_protocol_connections;
165 extern globus_list_t * globus_i_gram_protocol_old_creds;
166 extern globus_bool_t globus_i_gram_protocol_shutdown_called;
167 extern globus_io_attr_t globus_i_gram_protocol_default_attr;
168 extern int globus_i_gram_protocol_num_connects;
169 extern int globus_i_gram_protocol_max_concurrency;
170 extern globus_gram_protocol_handle_t globus_i_gram_protocol_handle;
171 extern globus_thread_key_t globus_i_gram_protocol_error_key;
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */
int globus_bool_t
Boolean type.
Definition: globus_types.h:93
unsigned long globus_gram_protocol_handle_t
Unique GRAM protocol identifier.
Definition: globus_gram_protocol.h:73
List data type.
Definition: globus_list.h:44
Mutex.
Definition: globus_thread.h:107
Condition variable.
Definition: globus_thread.h:124
size_t globus_size_t
Standard size of memory objectThe globus_size_t is the size of a memory object. It is identical to si...
Definition: globus_types.h:48
unsigned char globus_byte_t
Unsigned byte datatypeThis is used for byte-addressable arrays of arbitrary data which is not subject...
Definition: globus_types.h:85
Thread-specific data key.
Definition: globus_thread.h:201
Headers common to all of Globus.
GRAM Protocol API.