Esempio n. 1
0
int
add_timer(htimer_t *tm, unsigned long expires)
{
	if (root) {
		if (root->node.key > expires)
			return -1;
		root = __container_of(insert(&root->node, &tm->node, expires));
	} else
		root = __container_of(make_node(&tm->node, expires));

	return 0;
}
Esempio n. 2
0
static
void client_link_info(struct rudp_peer *peer, struct rudp_link_info *info)
{
    struct rudp_client *client = __container_of(peer, client, peer);

    client->handler->link_info(client, info);
}
Esempio n. 3
0
static
void client_handle_data_packet(
    struct rudp_peer *peer,
    struct rudp_packet_chain *pc)
{
    struct rudp_client *client = __container_of(peer, client, peer);
    struct rudp_packet_data *header = &pc->packet->data;

    client->handler->handle_packet(
        client, header->header.command - RUDP_CMD_APP,
        header->data, pc->len - sizeof(header));
}
Esempio n. 4
0
static
void client_peer_dropped(struct rudp_peer *peer)
{
    struct rudp_client *client = __container_of(peer, client, peer);

    client->connected = 0;

    rudp_peer_deinit(&client->peer);

    rudp_endpoint_close(&client->endpoint);

    client->handler->server_lost(client);
}
Esempio n. 5
0
void
timer_thread(unsigned long now)
{
	htimer_t *tm;

	while ((tm = root)) {
		if (now < tm->node.key)
			break;
		root  = __container_of(delete_min(&tm->node));
		if (tm->expire)
			tm->expire(tm);
	}
}
Esempio n. 6
0
/*
  - socket watcher
     - endpoint packet reader
        - client packet handler <===
           - peer packet handler
 */
static
void client_handle_endpoint_packet(struct rudp_endpoint *endpoint,
                                   const struct sockaddr_storage *addr,
                                   struct rudp_packet_chain *pc)
{
    struct rudp_client *client = __container_of(endpoint, client, endpoint);

    rudp_log_printf(client->rudp, RUDP_LOG_INFO,
                    "Endpoint handling packet\n");

    rudp_error_t err = rudp_peer_incoming_packet(&client->peer, pc);
    if ( err == 0 && client->connected == 0 )
    {
        client->connected = 1;
        client->handler->connected(client);
    }
}
Esempio n. 7
0
void
del_timer(htimer_t *tm)
{
	root = __container_of(delete(&root->node, &tm->node));
}