globus_connect_gridftp_server  17.0~rc3
/build/globus-connect-gridftp-server-17.0~rc3/globus_gridftp_server.h
Go to the documentation of this file.
1 /*
2  * Copyright The University of Chicago
3  *
4  * All Rights Reserved.
5  */
6 
7 
19 #ifndef GLOBUS_GRIDFTP_SERVER_H
20 #define GLOBUS_GRIDFTP_SERVER_H
21 
22 #include "globus_common.h"
23 #include "globus_error.h"
24 #include "globus_gridftp_server_control.h"
25 
26 #ifdef TARGET_ARCH_WIN32
27 #ifdef interface
28 #undef interface
29 #endif
30 #endif
31 
32 #ifndef TARGET_ARCH_WIN32
33 #include <grp.h>
34 #endif
35 
36 #define GLOBUS_MAPPING_STRING ":globus-mapping:"
37 
38 extern globus_module_descriptor_t globus_i_gfs_module;
39 #define GLOBUS_GRIDFTP_SERVER_MODULE (&globus_i_gfs_module)
40 
41 extern globus_extension_registry_t globus_i_gfs_dsi_registry;
42 #define GLOBUS_GFS_DSI_REGISTRY &globus_i_gfs_dsi_registry
43 
44 extern globus_extension_registry_t globus_i_gfs_acl_registry;
45 #define GLOBUS_GFS_ACL_REGISTRY &globus_i_gfs_acl_registry
46 
47 /*
48  * globus_gfs_error_type_t
49  *
50  */
51 typedef enum globus_gfs_error_type_e
52 {
53  GLOBUS_GFS_ERROR_MEMORY = 1,
54  GLOBUS_GFS_ERROR_PARAMETER,
55  GLOBUS_GFS_ERROR_SYSTEM_ERROR,
56  GLOBUS_GFS_ERROR_WRAPPED,
57  GLOBUS_GFS_ERROR_DATA,
58  GLOBUS_GFS_ERROR_GENERIC
59 } globus_gfs_error_type_t;
60 
61 /*
62  * globus_gfs_operation_type_t
63  *
64  * Server operations.
65  */
66 typedef enum globus_gfs_operation_type_e
67 {
68  GLOBUS_GFS_OP_FINAL_REPLY = 1,
69  GLOBUS_GFS_OP_EVENT_REPLY,
70  GLOBUS_GFS_OP_EVENT,
71  GLOBUS_GFS_OP_SESSION_START,
72  GLOBUS_GFS_OP_SESSION_STOP,
73  GLOBUS_GFS_OP_RECV,
74  GLOBUS_GFS_OP_SEND,
75  GLOBUS_GFS_OP_LIST,
76  GLOBUS_GFS_OP_COMMAND,
77  GLOBUS_GFS_OP_PASSIVE,
78  GLOBUS_GFS_OP_ACTIVE,
79  GLOBUS_GFS_OP_DESTROY,
80  GLOBUS_GFS_OP_TRANSFER,
81  GLOBUS_GFS_OP_STAT,
82  GLOBUS_GFS_OP_BUFFER_SEND,
83  GLOBUS_GFS_OP_HANDSHAKE,
84  GLOBUS_GFS_OP_SESSION_START_REPLY,
85  GLOBUS_GFS_OP_INTERMEDIATE_REPLY
86 } globus_gfs_operation_type_t;
87 
88 #define GLOBUS_GFS_OP_STAT_PARTIAL GLOBUS_GFS_OP_INTERMEDIATE_REPLY
89 
90 /*
91  * globus_gfs_command_type_t
92  *
93  * Command types. Commands are generally simple filesystem operations
94  * that only return success/failure and at most a single string.
95  */
96 typedef enum globus_gfs_command_type_e
97 {
98  GLOBUS_GFS_CMD_MKD = 1,
99  GLOBUS_GFS_CMD_RMD,
100  GLOBUS_GFS_CMD_DELE,
101  GLOBUS_GFS_CMD_SITE_AUTHZ_ASSERT,
102  GLOBUS_GFS_CMD_SITE_RDEL,
103  GLOBUS_GFS_CMD_RNTO,
104  GLOBUS_GFS_CMD_RNFR,
105  GLOBUS_GFS_CMD_CKSM,
106  GLOBUS_GFS_CMD_SITE_CHMOD,
107  GLOBUS_GFS_CMD_SITE_DSI,
108  GLOBUS_GFS_CMD_SITE_SETNETSTACK,
109  GLOBUS_GFS_CMD_SITE_SETDISKSTACK,
110  GLOBUS_GFS_CMD_SITE_CLIENTINFO,
111  GLOBUS_GFS_CMD_DCSC,
112  GLOBUS_GFS_CMD_SITE_CHGRP,
113  GLOBUS_GFS_CMD_SITE_UTIME,
114  GLOBUS_GFS_CMD_SITE_SYMLINKFROM,
115  GLOBUS_GFS_CMD_SITE_SYMLINK,
116  GLOBUS_GFS_CMD_HTTP_PUT,
117  GLOBUS_GFS_CMD_HTTP_GET,
118  GLOBUS_GFS_CMD_HTTP_CONFIG,
119  GLOBUS_GFS_CMD_TRNC,
120  GLOBUS_GFS_CMD_SITE_TASKID,
121 
122  /* handled internally */
123  GLOBUS_GFS_CMD_SITE_RESTRICT = 3072,
124  GLOBUS_GFS_CMD_SITE_CHROOT,
125  GLOBUS_GFS_CMD_SITE_SHARING,
126  GLOBUS_GFS_CMD_UPAS,
127  GLOBUS_GFS_CMD_UPRT,
128  GLOBUS_GFS_CMD_STORATTR,
129  GLOBUS_GFS_CMD_WHOAMI,
130 
131  GLOBUS_GFS_MIN_CUSTOM_CMD = 4096
132 } globus_gfs_command_type_t;
133 
154 {
158 
161 
165 
169 
174 
179 
184 
187 
190 
192  GLOBUS_GFS_EVENT_ALL = 0xFFFF
194 
195 /*
196  * globus_gfs_buffer_type_t
197  *
198  */
199 typedef enum globus_gfs_buffer_type_e
200 {
201  GLOBUS_GFS_BUFFER_EOF_INFO = 0x0001,
202  GLOBUS_GFS_BUFFER_SERVER_DEFINED = 0xFFFF
203  /* user defined types will start at 0x00010000 */
204 } globus_gfs_buffer_type_t;
205 
206 /*
207  * globus_gfs_layout_type_t
208  *
209  * Striped layout types.
210  */
211 typedef enum globus_gfs_layout_type_e
212 {
213  GLOBUS_GFS_LAYOUT_PARTITIONED = 1,
214  GLOBUS_GFS_LAYOUT_BLOCKED
215 } globus_gfs_layout_type_t;
216 
217 /*
218  * globus_gfs_stat_t
219  *
220  * Similar to a posix struct stat. Defined in the server-lib.
221  *
222  * (this comment should not be relied upon, so check the
223  * definition in globus_gridftp_server_control.h to be sure)
224  *
225  * typedef struct globus_gridftp_server_control_stat_s
226  * {
227  * int mode;
228  * int nlink;
229  * char * name;
230  * char * symlink_target;
231  * uid_t uid;
232  * gid_t gid;
233  * globus_off_t size;
234  * globus_time_t atime;
235  * globus_time_t ctime;
236  * globus_time_t mtime;
237  * int dev;
238  * int ino;
239  * } globus_gridftp_server_control_stat_t;
240  */
242 
243 /*
244  * globus_gfs_stat_ext_t
245  *
246  * A stat entry plus the data globus_gfs_stat_t has no room for, passed to
247  * globus_gridftp_server_finished_stat_ext(). globus_gfs_stat_t cannot grow,
248  * because DSIs allocate arrays of it. This struct can: new members are only
249  * added at the end, and the DSI passes sizeof(globus_gfs_stat_ext_t) as it
250  * was compiled, so the server reads only the members that DSI knows about.
251  */
252 typedef struct globus_gfs_stat_ext_s
253 {
254  globus_gfs_stat_t stat;
255  /* extra MLSx facts for this entry, or NULL: "name=value;name=value;"
256  * with URL-encoded values, for example "X.foo=1;X.bar=abc;". Only
257  * facts declared with globus_gridftp_server_set_mlst_facts() and
258  * selected by the client are sent, in MLST and MLSC replies (MLSD
259  * and MLSR do not carry them). The server copies it. */
260  char * facts;
261 } globus_gfs_stat_ext_t;
262 
263 
264 /*
265  * globus_gfs_operation_info_t
266  *
267  * Internal operation info. This handle is passed with the info structs
268  * Its data should not be accessed.
269  */
270 typedef struct globus_i_gfs_op_info_s * globus_gfs_op_info_t;
271 
272 /*
273  * globus_gfs_data_finished_info_t
274  *
275  * Contains specific result info for an active or passive data connection.
276  * Note that in most cases this info will simply be passed.
277  */
278 typedef struct globus_gfs_data_finished_info_s
279 {
281  void * data_arg;
283  globus_bool_t bi_directional;
285  globus_bool_t ipv6;
287  int cs_count;
289  const char ** contact_strings;
290 } globus_gfs_data_finished_info_t;
291 
292 /*
293  * globus_gfs_cmd_finshed_info_t
294  *
295  * Contains specific result info for commands.
296  */
297 typedef struct globus_gfs_cmd_finshed_info_s
298 {
300  globus_gfs_command_type_t command;
302  char * checksum;
304  char * created_dir;
305 } globus_gfs_cmd_finshed_info_t;
306 
307 /*
308  * globus_gfs_stat_finished_info_t
309  *
310  * Contains specific result info for a stat.
311  */
312 typedef struct globus_gfs_stat_finished_info_s
313 {
315  int uid;
317  int gid_count;
319  int * gid_array;
321  int stat_count;
323  globus_gfs_stat_t * stat_array;
324 } globus_gfs_stat_finished_info_t;
325 
326 /*
327  * globus_gfs_session_finished_info_t
328  *
329  * Contains specific result info for a stat.
330  */
331 typedef struct globus_gfs_session_finished_info_s
332 {
334  void * session_arg;
336  char * username;
338  char * home_dir;
339 } globus_gfs_session_finished_info_t;
340 
341 /*
342  * globus_gfs_session_finished_info_t
343  *
344  * Contains specific result info for a stat.
345  */
346 typedef struct globus_gfs_transfer_finished_info_s
347 {
348  /* total bytes transferred for this operation */
349  globus_off_t bytes_transferred;
350 
351 } globus_gfs_transfer_finished_info_t;
352 
353 /*
354  * globus_gfs_finished_info_t
355  *
356  * Final result info for an operation.
357  */
358 typedef struct globus_gfs_finished_info_s
359 {
361  globus_gfs_operation_type_t type;
363  int id;
365  int code;
368  char * msg;
370  globus_result_t result;
371 
372  union
373  {
374  globus_gfs_session_finished_info_t session;
375  globus_gfs_data_finished_info_t data;
376  globus_gfs_cmd_finshed_info_t command;
377  globus_gfs_stat_finished_info_t stat;
378  globus_gfs_transfer_finished_info_t transfer;
379  } info;
380 
382  globus_gfs_op_info_t op_info;
383 } globus_gfs_finished_info_t;
384 
385 /*
386  * globus_gfs_event_info_t
387  *
388  * Event info.
389  */
390 typedef struct globus_gfs_event_info_s
391 {
394 
397  void * event_arg;
398 
399  /* reply data */
401  int node_ndx;
403  int id;
405  int event_mask;
407  globus_off_t recvd_bytes;
409  globus_range_list_t recvd_ranges;
411  void * data_arg;
412 
413  /* request data */
415  int * eof_count;
417  int node_count;
418 
420  globus_gfs_op_info_t op_info;
421 } globus_gfs_event_info_t;
422 
423 /*
424  * globus_gfs_transfer_info_t
425  *
426  * Info needed for transfer operations (list, send, recv).
427  */
428 typedef struct globus_gfs_transfer_info_s
429 {
431  char * pathname;
433  char * module_name;
434  char * module_args;
436  char * list_type;
437 
439  globus_off_t partial_offset;
441  globus_off_t partial_length;
443  globus_range_list_t range_list;
445  globus_bool_t truncate;
446 
448  void * data_arg;
450  int eof_count;
452  int stripe_count;
454  int node_count;
456  int node_ndx;
457 
459  globus_off_t alloc_size;
460 
462  char * expected_checksum;
464  char * expected_checksum_alg;
465 
467  int list_depth;
469  int traversal_options;
470 
472  globus_gfs_op_info_t op_info;
473 } globus_gfs_transfer_info_t;
474 
475 
476 /*
477 * maintain backward source compatibility after member rename
478 */
479 #define rnfr_pathname from_pathname
480 
481 /*
482  * globus_gfs_command_info_t
483  *
484  * Info needed for a command operation.
485  */
486 typedef struct globus_gfs_command_info_s
487 {
489  globus_gfs_command_type_t command;
491  char * pathname;
492 
494  globus_off_t cksm_offset;
496  globus_off_t cksm_length;
498  char * cksm_alg;
499 
501  int chmod_mode;
502 
505  char * from_pathname;
506 
508  char * authz_assert;
509 
511  char * chgrp_group;
512 
514  time_t utime_time;
515 
517  globus_gfs_op_info_t op_info;
518 } globus_gfs_command_info_t;
519 
520 /*
521  * globus_gfs_data_info_t
522  *
523  * Info needed for data operations (active, passive).
524  */
525 typedef struct globus_gfs_data_info_s
526 {
528  globus_bool_t ipv6;
530  int nstreams;
532  char mode;
534  char type;
536  globus_size_t tcp_bufsize;
538  globus_size_t blocksize;
540  globus_size_t stripe_blocksize;
542  int stripe_layout;
543 
545  char prot;
547  char dcau;
549  char * subject;
551  char * pathname;
552 
554  int max_cs;
556  int cs_count;
558  const char ** contact_strings;
560  char * interface;
561 
562  /* if this is set, the data channel will use it instead
563  of the default session credential */
564  gss_cred_id_t del_cred;
565 
567  globus_gfs_op_info_t op_info;
568 } globus_gfs_data_info_t;
569 
570 /*
571  * globus_gfs_stat_info_t
572  *
573  * Info needed for a stat operation.
574  */
575 typedef struct globus_gfs_stat_info_s
576 {
578  globus_bool_t file_only;
580  globus_bool_t internal;
582  char * pathname;
584  globus_bool_t use_symlink_info;
586  globus_bool_t include_path_stat;
587 
589  globus_gfs_op_info_t op_info;
590 } globus_gfs_stat_info_t;
591 
592 typedef struct globus_gfs_session_info_s
593 {
594  gss_cred_id_t del_cred;
595  globus_bool_t free_cred;
596  globus_bool_t map_user;
597  char * username;
598  char * password;
599  char * subject;
600  char * cookie;
601  char * host_id;
602 
604  globus_gfs_op_info_t op_info;
605 } globus_gfs_session_info_t;
606 
607 typedef enum globus_gfs_brain_reason_e
608 {
609  GLOBUS_GFS_BRAIN_REASON_ERROR = 1,
610  GLOBUS_GFS_BRAIN_REASON_COMPLETE
611 } globus_gfs_brain_reason_t;
612 
613 typedef struct globus_i_gfs_brain_node_s
614 {
615  char * host_id;
616  char * repo_name;
617  void * brain_arg;
618  int max_connection;
619  int current_connection;
620  float load;
621 } globus_i_gfs_brain_node_t;
622 
623 /**************************************************************************
624  * Storage Module API
625  *
626  * The storage module API is made up of the interface definition,
627  * notification functions, and helper functions below.
628  *************************************************************************/
629 
630 /*
631  * globus_gfs_operation_t
632  *
633  * Operation handle. This handle is passed to and from the storage
634  * module. Its internal data should not be used.
635  */
636 typedef struct globus_l_gfs_data_operation_s * globus_gfs_operation_t;
637 
638 
639 typedef void * globus_gfs_session_config_t;
640 
645 /*
646  * init/destroy
647  *
648  * This will be called upon a new client session. Any persistent
649  * data that will be needed should be initialized and stored in a
650  * user-defined object which should be assigned to out_user_arg. This
651  * object pointer will then be passed back to the module with any other
652  * interface call.
653  */
654 typedef void
656  globus_gfs_operation_t op,
657  globus_gfs_session_info_t * session_info);
658 
659 /*
660  * This will be called when the client session ends. Final cleanup
661  * should be done here.
662  */
663 typedef void
664 (*globus_gfs_storage_destroy_t)(
665  void * user_arg);
666 
667 /*
668  * transfer
669  *
670  * This defines the functions that will be called for list, send, and recv.
671  */
672 typedef void
673 (*globus_gfs_storage_transfer_t)(
674  globus_gfs_operation_t op,
675  globus_gfs_transfer_info_t * transfer_info,
676  void * user_arg);
677 
678 /*
679  * command
680  *
681  * This defines the function that will be called for commands. The type
682  * member of command_info specifies which command to carry out.
683  */
684 typedef void
685 (*globus_gfs_storage_command_t)(
686  globus_gfs_operation_t op,
687  globus_gfs_command_info_t * command_info,
688  void * user_arg);
689 
690 /*
691  * stat
692  *
693  * This defines the function that will be called for a stat lookup.
694  */
695 typedef void
696 (*globus_gfs_storage_stat_t)(
697  globus_gfs_operation_t op,
698  globus_gfs_stat_info_t * stat_info,
699  void * user_arg);
700 
701 /*
702  * data connection
703  *
704  * This defines the functions that will be called for active and passive
705  * data connection creation.
706  */
707 typedef void
708 (*globus_gfs_storage_data_t)(
709  globus_gfs_operation_t op,
710  globus_gfs_data_info_t * data_info,
711  void * user_arg);
712 
713 /*
714  * data_destroy
715  *
716  * This defines the function that will be called to signal that a data
717  * connection should be destroyed. Note that there is no corresponding
718  * finished notification for data destroy requests.
719  */
720 typedef void
721 (*globus_gfs_storage_data_destroy_t)(
722  void * data_arg,
723  void * user_arg);
724 
725 /*
726  * data_destroy
727  *
728  * This defines the function that will be called to signal that a transfer
729  * event should occur. Note that there is no corresponding finished
730  * notification for transfer event requests.
731  */
732 typedef void
733 (*globus_gfs_storage_trev_t)(
734  globus_gfs_event_info_t * event_info,
735  void * user_arg);
736 
737 /*
738  * set cred
739  *
740  * This defines the function that will be called to pass delegated credentials.
741  * XXX more here later XXX
742  */
743 typedef void
744 (*globus_gfs_storage_set_cred_t)(
745  gss_cred_id_t del_cred,
746  void * user_arg);
747 
748 /*
749  * send user buffer
750  *
751  * This defines the function that will be called to send a user defined buffer.
752  * XXX more here later XXX
753  */
754 typedef void
755 (*globus_gfs_storage_buffer_send_t)(
756  int buffer_type,
757  globus_byte_t * buffer,
758  globus_size_t buffer_len,
759  void * user_arg);
760 
761 
762 /*
763  * realpath
764  *
765  * This defines the function that will be called to determine a true path
766  * free of symlinks or other obsfucation.
767  * if you implement this, add GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH to your
768  * globus_gfs_storage_iface_t interface definition.
769  */
770 
771 typedef globus_result_t
772 (*globus_gfs_storage_realpath_t)(
773  const char * in_path,
774  char ** out_realpath,
775  void * user_arg);
776 
777 
778 #define GLOBUS_GFS_DSI_DESCRIPTOR_SENDER (1 << 0)
779 #define GLOBUS_GFS_DSI_DESCRIPTOR_BLOCKING (1 << 1)
780 #define GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH (1 << 2)
781 #define GLOBUS_GFS_DSI_DESCRIPTOR_REQUIRES_ORDERED_DATA (1 << 3)
782 #define GLOBUS_GFS_DSI_DESCRIPTOR_SETS_ERROR_RESPONSES (1 << 4)
783 #define GLOBUS_GFS_DSI_DESCRIPTOR_SAFE_RDEL (1 << 5)
784 #define GLOBUS_GFS_DSI_DESCRIPTOR_USERNAME_INCLUDES_DOMAIN (1 << 6)
785 #define GLOBUS_GFS_DSI_DESCRIPTOR_DYN_SENDER (1 << 7)
786 #define GLOBUS_GFS_DSI_DESCRIPTOR_SIZE_NOT_REQUIRED (1 << 8)
787 /*
788  * globus_gfs_storage_iface_t
789  *
790  * Storage interface function pointers. Only define functions that are
791  * implemented. If a function is not defined, the server will either fail
792  * for that particular operation, or in the case of list, data, cred, and
793  * trev funcs, the server will act on those operations itself.
794  */
795 typedef struct globus_gfs_storage_iface_s
796 {
797  int descriptor;
798 
799  /* session initiating functions */
800  globus_gfs_storage_init_t init_func;
801  globus_gfs_storage_destroy_t destroy_func;
802 
803  /* transfer functions */
804  globus_gfs_storage_transfer_t list_func;
805  globus_gfs_storage_transfer_t send_func;
806  globus_gfs_storage_transfer_t recv_func;
807  globus_gfs_storage_trev_t trev_func;
808 
809  /* data conn funcs */
810  globus_gfs_storage_data_t active_func;
811  globus_gfs_storage_data_t passive_func;
812  globus_gfs_storage_data_destroy_t data_destroy_func;
813 
814  globus_gfs_storage_command_t command_func;
815  globus_gfs_storage_stat_t stat_func;
816 
817  globus_gfs_storage_set_cred_t set_cred_func;
818  globus_gfs_storage_buffer_send_t buffer_send_func;
819  globus_gfs_storage_realpath_t realpath_func;
820 } globus_gfs_storage_iface_t;
821 
826 /*
827  * operation finished
828  *
829  * This is a generic finished notification function. Either this *or* a
830  * specific finished function below must be called upon completion of an
831  * operation with the appropriate data set in the finished_info struct,
832  * including error info if the operation failed.
833  */
834 void
836  globus_gfs_operation_t op,
837  globus_result_t result,
838  globus_gfs_finished_info_t * finished_info);
839 
840 /*
841  * operation event
842  *
843  * This is a generic event notification function. Either this *or* a
844  * specific event function below must be called upon completion of an
845  * operation with the appropriate event data set in the event_info struct.
846  */
847 void
848 globus_gridftp_server_operation_event(
849  globus_gfs_operation_t op,
850  globus_result_t result,
851  globus_gfs_event_info_t * event_info);
852 
853 /*
854  * begin transfer event
855  *
856  * Speficic event notification for the start of a transfer.
857  */
858 void
859 globus_gridftp_server_begin_transfer(
860  globus_gfs_operation_t op,
861  int event_mask,
862  void * event_arg);
863 
864 /*
865  * finished transfer
866  *
867  * Speficic finished notification for completion of a transfer.
868  */
869 void
870 globus_gridftp_server_finished_transfer(
871  globus_gfs_operation_t op,
872  globus_result_t result);
873 
874 /*
875  * finished session_start
876  *
877  * Specific finished notification for session start completion.
878  *
879  */
880 void
881 globus_gridftp_server_finished_session_start(
882  globus_gfs_operation_t op,
883  globus_result_t result,
884  void * session_arg,
885  char * username,
886  char * home_dir);
887 
888 /*
889  * finished command
890  *
891  * Speficic finished notification for completion of a command.
892  * command_response should be NULL if not used (currently only
893  * used in MKD and CKSM)
894  */
895 void
896 globus_gridftp_server_finished_command(
897  globus_gfs_operation_t op,
898  globus_result_t result,
899  char * command_response);
900 void
901 globus_gridftp_server_intermediate_command(
902  globus_gfs_operation_t op,
903  globus_result_t result,
904  char * command_response);
905 
906 /*
907  * finished stat
908  *
909  * Speficic finished notification for completion of a stat.
910  */
911 void
912 globus_gridftp_server_finished_stat(
913  globus_gfs_operation_t op,
914  globus_result_t result,
915  globus_gfs_stat_t * stat_array,
916  int stat_count);
917 
932 globus_result_t
934  globus_gfs_operation_t op,
935  const char * fact_names);
936 
946 void
948  globus_gfs_operation_t op,
949  globus_result_t result,
950  globus_gfs_stat_ext_t * stat_array,
951  int stat_count,
952  size_t stat_size,
953  globus_bool_t final);
954 
955 void
956 globus_gridftp_server_finished_stat_partial(
957  globus_gfs_operation_t op,
958  globus_result_t result,
959  globus_gfs_stat_t * stat_array,
960  int stat_count);
961 
962 void
963 globus_gridftp_server_finished_stat_custom_list(
964  globus_gfs_operation_t op,
965  globus_result_t result,
966  globus_byte_t * list_response,
967  globus_size_t list_response_len,
968  globus_bool_t free_buffer);
969 
970 /*
971  * finished active data
972  *
973  * Speficic finished notification for completion of a active data creation.
974  */
975 void
976 globus_gridftp_server_finished_active_data(
977  globus_gfs_operation_t op,
978  globus_result_t result,
979  void * data_arg,
980  globus_bool_t bi_directional);
981 
982 /*
983  * finished passive data
984  *
985  * Speficic finished notification for completion of a passive data creation.
986  */
987 void
988 globus_gridftp_server_finished_passive_data(
989  globus_gfs_operation_t op,
990  globus_result_t result,
991  void * data_arg,
992  globus_bool_t bi_directional,
993  const char ** contact_strings,
994  int cs_count);
995 
996 
997 
1002 /*
1003  * write
1004  *
1005  * Register a write of specified buffer to the server. You should use
1006  * globus_gridftp_server_get_block_size()
1007  * and globus_gridftp_server_get_optimal_concurrency() to determine the
1008  * buffer size of each write and the number of writes you should have
1009  * pending at all times. (pending meaning you are waiting for the callback).
1010  */
1011 typedef void
1013  globus_gfs_operation_t op,
1014  globus_result_t result,
1015  globus_byte_t * buffer,
1016  globus_size_t nbytes,
1017  void * user_arg);
1018 
1019 globus_result_t
1020 globus_gridftp_server_register_write(
1021  globus_gfs_operation_t op,
1022  globus_byte_t * buffer,
1023  globus_size_t length,
1024  globus_off_t offset,
1025  int stripe_ndx,
1027  void * user_arg);
1028 
1029 /*
1030  * read
1031  *
1032  * Register a read of data from the server. You should use
1033  * globus_gridftp_server_get_block_size()
1034  * and globus_gridftp_server_get_optimal_concurrency() to determine the
1035  * buffer size you should use and the number of reads you should have
1036  * pending at all times. (pending meaning you are waiting for the callback).
1037  */
1038 typedef void
1039 (*globus_gridftp_server_read_cb_t)(
1040  globus_gfs_operation_t op,
1041  globus_result_t result,
1042  globus_byte_t * buffer,
1043  globus_size_t nbytes,
1044  globus_off_t offset,
1045  globus_bool_t eof,
1046  void * user_arg);
1047 
1048 globus_result_t
1049 globus_gridftp_server_register_read(
1050  globus_gfs_operation_t op,
1051  globus_byte_t * buffer,
1052  globus_size_t length,
1053  globus_gridftp_server_read_cb_t callback,
1054  void * user_arg);
1055 
1056 
1057 /*
1058  * register a custom command
1059  *
1060  * This must be called during the DSI session_start_func() function.
1061  * When a command is triggered, command_func() will be called with a
1062  * command_info->command equal to cmd_id.
1063  *
1064  * cmd_id must be >= GLOBUS_GFS_MIN_CUSTOM_CMD.
1065  *
1066  * If a command takes a pathname, it must be the final argument, and has_pathname
1067  * must be set to GLOBUS_TRUE. commands should not take multiple pathnames.
1068  *
1069  * If the command takes a pathname, set access_type to an globus_gfs_acl_action_e
1070  * like one of: GFS_ACL_ACTION_READ, GFS_ACL_ACTION_WRITE,
1071  * GFS_ACL_ACTION_CREATE, GFS_ACL_ACTION_DELETE, GFS_ACL_ACTION_LOOKUP.
1072  *
1073  * The last argument will always be passed in command_info->pathname, whether
1074  * it is a pathname or not.
1075  * Other args can be obtained by querying command_info->op_info for
1076  * GLOBUS_GFS_OP_INFO_CMD_ARGS. See globus_gridftp_server_query_op_info().
1077  *
1078  * Note for min_args and max_args, that the command itself counts as a argument
1079  * (or 2, in the case of SITE commands).
1080  *
1081  * A non-SITE command name must be exactly 4 characters long,
1082  * A SITE command (command name = "SITE SOMETHING") can be any length
1083  *
1084  * help_string should be of the form "COMMAND <sp> arg1 <sp> arg2 <sp> pathname"
1085  *
1086  * Responses are handled as with any other command. Call
1087  * globus_gridftp_server_finished_command() with a 'result' and 'command_response'.
1088  * If 'command_response' is NULL and result is success, a standard "200 OK"
1089  * response will be returned. A valid custom FTP response string should contain
1090  * a code between 200-299, and be terminated with \r\n.
1091  * i.e. "250 The command was successful\r\n".
1092  * The helper globus_gfs_custom_string_to_959() can be used to format more
1093  * complex 'command_response' strings, including multi-line responses.
1094  */
1095 
1096 globus_result_t
1097 globus_gridftp_server_add_command(
1098  globus_gfs_operation_t op,
1099  const char * command_name,
1100  int cmd_id,
1101  int min_args,
1102  int max_args,
1103  const char * help_string,
1104  globus_bool_t has_pathname,
1105  int access_type);
1106 
1107 /*
1108  * Convert a reply string to a 959 compatible message.
1109  *
1110  * This is a macro to the server control library function:
1111  *
1112  * char *
1113  * globus_gsc_string_to_959(
1114  * int code,
1115  * const char * in_str,
1116  * const char * preline);
1117  *
1118  * code is the FTP return code (ie: 200, 500, etc). in_str is
1119  * the messsage. If in_str has many lines in it, then it will be
1120  * formatted to a proper FRC959 multiline response.
1121  *
1122  * There are 2 types of multiline responses. If preline is NULL
1123  * then this will format the message in the style:
1124  * 200-<Line>
1125  * 200-<more>
1126  * 200 End.
1127  *
1128  * If you sett preline to a whitespace you will get:
1129  * 200-<Line>
1130  * <more>
1131  * 200 End.
1132  *
1133  * You must free the returned string
1134  */
1135 
1136 #define globus_gfs_custom_string_to_959 globus_gsc_string_to_959
1137 
1138 
1153 globus_result_t
1155  globus_gfs_operation_t op,
1156  const char * cksm_str);
1157 
1167 globus_result_t
1169  globus_gfs_operation_t op,
1170  const char * stage_str);
1171 
1180 globus_result_t
1182  globus_gfs_operation_t op,
1183  const char * info_str);
1184 
1189 typedef enum
1190 {
1191  /* return argv and argc for the current command. usually called when
1192  * handling custom commands.
1193  *
1194  * char *** argv,
1195  * int * argc
1196  */
1197  GLOBUS_GFS_OP_INFO_CMD_ARGS = 1,
1198  /* return the extra facts the client asked for with this stat, as fact
1199  * names ending in ';', e.g. "X.foo;X.bar;", or NULL. Only MLST and
1200  * MLSC request extra facts.
1201  * Query stat_info->op_info. stat_info->op_info is NULL when no extra
1202  * facts were requested; a DSI can then skip looking them up. Supply the
1203  * facts with globus_gridftp_server_finished_stat_ext(). The string
1204  * belongs to the server.
1205  *
1206  * const char ** requested_facts
1207  */
1208  GLOBUS_GFS_OP_INFO_REQUESTED_FACTS = 2
1210 
1211 /* query op_info for parameters
1212  * query parameters listed in the globus_gfs_op_info_param_t enum.
1213  * the varargs should be populated with variables of the correct type to hold
1214  * the returning parameters for the requested param type.
1215  *
1216 */
1217 globus_result_t
1218 globus_gridftp_server_query_op_info(
1219  globus_gfs_operation_t op,
1220  globus_gfs_op_info_t op_info,
1222  ...);
1223 
1224 /* check for attributes applicable to the current recv operation.
1225  * requested_attr is a case-insensitive string indicating the attribute
1226  * whose value will returned in out_value. requested_attr may be NULL, in
1227  * which case the full attr string will be returned in out_value.
1228  *
1229  * the format of the full attr string is attr1=value;attr2=value;...
1230  *
1231  * it is the caller's responsibility to free() out_value after a succesful return.
1232 */
1233 
1234 globus_result_t
1235 globus_gridftp_server_get_recv_attr_string(
1236  globus_gfs_operation_t op,
1237  const char * requested_attr,
1238  char ** out_value);
1239 
1240 /* get intended modification time for the file being received. out_time
1241  * will be the same as if a UTIME/MDTM command had been issued. if the modify
1242  * time has not been requested by the client, this will return GLOBUS_SUCCESS
1243  * but out_time will be -1.
1244  */
1245 
1246 globus_result_t
1247 globus_gridftp_server_get_recv_modification_time(
1248  globus_gfs_operation_t op,
1249  time_t * out_time);
1250 
1251 /*
1252  * update bytes written to storage
1253  *
1254  * This should be called during a recv(), after each successful write
1255  * to the storage system.
1256  *
1257  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1258  * both globus_gridftp_server_update_bytes_recvd() and
1259  * globus_gridftp_server_update_range_recvd() for a given range.
1260  */
1261 void
1262 globus_gridftp_server_update_bytes_written(
1263  globus_gfs_operation_t op,
1264  globus_off_t offset,
1265  globus_off_t length);
1266 
1267 /*
1268  * update bytes recieved, but not yet written to storage
1269  * use this when there may be a delay between reciving data
1270  * and writing to storage. this will ensure accurate performance
1271  * markers, but will not cause range/restart markers to be sent.
1272  *
1273  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1274  * both globus_gridftp_server_update_bytes_recvd() and
1275  * globus_gridftp_server_update_range_recvd() for a given range.
1276  */
1277 void
1278 globus_gridftp_server_update_bytes_recvd(
1279  globus_gfs_operation_t op,
1280  globus_off_t length);
1281 
1282 /*
1283  * update bytes written to storage
1284  * use this when there may be a delay between reciving data
1285  * and writing to storage. this will cause range/restart markers
1286  * to be sent.
1287  *
1288  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1289  * both globus_gridftp_server_update_bytes_recvd() and
1290  * globus_gridftp_server_update_range_recvd() for a given range.
1291  */
1292 void
1293 globus_gridftp_server_update_range_recvd(
1294  globus_gfs_operation_t op,
1295  globus_off_t offset,
1296  globus_off_t length);
1297 
1298 /*
1299  * get concurrency
1300  *
1301  * This should be called during a recv() and send() in order to know the
1302  * number of pending reads or writes you should have at once.
1303  */
1304 void
1305 globus_gridftp_server_get_optimal_concurrency(
1306  globus_gfs_operation_t op,
1307  int * count);
1308 
1309 /*
1310  * get blocksize
1311  *
1312  * This should be called during a recv() and send() in order to know the
1313  * size of buffers that you should be passing to the server for reads and
1314  * writes.
1315  */
1316 void
1317 globus_gridftp_server_get_block_size(
1318  globus_gfs_operation_t op,
1319  globus_size_t * block_size);
1320 
1321 /*
1322  * get stripe blocksize
1323  *
1324  * This can be called during a recv() and send() in modules that wish to
1325  * deal with striping.
1326  */
1327 void
1328 globus_gridftp_server_get_stripe_block_size(
1329  globus_gfs_operation_t op,
1330  globus_size_t * stripe_block_size);
1331 
1332 /*
1333  * get session username
1334  *
1335  * This should can be called to get the username that the process is running
1336  * under, which may be different from the username supplied in the
1337  * session_start call in some cases.
1338  */
1339 void
1340 globus_gridftp_server_get_session_username(
1341  globus_gfs_operation_t op,
1342  char ** username);
1343 
1344 /*
1345  * get delegated cred
1346  *
1347  * This can can be called to get the delegated credential. This may be called
1348  * with any op after session_start() and and the credential pointer will be
1349  * valid until at least session_stop. del_cred will be NULL if it is not
1350  * available.
1351  */
1352 void
1353 globus_gridftp_server_get_delegated_cred(
1354  globus_gfs_operation_t op,
1355  gss_cred_id_t * del_cred);
1356 
1357 /*
1358  * get security context (unsupported)
1359  *
1360  * This can can be called to get the gssapi security context of the client
1361  * connection. This may be called with any op after session_start() and
1362  * the context pointer will be valid until at least session_stop. context
1363  * will be NULL if it is not available. This is needed for accessing proxy
1364  * extensions or other gssapi operations where the delegated credential is
1365  * not sufficient. The caller should not attempt operations that modify the
1366  * context without fully understanding the effects.
1367  */
1368 void
1369 globus_gridftp_server_get_sec_context(
1370  globus_gfs_operation_t op,
1371  gss_ctx_id_t * context);
1372 
1373 
1374 /*
1375  * get/set ordered data requirement
1376  *
1377  * The DSI must call this before globus_gridftp_server_begin_transfer()
1378  * to set the ordered_data flag. This will ensure that the offsets read
1379  * in each data callback are in order, even when multiple streams are used.
1380  * This will result in the transfer slowing down to match the speed of the
1381  * slowest stream. Note: in cases where the data source intentionally sends
1382  * data out of order, this will result in an aborted transfer. However,
1383  * a DSI that needs ordered data would probably fail in such a scenario anyway.
1384  *
1385  * Instead of calling these functions, you can enable this setting for all
1386  * transfers by setting GLOBUS_GFS_DSI_DESCRIPTOR_REQUIRES_ORDERED_DATA
1387  * in the globus_gfs_storage_iface_t interface definition.
1388  */
1389 void
1390 globus_gridftp_server_set_ordered_data(
1391  globus_gfs_operation_t op,
1392  globus_bool_t ordered_data);
1393 
1394 void
1395 globus_gridftp_server_get_ordered_data(
1396  globus_gfs_operation_t op,
1397  globus_bool_t * ordered_data);
1398 
1399 /*
1400  * get config string
1401  *
1402  * This can be called to get the dsi specific configuration string
1403  * that is defined in the global configuration.
1404  */
1405 void
1406 globus_gridftp_server_get_config_string(
1407  globus_gfs_operation_t op,
1408  char ** config_string);
1409 
1410 /*
1411  * get config data
1412  *
1413  * This can be called to get the configuration data managed by the server.
1414  * data_id can be NULL, or can be used to specify a specific set of data.
1415  */
1416 void
1417 globus_gridftp_server_get_config_data(
1418  globus_gfs_operation_t op,
1419  char * data_id,
1420  char ** config_data);
1421 
1422 void
1423 globus_gridftp_server_session_get_config_data(
1424  globus_gfs_session_config_t session_conf_handle,
1425  char * data_id,
1426  char ** config_data);
1427 
1428 void
1429 globus_gridftp_server_get_session_config_handle(
1430  globus_gfs_operation_t op,
1431  globus_gfs_session_config_t * out_session_conf_handle);
1432 
1433 void
1434 globus_gfs_data_get_file_stack_list(
1435  globus_gfs_operation_t in_op,
1436  globus_list_t ** out_list);
1437 
1438 void
1439 globus_gridftp_server_get_update_interval(
1440  globus_gfs_operation_t op,
1441  int * interval);
1442 
1443 /*
1444  * get Transfer task ID
1445  *
1446  * Returns the Transfer task ID associated with the current GridFTP session.
1447  * If a task id is not known, return NULL instead.
1448  */
1449 void
1450 globus_gridftp_server_get_task_id(
1451  globus_gfs_operation_t op,
1452  char ** task_id);
1453 
1454 /*
1455  * get read_range
1456  *
1457  * This should be called during send() in order to know the specific
1458  * offset and length of the file to read from the storage system
1459  * You should continue calling this and transferring the speficied data
1460  * until it returns a length of 0.
1461  */
1462 void
1463 globus_gridftp_server_get_read_range(
1464  globus_gfs_operation_t op,
1465  globus_off_t * offset,
1466  globus_off_t * length);
1467 
1468 
1469 /*
1470  * get write_range
1471  *
1472  * This could be called during recv() in order to get hints on the specific
1473  * offset and length that the data will be expected to come from
1474  * globus_gridftp_server_register_read() callbacks. Note that this is
1475  * only a hint, and not necessarily the exact data ranges that will come.
1476  * You would continue calling this until it returns a length of 0.
1477  */
1478 void
1479 globus_gridftp_server_get_write_range(
1480  globus_gfs_operation_t op,
1481  globus_off_t * offset,
1482  globus_off_t * length);
1483 
1484 
1485 /* END Storage Interface API */
1486 
1487 typedef enum
1488 {
1489  GLOBUS_GFS_LOG_ERR = 0x01,
1490  GLOBUS_GFS_LOG_WARN = 0x02,
1491  GLOBUS_GFS_LOG_TRANSFER = 0x04,
1492  GLOBUS_GFS_LOG_INFO = 0x08,
1493  GLOBUS_GFS_LOG_DUMP = 0x10,
1494  GLOBUS_GFS_LOG_ALL = 0xFF,
1495  GLOBUS_GFS_LOG_AUDIT = 0x100
1496 } globus_gfs_log_type_t;
1497 
1498 void
1499 globus_gfs_log_message(
1500  globus_gfs_log_type_t type,
1501  const char * format,
1502  ...);
1503 
1504 void
1505 globus_gfs_log_result(
1506  globus_gfs_log_type_t type,
1507  const char * lead,
1508  globus_result_t result);
1509 
1511 enum
1512 {
1513  GLOBUS_GFS_DEBUG_TRACE = 8,
1514  GLOBUS_GFS_DEBUG_INFO = 16,
1515  GLOBUS_GFS_DEBUG_STATE = 32
1516 };
1517 
1518 #ifdef __GNUC__
1519 #define GlobusGFSName(func) static const char * _gfs_name __attribute__((__unused__)) = #func
1520 #else
1521 #define GlobusGFSName(func) static const char * _gfs_name = #func
1522 #endif
1523 
1524 GlobusDebugDeclare(GLOBUS_GRIDFTP_SERVER);
1525 
1526 #define GlobusGFSDebugPrintf(level, message) \
1527  GlobusDebugPrintf(GLOBUS_GRIDFTP_SERVER, level, message)
1528 
1529 
1530 #define GlobusGFSDebugInfoF(_msg) \
1531 do \
1532 { \
1533  GlobusGFSDebugPrintf( \
1534  GLOBUS_GFS_DEBUG_INFO, \
1535  ("[%s:%d] (pid=%d) [%s] ", __FILE__, __LINE__, getpid(), __func__));\
1536  GlobusGFSDebugPrintf( \
1537  GLOBUS_GFS_DEBUG_INFO, \
1538  _msg); \
1539 } while(0)
1540 
1541 #define GlobusGFSDebugResultT(_result, _msg) \
1542 do \
1543 { \
1544  char * _err_str = globus_error_print_friendly( \
1545  globus_error_peek(_result)); \
1546  GlobusGFSDebugInfoF(("%s: %s\n", _msg, _err_str)); \
1547  free(_err_str); \
1548 } while(0)
1549 
1550 #define GlobusGFSDebugInfo(_msg) \
1551  GlobusGFSDebugPrintf( \
1552  GLOBUS_GFS_DEBUG_INFO, \
1553  ("[%s] %s\n", __func__, _msg))
1554 
1555 #define GlobusGFSDebugEnter() \
1556  GlobusGFSDebugPrintf( \
1557  GLOBUS_GFS_DEBUG_TRACE, \
1558  ("[%s] Entering\n", __func__))
1559 
1560 #define GlobusGFSDebugExitResult(res) \
1561  GlobusGFSDebugPrintf( \
1562  GLOBUS_GFS_DEBUG_TRACE, \
1563  ("[%s] Exiting%s\n", \
1564  __func__, \
1565  (res != GLOBUS_SUCCESS) ? " with error" : ""))
1566 
1567 #define GlobusGFSDebugExit() \
1568  GlobusGFSDebugPrintf( \
1569  GLOBUS_GFS_DEBUG_TRACE, \
1570  ("[%s] Exiting\n", __func__))
1571 
1572 #define GlobusGFSDebugState(_state) \
1573  GlobusGFSDebugPrintf( \
1574  GLOBUS_GFS_DEBUG_INFO, \
1575  ("[%s] State: %d\n", __func__, _state))
1576 
1577 #define GlobusGFSDebugExitWithError() \
1578  GlobusGFSDebugPrintf( \
1579  GLOBUS_GFS_DEBUG_TRACE, \
1580  ("[%s] Exiting with error\n", __func__))
1581 
1582 #define GlobusGFSErrorParameter(mem_name) \
1583  globus_error_put(GlobusGFSErrorObjParameter(mem_name))
1584 
1585 #define GlobusGFSErrorIPC() \
1586  globus_error_put(GlobusGFSErrorObjIPC())
1587 
1588 #define GlobusGFSErrorObjIPC() \
1589  globus_error_construct_error( \
1590  NULL, \
1591  NULL, \
1592  GLOBUS_GFS_ERROR_MEMORY, \
1593  __FILE__, \
1594  __func__, \
1595  __LINE__, \
1596  "IPC Communication error.")
1597 
1598 #define GlobusGFSErrorObjParameter(param_name) \
1599  globus_error_construct_error( \
1600  NULL, \
1601  NULL, \
1602  GLOBUS_GFS_ERROR_PARAMETER, \
1603  __FILE__, \
1604  __func__, \
1605  __LINE__, \
1606  "invalid parameter: %s", \
1607  (param_name))
1608 
1609 #define GlobusGFSErrorSystemError(system_func, system_errno) \
1610  globus_error_put(GlobusGFSErrorObjSystemError(\
1611  (system_func), (system_errno)))
1612 #define GlobusGFSErrorObjSystemError(system_func, system_errno) \
1613  globus_i_gfs_error_system( \
1614  0, (system_errno), \
1615  "System error%s%s", \
1616  (system_func) != NULL ? " in " : "", \
1617  (system_func) != NULL ? (system_func) : "")
1618 
1619 #define GlobusGFSErrorWrapFailed(failed_func, result) \
1620  globus_error_put(GlobusGFSErrorObjWrapFailed(failed_func, result))
1621 
1622 #define GlobusGFSErrorObjWrapFailed(failed_func, result) \
1623  globus_error_construct_error( \
1624  NULL, \
1625  globus_error_get((result)), \
1626  GLOBUS_GFS_ERROR_WRAPPED, \
1627  __FILE__, \
1628  __func__, \
1629  __LINE__, \
1630  "%s failed.", \
1631  (failed_func))
1632 
1633 #define GlobusGFSErrorData(reason) \
1634  globus_error_put(GlobusGFSErrorObjData(reason))
1635 
1636 #define GlobusGFSErrorObjData(reason) \
1637  globus_error_construct_error( \
1638  NULL, \
1639  NULL, \
1640  GLOBUS_GFS_ERROR_DATA, \
1641  __FILE__, \
1642  __func__, \
1643  __LINE__, \
1644  "%s", \
1645  (reason))
1646 
1647 #define GlobusGFSErrorGeneric(reason) \
1648  globus_error_put(GlobusGFSErrorObjGeneric(reason))
1649 
1650 #define GlobusGFSErrorObjGeneric(reason) \
1651  globus_error_construct_error( \
1652  NULL, \
1653  NULL, \
1654  GLOBUS_GFS_ERROR_GENERIC, \
1655  __FILE__, \
1656  __func__, \
1657  __LINE__, \
1658  "%s", \
1659  (reason))
1660 
1661 globus_object_t *
1663  globus_module_descriptor_t * base_source,
1664  globus_object_t * base_cause,
1665  int response_code,
1666  const char *response_error_code,
1667  const char *fmt,
1668  ...);
1669 
1670 globus_object_t *
1672  globus_object_t * error,
1673  globus_module_descriptor_t * base_source,
1674  globus_object_t * base_cause,
1675  int response_code,
1676  const char * response_error_code,
1677  const char * fmt,
1678  va_list ap);
1679 globus_object_t *
1681  globus_object_t * error,
1682  globus_module_descriptor_t * base_source,
1683  globus_object_t * base_cause,
1684  int response_code,
1685  const char * response_error_code,
1686  const char * fmt,
1687  ...);
1688 
1689 int
1691  globus_object_t * error);
1692 
1693 const char *
1695  globus_object_t * error);
1696 
1697 globus_bool_t
1699  globus_object_t * error,
1700  const char * response_error_code);
1701 
1702 extern const globus_object_type_t
1704 
1705 #define GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE \
1706  (&GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE_DEFINITION)
1707 
1708 
1709 #define GlobusGFSErrorFtpResponse(cause, code, response_error_code, ...) \
1710  globus_error_put(GlobusGFSErrorObjFtpResponse( \
1711  cause, code, response_error_code, __VA_ARGS__))
1712 
1713 #define GlobusGFSErrorObjFtpResponse(cause, code, response_error_code, ...) \
1714  globus_gfs_ftp_response_error_construct( \
1715  NULL, \
1716  cause, \
1717  code, \
1718  response_error_code, \
1719  __VA_ARGS__)
1720 
1721 globus_object_t *
1722 globus_i_gfs_error_system(int ftp_code, int system_errno, const char *fmt, ...);
1723 
1724 #define GlobusGFSErrorMemory(mem) \
1725  globus_error_put(GlobusGFSErrorObjMemory(mem))
1726 #define GlobusGFSErrorObjMemory(mem) \
1727  GlobusGFSErrorObjSystemError("malloc", errno)
1728 
1729 #define GlobusGFSErrorObj(cause, response_code, ...) \
1730  GlobusGFSErrorObjFtpResponse(cause, response_code, __VA_ARGS__)
1731 
1732 #define GlobusGFSErrorPathNotFound(p) \
1733  globus_error_put(GlobusGFSErrorObjPathNotFound(NULL, p))
1734 #define GlobusGFSErrorObjPathNotFound(cause, p) \
1735  GlobusGFSErrorObj((cause), 550, "PATH_NOT_FOUND", \
1736  "%s%s%s", \
1737  ((p) != NULL) ? "GridFTP-Path: \"" : "", \
1738  ((p) != NULL) ? (p) : "", \
1739  ((p) != NULL) ? "\"" : "")
1740 
1741 #define GlobusGFSErrorIncorrectChecksum(computed, expected) \
1742  globus_error_put(GlobusGFSErrorObjIncorrectChecksum( \
1743  NULL, computed, expected))
1744 #define GlobusGFSErrorObjIncorrectChecksum(cause, computed, expected) \
1745  GlobusGFSErrorObj( \
1746  (cause), \
1747  550, \
1748  "INCORRECT_CHECKSUM", \
1749  "GridFTP-Computed-Checksum: %s\n" \
1750  "GridFTP-Expected-Checksum: %s", (computed), (expected))
1751 
1752 #define GlobusGFSErrorMultipartUploadNotFound() \
1753  globus_error_put(GlobusGFSErrorObjMultipartUploadNotFound(NULL))
1754 #define GlobusGFSErrorObjMultipartUploadNotFound(cause) \
1755  GlobusGFSErrorObj(cause, 553, "MULTI_PART_UPLOAD_NOT_FOUND", NULL)
1756 
1757 #define GlobusGFSErrorAppendNotSupported() \
1758  globus_error_put(GlobusGFSErrorObjAppendNotSupported(NULL))
1759 #define GlobusGFSErrorObjAppendNotSupported(cause) \
1760  GlobusGFSErrorObj((cause), 553, "APPEND_NOT_SUPPORTED", NULL)
1761 
1762 #define GlobusGFSErrorAmbiguousPath(ambiguity) \
1763  globus_error_put(GlobusGFSErrorObjAmbiguousPath(NULL, ambiguity))
1764 #define GlobusGFSErrorObjAmbiguousPath(cause, ambiguity) \
1765  GlobusGFSErrorObj( \
1766  (cause), \
1767  553, \
1768  "AMBIGUOUS_PATH", \
1769  "GridFTP-Path: %s", \
1770  (ambiguity))
1771 
1772 #define GlobusGFSErrorTooBusy() \
1773  globus_error_put(GlobusGFSErrorObjTooBusy(NULL))
1774 #define GlobusGFSErrorObjTooBusy(cause) \
1775  GlobusGFSErrorObj((cause), 451, "TOO_BUSY", NULL)
1776 
1777 #define GlobusGFSErrorDataChannelAuthenticationFailure() \
1778  globus_error_put(GlobusGFSErrorObjDataChannelAuthenticationFailure( \
1779  NULL))
1780 #define GlobusGFSErrorObjDataChannelAuthenticationFailure(cause) \
1781  GlobusGFSErrorObj((cause), 425, \
1782  "DATA_CHANNEL_AUTHENTICATION_FAILURE", NULL)
1783 
1784 #define GlobusGFSErrorDataChannelCommunicationFailure() \
1785  globus_error_put(GlobusGFSErrorObjDataChannelCommunicationFailure( \
1786  NULL))
1787 #define GlobusGFSErrorObjDataChannelCommunicationFailure(cause) \
1788  GlobusGFSErrorObj((cause), 425, \
1789  "DATA_CHANNEL_COMMUNICATION_FAILURE", NULL)
1790 
1791 #define GlobusGFSErrorLoginDenied() \
1792  globus_error_put(GlobusGFSErrorObjLoginDenied(NULL))
1793 #define GlobusGFSErrorObjLoginDenied(cause) \
1794  GlobusGFSErrorObj((cause), 530, "LOGIN_DENIED", NULL)
1795 
1796 #define GlobusGFSErrorLoginDeniedJSON(message, json) \
1797  globus_error_put(GlobusGFSErrorObjLoginDeniedJSON(NULL, message, json))
1798 #define GlobusGFSErrorObjLoginDeniedJSON(cause, message, json) \
1799  GlobusGFSErrorObj((cause), 530, "LOGIN_DENIED", \
1800  "GridFTP-Message: %s\n" \
1801  "GridFTP-JSON-Result: %s", \
1802  (message) ? (message) : "Message not available", (json))
1803 
1804 #define GlobusGFSErrorEndpointError() \
1805  globus_error_put(GlobusGFSErrorObjEndpointError(NULL))
1806 #define GlobusGFSErrorObjEndpointError(cause) \
1807  GlobusGFSErrorObj((cause), 530, "ENDPOINT_ERROR", NULL)
1808 
1809 #define GlobusGFSErrorPermissionDenied() \
1810  globus_error_put(GlobusGFSErrorObjPermissionDenied(NULL))
1811 #define GlobusGFSErrorObjPermissionDenied(cause) \
1812  GlobusGFSErrorObj((cause), 550, "PERMISSION_DENIED", NULL)
1813 
1814 #define GlobusGFSErrorQuotaExceeded() \
1815  globus_error_put(GlobusGFSErrorObjQuotaExceeded(NULL))
1816 #define GlobusGFSErrorObjQuotaExceeded(cause) \
1817  GlobusGFSErrorObj((cause), 451, "QUOTA_EXCEEDED", NULL)
1818 
1819 #define GlobusGFSErrorNoSpaceLeft() \
1820  globus_error_put(GlobusGFSErrorObjNoSpaceLeft(NULL))
1821 #define GlobusGFSErrorObjNoSpaceLeft(cause) \
1822  GlobusGFSErrorObj((cause), 451, "NO_SPACE_LEFT", NULL)
1823 
1824 #define GlobusGFSErrorInvalidPathName(name) \
1825  globus_error_put(GlobusGFSErrorObjInvalidPathName(NULL, name))
1826 #define GlobusGFSErrorObjInvalidPathName(cause, name) \
1827  GlobusGFSErrorObj((cause), 553, "INVALID_PATH_NAME", \
1828  "GridFTP-Path: %s", name)
1829 
1830 #define GlobusGFSErrorPathExists(name) \
1831  globus_error_put(GlobusGFSErrorObjPathExists(NULL, name))
1832 #define GlobusGFSErrorObjPathExists(cause, name) \
1833  GlobusGFSErrorObj((cause), 553, "PATH_EXISTS", \
1834  "GridFTP-Path: %s", name)
1835 
1836 #define GlobusGFSErrorIsADirectory(name) \
1837  globus_error_put(GlobusGFSErrorObjIsADirectory(NULL, name))
1838 #define GlobusGFSErrorObjIsADirectory(cause, name) \
1839  GlobusGFSErrorObj((cause), 553, "IS_A_DIRECTORY", \
1840  "GridFTP-Path: %s", name)
1841 
1842 #define GlobusGFSErrorNotADirectory(name) \
1843  globus_error_put(GlobusGFSErrorObjNotADirectory(NULL, name))
1844 #define GlobusGFSErrorObjNotADirectory(cause, name) \
1845  GlobusGFSErrorObj((cause), 553, "NOT_A_DIRECTORY", \
1846  "GridFTP-Path: %s", name)
1847 
1848 #define GlobusGFSErrorCRLError() \
1849  globus_error_put(GlobusGFSErrorObjCRLError(NULL))
1850 #define GlobusGFSErrorObjCRLError(cause) \
1851  GlobusGFSErrorObj((cause), 530, "CRL_ERROR", NULL)
1852 
1853 #define GlobusGFSErrorInternalError(generic_string) \
1854  globus_error_put(GlobusGFSErrorObjInternalError( \
1855  NULL, (generic_string)))
1856 #define GlobusGFSErrorObjInternalError(cause, generic_string) \
1857  GlobusGFSErrorObj((cause), 500, "INTERNAL_ERROR", \
1858  "%s%s", \
1859  ((generic_string) != NULL) ? "GridFTP-Error: " : "", \
1860  ((generic_string) != NULL) ? generic_string : "")
1861 
1862 #define GlobusGFSErrorNotImplemented() \
1863  globus_error_put(GlobusGFSErrorObjNotImplemented(NULL))
1864 #define GlobusGFSErrorObjNotImplemented(cause) \
1865  GlobusGFSErrorObj((cause), 500, "NOT_IMPLEMETED", NULL)
1866 
1867 #define GlobusGFSErrorNotImplementedFeature(feature) \
1868  globus_error_put(GlobusGFSErrorObjNotImplementedFeature(NULL, feature))
1869 #define GlobusGFSErrorObjNotImplementedFeature(cause, feature) \
1870  GlobusGFSErrorObj((cause), 500, \
1871  "NOT_IMPLEMETED", "GridFTP-Feature: %s", (feature))
1872 
1873 #define GlobusGFSErrorConfigurationError() \
1874  globus_error_put(GlobusGFSErrorObjConfigurationError(NULL))
1875 #define GlobusGFSErrorObjConfigurationError(cause) \
1876  GlobusGFSErrorObj((cause), 500, "CONFIGURATION_ERROR", NULL)
1877 
1878 
1879 /* Checksums */
1880 
1881 /* init, update update update ..., finalize.
1882  caller is responsible for freeing checksum_str.
1883 */
1884 
1885 #define GLOBUS_GFS_BUILTIN_CHECKSUM_SUPPORT "MD5:10;ADLER32:10;SHA1:10;CRC32C:10;SHA256:12;SHA512:11;QuickXORHex:12;Dropbox:12;"
1886 
1887 typedef struct globus_l_gfs_checksum_state_s * globus_gfs_checksum_state_t;
1888 
1889 globus_result_t
1890 globus_gfs_checksum_init(
1891  const char * algorithm,
1892  globus_gfs_checksum_state_t * state);
1893 
1894 globus_result_t
1895 globus_gfs_checksum_update(
1896  globus_gfs_checksum_state_t state,
1897  const unsigned char * buffer,
1898  size_t nbytes);
1899 
1900 globus_result_t
1901 globus_gfs_checksum_finalize(
1902  globus_gfs_checksum_state_t state,
1903  char ** checksum_str);
1904 
1905 /*
1906  *
1907  * IPC
1908  *
1909  */
1910 
1911 typedef struct globus_i_gfs_ipc_handle_s * globus_gfs_ipc_handle_t;
1912 
1913 /*
1914  * callbacks
1915  *
1916  * all functions have the same callback, they examine the
1917  * globus_gfs_finished_info_t() structure for their specific info
1918  *
1919  * error_cb
1920  * can be called at anytime. typically means the ipc connection broke
1921  * in an irrecoverable way. Even tho this is called all outstanding
1922  * callbacks will still be called (but with an error)
1923  */
1924 
1925  /*
1926  * replying
1927  *
1928  * every comman requires a reply and comes with a reply id. to reply
1929  * the requested side must fill in the globus_gfs_finished_info_t
1930  * structure and then pass it
1931  * to the function: globus_gfs_ipc_reply(); That call will result in
1932  * the ipc communication that will untilimately call the callback
1933  * on the callers side.
1934  */
1935 typedef void
1936 (*globus_gfs_ipc_callback_t)(
1937  globus_gfs_ipc_handle_t ipc_handle,
1938  globus_result_t result,
1939  globus_gfs_finished_info_t * reply,
1940  void * user_arg);
1941 
1942 typedef void
1943 (*globus_gfs_ipc_event_callback_t)(
1944  globus_gfs_ipc_handle_t ipc_handle,
1945  globus_result_t result,
1946  globus_gfs_event_info_t * reply,
1947  void * user_arg);
1948 
1949 typedef void
1950 (*globus_gfs_ipc_close_callback_t)(
1951  globus_gfs_ipc_handle_t ipc_handle,
1952  globus_result_t result,
1953  void * user_arg);
1954 
1955 typedef void
1956 (*globus_gfs_ipc_open_callback_t)(
1957  globus_gfs_ipc_handle_t ipc_handle,
1958  globus_result_t result,
1959  globus_gfs_finished_info_t * reply,
1960  void * user_arg);
1961 
1962 typedef void
1963 (*globus_gfs_ipc_error_callback_t)(
1964  globus_gfs_ipc_handle_t ipc_handle,
1965  globus_result_t result,
1966  void * user_arg);
1967 
1968 globus_result_t
1969 globus_gfs_ipc_reply_finished(
1970  globus_gfs_ipc_handle_t ipc_handle,
1971  globus_gfs_finished_info_t * reply);
1972 
1973 globus_result_t
1974 globus_gfs_ipc_reply_event(
1975  globus_gfs_ipc_handle_t ipc_handle,
1976  globus_gfs_event_info_t * reply);
1977 
1978 globus_result_t
1979 globus_gfs_ipc_reply_session(
1980  globus_gfs_ipc_handle_t ipc_handle,
1981  globus_gfs_finished_info_t * reply);
1982 
1983 /*
1984  * sending
1985  *
1986  * every command has a corresponding iface function. A call to a
1987  * command function results in a call to the correspoding iface
1988  * function on the other side of the channel.
1989  *
1990  * all parmeters are wrapped in a structure corresponding to
1991  * each function call type. those structures are defined below
1992  */
1993 
1994 typedef void
1995 (*globus_i_gfs_ipc_data_callback_t)(
1996  globus_gfs_finished_info_t * reply,
1997  void * user_arg);
1998 
1999 typedef void
2000 (*globus_i_gfs_ipc_data_event_callback_t)(
2001  globus_gfs_event_info_t * reply,
2002  void * user_arg);
2003 
2004 typedef void
2005 (*globus_i_gfs_ipc_done_callback_t)(
2006  void * user_arg,
2007  globus_result_t result);
2008 
2009 /*************************************************************************
2010  * interface function
2011  * ------------------
2012  *
2013  ************************************************************************/
2014 /* works with handle get */
2015 typedef void
2016 (*globus_gfs_ipc_iface_session_start_t)(
2017  globus_gfs_ipc_handle_t ipc_handle,
2018  const gss_ctx_id_t context,
2019  globus_gfs_session_info_t * session_info,
2020  globus_i_gfs_ipc_data_callback_t cb,
2021  void * user_arg);
2022 
2023 globus_result_t
2024 globus_gfs_ipc_start_session(
2025  globus_gfs_ipc_handle_t ipc_handle,
2026  globus_gfs_session_info_t * session_info,
2027  globus_gfs_ipc_callback_t cb,
2028  void * user_arg);
2029 
2030 /* works with release */
2031 typedef void
2032 (*globus_gfs_ipc_iface_session_stop_t)(
2033  globus_gfs_ipc_handle_t ipc_handle,
2034  void * session_handle);
2035 
2036 globus_result_t
2037 globus_gfs_ipc_iface_session_stop(
2038  globus_gfs_ipc_handle_t ipc_handle,
2039  void * session_handle);
2040 
2041 typedef void
2042 (*globus_gfs_ipc_iface_set_cred_t)(
2043  globus_gfs_ipc_handle_t ipc_handle,
2044  void * session_handle,
2045  gss_cred_id_t del_cred);
2046 
2047 globus_result_t
2048 globus_gfs_ipc_set_cred(
2049  globus_gfs_ipc_handle_t ipc_handle,
2050  gss_cred_id_t del_cred);
2051 
2052 typedef void
2053 (*globus_gfs_ipc_iface_buffer_send_t)(
2054  globus_gfs_ipc_handle_t ipc_handle,
2055  void * session_handle,
2056  globus_byte_t * buffer,
2057  int buffer_type,
2058  globus_size_t buffer_len);
2059 
2060 globus_result_t
2061 globus_gfs_ipc_request_buffer_send(
2062  globus_gfs_ipc_handle_t ipc_handle,
2063  globus_byte_t * buffer,
2064  int buffer_type,
2065  globus_size_t buffer_len);
2066 
2067 /*
2068  * receive
2069  *
2070  * tell the remote process to receive a file
2071  */
2072 typedef void
2073 (*globus_gfs_ipc_iface_recv_t)(
2074  globus_gfs_ipc_handle_t ipc_handle,
2075  void * session_handle,
2076  int id,
2077  globus_gfs_transfer_info_t * recv_info,
2078  globus_i_gfs_ipc_data_callback_t cb,
2079  globus_i_gfs_ipc_data_event_callback_t event_cb,
2080  void * user_arg);
2081 
2082 globus_result_t
2083 globus_gfs_ipc_request_recv(
2084  globus_gfs_ipc_handle_t ipc_handle,
2085  globus_gfs_transfer_info_t * recv_info,
2086  globus_gfs_ipc_callback_t cb,
2087  globus_gfs_ipc_event_callback_t event_cb,
2088  void * user_arg);
2089 
2090 /*
2091  * send
2092  *
2093  * tell remote process to send a file
2094  */
2095 typedef void
2096 (*globus_gfs_ipc_iface_send_t)(
2097  globus_gfs_ipc_handle_t ipc_handle,
2098  void * session_handle,
2099  int id,
2100  globus_gfs_transfer_info_t * send_info,
2101  globus_i_gfs_ipc_data_callback_t cb,
2102  globus_i_gfs_ipc_data_event_callback_t event_cb,
2103  void * user_arg);
2104 
2105 globus_result_t
2106 globus_gfs_ipc_request_send(
2107  globus_gfs_ipc_handle_t ipc_handle,
2108  globus_gfs_transfer_info_t * send_info,
2109  globus_gfs_ipc_callback_t cb,
2110  globus_gfs_ipc_event_callback_t event_cb,
2111  void * user_arg);
2112 
2113 typedef void
2114 (*globus_gfs_ipc_iface_list_t)(
2115  globus_gfs_ipc_handle_t ipc_handle,
2116  void * session_handle,
2117  int id,
2118  globus_gfs_transfer_info_t * list_info,
2119  globus_i_gfs_ipc_data_callback_t cb,
2120  globus_i_gfs_ipc_data_event_callback_t event_cb,
2121  void * user_arg);
2122 
2123 globus_result_t
2124 globus_gfs_ipc_request_list(
2125  globus_gfs_ipc_handle_t ipc_handle,
2126  globus_gfs_transfer_info_t * data_info,
2127  globus_gfs_ipc_callback_t cb,
2128  globus_gfs_ipc_event_callback_t event_cb,
2129  void * user_arg);
2130 
2131 /*
2132  * command
2133  *
2134  * tell remote side to execute the given command
2135  */
2136 typedef void
2137 (*globus_gfs_ipc_iface_command_t)(
2138  globus_gfs_ipc_handle_t ipc_handle,
2139  void * session_handle,
2140  int id,
2141  globus_gfs_command_info_t * cmd_info,
2142  globus_i_gfs_ipc_data_callback_t cb,
2143  void * user_arg);
2144 
2145 globus_result_t
2146 globus_gfs_ipc_request_command(
2147  globus_gfs_ipc_handle_t ipc_handle,
2148  globus_gfs_command_info_t * cmd_info,
2149  globus_gfs_ipc_callback_t cb,
2150  void * user_arg);
2151 
2152 /*
2153  * active data
2154  *
2155  * tell remote side to create an active data connection
2156  */
2157 typedef void
2158 (*globus_gfs_ipc_iface_active_data_t)(
2159  globus_gfs_ipc_handle_t ipc_handle,
2160  void * session_handle,
2161  int id,
2162  globus_gfs_data_info_t * data_info,
2163  globus_i_gfs_ipc_data_callback_t cb,
2164  void * user_arg);
2165 
2166 globus_result_t
2167 globus_gfs_ipc_request_active_data(
2168  globus_gfs_ipc_handle_t ipc_handle,
2169  globus_gfs_data_info_t * data_info,
2170  globus_gfs_ipc_callback_t cb,
2171  void * user_arg);
2172 
2173 /*
2174  * passive data
2175  *
2176  * tell remote side to do passive data connection
2177  */
2178 typedef void
2179 (*globus_gfs_ipc_iface_passive_data_t)(
2180  globus_gfs_ipc_handle_t ipc_handle,
2181  void * session_handle,
2182  int id,
2183  globus_gfs_data_info_t * data_info,
2184  globus_i_gfs_ipc_data_callback_t cb,
2185  void * user_arg);
2186 
2187 globus_result_t
2188 globus_gfs_ipc_request_passive_data(
2189  globus_gfs_ipc_handle_t ipc_handle,
2190  globus_gfs_data_info_t * data_info,
2191  globus_gfs_ipc_callback_t cb,
2192  void * user_arg);
2193 
2194 /*
2195  * send stat request
2196  */
2197 typedef void
2198 (*globus_gfs_ipc_iface_stat_t)(
2199  globus_gfs_ipc_handle_t ipc_handle,
2200  void * session_handle,
2201  int id,
2202  globus_gfs_stat_info_t * stat_info,
2203  globus_i_gfs_ipc_data_callback_t cb,
2204  void * user_arg);
2205 
2206 globus_result_t
2207 globus_gfs_ipc_request_stat(
2208  globus_gfs_ipc_handle_t ipc_handle,
2209  globus_gfs_stat_info_t * stat_info,
2210  globus_gfs_ipc_callback_t cb,
2211  void * user_arg);
2212 
2213 /*
2214  * poke transfer event request
2215  */
2216 typedef void
2217 (*globus_gfs_ipc_iface_transfer_event_t)(
2218  globus_gfs_ipc_handle_t ipc_handle,
2219  void * session_handle,
2220  globus_gfs_event_info_t * event_info);
2221 
2222 
2223 globus_result_t
2224 globus_gfs_ipc_request_transfer_event(
2225  globus_gfs_ipc_handle_t ipc_handle,
2226  globus_gfs_event_info_t * event_info);
2227 
2228 
2229 /*
2230  * destroy a data connection associated with the given ID
2231  */
2232 typedef void
2233 (*globus_gfs_ipc_iface_data_destroy_t)(
2234  globus_gfs_ipc_handle_t ipc_handle,
2235  void * session_handle,
2236  void * data_arg);
2237 
2238 globus_result_t
2239 globus_gfs_ipc_request_data_destroy(
2240  globus_gfs_ipc_handle_t ipc_handle,
2241  void * data_arg);
2242 
2243 typedef struct globus_i_gfs_ipc_iface_s
2244 {
2245  globus_gfs_ipc_iface_session_start_t session_start_func;
2246  globus_gfs_ipc_iface_session_stop_t session_stop_func;
2247  globus_gfs_ipc_iface_recv_t recv_func;
2248  globus_gfs_ipc_iface_send_t send_func;
2249  globus_gfs_ipc_iface_command_t command_func;
2250  globus_gfs_ipc_iface_active_data_t active_func;
2251  globus_gfs_ipc_iface_passive_data_t passive_func;
2252  globus_gfs_ipc_iface_data_destroy_t data_destroy_func;
2253  globus_gfs_ipc_iface_stat_t stat_func;
2254  globus_gfs_ipc_iface_list_t list_func;
2255  globus_gfs_ipc_iface_transfer_event_t transfer_event_func;
2256  globus_gfs_ipc_iface_set_cred_t set_cred;
2257  globus_gfs_ipc_iface_buffer_send_t buffer_send;
2258 } globus_gfs_ipc_iface_t;
2259 
2260 /*
2261  * getting an IPC handle
2262  */
2263 
2264 /*
2265  * create an IPC handle from a xio system handle, can be used
2266  * imediately, is not in handle table
2267  */
2268 globus_result_t
2269 globus_gfs_ipc_handle_create(
2270  globus_gfs_ipc_iface_t * iface,
2271  globus_xio_system_socket_t system_handle,
2272  globus_i_gfs_ipc_done_callback_t done_cb,
2273  void * user_arg);
2274 
2275 /*
2276  * actually close the handle
2277  */
2278 globus_result_t
2279 globus_gfs_ipc_close(
2280  globus_gfs_ipc_handle_t ipc_handle,
2281  globus_gfs_ipc_close_callback_t cb,
2282  void * user_arg);
2283 
2284 globus_result_t
2285 globus_gfs_ipc_reply_close(
2286  globus_gfs_ipc_handle_t ipc_handle);
2287 
2288 globus_result_t
2289 globus_gfs_ipc_session_stop(
2290  globus_gfs_ipc_handle_t ipc_handle);
2291 
2292 globus_result_t
2293 globus_gfs_ipc_handle_connect(
2294  globus_gfs_session_info_t * session_info,
2295  globus_gfs_ipc_open_callback_t cb,
2296  void * user_arg,
2297  globus_gfs_ipc_error_callback_t error_cb,
2298  void * error_user_arg);
2299 
2300 globus_result_t
2301 globus_gfs_ipc_handle_connect_ex(
2302  globus_gfs_session_info_t * session_info,
2303  globus_gfs_ipc_open_callback_t cb,
2304  void * user_arg,
2305  globus_gfs_ipc_error_callback_t error_cb,
2306  void * error_user_arg,
2307  globus_bool_t secure_ipc,
2308  gss_cred_id_t cred,
2309  const char *auth_mode,
2310  const char *subject,
2311  time_t connect_timeout,
2312  time_t idle_timeout,
2313  globus_bool_t inetd);
2314 
2315 globus_result_t
2316 globus_gfs_ipc_handle_obtain(
2317  globus_gfs_session_info_t * session_info,
2318  globus_gfs_ipc_iface_t * iface,
2319  globus_gfs_ipc_open_callback_t cb,
2320  void * user_arg,
2321  globus_gfs_ipc_error_callback_t error_cb,
2322  void * error_user_arg);
2323 
2324 /*
2325  * the brain bit
2326  */
2327 #define BRAIN_SYMBOL_NAME (void*)"gridftp_brain"
2328 extern globus_extension_registry_t brain_i_registry;
2329 
2330 typedef globus_result_t
2331 (*globus_i_gfs_brain_select_nodes_func_t)(
2332  globus_i_gfs_brain_node_t *** out_node_array,
2333  int * out_array_length,
2334  const char * repo_name,
2335  globus_off_t filesize,
2336  int min_count,
2337  int max_count);
2338 
2339 typedef globus_result_t
2340 (*globus_i_gfs_brain_release_node_func_t)(
2341  globus_i_gfs_brain_node_t * contact_node,
2342  globus_gfs_brain_reason_t reason);
2343 
2344 typedef globus_result_t
2345 (*globus_i_gfs_brain_init_func_t)(
2346  globus_callback_func_t ready_cb,
2347  void * ready_cb_arg);
2348 
2349 typedef void
2350 (*globus_i_gfs_brain_stop_func_t)();
2351 
2352 typedef globus_result_t
2353 (*globus_i_gfs_brain_get_available_func_t)(
2354  const char * user_id,
2355  const char * repo_name,
2356  int * count);
2357 
2358 
2359 typedef struct globus_i_gfs_brain_module_s
2360 {
2361  globus_i_gfs_brain_init_func_t init_func;
2362  globus_i_gfs_brain_stop_func_t stop_func;
2363  globus_i_gfs_brain_select_nodes_func_t select_func;
2364  globus_i_gfs_brain_release_node_func_t release_func;
2365  globus_i_gfs_brain_get_available_func_t available_func;
2366 } globus_i_gfs_brain_module_t;
2367 
2368 extern globus_i_gfs_brain_module_t globus_i_gfs_default_brain;
2369 
2370 globus_result_t
2371 globus_gfs_brain_select_nodes(
2372  globus_i_gfs_brain_node_t *** out_node_array,
2373  int * out_array_length,
2374  const char * repo_name,
2375  globus_off_t filesize,
2376  int min_count,
2377  int max_count);
2378 
2379 globus_result_t
2380 globus_gfs_brain_release_node(
2381  globus_i_gfs_brain_node_t * contact_node,
2382  globus_gfs_brain_reason_t reason);
2383 
2384 globus_result_t
2385 globus_gfs_brain_get_available(
2386  const char * user_id,
2387  const char * repo_name,
2388  int * count);
2389 
2390 globus_result_t
2391 globus_gfs_ipc_handle_get_contact_string(
2392  globus_gfs_ipc_handle_t ipc_handle,
2393  char ** contact_string);
2394 
2395 globus_result_t
2396 globus_gfs_ipc_init(
2397  globus_bool_t requester);
2398 
2399 /*
2400  *
2401  */
2402 void
2403 globus_gfs_ipc_add_server(
2404  globus_xio_server_t server_handle);
2405 
2406 extern globus_gfs_ipc_iface_t globus_gfs_ipc_default_iface;
2407 
2408 /* end IPC */
2409 
2410 
2411 
2412 /* ACL Interface */
2413 
2414 /*
2415  * ACL interface implementation functions
2416  * see the example implementations at
2417  * /usr/share/doc/globus-connect-gridftp-server/acl/ or
2418  * /usr/share/doc/libglobus-gridftp-server-dev/acl/
2419  */
2420 
2421 #define GFS_ACL_INTERFACE_VERSION 1000
2422 
2423 /* acl handle object. members are private. */
2424 typedef struct globus_i_gfs_acl_handle_s * globus_gfs_acl_handle_t;
2425 
2426 /* supported actions. all authorization callouts will be of these types.
2427  * an authorization callout should return success for any actions that
2428  * are not interesting. */
2429 enum globus_gfs_acl_action_e
2430 {
2431  GFS_ACL_ACTION_DELETE = 2,
2432  /* write to an existing object */
2433  GFS_ACL_ACTION_WRITE,
2434  /* create and write to a non-existent object */
2435  GFS_ACL_ACTION_CREATE,
2436  /* read an object */
2437  GFS_ACL_ACTION_READ,
2438  /* query metadata of an object (i.e. list) */
2439  GFS_ACL_ACTION_LOOKUP
2440 };
2441 
2442 
2443 /* return values for authorization functions */
2444 enum globus_gfs_acl_status_e
2445 {
2446  /* decision is complete */
2447  GLOBUS_GFS_ACL_COMPLETE = 1,
2448  /* decision will be made in a seperate call to globus_gfs_acl_finished() */
2449  GLOBUS_GFS_ACL_PENDING
2450 };
2451 
2452 
2453 /* collection types */
2454 enum globus_gfs_acl_collection_type_e
2455 {
2456  GFS_ACL_COLLECTION_MAPPED = 1,
2457  GFS_ACL_COLLECTION_GUEST
2458 };
2459 
2460 /* access methods */
2461 enum globus_gfs_acl_access_method_e
2462 {
2463  /* connection initiated by the Globus Transfer service */
2464  GFS_ACL_ACCESS_SERVICE = 1,
2465  /* connection initiated by collection HTTPS access */
2466  GFS_ACL_ACCESS_HTTPS
2467 };
2468 
2469 /* Initialization callout. This is called with each new connection.
2470  * With this call you are able to authorize the initial connection attempt.
2471  * You can also initialize local state for in preparation for future
2472  * authorization calls.
2473  *
2474  * This must return GLOBUS_GFS_ACL_COMPLETE or GLOBUS_GFS_ACL_PENDING, and
2475  * store GLOBUS_SUCCESS or an error result_t in out_res. If returning
2476  * GLOBUS_GFS_ACL_PENDING, the final result must be returned in a subsequent
2477  * call to globus_gfs_acl_finished(). Optionally, a pointer may be stored
2478  * in out_handle. This pointer will then be passed back in later callouts.
2479  */
2480 typedef int
2481 (*globus_gfs_acl_init_t)(
2482  void ** out_handle,
2483  globus_gfs_acl_handle_t acl_handle,
2484  globus_result_t * out_res);
2485 
2486 /* Authorization callout. Tnis is called to authrorize all actions the
2487  * client performs on object files. See globus_gfs_acl_action_e for the list
2488  * of the supported actions.
2489  *
2490  * Must return GLOBUS_GFS_ACL_COMPLETE or GLOBUS_GFS_ACL_PENDING, and
2491  * store GLOBUS_SUCCESS or an error result_t in out_res. If returning
2492  * GLOBUS_GFS_ACL_PENDING, the final result must be returned in a call to
2493  * globus_gfs_acl_finished().
2494  */
2495 typedef int
2496 (*globus_gfs_acl_authorize_t)(
2497  void * out_handle,
2498  int action,
2499  const char * object,
2500  globus_gfs_acl_handle_t acl_handle,
2501  globus_result_t * out_res);
2502 
2503 /* Destructor callout, called at the end of connection. Clean up state if
2504  * necessary */
2505 typedef void
2506 (*globus_gfs_acl_destroy_t)(
2507  void * out_handle);
2508 
2509 /* ACL module descriptor. Define your functions.
2510  * Set version to GFS_ACL_INTERFACE_VERSION.
2511  *
2512  * You should add this module to the globus extension registry
2513  * GLOBUS_GFS_ACL_REGISTRY. See the examples for building an extension
2514  * module that updates a registry upon activation.
2515  */
2516 typedef struct globus_gfs_acl_module_s
2517 {
2518  int version;
2519  globus_gfs_acl_init_t init_func;
2520  globus_gfs_acl_authorize_t authorize_func;
2521  globus_gfs_acl_destroy_t destroy_func;
2522 } globus_gfs_acl_module_t;
2523 
2524 
2525 /* Available authorization info.
2526  *
2527  * Unless otherwise noted, all info is available during the init_func and
2528  * authorize_func.
2529  *
2530  * Each info requires the indicated return param type. Free indicates whether
2531  * the caller is responsible for freeing, and the expected free call if so.
2532  *
2533  * Pass the desired info to globus_gfs_acl_get_info() with the appropriate
2534  * return param.
2535  */
2536 enum globus_gfs_acl_info_e
2537 {
2538  /*
2539  * ID of the collection being accessed.
2540  *
2541  * Param: char **
2542  * Free: yes, free()
2543  */
2544  GFS_ACL_INFO_COLLECTION_ID,
2545 
2546  /*
2547  * Type of the collection being accessed.
2548  * GFS_ACL_COLLECTION_MAPPED or GFS_ACL_COLLECTION_GUEST.
2549  *
2550  * Param: int *
2551  * Free: no
2552  */
2553  GFS_ACL_INFO_COLLECTION_TYPE,
2554 
2555  /*
2556  * Method of access.
2557  * GFS_ACL_ACCESS_SERVICE or GFS_ACL_ACCESS_HTTPS.
2558  *
2559  * Note: Identity IDs will be unavailable for anonymous HTTPS access.
2560  *
2561  * Param: int *
2562  * Free: no
2563  */
2564  GFS_ACL_INFO_METHOD,
2565 
2566  /*
2567  * Local username to which the login session was mapped.
2568  *
2569  * Param: char **
2570  * Free: yes, free()
2571  */
2572  GFS_ACL_INFO_MAPPED_USERNAME,
2573 
2574  /*
2575  * The effective identity id for this session. This is the identity that
2576  * resulted in the mapped username. For a guest collection, this is the
2577  * owner of the guest collection.
2578  *
2579  * Param: char **
2580  * Free: yes, free()
2581  */
2582  GFS_ACL_INFO_MAPPED_IDENTITY_ID,
2583 
2584  /*
2585  * For a mapped collection, the list of linked identity ids for the user
2586  * accessing the collection.
2587  *
2588  * Note: This is the set of identities on which mapping was performed.
2589  * Identities may be omitted depending on the relevant authentication
2590  * timeouts.
2591  *
2592  * Param: char **
2593  * Free: yes, free()
2594  */
2595  GFS_ACL_INFO_MAPPED_IDENTITY_IDS,
2596 
2597  /*
2598  * For a guest collection, the list of linked identity ids for the user
2599  * accessing the collection.
2600  *
2601  * Note: Identities may be omitted if they were not granted permissions
2602  * on the guest collection.
2603  *
2604  * Param: char **
2605  * Free: yes, free()
2606  */
2607  GFS_ACL_INFO_GUEST_IDENTITY_IDS,
2608 
2609  /*
2610  * The task id associated with the current session. NULL indicates
2611  * an interactive login (browsing from the file manager, HTTPS access,
2612  * or non-task API/CLI operations such as 'ls' and 'stat').
2613  *
2614  * Note: Currently not available in init_func().
2615  *
2616  * Param: char **
2617  * Free: yes, free()
2618  */
2619  GFS_ACL_INFO_TASK_ID,
2620 
2621  /*
2622  * The unique session id for this login session. This correlates to audit
2623  * log entries for high assurance collections.
2624  *
2625  * Param: char **
2626  * Free: yes, free()
2627  */
2628  GFS_ACL_INFO_SESSION_ID
2629 };
2630 
2631 
2632 /* Access info from the active acl handle. See globus_gfs_acl_info_e. */
2633 globus_result_t
2634 globus_gfs_acl_get_info(
2635  globus_gfs_acl_handle_t acl_handle,
2636  int info,
2637  ...);
2638 
2639 /* Authorization finalization function. Ths must be called when the
2640  * initialization or authorization callouts return GLOBUS_GFS_ACL_PENDING.
2641  */
2642 void
2643 globus_gfs_acl_finished(
2644  globus_gfs_acl_handle_t acl_handle,
2645  globus_result_t result);
2646 
2647 /* Helper function to get a string from action type. Useful for log or error
2648  * messages */
2649 const char *
2650 globus_gfs_acl_action_to_string(
2651  int action);
2652 
2653 
2654 /* END ACL Interface */
2655 
2656 
2657 /* config locking functions */
2658 typedef
2659 void
2660 (*globus_i_gfs_config_set_string_cb_t)(
2661  const char * option_name,
2662  const char * val,
2663  void * user_arg);
2664 
2665 typedef
2666 void
2667 (*globus_i_gfs_config_set_int_cb_t)(
2668  const char * option_name,
2669  int val,
2670  void * user_arg);
2671 
2672 typedef struct
2673 {
2674  void * user_arg;
2675  globus_bool_t enabled;
2676  void * cb;
2677 } globus_i_gfs_config_option_cb_ent_t;
2678 
2679 void
2680 globus_gfs_config_enable_cb(
2681  globus_i_gfs_config_option_cb_ent_t * cb_handle,
2682  globus_bool_t enabled);
2683 
2684 int
2685 globus_gfs_config_add_cb(
2686  globus_i_gfs_config_option_cb_ent_t ** cb_handle,
2687  char * option_name,
2688  void * cb,
2689  void * user_arg);
2690 
2691 globus_bool_t
2692 globus_gfs_config_get_bool(
2693  const char * option_name);
2694 
2695 char *
2696 globus_gfs_config_get_string(
2697  const char * option_name);
2698 
2699 globus_list_t *
2700 globus_gfs_config_get_list(
2701  const char * option_name);
2702 
2703 void *
2704 globus_gfs_config_get(
2705  const char * option_name);
2706 
2707 int
2708 globus_gfs_config_get_int(
2709  const char * option_name);
2710 
2711 int
2712 globus_gfs_config_set_int(
2713  char * option_name,
2714  int int_value);
2715 
2716 int
2717 globus_gfs_config_set_bool(
2718  char * option_name,
2719  int int_value);
2720 
2721 int
2722 globus_gfs_config_set_ptr(
2723  char * option_name,
2724  void * ptr);
2725 
2726 int
2727 globus_gfs_config_inc_int(
2728  char * option_name,
2729  int inc_val);
2730 
2731 globus_result_t
2732 globus_gfs_base64_encode(
2733  const unsigned char * inbuf,
2734  globus_size_t in_len,
2735  globus_byte_t * outbuf,
2736  globus_size_t * out_len);
2737 
2738 globus_result_t
2739 globus_gfs_base64_decode(
2740  const unsigned char * inbuf,
2741  globus_byte_t * outbuf,
2742  globus_size_t * out_len);
2743 
2744 
2745 #endif
const globus_object_type_t GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE_DEFINITION
Definition: globus_i_gfs_ftp_response_error.c:609
globus_gfs_op_info_param_t
Definition: globus_gridftp_server.h:1190
void(* globus_gridftp_server_write_cb_t)(globus_gfs_operation_t op, globus_result_t result, globus_byte_t *buffer, globus_size_t nbytes, void *user_arg)
Definition: globus_gridftp_server.h:1012
globus_object_t * globus_i_gfs_error_system(int ftp_code, int system_errno, const char *fmt,...)
Definition: globus_i_gfs_ftp_response_error.c:464
void globus_gridftp_server_finished_stat_ext(globus_gfs_operation_t op, globus_result_t result, globus_gfs_stat_ext_t *stat_array, int stat_count, size_t stat_size, globus_bool_t final)
Definition: globus_i_gfs_data.c:13841
globus_result_t globus_gridftp_server_set_staging_support(globus_gfs_operation_t op, const char *stage_str)
Definition: globus_i_gfs_data.c:15244
globus_object_t * globus_gfs_ftp_response_error_initialize(globus_object_t *error, globus_module_descriptor_t *base_source, globus_object_t *base_cause, int response_code, const char *response_error_code, const char *fmt,...)
Definition: globus_i_gfs_ftp_response_error.c:122
void globus_gridftp_server_operation_finished(globus_gfs_operation_t op, globus_result_t result, globus_gfs_finished_info_t *finished_info)
Definition: globus_i_gfs_data.c:14486
int globus_gfs_error_get_ftp_response_code(globus_object_t *error)
Definition: globus_i_gfs_ftp_response_error.c:252
globus_result_t globus_gridftp_server_set_checksum_support(globus_gfs_operation_t op, const char *cksm_str)
Definition: globus_i_gfs_data.c:15224
void(* globus_gfs_storage_init_t)(globus_gfs_operation_t op, globus_gfs_session_info_t *session_info)
Definition: globus_gridftp_server.h:655
globus_object_t * globus_gfs_ftp_response_error_construct(globus_module_descriptor_t *base_source, globus_object_t *base_cause, int response_code, const char *response_error_code, const char *fmt,...)
Definition: globus_i_gfs_ftp_response_error.c:57
enum globus_gfs_event_type_e globus_gfs_event_type_t
Event types.
const char * globus_gfs_error_get_ftp_response_error_code(globus_object_t *error)
Definition: globus_i_gfs_ftp_response_error.c:284
globus_result_t globus_gridftp_server_set_mlst_facts(globus_gfs_operation_t op, const char *fact_names)
Definition: globus_i_gfs_data.c:15271
globus_gfs_event_type_e
Event types.
Definition: globus_gridftp_server.h:154
@ GLOBUS_GFS_EVENT_DISCONNECTED
Definition: globus_gridftp_server.h:168
@ GLOBUS_GFS_EVENT_TRANSFER_COMPLETE
Definition: globus_gridftp_server.h:164
@ GLOBUS_GFS_EVENT_TRANSFER_CONNECTED
Definition: globus_gridftp_server.h:183
@ GLOBUS_GFS_EVENT_PARTIAL_EOF_COUNT
Definition: globus_gridftp_server.h:186
@ GLOBUS_GFS_EVENT_RANGES_RECVD
Definition: globus_gridftp_server.h:178
@ GLOBUS_GFS_EVENT_TRANSFER_BEGIN
Definition: globus_gridftp_server.h:157
@ GLOBUS_GFS_EVENT_TRANSFER_ABORT
Definition: globus_gridftp_server.h:160
@ GLOBUS_GFS_EVENT_ALL
Definition: globus_gridftp_server.h:192
@ GLOBUS_GFS_EVENT_BYTES_RECVD
Definition: globus_gridftp_server.h:173
@ GLOBUS_GFS_EVENT_FINAL_EOF_COUNT
Definition: globus_gridftp_server.h:189
globus_object_t * globus_gfs_ftp_response_error_v_initialize(globus_object_t *error, globus_module_descriptor_t *base_source, globus_object_t *base_cause, int response_code, const char *response_error_code, const char *fmt, va_list ap)
Definition: globus_i_gfs_ftp_response_error.c:175
globus_bool_t globus_gfs_error_match_response_error_code(globus_object_t *error, const char *response_error_code)
Definition: globus_i_gfs_ftp_response_error.c:317
globus_result_t globus_gridftp_server_set_info_string(globus_gfs_operation_t op, const char *info_str)
Definition: globus_i_gfs_data.c:15305
Definition: globus_gridftp_server_control.h:204