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