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