static
globus_result_t
globus_l_xio_net_manager_accept(
    const globus_xio_contact_t *        contact_info,
    void *                              driver_link,
    void *                              driver_attr,
    globus_xio_operation_t              op)
{
    globus_result_t                     result = GLOBUS_SUCCESS;
    globus_l_xio_net_manager_link_t    *link = driver_link;

    result = globus_xio_driver_pass_open(op, contact_info,
            globus_l_xio_net_manager_accept_callback,
            link);

    return result;
}
Exemplo n.º 2
0
globus_result_t
globus_l_xio_bounce_open(
    const globus_xio_contact_t *        contact_info,
    void *                              driver_link,
    void *                              driver_attr,
    globus_xio_operation_t              op)
{
    bounce_info_t *                     info;
    globus_result_t                     res;
    GlobusXIOName(globus_l_xio_bounce_open);

    GlobusXIOTestDebugInternalEnter();
    info = (bounce_info_t *)
                globus_malloc(sizeof(bounce_info_t));
    memset(info, '\0', sizeof(bounce_info_t));
    info->next_op = TEST_READ;
    info->bounce_count = 0;
    info->max_count = MAX_COUNT;
    info->start_op = TEST_OPEN;
    info->handle = (bounce_handle_t *) globus_malloc(sizeof(bounce_handle_t));  
    globus_mutex_init(&info->handle->mutex, NULL);
    info->handle->closed_iface = GLOBUS_FALSE;
    info->handle->closed_cb = GLOBUS_FALSE;
    info->handle->open_cb = GLOBUS_FALSE;

    res = globus_xio_driver_pass_open(
        op, contact_info, open_bounce_cb, (void*)info);
    if(res != GLOBUS_SUCCESS)
    {
        bounce_handle_destroy(info->handle);
        globus_free(info);
        goto err;
    }

    GlobusXIOTestDebugInternalExit();
    return GLOBUS_SUCCESS;

  err:
    GlobusXIOTestDebugInternalExitWithError();
    return res;
}
Exemplo n.º 3
0
static globus_result_t
globus_l_xio_telnet_open(
    const globus_xio_contact_t *        contact_info,
    void *                              driver_link,
    void *                              driver_attr,
    globus_xio_operation_t              op)
{
    globus_result_t                     res;
    globus_l_xio_telnet_attr_t *       attr;
    globus_l_xio_telnet_handle_t *     handle;
    GlobusXIOName(globus_l_xio_telnet_open);

    /* decide what attr to use */
    if(driver_attr != NULL)
    {
        attr = (globus_l_xio_telnet_attr_t *) driver_attr;
    }
    else if(driver_link != NULL)
    {
        attr = (globus_l_xio_telnet_attr_t *) driver_link;
    }
    else
    {
        /* default */
        attr = NULL;
    }

    handle = (globus_l_xio_telnet_handle_t *) globus_calloc(
        sizeof(globus_l_xio_telnet_handle_t), 1);
    if(handle == NULL)
    {
        res = GlobusXIOErrorMemory("handle");
        goto error_handle_alloc;
    }

    if(attr != NULL && attr->force_server)
    {
        handle->client = GLOBUS_FALSE;
    }
    else
    {       
        handle->client = driver_link ? GLOBUS_FALSE : GLOBUS_TRUE;
    }

    handle->read_buffer_length = GLOBUS_L_XIO_TELNET_DEFAULT_BUFFER_SIZE;
    handle->read_buffer = globus_malloc(handle->read_buffer_length);
    if(handle->read_buffer == NULL)
    {
        res = GlobusXIOErrorMemory("buffer");
        goto error_buffer_alloc;
    }
    globus_mutex_init(&handle->mutex, NULL);
    globus_fifo_init(&handle->write_q);

    handle->create_buffer_mode = attr 
        ? attr->create_buffer_mode : GLOBUS_FALSE;

    res = globus_xio_driver_pass_open(
        op,
        contact_info,
        globus_l_xio_telnet_open_cb,
        handle);
    if(res != GLOBUS_SUCCESS)
    {
        goto error_pass;
    }

    return GLOBUS_SUCCESS;
error_pass:
    globus_free(handle->read_buffer);
    globus_mutex_destroy(&handle->mutex);
    globus_fifo_destroy(&handle->write_q);
error_buffer_alloc:
    globus_free(handle);
error_handle_alloc:
    return res;
}
static
globus_result_t
globus_l_xio_net_manager_connect(
    const globus_xio_contact_t *        contact_info,
    void *                              driver_attr,
    globus_xio_operation_t              op)
{
    globus_result_t                     result = GLOBUS_SUCCESS;
    globus_l_xio_net_manager_handle_t  *handle = NULL;
    char                               *contact_out = NULL;
    char                               *string_opts = NULL;
    globus_net_manager_attr_t          *attrs = NULL, *attr_array_out = NULL;
    globus_xio_contact_t                new_contact_info = {NULL};
    
    if (!driver_attr)
    {
        goto no_attr;
    }
    handle = malloc(sizeof(globus_l_xio_net_manager_handle_t));
    if (handle == NULL)
    {
        result = GlobusNetManagerErrorMemory("handle");
        goto malloc_handle_fail;
    }
    handle->local_contact = handle->remote_contact = NULL;

    result = globus_l_xio_net_manager_attr_copy(
            (void **)&handle->attr, driver_attr);
    if (result != GLOBUS_SUCCESS)
    {
        goto attr_copy_fail;
    }

    handle->passive = GLOBUS_FALSE;
    handle->transport_driver = globus_xio_operation_get_transport_user_driver(
            op);
    result = globus_xio_driver_attr_cntl(
            op,
            handle->transport_driver,
            GLOBUS_XIO_GET_DRIVER_NAME,
            &handle->transport_name);
    if (result)
    {
        goto get_driver_name_fail;
    }

    result = globus_xio_driver_attr_cntl(
        op,
        handle->transport_driver,
        GLOBUS_XIO_GET_STRING_OPTIONS,
        &string_opts);
    if (result)
    {
        goto get_string_opts_fail;
    }
    result = globus_net_manager_attr_array_from_string(
        &attrs,
        handle->transport_name,
        string_opts);
    if (result)
    {
        goto array_from_string_fail;
    }

    result = globus_net_manager_context_pre_connect(
            handle->attr->context,
            handle->attr->task_id ? handle->attr->task_id : "unset",
            handle->transport_name,
            contact_info->unparsed,
            attrs,
            &contact_out,
            &attr_array_out);

    if (result != GLOBUS_SUCCESS)
    {
        goto pre_connect_fail;
    }
    if (contact_out)
    {
        result = globus_xio_contact_parse(&new_contact_info, contact_out);
        if (result != GLOBUS_SUCCESS)
        {
            goto new_contact_parse_fail;
        }
        handle->remote_contact = contact_out;
        contact_out = NULL;
    }
    else
    {
        handle->remote_contact = strdup(contact_info->unparsed);
        if (handle->remote_contact == NULL)
        {
            result = GlobusNetManagerErrorMemory("remote_contact");
            goto strdup_remote_contact_fail;
        }
    }
    if (attr_array_out)
    {
        globus_net_manager_attr_array_delete(handle->attr->attr_array);
        handle->attr->attr_array = attr_array_out;

        result = globus_l_xio_net_manager_transport_handle_apply(
                handle, op, attr_array_out);
        if (result != GLOBUS_SUCCESS)
        {
            goto attr_apply_fail;
        }
    }

no_attr:
    result = globus_xio_driver_pass_open(
        op, contact_info, globus_l_xio_net_manager_connect_callback, handle);

attr_apply_fail:
    if (result && handle)
    {
        free(handle->remote_contact);
    }
strdup_remote_contact_fail:
new_contact_parse_fail:
    free(contact_out);
pre_connect_fail:
    globus_net_manager_attr_array_delete(attrs);
array_from_string_fail:
    free(string_opts);
get_string_opts_fail:
get_driver_name_fail:
    if (result && handle)
    {
        globus_l_xio_net_manager_attr_destroy(handle->attr);
attr_copy_fail:
        free(handle);
    }
malloc_handle_fail:
    return result;
}