Exemplo n.º 1
0
/*
 * tftp_server_init
 * @tftp_server: TFTP server instance to initialize.
 * @socket_address: Socket address at which TFTP server will be listening on.
 * @name: Name of the TFTP server.
 * This function will initialize TFTP server.
 */
void tftp_server_init(TFTP_SERVER *tftp_server, SOCKET_ADDRESS *socket_address, char *name)
{
    SYS_LOG_FUNCTION_ENTRY(TFTPS);

    /* Clear the given server structure. */
    memset(tftp_server, 0, sizeof(TFTP_SERVER));

    /* Use buffered mode for this UDP port. */
    tftp_server->port.console.fs.flags = FS_BUFFERED;

    /* As we will be using net condition to process data on this port so it
     * would not be okay to suspend for buffers. */
    tftp_server->port.flags = UDP_FLAG_THR_BUFFERS;

    /* Register the UDP port. */
    udp_register((FD)&tftp_server->port, name, socket_address);

    /* Get read condition for UDP port. */
    fs_condition_get((FD)&tftp_server->port, &tftp_server->port_condition, &tftp_server->port_suspend, &tftp_server->port_fs_param, FS_BLOCK_READ);

    /* For now disable the timer. */
    tftp_server->port_suspend.timeout_enabled = FALSE;
    tftp_server->port_suspend.priority = NET_SOCKET_PRIORITY;
    tftp_server->port_suspend.status = SUCCESS;

    /* Lets never block on this socket. */
    tftp_server->port.console.fs.flags &= (uint16_t)~(FS_BLOCK);

    /* Add a networking condition for this UDP port. */
    net_condition_add(tftp_server->port_condition, &tftp_server->port_suspend, &tftp_server_process, (void *)tftp_server);

} /* tftp_server_init */
Exemplo n.º 2
0
/*
 * net_buffer_get_condition
 * @condition: Pointer where condition will be returned.
 * @suspend: Suspend needed to be populated.
 * @process: Pointer where process will be returned.
 * This function will return the condition to for networking buffers.
 */
void net_buffer_get_condition(CONDITION **condition, SUSPEND *suspend, NET_CONDITION_PROCESS **process)
{
    /* For networking buffers we will wait for data on networking buffer file descriptor. */
    fs_condition_get((FD)&net_buffers_fs, condition, suspend, &net_buffers_fs.fs_param, FS_BLOCK_READ);

    /* Set callback that is needed to be called when this condition is fulfilled. */
    *process = &net_buffer_condition_callback;

} /* net_buffer_get_condition */