globus_xio_driver.h

00001 /*
00002  * Copyright 1999-2006 University of Chicago
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #if !defined(GLOBUS_XIO_DRIVER_H)
00018 #define GLOBUS_XIO_DRIVER_H 1
00019 
00020 #include "globus_common.h"
00021 #include "globus_xio_load.h"
00022 #include "globus_common.h"
00023 #include "globus_xio_types.h"
00024 #include "globus_xio.h"
00025 #include "globus_xio_util.h"
00026 #include <stdarg.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 /*-**********************************************************************
00033  *                      attribute macros
00034  ***********************************************************************/
00035 #define GlobusIXIOAttrGetDS(_out_ds, _in_attr, _in_driver)                  \
00036 do                                                                          \
00037 {                                                                           \
00038     int                                 _ctr;                               \
00039     globus_i_xio_attr_t *               _attr;                              \
00040     globus_xio_driver_t                 _driver;                            \
00041     globus_i_xio_attr_ent_t *           _entry;                             \
00042     void *                              _ds = NULL;                         \
00043                                                                             \
00044     _attr = (_in_attr);                                                     \
00045     _driver = (_in_driver);                                                 \
00046                                                                             \
00047     if(_in_attr == NULL)                                                    \
00048     {                                                                       \
00049         _out_ds = NULL;                                                     \
00050     }                                                                       \
00051     else                                                                    \
00052     {                                                                       \
00053         _entry = _attr->entry;                                              \
00054         for(_ctr = 0; _ctr < _attr->ndx && _ds == NULL; _ctr++)             \
00055         {                                                                   \
00056             if(_entry[_ctr].driver == _driver)                              \
00057             {                                                               \
00058                 _ds = _entry[_ctr].driver_data;                             \
00059             }                                                               \
00060     }                                                                       \
00061         _out_ds = _ds;                                                      \
00062     }                                                                       \
00063 } while(0)
00064     
00065 /*-*****************************************************************
00066  *                      driver interface
00067  ******************************************************************/
00252 /*******************************************************************
00253  *                        callbacks
00254  ******************************************************************/
00271 typedef void
00272 (*globus_xio_driver_callback_t)(
00273     globus_xio_operation_t              op,
00274     globus_result_t                     result,
00275     void *                              user_arg);
00276 
00277 
00299 typedef void
00300 (*globus_xio_driver_data_callback_t)(
00301     globus_xio_operation_t              op,
00302     globus_result_t                     result,
00303     globus_size_t                       nbytes,
00304     void *                              user_arg);
00305 
00306 
00307 typedef globus_result_t
00308 (*globus_xio_driver_push_driver_t)(
00309     globus_xio_driver_t                 driver,
00310     globus_xio_stack_t                  stack);
00311 
00312 globus_result_t
00313 globus_xio_driver_attr_cntl(
00314     globus_xio_operation_t              op,
00315     globus_xio_driver_t                 driver,
00316     int                                 cmd,
00317     ...);
00318 
00319 globus_result_t
00320 globus_xio_driver_data_descriptor_cntl(
00321     globus_xio_operation_t              op,
00322     globus_xio_driver_t                 driver,
00323     int                                 cmd,
00324     ...);
00325 
00335 globus_result_t
00336 globus_xio_driver_handle_cntl(
00337     globus_xio_driver_handle_t          handle,
00338     globus_xio_driver_t                 driver,
00339     int                                 cmd,
00340     ...);
00341 
00345 typedef globus_result_t
00346 (*globus_xio_driver_get_driver_t)(
00347     globus_xio_driver_t *               out_driver);
00356 typedef globus_result_t
00357 (*globus_xio_driver_attr_init_t)(
00358     void **                             out_driver_attr);
00359 
00367 typedef globus_result_t
00368 (*globus_xio_driver_attr_copy_t)(
00369     void **                             dst,
00370     void *                              src);
00371 
00379 typedef globus_result_t
00380 (*globus_xio_driver_attr_destroy_t)(
00381     void *                              driver_attr);
00382 
00402 typedef globus_result_t
00403 (*globus_xio_driver_attr_cntl_t)(
00404     void *                              attr,
00405     int                                 cmd,
00406     va_list                             ap);
00407 
00433 typedef globus_result_t
00434 (*globus_xio_driver_server_init_t)(
00435     void *                              driver_attr,
00436     const globus_xio_contact_t *        contact_info,
00437     globus_xio_operation_t              op);
00438 
00464 globus_result_t
00465 globus_xio_driver_pass_server_init(
00466     globus_xio_operation_t              op,
00467     const globus_xio_contact_t *        contact_info,
00468     void *                              driver_server);
00469 
00484 typedef globus_result_t
00485 (*globus_xio_driver_server_destroy_t)(
00486     void *                              driver_server);
00487 
00508 typedef globus_result_t
00509 (*globus_xio_driver_server_accept_t)(
00510     void *                              driver_server,
00511     globus_xio_operation_t              op);
00512 
00513 globus_result_t
00514 globus_xio_driver_pass_accept(
00515     globus_xio_operation_t              op,
00516     globus_xio_driver_callback_t        in_cb,
00517     void *                              in_user_arg);
00518 
00522 typedef void
00523 (*globus_xio_driver_cancel_callback_t)(
00524     globus_xio_operation_t              op,
00525     void *                              user_arg,
00526     globus_xio_error_type_t             reason);
00527 
00547 void
00548 globus_xio_driver_finished_accept(
00549     globus_xio_operation_t              op,
00550     void *                              driver_link,
00551     globus_result_t                     result);
00552     
00570 typedef globus_result_t
00571 (*globus_xio_driver_server_cntl_t)(
00572     void *                              driver_server,
00573     int                                 cmd,
00574     va_list                             ap);
00575 
00576 
00580 typedef globus_result_t
00581 (*globus_xio_driver_link_cntl_t)(
00582     void *                              driver_link,
00583     int                                 cmd,
00584     va_list                             ap);
00585 
00596 typedef globus_result_t
00597 (*globus_xio_driver_link_destroy_t)(
00598     void *                              driver_link);
00599 
00600 
00601 /**********************************************************************
00602  *                          Open
00603  *********************************************************************/
00604 
00632 typedef globus_result_t
00633 (*globus_xio_driver_transform_open_t)(
00634     const globus_xio_contact_t *        contact_info,
00635     void *                              driver_link,
00636     void *                              driver_attr,
00637     globus_xio_operation_t              op);
00638 
00643 typedef globus_result_t
00644 (*globus_xio_driver_transport_open_t)(
00645     const globus_xio_contact_t *        contact_info,
00646     void *                              driver_link,
00647     void *                              driver_attr,
00648     globus_xio_operation_t              op);
00649 
00678 globus_result_t
00679 globus_xio_driver_pass_open(
00680     globus_xio_operation_t              op,
00681     const globus_xio_contact_t *        contact_info,
00682     globus_xio_driver_callback_t        cb,
00683     void *                              user_arg);
00684 
00704 void
00705 globus_xio_driver_finished_open(
00706     void *                              driver_handle,
00707     globus_xio_operation_t              op,
00708     globus_result_t                     result);
00709 
00710 /**********************************************************************
00711  *                      Context functions
00712  *********************************************************************/
00731 globus_result_t
00732 globus_xio_driver_operation_create(
00733     globus_xio_operation_t *            operation,
00734     globus_xio_driver_handle_t          handle);
00735 
00739 void
00740 globus_xio_driver_operation_destroy(
00741     globus_xio_operation_t              operation);
00742 
00746 globus_result_t
00747 globus_xio_driver_operation_cancel(
00748     globus_xio_driver_handle_t          handle,
00749     globus_xio_operation_t              operation);
00750 
00759 globus_bool_t
00760 globus_xio_driver_operation_is_blocking(
00761     globus_xio_operation_t              operation);
00762 
00774 typedef globus_result_t
00775 (*globus_xio_driver_handle_cntl_t)(
00776     void *                              handle,
00777     int                                 cmd,
00778     va_list                             ap);
00779 
00780 
00781 globus_result_t
00782 globus_xio_driver_merge_handle(
00783     globus_xio_operation_t              op,
00784     globus_xio_driver_handle_t          handle);
00785 
00786 /**********************************************************************
00787  *                          Close
00788  *********************************************************************/
00808 typedef globus_result_t
00809 (*globus_xio_driver_close_t)(
00810     void *                              driver_handle,
00811     void *                              driver_attr,
00812     globus_xio_operation_t              op);
00813 
00830 globus_result_t
00831 globus_xio_driver_pass_close(
00832     globus_xio_operation_t              op,
00833     globus_xio_driver_callback_t        cb,
00834     void *                              callback_arg);
00835 
00851 void
00852 globus_xio_driver_finished_close(
00853     globus_xio_operation_t              op,
00854     globus_result_t                     result);
00855 
00856 /**********************************************************************
00857  *                          Read
00858  *********************************************************************/
00882 typedef globus_result_t
00883 (*globus_xio_driver_read_t)(
00884     void *                              driver_specific_handle,
00885     const globus_xio_iovec_t *          iovec,
00886     int                                 iovec_count,
00887     globus_xio_operation_t              op);
00888 
00920 globus_result_t
00921 globus_xio_driver_pass_read(
00922     globus_xio_operation_t              op,
00923     globus_xio_iovec_t *                iovec,
00924     int                                 iovec_count,
00925     globus_size_t                       wait_for,
00926     globus_xio_driver_data_callback_t   cb,
00927     void *                              user_arg);
00928 
00946 void
00947 globus_xio_driver_finished_read(
00948     globus_xio_operation_t              op,
00949     globus_result_t                     result,
00950     globus_size_t                       nread);
00951 
00976 void
00977 globus_xio_driver_set_eof_received(
00978     globus_xio_operation_t              op);
00979 
01002 globus_bool_t
01003 globus_xio_driver_eof_received(
01004     globus_xio_operation_t              op);
01005 
01006 /**********************************************************************
01007  *                          Write
01008  *********************************************************************/
01032 typedef globus_result_t
01033 (*globus_xio_driver_write_t)(
01034     void *                              driver_specific_handle,
01035     const globus_xio_iovec_t *          iovec,
01036     int                                 iovec_count,
01037     globus_xio_operation_t              op);
01038 
01071 globus_result_t
01072 globus_xio_driver_pass_write(
01073     globus_xio_operation_t              op,
01074     globus_xio_iovec_t *                iovec,
01075     int                                 iovec_count,
01076     globus_size_t                       wait_for,
01077     globus_xio_driver_data_callback_t   cb,
01078     void *                              user_arg);
01079 
01097 void
01098 globus_xio_driver_finished_write(
01099     globus_xio_operation_t              op,
01100     globus_result_t                     result,
01101     globus_size_t                       nwritten);
01102 
01127 globus_result_t
01128 globus_xio_driver_merge_operation(
01129      globus_xio_operation_t             top_op,
01130      globus_xio_operation_t             bottom_op);
01131 
01132 
01133 /**********************************************************************
01134  *                     data descriptors
01135  *********************************************************************/
01193 globus_result_t
01194 globus_xio_driver_init(
01195     globus_xio_driver_t *               driver,
01196     const char *                        driver_name,
01197     void *                              user_data);
01198 
01202 globus_result_t
01203 globus_xio_driver_get_user_data(
01204     globus_xio_driver_t                 in_driver,
01205     void **                             out_user_data);
01206 
01207 globus_result_t
01208 globus_xio_operation_attr_cntl(
01209     globus_xio_operation_t              op,
01210     globus_xio_attr_cmd_t               cmd,
01211     ...);
01212 
01216 globus_result_t
01217 globus_xio_driver_destroy(
01218     globus_xio_driver_t                 driver);
01219 
01223 globus_result_t
01224 globus_xio_driver_set_transport(
01225     globus_xio_driver_t                 driver,
01226     globus_xio_driver_transport_open_t  transport_open_func,
01227     globus_xio_driver_close_t           close_func,
01228     globus_xio_driver_read_t            read_func,
01229     globus_xio_driver_write_t           write_func,
01230     globus_xio_driver_handle_cntl_t     handle_cntl_func);
01231 
01235 globus_result_t
01236 globus_xio_driver_set_transform(
01237     globus_xio_driver_t                 driver,
01238     globus_xio_driver_transform_open_t  transform_open_func,
01239     globus_xio_driver_close_t           close_func,
01240     globus_xio_driver_read_t            read_func,
01241     globus_xio_driver_write_t           write_func,
01242     globus_xio_driver_handle_cntl_t     handle_cntl_func,
01243     globus_xio_driver_push_driver_t     push_driver_func);
01244 
01248 globus_result_t
01249 globus_xio_driver_set_server(
01250     globus_xio_driver_t                 driver,
01251     globus_xio_driver_server_init_t     server_init_func,
01252     globus_xio_driver_server_accept_t   server_accept_func,
01253     globus_xio_driver_server_destroy_t  server_destroy_func,
01254     globus_xio_driver_server_cntl_t     server_cntl_func,
01255     globus_xio_driver_link_cntl_t       link_cntl_func,
01256     globus_xio_driver_link_destroy_t    link_destroy_func);
01257 
01258 globus_result_t
01259 globus_xio_driver_set_server_pre_init(
01260     globus_xio_driver_t                 driver,
01261     globus_xio_driver_server_init_t     server_pre_init_func);
01265 globus_result_t
01266 globus_xio_driver_set_attr(
01267     globus_xio_driver_t                 driver,
01268     globus_xio_driver_attr_init_t       attr_init_func,
01269     globus_xio_driver_attr_copy_t       attr_copy_func,
01270     globus_xio_driver_attr_cntl_t       attr_cntl_func,
01271     globus_xio_driver_attr_destroy_t    attr_destroy_func);
01272 
01273 /*
01274  *  operation accessors
01275  */
01276 void
01277 globus_xio_operation_block_timeout(
01278     globus_xio_operation_t              op);
01279     
01280 void
01281 globus_xio_operation_unblock_timeout(
01282     globus_xio_operation_t              op);
01283 
01284 void
01285 globus_xio_operation_refresh_timeout(
01286     globus_xio_operation_t              op);
01287 
01289 globus_bool_t
01290 globus_xio_operation_enable_cancel(
01291     globus_xio_operation_t              op,
01292     globus_xio_driver_cancel_callback_t cb,
01293     void *                              user_arg);
01294 
01295 void
01296 globus_xio_operation_disable_cancel(
01297     globus_xio_operation_t              op);
01298 
01299 globus_bool_t
01300 globus_xio_operation_is_canceled(
01301     globus_xio_operation_t              op);
01302 
01303 globus_size_t
01304 globus_xio_operation_get_wait_for(
01305     globus_xio_operation_t              op);
01306 
01307 void *
01308 globus_xio_operation_get_driver_specific(
01309     globus_xio_operation_t              op);
01310 
01311 globus_xio_driver_t
01312 globus_xio_operation_get_user_driver(
01313     globus_xio_operation_t              op);
01314 
01315 globus_xio_driver_t
01316 globus_xio_operation_get_transport_user_driver(
01317     globus_xio_operation_t              op);
01318 
01319 /* this returns the handle to the drivers below you */
01320 globus_xio_driver_handle_t
01321 globus_xio_operation_get_driver_handle(
01322     globus_xio_operation_t              op);
01323 
01324 /* this returns the handle to your driver.
01325  * (only useful for canceling operations in your possession)
01326  * or getting user handle associated with the driver
01327  */
01328 globus_xio_driver_handle_t
01329 globus_xio_operation_get_driver_self_handle(
01330     globus_xio_operation_t              op);
01331 
01332 void *
01333 globus_xio_operation_get_data_descriptor(
01334     globus_xio_operation_t              op,
01335     globus_bool_t                       force_create);
01336 
01337 globus_result_t
01338 globus_xio_operation_copy_stack(
01339     globus_xio_operation_t              op,
01340     globus_xio_stack_t *                stack);
01341 
01342 /* STRING PARSING STUFF */
01346 typedef globus_result_t
01347 (*globus_xio_string_cntl_parse_func_t)(
01348     void *                              attr,
01349     const char *                        key,
01350     const char *                        val,
01351     int                                 cmd,
01352     globus_xio_driver_attr_cntl_t       cntl_func);
01353 
01357 typedef struct globus_xio_string_cntl_table_s
01358 {
01359     const char *                        key;
01360     int                                 cmd;
01361     globus_xio_string_cntl_parse_func_t parse_func;
01362 } globus_xio_string_cntl_table_t;
01363 
01417 globus_result_t
01418 globus_xio_driver_string_cntl_set_table(
01419     globus_xio_driver_t                 driver,
01420     globus_xio_string_cntl_table_t *   table);
01421 
01426 globus_result_t
01427 globus_xio_driver_handle_string_cntl_set_table(
01428     globus_xio_driver_t                driver,
01429     globus_xio_string_cntl_table_t *   table);
01430 
01436 globus_result_t
01437 globus_xio_string_cntl_bouncer(
01438     globus_xio_driver_attr_cntl_t       cntl_func,
01439     void *                              attr,
01440     int                                 cmd,
01441     ...);
01442 
01443 /* list all of the built in parsing functions */
01449 globus_result_t
01450 globus_xio_string_cntl_bool(
01451     void *                              attr,
01452     const char *                        key,
01453     const char *                        val,
01454     int                                 cmd,
01455     globus_xio_driver_attr_cntl_t       cntl_func);
01456 
01462 globus_result_t
01463 globus_xio_string_cntl_float(
01464     void *                              attr,
01465     const char *                        key,
01466     const char *                        val,
01467     int                                 cmd,
01468     globus_xio_driver_attr_cntl_t       cntl_func);
01469 
01475 globus_result_t
01476 globus_xio_string_cntl_int(
01477     void *                              attr,
01478     const char *                        key,
01479     const char *                        val,
01480     int                                 cmd,
01481     globus_xio_driver_attr_cntl_t       cntl_func);
01482 
01488 globus_result_t
01489 globus_xio_string_cntl_string(
01490     void *                              attr,
01491     const char *                        key,
01492     const char *                        val,
01493     int                                 cmd,
01494     globus_xio_driver_attr_cntl_t       cntl_func);
01495 
01501 globus_result_t
01502 globus_xio_string_cntl_int_int(
01503     void *                              attr,
01504     const char *                        key,
01505     const char *                        val,
01506     int                                 cmd,
01507     globus_xio_driver_attr_cntl_t       cntl_func);
01508 
01509 globus_result_t
01510 globus_xio_string_cntl_formated_off(
01511     void *                              attr,
01512     const char *                        key,
01513     const char *                        val,
01514     int                                 cmd,
01515     globus_xio_driver_attr_cntl_t       cntl_func);
01516 
01517 globus_result_t
01518 globus_xio_string_cntl_formated_int(
01519     void *                              attr,
01520     const char *                        key,
01521     const char *                        val,
01522     int                                 cmd,
01523     globus_xio_driver_attr_cntl_t       cntl_func);
01524 
01525 globus_result_t
01526 globus_xio_string_cntl_string_list(
01527     void *                              attr,
01528     const char *                        key,
01529     const char *                        val,
01530     int                                 cmd,
01531     globus_xio_driver_attr_cntl_t       cntl_func);
01532 
01533 
01534 #ifdef __cplusplus
01535 }
01536 #endif
01537 
01538 #endif /* GLOBUS_XIO_DRIVER_H */

Generated on 25 Nov 2015 for globus_xio by  doxygen 1.4.7