globus_connect_gridftp_server  16.15
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. Responses are handled as with
1006  * any other command. Call globus_gridftp_server_finished_command() with
1007  * a valid FTP response string in 'command_response' to customize your response
1008  * i.e. "250 The command was successful\r\n"
1009  *
1010  * cmd_id must be >= GLOBUS_GFS_MIN_CUSTOM_CMD.
1011  *
1012  * If a command takes a pathname, it must be the final argument, and has_pathname
1013  * must be set to GLOBUS_TRUE. commands should not take multiple pathnames.
1014  *
1015  * If the command takes a pathname, set access_type to an globus_gfs_acl_action_t
1016  * like one of: GFS_ACL_ACTION_READ, GFS_ACL_ACTION_WRITE,
1017  * GFS_ACL_ACTION_CREATE, GFS_ACL_ACTION_DELETE, GFS_ACL_ACTION_LOOKUP.
1018  *
1019  * The last argument will always be passed in command_info->pathname, whether
1020  * it is a pathname or not.
1021  * Other args can be obtained by querying command_info->op_info for
1022  * GLOBUS_GFS_OP_INFO_CMD_ARGS. See globus_gridftp_server_query_op_info().
1023  *
1024  * Note for min_args and max_args, that the command itself counts as a argument
1025  * (or 2, in the case of SITE commands).
1026  *
1027  * A non-SITE command name must be exactly 4 characters long,
1028  * A SITE command (command name = "SITE SOMETHING") can be any length
1029  *
1030  * help_string should be of the form "COMMAND <sp> arg1 <sp> arg2 <sp> pathname"
1031  *
1032  */
1033 
1034 globus_result_t
1035 globus_gridftp_server_add_command(
1036  globus_gfs_operation_t op,
1037  const char * command_name,
1038  int cmd_id,
1039  int min_args,
1040  int max_args,
1041  const char * help_string,
1042  globus_bool_t has_pathname,
1043  int access_type);
1044 
1059 globus_result_t
1061  globus_gfs_operation_t op,
1062  const char * cksm_str);
1063 
1068 typedef enum
1069 {
1070  /* return argv and argc for the current command. usually called when
1071  * handling custom commands.
1072  *
1073  * char *** argv,
1074  * int * argc
1075  */
1076  GLOBUS_GFS_OP_INFO_CMD_ARGS = 1
1078 
1079 /* query op_info for parameters
1080  * query parameters listed in the globus_gfs_op_info_param_t enum.
1081  * the varargs should be populated with variables of the correct type to hold
1082  * the returning parameters for the requested param type.
1083  *
1084 */
1085 globus_result_t
1086 globus_gridftp_server_query_op_info(
1087  globus_gfs_operation_t op,
1088  globus_gfs_op_info_t op_info,
1090  ...);
1091 
1092 /* check for attributes applicable to the current recv operation.
1093  * requested_attr is a case-insensitive string indicating the attribute
1094  * whose value will returned in out_value. requested_attr may be NULL, in
1095  * which case the full attr string will be returned in out_value.
1096  *
1097  * the format of the full attr string is attr1=value;attr2=value;...
1098  *
1099  * it is the caller's responsibility to free() out_value after a succesful return.
1100 */
1101 
1102 globus_result_t
1103 globus_gridftp_server_get_recv_attr_string(
1104  globus_gfs_operation_t op,
1105  const char * requested_attr,
1106  char ** out_value);
1107 
1108 /* get intended modification time for the file being received. out_time
1109  * will be the same as if a UTIME/MDTM command had been issued. if the modify
1110  * time has not been requested by the client, this will return GLOBUS_SUCCESS
1111  * but out_time will be -1.
1112  */
1113 
1114 globus_result_t
1115 globus_gridftp_server_get_recv_modification_time(
1116  globus_gfs_operation_t op,
1117  time_t * out_time);
1118 
1119 /*
1120  * update bytes written to storage
1121  *
1122  * This should be called during a recv(), after each successful write
1123  * to the storage system.
1124  *
1125  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1126  * both globus_gridftp_server_update_bytes_recvd() and
1127  * globus_gridftp_server_update_range_recvd() for a given range.
1128  */
1129 void
1130 globus_gridftp_server_update_bytes_written(
1131  globus_gfs_operation_t op,
1132  globus_off_t offset,
1133  globus_off_t length);
1134 
1135 /*
1136  * update bytes recieved, but not yet written to storage
1137  * use this when there may be a delay between reciving data
1138  * and writing to storage. this will ensure accurate performance
1139  * markers, but will not cause range/restart markers to be sent.
1140  *
1141  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1142  * both globus_gridftp_server_update_bytes_recvd() and
1143  * globus_gridftp_server_update_range_recvd() for a given range.
1144  */
1145 void
1146 globus_gridftp_server_update_bytes_recvd(
1147  globus_gfs_operation_t op,
1148  globus_off_t length);
1149 
1150 /*
1151  * update bytes written to storage
1152  * use this when there may be a delay between reciving data
1153  * and writing to storage. this will cause range/restart markers
1154  * to be sent.
1155  *
1156  * Use EITHER globus_gridftp_server_update_bytes_written() OR
1157  * both globus_gridftp_server_update_bytes_recvd() and
1158  * globus_gridftp_server_update_range_recvd() for a given range.
1159  */
1160 void
1161 globus_gridftp_server_update_range_recvd(
1162  globus_gfs_operation_t op,
1163  globus_off_t offset,
1164  globus_off_t length);
1165 
1166 /*
1167  * get concurrency
1168  *
1169  * This should be called during a recv() and send() in order to know the
1170  * number of pending reads or writes you should have at once.
1171  */
1172 void
1173 globus_gridftp_server_get_optimal_concurrency(
1174  globus_gfs_operation_t op,
1175  int * count);
1176 
1177 /*
1178  * get blocksize
1179  *
1180  * This should be called during a recv() and send() in order to know the
1181  * size of buffers that you should be passing to the server for reads and
1182  * writes.
1183  */
1184 void
1185 globus_gridftp_server_get_block_size(
1186  globus_gfs_operation_t op,
1187  globus_size_t * block_size);
1188 
1189 /*
1190  * get stripe blocksize
1191  *
1192  * This can be called during a recv() and send() in modules that wish to
1193  * deal with striping.
1194  */
1195 void
1196 globus_gridftp_server_get_stripe_block_size(
1197  globus_gfs_operation_t op,
1198  globus_size_t * stripe_block_size);
1199 
1200 /*
1201  * get session username
1202  *
1203  * This should can be called to get the username that the process is running
1204  * under, which may be different from the username supplied in the
1205  * session_start call in some cases.
1206  */
1207 void
1208 globus_gridftp_server_get_session_username(
1209  globus_gfs_operation_t op,
1210  char ** username);
1211 
1212 /*
1213  * get delegated cred
1214  *
1215  * This can can be called to get the delegated credential. This may be called
1216  * with any op after session_start() and and the credential pointer will be
1217  * valid until at least session_stop. del_cred will be NULL if it is not
1218  * available.
1219  */
1220 void
1221 globus_gridftp_server_get_delegated_cred(
1222  globus_gfs_operation_t op,
1223  gss_cred_id_t * del_cred);
1224 
1225 /*
1226  * get security context (unsupported)
1227  *
1228  * This can can be called to get the gssapi security context of the client
1229  * connection. This may be called with any op after session_start() and
1230  * the context pointer will be valid until at least session_stop. context
1231  * will be NULL if it is not available. This is needed for accessing proxy
1232  * extensions or other gssapi operations where the delegated credential is
1233  * not sufficient. The caller should not attempt operations that modify the
1234  * context without fully understanding the effects.
1235  */
1236 void
1237 globus_gridftp_server_get_sec_context(
1238  globus_gfs_operation_t op,
1239  gss_ctx_id_t * context);
1240 
1241 
1242 /*
1243  * get/set ordered data requirement
1244  *
1245  * The DSI must call this before globus_gridftp_server_begin_transfer()
1246  * to set the ordered_data flag. This will ensure that the offsets read
1247  * in each data callback are in order, even when multiple streams are used.
1248  * This will result in the transfer slowing down to match the speed of the
1249  * slowest stream. Note: in cases where the data source intentionally sends
1250  * data out of order, this will result in an aborted transfer. However,
1251  * a DSI that needs ordered data would probably fail in such a scenario anyway.
1252  *
1253  * Instead of calling these functions, you can enable this setting for all
1254  * transfers by setting GLOBUS_GFS_DSI_DESCRIPTOR_REQUIRES_ORDERED_DATA
1255  * in the globus_gfs_storage_iface_t interface definition.
1256  */
1257 void
1258 globus_gridftp_server_set_ordered_data(
1259  globus_gfs_operation_t op,
1260  globus_bool_t ordered_data);
1261 
1262 void
1263 globus_gridftp_server_get_ordered_data(
1264  globus_gfs_operation_t op,
1265  globus_bool_t * ordered_data);
1266 
1267 /*
1268  * get config string
1269  *
1270  * This can be called to get the dsi specific configuration string
1271  * that is defined in the global configuration.
1272  */
1273 void
1274 globus_gridftp_server_get_config_string(
1275  globus_gfs_operation_t op,
1276  char ** config_string);
1277 
1278 /*
1279  * get config data
1280  *
1281  * This can be called to get the configuration data managed by the server.
1282  * data_id can be NULL, or can be used to specify a specific set of data.
1283  */
1284 void
1285 globus_gridftp_server_get_config_data(
1286  globus_gfs_operation_t op,
1287  char * data_id,
1288  char ** config_data);
1289 
1290 void
1291 globus_gridftp_server_session_get_config_data(
1292  globus_gfs_session_config_t session_conf_handle,
1293  char * data_id,
1294  char ** config_data);
1295 
1296 void
1297 globus_gridftp_server_get_session_config_handle(
1298  globus_gfs_operation_t op,
1299  globus_gfs_session_config_t * out_session_conf_handle);
1300 
1301 void
1302 globus_gfs_data_get_file_stack_list(
1303  globus_gfs_operation_t in_op,
1304  globus_list_t ** out_list);
1305 
1306 void
1307 globus_gridftp_server_get_update_interval(
1308  globus_gfs_operation_t op,
1309  int * interval);
1310 
1311 /*
1312  * get Transfer task ID
1313  *
1314  * Returns the Transfer task ID associated with the current GridFTP session.
1315  * If a task id is not known, return NULL instead.
1316  */
1317 void
1318 globus_gridftp_server_get_task_id(
1319  globus_gfs_operation_t op,
1320  char ** task_id);
1321 
1322 /*
1323  * get read_range
1324  *
1325  * This should be called during send() in order to know the specific
1326  * offset and length of the file to read from the storage system
1327  * You should continue calling this and transferring the speficied data
1328  * until it returns a length of 0.
1329  */
1330 void
1331 globus_gridftp_server_get_read_range(
1332  globus_gfs_operation_t op,
1333  globus_off_t * offset,
1334  globus_off_t * length);
1335 
1336 
1337 /*
1338  * get write_range
1339  *
1340  * This could be called during recv() in order to get hints on the specific
1341  * offset and length that the data will be expected to come from
1342  * globus_gridftp_server_register_read() callbacks. Note that this is
1343  * only a hint, and not necessarily the exact data ranges that will come.
1344  * You would continue calling this until it returns a length of 0.
1345  */
1346 void
1347 globus_gridftp_server_get_write_range(
1348  globus_gfs_operation_t op,
1349  globus_off_t * offset,
1350  globus_off_t * length);
1351 
1352 
1353 /* END Storage Interface API */
1354 
1355 typedef enum
1356 {
1357  GLOBUS_GFS_LOG_ERR = 0x01,
1358  GLOBUS_GFS_LOG_WARN = 0x02,
1359  GLOBUS_GFS_LOG_TRANSFER = 0x04,
1360  GLOBUS_GFS_LOG_INFO = 0x08,
1361  GLOBUS_GFS_LOG_DUMP = 0x10,
1362  GLOBUS_GFS_LOG_ALL = 0xFF,
1363  GLOBUS_GFS_LOG_AUDIT = 0x100
1364 } globus_gfs_log_type_t;
1365 
1366 void
1367 globus_gfs_log_message(
1368  globus_gfs_log_type_t type,
1369  const char * format,
1370  ...);
1371 
1372 void
1373 globus_gfs_log_result(
1374  globus_gfs_log_type_t type,
1375  const char * lead,
1376  globus_result_t result);
1377 
1379 enum
1380 {
1381  GLOBUS_GFS_DEBUG_TRACE = 8,
1382  GLOBUS_GFS_DEBUG_INFO = 16,
1383  GLOBUS_GFS_DEBUG_STATE = 32
1384 };
1385 
1386 #ifdef __GNUC__
1387 #define GlobusGFSName(func) static const char * _gfs_name __attribute__((__unused__)) = #func
1388 #else
1389 #define GlobusGFSName(func) static const char * _gfs_name = #func
1390 #endif
1391 
1392 GlobusDebugDeclare(GLOBUS_GRIDFTP_SERVER);
1393 
1394 #define GlobusGFSDebugPrintf(level, message) \
1395  GlobusDebugPrintf(GLOBUS_GRIDFTP_SERVER, level, message)
1396 
1397 
1398 #define GlobusGFSDebugInfoF(_msg) \
1399 do \
1400 { \
1401  GlobusGFSDebugPrintf( \
1402  GLOBUS_GFS_DEBUG_INFO, \
1403  ("[%s:%d] (pid=%d) [%s] ", __FILE__, __LINE__, getpid(), __func__));\
1404  GlobusGFSDebugPrintf( \
1405  GLOBUS_GFS_DEBUG_INFO, \
1406  _msg); \
1407 } while(0)
1408 
1409 #define GlobusGFSDebugResultT(_result, _msg) \
1410 do \
1411 { \
1412  char * _err_str = globus_error_print_friendly( \
1413  globus_error_peek(_result)); \
1414  GlobusGFSDebugInfoF(("%s: %s\n", _msg, _err_str)); \
1415  free(_err_str); \
1416 } while(0)
1417 
1418 #define GlobusGFSDebugInfo(_msg) \
1419  GlobusGFSDebugPrintf( \
1420  GLOBUS_GFS_DEBUG_INFO, \
1421  ("[%s] %s\n", __func__, _msg))
1422 
1423 #define GlobusGFSDebugEnter() \
1424  GlobusGFSDebugPrintf( \
1425  GLOBUS_GFS_DEBUG_TRACE, \
1426  ("[%s] Entering\n", __func__))
1427 
1428 #define GlobusGFSDebugExitResult(res) \
1429  GlobusGFSDebugPrintf( \
1430  GLOBUS_GFS_DEBUG_TRACE, \
1431  ("[%s] Exiting%s\n", \
1432  __func__, \
1433  (res != GLOBUS_SUCCESS) ? " with error" : ""))
1434 
1435 #define GlobusGFSDebugExit() \
1436  GlobusGFSDebugPrintf( \
1437  GLOBUS_GFS_DEBUG_TRACE, \
1438  ("[%s] Exiting\n", __func__))
1439 
1440 #define GlobusGFSDebugState(_state) \
1441  GlobusGFSDebugPrintf( \
1442  GLOBUS_GFS_DEBUG_INFO, \
1443  ("[%s] State: %d\n", __func__, _state))
1444 
1445 #define GlobusGFSDebugExitWithError() \
1446  GlobusGFSDebugPrintf( \
1447  GLOBUS_GFS_DEBUG_TRACE, \
1448  ("[%s] Exiting with error\n", __func__))
1449 
1450 #define GlobusGFSErrorParameter(mem_name) \
1451  globus_error_put(GlobusGFSErrorObjParameter(mem_name))
1452 
1453 #define GlobusGFSErrorIPC() \
1454  globus_error_put(GlobusGFSErrorObjIPC())
1455 
1456 #define GlobusGFSErrorObjIPC() \
1457  globus_error_construct_error( \
1458  NULL, \
1459  NULL, \
1460  GLOBUS_GFS_ERROR_MEMORY, \
1461  __FILE__, \
1462  __func__, \
1463  __LINE__, \
1464  "IPC Communication error.")
1465 
1466 #define GlobusGFSErrorObjParameter(param_name) \
1467  globus_error_construct_error( \
1468  NULL, \
1469  NULL, \
1470  GLOBUS_GFS_ERROR_PARAMETER, \
1471  __FILE__, \
1472  __func__, \
1473  __LINE__, \
1474  "invalid parameter: %s", \
1475  (param_name))
1476 
1477 #define GlobusGFSErrorSystemError(system_func, system_errno) \
1478  globus_error_put(GlobusGFSErrorObjSystemError(\
1479  (system_func), (system_errno)))
1480 #define GlobusGFSErrorObjSystemError(system_func, system_errno) \
1481  globus_i_gfs_error_system( \
1482  0, (system_errno), \
1483  "System error%s%s", \
1484  (system_func) != NULL ? " in " : "", \
1485  (system_func) != NULL ? (system_func) : "")
1486 
1487 #define GlobusGFSErrorWrapFailed(failed_func, result) \
1488  globus_error_put(GlobusGFSErrorObjWrapFailed(failed_func, result))
1489 
1490 #define GlobusGFSErrorObjWrapFailed(failed_func, result) \
1491  globus_error_construct_error( \
1492  NULL, \
1493  globus_error_get((result)), \
1494  GLOBUS_GFS_ERROR_WRAPPED, \
1495  __FILE__, \
1496  __func__, \
1497  __LINE__, \
1498  "%s failed.", \
1499  (failed_func))
1500 
1501 #define GlobusGFSErrorData(reason) \
1502  globus_error_put(GlobusGFSErrorObjData(reason))
1503 
1504 #define GlobusGFSErrorObjData(reason) \
1505  globus_error_construct_error( \
1506  NULL, \
1507  NULL, \
1508  GLOBUS_GFS_ERROR_DATA, \
1509  __FILE__, \
1510  __func__, \
1511  __LINE__, \
1512  "%s", \
1513  (reason))
1514 
1515 #define GlobusGFSErrorGeneric(reason) \
1516  globus_error_put(GlobusGFSErrorObjGeneric(reason))
1517 
1518 #define GlobusGFSErrorObjGeneric(reason) \
1519  globus_error_construct_error( \
1520  NULL, \
1521  NULL, \
1522  GLOBUS_GFS_ERROR_GENERIC, \
1523  __FILE__, \
1524  __func__, \
1525  __LINE__, \
1526  "%s", \
1527  (reason))
1528 
1529 globus_object_t *
1531  globus_module_descriptor_t * base_source,
1532  globus_object_t * base_cause,
1533  int response_code,
1534  const char *response_error_code,
1535  const char *fmt,
1536  ...);
1537 
1538 globus_object_t *
1540  globus_object_t * error,
1541  globus_module_descriptor_t * base_source,
1542  globus_object_t * base_cause,
1543  int response_code,
1544  const char * response_error_code,
1545  const char * fmt,
1546  va_list ap);
1547 globus_object_t *
1549  globus_object_t * error,
1550  globus_module_descriptor_t * base_source,
1551  globus_object_t * base_cause,
1552  int response_code,
1553  const char * response_error_code,
1554  const char * fmt,
1555  ...);
1556 
1557 int
1559  globus_object_t * error);
1560 
1561 const char *
1563  globus_object_t * error);
1564 
1565 globus_bool_t
1567  globus_object_t * error,
1568  const char * response_error_code);
1569 
1570 extern const globus_object_type_t
1572 
1573 #define GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE \
1574  (&GLOBUS_GFS_ERROR_FTP_RESPONSE_TYPE_DEFINITION)
1575 
1576 
1577 #define GlobusGFSErrorFtpResponse(cause, code, response_error_code, ...) \
1578  globus_error_put(GlobusGFSErrorObjFtpResponse( \
1579  cause, code, response_error_code, __VA_ARGS__))
1580 
1581 #define GlobusGFSErrorObjFtpResponse(cause, code, response_error_code, ...) \
1582  globus_gfs_ftp_response_error_construct( \
1583  NULL, \
1584  cause, \
1585  code, \
1586  response_error_code, \
1587  __VA_ARGS__)
1588 
1589 globus_object_t *
1590 globus_i_gfs_error_system(int ftp_code, int system_errno, const char *fmt, ...);
1591 
1592 #define GlobusGFSErrorMemory(mem) \
1593  globus_error_put(GlobusGFSErrorObjMemory(mem))
1594 #define GlobusGFSErrorObjMemory(mem) \
1595  GlobusGFSErrorObjSystemError("malloc", errno)
1596 
1597 #define GlobusGFSErrorObj(cause, response_code, ...) \
1598  GlobusGFSErrorObjFtpResponse(cause, response_code, __VA_ARGS__)
1599 
1600 #define GlobusGFSErrorPathNotFound(p) \
1601  globus_error_put(GlobusGFSErrorObjPathNotFound(NULL, p))
1602 #define GlobusGFSErrorObjPathNotFound(cause, p) \
1603  GlobusGFSErrorObj((cause), 550, "PATH_NOT_FOUND", \
1604  "%s%s%s", \
1605  ((p) != NULL) ? "GridFTP-Path: \"" : "", \
1606  ((p) != NULL) ? (p) : "", \
1607  ((p) != NULL) ? "\"" : "")
1608 
1609 #define GlobusGFSErrorIncorrectChecksum(computed, expected) \
1610  globus_error_put(GlobusGFSErrorObjIncorrectChecksum( \
1611  NULL, computed, expected))
1612 #define GlobusGFSErrorObjIncorrectChecksum(cause, computed, expected) \
1613  GlobusGFSErrorObj( \
1614  (cause), \
1615  550, \
1616  "INCORRECT_CHECKSUM", \
1617  "GridFTP-Computed-Checksum: %s\n" \
1618  "GridFTP-Expected-Checksum: %s", (computed), (expected))
1619 
1620 #define GlobusGFSErrorMultipartUploadNotFound() \
1621  globus_error_put(GlobusGFSErrorObjMultipartUploadNotFound(NULL))
1622 #define GlobusGFSErrorObjMultipartUploadNotFound(cause) \
1623  GlobusGFSErrorObj(cause, 553, "MULTI_PART_UPLOAD_NOT_FOUND", NULL)
1624 
1625 #define GlobusGFSErrorAppendNotSupported() \
1626  globus_error_put(GlobusGFSErrorObjAppendNotSupported(NULL))
1627 #define GlobusGFSErrorObjAppendNotSupported(cause) \
1628  GlobusGFSErrorObj((cause), 553, "APPEND_NOT_SUPPORTED", NULL)
1629 
1630 #define GlobusGFSErrorAmbiguousPath(ambiguity) \
1631  globus_error_put(GlobusGFSErrorObjAmbiguousPath(NULL, ambiguity))
1632 #define GlobusGFSErrorObjAmbiguousPath(cause, ambiguity) \
1633  GlobusGFSErrorObj( \
1634  (cause), \
1635  553, \
1636  "AMBIGUOUS_PATH", \
1637  "GridFTP-Path: %s", \
1638  (ambiguity))
1639 
1640 #define GlobusGFSErrorTooBusy() \
1641  globus_error_put(GlobusGFSErrorObjTooBusy(NULL))
1642 #define GlobusGFSErrorObjTooBusy(cause) \
1643  GlobusGFSErrorObj((cause), 451, "TOO_BUSY", NULL)
1644 
1645 #define GlobusGFSErrorDataChannelAuthenticationFailure() \
1646  globus_error_put(GlobusGFSErrorObjDataChannelAuthenticationFailure( \
1647  NULL))
1648 #define GlobusGFSErrorObjDataChannelAuthenticationFailure(cause) \
1649  GlobusGFSErrorObj((cause), 425, \
1650  "DATA_CHANNEL_AUTHENTICATION_FAILURE", NULL)
1651 
1652 #define GlobusGFSErrorDataChannelCommunicationFailure() \
1653  globus_error_put(GlobusGFSErrorObjDataChannelCommunicationFailure( \
1654  NULL))
1655 #define GlobusGFSErrorObjDataChannelCommunicationFailure(cause) \
1656  GlobusGFSErrorObj((cause), 425, \
1657  "DATA_CHANNEL_COMMUNICATION_FAILURE", NULL)
1658 
1659 #define GlobusGFSErrorLoginDenied() \
1660  globus_error_put(GlobusGFSErrorObjLoginDenied(NULL))
1661 #define GlobusGFSErrorObjLoginDenied(cause) \
1662  GlobusGFSErrorObj((cause), 530, "LOGIN_DENIED", NULL)
1663 
1664 #define GlobusGFSErrorLoginDeniedJSON(message, json) \
1665  globus_error_put(GlobusGFSErrorObjLoginDeniedJSON(NULL, message, json))
1666 #define GlobusGFSErrorObjLoginDeniedJSON(cause, message, json) \
1667  GlobusGFSErrorObj((cause), 530, "LOGIN_DENIED", \
1668  "GridFTP-Message: %s\n" \
1669  "GridFTP-JSON-Result: %s", \
1670  (message) ? (message) : "Message not available", (json))
1671 
1672 #define GlobusGFSErrorEndpointError() \
1673  globus_error_put(GlobusGFSErrorObjEndpointError(NULL))
1674 #define GlobusGFSErrorObjEndpointError(cause) \
1675  GlobusGFSErrorObj((cause), 530, "ENDPOINT_ERROR", NULL)
1676 
1677 #define GlobusGFSErrorPermissionDenied() \
1678  globus_error_put(GlobusGFSErrorObjPermissionDenied(NULL))
1679 #define GlobusGFSErrorObjPermissionDenied(cause) \
1680  GlobusGFSErrorObj((cause), 550, "PERMISSION_DENIED", NULL)
1681 
1682 #define GlobusGFSErrorQuotaExceeded() \
1683  globus_error_put(GlobusGFSErrorObjQuotaExceeded(NULL))
1684 #define GlobusGFSErrorObjQuotaExceeded(cause) \
1685  GlobusGFSErrorObj((cause), 451, "QUOTA_EXCEEDED", NULL)
1686 
1687 #define GlobusGFSErrorNoSpaceLeft() \
1688  globus_error_put(GlobusGFSErrorObjNoSpaceLeft(NULL))
1689 #define GlobusGFSErrorObjNoSpaceLeft(cause) \
1690  GlobusGFSErrorObj((cause), 451, "NO_SPACE_LEFT", NULL)
1691 
1692 #define GlobusGFSErrorInvalidPathName(name) \
1693  globus_error_put(GlobusGFSErrorObjInvalidPathName(NULL, name))
1694 #define GlobusGFSErrorObjInvalidPathName(cause, name) \
1695  GlobusGFSErrorObj((cause), 553, "INVALID_PATH_NAME", \
1696  "GridFTP-Path: %s", name)
1697 
1698 #define GlobusGFSErrorPathExists(name) \
1699  globus_error_put(GlobusGFSErrorObjPathExists(NULL, name))
1700 #define GlobusGFSErrorObjPathExists(cause, name) \
1701  GlobusGFSErrorObj((cause), 553, "PATH_EXISTS", \
1702  "GridFTP-Path: %s", name)
1703 
1704 #define GlobusGFSErrorIsADirectory(name) \
1705  globus_error_put(GlobusGFSErrorObjIsADirectory(NULL, name))
1706 #define GlobusGFSErrorObjIsADirectory(cause, name) \
1707  GlobusGFSErrorObj((cause), 553, "IS_A_DIRECTORY", \
1708  "GridFTP-Path: %s", name)
1709 
1710 #define GlobusGFSErrorNotADirectory(name) \
1711  globus_error_put(GlobusGFSErrorObjNotADirectory(NULL, name))
1712 #define GlobusGFSErrorObjNotADirectory(cause, name) \
1713  GlobusGFSErrorObj((cause), 553, "NOT_A_DIRECTORY", \
1714  "GridFTP-Path: %s", name)
1715 
1716 #define GlobusGFSErrorCRLError() \
1717  globus_error_put(GlobusGFSErrorObjCRLError(NULL))
1718 #define GlobusGFSErrorObjCRLError(cause) \
1719  GlobusGFSErrorObj((cause), 530, "CRL_ERROR", NULL)
1720 
1721 #define GlobusGFSErrorInternalError(generic_string) \
1722  globus_error_put(GlobusGFSErrorObjInternalError( \
1723  NULL, (generic_string)))
1724 #define GlobusGFSErrorObjInternalError(cause, generic_string) \
1725  GlobusGFSErrorObj((cause), 500, "INTERNAL_ERROR", \
1726  "%s%s", \
1727  ((generic_string) != NULL) ? "GridFTP-Error: " : "", \
1728  ((generic_string) != NULL) ? generic_string : "")
1729 
1730 #define GlobusGFSErrorNotImplemented() \
1731  globus_error_put(GlobusGFSErrorObjNotImplemented(NULL))
1732 #define GlobusGFSErrorObjNotImplemented(cause) \
1733  GlobusGFSErrorObj((cause), 500, "NOT_IMPLEMETED", NULL)
1734 
1735 #define GlobusGFSErrorNotImplementedFeature(feature) \
1736  globus_error_put(GlobusGFSErrorObjNotImplementedFeature(NULL, feature))
1737 #define GlobusGFSErrorObjNotImplementedFeature(cause, feature) \
1738  GlobusGFSErrorObj((cause), 500, \
1739  "NOT_IMPLEMETED", "GridFTP-Feature: %s", (feature))
1740 
1741 #define GlobusGFSErrorConfigurationError() \
1742  globus_error_put(GlobusGFSErrorObjConfigurationError(NULL))
1743 #define GlobusGFSErrorObjConfigurationError(cause) \
1744  GlobusGFSErrorObj((cause), 500, "CONFIGURATION_ERROR", NULL)
1745 
1746 
1747 /* Checksums */
1748 
1749 /* init, update update update ..., finalize.
1750  caller is responsible for freeing checksum_str.
1751 */
1752 
1753 #define GLOBUS_GFS_BUILTIN_CHECKSUM_SUPPORT "MD5:10;ADLER32:10;SHA1:10;CRC32C:10;SHA256:12;SHA512:11;QuickXORHex:12;Dropbox:12;"
1754 
1755 typedef struct globus_l_gfs_checksum_state_s * globus_gfs_checksum_state_t;
1756 
1757 globus_result_t
1758 globus_gfs_checksum_init(
1759  const char * algorithm,
1760  globus_gfs_checksum_state_t * state);
1761 
1762 globus_result_t
1763 globus_gfs_checksum_update(
1764  globus_gfs_checksum_state_t state,
1765  const unsigned char * buffer,
1766  size_t nbytes);
1767 
1768 globus_result_t
1769 globus_gfs_checksum_finalize(
1770  globus_gfs_checksum_state_t state,
1771  char ** checksum_str);
1772 
1773 /*
1774  *
1775  * IPC
1776  *
1777  */
1778 
1779 typedef struct globus_i_gfs_ipc_handle_s * globus_gfs_ipc_handle_t;
1780 
1781 /*
1782  * callbacks
1783  *
1784  * all functions have the same callback, they examine the
1785  * globus_gfs_finished_info_t() structure for their specific info
1786  *
1787  * error_cb
1788  * can be called at anytime. typically means the ipc connection broke
1789  * in an irrecoverable way. Even tho this is called all outstanding
1790  * callbacks will still be called (but with an error)
1791  */
1792 
1793  /*
1794  * replying
1795  *
1796  * every comman requires a reply and comes with a reply id. to reply
1797  * the requested side must fill in the globus_gfs_finished_info_t
1798  * structure and then pass it
1799  * to the function: globus_gfs_ipc_reply(); That call will result in
1800  * the ipc communication that will untilimately call the callback
1801  * on the callers side.
1802  */
1803 typedef void
1804 (*globus_gfs_ipc_callback_t)(
1805  globus_gfs_ipc_handle_t ipc_handle,
1806  globus_result_t result,
1807  globus_gfs_finished_info_t * reply,
1808  void * user_arg);
1809 
1810 typedef void
1811 (*globus_gfs_ipc_event_callback_t)(
1812  globus_gfs_ipc_handle_t ipc_handle,
1813  globus_result_t result,
1814  globus_gfs_event_info_t * reply,
1815  void * user_arg);
1816 
1817 typedef void
1818 (*globus_gfs_ipc_close_callback_t)(
1819  globus_gfs_ipc_handle_t ipc_handle,
1820  globus_result_t result,
1821  void * user_arg);
1822 
1823 typedef void
1824 (*globus_gfs_ipc_open_callback_t)(
1825  globus_gfs_ipc_handle_t ipc_handle,
1826  globus_result_t result,
1827  globus_gfs_finished_info_t * reply,
1828  void * user_arg);
1829 
1830 typedef void
1831 (*globus_gfs_ipc_error_callback_t)(
1832  globus_gfs_ipc_handle_t ipc_handle,
1833  globus_result_t result,
1834  void * user_arg);
1835 
1836 globus_result_t
1837 globus_gfs_ipc_reply_finished(
1838  globus_gfs_ipc_handle_t ipc_handle,
1839  globus_gfs_finished_info_t * reply);
1840 
1841 globus_result_t
1842 globus_gfs_ipc_reply_event(
1843  globus_gfs_ipc_handle_t ipc_handle,
1844  globus_gfs_event_info_t * reply);
1845 
1846 globus_result_t
1847 globus_gfs_ipc_reply_session(
1848  globus_gfs_ipc_handle_t ipc_handle,
1849  globus_gfs_finished_info_t * reply);
1850 
1851 /*
1852  * sending
1853  *
1854  * every command has a corresponding iface function. A call to a
1855  * command function results in a call to the correspoding iface
1856  * function on the other side of the channel.
1857  *
1858  * all parmeters are wrapped in a structure corresponding to
1859  * each function call type. those structures are defined below
1860  */
1861 
1862 typedef void
1863 (*globus_i_gfs_ipc_data_callback_t)(
1864  globus_gfs_finished_info_t * reply,
1865  void * user_arg);
1866 
1867 typedef void
1868 (*globus_i_gfs_ipc_data_event_callback_t)(
1869  globus_gfs_event_info_t * reply,
1870  void * user_arg);
1871 
1872 typedef void
1873 (*globus_i_gfs_ipc_done_callback_t)(
1874  void * user_arg,
1875  globus_result_t result);
1876 
1877 /*************************************************************************
1878  * interface function
1879  * ------------------
1880  *
1881  ************************************************************************/
1882 /* works with handle get */
1883 typedef void
1884 (*globus_gfs_ipc_iface_session_start_t)(
1885  globus_gfs_ipc_handle_t ipc_handle,
1886  const gss_ctx_id_t context,
1887  globus_gfs_session_info_t * session_info,
1888  globus_i_gfs_ipc_data_callback_t cb,
1889  void * user_arg);
1890 
1891 globus_result_t
1892 globus_gfs_ipc_start_session(
1893  globus_gfs_ipc_handle_t ipc_handle,
1894  globus_gfs_session_info_t * session_info,
1895  globus_gfs_ipc_callback_t cb,
1896  void * user_arg);
1897 
1898 /* works with release */
1899 typedef void
1900 (*globus_gfs_ipc_iface_session_stop_t)(
1901  globus_gfs_ipc_handle_t ipc_handle,
1902  void * session_handle);
1903 
1904 globus_result_t
1905 globus_gfs_ipc_iface_session_stop(
1906  globus_gfs_ipc_handle_t ipc_handle,
1907  void * session_handle);
1908 
1909 typedef void
1910 (*globus_gfs_ipc_iface_set_cred_t)(
1911  globus_gfs_ipc_handle_t ipc_handle,
1912  void * session_handle,
1913  gss_cred_id_t del_cred);
1914 
1915 globus_result_t
1916 globus_gfs_ipc_set_cred(
1917  globus_gfs_ipc_handle_t ipc_handle,
1918  gss_cred_id_t del_cred);
1919 
1920 typedef void
1921 (*globus_gfs_ipc_iface_buffer_send_t)(
1922  globus_gfs_ipc_handle_t ipc_handle,
1923  void * session_handle,
1924  globus_byte_t * buffer,
1925  int buffer_type,
1926  globus_size_t buffer_len);
1927 
1928 globus_result_t
1929 globus_gfs_ipc_request_buffer_send(
1930  globus_gfs_ipc_handle_t ipc_handle,
1931  globus_byte_t * buffer,
1932  int buffer_type,
1933  globus_size_t buffer_len);
1934 
1935 /*
1936  * receive
1937  *
1938  * tell the remote process to receive a file
1939  */
1940 typedef void
1941 (*globus_gfs_ipc_iface_recv_t)(
1942  globus_gfs_ipc_handle_t ipc_handle,
1943  void * session_handle,
1944  int id,
1945  globus_gfs_transfer_info_t * recv_info,
1946  globus_i_gfs_ipc_data_callback_t cb,
1947  globus_i_gfs_ipc_data_event_callback_t event_cb,
1948  void * user_arg);
1949 
1950 globus_result_t
1951 globus_gfs_ipc_request_recv(
1952  globus_gfs_ipc_handle_t ipc_handle,
1953  globus_gfs_transfer_info_t * recv_info,
1954  globus_gfs_ipc_callback_t cb,
1955  globus_gfs_ipc_event_callback_t event_cb,
1956  void * user_arg);
1957 
1958 /*
1959  * send
1960  *
1961  * tell remote process to send a file
1962  */
1963 typedef void
1964 (*globus_gfs_ipc_iface_send_t)(
1965  globus_gfs_ipc_handle_t ipc_handle,
1966  void * session_handle,
1967  int id,
1968  globus_gfs_transfer_info_t * send_info,
1969  globus_i_gfs_ipc_data_callback_t cb,
1970  globus_i_gfs_ipc_data_event_callback_t event_cb,
1971  void * user_arg);
1972 
1973 globus_result_t
1974 globus_gfs_ipc_request_send(
1975  globus_gfs_ipc_handle_t ipc_handle,
1976  globus_gfs_transfer_info_t * send_info,
1977  globus_gfs_ipc_callback_t cb,
1978  globus_gfs_ipc_event_callback_t event_cb,
1979  void * user_arg);
1980 
1981 typedef void
1982 (*globus_gfs_ipc_iface_list_t)(
1983  globus_gfs_ipc_handle_t ipc_handle,
1984  void * session_handle,
1985  int id,
1986  globus_gfs_transfer_info_t * list_info,
1987  globus_i_gfs_ipc_data_callback_t cb,
1988  globus_i_gfs_ipc_data_event_callback_t event_cb,
1989  void * user_arg);
1990 
1991 globus_result_t
1992 globus_gfs_ipc_request_list(
1993  globus_gfs_ipc_handle_t ipc_handle,
1994  globus_gfs_transfer_info_t * data_info,
1995  globus_gfs_ipc_callback_t cb,
1996  globus_gfs_ipc_event_callback_t event_cb,
1997  void * user_arg);
1998 
1999 /*
2000  * command
2001  *
2002  * tell remote side to execute the given command
2003  */
2004 typedef void
2005 (*globus_gfs_ipc_iface_command_t)(
2006  globus_gfs_ipc_handle_t ipc_handle,
2007  void * session_handle,
2008  int id,
2009  globus_gfs_command_info_t * cmd_info,
2010  globus_i_gfs_ipc_data_callback_t cb,
2011  void * user_arg);
2012 
2013 globus_result_t
2014 globus_gfs_ipc_request_command(
2015  globus_gfs_ipc_handle_t ipc_handle,
2016  globus_gfs_command_info_t * cmd_info,
2017  globus_gfs_ipc_callback_t cb,
2018  void * user_arg);
2019 
2020 /*
2021  * active data
2022  *
2023  * tell remote side to create an active data connection
2024  */
2025 typedef void
2026 (*globus_gfs_ipc_iface_active_data_t)(
2027  globus_gfs_ipc_handle_t ipc_handle,
2028  void * session_handle,
2029  int id,
2030  globus_gfs_data_info_t * data_info,
2031  globus_i_gfs_ipc_data_callback_t cb,
2032  void * user_arg);
2033 
2034 globus_result_t
2035 globus_gfs_ipc_request_active_data(
2036  globus_gfs_ipc_handle_t ipc_handle,
2037  globus_gfs_data_info_t * data_info,
2038  globus_gfs_ipc_callback_t cb,
2039  void * user_arg);
2040 
2041 /*
2042  * passive data
2043  *
2044  * tell remote side to do passive data connection
2045  */
2046 typedef void
2047 (*globus_gfs_ipc_iface_passive_data_t)(
2048  globus_gfs_ipc_handle_t ipc_handle,
2049  void * session_handle,
2050  int id,
2051  globus_gfs_data_info_t * data_info,
2052  globus_i_gfs_ipc_data_callback_t cb,
2053  void * user_arg);
2054 
2055 globus_result_t
2056 globus_gfs_ipc_request_passive_data(
2057  globus_gfs_ipc_handle_t ipc_handle,
2058  globus_gfs_data_info_t * data_info,
2059  globus_gfs_ipc_callback_t cb,
2060  void * user_arg);
2061 
2062 /*
2063  * send stat request
2064  */
2065 typedef void
2066 (*globus_gfs_ipc_iface_stat_t)(
2067  globus_gfs_ipc_handle_t ipc_handle,
2068  void * session_handle,
2069  int id,
2070  globus_gfs_stat_info_t * stat_info,
2071  globus_i_gfs_ipc_data_callback_t cb,
2072  void * user_arg);
2073 
2074 globus_result_t
2075 globus_gfs_ipc_request_stat(
2076  globus_gfs_ipc_handle_t ipc_handle,
2077  globus_gfs_stat_info_t * stat_info,
2078  globus_gfs_ipc_callback_t cb,
2079  void * user_arg);
2080 
2081 /*
2082  * poke transfer event request
2083  */
2084 typedef void
2085 (*globus_gfs_ipc_iface_transfer_event_t)(
2086  globus_gfs_ipc_handle_t ipc_handle,
2087  void * session_handle,
2088  globus_gfs_event_info_t * event_info);
2089 
2090 
2091 globus_result_t
2092 globus_gfs_ipc_request_transfer_event(
2093  globus_gfs_ipc_handle_t ipc_handle,
2094  globus_gfs_event_info_t * event_info);
2095 
2096 
2097 /*
2098  * destroy a data connection associated with the given ID
2099  */
2100 typedef void
2101 (*globus_gfs_ipc_iface_data_destroy_t)(
2102  globus_gfs_ipc_handle_t ipc_handle,
2103  void * session_handle,
2104  void * data_arg);
2105 
2106 globus_result_t
2107 globus_gfs_ipc_request_data_destroy(
2108  globus_gfs_ipc_handle_t ipc_handle,
2109  void * data_arg);
2110 
2111 typedef struct globus_i_gfs_ipc_iface_s
2112 {
2113  globus_gfs_ipc_iface_session_start_t session_start_func;
2114  globus_gfs_ipc_iface_session_stop_t session_stop_func;
2115  globus_gfs_ipc_iface_recv_t recv_func;
2116  globus_gfs_ipc_iface_send_t send_func;
2117  globus_gfs_ipc_iface_command_t command_func;
2118  globus_gfs_ipc_iface_active_data_t active_func;
2119  globus_gfs_ipc_iface_passive_data_t passive_func;
2120  globus_gfs_ipc_iface_data_destroy_t data_destroy_func;
2121  globus_gfs_ipc_iface_stat_t stat_func;
2122  globus_gfs_ipc_iface_list_t list_func;
2123  globus_gfs_ipc_iface_transfer_event_t transfer_event_func;
2124  globus_gfs_ipc_iface_set_cred_t set_cred;
2125  globus_gfs_ipc_iface_buffer_send_t buffer_send;
2126 } globus_gfs_ipc_iface_t;
2127 
2128 /*
2129  * getting an IPC handle
2130  */
2131 
2132 /*
2133  * create an IPC handle from a xio system handle, can be used
2134  * imediately, is not in handle table
2135  */
2136 globus_result_t
2137 globus_gfs_ipc_handle_create(
2138  globus_gfs_ipc_iface_t * iface,
2139  globus_xio_system_socket_t system_handle,
2140  globus_i_gfs_ipc_done_callback_t done_cb,
2141  void * user_arg);
2142 
2143 /*
2144  * actually close the handle
2145  */
2146 globus_result_t
2147 globus_gfs_ipc_close(
2148  globus_gfs_ipc_handle_t ipc_handle,
2149  globus_gfs_ipc_close_callback_t cb,
2150  void * user_arg);
2151 
2152 globus_result_t
2153 globus_gfs_ipc_reply_close(
2154  globus_gfs_ipc_handle_t ipc_handle);
2155 
2156 globus_result_t
2157 globus_gfs_ipc_session_stop(
2158  globus_gfs_ipc_handle_t ipc_handle);
2159 
2160 globus_result_t
2161 globus_gfs_ipc_handle_connect(
2162  globus_gfs_session_info_t * session_info,
2163  globus_gfs_ipc_open_callback_t cb,
2164  void * user_arg,
2165  globus_gfs_ipc_error_callback_t error_cb,
2166  void * error_user_arg);
2167 
2168 globus_result_t
2169 globus_gfs_ipc_handle_connect_ex(
2170  globus_gfs_session_info_t * session_info,
2171  globus_gfs_ipc_open_callback_t cb,
2172  void * user_arg,
2173  globus_gfs_ipc_error_callback_t error_cb,
2174  void * error_user_arg,
2175  globus_bool_t secure_ipc,
2176  gss_cred_id_t cred,
2177  const char *auth_mode,
2178  const char *subject,
2179  time_t connect_timeout,
2180  time_t idle_timeout,
2181  globus_bool_t inetd);
2182 
2183 globus_result_t
2184 globus_gfs_ipc_handle_obtain(
2185  globus_gfs_session_info_t * session_info,
2186  globus_gfs_ipc_iface_t * iface,
2187  globus_gfs_ipc_open_callback_t cb,
2188  void * user_arg,
2189  globus_gfs_ipc_error_callback_t error_cb,
2190  void * error_user_arg);
2191 
2192 /*
2193  * the brain bit
2194  */
2195 #define BRAIN_SYMBOL_NAME (void*)"gridftp_brain"
2196 extern globus_extension_registry_t brain_i_registry;
2197 
2198 typedef globus_result_t
2199 (*globus_i_gfs_brain_select_nodes_func_t)(
2200  globus_i_gfs_brain_node_t *** out_node_array,
2201  int * out_array_length,
2202  const char * repo_name,
2203  globus_off_t filesize,
2204  int min_count,
2205  int max_count);
2206 
2207 typedef globus_result_t
2208 (*globus_i_gfs_brain_release_node_func_t)(
2209  globus_i_gfs_brain_node_t * contact_node,
2210  globus_gfs_brain_reason_t reason);
2211 
2212 typedef globus_result_t
2213 (*globus_i_gfs_brain_init_func_t)(
2214  globus_callback_func_t ready_cb,
2215  void * ready_cb_arg);
2216 
2217 typedef void
2218 (*globus_i_gfs_brain_stop_func_t)();
2219 
2220 typedef globus_result_t
2221 (*globus_i_gfs_brain_get_available_func_t)(
2222  const char * user_id,
2223  const char * repo_name,
2224  int * count);
2225 
2226 
2227 typedef struct globus_i_gfs_brain_module_s
2228 {
2229  globus_i_gfs_brain_init_func_t init_func;
2230  globus_i_gfs_brain_stop_func_t stop_func;
2231  globus_i_gfs_brain_select_nodes_func_t select_func;
2232  globus_i_gfs_brain_release_node_func_t release_func;
2233  globus_i_gfs_brain_get_available_func_t available_func;
2234 } globus_i_gfs_brain_module_t;
2235 
2236 extern globus_i_gfs_brain_module_t globus_i_gfs_default_brain;
2237 
2238 globus_result_t
2239 globus_gfs_brain_select_nodes(
2240  globus_i_gfs_brain_node_t *** out_node_array,
2241  int * out_array_length,
2242  const char * repo_name,
2243  globus_off_t filesize,
2244  int min_count,
2245  int max_count);
2246 
2247 globus_result_t
2248 globus_gfs_brain_release_node(
2249  globus_i_gfs_brain_node_t * contact_node,
2250  globus_gfs_brain_reason_t reason);
2251 
2252 globus_result_t
2253 globus_gfs_brain_get_available(
2254  const char * user_id,
2255  const char * repo_name,
2256  int * count);
2257 
2258 globus_result_t
2259 globus_gfs_ipc_handle_get_contact_string(
2260  globus_gfs_ipc_handle_t ipc_handle,
2261  char ** contact_string);
2262 
2263 globus_result_t
2264 globus_gfs_ipc_init(
2265  globus_bool_t requester);
2266 
2267 /*
2268  *
2269  */
2270 void
2271 globus_gfs_ipc_add_server(
2272  globus_xio_server_t server_handle);
2273 
2274 extern globus_gfs_ipc_iface_t globus_gfs_ipc_default_iface;
2275 
2276 /* end IPC */
2277 
2278 /* ACL interface */
2279 
2280 /*
2281  * interface implementation functions
2282  * see the globus_gridftp_server_acl_example package at
2283  * gridftp/server/acl/example for an example implementation.
2284  */
2285 
2286 /* acl handle object. members are internal use only. */
2287 typedef struct globus_i_gfs_acl_handle_s * globus_gfs_acl_handle_t;
2288 
2289 /* supported actions, all authorization callouts will be of these types.
2290  * an authorization callout should return success for any actions that
2291  * are not interesting. */
2292 typedef enum globus_gfs_acl_action_e
2293 {
2294  /* internal use only */
2295  GFS_ACL_ACTION_INIT = 1,
2296  /* the named object. will be deleted. */
2297  GFS_ACL_ACTION_DELETE,
2298  /* write to an existing object */
2299  GFS_ACL_ACTION_WRITE,
2300  /* create and write to a non-existant object */
2301  GFS_ACL_ACTION_CREATE,
2302  /* read an object */
2303  GFS_ACL_ACTION_READ,
2304  /* query metadata of an object (i.e. list) */
2305  GFS_ACL_ACTION_LOOKUP,
2306  /* speficy an authorization assertion. client may submit data to
2307  * influence future authorization decisions. data is in an unspecified
2308  * format. */
2309  GFS_ACL_ACTION_AUTHZ_ASSERT,
2310  /* report data safely written to disk. failure means data written has
2311  * overrun acceptable limits. */
2312  GFS_ACL_ACTION_COMMIT,
2313  /* increase previously requested write limits for an object */
2314  GFS_ACL_ACTION_GROW
2315 } globus_gfs_acl_action_t;
2316 
2317 /* user connection descriptor. this provides info about the user
2318  * attempting the connection or action */
2319 typedef struct globus_gfs_acl_info_s
2320 {
2321  char * hostname;
2322  char * subject;
2323  char * username;
2324  char * password;
2325  char * ipaddr;
2326  gss_ctx_id_t context;
2327 } globus_gfs_acl_info_t;
2328 
2329 /* object descriptor. this provides various info about the object of the
2330  * action attempt. */
2331 typedef struct globus_gfs_acl_object_desc_s
2332 {
2333  /* ALL: name of the object. commonly a filename.
2334  * value is NULL when not known or not used. */
2335  char * name;
2336 
2337  /* WRITE/CREATE: size being requested to write.
2338  * COMMIT: amount of data already written safely.
2339  * GROW: new full size being requested to write.
2340  * value is 0 when not known or not used. */
2341  globus_off_t size;
2342 
2343  /* AUTHZ_ASSERT: assertion data from the client.
2344  * value is NULL when not known or not used. */
2345  char * data;
2346 
2347  /* COMMIT: all data has been safely written
2348  * value is FALSE when not known or not used. */
2349  globus_bool_t final;
2350 
2352  globus_gfs_op_info_t op_info;
2353 } globus_gfs_acl_object_desc_t;
2354 
2355 /* return values for authorization functions */
2356 typedef enum globus_gfs_acl_status_e
2357 {
2358  /* decision is complete */
2359  GLOBUS_GFS_ACL_COMPLETE = 1,
2360  /* decision will be made in a seperate call to
2361  globus_gfs_acl_authorized_finished() */
2362  GLOBUS_GFS_ACL_WOULD_BLOCK
2363 } globus_gfs_acl_status_t;
2364 
2365 /* initialization callout. this is ususally necessary. must be
2366  * implemented if:
2367  * 1) we need to set up some sort of internal state/handle that can be passed
2368  * back to us in all callouts
2369  * and/or
2370  * 2) we are interested in authorizing the gridftp session based on client
2371  * user information.
2372  *
2373  * must return GLOBUS_GFS_ACL_COMPLETE or GLOBUS_GFS_ACL_WOULD_BLOCK, and
2374  * store GLOBUS_SUCCESS or an error result_t in out_res. if returning
2375  * GLOBUS_GFS_ACL_WOULD_BLOCK, the result must be returned in a call to
2376  * globus_gfs_acl_authorized_finished(). optionally, a pointer may be stored
2377  * in out_handle. this pointer will then be passed back in later callouts.
2378  */
2379 typedef int
2380 (*globus_gfs_acl_init_t)(
2381  void ** out_handle,
2382  globus_gfs_acl_info_t * acl_info,
2383  globus_gfs_acl_handle_t acl_handle,
2384  globus_result_t * out_res);
2385 
2386 /* authorization callout. this is usually necessary. here we will
2387  * get called to authrorize all actions the client performs. see the
2388  * globus_gfs_acl_action_t declaration for all of the supported actions.
2389  *
2390  * must return GLOBUS_GFS_ACL_COMPLETE or GLOBUS_GFS_ACL_WOULD_BLOCK, and
2391  * store GLOBUS_SUCCESS or an error result_t in out_res. If returning
2392  * GLOBUS_GFS_ACL_WOULD_BLOCK, the result must be returned in a call to
2393  * globus_gfs_acl_authorized_finished().
2394  */
2395 typedef int
2396 (*globus_gfs_acl_authorize_t)(
2397  void * out_handle,
2398  globus_gfs_acl_action_t action,
2399  globus_gfs_acl_object_desc_t * object,
2400  globus_gfs_acl_info_t * acl_info,
2401  globus_gfs_acl_handle_t acl_handle,
2402  globus_result_t * out_res);
2403 
2404 /* destructor callout. clean up our session state if necessary */
2405 typedef void
2406 (*globus_gfs_acl_destroy_t)(
2407  void * out_handle);
2408 
2409 /* audit callout. informational callout only. implement this if you would
2410  * like to be notified of activities, but don't need to allow/deny them. */
2411 typedef void
2412 (*globus_gfs_acl_audit_t)(
2413  void * out_handle,
2414  globus_gfs_acl_action_t action,
2415  globus_gfs_acl_object_desc_t * object,
2416  const char * message);
2417 
2418 /* acl module descriptor.
2419  * Only define the functions you implement, otherwise NULL */
2420 typedef struct globus_gfs_acl_module_s
2421 {
2422  globus_gfs_acl_init_t init_func;
2423  globus_gfs_acl_authorize_t authorize_func;
2424  globus_gfs_acl_destroy_t destroy_func;
2425  globus_gfs_acl_audit_t audit_func;
2426 } globus_gfs_acl_module_t;
2427 
2428 /* authorization finalization function. this must be called when the
2429  * initialization or authorization callouts return GLOBUS_GFS_ACL_WOULD_BLOCK.
2430  */
2431 void
2432 globus_gfs_acl_authorized_finished(
2433  globus_gfs_acl_handle_t acl_handle,
2434  globus_result_t result);
2435 
2436 /* helper function to get strings from action types. useful for log/error
2437  * messages */
2438 const char *
2439 globus_gfs_acl_action_to_string(
2440  globus_gfs_acl_action_t action);
2441 
2442 
2443 /* end ACL */
2444 
2445 
2446 /* config locking functions */
2447 typedef
2448 void
2449 (*globus_i_gfs_config_set_string_cb_t)(
2450  const char * option_name,
2451  const char * val,
2452  void * user_arg);
2453 
2454 typedef
2455 void
2456 (*globus_i_gfs_config_set_int_cb_t)(
2457  const char * option_name,
2458  int val,
2459  void * user_arg);
2460 
2461 typedef struct
2462 {
2463  void * user_arg;
2464  globus_bool_t enabled;
2465  void * cb;
2466 } globus_i_gfs_config_option_cb_ent_t;
2467 
2468 void
2469 globus_gfs_config_enable_cb(
2470  globus_i_gfs_config_option_cb_ent_t * cb_handle,
2471  globus_bool_t enabled);
2472 
2473 int
2474 globus_gfs_config_add_cb(
2475  globus_i_gfs_config_option_cb_ent_t ** cb_handle,
2476  char * option_name,
2477  void * cb,
2478  void * user_arg);
2479 
2480 globus_bool_t
2481 globus_gfs_config_get_bool(
2482  const char * option_name);
2483 
2484 char *
2485 globus_gfs_config_get_string(
2486  const char * option_name);
2487 
2488 globus_list_t *
2489 globus_gfs_config_get_list(
2490  const char * option_name);
2491 
2492 void *
2493 globus_gfs_config_get(
2494  const char * option_name);
2495 
2496 int
2497 globus_gfs_config_get_int(
2498  const char * option_name);
2499 
2500 int
2501 globus_gfs_config_set_int(
2502  char * option_name,
2503  int int_value);
2504 
2505 int
2506 globus_gfs_config_set_bool(
2507  char * option_name,
2508  int int_value);
2509 
2510 int
2511 globus_gfs_config_set_ptr(
2512  char * option_name,
2513  void * ptr);
2514 
2515 int
2516 globus_gfs_config_inc_int(
2517  char * option_name,
2518  int inc_val);
2519 
2520 #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:1069
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:14434
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:15165
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