globus_connect_gridftp_server  16.16~a1
/home/rocky/workspace/us-connect-gridftp-server_master/gridftp/server/src/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  */
241 typedef globus_gridftp_server_control_stat_t globus_gfs_stat_t;
242 
243 
244 /*
245  * globus_gfs_operation_info_t
246  *
247  * Internal operation info. This handle is passed with the info structs
248  * Its data should not be accessed.
249  */
250 typedef struct globus_i_gfs_op_info_s * globus_gfs_op_info_t;
251 
252 /*
253  * globus_gfs_data_finished_info_t
254  *
255  * Contains specific result info for an active or passive data connection.
256  * Note that in most cases this info will simply be passed.
257  */
258 typedef struct globus_gfs_data_finished_info_s
259 {
261  void * data_arg;
263  globus_bool_t bi_directional;
265  globus_bool_t ipv6;
267  int cs_count;
269  const char ** contact_strings;
270 } globus_gfs_data_finished_info_t;
271 
272 /*
273  * globus_gfs_cmd_finshed_info_t
274  *
275  * Contains specific result info for commands.
276  */
277 typedef struct globus_gfs_cmd_finshed_info_s
278 {
280  globus_gfs_command_type_t command;
282  char * checksum;
284  char * created_dir;
285 } globus_gfs_cmd_finshed_info_t;
286 
287 /*
288  * globus_gfs_stat_finished_info_t
289  *
290  * Contains specific result info for a stat.
291  */
292 typedef struct globus_gfs_stat_finished_info_s
293 {
295  int uid;
297  int gid_count;
299  int * gid_array;
301  int stat_count;
303  globus_gfs_stat_t * stat_array;
304 } globus_gfs_stat_finished_info_t;
305 
306 /*
307  * globus_gfs_session_finished_info_t
308  *
309  * Contains specific result info for a stat.
310  */
311 typedef struct globus_gfs_session_finished_info_s
312 {
314  void * session_arg;
316  char * username;
318  char * home_dir;
319 } globus_gfs_session_finished_info_t;
320 
321 /*
322  * globus_gfs_session_finished_info_t
323  *
324  * Contains specific result info for a stat.
325  */
326 typedef struct globus_gfs_transfer_finished_info_s
327 {
328  /* total bytes transferred for this operation */
329  globus_off_t bytes_transferred;
330 
331 } globus_gfs_transfer_finished_info_t;
332 
333 /*
334  * globus_gfs_finished_info_t
335  *
336  * Final result info for an operation.
337  */
338 typedef struct globus_gfs_finished_info_s
339 {
341  globus_gfs_operation_type_t type;
343  int id;
345  int code;
348  char * msg;
350  globus_result_t result;
351 
352  union
353  {
354  globus_gfs_session_finished_info_t session;
355  globus_gfs_data_finished_info_t data;
356  globus_gfs_cmd_finshed_info_t command;
357  globus_gfs_stat_finished_info_t stat;
358  globus_gfs_transfer_finished_info_t transfer;
359  } info;
360 
362  globus_gfs_op_info_t op_info;
363 } globus_gfs_finished_info_t;
364 
365 /*
366  * globus_gfs_event_info_t
367  *
368  * Event info.
369  */
370 typedef struct globus_gfs_event_info_s
371 {
374 
377  void * event_arg;
378 
379  /* reply data */
381  int node_ndx;
383  int id;
385  int event_mask;
387  globus_off_t recvd_bytes;
389  globus_range_list_t recvd_ranges;
391  void * data_arg;
392 
393  /* request data */
395  int * eof_count;
397  int node_count;
398 
400  globus_gfs_op_info_t op_info;
401 } globus_gfs_event_info_t;
402 
403 /*
404  * globus_gfs_transfer_info_t
405  *
406  * Info needed for transfer operations (list, send, recv).
407  */
408 typedef struct globus_gfs_transfer_info_s
409 {
411  char * pathname;
413  char * module_name;
414  char * module_args;
416  char * list_type;
417 
419  globus_off_t partial_offset;
421  globus_off_t partial_length;
423  globus_range_list_t range_list;
425  globus_bool_t truncate;
426 
428  void * data_arg;
430  int eof_count;
432  int stripe_count;
434  int node_count;
436  int node_ndx;
437 
439  globus_off_t alloc_size;
440 
442  char * expected_checksum;
444  char * expected_checksum_alg;
445 
447  int list_depth;
449  int traversal_options;
450 
452  globus_gfs_op_info_t op_info;
453 } globus_gfs_transfer_info_t;
454 
455 
456 /*
457 * maintain backward source compatibility after member rename
458 */
459 #define rnfr_pathname from_pathname
460 
461 /*
462  * globus_gfs_command_info_t
463  *
464  * Info needed for a command operation.
465  */
466 typedef struct globus_gfs_command_info_s
467 {
469  globus_gfs_command_type_t command;
471  char * pathname;
472 
474  globus_off_t cksm_offset;
476  globus_off_t cksm_length;
478  char * cksm_alg;
479 
481  int chmod_mode;
482 
485  char * from_pathname;
486 
488  char * authz_assert;
489 
491  char * chgrp_group;
492 
494  time_t utime_time;
495 
497  globus_gfs_op_info_t op_info;
498 } globus_gfs_command_info_t;
499 
500 /*
501  * globus_gfs_data_info_t
502  *
503  * Info needed for data operations (active, passive).
504  */
505 typedef struct globus_gfs_data_info_s
506 {
508  globus_bool_t ipv6;
510  int nstreams;
512  char mode;
514  char type;
516  globus_size_t tcp_bufsize;
518  globus_size_t blocksize;
520  globus_size_t stripe_blocksize;
522  int stripe_layout;
523 
525  char prot;
527  char dcau;
529  char * subject;
531  char * pathname;
532 
534  int max_cs;
536  int cs_count;
538  const char ** contact_strings;
540  char * interface;
541 
542  /* if this is set, the data channel will use it instead
543  of the default session credential */
544  gss_cred_id_t del_cred;
545 
547  globus_gfs_op_info_t op_info;
548 } globus_gfs_data_info_t;
549 
550 /*
551  * globus_gfs_stat_info_t
552  *
553  * Info needed for a stat operation.
554  */
555 typedef struct globus_gfs_stat_info_s
556 {
558  globus_bool_t file_only;
560  globus_bool_t internal;
562  char * pathname;
564  globus_bool_t use_symlink_info;
566  globus_bool_t include_path_stat;
567 
569  globus_gfs_op_info_t op_info;
570 } globus_gfs_stat_info_t;
571 
572 typedef struct globus_gfs_session_info_s
573 {
574  gss_cred_id_t del_cred;
575  globus_bool_t free_cred;
576  globus_bool_t map_user;
577  char * username;
578  char * password;
579  char * subject;
580  char * cookie;
581  char * host_id;
582 
584  globus_gfs_op_info_t op_info;
585 } globus_gfs_session_info_t;
586 
587 typedef enum globus_gfs_brain_reason_e
588 {
589  GLOBUS_GFS_BRAIN_REASON_ERROR = 1,
590  GLOBUS_GFS_BRAIN_REASON_COMPLETE
591 } globus_gfs_brain_reason_t;
592 
593 typedef struct globus_i_gfs_brain_node_s
594 {
595  char * host_id;
596  char * repo_name;
597  void * brain_arg;
598  int max_connection;
599  int current_connection;
600  float load;
601 } globus_i_gfs_brain_node_t;
602 
603 /**************************************************************************
604  * Storage Module API
605  *
606  * The storage module API is made up of the interface definition,
607  * notification functions, and helper functions below.
608  *************************************************************************/
609 
610 /*
611  * globus_gfs_operation_t
612  *
613  * Operation handle. This handle is passed to and from the storage
614  * module. Its internal data should not be used.
615  */
616 typedef struct globus_l_gfs_data_operation_s * globus_gfs_operation_t;
617 
618 
619 typedef void * globus_gfs_session_config_t;
620 
625 /*
626  * init/destroy
627  *
628  * This will be called upon a new client session. Any persistent
629  * data that will be needed should be initialized and stored in a
630  * user-defined object which should be assigned to out_user_arg. This
631  * object pointer will then be passed back to the module with any other
632  * interface call.
633  */
634 typedef void
636  globus_gfs_operation_t op,
637  globus_gfs_session_info_t * session_info);
638 
639 /*
640  * This will be called when the client session ends. Final cleanup
641  * should be done here.
642  */
643 typedef void
644 (*globus_gfs_storage_destroy_t)(
645  void * user_arg);
646 
647 /*
648  * transfer
649  *
650  * This defines the functions that will be called for list, send, and recv.
651  */
652 typedef void
653 (*globus_gfs_storage_transfer_t)(
654  globus_gfs_operation_t op,
655  globus_gfs_transfer_info_t * transfer_info,
656  void * user_arg);
657 
658 /*
659  * command
660  *
661  * This defines the function that will be called for commands. The type
662  * member of command_info specifies which command to carry out.
663  */
664 typedef void
665 (*globus_gfs_storage_command_t)(
666  globus_gfs_operation_t op,
667  globus_gfs_command_info_t * command_info,
668  void * user_arg);
669 
670 /*
671  * stat
672  *
673  * This defines the function that will be called for a stat lookup.
674  */
675 typedef void
676 (*globus_gfs_storage_stat_t)(
677  globus_gfs_operation_t op,
678  globus_gfs_stat_info_t * stat_info,
679  void * user_arg);
680 
681 /*
682  * data connection
683  *
684  * This defines the functions that will be called for active and passive
685  * data connection creation.
686  */
687 typedef void
688 (*globus_gfs_storage_data_t)(
689  globus_gfs_operation_t op,
690  globus_gfs_data_info_t * data_info,
691  void * user_arg);
692 
693 /*
694  * data_destroy
695  *
696  * This defines the function that will be called to signal that a data
697  * connection should be destroyed. Note that there is no corresponding
698  * finished notification for data destroy requests.
699  */
700 typedef void
701 (*globus_gfs_storage_data_destroy_t)(
702  void * data_arg,
703  void * user_arg);
704 
705 /*
706  * data_destroy
707  *
708  * This defines the function that will be called to signal that a transfer
709  * event should occur. Note that there is no corresponding finished
710  * notification for transfer event requests.
711  */
712 typedef void
713 (*globus_gfs_storage_trev_t)(
714  globus_gfs_event_info_t * event_info,
715  void * user_arg);
716 
717 /*
718  * set cred
719  *
720  * This defines the function that will be called to pass delegated credentials.
721  * XXX more here later XXX
722  */
723 typedef void
724 (*globus_gfs_storage_set_cred_t)(
725  gss_cred_id_t del_cred,
726  void * user_arg);
727 
728 /*
729  * send user buffer
730  *
731  * This defines the function that will be called to send a user defined buffer.
732  * XXX more here later XXX
733  */
734 typedef void
735 (*globus_gfs_storage_buffer_send_t)(
736  int buffer_type,
737  globus_byte_t * buffer,
738  globus_size_t buffer_len,
739  void * user_arg);
740 
741 
742 /*
743  * realpath
744  *
745  * This defines the function that will be called to determine a true path
746  * free of symlinks or other obsfucation.
747  * if you implement this, add GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH to your
748  * globus_gfs_storage_iface_t interface definition.
749  */
750 
751 typedef globus_result_t
752 (*globus_gfs_storage_realpath_t)(
753  const char * in_path,
754  char ** out_realpath,
755  void * user_arg);
756 
757 
758 #define GLOBUS_GFS_DSI_DESCRIPTOR_SENDER (1 << 0)
759 #define GLOBUS_GFS_DSI_DESCRIPTOR_BLOCKING (1 << 1)
760 #define GLOBUS_GFS_DSI_DESCRIPTOR_HAS_REALPATH (1 << 2)
761 #define GLOBUS_GFS_DSI_DESCRIPTOR_REQUIRES_ORDERED_DATA (1 << 3)
762 #define GLOBUS_GFS_DSI_DESCRIPTOR_SETS_ERROR_RESPONSES (1 << 4)
763 #define GLOBUS_GFS_DSI_DESCRIPTOR_SAFE_RDEL (1 << 5)
764 #define GLOBUS_GFS_DSI_DESCRIPTOR_USERNAME_INCLUDES_DOMAIN (1 << 6)
765 #define GLOBUS_GFS_DSI_DESCRIPTOR_DYN_SENDER (1 << 7)
766 #define GLOBUS_GFS_DSI_DESCRIPTOR_SIZE_NOT_REQUIRED (1 << 8)
767 /*
768  * globus_gfs_storage_iface_t
769  *
770  * Storage interface function pointers. Only define functions that are
771  * implemented. If a function is not defined, the server will either fail
772  * for that particular operation, or in the case of list, data, cred, and
773  * trev funcs, the server will act on those operations itself.
774  */
775 typedef struct globus_gfs_storage_iface_s
776 {
777  int descriptor;
778 
779  /* session initiating functions */
780  globus_gfs_storage_init_t init_func;
781  globus_gfs_storage_destroy_t destroy_func;
782 
783  /* transfer functions */
784  globus_gfs_storage_transfer_t list_func;
785  globus_gfs_storage_transfer_t send_func;
786  globus_gfs_storage_transfer_t recv_func;
787  globus_gfs_storage_trev_t trev_func;
788 
789  /* data conn funcs */
790  globus_gfs_storage_data_t active_func;
791  globus_gfs_storage_data_t passive_func;
792  globus_gfs_storage_data_destroy_t data_destroy_func;
793 
794  globus_gfs_storage_command_t command_func;
795  globus_gfs_storage_stat_t stat_func;
796 
797  globus_gfs_storage_set_cred_t set_cred_func;
798  globus_gfs_storage_buffer_send_t buffer_send_func;
799  globus_gfs_storage_realpath_t realpath_func;
800 } globus_gfs_storage_iface_t;
801 
806 /*
807  * operation finished
808  *
809  * This is a generic finished notification function. Either this *or* a
810  * specific finished function below must be called upon completion of an
811  * operation with the appropriate data set in the finished_info struct,
812  * including error info if the operation failed.
813  */
814 void
816  globus_gfs_operation_t op,
817  globus_result_t result,
818  globus_gfs_finished_info_t * finished_info);
819 
820 /*
821  * operation event
822  *
823  * This is a generic event notification function. Either this *or* a
824  * specific event function below must be called upon completion of an
825  * operation with the appropriate event data set in the event_info struct.
826  */
827 void
828 globus_gridftp_server_operation_event(
829  globus_gfs_operation_t op,
830  globus_result_t result,
831  globus_gfs_event_info_t * event_info);
832 
833 /*
834  * begin transfer event
835  *
836  * Speficic event notification for the start of a transfer.
837  */
838 void
839 globus_gridftp_server_begin_transfer(
840  globus_gfs_operation_t op,
841  int event_mask,
842  void * event_arg);
843 
844 /*
845  * finished transfer
846  *
847  * Speficic finished notification for completion of a transfer.
848  */
849 void
850 globus_gridftp_server_finished_transfer(
851  globus_gfs_operation_t op,
852  globus_result_t result);
853 
854 /*
855  * finished session_start
856  *
857  * Specific finished notification for session start completion.
858  *
859  */
860 void
861 globus_gridftp_server_finished_session_start(
862  globus_gfs_operation_t op,
863  globus_result_t result,
864  void * session_arg,
865  char * username,
866  char * home_dir);
867 
868 /*
869  * finished command
870  *
871  * Speficic finished notification for completion of a command.
872  * command_response should be NULL if not used (currently only
873  * used in MKD and CKSM)
874  */
875 void
876 globus_gridftp_server_finished_command(
877  globus_gfs_operation_t op,
878  globus_result_t result,
879  char * command_response);
880 void
881 globus_gridftp_server_intermediate_command(
882  globus_gfs_operation_t op,
883  globus_result_t result,
884  char * command_response);
885 
886 /*
887  * finished stat
888  *
889  * Speficic finished notification for completion of a stat.
890  */
891 void
892 globus_gridftp_server_finished_stat(
893  globus_gfs_operation_t op,
894  globus_result_t result,
895  globus_gfs_stat_t * stat_array,
896  int stat_count);
897 
898 void
899 globus_gridftp_server_finished_stat_partial(
900  globus_gfs_operation_t op,
901  globus_result_t result,
902  globus_gfs_stat_t * stat_array,
903  int stat_count);
904 
905 void
906 globus_gridftp_server_finished_stat_custom_list(
907  globus_gfs_operation_t op,
908  globus_result_t result,
909  globus_byte_t * list_response,
910  globus_size_t list_response_len,
911  globus_bool_t free_buffer);
912 
913 /*
914  * finished active data
915  *
916  * Speficic finished notification for completion of a active data creation.
917  */
918 void
919 globus_gridftp_server_finished_active_data(
920  globus_gfs_operation_t op,
921  globus_result_t result,
922  void * data_arg,
923  globus_bool_t bi_directional);
924 
925 /*
926  * finished passive data
927  *
928  * Speficic finished notification for completion of a passive data creation.
929  */
930 void
931 globus_gridftp_server_finished_passive_data(
932  globus_gfs_operation_t op,
933  globus_result_t result,
934  void * data_arg,
935  globus_bool_t bi_directional,
936  const char ** contact_strings,
937  int cs_count);
938 
939 
940 
945 /*
946  * write
947  *
948  * Register a write of specified buffer to the server. You should use
949  * globus_gridftp_server_get_block_size()
950  * and globus_gridftp_server_get_optimal_concurrency() to determine the
951  * buffer size of each write and the number of writes you should have
952  * pending at all times. (pending meaning you are waiting for the callback).
953  */
954 typedef void
956  globus_gfs_operation_t op,
957  globus_result_t result,
958  globus_byte_t * buffer,
959  globus_size_t nbytes,
960  void * user_arg);
961 
962 globus_result_t
963 globus_gridftp_server_register_write(
964  globus_gfs_operation_t op,
965  globus_byte_t * buffer,
966  globus_size_t length,
967  globus_off_t offset,
968  int stripe_ndx,
970  void * user_arg);
971 
972 /*
973  * read
974  *
975  * Register a read of data from the server. You should use
976  * globus_gridftp_server_get_block_size()
977  * and globus_gridftp_server_get_optimal_concurrency() to determine the
978  * buffer size you should use and the number of reads you should have
979  * pending at all times. (pending meaning you are waiting for the callback).
980  */
981 typedef void
982 (*globus_gridftp_server_read_cb_t)(
983  globus_gfs_operation_t op,
984  globus_result_t result,
985  globus_byte_t * buffer,
986  globus_size_t nbytes,
987  globus_off_t offset,
988  globus_bool_t eof,
989  void * user_arg);
990 
991 globus_result_t
992 globus_gridftp_server_register_read(
993  globus_gfs_operation_t op,
994  globus_byte_t * buffer,
995  globus_size_t length,
996  globus_gridftp_server_read_cb_t callback,
997  void * user_arg);
998 
999 
1000 /*
1001  * register a custom command
1002  *
1003  * This must be called during the DSI session_start_func() function.
1004  * When a command is triggered, command_func() will be called with a
1005  * command_info->command equal to cmd_id.
1006  *
1007  * cmd_id must be >= GLOBUS_GFS_MIN_CUSTOM_CMD.
1008  *
1009  * If a command takes a pathname, it must be the final argument, and has_pathname
1010  * must be set to GLOBUS_TRUE. commands should not take multiple pathnames.
1011  *
1012  * If the command takes a pathname, set access_type to an globus_gfs_acl_action_t
1013  * like one of: GFS_ACL_ACTION_READ, GFS_ACL_ACTION_WRITE,
1014  * GFS_ACL_ACTION_CREATE, GFS_ACL_ACTION_DELETE, GFS_ACL_ACTION_LOOKUP.
1015  *
1016  * The last argument will always be passed in command_info->pathname, whether
1017  * it is a pathname or not.
1018  * Other args can be obtained by querying command_info->op_info for
1019  * GLOBUS_GFS_OP_INFO_CMD_ARGS. See globus_gridftp_server_query_op_info().
1020  *
1021  * Note for min_args and max_args, that the command itself counts as a argument
1022  * (or 2, in the case of SITE commands).
1023  *
1024  * A non-SITE command name must be exactly 4 characters long,
1025  * A SITE command (command name = "SITE SOMETHING") can be any length
1026  *
1027  * help_string should be of the form "COMMAND <sp> arg1 <sp> arg2 <sp> pathname"
1028  *
1029  * Responses are handled as with any other command. Call
1030  * globus_gridftp_server_finished_command() with a 'result' and 'command_response'.
1031  * If 'command_response' is NULL and result is success, a standard "200 OK"
1032  * response will be returned. A valid custom FTP response string should contain
1033  * a code between 200-299, and be terminated with \r\n.
1034  * i.e. "250 The command was successful\r\n".
1035  * The helper globus_gfs_custom_string_to_959() can be used to format more
1036  * complex 'command_response' strings, including multi-line responses.
1037  */
1038 
1039 globus_result_t
1040 globus_gridftp_server_add_command(
1041  globus_gfs_operation_t op,
1042  const char * command_name,
1043  int cmd_id,
1044  int min_args,
1045  int max_args,
1046  const char * help_string,
1047  globus_bool_t has_pathname,
1048  int access_type);
1049 
1050 /*
1051  * Convert a reply string to a 959 compatible message.
1052  *
1053  * This is a macro to the server control library function:
1054  *
1055  * char *
1056  * globus_gsc_string_to_959(
1057  * int code,
1058  * const char * in_str,
1059  * const char * preline);
1060  *
1061  * code is the FTP return code (ie: 200, 500, etc). in_str is
1062  * the messsage. If in_str has many lines in it, then it will be
1063  * formatted to a proper FRC959 multiline response.
1064  *
1065  * There are 2 types of multiline responses. If preline is NULL
1066  * then this will format the message in the style:
1067  * 200-<Line>
1068  * 200-<more>
1069  * 200 End.
1070  *
1071  * If you sett preline to a whitespace you will get:
1072  * 200-<Line>
1073  * <more>
1074  * 200 End.
1075  *
1076  * You must free the returned string
1077  */
1078 
1079 #define globus_gfs_custom_string_to_959 globus_gsc_string_to_959
1080 
1081 
1096 globus_result_t
1098  globus_gfs_operation_t op,
1099  const char * cksm_str);
1100 
1105 typedef enum
1106 {
1107  /* return argv and argc for the current command. usually called when
1108  * handling custom commands.
1109  *
1110  * char *** argv,
1111  * int * argc
1112  */
1113  GLOBUS_GFS_OP_INFO_CMD_ARGS = 1
1115 
1116 /* query op_info for parameters
1117  * query parameters listed in the globus_gfs_op_info_param_t enum.
1118  * the varargs should be populated with variables of the correct type to hold
1119  * the returning parameters for the requested param type.
1120  *
1121 */
1122 globus_result_t
1123 globus_gridftp_server_query_op_info(
1124  globus_gfs_operation_t op,
1125  globus_gfs_op_info_t op_info,
1127  ...);
1128 
1129 /* check for attributes applicable to the current recv operation.
1130  * requested_attr is a case-insensitive string indicating the attribute
1131  * whose value will returned in out_value. requested_attr may be NULL, in
1132  * which case the full attr string will be returned in out_value.
1133  *
1134  * the format of the full attr string is attr1=value;attr2=value;...
1135  *
1136  * it is the caller's responsibility to free() out_value after a succesful return.
1137 */
1138 
1139 globus_result_t
1140 globus_gridftp_server_get_recv_attr_string(
1141  globus_gfs_operation_t op,
1142  const char * requested_attr,
1143  char ** out_value);
1144 
1145 /* get intended modification time for the file being received. out_time
1146  * will be the same as if a UTIME/MDTM command had been issued. if the modify
1147  * time has not been requested by the client, this will return GLOBUS_SUCCESS
1148  * but out_time will be -1.
1149  */
1150 
1151 globus_result_t
1152 globus_gridftp_server_get_recv_modification_time(
1153  globus_gfs_operation_t op,
1154  time_t * out_time);
1155 
1156 /*
1157  * update bytes written to storage
1158  *
1159  * This should be called during a recv(), after each successful write
1160  * to the storage system.
1161  *
1162  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1163  * both globus_gridftp_server_update_bytes_recvd() and
1164  * globus_gridftp_server_update_range_recvd() for a given range.
1165  */
1166 void
1167 globus_gridftp_server_update_bytes_written(
1168  globus_gfs_operation_t op,
1169  globus_off_t offset,
1170  globus_off_t length);
1171 
1172 /*
1173  * update bytes recieved, but not yet written to storage
1174  * use this when there may be a delay between reciving data
1175  * and writing to storage. this will ensure accurate performance
1176  * markers, but will not cause range/restart markers to be sent.
1177  *
1178  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1179  * both globus_gridftp_server_update_bytes_recvd() and
1180  * globus_gridftp_server_update_range_recvd() for a given range.
1181  */
1182 void
1183 globus_gridftp_server_update_bytes_recvd(
1184  globus_gfs_operation_t op,
1185  globus_off_t length);
1186 
1187 /*
1188  * update bytes written to storage
1189  * use this when there may be a delay between reciving data
1190  * and writing to storage. this will cause range/restart markers
1191  * to be sent.
1192  *
1193  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1194  * both globus_gridftp_server_update_bytes_recvd() and
1195  * globus_gridftp_server_update_range_recvd() for a given range.
1196  */
1197 void
1198 globus_gridftp_server_update_range_recvd(
1199  globus_gfs_operation_t op,
1200  globus_off_t offset,
1201  globus_off_t length);
1202 
1203 /*
1204  * get concurrency
1205  *
1206  * This should be called during a recv() and send() in order to know the
1207  * number of pending reads or writes you should have at once.
1208  */
1209 void
1210 globus_gridftp_server_get_optimal_concurrency(
1211  globus_gfs_operation_t op,
1212  int * count);
1213 
1214 /*
1215  * get blocksize
1216  *
1217  * This should be called during a recv() and send() in order to know the
1218  * size of buffers that you should be passing to the server for reads and
1219  * writes.
1220  */
1221 void
1222 globus_gridftp_server_get_block_size(
1223  globus_gfs_operation_t op,
1224  globus_size_t * block_size);
1225 
1226 /*
1227  * get stripe blocksize
1228  *
1229  * This can be called during a recv() and send() in modules that wish to
1230  * deal with striping.
1231  */
1232 void
1233 globus_gridftp_server_get_stripe_block_size(
1234  globus_gfs_operation_t op,
1235  globus_size_t * stripe_block_size);
1236 
1237 /*
1238  * get session username
1239  *
1240  * This should can be called to get the username that the process is running
1241  * under, which may be different from the username supplied in the
1242  * session_start call in some cases.
1243  */
1244 void
1245 globus_gridftp_server_get_session_username(
1246  globus_gfs_operation_t op,
1247  char ** username);
1248 
1249 /*
1250  * get delegated cred
1251  *
1252  * This can can be called to get the delegated credential. This may be called
1253  * with any op after session_start() and and the credential pointer will be
1254  * valid until at least session_stop. del_cred will be NULL if it is not
1255  * available.
1256  */
1257 void
1258 globus_gridftp_server_get_delegated_cred(
1259  globus_gfs_operation_t op,
1260  gss_cred_id_t * del_cred);
1261 
1262 /*
1263  * get security context (unsupported)
1264  *
1265  * This can can be called to get the gssapi security context of the client
1266  * connection. This may be called with any op after session_start() and
1267  * the context pointer will be valid until at least session_stop. context
1268  * will be NULL if it is not available. This is needed for accessing proxy
1269  * extensions or other gssapi operations where the delegated credential is
1270  * not sufficient. The caller should not attempt operations that modify the
1271  * context without fully understanding the effects.
1272  */
1273 void
1274 globus_gridftp_server_get_sec_context(
1275  globus_gfs_operation_t op,
1276  gss_ctx_id_t * context);
1277 
1278 
1279 /*
1280  * get/set ordered data requirement
1281  *
1282  * The DSI must call this before globus_gridftp_server_begin_transfer()
1283  * to set the ordered_data flag. This will ensure that the offsets read
1284  * in each data callback are in order, even when multiple streams are used.
1285  * This will result in the transfer slowing down to match the speed of the
1286  * slowest stream. Note: in cases where the data source intentionally sends
1287  * data out of order, this will result in an aborted transfer. However,
1288  * a DSI that needs ordered data would probably fail in such a scenario anyway.
1289  *
1290  * Instead of calling these functions, you can enable this setting for all
1291  * transfers by setting GLOBUS_GFS_DSI_DESCRIPTOR_REQUIRES_ORDERED_DATA
1292  * in the globus_gfs_storage_iface_t interface definition.
1293  */
1294 void
1295 globus_gridftp_server_set_ordered_data(
1296  globus_gfs_operation_t op,
1297  globus_bool_t ordered_data);
1298 
1299 void
1300 globus_gridftp_server_get_ordered_data(
1301  globus_gfs_operation_t op,
1302  globus_bool_t * ordered_data);
1303 
1304 /*
1305  * get config string
1306  *
1307  * This can be called to get the dsi specific configuration string
1308  * that is defined in the global configuration.
1309  */
1310 void
1311 globus_gridftp_server_get_config_string(
1312  globus_gfs_operation_t op,
1313  char ** config_string);
1314 
1315 /*
1316  * get config data
1317  *
1318  * This can be called to get the configuration data managed by the server.
1319  * data_id can be NULL, or can be used to specify a specific set of data.
1320  */
1321 void
1322 globus_gridftp_server_get_config_data(
1323  globus_gfs_operation_t op,
1324  char * data_id,
1325  char ** config_data);
1326 
1327 void
1328 globus_gridftp_server_session_get_config_data(
1329  globus_gfs_session_config_t session_conf_handle,
1330  char * data_id,
1331  char ** config_data);
1332 
1333 void
1334 globus_gridftp_server_get_session_config_handle(
1335  globus_gfs_operation_t op,
1336  globus_gfs_session_config_t * out_session_conf_handle);
1337 
1338 void
1339 globus_gfs_data_get_file_stack_list(
1340  globus_gfs_operation_t in_op,
1341  globus_list_t ** out_list);
1342 
1343 void
1344 globus_gridftp_server_get_update_interval(
1345  globus_gfs_operation_t op,
1346  int * interval);
1347 
1348 /*
1349  * get Transfer task ID
1350  *
1351  * Returns the Transfer task ID associated with the current GridFTP session.
1352  * If a task id is not known, return NULL instead.
1353  */
1354 void
1355 globus_gridftp_server_get_task_id(
1356  globus_gfs_operation_t op,
1357  char ** task_id);
1358 
1359 /*
1360  * get read_range
1361  *
1362  * This should be called during send() in order to know the specific
1363  * offset and length of the file to read from the storage system
1364  * You should continue calling this and transferring the speficied data
1365  * until it returns a length of 0.
1366  */
1367 void
1368 globus_gridftp_server_get_read_range(
1369  globus_gfs_operation_t op,
1370  globus_off_t * offset,
1371  globus_off_t * length);
1372 
1373 
1374 /*
1375  * get write_range
1376  *
1377  * This could be called during recv() in order to get hints on the specific
1378  * offset and length that the data will be expected to come from
1379  * globus_gridftp_server_register_read() callbacks. Note that this is
1380  * only a hint, and not necessarily the exact data ranges that will come.
1381  * You would continue calling this until it returns a length of 0.
1382  */
1383 void
1384 globus_gridftp_server_get_write_range(
1385  globus_gfs_operation_t op,
1386  globus_off_t * offset,
1387  globus_off_t * length);
1388 
1389 
1390 /* END Storage Interface API */
1391 
1392 typedef enum
1393 {
1394  GLOBUS_GFS_LOG_ERR = 0x01,
1395  GLOBUS_GFS_LOG_WARN = 0x02,
1396  GLOBUS_GFS_LOG_TRANSFER = 0x04,
1397  GLOBUS_GFS_LOG_INFO = 0x08,
1398  GLOBUS_GFS_LOG_DUMP = 0x10,
1399  GLOBUS_GFS_LOG_ALL = 0xFF,
1400  GLOBUS_GFS_LOG_AUDIT = 0x100
1401 } globus_gfs_log_type_t;
1402 
1403 void
1404 globus_gfs_log_message(
1405  globus_gfs_log_type_t type,
1406  const char * format,
1407  ...);
1408 
1409 void
1410 globus_gfs_log_result(
1411  globus_gfs_log_type_t type,
1412  const char * lead,
1413  globus_result_t result);
1414 
1416 enum
1417 {
1418  GLOBUS_GFS_DEBUG_TRACE = 8,
1419  GLOBUS_GFS_DEBUG_INFO = 16,
1420  GLOBUS_GFS_DEBUG_STATE = 32
1421 };
1422 
1423 #ifdef __GNUC__
1424 #define GlobusGFSName(func) static const char * _gfs_name __attribute__((__unused__)) = #func
1425 #else
1426 #define GlobusGFSName(func) static const char * _gfs_name = #func
1427 #endif
1428 
1429 GlobusDebugDeclare(GLOBUS_GRIDFTP_SERVER);
1430 
1431 #define GlobusGFSDebugPrintf(level, message) \
1432  GlobusDebugPrintf(GLOBUS_GRIDFTP_SERVER, level, message)
1433 
1434 
1435 #define GlobusGFSDebugInfoF(_msg) \
1436 do \
1437 { \
1438  GlobusGFSDebugPrintf( \
1439  GLOBUS_GFS_DEBUG_INFO, \
1440  ("[%s:%d] (pid=%d) [%s] ", __FILE__, __LINE__, getpid(), __func__));\
1441  GlobusGFSDebugPrintf( \
1442  GLOBUS_GFS_DEBUG_INFO, \
1443  _msg); \
1444 } while(0)
1445 
1446 #define GlobusGFSDebugResultT(_result, _msg) \
1447 do \
1448 { \
1449  char * _err_str = globus_error_print_friendly( \
1450  globus_error_peek(_result)); \
1451  GlobusGFSDebugInfoF(("%s: %s\n", _msg, _err_str)); \
1452  free(_err_str); \
1453 } while(0)
1454 
1455 #define GlobusGFSDebugInfo(_msg) \
1456  GlobusGFSDebugPrintf( \
1457  GLOBUS_GFS_DEBUG_INFO, \
1458  ("[%s] %s\n", __func__, _msg))
1459 
1460 #define GlobusGFSDebugEnter() \
1461  GlobusGFSDebugPrintf( \
1462  GLOBUS_GFS_DEBUG_TRACE, \
1463  ("[%s] Entering\n", __func__))
1464 
1465 #define GlobusGFSDebugExitResult(res) \
1466  GlobusGFSDebugPrintf( \
1467  GLOBUS_GFS_DEBUG_TRACE, \
1468  ("[%s] Exiting%s\n", \
1469  __func__, \
1470  (res != GLOBUS_SUCCESS) ? " with error" : ""))
1471 
1472 #define GlobusGFSDebugExit() \
1473  GlobusGFSDebugPrintf( \
1474  GLOBUS_GFS_DEBUG_TRACE, \
1475  ("[%s] Exiting\n", __func__))
1476 
1477 #define GlobusGFSDebugState(_state) \
1478  GlobusGFSDebugPrintf( \
1479  GLOBUS_GFS_DEBUG_INFO, \
1480  ("[%s] State: %d\n", __func__, _state))
1481 
1482 #define GlobusGFSDebugExitWithError() \
1483  GlobusGFSDebugPrintf( \
1484  GLOBUS_GFS_DEBUG_TRACE, \
1485  ("[%s] Exiting with error\n", __func__))
1486 
1487 #define GlobusGFSErrorParameter(mem_name) \
1488  globus_error_put(GlobusGFSErrorObjParameter(mem_name))
1489 
1490 #define GlobusGFSErrorIPC() \
1491  globus_error_put(GlobusGFSErrorObjIPC())
1492 
1493 #define GlobusGFSErrorObjIPC() \
1494  globus_error_construct_error( \
1495  NULL, \
1496  NULL, \
1497  GLOBUS_GFS_ERROR_MEMORY, \
1498  __FILE__, \
1499  __func__, \
1500  __LINE__, \
1501  "IPC Communication error.")
1502 
1503 #define GlobusGFSErrorObjParameter(param_name) \
1504  globus_error_construct_error( \
1505  NULL, \
1506  NULL, \
1507  GLOBUS_GFS_ERROR_PARAMETER, \
1508  __FILE__, \
1509  __func__, \
1510  __LINE__, \
1511  "invalid parameter: %s", \
1512  (param_name))
1513 
1514 #define GlobusGFSErrorSystemError(system_func, system_errno) \
1515  globus_error_put(GlobusGFSErrorObjSystemError(\
1516  (system_func), (system_errno)))
1517 #define GlobusGFSErrorObjSystemError(system_func, system_errno) \
1518  globus_i_gfs_error_system( \
1519  0, (system_errno), \
1520  "System error%s%s", \
1521  (system_func) != NULL ? " in " : "", \
1522  (system_func) != NULL ? (system_func) : "")
1523 
1524 #define GlobusGFSErrorWrapFailed(failed_func, result) \
1525  globus_error_put(GlobusGFSErrorObjWrapFailed(failed_func, result))
1526 
1527 #define GlobusGFSErrorObjWrapFailed(failed_func, result) \
1528  globus_error_construct_error( \
1529  NULL, \
1530  globus_error_get((result)), \
1531  GLOBUS_GFS_ERROR_WRAPPED, \
1532  __FILE__, \
1533  __func__, \
1534  __LINE__, \
1535  "%s failed.", \
1536  (failed_func))
1537 
1538 #define GlobusGFSErrorData(reason) \
1539  globus_error_put(GlobusGFSErrorObjData(reason))
1540 
1541 #define GlobusGFSErrorObjData(reason) \
1542  globus_error_construct_error( \
1543  NULL, \
1544  NULL, \
1545  GLOBUS_GFS_ERROR_DATA, \
1546  __FILE__, \
1547  __func__, \
1548  __LINE__, \
1549  "%s", \
1550  (reason))
1551 
1552 #define GlobusGFSErrorGeneric(reason) \
1553  globus_error_put(GlobusGFSErrorObjGeneric(reason))
1554 
1555 #define GlobusGFSErrorObjGeneric(reason) \
1556  globus_error_construct_error( \
1557  NULL, \
1558  NULL, \
1559  GLOBUS_GFS_ERROR_GENERIC, \
1560  __FILE__, \
1561  __func__, \
1562  __LINE__, \
1563  "%s", \
1564  (reason))
1565 
1566 globus_object_t *
1568  globus_module_descriptor_t * base_source,
1569  globus_object_t * base_cause,
1570  int response_code,
1571  const char *response_error_code,
1572  const char *fmt,
1573  ...);
1574 
1575 globus_object_t *
1577  globus_object_t * error,
1578  globus_module_descriptor_t * base_source,
1579  globus_object_t * base_cause,
1580  int response_code,
1581  const char * response_error_code,
1582  const char * fmt,
1583  va_list ap);
1584 globus_object_t *
1586  globus_object_t * error,
1587  globus_module_descriptor_t * base_source,
1588  globus_object_t * base_cause,
1589  int response_code,
1590  const char * response_error_code,
1591  const char * fmt,
1592  ...);
1593 
1594 int
1596  globus_object_t * error);
1597 
1598 const char *
1600  globus_object_t * error);
1601 
1602 globus_bool_t
1604  globus_object_t * error,
1605  const char * response_error_code);
1606 
1607 extern const globus_object_type_t
1609 
1610 #define GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE \
1611  (&GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE_DEFINITION)
1612 
1613 
1614 #define GlobusGFSErrorFtpResponse(cause, code, response_error_code, ...) \
1615  globus_error_put(GlobusGFSErrorObjFtpResponse( \
1616  cause, code, response_error_code, __VA_ARGS__))
1617 
1618 #define GlobusGFSErrorObjFtpResponse(cause, code, response_error_code, ...) \
1619  globus_gfs_ftp_response_error_construct( \
1620  NULL, \
1621  cause, \
1622  code, \
1623  response_error_code, \
1624  __VA_ARGS__)
1625 
1626 globus_object_t *
1627 globus_i_gfs_error_system(int ftp_code, int system_errno, const char *fmt, ...);
1628 
1629 #define GlobusGFSErrorMemory(mem) \
1630  globus_error_put(GlobusGFSErrorObjMemory(mem))
1631 #define GlobusGFSErrorObjMemory(mem) \
1632  GlobusGFSErrorObjSystemError("malloc", errno)
1633 
1634 #define GlobusGFSErrorObj(cause, response_code, ...) \
1635  GlobusGFSErrorObjFtpResponse(cause, response_code, __VA_ARGS__)
1636 
1637 #define GlobusGFSErrorPathNotFound(p) \
1638  globus_error_put(GlobusGFSErrorObjPathNotFound(NULL, p))
1639 #define GlobusGFSErrorObjPathNotFound(cause, p) \
1640  GlobusGFSErrorObj((cause), 550, "PATH_NOT_FOUND", \
1641  "%s%s%s", \
1642  ((p) != NULL) ? "GridFTP-Path: \"" : "", \
1643  ((p) != NULL) ? (p) : "", \
1644  ((p) != NULL) ? "\"" : "")
1645 
1646 #define GlobusGFSErrorIncorrectChecksum(computed, expected) \
1647  globus_error_put(GlobusGFSErrorObjIncorrectChecksum( \
1648  NULL, computed, expected))
1649 #define GlobusGFSErrorObjIncorrectChecksum(cause, computed, expected) \
1650  GlobusGFSErrorObj( \
1651  (cause), \
1652  550, \
1653  "INCORRECT_CHECKSUM", \
1654  "GridFTP-Computed-Checksum: %s\n" \
1655  "GridFTP-Expected-Checksum: %s", (computed), (expected))
1656 
1657 #define GlobusGFSErrorMultipartUploadNotFound() \
1658  globus_error_put(GlobusGFSErrorObjMultipartUploadNotFound(NULL))
1659 #define GlobusGFSErrorObjMultipartUploadNotFound(cause) \
1660  GlobusGFSErrorObj(cause, 553, "MULTI_PART_UPLOAD_NOT_FOUND", NULL)
1661 
1662 #define GlobusGFSErrorAppendNotSupported() \
1663  globus_error_put(GlobusGFSErrorObjAppendNotSupported(NULL))
1664 #define GlobusGFSErrorObjAppendNotSupported(cause) \
1665  GlobusGFSErrorObj((cause), 553, "APPEND_NOT_SUPPORTED", NULL)
1666 
1667 #define GlobusGFSErrorAmbiguousPath(ambiguity) \
1668  globus_error_put(GlobusGFSErrorObjAmbiguousPath(NULL, ambiguity))
1669 #define GlobusGFSErrorObjAmbiguousPath(cause, ambiguity) \
1670  GlobusGFSErrorObj( \
1671  (cause), \
1672  553, \
1673  "AMBIGUOUS_PATH", \
1674  "GridFTP-Path: %s", \
1675  (ambiguity))
1676 
1677 #define GlobusGFSErrorTooBusy() \
1678  globus_error_put(GlobusGFSErrorObjTooBusy(NULL))
1679 #define GlobusGFSErrorObjTooBusy(cause) \
1680  GlobusGFSErrorObj((cause), 451, "TOO_BUSY", NULL)
1681 
1682 #define GlobusGFSErrorDataChannelAuthenticationFailure() \
1683  globus_error_put(GlobusGFSErrorObjDataChannelAuthenticationFailure( \
1684  NULL))
1685 #define GlobusGFSErrorObjDataChannelAuthenticationFailure(cause) \
1686  GlobusGFSErrorObj((cause), 425, \
1687  "DATA_CHANNEL_AUTHENTICATION_FAILURE", NULL)
1688 
1689 #define GlobusGFSErrorDataChannelCommunicationFailure() \
1690  globus_error_put(GlobusGFSErrorObjDataChannelCommunicationFailure( \
1691  NULL))
1692 #define GlobusGFSErrorObjDataChannelCommunicationFailure(cause) \
1693  GlobusGFSErrorObj((cause), 425, \
1694  "DATA_CHANNEL_COMMUNICATION_FAILURE", NULL)
1695 
1696 #define GlobusGFSErrorLoginDenied() \
1697  globus_error_put(GlobusGFSErrorObjLoginDenied(NULL))
1698 #define GlobusGFSErrorObjLoginDenied(cause) \
1699  GlobusGFSErrorObj((cause), 530, "LOGIN_DENIED", NULL)
1700 
1701 #define GlobusGFSErrorLoginDeniedJSON(message, json) \
1702  globus_error_put(GlobusGFSErrorObjLoginDeniedJSON(NULL, message, json))
1703 #define GlobusGFSErrorObjLoginDeniedJSON(cause, message, json) \
1704  GlobusGFSErrorObj((cause), 530, "LOGIN_DENIED", \
1705  "GridFTP-Message: %s\n" \
1706  "GridFTP-JSON-Result: %s", \
1707  (message) ? (message) : "Message not available", (json))
1708 
1709 #define GlobusGFSErrorEndpointError() \
1710  globus_error_put(GlobusGFSErrorObjEndpointError(NULL))
1711 #define GlobusGFSErrorObjEndpointError(cause) \
1712  GlobusGFSErrorObj((cause), 530, "ENDPOINT_ERROR", NULL)
1713 
1714 #define GlobusGFSErrorPermissionDenied() \
1715  globus_error_put(GlobusGFSErrorObjPermissionDenied(NULL))
1716 #define GlobusGFSErrorObjPermissionDenied(cause) \
1717  GlobusGFSErrorObj((cause), 550, "PERMISSION_DENIED", NULL)
1718 
1719 #define GlobusGFSErrorQuotaExceeded() \
1720  globus_error_put(GlobusGFSErrorObjQuotaExceeded(NULL))
1721 #define GlobusGFSErrorObjQuotaExceeded(cause) \
1722  GlobusGFSErrorObj((cause), 451, "QUOTA_EXCEEDED", NULL)
1723 
1724 #define GlobusGFSErrorNoSpaceLeft() \
1725  globus_error_put(GlobusGFSErrorObjNoSpaceLeft(NULL))
1726 #define GlobusGFSErrorObjNoSpaceLeft(cause) \
1727  GlobusGFSErrorObj((cause), 451, "NO_SPACE_LEFT", NULL)
1728 
1729 #define GlobusGFSErrorInvalidPathName(name) \
1730  globus_error_put(GlobusGFSErrorObjInvalidPathName(NULL, name))
1731 #define GlobusGFSErrorObjInvalidPathName(cause, name) \
1732  GlobusGFSErrorObj((cause), 553, "INVALID_PATH_NAME", \
1733  "GridFTP-Path: %s", name)
1734 
1735 #define GlobusGFSErrorPathExists(name) \
1736  globus_error_put(GlobusGFSErrorObjPathExists(NULL, name))
1737 #define GlobusGFSErrorObjPathExists(cause, name) \
1738  GlobusGFSErrorObj((cause), 553, "PATH_EXISTS", \
1739  "GridFTP-Path: %s", name)
1740 
1741 #define GlobusGFSErrorIsADirectory(name) \
1742  globus_error_put(GlobusGFSErrorObjIsADirectory(NULL, name))
1743 #define GlobusGFSErrorObjIsADirectory(cause, name) \
1744  GlobusGFSErrorObj((cause), 553, "IS_A_DIRECTORY", \
1745  "GridFTP-Path: %s", name)
1746 
1747 #define GlobusGFSErrorNotADirectory(name) \
1748  globus_error_put(GlobusGFSErrorObjNotADirectory(NULL, name))
1749 #define GlobusGFSErrorObjNotADirectory(cause, name) \
1750  GlobusGFSErrorObj((cause), 553, "NOT_A_DIRECTORY", \
1751  "GridFTP-Path: %s", name)
1752 
1753 #define GlobusGFSErrorCRLError() \
1754  globus_error_put(GlobusGFSErrorObjCRLError(NULL))
1755 #define GlobusGFSErrorObjCRLError(cause) \
1756  GlobusGFSErrorObj((cause), 530, "CRL_ERROR", NULL)
1757 
1758 #define GlobusGFSErrorInternalError(generic_string) \
1759  globus_error_put(GlobusGFSErrorObjInternalError( \
1760  NULL, (generic_string)))
1761 #define GlobusGFSErrorObjInternalError(cause, generic_string) \
1762  GlobusGFSErrorObj((cause), 500, "INTERNAL_ERROR", \
1763  "%s%s", \
1764  ((generic_string) != NULL) ? "GridFTP-Error: " : "", \
1765  ((generic_string) != NULL) ? generic_string : "")
1766 
1767 #define GlobusGFSErrorNotImplemented() \
1768  globus_error_put(GlobusGFSErrorObjNotImplemented(NULL))
1769 #define GlobusGFSErrorObjNotImplemented(cause) \
1770  GlobusGFSErrorObj((cause), 500, "NOT_IMPLEMETED", NULL)
1771 
1772 #define GlobusGFSErrorNotImplementedFeature(feature) \
1773  globus_error_put(GlobusGFSErrorObjNotImplementedFeature(NULL, feature))
1774 #define GlobusGFSErrorObjNotImplementedFeature(cause, feature) \
1775  GlobusGFSErrorObj((cause), 500, \
1776  "NOT_IMPLEMETED", "GridFTP-Feature: %s", (feature))
1777 
1778 #define GlobusGFSErrorConfigurationError() \
1779  globus_error_put(GlobusGFSErrorObjConfigurationError(NULL))
1780 #define GlobusGFSErrorObjConfigurationError(cause) \
1781  GlobusGFSErrorObj((cause), 500, "CONFIGURATION_ERROR", NULL)
1782 
1783 
1784 /* Checksums */
1785 
1786 /* init, update update update ..., finalize.
1787  caller is responsible for freeing checksum_str.
1788 */
1789 
1790 #define GLOBUS_GFS_BUILTIN_CHECKSUM_SUPPORT "MD5:10;ADLER32:10;SHA1:10;CRC32C:10;SHA256:12;SHA512:11;QuickXORHex:12;Dropbox:12;"
1791 
1792 typedef struct globus_l_gfs_checksum_state_s * globus_gfs_checksum_state_t;
1793 
1794 globus_result_t
1795 globus_gfs_checksum_init(
1796  const char * algorithm,
1797  globus_gfs_checksum_state_t * state);
1798 
1799 globus_result_t
1800 globus_gfs_checksum_update(
1801  globus_gfs_checksum_state_t state,
1802  const unsigned char * buffer,
1803  size_t nbytes);
1804 
1805 globus_result_t
1806 globus_gfs_checksum_finalize(
1807  globus_gfs_checksum_state_t state,
1808  char ** checksum_str);
1809 
1810 /*
1811  *
1812  * IPC
1813  *
1814  */
1815 
1816 typedef struct globus_i_gfs_ipc_handle_s * globus_gfs_ipc_handle_t;
1817 
1818 /*
1819  * callbacks
1820  *
1821  * all functions have the same callback, they examine the
1822  * globus_gfs_finished_info_t() structure for their specific info
1823  *
1824  * error_cb
1825  * can be called at anytime. typically means the ipc connection broke
1826  * in an irrecoverable way. Even tho this is called all outstanding
1827  * callbacks will still be called (but with an error)
1828  */
1829 
1830  /*
1831  * replying
1832  *
1833  * every comman requires a reply and comes with a reply id. to reply
1834  * the requested side must fill in the globus_gfs_finished_info_t
1835  * structure and then pass it
1836  * to the function: globus_gfs_ipc_reply(); That call will result in
1837  * the ipc communication that will untilimately call the callback
1838  * on the callers side.
1839  */
1840 typedef void
1841 (*globus_gfs_ipc_callback_t)(
1842  globus_gfs_ipc_handle_t ipc_handle,
1843  globus_result_t result,
1844  globus_gfs_finished_info_t * reply,
1845  void * user_arg);
1846 
1847 typedef void
1848 (*globus_gfs_ipc_event_callback_t)(
1849  globus_gfs_ipc_handle_t ipc_handle,
1850  globus_result_t result,
1851  globus_gfs_event_info_t * reply,
1852  void * user_arg);
1853 
1854 typedef void
1855 (*globus_gfs_ipc_close_callback_t)(
1856  globus_gfs_ipc_handle_t ipc_handle,
1857  globus_result_t result,
1858  void * user_arg);
1859 
1860 typedef void
1861 (*globus_gfs_ipc_open_callback_t)(
1862  globus_gfs_ipc_handle_t ipc_handle,
1863  globus_result_t result,
1864  globus_gfs_finished_info_t * reply,
1865  void * user_arg);
1866 
1867 typedef void
1868 (*globus_gfs_ipc_error_callback_t)(
1869  globus_gfs_ipc_handle_t ipc_handle,
1870  globus_result_t result,
1871  void * user_arg);
1872 
1873 globus_result_t
1874 globus_gfs_ipc_reply_finished(
1875  globus_gfs_ipc_handle_t ipc_handle,
1876  globus_gfs_finished_info_t * reply);
1877 
1878 globus_result_t
1879 globus_gfs_ipc_reply_event(
1880  globus_gfs_ipc_handle_t ipc_handle,
1881  globus_gfs_event_info_t * reply);
1882 
1883 globus_result_t
1884 globus_gfs_ipc_reply_session(
1885  globus_gfs_ipc_handle_t ipc_handle,
1886  globus_gfs_finished_info_t * reply);
1887 
1888 /*
1889  * sending
1890  *
1891  * every command has a corresponding iface function. A call to a
1892  * command function results in a call to the correspoding iface
1893  * function on the other side of the channel.
1894  *
1895  * all parmeters are wrapped in a structure corresponding to
1896  * each function call type. those structures are defined below
1897  */
1898 
1899 typedef void
1900 (*globus_i_gfs_ipc_data_callback_t)(
1901  globus_gfs_finished_info_t * reply,
1902  void * user_arg);
1903 
1904 typedef void
1905 (*globus_i_gfs_ipc_data_event_callback_t)(
1906  globus_gfs_event_info_t * reply,
1907  void * user_arg);
1908 
1909 typedef void
1910 (*globus_i_gfs_ipc_done_callback_t)(
1911  void * user_arg,
1912  globus_result_t result);
1913 
1914 /*************************************************************************
1915  * interface function
1916  * ------------------
1917  *
1918  ************************************************************************/
1919 /* works with handle get */
1920 typedef void
1921 (*globus_gfs_ipc_iface_session_start_t)(
1922  globus_gfs_ipc_handle_t ipc_handle,
1923  const gss_ctx_id_t context,
1924  globus_gfs_session_info_t * session_info,
1925  globus_i_gfs_ipc_data_callback_t cb,
1926  void * user_arg);
1927 
1928 globus_result_t
1929 globus_gfs_ipc_start_session(
1930  globus_gfs_ipc_handle_t ipc_handle,
1931  globus_gfs_session_info_t * session_info,
1932  globus_gfs_ipc_callback_t cb,
1933  void * user_arg);
1934 
1935 /* works with release */
1936 typedef void
1937 (*globus_gfs_ipc_iface_session_stop_t)(
1938  globus_gfs_ipc_handle_t ipc_handle,
1939  void * session_handle);
1940 
1941 globus_result_t
1942 globus_gfs_ipc_iface_session_stop(
1943  globus_gfs_ipc_handle_t ipc_handle,
1944  void * session_handle);
1945 
1946 typedef void
1947 (*globus_gfs_ipc_iface_set_cred_t)(
1948  globus_gfs_ipc_handle_t ipc_handle,
1949  void * session_handle,
1950  gss_cred_id_t del_cred);
1951 
1952 globus_result_t
1953 globus_gfs_ipc_set_cred(
1954  globus_gfs_ipc_handle_t ipc_handle,
1955  gss_cred_id_t del_cred);
1956 
1957 typedef void
1958 (*globus_gfs_ipc_iface_buffer_send_t)(
1959  globus_gfs_ipc_handle_t ipc_handle,
1960  void * session_handle,
1961  globus_byte_t * buffer,
1962  int buffer_type,
1963  globus_size_t buffer_len);
1964 
1965 globus_result_t
1966 globus_gfs_ipc_request_buffer_send(
1967  globus_gfs_ipc_handle_t ipc_handle,
1968  globus_byte_t * buffer,
1969  int buffer_type,
1970  globus_size_t buffer_len);
1971 
1972 /*
1973  * receive
1974  *
1975  * tell the remote process to receive a file
1976  */
1977 typedef void
1978 (*globus_gfs_ipc_iface_recv_t)(
1979  globus_gfs_ipc_handle_t ipc_handle,
1980  void * session_handle,
1981  int id,
1982  globus_gfs_transfer_info_t * recv_info,
1983  globus_i_gfs_ipc_data_callback_t cb,
1984  globus_i_gfs_ipc_data_event_callback_t event_cb,
1985  void * user_arg);
1986 
1987 globus_result_t
1988 globus_gfs_ipc_request_recv(
1989  globus_gfs_ipc_handle_t ipc_handle,
1990  globus_gfs_transfer_info_t * recv_info,
1991  globus_gfs_ipc_callback_t cb,
1992  globus_gfs_ipc_event_callback_t event_cb,
1993  void * user_arg);
1994 
1995 /*
1996  * send
1997  *
1998  * tell remote process to send a file
1999  */
2000 typedef void
2001 (*globus_gfs_ipc_iface_send_t)(
2002  globus_gfs_ipc_handle_t ipc_handle,
2003  void * session_handle,
2004  int id,
2005  globus_gfs_transfer_info_t * send_info,
2006  globus_i_gfs_ipc_data_callback_t cb,
2007  globus_i_gfs_ipc_data_event_callback_t event_cb,
2008  void * user_arg);
2009 
2010 globus_result_t
2011 globus_gfs_ipc_request_send(
2012  globus_gfs_ipc_handle_t ipc_handle,
2013  globus_gfs_transfer_info_t * send_info,
2014  globus_gfs_ipc_callback_t cb,
2015  globus_gfs_ipc_event_callback_t event_cb,
2016  void * user_arg);
2017 
2018 typedef void
2019 (*globus_gfs_ipc_iface_list_t)(
2020  globus_gfs_ipc_handle_t ipc_handle,
2021  void * session_handle,
2022  int id,
2023  globus_gfs_transfer_info_t * list_info,
2024  globus_i_gfs_ipc_data_callback_t cb,
2025  globus_i_gfs_ipc_data_event_callback_t event_cb,
2026  void * user_arg);
2027 
2028 globus_result_t
2029 globus_gfs_ipc_request_list(
2030  globus_gfs_ipc_handle_t ipc_handle,
2031  globus_gfs_transfer_info_t * data_info,
2032  globus_gfs_ipc_callback_t cb,
2033  globus_gfs_ipc_event_callback_t event_cb,
2034  void * user_arg);
2035 
2036 /*
2037  * command
2038  *
2039  * tell remote side to execute the given command
2040  */
2041 typedef void
2042 (*globus_gfs_ipc_iface_command_t)(
2043  globus_gfs_ipc_handle_t ipc_handle,
2044  void * session_handle,
2045  int id,
2046  globus_gfs_command_info_t * cmd_info,
2047  globus_i_gfs_ipc_data_callback_t cb,
2048  void * user_arg);
2049 
2050 globus_result_t
2051 globus_gfs_ipc_request_command(
2052  globus_gfs_ipc_handle_t ipc_handle,
2053  globus_gfs_command_info_t * cmd_info,
2054  globus_gfs_ipc_callback_t cb,
2055  void * user_arg);
2056 
2057 /*
2058  * active data
2059  *
2060  * tell remote side to create an active data connection
2061  */
2062 typedef void
2063 (*globus_gfs_ipc_iface_active_data_t)(
2064  globus_gfs_ipc_handle_t ipc_handle,
2065  void * session_handle,
2066  int id,
2067  globus_gfs_data_info_t * data_info,
2068  globus_i_gfs_ipc_data_callback_t cb,
2069  void * user_arg);
2070 
2071 globus_result_t
2072 globus_gfs_ipc_request_active_data(
2073  globus_gfs_ipc_handle_t ipc_handle,
2074  globus_gfs_data_info_t * data_info,
2075  globus_gfs_ipc_callback_t cb,
2076  void * user_arg);
2077 
2078 /*
2079  * passive data
2080  *
2081  * tell remote side to do passive data connection
2082  */
2083 typedef void
2084 (*globus_gfs_ipc_iface_passive_data_t)(
2085  globus_gfs_ipc_handle_t ipc_handle,
2086  void * session_handle,
2087  int id,
2088  globus_gfs_data_info_t * data_info,
2089  globus_i_gfs_ipc_data_callback_t cb,
2090  void * user_arg);
2091 
2092 globus_result_t
2093 globus_gfs_ipc_request_passive_data(
2094  globus_gfs_ipc_handle_t ipc_handle,
2095  globus_gfs_data_info_t * data_info,
2096  globus_gfs_ipc_callback_t cb,
2097  void * user_arg);
2098 
2099 /*
2100  * send stat request
2101  */
2102 typedef void
2103 (*globus_gfs_ipc_iface_stat_t)(
2104  globus_gfs_ipc_handle_t ipc_handle,
2105  void * session_handle,
2106  int id,
2107  globus_gfs_stat_info_t * stat_info,
2108  globus_i_gfs_ipc_data_callback_t cb,
2109  void * user_arg);
2110 
2111 globus_result_t
2112 globus_gfs_ipc_request_stat(
2113  globus_gfs_ipc_handle_t ipc_handle,
2114  globus_gfs_stat_info_t * stat_info,
2115  globus_gfs_ipc_callback_t cb,
2116  void * user_arg);
2117 
2118 /*
2119  * poke transfer event request
2120  */
2121 typedef void
2122 (*globus_gfs_ipc_iface_transfer_event_t)(
2123  globus_gfs_ipc_handle_t ipc_handle,
2124  void * session_handle,
2125  globus_gfs_event_info_t * event_info);
2126 
2127 
2128 globus_result_t
2129 globus_gfs_ipc_request_transfer_event(
2130  globus_gfs_ipc_handle_t ipc_handle,
2131  globus_gfs_event_info_t * event_info);
2132 
2133 
2134 /*
2135  * destroy a data connection associated with the given ID
2136  */
2137 typedef void
2138 (*globus_gfs_ipc_iface_data_destroy_t)(
2139  globus_gfs_ipc_handle_t ipc_handle,
2140  void * session_handle,
2141  void * data_arg);
2142 
2143 globus_result_t
2144 globus_gfs_ipc_request_data_destroy(
2145  globus_gfs_ipc_handle_t ipc_handle,
2146  void * data_arg);
2147 
2148 typedef struct globus_i_gfs_ipc_iface_s
2149 {
2150  globus_gfs_ipc_iface_session_start_t session_start_func;
2151  globus_gfs_ipc_iface_session_stop_t session_stop_func;
2152  globus_gfs_ipc_iface_recv_t recv_func;
2153  globus_gfs_ipc_iface_send_t send_func;
2154  globus_gfs_ipc_iface_command_t command_func;
2155  globus_gfs_ipc_iface_active_data_t active_func;
2156  globus_gfs_ipc_iface_passive_data_t passive_func;
2157  globus_gfs_ipc_iface_data_destroy_t data_destroy_func;
2158  globus_gfs_ipc_iface_stat_t stat_func;
2159  globus_gfs_ipc_iface_list_t list_func;
2160  globus_gfs_ipc_iface_transfer_event_t transfer_event_func;
2161  globus_gfs_ipc_iface_set_cred_t set_cred;
2162  globus_gfs_ipc_iface_buffer_send_t buffer_send;
2163 } globus_gfs_ipc_iface_t;
2164 
2165 /*
2166  * getting an IPC handle
2167  */
2168 
2169 /*
2170  * create an IPC handle from a xio system handle, can be used
2171  * imediately, is not in handle table
2172  */
2173 globus_result_t
2174 globus_gfs_ipc_handle_create(
2175  globus_gfs_ipc_iface_t * iface,
2176  globus_xio_system_socket_t system_handle,
2177  globus_i_gfs_ipc_done_callback_t done_cb,
2178  void * user_arg);
2179 
2180 /*
2181  * actually close the handle
2182  */
2183 globus_result_t
2184 globus_gfs_ipc_close(
2185  globus_gfs_ipc_handle_t ipc_handle,
2186  globus_gfs_ipc_close_callback_t cb,
2187  void * user_arg);
2188 
2189 globus_result_t
2190 globus_gfs_ipc_reply_close(
2191  globus_gfs_ipc_handle_t ipc_handle);
2192 
2193 globus_result_t
2194 globus_gfs_ipc_session_stop(
2195  globus_gfs_ipc_handle_t ipc_handle);
2196 
2197 globus_result_t
2198 globus_gfs_ipc_handle_connect(
2199  globus_gfs_session_info_t * session_info,
2200  globus_gfs_ipc_open_callback_t cb,
2201  void * user_arg,
2202  globus_gfs_ipc_error_callback_t error_cb,
2203  void * error_user_arg);
2204 
2205 globus_result_t
2206 globus_gfs_ipc_handle_connect_ex(
2207  globus_gfs_session_info_t * session_info,
2208  globus_gfs_ipc_open_callback_t cb,
2209  void * user_arg,
2210  globus_gfs_ipc_error_callback_t error_cb,
2211  void * error_user_arg,
2212  globus_bool_t secure_ipc,
2213  gss_cred_id_t cred,
2214  const char *auth_mode,
2215  const char *subject,
2216  time_t connect_timeout,
2217  time_t idle_timeout,
2218  globus_bool_t inetd);
2219 
2220 globus_result_t
2221 globus_gfs_ipc_handle_obtain(
2222  globus_gfs_session_info_t * session_info,
2223  globus_gfs_ipc_iface_t * iface,
2224  globus_gfs_ipc_open_callback_t cb,
2225  void * user_arg,
2226  globus_gfs_ipc_error_callback_t error_cb,
2227  void * error_user_arg);
2228 
2229 /*
2230  * the brain bit
2231  */
2232 #define BRAIN_SYMBOL_NAME (void*)"gridftp_brain"
2233 extern globus_extension_registry_t brain_i_registry;
2234 
2235 typedef globus_result_t
2236 (*globus_i_gfs_brain_select_nodes_func_t)(
2237  globus_i_gfs_brain_node_t *** out_node_array,
2238  int * out_array_length,
2239  const char * repo_name,
2240  globus_off_t filesize,
2241  int min_count,
2242  int max_count);
2243 
2244 typedef globus_result_t
2245 (*globus_i_gfs_brain_release_node_func_t)(
2246  globus_i_gfs_brain_node_t * contact_node,
2247  globus_gfs_brain_reason_t reason);
2248 
2249 typedef globus_result_t
2250 (*globus_i_gfs_brain_init_func_t)(
2251  globus_callback_func_t ready_cb,
2252  void * ready_cb_arg);
2253 
2254 typedef void
2255 (*globus_i_gfs_brain_stop_func_t)();
2256 
2257 typedef globus_result_t
2258 (*globus_i_gfs_brain_get_available_func_t)(
2259  const char * user_id,
2260  const char * repo_name,
2261  int * count);
2262 
2263 
2264 typedef struct globus_i_gfs_brain_module_s
2265 {
2266  globus_i_gfs_brain_init_func_t init_func;
2267  globus_i_gfs_brain_stop_func_t stop_func;
2268  globus_i_gfs_brain_select_nodes_func_t select_func;
2269  globus_i_gfs_brain_release_node_func_t release_func;
2270  globus_i_gfs_brain_get_available_func_t available_func;
2271 } globus_i_gfs_brain_module_t;
2272 
2273 extern globus_i_gfs_brain_module_t globus_i_gfs_default_brain;
2274 
2275 globus_result_t
2276 globus_gfs_brain_select_nodes(
2277  globus_i_gfs_brain_node_t *** out_node_array,
2278  int * out_array_length,
2279  const char * repo_name,
2280  globus_off_t filesize,
2281  int min_count,
2282  int max_count);
2283 
2284 globus_result_t
2285 globus_gfs_brain_release_node(
2286  globus_i_gfs_brain_node_t * contact_node,
2287  globus_gfs_brain_reason_t reason);
2288 
2289 globus_result_t
2290 globus_gfs_brain_get_available(
2291  const char * user_id,
2292  const char * repo_name,
2293  int * count);
2294 
2295 globus_result_t
2296 globus_gfs_ipc_handle_get_contact_string(
2297  globus_gfs_ipc_handle_t ipc_handle,
2298  char ** contact_string);
2299 
2300 globus_result_t
2301 globus_gfs_ipc_init(
2302  globus_bool_t requester);
2303 
2304 /*
2305  *
2306  */
2307 void
2308 globus_gfs_ipc_add_server(
2309  globus_xio_server_t server_handle);
2310 
2311 extern globus_gfs_ipc_iface_t globus_gfs_ipc_default_iface;
2312 
2313 /* end IPC */
2314 
2315 /* ACL interface */
2316 
2317 /*
2318  * interface implementation functions
2319  * see the globus_gridftp_server_acl_example package at
2320  * gridftp/server/acl/example for an example implementation.
2321  */
2322 
2323 /* acl handle object. members are internal use only. */
2324 typedef struct globus_i_gfs_acl_handle_s * globus_gfs_acl_handle_t;
2325 
2326 /* supported actions, all authorization callouts will be of these types.
2327  * an authorization callout should return success for any actions that
2328  * are not interesting. */
2329 typedef enum globus_gfs_acl_action_e
2330 {
2331  /* internal use only */
2332  GFS_ACL_ACTION_INIT = 1,
2333  /* the named object. will be deleted. */
2334  GFS_ACL_ACTION_DELETE,
2335  /* write to an existing object */
2336  GFS_ACL_ACTION_WRITE,
2337  /* create and write to a non-existant object */
2338  GFS_ACL_ACTION_CREATE,
2339  /* read an object */
2340  GFS_ACL_ACTION_READ,
2341  /* query metadata of an object (i.e. list) */
2342  GFS_ACL_ACTION_LOOKUP,
2343  /* speficy an authorization assertion. client may submit data to
2344  * influence future authorization decisions. data is in an unspecified
2345  * format. */
2346  GFS_ACL_ACTION_AUTHZ_ASSERT,
2347  /* report data safely written to disk. failure means data written has
2348  * overrun acceptable limits. */
2349  GFS_ACL_ACTION_COMMIT,
2350  /* increase previously requested write limits for an object */
2351  GFS_ACL_ACTION_GROW
2352 } globus_gfs_acl_action_t;
2353 
2354 /* user connection descriptor. this provides info about the user
2355  * attempting the connection or action */
2356 typedef struct globus_gfs_acl_info_s
2357 {
2358  char * hostname;
2359  char * subject;
2360  char * username;
2361  char * password;
2362  char * ipaddr;
2363  gss_ctx_id_t context;
2364 } globus_gfs_acl_info_t;
2365 
2366 /* object descriptor. this provides various info about the object of the
2367  * action attempt. */
2368 typedef struct globus_gfs_acl_object_desc_s
2369 {
2370  /* ALL: name of the object. commonly a filename.
2371  * value is NULL when not known or not used. */
2372  char * name;
2373 
2374  /* WRITE/CREATE: size being requested to write.
2375  * COMMIT: amount of data already written safely.
2376  * GROW: new full size being requested to write.
2377  * value is 0 when not known or not used. */
2378  globus_off_t size;
2379 
2380  /* AUTHZ_ASSERT: assertion data from the client.
2381  * value is NULL when not known or not used. */
2382  char * data;
2383 
2384  /* COMMIT: all data has been safely written
2385  * value is FALSE when not known or not used. */
2386  globus_bool_t final;
2387 
2389  globus_gfs_op_info_t op_info;
2390 } globus_gfs_acl_object_desc_t;
2391 
2392 /* return values for authorization functions */
2393 typedef enum globus_gfs_acl_status_e
2394 {
2395  /* decision is complete */
2396  GLOBUS_GFS_ACL_COMPLETE = 1,
2397  /* decision will be made in a seperate call to
2398  globus_gfs_acl_authorized_finished() */
2399  GLOBUS_GFS_ACL_WOULD_BLOCK
2400 } globus_gfs_acl_status_t;
2401 
2402 /* initialization callout. this is ususally necessary. must be
2403  * implemented if:
2404  * 1) we need to set up some sort of internal state/handle that can be passed
2405  * back to us in all callouts
2406  * and/or
2407  * 2) we are interested in authorizing the gridftp session based on client
2408  * user information.
2409  *
2410  * must return GLOBUS_GFS_ACL_COMPLETE or GLOBUS_GFS_ACL_WOULD_BLOCK, and
2411  * store GLOBUS_SUCCESS or an error result_t in out_res. if returning
2412  * GLOBUS_GFS_ACL_WOULD_BLOCK, the result must be returned in a call to
2413  * globus_gfs_acl_authorized_finished(). optionally, a pointer may be stored
2414  * in out_handle. this pointer will then be passed back in later callouts.
2415  */
2416 typedef int
2417 (*globus_gfs_acl_init_t)(
2418  void ** out_handle,
2419  globus_gfs_acl_info_t * acl_info,
2420  globus_gfs_acl_handle_t acl_handle,
2421  globus_result_t * out_res);
2422 
2423 /* authorization callout. this is usually necessary. here we will
2424  * get called to authrorize all actions the client performs. see the
2425  * globus_gfs_acl_action_t declaration for all of the supported actions.
2426  *
2427  * must return GLOBUS_GFS_ACL_COMPLETE or GLOBUS_GFS_ACL_WOULD_BLOCK, and
2428  * store GLOBUS_SUCCESS or an error result_t in out_res. If returning
2429  * GLOBUS_GFS_ACL_WOULD_BLOCK, the result must be returned in a call to
2430  * globus_gfs_acl_authorized_finished().
2431  */
2432 typedef int
2433 (*globus_gfs_acl_authorize_t)(
2434  void * out_handle,
2435  globus_gfs_acl_action_t action,
2436  globus_gfs_acl_object_desc_t * object,
2437  globus_gfs_acl_info_t * acl_info,
2438  globus_gfs_acl_handle_t acl_handle,
2439  globus_result_t * out_res);
2440 
2441 /* destructor callout. clean up our session state if necessary */
2442 typedef void
2443 (*globus_gfs_acl_destroy_t)(
2444  void * out_handle);
2445 
2446 /* audit callout. informational callout only. implement this if you would
2447  * like to be notified of activities, but don't need to allow/deny them. */
2448 typedef void
2449 (*globus_gfs_acl_audit_t)(
2450  void * out_handle,
2451  globus_gfs_acl_action_t action,
2452  globus_gfs_acl_object_desc_t * object,
2453  const char * message);
2454 
2455 /* acl module descriptor.
2456  * Only define the functions you implement, otherwise NULL */
2457 typedef struct globus_gfs_acl_module_s
2458 {
2459  globus_gfs_acl_init_t init_func;
2460  globus_gfs_acl_authorize_t authorize_func;
2461  globus_gfs_acl_destroy_t destroy_func;
2462  globus_gfs_acl_audit_t audit_func;
2463 } globus_gfs_acl_module_t;
2464 
2465 /* authorization finalization function. this must be called when the
2466  * initialization or authorization callouts return GLOBUS_GFS_ACL_WOULD_BLOCK.
2467  */
2468 void
2469 globus_gfs_acl_authorized_finished(
2470  globus_gfs_acl_handle_t acl_handle,
2471  globus_result_t result);
2472 
2473 /* helper function to get strings from action types. useful for log/error
2474  * messages */
2475 const char *
2476 globus_gfs_acl_action_to_string(
2477  globus_gfs_acl_action_t action);
2478 
2479 
2480 /* end ACL */
2481 
2482 
2483 /* config locking functions */
2484 typedef
2485 void
2486 (*globus_i_gfs_config_set_string_cb_t)(
2487  const char * option_name,
2488  const char * val,
2489  void * user_arg);
2490 
2491 typedef
2492 void
2493 (*globus_i_gfs_config_set_int_cb_t)(
2494  const char * option_name,
2495  int val,
2496  void * user_arg);
2497 
2498 typedef struct
2499 {
2500  void * user_arg;
2501  globus_bool_t enabled;
2502  void * cb;
2503 } globus_i_gfs_config_option_cb_ent_t;
2504 
2505 void
2506 globus_gfs_config_enable_cb(
2507  globus_i_gfs_config_option_cb_ent_t * cb_handle,
2508  globus_bool_t enabled);
2509 
2510 int
2511 globus_gfs_config_add_cb(
2512  globus_i_gfs_config_option_cb_ent_t ** cb_handle,
2513  char * option_name,
2514  void * cb,
2515  void * user_arg);
2516 
2517 globus_bool_t
2518 globus_gfs_config_get_bool(
2519  const char * option_name);
2520 
2521 char *
2522 globus_gfs_config_get_string(
2523  const char * option_name);
2524 
2525 globus_list_t *
2526 globus_gfs_config_get_list(
2527  const char * option_name);
2528 
2529 void *
2530 globus_gfs_config_get(
2531  const char * option_name);
2532 
2533 int
2534 globus_gfs_config_get_int(
2535  const char * option_name);
2536 
2537 int
2538 globus_gfs_config_set_int(
2539  char * option_name,
2540  int int_value);
2541 
2542 int
2543 globus_gfs_config_set_bool(
2544  char * option_name,
2545  int int_value);
2546 
2547 int
2548 globus_gfs_config_set_ptr(
2549  char * option_name,
2550  void * ptr);
2551 
2552 int
2553 globus_gfs_config_inc_int(
2554  char * option_name,
2555  int inc_val);
2556 
2557 globus_result_t
2558 globus_gfs_base64_encode(
2559  const unsigned char * inbuf,
2560  globus_size_t in_len,
2561  globus_byte_t * outbuf,
2562  globus_size_t * out_len);
2563 
2564 globus_result_t
2565 globus_gfs_base64_decode(
2566  const unsigned char * inbuf,
2567  globus_byte_t * outbuf,
2568  globus_size_t * out_len);
2569 
2570 
2571 #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:1106
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:955
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
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:14441
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:15172
void(* globus_gfs_storage_init_t)(globus_gfs_operation_t op, globus_gfs_session_info_t *session_info)
Definition: globus_gridftp_server.h:635
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_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