Changeset 7719958 in mainline for uspace/srv/net/udp/udp.c


Ignore:
Timestamp:
2012-04-23T22:51:36Z (12 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6a3808e
Parents:
3293a94 (diff), 32fef47 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge mainline changes

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/udp/udp.c

    r3293a94 r7719958  
    11/*
    2  * Copyright (c) 2008 Lukas Mejdrech
     2 * Copyright (c) 2012 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3131 */
    3232
    33 /** @file
    34  * UDP module.
     33/**
     34 * @file UDP (User Datagram Protocol) service
    3535 */
    3636
    37 #ifndef NET_UDP_H_
    38 #define NET_UDP_H_
     37#include <async.h>
     38#include <errno.h>
     39#include <io/log.h>
     40#include <stdio.h>
     41#include <task.h>
    3942
    40 #include <async.h>
    41 #include <fibril_synch.h>
    42 #include <socket_core.h>
    43 #include <tl_common.h>
     43#include "udp_inet.h"
     44#include "sock.h"
    4445
    45 /** Type definition of the UDP global data.
    46  * @see udp_globals
     46#define NAME       "udp"
     47
     48static int udp_init(void)
     49{
     50        int rc;
     51
     52        log_msg(LVL_DEBUG, "udp_init()");
     53
     54        rc = udp_inet_init();
     55        if (rc != EOK) {
     56                log_msg(LVL_ERROR, "Failed connecting to internet service.");
     57                return ENOENT;
     58        }
     59
     60        rc = udp_sock_init();
     61        if (rc != EOK) {
     62                log_msg(LVL_ERROR, "Failed initializing socket service.");
     63                return ENOENT;
     64        }
     65
     66        return EOK;
     67}
     68
     69int main(int argc, char **argv)
     70{
     71        int rc;
     72
     73        printf(NAME ": UDP (User Datagram Protocol) service\n");
     74
     75        rc = log_init(NAME, LVL_WARN);
     76        if (rc != EOK) {
     77                printf(NAME ": Failed to initialize log.\n");
     78                return 1;
     79        }
     80
     81        rc = udp_init();
     82        if (rc != EOK)
     83                return 1;
     84
     85        printf(NAME ": Accepting connections.\n");
     86        task_retval(0);
     87        async_manager();
     88
     89        /* Not reached */
     90        return 0;
     91}
     92
     93/**
     94 * @}
    4795 */
    48 typedef struct udp_globals udp_globals_t;
    49 
    50 /** UDP global data. */
    51 struct udp_globals {
    52         /** Networking module session. */
    53         async_sess_t *net_sess;
    54         /** IP module session. */
    55         async_sess_t *ip_sess;
    56         /** ICMP module session. */
    57         async_sess_t *icmp_sess;
    58         /** Packet dimension. */
    59         packet_dimension_t packet_dimension;
    60         /** Indicates whether UDP checksum computing is enabled. */
    61         int checksum_computing;
    62         /** Indicates whether UDP autobnding on send is enabled. */
    63         int autobinding;
    64         /** Last used free port. */
    65         int last_used_port;
    66         /** Active sockets. */
    67         socket_ports_t sockets;
    68         /** Device packet dimensions. */
    69         packet_dimensions_t dimensions;
    70         /** Safety lock. */
    71         fibril_rwlock_t lock;
    72 };
    73 
    74 #endif
    75 
    76 /** @}
    77  */
Note: See TracChangeset for help on using the changeset viewer.