Changeset 8fb1bf82 in mainline for uspace/lib/net


Ignore:
Timestamp:
2010-11-25T13:42:50Z (15 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8df8415
Parents:
a93d79a (diff), eb667613 (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.

Location:
uspace/lib/net
Files:
2 added
45 edited
2 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/Makefile

    ra93d79a r8fb1bf82  
    3838        generic/packet_client.c \
    3939        generic/packet_remote.c \
    40         generic/socket_core.c \
     40        generic/protocol_map.c \
    4141        adt/module_map.c \
    4242        netif/netif_local.c \
    4343        netif/netif_remote.c \
    4444        nil/nil_remote.c \
     45        il/il_interface.c \
    4546        il/ip_remote.c \
    4647        il/ip_client.c \
     
    4849        tl/icmp_remote.c \
    4950        tl/icmp_client.c \
     51        tl/socket_core.c \
     52        tl/tl_interface.c \
    5053        tl/tl_common.c
    5154
  • uspace/lib/net/adt/module_map.c

    ra93d79a r8fb1bf82  
    3838#include <task.h>
    3939#include <unistd.h>
    40 #include <err.h>
     40#include <errno.h>
    4141
    4242#include <ipc/services.h>
     
    5959 *                      running.
    6060 * @param[in] connect_module The module connecting function.
    61  * @returns             EOK on success.
    62  * @returns             ENOMEM if there is not enough memory left.
     61 * @return              EOK on success.
     62 * @return              ENOMEM if there is not enough memory left.
    6363 */
    6464int
    65 add_module(module_ref *module, modules_ref modules, const char *name,
     65add_module(module_t **module, modules_t *modules, const char *name,
    6666    const char *filename, services_t service, task_id_t task_id,
    6767    connect_module_t connect_module)
    6868{
    69         ERROR_DECLARE;
     69        module_t *tmp_module;
     70        int rc;
    7071
    71         module_ref tmp_module;
    72 
    73         tmp_module = (module_ref) malloc(sizeof(module_t));
     72        tmp_module = (module_t *) malloc(sizeof(module_t));
    7473        if (!tmp_module)
    7574                return ENOMEM;
     
    8382        tmp_module->connect_module = connect_module;
    8483
    85         if (ERROR_OCCURRED(modules_add(modules, tmp_module->name, 0,
    86             tmp_module))) {
     84        rc = modules_add(modules, tmp_module->name, 0, tmp_module);
     85        if (rc != EOK) {
    8786                free(tmp_module);
    88                 return ERROR_CODE;
     87                return rc;
    8988        }
    9089        if (module)
     
    101100 * @param[in] modules   The module map.
    102101 * @param[in] name      The module name.
    103  * @returns             The running module found. It does not have to be
     102 * @return              The running module found. It does not have to be
    104103 *                      connected.
    105  * @returns             NULL if there is no such module.
     104 * @return              NULL if there is no such module.
    106105 */
    107 module_ref get_running_module(modules_ref modules, char *name)
     106module_t *get_running_module(modules_t *modules, char *name)
    108107{
    109         module_ref module;
     108        module_t *module;
    110109
    111110        module = modules_find(modules, name, 0);
     
    127126 *
    128127 * @param[in] fname     The module full or relative path filename.
    129  * @returns             The new module task identifier on success.
    130  * @returns             Zero if there is no such module.
     128 * @return              The new module task identifier on success.
     129 * @return              Zero if there is no such module.
    131130 */
    132131task_id_t spawn(const char *fname)
    133132{
    134         const char *argv[2];
    135         task_id_t res;
     133        task_id_t id;
     134        int rc;
    136135       
    137         argv[0] = fname;
    138         argv[1] = NULL;
    139         res = task_spawn(fname, argv, NULL);
     136        rc = task_spawnl(&id, fname, fname, NULL);
     137        if (rc != EOK)
     138                return 0;
    140139       
    141         return res;
     140        return id;
    142141}
    143142
  • uspace/lib/net/generic/generic.c

    ra93d79a r8fb1bf82  
    9292 * @param[out] address  The desired address.
    9393 * @param[out] data     The address data container.
    94  * @returns             EOK on success.
    95  * @returns             EBADMEM if the address parameter and/or the data
     94 * @return              EOK on success.
     95 * @return              EBADMEM if the address parameter and/or the data
    9696 *                      parameter is NULL.
    97  * @returns             Other error codes as defined for the specific service
     97 * @return              Other error codes as defined for the specific service
    9898 *                      message.
    9999 */
    100100int
    101101generic_get_addr_req(int phone, int message, device_id_t device_id,
    102     measured_string_ref *address, char ** data)
     102    measured_string_t **address, char ** data)
    103103{
    104104        aid_t message_id;
     
    138138int
    139139generic_packet_size_req_remote(int phone, int message, device_id_t device_id,
    140     packet_dimension_ref packet_dimension)
     140    packet_dimension_t *packet_dimension)
    141141{
    142142        if (!packet_dimension)
     
    223223 * @param[out] translation The translated values.
    224224 * @param[out] data     The translation data container.
    225  * @returns             EOK on success.
    226  * @returns             EINVAL if the configuration parameter is NULL.
    227  * @returns             EINVAL if the count parameter is zero.
    228  * @returns             EBADMEM if the translation or the data parameters are
     225 * @return              EOK on success.
     226 * @return              EINVAL if the configuration parameter is NULL.
     227 * @return              EINVAL if the count parameter is zero.
     228 * @return              EBADMEM if the translation or the data parameters are
    229229 *                      NULL.
    230  * @returns             Other error codes as defined for the specific service
     230 * @return              Other error codes as defined for the specific service
    231231 *                      message.
    232232 */
    233233int
    234234generic_translate_req(int phone, int message, device_id_t device_id,
    235     services_t service, measured_string_ref configuration, size_t count,
    236     measured_string_ref *translation, char **data)
     235    services_t service, measured_string_t *configuration, size_t count,
     236    measured_string_t **translation, char **data)
    237237{
    238238        aid_t message_id;
  • uspace/lib/net/generic/net_checksum.c

    ra93d79a r8fb1bf82  
    4848 *
    4949 * @param[in] sum       Computed checksum.
    50  * @returns             Compacted computed checksum to the 16 bits.
     50 * @return              Compacted computed checksum to the 16 bits.
    5151 */
    5252uint16_t compact_checksum(uint32_t sum)
     
    6666 * @param[in] data      Pointer to the beginning of data to process.
    6767 * @param[in] length    Length of the data in bytes.
    68  * @returns             The computed checksum of the length bytes of the data.
     68 * @return              The computed checksum of the length bytes of the data.
    6969 */
    7070uint32_t compute_checksum(uint32_t seed, uint8_t *data, size_t length)
     
    8888 * @param[in] data      Pointer to the beginning of data to process.
    8989 * @param[in] length    Length of the data in bits.
    90  * @returns             The computed CRC32 of the length bits of the data.
     90 * @return              The computed CRC32 of the length bits of the data.
    9191 */
    9292uint32_t compute_crc32_be(uint32_t seed, uint8_t * data, size_t length)
     
    142142 * @param[in] data      Pointer to the beginning of data to process.
    143143 * @param[in] length    Length of the data in bits.
    144  * @returns             The computed CRC32 of the length bits of the data.
     144 * @return              The computed CRC32 of the length bits of the data.
    145145 */
    146146uint32_t compute_crc32_le(uint32_t seed, uint8_t * data, size_t length)
     
    193193 *
    194194 * @param[in] checksum  The computed checksum.
    195  * @returns             The internet protocol header checksum.
    196  * @returns             0xFFFF if the computed checksum is zero.
     195 * @return              The internet protocol header checksum.
     196 * @return              0xFFFF if the computed checksum is zero.
    197197 */
    198198uint16_t flip_checksum(uint16_t checksum)
     
    211211 * @param[in] data      The header data.
    212212 * @param[in] length    The header length in bytes.
    213  * @returns             The internet protocol header checksum.
    214  * @returns             0xFFFF if the computed checksum is zero.
     213 * @return              The internet protocol header checksum.
     214 * @return              0xFFFF if the computed checksum is zero.
    215215 */
    216216uint16_t ip_checksum(uint8_t *data, size_t length)
  • uspace/lib/net/generic/net_remote.c

    ra93d79a r8fb1bf82  
    4949/** Connects to the networking module.
    5050 *
    51  * @returns             The networking module phone on success.
     51 * @return              The networking module phone on success.
    5252 */
    5353int net_connect_module(void)
     
    6363 * @see net_get_conf_req()
    6464 */
    65 void net_free_settings(measured_string_ref settings, char *data)
     65void net_free_settings(measured_string_t *settings, char *data)
    6666{
    6767        if (settings)
     
    8383 * @param[in] count     The configuration entries count.
    8484 * @param[in,out] data  The configuration and settings data.
    85  * @returns             EOK on success.
    86  * @returns             EINVAL if the configuration is NULL.
    87  * @returns             EINVAL if the count is zero.
    88  * @returns             Other error codes as defined for the
     85 * @return              EOK on success.
     86 * @return              EINVAL if the configuration is NULL.
     87 * @return              EINVAL if the count is zero.
     88 * @return              Other error codes as defined for the
    8989 *                      generic_translate_req() function.
    9090 */
    9191int
    92 net_get_conf_req(int net_phone, measured_string_ref *configuration,
     92net_get_conf_req(int net_phone, measured_string_t **configuration,
    9393    size_t count, char **data)
    9494{
     
    110110 * @param[in] count     The configuration entries count.
    111111 * @param[in,out] data  The configuration and settings data.
    112  * @returns             EOK on success.
    113  * @returns             EINVAL if the configuration is NULL.
    114  * @returns             EINVAL if the count is zero.
    115  * @returns             Other error codes as defined for the
     112 * @return              EOK on success.
     113 * @return              EINVAL if the configuration is NULL.
     114 * @return              EINVAL if the count is zero.
     115 * @return              Other error codes as defined for the
    116116 *                      generic_translate_req() function.
    117117 */
    118118int
    119119net_get_device_conf_req(int net_phone, device_id_t device_id,
    120     measured_string_ref *configuration, size_t count, char **data)
     120    measured_string_t **configuration, size_t count, char **data)
    121121{
    122122        return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF,
  • uspace/lib/net/generic/packet_client.c

    ra93d79a r8fb1bf82  
    5353 * @param[in] data      The data to be copied.
    5454 * @param[in] length    The length of the copied data.
    55  * @returns             EOK on success.
    56  * @returns             EINVAL if the packet is not valid.
    57  * @returns             ENOMEM if there is not enough memory left.
    58  */
    59 int packet_copy_data(packet_t packet, const void *data, size_t length)
     55 * @return              EOK on success.
     56 * @return              EINVAL if the packet is not valid.
     57 * @return              ENOMEM if there is not enough memory left.
     58 */
     59int packet_copy_data(packet_t *packet, const void *data, size_t length)
    6060{
    6161        if (!packet_is_valid(packet))
     
    7878 * @param[in] length    The space length to be allocated at the beginning of the
    7979 *                      packet content.
    80  * @returns             The pointer to the allocated memory.
    81  * @returns             NULL if there is not enough memory left.
    82  */
    83 void *packet_prefix(packet_t packet, size_t length)
     80 * @return              The pointer to the allocated memory.
     81 * @return              NULL if there is not enough memory left.
     82 */
     83void *packet_prefix(packet_t *packet, size_t length)
    8484{
    8585        if ((!packet_is_valid(packet)) ||
    86             (packet->data_start - sizeof(struct packet) -
     86            (packet->data_start - sizeof(packet_t) -
    8787            2 * (packet->dest_addr - packet->src_addr) < length)) {
    8888                return NULL;
     
    9999 * @param[in] length    The space length to be allocated at the end of the
    100100 *                       packet content.
    101  * @returns             The pointer to the allocated memory.
    102  * @returns             NULL if there is not enough memory left.
    103  */
    104 void *packet_suffix(packet_t packet, size_t length)
     101 * @return              The pointer to the allocated memory.
     102 * @return              NULL if there is not enough memory left.
     103 */
     104void *packet_suffix(packet_t *packet, size_t length)
    105105{
    106106        if ((!packet_is_valid(packet)) ||
     
    120120 * @param[in] suffix    The suffix length to be removed from the end of the
    121121 *                      packet content.
    122  * @returns             EOK on success.
    123  * @returns             EINVAL if the packet is not valid.
    124  * @returns             ENOMEM if there is not enough memory left.
    125  */
    126 int packet_trim(packet_t packet, size_t prefix, size_t suffix)
     122 * @return              EOK on success.
     123 * @return              EINVAL if the packet is not valid.
     124 * @return              ENOMEM if there is not enough memory left.
     125 */
     126int packet_trim(packet_t *packet, size_t prefix, size_t suffix)
    127127{
    128128        if (!packet_is_valid(packet))
     
    140140 *
    141141 * @param[in] packet    The packet.
    142  * @returns             The packet identifier.
    143  * @returns             Zero if the packet is not valid.
    144  */
    145 packet_id_t packet_get_id(const packet_t packet)
     142 * @return              The packet identifier.
     143 * @return              Zero if the packet is not valid.
     144 */
     145packet_id_t packet_get_id(const packet_t *packet)
    146146{
    147147        return packet_is_valid(packet) ? packet->packet_id : 0;
     
    153153 * @param[out] src      The source address. May be NULL if not desired.
    154154 * @param[out] dest     The destination address. May be NULL if not desired.
    155  * @returns             The stored addresses length.
    156  * @returns             Zero if the addresses are not present.
    157  * @returns             EINVAL if the packet is not valid.
    158  */
    159 int packet_get_addr(const packet_t packet, uint8_t **src, uint8_t **dest)
     155 * @return              The stored addresses length.
     156 * @return              Zero if the addresses are not present.
     157 * @return              EINVAL if the packet is not valid.
     158 */
     159int packet_get_addr(const packet_t *packet, uint8_t **src, uint8_t **dest)
    160160{
    161161        if (!packet_is_valid(packet))
     
    174174 *
    175175 * @param[in] packet    The packet.
    176  * @returns             The packet content length in bytes.
    177  * @returns             Zero if the packet is not valid.
    178  */
    179 size_t packet_get_data_length(const packet_t packet)
     176 * @return              The packet content length in bytes.
     177 * @return              Zero if the packet is not valid.
     178 */
     179size_t packet_get_data_length(const packet_t *packet)
    180180{
    181181        if (!packet_is_valid(packet))
     
    188188 *
    189189 * @param[in] packet    The packet.
    190  * @returns             The pointer to the beginning of the packet content.
    191  * @returns             NULL if the packet is not valid.
    192  */
    193 void *packet_get_data(const packet_t packet)
     190 * @return              The pointer to the beginning of the packet content.
     191 * @return              NULL if the packet is not valid.
     192 */
     193void *packet_get_data(const packet_t *packet)
    194194{
    195195        if (!packet_is_valid(packet))
     
    205205 * @param[in] dest      The new destination address. May be NULL.
    206206 * @param[in] addr_len  The addresses length.
    207  * @returns             EOK on success.
    208  * @returns             EINVAL if the packet is not valid.
    209  * @returns             ENOMEM if there is not enough memory left.
     207 * @return              EOK on success.
     208 * @return              EINVAL if the packet is not valid.
     209 * @return              ENOMEM if there is not enough memory left.
    210210 */
    211211int
    212 packet_set_addr(packet_t packet, const uint8_t *src, const uint8_t *dest,
     212packet_set_addr(packet_t *packet, const uint8_t *src, const uint8_t *dest,
    213213    size_t addr_len)
    214214{
     
    254254 * @param[in] phone     The packet server module phone.
    255255 * @param[in] packet    The original packet.
    256  * @returns             The packet copy.
    257  * @returns             NULL on error.
    258  */
    259 packet_t packet_get_copy(int phone, packet_t packet)
    260 {
    261         packet_t copy;
     256 * @return              The packet copy.
     257 * @return              NULL on error.
     258 */
     259packet_t *packet_get_copy(int phone, packet_t *packet)
     260{
     261        packet_t *copy;
    262262        uint8_t * src = NULL;
    263263        uint8_t * dest = NULL;
  • uspace/lib/net/generic/packet_remote.c

    ra93d79a r8fb1bf82  
    3838#include <async.h>
    3939#include <errno.h>
    40 #include <err.h>
    4140#include <ipc/ipc.h>
    4241#include <ipc/packet.h>
     
    6564 */
    6665static int
    67 packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size)
    68 {
    69         ERROR_DECLARE;
    70        
     66packet_return(int phone, packet_t **packet, packet_id_t packet_id, size_t size)
     67{
    7168        ipc_call_t answer;
    72         aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    73 
    74         *packet = (packet_t) as_get_mappable_page(size);
    75         if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size)) ||
    76             ERROR_OCCURRED(pm_add(*packet))) {
     69        aid_t message;
     70        int rc;
     71       
     72        message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     73
     74        *packet = (packet_t *) as_get_mappable_page(size);
     75        rc = async_share_in_start_0_0(phone, *packet, size);
     76        if (rc != EOK) {
    7777                munmap(*packet, size);
    7878                async_wait_for(message, NULL);
    79                 return ERROR_CODE;
     79                return rc;
     80        }
     81        rc = pm_add(*packet);
     82        if (rc != EOK) {
     83                munmap(*packet, size);
     84                async_wait_for(message, NULL);
     85                return rc;
    8086        }
    8187       
     
    94100 * @param[out] packet   The packet reference.
    95101 * @param[in] packet_id The packet identifier.
    96  * @returns             EOK on success.
    97  * @returns             EINVAL if the packet parameter is NULL.
    98  * @returns             Other error codes as defined for the NET_PACKET_GET_SIZE
     102 * @return              EOK on success.
     103 * @return              EINVAL if the packet parameter is NULL.
     104 * @return              Other error codes as defined for the NET_PACKET_GET_SIZE
    99105 *                      message.
    100  * @returns             Other error codes as defined for the packet_return()
     106 * @return              Other error codes as defined for the packet_return()
    101107 *                      function.
    102108 */
    103 int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
    104 {
    105         ERROR_DECLARE;
     109int packet_translate_remote(int phone, packet_t **packet, packet_id_t packet_id)
     110{
     111        int rc;
    106112       
    107113        if (!packet)
     
    112118                ipcarg_t size;
    113119               
    114                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE,
    115                     packet_id, &size));
    116                 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
     120                rc = async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id,
     121                    &size);
     122                if (rc != EOK)
     123                        return rc;
     124                rc = packet_return(phone, packet, packet_id, size);
     125                if (rc != EOK)
     126                        return rc;
    117127        }
    118128        if ((*packet)->next) {
    119                 packet_t next;
     129                packet_t *next;
    120130               
    121131                return packet_translate_remote(phone, &next, (*packet)->next);
     
    135145 * @param[in] max_content The maximal content length in bytes.
    136146 * @param[in] max_suffix The maximal suffix length in bytes.
    137  * @returns             The packet reference.
    138  * @returns             NULL on error.
    139  */
    140 packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
     147 * @return              The packet reference.
     148 * @return              NULL on error.
     149 */
     150packet_t *packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
    141151    size_t max_prefix, size_t max_suffix)
    142152{
    143         ERROR_DECLARE;
    144        
    145153        ipcarg_t packet_id;
    146154        ipcarg_t size;
    147        
    148         if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4,
    149             max_content, addr_len, max_prefix, max_suffix, &packet_id, &size)))
     155        int rc;
     156       
     157        rc = async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len,
     158            max_prefix, max_suffix, &packet_id, &size);
     159        if (rc != EOK)
    150160                return NULL;
    151161       
    152162       
    153         packet_t packet = pm_find(packet_id);
     163        packet_t *packet = pm_find(packet_id);
    154164        if (!packet) {
    155                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
    156                     size)))
     165                rc = packet_return(phone, &packet, packet_id, size);
     166                if (rc != EOK)
    157167                        return NULL;
    158168        }
     
    167177 * @param[in] phone     The packet server module phone.
    168178 * @param[in] content   The maximal content length in bytes.
    169  * @returns             The packet reference.
    170  * @returns             NULL on error.
    171  */
    172 packet_t packet_get_1_remote(int phone, size_t content)
    173 {
    174         ERROR_DECLARE;
    175        
     179 * @return              The packet reference.
     180 * @return              NULL on error.
     181 */
     182packet_t *packet_get_1_remote(int phone, size_t content)
     183{
    176184        ipcarg_t packet_id;
    177185        ipcarg_t size;
    178        
    179         if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,
    180             &packet_id, &size)))
     186        int rc;
     187       
     188        rc = async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id,
     189            &size);
     190        if (rc != EOK)
    181191                return NULL;
    182192       
    183         packet_t packet = pm_find(packet_id);
     193        packet_t *packet = pm_find(packet_id);
    184194        if (!packet) {
    185                 if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id,
    186                     size)))
     195                rc = packet_return(phone, &packet, packet_id, size);
     196                if (rc != EOK)
    187197                        return NULL;
    188198        }
  • uspace/lib/net/il/arp_remote.c

    ra93d79a r8fb1bf82  
    5252 *
    5353 * @param service       The ARP module service. Ignored parameter.
    54  * @returns             The ARP module phone on success.
     54 * @return              The ARP module phone on success.
    5555 */
    5656int arp_connect_module(services_t service)
     
    6565 *
    6666 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    67  * @returns             EOK on success.
     67 * @return              EOK on success.
    6868 */
    6969int arp_clean_cache_req(int arp_phone)
     
    7878 * @param[in] protocol  The requesting protocol service.
    7979 * @param[in] address   The protocol address to be cleared.
    80  * @returns             EOK on success.
    81  * @returns             ENOENT if the mapping is not found.
     80 * @return              EOK on success.
     81 * @return              ENOENT if the mapping is not found.
    8282 */
    8383int
    8484arp_clear_address_req(int arp_phone, device_id_t device_id, services_t protocol,
    85     measured_string_ref address)
     85    measured_string_t *address)
    8686{
    8787        aid_t message_id;
     
    100100 * @param[in] arp_phone The ARP module phone used for (semi)remote calls.
    101101 * @param[in] device_id The device identifier.
    102  * @returns             EOK on success.
    103  * @returns             ENOENT if the device is not found.
     102 * @return              EOK on success.
     103 * @return              ENOENT if the device is not found.
    104104 */
    105105int arp_clear_device_req(int arp_phone, device_id_t device_id)
     
    119119 * @param[in] netif     The underlying device network interface layer service.
    120120 * @param[in] address   The local requesting protocol address of the device.
    121  * @returns             EOK on success.
    122  * @returns             EEXIST if the device is already used.
    123  * @returns             ENOMEM if there is not enough memory left.
    124  * @returns             ENOENT if the network interface service is not known.
    125  * @returns             EREFUSED if the network interface service is not
     121 * @return              EOK on success.
     122 * @return              EEXIST if the device is already used.
     123 * @return              ENOMEM if there is not enough memory left.
     124 * @return              ENOENT if the network interface service is not known.
     125 * @return              EREFUSED if the network interface service is not
    126126 *                      responding.
    127  * @returns             Other error codes as defined for the
     127 * @return              Other error codes as defined for the
    128128 *                      nil_packet_get_size() function.
    129  * @returns             Other error codes as defined for the nil_get_addr()
     129 * @return              Other error codes as defined for the nil_get_addr()
    130130 *                      function.
    131  * @returns             Other error codes as defined for the
     131 * @return              Other error codes as defined for the
    132132 *                      nil_get_broadcast_addr() function.
    133133 */
    134134int arp_device_req(int arp_phone, device_id_t device_id, services_t protocol,
    135     services_t netif, measured_string_ref address)
     135    services_t netif, measured_string_t *address)
    136136{
    137137        aid_t message_id;
     
    157157 * @param[out] translation The translation of the local protocol address.
    158158 * @param[out] data     The allocated raw translation data container.
    159  * @returns             EOK on success.
    160  * @returns             EINVAL if the address parameter is NULL.
    161  * @returns             EBADMEM if the translation or the data parameters are
     159 * @return              EOK on success.
     160 * @return              EINVAL if the address parameter is NULL.
     161 * @return              EBADMEM if the translation or the data parameters are
    162162 *                      NULL.
    163  * @returns             ENOENT if the mapping is not found.
     163 * @return              ENOENT if the mapping is not found.
    164164 */
    165165int
    166166arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol,
    167     measured_string_ref address, measured_string_ref *translation, char **data)
     167    measured_string_t *address, measured_string_t **translation, char **data)
    168168{
    169169        return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id,
  • uspace/lib/net/il/ip_client.c

    ra93d79a r8fb1bf82  
    4848 *
    4949 * @param[in] packet    The packet.
    50  * @returns             The IP header length in bytes.
    51  * @returns             Zero if there is no IP header.
    52  */
    53 size_t ip_client_header_length(packet_t packet)
    54 {
    55         ip_header_ref header;
    56 
    57         header = (ip_header_ref) packet_get_data(packet);
     50 * @return              The IP header length in bytes.
     51 * @return              Zero if there is no IP header.
     52 */
     53size_t ip_client_header_length(packet_t *packet)
     54{
     55        ip_header_t *header;
     56
     57        header = (ip_header_t *) packet_get_data(packet);
    5858        if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t)))
    5959                return 0;
     
    7272 * @param[out] header   The constructed IPv4 pseudo header.
    7373 * @param[out] headerlen The length of the IP pseudo header in bytes.
    74  * @returns             EOK on success.
    75  * @returns             EBADMEM if the header and/or the headerlen parameter is
     74 * @return              EOK on success.
     75 * @return              EBADMEM if the header and/or the headerlen parameter is
    7676 *                      NULL.
    77  * @returns             EINVAL if the source address and/or the destination
     77 * @return              EINVAL if the source address and/or the destination
    7878 *                      address parameter is NULL.
    79  * @returns             EINVAL if the source address length is less than struct
     79 * @return              EINVAL if the source address length is less than struct
    8080 *                      sockaddr length.
    81  * @returns             EINVAL if the source address length differs from the
     81 * @return              EINVAL if the source address length differs from the
    8282 *                      destination address length.
    83  * @returns             EINVAL if the source address family differs from the
     83 * @return              EINVAL if the source address family differs from the
    8484 *                      destination family.
    85  * @returns             EAFNOSUPPORT if the address family is not supported.
    86  * @returns             ENOMEM if there is not enough memory left.
     85 * @return              EAFNOSUPPORT if the address family is not supported.
     86 * @return              ENOMEM if there is not enough memory left.
    8787 */
    8888int
     
    9191    size_t data_length, void **header, size_t *headerlen)
    9292{
    93         ipv4_pseudo_header_ref header_in;
     93        ipv4_pseudo_header_t *header_in;
    9494        struct sockaddr_in *address_in;
    9595
     
    109109               
    110110                *headerlen = sizeof(*header_in);
    111                 header_in = (ipv4_pseudo_header_ref) malloc(*headerlen);
     111                header_in = (ipv4_pseudo_header_t *) malloc(*headerlen);
    112112                if (!header_in)
    113113                        return ENOMEM;
     
    148148 *                      disabled.
    149149 * @param[in] ipopt_length The prefixed IP options length in bytes.
    150  * @returns             EOK on success.
    151  * @returns             ENOMEM if there is not enough memory left in the packet.
    152  */
    153 int
    154 ip_client_prepare_packet(packet_t packet, ip_protocol_t protocol, ip_ttl_t ttl,
     150 * @return              EOK on success.
     151 * @return              ENOMEM if there is not enough memory left in the packet.
     152 */
     153int
     154ip_client_prepare_packet(packet_t *packet, ip_protocol_t protocol, ip_ttl_t ttl,
    155155    ip_tos_t tos, int dont_fragment, size_t ipopt_length)
    156156{
    157         ip_header_ref header;
     157        ip_header_t *header;
    158158        uint8_t *data;
    159159        size_t padding;
     
    177177
    178178        // set the header
    179         header = (ip_header_ref) data;
     179        header = (ip_header_t *) data;
    180180        header->header_length = IP_COMPUTE_HEADER_LENGTH(sizeof(ip_header_t) +
    181181            ipopt_length);
     
    203203 * @param[out] ipopt_length The IP options length in bytes. May be NULL if not
    204204 *                      desired.
    205  * @returns             The prefixed IP header length in bytes on success.
    206  * @returns             ENOMEM if the packet is too short to contain the IP
     205 * @return              The prefixed IP header length in bytes on success.
     206 * @return              ENOMEM if the packet is too short to contain the IP
    207207 *                      header.
    208208 */
    209209int
    210 ip_client_process_packet(packet_t packet, ip_protocol_t *protocol,
     210ip_client_process_packet(packet_t *packet, ip_protocol_t *protocol,
    211211    ip_ttl_t *ttl, ip_tos_t *tos, int *dont_fragment, size_t *ipopt_length)
    212212{
    213         ip_header_ref header;
    214 
    215         header = (ip_header_ref) packet_get_data(packet);
     213        ip_header_t *header;
     214
     215        header = (ip_header_t *) packet_get_data(packet);
    216216        if (!header || (packet_get_data_length(packet) < sizeof(ip_header_t)))
    217217                return ENOMEM;
     
    238238 * @param[in] headerlen The length of the IP pseudo header in bytes.
    239239 * @param[in] data_length The data length to be set.
    240  * @returns             EOK on success.
    241  * @returns             EBADMEM if the header parameter is NULL.
    242  * @returns             EINVAL if the headerlen parameter is not IPv4 pseudo
     240 * @return              EOK on success.
     241 * @return              EBADMEM if the header parameter is NULL.
     242 * @return              EINVAL if the headerlen parameter is not IPv4 pseudo
    243243 *                      header length.
    244244 */
     
    247247    size_t data_length)
    248248{
    249         ipv4_pseudo_header_ref header_in;
     249        ipv4_pseudo_header_t *header_in;
    250250
    251251        if (!header)
     
    253253
    254254        if (headerlen == sizeof(ipv4_pseudo_header_t)) {
    255                 header_in = (ipv4_pseudo_header_ref) header;
     255                header_in = (ipv4_pseudo_header_t *) header;
    256256                header_in->data_length = htons(data_length);
    257257                return EOK;
  • uspace/lib/net/il/ip_remote.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup ip
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    5757 * The target network is routed using this device.
    5858 *
    59  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    60  * @param[in] device_id The device identifier.
    61  * @param[in] address   The target network address.
    62  * @param[in] netmask   The target network mask.
    63  * @param[in] gateway   The target network gateway. Not used if zero.
    64  *
     59 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     60 * @param[in] device_id The device identifier.
     61 * @param[in] address   The target network address.
     62 * @param[in] netmask   The target network mask.
     63 * @param[in] gateway   The target network gateway. Not used if zero.
    6564 */
    6665int ip_add_route_req_remote(int ip_phone, device_id_t device_id,
     
    7271}
    7372
     73/** Creates bidirectional connection with the ip module service and registers
     74 * the message receiver.
     75 *
     76 * @param[in] service   The IP module service.
     77 * @param[in] protocol  The transport layer protocol.
     78 * @param[in] me        The requesting module service.
     79 * @param[in] receiver  The message receiver. Used for remote connection.
     80 * @return              The phone of the needed service.
     81 * @return              EOK on success.
     82 * @return              Other error codes as defined for the bind_service()
     83 *                      function.
     84 */
    7485int ip_bind_service(services_t service, int protocol, services_t me,
    7586    async_client_conn_t receiver)
     
    7990}
    8091
     92/** Connects to the IP module.
     93 *
     94 * @param service       The IP module service. Ignored parameter.
     95 * @return              The IP module phone on success.
     96 */
    8197int ip_connect_module(services_t service)
    8298{
     
    89105 * If the device uses ARP registers also the new ARP device.
    90106 *
    91  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    92  * @param[in] device_id The new device identifier.
    93  * @param[in] netif     The underlying device network interface layer service.
    94  *
    95  * @return EOK on success.
    96  * @return ENOMEM if there is not enough memory left.
    97  * @return EINVAL if the device configuration is invalid.
    98  * @return ENOTSUP if the device uses IPv6.
    99  * @return ENOTSUP if the device uses DHCP.
    100  * @return Other error codes as defined for the net_get_device_conf_req()
    101  *         function.
    102  * @return Other error codes as defined for the arp_device_req() function.
    103  *
     107 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     108 * @param[in] device_id The new device identifier.
     109 * @param[in] netif     The underlying device network interface layer service.
     110 * @return              EOK on success.
     111 * @return              ENOMEM if there is not enough memory left.
     112 * @return              EINVAL if the device configuration is invalid.
     113 * @return              ENOTSUP if the device uses IPv6.
     114 * @return              ENOTSUP if the device uses DHCP.
     115 * @return              Other error codes as defined for the
     116 *                      net_get_device_conf_req() function.
     117 * @return              Other error codes as defined for the arp_device_req()
     118 *                      function.
    104119 */
    105120int ip_device_req_remote(int ip_phone, device_id_t device_id,
     
    110125}
    111126
    112 /** Return the device identifier and the IP pseudo header based on the destination address.
    113  *
    114  * @param[in]  ip_phone    The IP module phone used for (semi)remote calls.
    115  * @param[in]  protocol    The transport protocol.
    116  * @param[in]  destination The destination address.
    117  * @param[in]  addrlen     The destination address length.
    118  * @param[out] device_id   The device identifier.
    119  * @param[out] header      The constructed IP pseudo header.
    120  * @param[out] headerlen   The IP pseudo header length.
     127/** Return the device identifier and the IP pseudo header based on the
     128 * destination address.
     129 *
     130 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     131 * @param[in] protocol  The transport protocol.
     132 * @param[in] destination The destination address.
     133 * @param[in] addrlen   The destination address length.
     134 * @param[out] device_id The device identifier.
     135 * @param[out] header   The constructed IP pseudo header.
     136 * @param[out] headerlen The IP pseudo header length.
    121137 *
    122138 */
     
    125141    device_id_t *device_id, void **header, size_t *headerlen)
    126142{
    127         if ((!destination) || (addrlen == 0))
     143        if (!destination || (addrlen == 0))
    128144                return EINVAL;
    129145       
    130         if ((!device_id) || (!header) || (!headerlen))
     146        if (!device_id || !header || !headerlen)
    131147                return EBADMEM;
    132148       
     
    137153            (ipcarg_t) protocol, &answer);
    138154       
    139         if ((async_data_write_start(ip_phone, destination, addrlen) == EOK)
    140             && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK)
    141             && (*headerlen > 0)) {
     155        if ((async_data_write_start(ip_phone, destination, addrlen) == EOK) &&
     156            (async_data_read_start(ip_phone, headerlen,
     157            sizeof(*headerlen)) == EOK) && (*headerlen > 0)) {
    142158                *header = malloc(*headerlen);
    143159                if (*header) {
    144                         if (async_data_read_start(ip_phone, *header, *headerlen) != EOK)
     160                        if (async_data_read_start(ip_phone, *header,
     161                            *headerlen) != EOK)
    145162                                free(*header);
    146163                }
     
    150167        async_wait_for(message_id, &result);
    151168       
    152         if ((result != EOK) && (*header))
     169        if ((result != EOK) && *header)
    153170                free(*header);
    154171        else
     
    160177/** Return the device packet dimension for sending.
    161178 *
    162  * @param[in]  ip_phone         The IP module phone used for (semi)remote calls.
    163  * @param[in]  device_id        The device identifier.
     179 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     180 * @param[in] device_id The device identifier.
    164181 * @param[out] packet_dimension The packet dimension.
    165  *
    166  * @return EOK on success.
    167  * @return ENOENT if there is no such device.
    168  * @return Other error codes as defined for the
    169  *         generic_packet_size_req_remote() function.
    170  *
     182 * @return              EOK on success.
     183 * @return              ENOENT if there is no such device.
     184 * @return              Other error codes as defined for the
     185 *                      generic_packet_size_req_remote() function.
    171186 */
    172187int ip_packet_size_req_remote(int ip_phone, device_id_t device_id,
    173     packet_dimension_ref packet_dimension)
    174 {
    175         return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id,
    176             packet_dimension);
     188    packet_dimension_t *packet_dimension)
     189{
     190        return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE,
     191            device_id, packet_dimension);
    177192}
    178193
    179194/** Notify the IP module about the received error notification packet.
    180195 *
    181  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    182  * @param[in] device_id The device identifier.
    183  * @param[in] packet    The received packet or the received packet queue.
    184  * @param[in] target    The target internetwork module service to be
    185  *                      delivered to.
    186  * @param[in] error     The packet error reporting service. Prefixes the
    187  *                      received packet.
    188  *
    189  * @return EOK on success.
    190  *
     196 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     197 * @param[in] device_id The device identifier.
     198 * @param[in] packet    The received packet or the received packet queue.
     199 * @param[in] target    The target internetwork module service to be
     200 *                      delivered to.
     201 * @param[in] error     The packet error reporting service. Prefixes the
     202 *                      received packet.
     203 * @return              EOK on success.
    191204 */
    192205int ip_received_error_msg_remote(int ip_phone, device_id_t device_id,
    193     packet_t packet, services_t target, services_t error)
     206    packet_t *packet, services_t target, services_t error)
    194207{
    195208        return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
     
    201214 * The packets may get fragmented if needed.
    202215 *
    203  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    204  * @param[in] device_id The device identifier.
    205  * @param[in] packet    The packet fragments as a packet queue. All the
    206  *                      packets have to have the same destination address.
    207  * @param[in] sender    The sending module service.
    208  * @param[in] error     The packet error reporting service. Prefixes the
    209  *                      received packet.
    210  *
    211  * @return EOK on success.
    212  * @return Other error codes as defined for the generic_send_msg() function.
    213  *
    214  */
    215 int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet,
     216 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     217 * @param[in] device_id The device identifier.
     218 * @param[in] packet    The packet fragments as a packet queue. All the
     219 *                      packets have to have the same destination address.
     220 * @param[in] sender    The sending module service.
     221 * @param[in] error     The packet error reporting service. Prefixes the
     222 *                      received packet.
     223 * @return              EOK on success.
     224 * @return              Other error codes as defined for the generic_send_msg()
     225 *                      function.
     226 */
     227int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t *packet,
    216228    services_t sender, services_t error)
    217229{
     
    224236 * This gateway is used if no other route is found.
    225237 *
    226  * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
    227  * @param[in] device_id The device identifier.
    228  * @param[in] gateway   The default gateway.
    229  *
     238 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     239 * @param[in] device_id The device identifier.
     240 * @param[in] gateway   The default gateway.
    230241 */
    231242int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id,
  • uspace/lib/net/include/adt/module_map.h

    ra93d79a r8fb1bf82  
    4848typedef struct module_struct module_t;
    4949
    50 /** Type definition of the module structure pointer.
    51  * @see module_struct
    52  */
    53 typedef module_t *module_ref;
    54 
    5550/** Module map.
    5651 * Sorted by module names.
     
    7772};
    7873
    79 extern int add_module(module_ref *, modules_ref, const char *, const char *,
     74extern int add_module(module_t **, modules_t *, const char *, const char *,
    8075    services_t, task_id_t, connect_module_t *);
    81 extern module_ref get_running_module(modules_ref, char *);
     76extern module_t *get_running_module(modules_t *, char *);
    8277extern task_id_t spawn(const char *);
    8378
  • uspace/lib/net/include/arp_interface.h

    ra93d79a r8fb1bf82  
    4848
    4949extern int arp_device_req(int, device_id_t, services_t, services_t,
    50     measured_string_ref);
    51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_ref,
    52     measured_string_ref *, char **);
     50    measured_string_t *);
     51extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *,
     52    measured_string_t **, char **);
    5353extern int arp_clear_device_req(int, device_id_t);
    5454extern int arp_clear_address_req(int, device_id_t, services_t,
    55     measured_string_ref);
     55    measured_string_t *);
    5656extern int arp_clean_cache_req(int);
    5757extern int arp_connect_module(services_t);
  • uspace/lib/net/include/ethernet_lsap.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup eth
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Link service access point identifiers.
     34 * Link service access point identifiers.
    3535 */
    3636
    37 #ifndef __NET_ETHERNET_LSAP_H__
    38 #define __NET_ETHERNET_LSAP_H__
     37#ifndef LIBNET_ETHERNET_LSAP_H_
     38#define LIBNET_ETHERNET_LSAP_H_
    3939
    4040#include <sys/types.h>
    4141
    42 /** Ethernet LSAP type definition.
    43  */
    44 typedef uint8_t eth_lsap_t;
     42/** Ethernet LSAP type definition. */
     43typedef uint8_t eth_lsap_t;
    4544
    46 /** @name Ethernet LSAP values definitions
    47  */
     45/** @name Ethernet LSAP values definitions */
    4846/*@{*/
    4947
    50 /** Null LSAP LSAP identifier.
    51  */
     48/** Null LSAP LSAP identifier. */
    5249#define ETH_LSAP_NULL   0x00
    53 /** Individual LLC Sublayer Management Function LSAP identifier.
    54  */
    55 #define ETH_LSAP_ISLMF  0x02
    56 /** Group LLC Sublayer Management Function LSAP identifier.
    57  */
    58 #define ETH_LSAP_GSLMI  0x03
    59 /** IBM SNA Path Control (individual) LSAP identifier.
    60  */
    61 #define ETH_LSAP_ISNA   0x04
    62 /** IBM SNA Path Control (group) LSAP identifier.
    63  */
    64 #define ETH_LSAP_GSNA   0x05
    65 /** ARPANET Internet Protocol (IP) LSAP identifier.
    66  */
     50/** ARPANET Internet Protocol (IP) LSAP identifier. */
    6751#define ETH_LSAP_IP     0x06
    68 /** SNA LSAP identifier.
    69  */
    70 #define ETH_LSAP_SNA    0x08
    71 /** SNA LSAP identifier.
    72  */
    73 #define ETH_LSAP_SNA2   0x0C
    74 /** PROWAY (IEC955) Network Management &Initialization LSAP identifier.
    75  */
    76 #define ETH_LSAP_PROWAY_NMI     0x0E
    77 /** Texas Instruments LSAP identifier.
    78  */
    79 #define ETH_LSAP_TI     0x18
    80 /** IEEE 802.1 Bridge Spanning Tree Protocol LSAP identifier.
    81  */
    82 #define ETH_LSAP_BRIDGE 0x42
    83 /** EIA RS-511 Manufacturing Message Service LSAP identifier.
    84  */
    85 #define ETH_LSAP_EIS    0x4E
    86 /** ISO 8208 (X.25 over IEEE 802.2 Type 2 LLC) LSAP identifier.
    87  */
    88 #define ETH_LSAP_ISO8208        0x7E
    89 /** Xerox Network Systems (XNS) LSAP identifier.
    90  */
    91 #define ETH_LSAP_XNS    0x80
    92 /** Nestar LSAP identifier.
    93  */
    94 #define ETH_LSAP_NESTAR 0x86
    95 /** PROWAY (IEC 955) Active Station List Maintenance LSAP identifier.
    96  */
    97 #define ETH_LSAP_PROWAY_ASLM    0x8E
    98 /** ARPANET Address Resolution Protocol (ARP) LSAP identifier.
    99  */
     52/** ARPANET Address Resolution Protocol (ARP) LSAP identifier. */
    10053#define ETH_LSAP_ARP    0x98
    101 /** Banyan VINES LSAP identifier.
    102  */
    103 #define ETH_LSAP_VINES  0xBC
    104 /** SubNetwork Access Protocol (SNAP) LSAP identifier.
    105  */
     54/** SubNetwork Access Protocol (SNAP) LSAP identifier. */
    10655#define ETH_LSAP_SNAP   0xAA
    107 /** Novell NetWare LSAP identifier.
    108  */
    109 #define ETH_LSAP_NETWARE        0xE0
    110 /** IBM NetBIOS LSAP identifier.
    111  */
    112 #define ETH_LSAP_NETBIOS        0xF0
    113 /** IBM LAN Management (individual) LSAP identifier.
    114  */
    115 #define ETH_LSAP_ILAN   0xF4
    116 /** IBM LAN Management (group) LSAP identifier.
    117  */
    118 #define ETH_LSAP_GLAN   0xF5
    119 /** IBM Remote Program Load (RPL) LSAP identifier.
    120  */
    121 #define ETH_LSAP_RPL    0xF8
    122 /** Ungermann-Bass LSAP identifier.
    123  */
    124 #define ETH_LSAP_UB     0xFA
    125 /** ISO Network Layer Protocol LSAP identifier.
    126  */
    127 #define ETH_LSAP_ISONLP 0xFE
    128 /** Global LSAP LSAP identifier.
    129  */
     56/** Global LSAP LSAP identifier. */
    13057#define ETH_LSAP_GLSAP  0xFF
    13158
  • uspace/lib/net/include/ethernet_protocols.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup eth
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Ethernet protocol numbers according to the on-line IANA - Ethernet numbers - <http://www.iana.org/assignments/ethernet-numbers>, cited January 17 2009.
     34 * Ethernet protocol numbers according to the on-line IANA - Ethernet numbers
     35 * http://www.iana.org/assignments/ethernet-numbers
     36 * cited January 17 2009.
    3537 */
    3638
    37 #ifndef __NET_ETHERNET_PROTOCOLS_H__
    38 #define __NET_ETHERNET_PROTOCOLS_H__
     39#ifndef LIBNET_ETHERNET_PROTOCOLS_H_
     40#define LIBNET_ETHERNET_PROTOCOLS_H_
    3941
    4042#include <sys/types.h>
    4143
    42 /** Ethernet protocol type definition.
    43  */
    44 typedef uint16_t        eth_type_t;
     44/** Ethernet protocol type definition. */
     45typedef uint16_t eth_type_t;
    4546
    46 /** @name Ethernet protocols definitions
    47  */
     47/** @name Ethernet protocols definitions */
    4848/*@{*/
    4949
    5050/** Ethernet minimal protocol number.
    51  *  According to the IEEE 802.3 specification.
     51 * According to the IEEE 802.3 specification.
    5252 */
    53 #define ETH_MIN_PROTO   0x0600 /*1536*/
     53#define ETH_MIN_PROTO           0x0600 /* 1536 */
    5454
    55 /** Ethernet loopback packet protocol type.
    56  */
    57 #define ETH_P_LOOP              0x0060
    58 
    59 /** XEROX PUP (see 0A00) ethernet protocol type.
    60  */
    61 #define ETH_P_PUP               0x0200
    62 
    63 /** PUP Addr Trans (see 0A01) ethernet protocol type.
    64  */
    65 #define ETH_P_PUPAT             0x0201
    66 
    67 /** Nixdorf ethernet protocol type.
    68  */
    69 #define ETH_P_Nixdorf           0x0400
    70 
    71 /** XEROX NS IDP ethernet protocol type.
    72  */
    73 #define ETH_P_XEROX_NS_IDP              0x0600
    74 
    75 /** DLOG ethernet protocol type.
    76  */
    77 #define ETH_P_DLOG              0x0660
    78 
    79 /** DLOG ethernet protocol type.
    80  */
    81 #define ETH_P_DLOG2             0x0661
    82 
    83 /** Internet IP (IPv4) ethernet protocol type.
    84  */
     55/** Internet IP (IPv4) ethernet protocol type. */
    8556#define ETH_P_IP                0x0800
    8657
    87 /** X.75 Internet ethernet protocol type.
    88  */
    89 #define ETH_P_X_75              0x0801
    90 
    91 /** NBS Internet ethernet protocol type.
    92  */
    93 #define ETH_P_NBS               0x0802
    94 
    95 /** ECMA Internet ethernet protocol type.
    96  */
    97 #define ETH_P_ECMA              0x0803
    98 
    99 /** Chaosnet ethernet protocol type.
    100  */
    101 #define ETH_P_Chaosnet          0x0804
    102 
    103 /** X.25 Level 3 ethernet protocol type.
    104  */
    105 #define ETH_P_X25               0x0805
    106 
    107 /** ARP ethernet protocol type.
    108  */
     58/** ARP ethernet protocol type. */
    10959#define ETH_P_ARP               0x0806
    110 
    111 /** XNS Compatability ethernet protocol type.
    112  */
    113 #define ETH_P_XNS_Compatability         0x0807
    114 
    115 /** Frame Relay ARP ethernet protocol type.
    116  */
    117 #define ETH_P_Frame_Relay_ARP           0x0808
    118 
    119 /** Symbolics Private ethernet protocol type.
    120  */
    121 #define ETH_P_Symbolics_Private         0x081C
    122 
    123 /** Xyplex ethernet protocol type.
    124  */
    125 #define ETH_P_Xyplex_MIN                0x0888
    126 
    127 /** Xyplex ethernet protocol type.
    128  */
    129 #define ETH_P_Xyplex_MAX                0x088A
    130 
    131 /** Ungermann-Bass net debugr ethernet protocol type.
    132  */
    133 #define ETH_P_Ungermann_Bass_net_debugr         0x0900
    134 
    135 /** Xerox IEEE802.3 PUP ethernet protocol type.
    136  */
    137 #define ETH_P_IEEEPUP           0x0A00
    138 
    139 /** PUP Addr Trans ethernet protocol type.
    140  */
    141 #define ETH_P_IEEEPUPAT         0x0A01
    142 
    143 /** Banyan VINES ethernet protocol type.
    144  */
    145 #define ETH_P_Banyan_VINES              0x0BAD
    146 
    147 /** VINES Loopback ethernet protocol type.
    148  */
    149 #define ETH_P_VINES_Loopback            0x0BAE
    150 
    151 /** VINES Echo ethernet protocol type.
    152  */
    153 #define ETH_P_VINES_Echo                0x0BAF
    154 
    155 /** Berkeley Trailer nego ethernet protocol type.
    156  */
    157 #define ETH_P_Berkeley_Trailer_nego             0x1000
    158 
    159 /** Berkeley Trailer encap/IP ethernet protocol type.
    160  */
    161 #define ETH_P_Berkeley_Trailer_encapIP_MIN              0x1001
    162 
    163 /** Berkeley Trailer encap/IP ethernet protocol type.
    164  */
    165 #define ETH_P_Berkeley_Trailer_encapIP_MAX              0x100F
    166 
    167 /** Valid Systems ethernet protocol type.
    168  */
    169 #define ETH_P_Valid_Systems             0x1600
    170 
    171 /** PCS Basic Block Protocol ethernet protocol type.
    172  */
    173 #define ETH_P_PCS_Basic_Block_Protocol          0x4242
    174 
    175 /** BBN Simnet ethernet protocol type.
    176  */
    177 #define ETH_P_BBN_Simnet                0x5208
    178 
    179 /** DEC Unassigned (Exp.) ethernet protocol type.
    180  */
    181 #define ETH_P_DEC               0x6000
    182 
    183 /** DEC MOP Dump/Load ethernet protocol type.
    184  */
    185 #define ETH_P_DNA_DL            0x6001
    186 
    187 /** DEC MOP Remote Console ethernet protocol type.
    188  */
    189 #define ETH_P_DNA_RC            0x6002
    190 
    191 /** DEC DECNET Phase IV Route ethernet protocol type.
    192  */
    193 #define ETH_P_DNA_RT            0x6003
    194 
    195 /** DEC LAT ethernet protocol type.
    196  */
    197 #define ETH_P_LAT               0x6004
    198 
    199 /** DEC Diagnostic Protocol ethernet protocol type.
    200  */
    201 #define ETH_P_DIAG              0x6005
    202 
    203 /** DEC Customer Protocol ethernet protocol type.
    204  */
    205 #define ETH_P_CUST              0x6006
    206 
    207 /** DEC LAVC, SCA ethernet protocol type.
    208  */
    209 #define ETH_P_SCA               0x6007
    210 
    211 /** DEC Unassigned ethernet protocol type.
    212  */
    213 #define ETH_P_DEC_Unassigned_MIN                0x6008
    214 
    215 /** DEC Unassigned ethernet protocol type.
    216  */
    217 #define ETH_P_DEC_Unassigned_MAX                0x6009
    218 
    219 /** Com Corporation ethernet protocol type.
    220  */
    221 #define ETH_P_Com_Corporation_MIN               0x6010
    222 
    223 /** Com Corporation ethernet protocol type.
    224  */
    225 #define ETH_P_Com_Corporation_MAX               0x6014
    226 
    227 /** Trans Ether Bridging ethernet protocol type.
    228  */
    229 #define ETH_P_Trans_Ether_Bridging              0x6558
    230 
    231 /** Raw Frame Relay ethernet protocol type.
    232  */
    233 #define ETH_P_Raw_Frame_Relay           0x6559
    234 
    235 /** Ungermann-Bass download ethernet protocol type.
    236  */
    237 #define ETH_P_Ungermann_Bass_download           0x7000
    238 
    239 /** Ungermann-Bass dia/loop ethernet protocol type.
    240  */
    241 #define ETH_P_Ungermann_Bass_dialoop            0x7002
    242 
    243 /** LRT ethernet protocol type.
    244  */
    245 #define ETH_P_LRT_MIN           0x7020
    246 
    247 /** LRT ethernet protocol type.
    248  */
    249 #define ETH_P_LRT_MAX           0x7029
    250 
    251 /** Proteon ethernet protocol type.
    252  */
    253 #define ETH_P_Proteon           0x7030
    254 
    255 /** Cabletron ethernet protocol type.
    256  */
    257 #define ETH_P_Cabletron         0x7034
    258 
    259 /** Cronus VLN ethernet protocol type.
    260  */
    261 #define ETH_P_Cronus_VLN                0x8003
    262 
    263 /** Cronus Direct ethernet protocol type.
    264  */
    265 #define ETH_P_Cronus_Direct             0x8004
    266 
    267 /** HP Probe ethernet protocol type.
    268  */
    269 #define ETH_P_HP_Probe          0x8005
    270 
    271 /** Nestar ethernet protocol type.
    272  */
    273 #define ETH_P_Nestar            0x8006
    274 
    275 /** AT&T ethernet protocol type.
    276  */
    277 #define ETH_P_AT_T              0x8008
    278 
    279 /** Excelan ethernet protocol type.
    280  */
    281 #define ETH_P_Excelan           0x8010
    282 
    283 /** SGI diagnostics ethernet protocol type.
    284  */
    285 #define ETH_P_SGI_diagnostics           0x8013
    286 
    287 /** SGI network games ethernet protocol type.
    288  */
    289 #define ETH_P_SGI_network_games         0x8014
    290 
    291 /** SGI reserved ethernet protocol type.
    292  */
    293 #define ETH_P_SGI_reserved              0x8015
    294 
    295 /** SGI bounce server ethernet protocol type.
    296  */
    297 #define ETH_P_SGI_bounce_server         0x8016
    298 
    299 /** Apollo Domain ethernet protocol type.
    300  */
    301 #define ETH_P_Apollo_Domain             0x8019
    302 
    303 /** Tymshare ethernet protocol type.
    304  */
    305 #define ETH_P_Tymshare          0x802E
    306 
    307 /** Tigan, Inc. ethernet protocol type.
    308  */
    309 #define ETH_P_Tigan             0x802F
    310 
    311 /** Reverse ARP ethernet protocol type.
    312  */
    313 #define ETH_P_RARP              0x8035
    314 
    315 /** Aeonic Systems ethernet protocol type.
    316  */
    317 #define ETH_P_Aeonic_Systems            0x8036
    318 
    319 /** DEC LANBridge ethernet protocol type.
    320  */
    321 #define ETH_P_DEC_LANBridge             0x8038
    322 
    323 /** DEC Unassigned ethernet protocol type.
    324  */
    325 #define ETH_P_DEC_Unassigned_MIN1               0x8039
    326 
    327 /** DEC Unassigned ethernet protocol type.
    328  */
    329 #define ETH_P_DEC_Unassigned_MAX2               0x803C
    330 
    331 /** DEC Ethernet Encryption ethernet protocol type.
    332  */
    333 #define ETH_P_DEC_Ethernet_Encryption           0x803D
    334 
    335 /** DEC Unassigned ethernet protocol type.
    336  */
    337 #define ETH_P_DEC_Unassigned            0x803E
    338 
    339 /** DEC LAN Traffic Monitor ethernet protocol type.
    340  */
    341 #define ETH_P_DEC_LAN_Traffic_Monitor           0x803F
    342 
    343 /** DEC Unassigned ethernet protocol type.
    344  */
    345 #define ETH_P_DEC_Unassigned_MIN3               0x8040
    346 
    347 /** DEC Unassigned ethernet protocol type.
    348  */
    349 #define ETH_P_DEC_Unassigned_MAX3               0x8042
    350 
    351 /** Planning Research Corp. ethernet protocol type.
    352  */
    353 #define ETH_P_Planning_Research_Corp            0x8044
    354 
    355 /** AT&T ethernet protocol type.
    356  */
    357 #define ETH_P_AT_T2             0x8046
    358 
    359 /** AT&T ethernet protocol type.
    360  */
    361 #define ETH_P_AT_T3             0x8047
    362 
    363 /** ExperData ethernet protocol type.
    364  */
    365 #define ETH_P_ExperData         0x8049
    366 
    367 /** Stanford V Kernel exp. ethernet protocol type.
    368  */
    369 #define ETH_P_Stanford_V_Kernel_exp             0x805B
    370 
    371 /** Stanford V Kernel prod. ethernet protocol type.
    372  */
    373 #define ETH_P_Stanford_V_Kernel_prod            0x805C
    374 
    375 /** Evans &Sutherland ethernet protocol type.
    376  */
    377 #define ETH_P_Evans_Sutherland          0x805D
    378 
    379 /** Little Machines ethernet protocol type.
    380  */
    381 #define ETH_P_Little_Machines           0x8060
    382 
    383 /** Counterpoint Computers ethernet protocol type.
    384  */
    385 #define ETH_P_Counterpoint_Computers            0x8062
    386 
    387 /** Univ. of Mass. @ Amherst ethernet protocol type.
    388  */
    389 #define ETH_P_Univ_of_Mass              0x8065
    390 
    391 /** Univ. of Mass. @ Amherst ethernet protocol type.
    392  */
    393 #define ETH_P_Univ_of_Mass2             0x8066
    394 
    395 /** Veeco Integrated Auto. ethernet protocol type.
    396  */
    397 #define ETH_P_Veeco_Integrated_Auto             0x8067
    398 
    399 /** General Dynamics ethernet protocol type.
    400  */
    401 #define ETH_P_General_Dynamics          0x8068
    402 
    403 /** AT&T ethernet protocol type.
    404  */
    405 #define ETH_P_AT_T4             0x8069
    406 
    407 /** Autophon ethernet protocol type.
    408  */
    409 #define ETH_P_Autophon          0x806A
    410 
    411 /** ComDesign ethernet protocol type.
    412  */
    413 #define ETH_P_ComDesign         0x806C
    414 
    415 /** Computgraphic Corp. ethernet protocol type.
    416  */
    417 #define ETH_P_Computgraphic_Corp                0x806D
    418 
    419 /** Landmark Graphics Corp. ethernet protocol type.
    420  */
    421 #define ETH_P_Landmark_Graphics_Corp_MIN                0x806E
    422 
    423 /** Landmark Graphics Corp. ethernet protocol type.
    424  */
    425 #define ETH_P_Landmark_Graphics_Corp_MAX                0x8077
    426 
    427 /** Matra ethernet protocol type.
    428  */
    429 #define ETH_P_Matra             0x807A
    430 
    431 /** Dansk Data Elektronik ethernet protocol type.
    432  */
    433 #define ETH_P_Dansk_Data_Elektronik             0x807B
    434 
    435 /** Merit Internodal ethernet protocol type.
    436  */
    437 #define ETH_P_Merit_Internodal          0x807C
    438 
    439 /** Vitalink Communications ethernet protocol type.
    440  */
    441 #define ETH_P_Vitalink_Communications_MIN               0x807D
    442 
    443 /** Vitalink Communications ethernet protocol type.
    444  */
    445 #define ETH_P_Vitalink_Communications_MAX               0x807F
    446 
    447 /** Vitalink TransLAN III ethernet protocol type.
    448  */
    449 #define ETH_P_Vitalink_TransLAN_III             0x8080
    450 
    451 /** Counterpoint Computers ethernet protocol type.
    452  */
    453 #define ETH_P_Counterpoint_Computers_MIN                0x8081
    454 
    455 /** Counterpoint Computers ethernet protocol type.
    456  */
    457 #define ETH_P_Counterpoint_Computers_MAX                0x8083
    458 
    459 /** Appletalk ethernet protocol type.
    460  */
    461 #define ETH_P_ATALK             0x809B
    462 
    463 /** Datability ethernet protocol type.
    464  */
    465 #define ETH_P_Datability_MIN            0x809C
    466 
    467 /** Datability ethernet protocol type.
    468  */
    469 #define ETH_P_Datability_MAX            0x809E
    470 
    471 /** Spider Systems Ltd. ethernet protocol type.
    472  */
    473 #define ETH_P_Spider_Systems_Ltd                0x809F
    474 
    475 /** Nixdorf Computers ethernet protocol type.
    476  */
    477 #define ETH_P_Nixdorf_Computers         0x80A3
    478 
    479 /** Siemens Gammasonics Inc. ethernet protocol type.
    480  */
    481 #define ETH_P_Siemens_Gammasonics_Inc_MIN               0x80A4
    482 
    483 /** Siemens Gammasonics Inc. ethernet protocol type.
    484  */
    485 #define ETH_P_Siemens_Gammasonics_Inc_MAX               0x80B3
    486 
    487 /** DCA Data Exchange Cluster ethernet protocol type.
    488  */
    489 #define ETH_P_DCA_Data_Exchange_Cluster_MIN             0x80C0
    490 
    491 /** DCA Data Exchange Cluster ethernet protocol type.
    492  */
    493 #define ETH_P_DCA_Data_Exchange_Cluster_MAX             0x80C3
    494 
    495 /** Banyan Systems ethernet protocol type.
    496  */
    497 #define ETH_P_Banyan_Systems            0x80C4
    498 
    499 /** Banyan Systems ethernet protocol type.
    500  */
    501 #define ETH_P_Banyan_Systems2           0x80C5
    502 
    503 /** Pacer Software ethernet protocol type.
    504  */
    505 #define ETH_P_Pacer_Software            0x80C6
    506 
    507 /** Applitek Corporation ethernet protocol type.
    508  */
    509 #define ETH_P_Applitek_Corporation              0x80C7
    510 
    511 /** Intergraph Corporation ethernet protocol type.
    512  */
    513 #define ETH_P_Intergraph_Corporation_MIN                0x80C8
    514 
    515 /** Intergraph Corporation ethernet protocol type.
    516  */
    517 #define ETH_P_Intergraph_Corporation_MAX                0x80CC
    518 
    519 /** Harris Corporation ethernet protocol type.
    520  */
    521 #define ETH_P_Harris_Corporation_MIN            0x80CD
    522 
    523 /** Harris Corporation ethernet protocol type.
    524  */
    525 #define ETH_P_Harris_Corporation_MAX            0x80CE
    526 
    527 /** Taylor Instrument ethernet protocol type.
    528  */
    529 #define ETH_P_Taylor_Instrument_MIN             0x80CF
    530 
    531 /** Taylor Instrument ethernet protocol type.
    532  */
    533 #define ETH_P_Taylor_Instrument_MAX             0x80D2
    534 
    535 /** Rosemount Corporation ethernet protocol type.
    536  */
    537 #define ETH_P_Rosemount_Corporation_MIN         0x80D3
    538 
    539 /** Rosemount Corporation ethernet protocol type.
    540  */
    541 #define ETH_P_Rosemount_Corporation_MAX         0x80D4
    542 
    543 /** IBM SNA Service on Ether ethernet protocol type.
    544  */
    545 #define ETH_P_IBM_SNA_Service_on_Ether          0x80D5
    546 
    547 /** Varian Associates ethernet protocol type.
    548  */
    549 #define ETH_P_Varian_Associates         0x80DD
    550 
    551 /** Integrated Solutions TRFS ethernet protocol type.
    552  */
    553 #define ETH_P_Integrated_Solutions_TRFS_MIN             0x80DE
    554 
    555 /** Integrated Solutions TRFS ethernet protocol type.
    556  */
    557 #define ETH_P_Integrated_Solutions_TRFS_MAX             0x80DF
    558 
    559 /** Allen-Bradley ethernet protocol type.
    560  */
    561 #define ETH_P_Allen_Bradley_MIN         0x80E0
    562 
    563 /** Allen-Bradley ethernet protocol type.
    564  */
    565 #define ETH_P_Allen_Bradley_MAX         0x80E3
    566 
    567 /** Datability ethernet protocol type.
    568  */
    569 #define ETH_P_Datability_MIN2           0x80E4
    570 
    571 /** Datability ethernet protocol type.
    572  */
    573 #define ETH_P_Datability_MAX2           0x80F0
    574 
    575 /** Retix ethernet protocol type.
    576  */
    577 #define ETH_P_Retix             0x80F2
    578 
    579 /** AppleTalk AARP (Kinetics) ethernet protocol type.
    580  */
    581 #define ETH_P_AARP              0x80F3
    582 
    583 /** Kinetics ethernet protocol type.
    584  */
    585 #define ETH_P_Kinetics_MIN              0x80F4
    586 
    587 /** Kinetics ethernet protocol type.
    588  */
    589 #define ETH_P_Kinetics_MAX              0x80F5
    590 
    591 /** Apollo Computer ethernet protocol type.
    592  */
    593 #define ETH_P_Apollo_Computer           0x80F7
    594 
    595 /** Wellfleet Communications ethernet protocol type.
    596  */
    597 #define ETH_P_Wellfleet_Communications          0x80FF
    598 
    599 /** IEEE 802.1Q VLAN-tagged frames (initially Wellfleet) ethernet protocol type.
    600  */
    601 #define ETH_P_8021Q             0x8100
    602 
    603 /** Wellfleet Communications ethernet protocol type.
    604  */
    605 #define ETH_P_Wellfleet_Communications_MIN              0x8101
    606 
    607 /** Wellfleet Communications ethernet protocol type.
    608  */
    609 #define ETH_P_Wellfleet_Communications_MAX              0x8103
    610 
    611 /** Symbolics Private ethernet protocol type.
    612  */
    613 #define ETH_P_Symbolics_Private_MIN             0x8107
    614 
    615 /** Symbolics Private ethernet protocol type.
    616  */
    617 #define ETH_P_Symbolics_Private_MAX             0x8109
    618 
    619 /** Hayes Microcomputers ethernet protocol type.
    620  */
    621 #define ETH_P_Hayes_Microcomputers              0x8130
    622 
    623 /** VG Laboratory Systems ethernet protocol type.
    624  */
    625 #define ETH_P_VG_Laboratory_Systems             0x8131
    626 
    627 /** Bridge Communications ethernet protocol type.
    628  */
    629 #define ETH_P_Bridge_Communications_MIN         0x8132
    630 
    631 /** Bridge Communications ethernet protocol type.
    632  */
    633 #define ETH_P_Bridge_Communications_MAX         0x8136
    634 
    635 /** Novell, Inc. ethernet protocol type.
    636  */
    637 #define ETH_P_Novell_Inc_MIN            0x8137
    638 
    639 /** Novell, Inc. ethernet protocol type.
    640  */
    641 #define ETH_P_Novell_Inc_MAX            0x8138
    642 
    643 /** KTI ethernet protocol type.
    644  */
    645 #define ETH_P_KTI_MIN           0x8139
    646 
    647 /** KTI ethernet protocol type.
    648  */
    649 #define ETH_P_KTI_MAX           0x813D
    650 
    651 /** Logicraft ethernet protocol type.
    652  */
    653 #define ETH_P_Logicraft         0x8148
    654 
    655 /** Network Computing Devices ethernet protocol type.
    656  */
    657 #define ETH_P_Network_Computing_Devices         0x8149
    658 
    659 /** Alpha Micro ethernet protocol type.
    660  */
    661 #define ETH_P_Alpha_Micro               0x814A
    662 
    663 /** SNMP ethernet protocol type.
    664  */
    665 #define ETH_P_SNMP              0x814C
    666 
    667 /** BIIN ethernet protocol type.
    668  */
    669 #define ETH_P_BIIN              0x814D
    670 
    671 /** BIIN ethernet protocol type.
    672  */
    673 #define ETH_P_BIIN2             0x814E
    674 
    675 /** Technically Elite Concept ethernet protocol type.
    676  */
    677 #define ETH_P_Technically_Elite_Concept         0x814F
    678 
    679 /** Rational Corp ethernet protocol type.
    680  */
    681 #define ETH_P_Rational_Corp             0x8150
    682 
    683 /** Qualcomm ethernet protocol type.
    684  */
    685 #define ETH_P_Qualcomm_MIN              0x8151
    686 
    687 /** Qualcomm ethernet protocol type.
    688  */
    689 #define ETH_P_Qualcomm_MAX              0x8153
    690 
    691 /** Computer Protocol Pty Ltd ethernet protocol type.
    692  */
    693 #define ETH_P_Computer_Protocol_Pty_Ltd_MIN             0x815C
    694 
    695 /** Computer Protocol Pty Ltd ethernet protocol type.
    696  */
    697 #define ETH_P_Computer_Protocol_Pty_Ltd_MAX             0x815E
    698 
    699 /** Charles River Data System ethernet protocol type.
    700  */
    701 #define ETH_P_Charles_River_Data_System_MIN             0x8164
    702 
    703 /** Charles River Data System ethernet protocol type.
    704  */
    705 #define ETH_P_Charles_River_Data_System_MAX             0x8166
    706 
    707 /** XTP ethernet protocol type.
    708  */
    709 #define ETH_P_XTP               0x817D
    710 
    711 /** SGI/Time Warner prop. ethernet protocol type.
    712  */
    713 #define ETH_P_SGITime_Warner_prop               0x817E
    714 
    715 /** HIPPI-FP encapsulation ethernet protocol type.
    716  */
    717 #define ETH_P_HIPPI_FP_encapsulation            0x8180
    718 
    719 /** STP, HIPPI-ST ethernet protocol type.
    720  */
    721 #define ETH_P_STP_HIPPI_ST              0x8181
    722 
    723 /** Reserved for HIPPI-6400 ethernet protocol type.
    724  */
    725 #define ETH_P_Reserved_for_HIPPI_6400           0x8182
    726 
    727 /** Reserved for HIPPI-6400 ethernet protocol type.
    728  */
    729 #define ETH_P_Reserved_for_HIPPI_64002          0x8183
    730 
    731 /** Silicon Graphics prop. ethernet protocol type.
    732  */
    733 #define ETH_P_Silicon_Graphics_prop_MIN         0x8184
    734 
    735 /** Silicon Graphics prop. ethernet protocol type.
    736  */
    737 #define ETH_P_Silicon_Graphics_prop_MAX         0x818C
    738 
    739 /** Motorola Computer ethernet protocol type.
    740  */
    741 #define ETH_P_Motorola_Computer         0x818D
    742 
    743 /** Qualcomm ethernet protocol type.
    744  */
    745 #define ETH_P_Qualcomm_MIN2             0x819A
    746 
    747 /** Qualcomm ethernet protocol type.
    748  */
    749 #define ETH_P_Qualcomm_MAX2             0x81A3
    750 
    751 /** ARAI Bunkichi ethernet protocol type.
    752  */
    753 #define ETH_P_ARAI_Bunkichi             0x81A4
    754 
    755 /** RAD Network Devices ethernet protocol type.
    756  */
    757 #define ETH_P_RAD_Network_Devices_MIN           0x81A5
    758 
    759 /** RAD Network Devices ethernet protocol type.
    760  */
    761 #define ETH_P_RAD_Network_Devices_MAX           0x81AE
    762 
    763 /** Xyplex ethernet protocol type.
    764  */
    765 #define ETH_P_Xyplex_MIN2               0x81B7
    766 
    767 /** Xyplex ethernet protocol type.
    768  */
    769 #define ETH_P_Xyplex_MAX2               0x81B9
    770 
    771 /** Apricot Computers ethernet protocol type.
    772  */
    773 #define ETH_P_Apricot_Computers_MIN             0x81CC
    774 
    775 /** Apricot Computers ethernet protocol type.
    776  */
    777 #define ETH_P_Apricot_Computers_MAX             0x81D5
    778 
    779 /** Artisoft ethernet protocol type.
    780  */
    781 #define ETH_P_Artisoft_MIN              0x81D6
    782 
    783 /** Artisoft ethernet protocol type.
    784  */
    785 #define ETH_P_Artisoft_MAX              0x81DD
    786 
    787 /** Polygon ethernet protocol type.
    788  */
    789 #define ETH_P_Polygon_MIN               0x81E6
    790 
    791 /** Polygon ethernet protocol type.
    792  */
    793 #define ETH_P_Polygon_MAX               0x81EF
    794 
    795 /** Comsat Labs ethernet protocol type.
    796  */
    797 #define ETH_P_Comsat_Labs_MIN           0x81F0
    798 
    799 /** Comsat Labs ethernet protocol type.
    800  */
    801 #define ETH_P_Comsat_Labs_MAX           0x81F2
    802 
    803 /** SAIC ethernet protocol type.
    804  */
    805 #define ETH_P_SAIC_MIN          0x81F3
    806 
    807 /** SAIC ethernet protocol type.
    808  */
    809 #define ETH_P_SAIC_MAX          0x81F5
    810 
    811 /** VG Analytical ethernet protocol type.
    812  */
    813 #define ETH_P_VG_Analytical_MIN         0x81F6
    814 
    815 /** VG Analytical ethernet protocol type.
    816  */
    817 #define ETH_P_VG_Analytical_MAX         0x81F8
    818 
    819 /** Quantum Software ethernet protocol type.
    820  */
    821 #define ETH_P_Quantum_Software_MIN              0x8203
    822 
    823 /** Quantum Software ethernet protocol type.
    824  */
    825 #define ETH_P_Quantum_Software_MAX              0x8205
    826 
    827 /** Ascom Banking Systems ethernet protocol type.
    828  */
    829 #define ETH_P_Ascom_Banking_Systems_MIN         0x8221
    830 
    831 /** Ascom Banking Systems ethernet protocol type.
    832  */
    833 #define ETH_P_Ascom_Banking_Systems_MAX         0x8222
    834 
    835 /** Advanced Encryption Syste ethernet protocol type.
    836  */
    837 #define ETH_P_Advanced_Encryption_Syste_MIN             0x823E
    838 
    839 /** Advanced Encryption Syste ethernet protocol type.
    840  */
    841 #define ETH_P_Advanced_Encryption_Syste_MAX             0x8240
    842 
    843 /** Athena Programming ethernet protocol type.
    844  */
    845 #define ETH_P_Athena_Programming_MIN            0x827F
    846 
    847 /** Athena Programming ethernet protocol type.
    848  */
    849 #define ETH_P_Athena_Programming_MAX            0x8282
    850 
    851 /** Charles River Data System ethernet protocol type.
    852  */
    853 #define ETH_P_Charles_River_Data_System_MIN2            0x8263
    854 
    855 /** Charles River Data System ethernet protocol type.
    856  */
    857 #define ETH_P_Charles_River_Data_System_MAX2            0x826A
    858 
    859 /** Inst Ind Info Tech ethernet protocol type.
    860  */
    861 #define ETH_P_Inst_Ind_Info_Tech_MIN            0x829A
    862 
    863 /** Inst Ind Info Tech ethernet protocol type.
    864  */
    865 #define ETH_P_Inst_Ind_Info_Tech_MAX            0x829B
    866 
    867 /** Taurus Controls ethernet protocol type.
    868  */
    869 #define ETH_P_Taurus_Controls_MIN               0x829C
    870 
    871 /** Taurus Controls ethernet protocol type.
    872  */
    873 #define ETH_P_Taurus_Controls_MAX               0x82AB
    874 
    875 /** Walker Richer &Quinn ethernet protocol type.
    876  */
    877 #define ETH_P_Walker_Richer_Quinn_MIN           0x82AC
    878 
    879 /** Walker Richer &Quinn ethernet protocol type.
    880  */
    881 #define ETH_P_Walker_Richer_Quinn_MAX           0x8693
    882 
    883 /** Idea Courier ethernet protocol type.
    884  */
    885 #define ETH_P_Idea_Courier_MIN          0x8694
    886 
    887 /** Idea Courier ethernet protocol type.
    888  */
    889 #define ETH_P_Idea_Courier_MAX          0x869D
    890 
    891 /** Computer Network Tech ethernet protocol type.
    892  */
    893 #define ETH_P_Computer_Network_Tech_MIN         0x869E
    894 
    895 /** Computer Network Tech ethernet protocol type.
    896  */
    897 #define ETH_P_Computer_Network_Tech_MAX         0x86A1
    898 
    899 /** Gateway Communications ethernet protocol type.
    900  */
    901 #define ETH_P_Gateway_Communications_MIN                0x86A3
    902 
    903 /** Gateway Communications ethernet protocol type.
    904  */
    905 #define ETH_P_Gateway_Communications_MAX                0x86AC
    906 
    907 /** SECTRA ethernet protocol type.
    908  */
    909 #define ETH_P_SECTRA            0x86DB
    910 
    911 /** Delta Controls ethernet protocol type.
    912  */
    913 #define ETH_P_Delta_Controls            0x86DE
    914 
    915 /** IPv6 ethernet protocol type.
    916  */
    917 #define ETH_P_IPV6              0x86DD
    918 
    919 /** ATOMIC ethernet protocol type.
    920  */
    921 #define ETH_P_ATOMIC            0x86DF
    922 
    923 /** Landis &Gyr Powers ethernet protocol type.
    924  */
    925 #define ETH_P_Landis_Gyr_Powers_MIN             0x86E0
    926 
    927 /** Landis &Gyr Powers ethernet protocol type.
    928  */
    929 #define ETH_P_Landis_Gyr_Powers_MAX             0x86EF
    930 
    931 /** Motorola ethernet protocol type.
    932  */
    933 #define ETH_P_Motorola_MIN              0x8700
    934 
    935 /** Motorola ethernet protocol type.
    936  */
    937 #define ETH_P_Motorola_MAX              0x8710
    938 
    939 /** TCP/IP Compression ethernet protocol type.
    940  */
    941 #define ETH_P_TCPIP_Compression         0x876B
    942 
    943 /** IP Autonomous Systems ethernet protocol type.
    944  */
    945 #define ETH_P_IP_Autonomous_Systems             0x876C
    946 
    947 /** Secure Data ethernet protocol type.
    948  */
    949 #define ETH_P_Secure_Data               0x876D
    950 
    951 /** PPP ethernet protocol type.
    952  */
    953 #define ETH_P_PPP               0x880B
    954 
    955 /** MPLS ethernet protocol type.
    956  */
    957 #define ETH_P_MPLS_UC           0x8847
    958 
    959 /** MPLS with upstream-assigned label ethernet protocol type.
    960  */
    961 #define ETH_P_MPLS_MC           0x8848
    962 
    963 /** Invisible Software ethernet protocol type.
    964  */
    965 #define ETH_P_Invisible_Software_MIN            0x8A96
    966 
    967 /** Invisible Software ethernet protocol type.
    968  */
    969 #define ETH_P_Invisible_Software_MAX            0x8A97
    970 
    971 /** PPPoE Discovery Stage ethernet protocol type.
    972  */
    973 #define ETH_P_PPP_DISC          0x8863
    974 
    975 /** PPPoE Session Stage ethernet protocol type.
    976  */
    977 #define ETH_P_PPP_SES           0x8864
    978 
    979 /** Loopback ethernet protocol type.
    980  */
    981 #define ETH_P_Loopback          0x9000
    982 
    983 /** Com(Bridge) XNS Sys Mgmt ethernet protocol type.
    984  */
    985 #define ETH_P_Com_XNS_Sys_Mgmt          0x9001
    986 
    987 /** Com(Bridge) TCP-IP Sys ethernet protocol type.
    988  */
    989 #define ETH_P_Com_TCP_IP_Sys            0x9002
    990 
    991 /** Com(Bridge) loop detect ethernet protocol type.
    992  */
    993 #define ETH_P_Com_loop_detect           0x9003
    994 
    995 /** BBN VITAL-LanBridge cache ethernet protocol type.
    996  */
    997 #define ETH_P_BBN_VITAL_LanBridge_cache         0xFF00
    998 
    999 /** ISC Bunker Ramo ethernet protocol type.
    1000  */
    1001 #define ETH_P_ISC_Bunker_Ramo_MIN               0xFF00
    1002 
    1003 /** ISC Bunker Ramo ethernet protocol type.
    1004  */
    1005 #define ETH_P_ISC_Bunker_Ramo_MAX               0xFF0F
    100660
    100761/*@}*/
  • uspace/lib/net/include/generic.h

    ra93d79a r8fb1bf82  
    4949    services_t);
    5050extern int generic_device_req_remote(int, int, device_id_t, int, services_t);
    51 extern int generic_get_addr_req(int, int, device_id_t, measured_string_ref *,
     51extern int generic_get_addr_req(int, int, device_id_t, measured_string_t **,
    5252    char **);
    5353extern int generic_packet_size_req_remote(int, int, device_id_t,
    54     packet_dimension_ref);
     54    packet_dimension_t *);
    5555extern int generic_received_msg_remote(int, int, device_id_t, packet_id_t,
    5656    services_t, services_t);
     
    5858    services_t, services_t);
    5959extern int generic_translate_req(int, int, device_id_t, services_t,
    60     measured_string_ref, size_t, measured_string_ref *, char **);
     60    measured_string_t *, size_t, measured_string_t **, char **);
    6161
    6262#endif
  • uspace/lib/net/include/icmp_client.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup icmp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP client interface.
     34 * ICMP client interface.
    3535 */
    3636
    37 #ifndef __NET_ICMP_CLIENT_H__
    38 #define __NET_ICMP_CLIENT_H__
     37#ifndef LIBNET_ICMP_CLIENT_H_
     38#define LIBNET_ICMP_CLIENT_H_
    3939
    4040#include <net/icmp_codes.h>
    4141#include <net/packet.h>
    4242
    43 /** Processes the received packet prefixed with an ICMP header.
    44  *  @param[in] packet The received packet.
    45  *  @param[out] type The ICMP header type.
    46  *  @param[out] code The ICMP header code.
    47  *  @param[out] pointer The ICMP header pointer.
    48  *  @param[out] mtu The ICMP header MTU.
    49  *  @returns The ICMP header length.
    50  *  @returns Zero (0) if the packet contains no data.
    51  */
    52 extern int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu);
    53 
    54 /** Returns the ICMP header length.
    55  *  @param[in] packet The packet.
    56  *  @returns The ICMP header length in bytes.
    57  */
    58 extern size_t icmp_client_header_length(packet_t packet);
     43extern int icmp_client_process_packet(packet_t *, icmp_type_t *, icmp_code_t *,
     44    icmp_param_t *, icmp_param_t *);
     45extern size_t icmp_client_header_length(packet_t *);
    5946
    6047#endif
  • uspace/lib/net/include/icmp_header.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libnet
    3030 *  @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP header definition.
    35  *  Based on the RFC~792.
     34 * ICMP header definition.
     35 * Based on the RFC 792.
    3636 */
    3737
    38 #ifndef __NET_ICMP_HEADER_H__
    39 #define __NET_ICMP_HEADER_H__
     38#ifndef LIBNET_ICMP_HEADER_H_
     39#define LIBNET_ICMP_HEADER_H_
    4040
    4141#include <sys/types.h>
     
    4444#include <net/icmp_codes.h>
    4545
    46 /** ICMP header size in bytes.
    47  */
    48 #define ICMP_HEADER_SIZE                        sizeof(icmp_header_t)
     46/** ICMP header size in bytes. */
     47#define ICMP_HEADER_SIZE        sizeof(icmp_header_t)
    4948
    5049/** Type definition of the echo specific data.
    51  *  @see icmp_echo
     50 * @see icmp_echo
    5251 */
    53 typedef struct icmp_echo        icmp_echo_t;
     52typedef struct icmp_echo icmp_echo_t;
    5453
    55 /** Type definition of the echo specific data pointer.
    56  *  @see icmp_echo
    57  */
    58 typedef icmp_echo_t *           icmp_echo_ref;
    59 
    60 /** Echo specific data.
    61  */
    62 struct icmp_echo{
    63         /** Message idintifier.
    64          */
     54/** Echo specific data. */
     55struct icmp_echo {
     56        /** Message idintifier. */
    6557        icmp_param_t identifier;
    66         /** Message sequence number.
    67          */
     58        /** Message sequence number. */
    6859        icmp_param_t sequence_number;
    6960} __attribute__ ((packed));
    7061
    7162/** Type definition of the internet control message header.
    72  *  @see icmp_header
     63 * @see icmp_header
    7364 */
    74 typedef struct icmp_header      icmp_header_t;
     65typedef struct icmp_header icmp_header_t;
    7566
    76 /** Type definition of the internet control message header pointer.
    77  *  @see icmp_header
    78  */
    79 typedef icmp_header_t *         icmp_header_ref;
    80 
    81 /** Internet control message header.
    82  */
    83 struct icmp_header{
    84         /** The type of the message.
    85          */
     67/** Internet control message header. */
     68struct icmp_header {
     69        /** The type of the message. */
    8670        uint8_t type;
    87         /** The error code for the datagram reported by the ICMP message.
    88          *  The interpretation is dependent on the message type.
     71       
     72        /**
     73         * The error code for the datagram reported by the ICMP message.
     74         * The interpretation is dependent on the message type.
    8975         */
    9076        uint8_t code;
    91         /** The checksum is the 16-bit ones's complement of the one's complement sum of the ICMP message starting with the ICMP Type.
    92      *  For computing the checksum, the checksum field should be zero.
    93          *  If the checksum does not match the contents, the datagram is discarded.
     77       
     78        /**
     79         * The checksum is the 16-bit ones's complement of the one's complement
     80         * sum of the ICMP message starting with the ICMP Type. For computing
     81         * the checksum, the checksum field should be zero. If the checksum does
     82         * not match the contents, the datagram is discarded.
    9483         */
    9584        uint16_t checksum;
    96         /** Message specific data.
    97          */
    98         union{
    99                 /** Echo specific data.
    100                  */
     85
     86        /** Message specific data. */
     87        union {
     88                /** Echo specific data. */
    10189                icmp_echo_t  echo;
    102                 /** Proposed gateway value.
    103                  */
     90                /** Proposed gateway value. */
    10491                in_addr_t gateway;
    105                 /** Fragmentation needed specific data.
    106                  */
    107                 struct{
    108                         /** Reserved field.
    109                          *  Must be zero.
    110                          */
     92               
     93                /** Fragmentation needed specific data. */
     94                struct {
     95                        /** Reserved field. Must be zero. */
    11196                        icmp_param_t reserved;
    112                         /** Proposed MTU.
    113                          */
     97                        /** Proposed MTU. */
    11498                        icmp_param_t mtu;
    11599                } frag;
    116                 /** Parameter problem specific data.
    117                  */
    118                 struct{
    119                         /** Problem pointer.
    120                          */
     100               
     101                /** Parameter problem specific data. */
     102                struct {
     103                        /** Problem pointer. */
    121104                        icmp_param_t pointer;
    122                         /** Reserved field.
    123                          *  Must be zero.
    124                          */
     105                        /** Reserved field. Must be zero. */
    125106                        icmp_param_t reserved;
    126107                } param;
  • uspace/lib/net/include/icmp_interface.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libnet
    3030 *  @{
    3131 */
    3232
    33 #ifndef __NET_ICMP_INTERFACE_H__
    34 #define __NET_ICMP_INTERFACE_H__
     33#ifndef LIBNET_ICMP_INTERFACE_H_
     34#define LIBNET_ICMP_INTERFACE_H_
    3535
    3636#include <net/socket_codes.h>
     
    4646
    4747/** @name ICMP module interface
    48  *  This interface is used by other modules.
     48 * This interface is used by other modules.
    4949 */
    5050/*@{*/
    5151
    52 /** Sends the Destination Unreachable error notification packet.
    53  *  Beginning of the packet is sent as the notification packet data.
    54  *  The source and the destination addresses should be set in the original packet.
    55  *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    56  *  @param[in] code The error specific code.
    57  *  @param[in] mtu The error MTU value.
    58  *  @param[in] packet The original packet.
    59  *  @returns EOK on success.
    60  *  @returns EPERM if the ICMP error notifications are disabled.
    61  *  @returns ENOMEM if there is not enough memory left.
    62  */
    63 extern int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet);
    64 
    65 /** Sends the Source Quench error notification packet.
    66  *  Beginning of the packet is sent as the notification packet data.
    67  *  The source and the destination addresses should be set in the original packet.
    68  *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    69  *  @param[in] packet The original packet.
    70  *  @returns EOK on success.
    71  *  @returns EPERM if the ICMP error notifications are disabled.
    72  *  @returns ENOMEM if there is not enough memory left.
    73  */
    74 extern int icmp_source_quench_msg(int icmp_phone, packet_t packet);
    75 
    76 /** Sends the Time Exceeded error notification packet.
    77  *  Beginning of the packet is sent as the notification packet data.
    78  *  The source and the destination addresses should be set in the original packet.
    79  *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    80  *  @param[in] code The error specific code.
    81  *  @param[in] packet The original packet.
    82  *  @returns EOK on success.
    83  *  @returns EPERM if the ICMP error notifications are disabled.
    84  *  @returns ENOMEM if there is not enough memory left.
    85  */
    86 extern int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet);
    87 
    88 /** Sends the Parameter Problem error notification packet.
    89  *  Beginning of the packet is sent as the notification packet data.
    90  *  The source and the destination addresses should be set in the original packet.
    91  *  @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
    92  *  @param[in] code The error specific code.
    93  *  @param[in] pointer The problematic parameter offset.
    94  *  @param[in] packet The original packet.
    95  *  @returns EOK on success.
    96  *  @returns EPERM if the ICMP error notifications are disabled.
    97  *  @returns ENOMEM if there is not enough memory left.
    98  */
    99 extern int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet);
     52extern int icmp_destination_unreachable_msg(int, icmp_code_t, icmp_param_t,
     53    packet_t *);
     54extern int icmp_source_quench_msg(int, packet_t *);
     55extern int icmp_time_exceeded_msg(int, icmp_code_t, packet_t *);
     56extern int icmp_parameter_problem_msg(int, icmp_code_t, icmp_param_t, packet_t *);
    10057
    10158/*@}*/
  • uspace/lib/net/include/il_interface.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_il
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  * Internetwork layer module interface for the underlying network interface layer.
    35  * This interface is always called by the remote modules.
     34 * Internetwork layer module interface for the underlying network interface
     35 * layer. This interface is always called by the remote modules.
    3636 */
    3737
    38 #ifndef __NET_IL_INTERFACE_H__
    39 #define __NET_IL_INTERFACE_H__
    40 
    41 #include <generic.h>
     38#ifndef LIBNET_IL_INTERFACE_H_
     39#define LIBNET_IL_INTERFACE_H_
    4240
    4341#include <ipc/services.h>
    44 #include <ipc/il.h>
     42#include <sys/types.h>
    4543
    4644#include <net/device.h>
    4745#include <net/packet.h>
    48 
    49 #include <packet_client.h>
    5046
    5147/** @name Internetwork layer module interface
     
    5450/*@{*/
    5551
    56 /** Notify the internetwork layer modules about the device state change.
    57  *
    58  * @param[in] il_phone  The internetwork layer module phone used for
    59  *                      (semi)remote calls.
    60  * @param[in] device_id The device identifier.
    61  * @param[in] state     The new device state.
    62  * @param[in] target    The target internetwork module service to be
    63  *                      delivered to.
    64  *
    65  * @return EOK on success.
    66  *
    67  */
    68 static inline int il_device_state_msg(int il_phone, device_id_t device_id,
    69     device_state_t state, services_t target)
    70 {
    71         return generic_device_state_msg_remote(il_phone, NET_IL_DEVICE_STATE,
    72             device_id, state, target);
    73 }
    74 
    75 /** Notify the internetwork layer modules about the received packet/s.
    76  *
    77  * @param[in] il_phone  The internetwork layer module phone used for
    78  *                      (semi)remote calls.
    79  * @param[in] device_id The device identifier.
    80  * @param[in] packet    The received packet or the received packet queue.
    81  * @param[in] target    The target internetwork module service to be
    82  *                      delivered to.
    83  *
    84  * @return EOK on success.
    85  *
    86  */
    87 inline static int il_received_msg(int il_phone, device_id_t device_id,
    88     packet_t packet, services_t target)
    89 {
    90         return generic_received_msg_remote(il_phone, NET_IL_RECEIVED, device_id,
    91             packet_get_id(packet), target, 0);
    92 }
    93 
    94 /** Notify the internetwork layer modules about the mtu change.
    95  *
    96  * @param[in] il_phone  The internetwork layer module phone used for
    97  *                      (semi)remote calls.
    98  * @param[in] device_id The device identifier.
    99  * @param[in] mtu       The new mtu value.
    100  * @param[in] target    The target internetwork module service to be
    101  *                      delivered to.
    102  *
    103  * @return EOK on success.
    104  *
    105  */
    106 inline static int il_mtu_changed_msg(int il_phone, device_id_t device_id,
    107     size_t mtu, services_t target)
    108 {
    109         return generic_device_state_msg_remote(il_phone, NET_IL_MTU_CHANGED,
    110             device_id, (int) mtu, target);
    111 }
     52extern int il_device_state_msg(int, device_id_t, device_state_t, services_t);
     53extern int il_received_msg(int, device_id_t, packet_t *, services_t);
     54extern int il_mtu_changed_msg(int, device_id_t, size_t, services_t);
    11255
    11356/*@}*/
  • uspace/lib/net/include/il_local.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup il_local
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    33 #ifndef __IL_LOCAL_H__
    34 #define __IL_LOCAL_H__
     33#ifndef LIBNET_IL_LOCAL_H_
     34#define LIBNET_IL_LOCAL_H_
    3535
    3636#include <ipc/ipc.h>
    3737#include <async.h>
    3838
     39/** Processes the Internet layer module message.
     40 *
     41 * @param[in]           callid The message identifier.
     42 * @param[in]           call The message parameters.
     43 * @param[out]          answer The message answer parameters.
     44 * @param[out]          answer_count The last parameter for the actual answer in
     45 *                      the answer parameter.
     46 * @return              EOK on success.
     47 * @return              Other error codes as defined for the arp_message()
     48 *                      function.
     49 */
    3950extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    4051    ipc_call_t *answer, int *answer_count);
     52
     53/** Starts the Internet layer module.
     54 *
     55 * Initializes the client connection servicing function, initializes the module,
     56 * registers the module service and starts the async manager, processing IPC
     57 * messages in an infinite loop.
     58 *
     59 * @param[in] client_connection The client connection processing function. The
     60 *                      module skeleton propagates its own one.
     61 * @return              EOK on successful module termination.
     62 * @return              Other error codes as defined for the arp_initialize()
     63 *                      function.
     64 * @return              Other error codes as defined for the REGISTER_ME() macro
     65 *                      function.
     66 */
    4167extern int il_module_start_standalone(async_client_conn_t client_connection);
    4268
  • uspace/lib/net/include/ip_client.h

    ra93d79a r8fb1bf82  
    4545#include <ip_interface.h>
    4646
    47 extern int ip_client_prepare_packet(packet_t, ip_protocol_t, ip_ttl_t, ip_tos_t,
    48     int, size_t);
    49 extern int ip_client_process_packet(packet_t, ip_protocol_t *, ip_ttl_t *,
     47extern int ip_client_prepare_packet(packet_t *, ip_protocol_t, ip_ttl_t,
     48    ip_tos_t, int, size_t);
     49extern int ip_client_process_packet(packet_t *, ip_protocol_t *, ip_ttl_t *,
    5050    ip_tos_t *, int *, size_t *);
    51 extern size_t ip_client_header_length(packet_t);
     51extern size_t ip_client_header_length(packet_t *);
    5252extern int ip_client_set_pseudo_header_data_length(void *, size_t, size_t);
    5353extern int ip_client_get_pseudo_header(ip_protocol_t, struct sockaddr *,
  • uspace/lib/net/include/ip_header.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup ip
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  IP header and options definitions.
    35  *  Based on the RFC~791.
    36  */
    37 
    38 #ifndef __NET_IP_HEADER_H__
    39 #define __NET_IP_HEADER_H__
     34 * IP header and options definitions.
     35 * Based on the RFC 791.
     36 */
     37
     38#ifndef LIBNET_IP_HEADER_H_
     39#define LIBNET_IP_HEADER_H_
    4040
    4141#include <byteorder.h>
     
    4343
    4444/** Returns the fragment offest high bits.
    45  *  @param[in] length The prefixed data total length.
    46  */
    47 #define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) ((((length) / 8u) &0x1F00) >> 8)
     45 * @param[in] length The prefixed data total length.
     46 */
     47#define IP_COMPUTE_FRAGMENT_OFFSET_HIGH(length) \
     48        ((((length) / 8U) & 0x1f00) >> 8)
    4849
    4950/** Returns the fragment offest low bits.
    50  *  @param[in] length The prefixed data total length.
    51  */
    52 #define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) (((length) / 8u) &0xFF)
     51 * @param[in] length The prefixed data total length.
     52 */
     53#define IP_COMPUTE_FRAGMENT_OFFSET_LOW(length) \
     54        (((length) / 8U) & 0xff)
    5355
    5456/** Returns the IP header length.
    55  *  @param[in] length The IP header length in bytes.
    56  */
    57 #define IP_COMPUTE_HEADER_LENGTH(length)                ((uint8_t) ((length) / 4u))
     57 * @param[in] length The IP header length in bytes.
     58 */
     59#define IP_COMPUTE_HEADER_LENGTH(length) \
     60        ((uint8_t) ((length) / 4U))
    5861
    5962/** Returns the fragment offest.
    60  *  @param[in] header The IP packet header.
    61  */
    62 #define IP_FRAGMENT_OFFSET(header) ((((header)->fragment_offset_high << 8) + (header)->fragment_offset_low) * 8u)
     63 * @param[in] header The IP packet header.
     64 */
     65#define IP_FRAGMENT_OFFSET(header) \
     66        ((((header)->fragment_offset_high << 8) + \
     67            (header)->fragment_offset_low) * 8U)
    6368
    6469/** Returns the IP packet header checksum.
    6570 *  @param[in] header The IP packet header.
    6671 */
    67 #define IP_HEADER_CHECKSUM(header)      (htons(ip_checksum((uint8_t *)(header), IP_HEADER_LENGTH(header))))
     72#define IP_HEADER_CHECKSUM(header) \
     73        (htons(ip_checksum((uint8_t *) (header), IP_HEADER_LENGTH(header))))
    6874
    6975/** Returns the actual IP packet data length.
    70  *  @param[in] header The IP packet header.
    71  */
    72 #define IP_HEADER_DATA_LENGTH(header)   (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
     76 * @param[in] header The IP packet header.
     77 */
     78#define IP_HEADER_DATA_LENGTH(header) \
     79        (IP_TOTAL_LENGTH(header) - IP_HEADER_LENGTH(header))
    7380
    7481/** Returns the actual IP header length in bytes.
    75  *  @param[in] header The IP packet header.
    76  */
    77 #define IP_HEADER_LENGTH(header)                ((header)->header_length * 4u)
     82 * @param[in] header The IP packet header.
     83 */
     84#define IP_HEADER_LENGTH(header) \
     85        ((header)->header_length * 4U)
    7886
    7987/** Returns the actual IP packet total length.
    80  *  @param[in] header The IP packet header.
    81  */
    82 #define IP_TOTAL_LENGTH(header)         ntohs((header)->total_length)
    83 
    84 /** @name IP flags definitions
    85  */
     88 * @param[in] header The IP packet header.
     89 */
     90#define IP_TOTAL_LENGTH(header) \
     91        ntohs((header)->total_length)
     92
     93/** @name IP flags definitions */
    8694/*@{*/
    8795
    88 /** Fragment flag field shift.
    89  */
    90 #define IPFLAG_FRAGMENT_SHIFT           1
    91 
    92 /** Fragmented flag field shift.
    93  */
    94 #define IPFLAG_FRAGMENTED_SHIFT         0
     96/** Fragment flag field shift. */
     97#define IPFLAG_FRAGMENT_SHIFT   1
     98
     99/** Fragmented flag field shift. */
     100#define IPFLAG_FRAGMENTED_SHIFT 0
    95101
    96102/** Don't fragment flag value.
    97  *  Permits the packet fragmentation.
    98  */
    99 #define IPFLAG_DONT_FRAGMENT            (0x1 << IPFLAG_FRAGMENT_SHIFT)
     103 * Permits the packet fragmentation.
     104 */
     105#define IPFLAG_DONT_FRAGMENT    (0x1 << IPFLAG_FRAGMENT_SHIFT)
    100106
    101107/** Last fragment flag value.
    102  *  Indicates the last packet fragment.
    103  */
    104 #define IPFLAG_LAST_FRAGMENT            (0x0 << IPFLAG_FRAGMENTED_SHIFT)
     108 * Indicates the last packet fragment.
     109 */
     110#define IPFLAG_LAST_FRAGMENT    (0x0 << IPFLAG_FRAGMENTED_SHIFT)
    105111
    106112/** May fragment flag value.
    107  *  Allows the packet fragmentation.
    108  */
    109 #define IPFLAG_MAY_FRAGMENT                     (0x0 << IPFLAG_FRAGMENT_SHIFT)
     113 * Allows the packet fragmentation.
     114 */
     115#define IPFLAG_MAY_FRAGMENT     (0x0 << IPFLAG_FRAGMENT_SHIFT)
    110116
    111117/** More fragments flag value.
    112  *  Indicates that more packet fragments follow.
    113  */
    114 #define IPFLAG_MORE_FRAGMENTS           (0x1 << IPFLAG_FRAGMENTED_SHIFT)
     118 * Indicates that more packet fragments follow.
     119 */
     120#define IPFLAG_MORE_FRAGMENTS   (0x1 << IPFLAG_FRAGMENTED_SHIFT)
    115121
    116122/*@}*/
    117123
    118124/** Type definition of the internet header.
    119  *  @see ip_header
    120  */
    121 typedef struct ip_header        ip_header_t;
    122 
    123 /** Type definition of the internet header pointer.
    124  *  @see ip_header
    125  */
    126 typedef ip_header_t *           ip_header_ref;
     125 * @see ip_header
     126 */
     127typedef struct ip_header ip_header_t;
    127128
    128129/** Type definition of the internet option header.
    129  *  @see ip_header
    130  */
    131 typedef struct ip_option        ip_option_t;
    132 
    133 /** Type definition of the internet option header pointer.
    134  *  @see ip_header
    135  */
    136 typedef ip_option_t *           ip_option_ref;
     130 * @see ip_header
     131 */
     132typedef struct ip_option ip_option_t;
    137133
    138134/** Type definition of the internet version 4 pseudo header.
    139  *  @see ipv4_pseudo_header
    140  */
    141 typedef struct ipv4_pseudo_header       ipv4_pseudo_header_t;
    142 
    143 /** Type definition of the internet version 4 pseudo header pointer.
    144  *  @see ipv4_pseudo_header
    145  */
    146 typedef ipv4_pseudo_header_t *          ipv4_pseudo_header_ref;
     135 * @see ipv4_pseudo_header
     136 */
     137typedef struct ipv4_pseudo_header ipv4_pseudo_header_t;
    147138
    148139/** Internet header.
    149  *  The variable options should be included after the header itself and indicated by the increased header length value.
    150  */
    151 struct ip_header{
     140 *
     141 * The variable options should be included after the header itself and
     142 * indicated by the increased header length value.
     143 */
     144struct ip_header {
    152145#ifdef ARCH_IS_BIG_ENDIAN
    153         /** The Version field indicates the format of the internet header.
    154          */
    155         uint8_t version:4;
    156         /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
    157          *  Note that the minimum value for a~correct header is~5.
    158          */
    159         uint8_t header_length:4;
     146        uint8_t version : 4;
     147        uint8_t header_length : 4;
    160148#else
    161         /** Internet Header Length is the length of the internet header in 32~bit words, and thus points to the beginning of the data.
    162          *  Note that the minimum value for a~correct header is~5.
    163          */
    164         uint8_t header_length:4;
    165         /** The Version field indicates the format of the internet header.
    166          */
    167         uint8_t version:4;
    168 #endif
    169         /** The Type of Service provides an indication of the abstract parameters of the quality of service desired.
    170          *  These parameters are to be used to guide the selection of the actual service parameters when transmitting a~datagram through a~particular network.
    171          *  Several networks offer service precedence, which somehow treats high precedence traffic as more important than other traffic (generally by accepting only traffic above a~certain precedence at time of high load).
    172          *  The major choice is a~three way tradeoff between low-delay, high-reliability, and high-throughput.
    173          */
     149        uint8_t header_length : 4;
     150        uint8_t version : 4;
     151#endif
     152
    174153        uint8_t tos;
    175         /** Total Length is the length of the datagram, measured in octets, including internet header and data.
    176          *  This field allows the length of a~datagram to be up to 65,535~octets.
    177          */
    178154        uint16_t total_length;
    179         /** An identifying value assigned by the sender to aid in assembling the fragments of a~datagram.
    180          */
    181155        uint16_t identification;
     156
    182157#ifdef ARCH_IS_BIG_ENDIAN
    183         /** Various control flags.
    184          */
    185         uint8_t flags:3;
    186         /** This field indicates where in the datagram this fragment belongs.
    187          *  High bits.
    188          */
    189         uint8_t fragment_offset_high:5;
     158        uint8_t flags : 3;
     159        uint8_t fragment_offset_high : 5;
    190160#else
    191         /** This field indicates where in the datagram this fragment belongs.
    192          *  High bits.
    193          */
    194         uint8_t fragment_offset_high:5;
    195         /** Various control flags.
    196          */
    197         uint8_t flags:3;
    198 #endif
    199         /** This field indicates where in the datagram this fragment belongs.
    200          *  Low bits.
    201          */
     161        uint8_t fragment_offset_high : 5;
     162        uint8_t flags : 3;
     163#endif
     164
    202165        uint8_t fragment_offset_low;
    203         /** This field indicates the maximum time the datagram is allowed to remain in the internet system.
    204          *  If this field contains the value zero, then the datagram must be destroyed.
    205          *  This field is modified in internet header processing.
    206          *  The time is measured in units of seconds, but since every module that processes a~datagram must decrease the TTL by at least one even if it process the datagram in less than a~second, the TTL must be thought of only as an upper bound on the time a~datagram may exist.
    207          *  The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.
    208          */
    209166        uint8_t ttl;
    210         /** This field indicates the next level protocol used in the data portion of the internet datagram.
    211          */
    212167        uint8_t protocol;
    213         /** A checksum of the header only.
    214          *  Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.
    215          *  The checksum algorithm is: The checksum field is the 16~bit one's complement of the one's complement sum of all 16~bit words in the header.
    216          *  For purposes of computing the checksum, the value of the checksum field is zero.
    217          */
    218168        uint16_t header_checksum;
    219         /** The source address.
    220          */
    221169        uint32_t source_address;
    222         /** The destination address.
    223          */
    224170        uint32_t destination_address;
    225171} __attribute__ ((packed));
    226172
    227173/** Internet option header.
    228  *  Only type field is always valid.
    229  *  Other fields' validity depends on the option type.
    230  */
    231 struct ip_option{
    232         /** A single octet of option-type.
    233          */
     174 *
     175 * Only type field is always valid.
     176 * Other fields' validity depends on the option type.
     177 */
     178struct ip_option {
    234179        uint8_t type;
    235         /** An option length octet.
    236          */
    237180        uint8_t length;
    238         /** A~pointer.
    239          */
    240181        uint8_t pointer;
     182
    241183#ifdef ARCH_IS_BIG_ENDIAN
    242         /** The number of IP modules that cannot register timestamps due to lack of space.
    243          */
    244         uint8_t overflow:4;
    245         /** Various internet timestamp control flags.
    246          */
    247         uint8_t flags:4;
     184        uint8_t overflow : 4;
     185        uint8_t flags : 4;
    248186#else
    249         /** Various internet timestamp control flags.
    250          */
    251         uint8_t flags:4;
    252         /** The number of IP modules that cannot register timestamps due to lack of space.
    253          */
    254         uint8_t overflow:4;
     187        uint8_t flags : 4;
     188        uint8_t overflow : 4;
    255189#endif
    256190} __attribute__ ((packed));
    257191
    258 /** Internet version 4 pseudo header.
    259  */
    260 struct ipv4_pseudo_header{
    261         /** The source address.
    262          */
     192/** Internet version 4 pseudo header. */
     193struct ipv4_pseudo_header {
    263194        uint32_t source_address;
    264         /** The destination address.
    265          */
    266195        uint32_t destination_address;
    267         /** Reserved byte.
    268          *  Must be zero.
    269          */
    270196        uint8_t reserved;
    271         /** This field indicates the next level protocol used in the data portion of the internet datagram.
    272          */
    273197        uint8_t protocol;
    274         /** Data length is the length of the datagram, measured in octets.
    275          */
    276198        uint16_t data_length;
    277199} __attribute__ ((packed));
  • uspace/lib/net/include/ip_interface.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup ip
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    33 #ifndef __NET_IP_INTERFACE_H__
    34 #define __NET_IP_INTERFACE_H__
     33#ifndef LIBNET_IP_INTERFACE_H_
     34#define LIBNET_IP_INTERFACE_H_
    3535
    3636#include <net/socket_codes.h>
     
    5555
    5656/** @name IP module interface
    57  *  This interface is used by other modules.
     57 * This interface is used by other modules.
    5858 */
    5959/*@{*/
    6060
    6161/** The transport layer notification function type definition.
    62  *  Notifies the transport layer modules about the received packet/s.
    63  *  @param[in] device_id The device identifier.
    64  *  @param[in] packet The received packet or the received packet queue.
    65  *  @param[in] receiver The receiving module service.
    66  *  @param[in] error The packet error reporting service. Prefixes the received packet.
    67  *  @returns EOK on success.
     62 *
     63 * Notifies the transport layer modules about the received packet/s.
     64 *
     65 * @param[in] device_id The device identifier.
     66 * @param[in] packet    The received packet or the received packet queue.
     67 * @param[in] receiver  The receiving module service.
     68 * @param[in] error     The packet error reporting service. Prefixes the
     69 *                      received packet.
     70 * @return              EOK on success.
    6871 */
    69 typedef int     (*tl_received_msg_t)(device_id_t device_id, packet_t packet, services_t receiver, services_t error);
     72typedef int (*tl_received_msg_t)(device_id_t device_id, packet_t *packet,
     73    services_t receiver, services_t error);
    7074
    71 /** Creates bidirectional connection with the ip module service and registers the message receiver.
    72  *  @param[in] service The IP module service.
    73  *  @param[in] protocol The transport layer protocol.
    74  *  @param[in] me The requesting module service.
    75  *  @param[in] receiver The message receiver. Used for remote connection.
    76  *  @returns The phone of the needed service.
    77  *  @returns EOK on success.
    78  *  @returns Other error codes as defined for the bind_service() function.
    79  */
    80 extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver);
    81 
    82 /** Connects to the IP module.
    83  *  @param service The IP module service. Ignored parameter.
    84  *  @returns The IP module phone on success.
    85  */
    86 extern int ip_connect_module(services_t service);
     75extern int ip_bind_service(services_t, int, services_t, async_client_conn_t);
     76extern int ip_connect_module(services_t);
    8777
    8878/*@}*/
  • uspace/lib/net/include/ip_remote.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup ip
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
    33 #ifndef __NET_IP_REMOTE_H__
    34 #define __NET_IP_REMOTE_H__
     33#ifndef LIBNET_IP_REMOTE_H_
     34#define LIBNET_IP_REMOTE_H_
    3535
    3636#include <ipc/services.h>
     
    4444
    4545extern int ip_set_gateway_req_remote(int, device_id_t, in_addr_t);
    46 extern int ip_packet_size_req_remote(int, device_id_t, packet_dimension_ref);
    47 extern int ip_received_error_msg_remote(int, device_id_t, packet_t, services_t,
     46extern int ip_packet_size_req_remote(int, device_id_t, packet_dimension_t *);
     47extern int ip_received_error_msg_remote(int, device_id_t, packet_t *, services_t,
    4848    services_t);
    4949extern int ip_device_req_remote(int, device_id_t, services_t);
    5050extern int ip_add_route_req_remote(int, device_id_t, in_addr_t, in_addr_t,
    5151    in_addr_t);
    52 extern int ip_send_msg_remote(int, device_id_t, packet_t, services_t,
     52extern int ip_send_msg_remote(int, device_id_t, packet_t *, services_t,
    5353    services_t);
    5454extern int ip_get_route_req_remote(int, ip_protocol_t, const struct sockaddr *,
  • uspace/lib/net/include/net_hardware.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_nil
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Hardware types according to the on-line IANA - Address Resolution Protocol (ARP) Parameters - <http://www.iana.org/assignments/arp-parameters/arp-parameters.xml>, cited January 14 2009.
     34 * Hardware types according to the on-line IANA - Address Resolution Protocol
     35 * (ARP) Parameters
     36 * http://www.iana.org/assignments/arp-parameters/arp-parameters.xml,
     37 * cited January 14 2009.
    3538 */
    3639
    37 #ifndef __NET_HW_TYPES_H__
    38 #define __NET_HW_TYPES_H__
     40#ifndef LIBNET_NET_HARDWARE_H_
     41#define LIBNET_NET_HARDWARE_H_
    3942
    4043#include <sys/types.h>
    4144
    42 /** Network interface layer type type definition.
    43  */
    44 typedef uint8_t hw_type_t;
     45/** Network interface layer type type definition. */
     46typedef uint8_t hw_type_t;
    4547
    46 /** @name Network interface layer types definitions
    47  */
     48/** @name Network interface layer types definitions */
    4849/*@{*/
    4950
    50 /** Ethernet (10Mb) hardware type.
    51  */
     51/** Ethernet (10Mb) hardware type. */
    5252#define HW_ETHER                1
    53 
    54 /** Experimental Ethernet (3Mb) hardware type.
    55  */
    56 #define HW_EETHER               2
    57 
    58 /** Amateur Radio AX.25 hardware type.
    59  */
    60 #define HW_AX25         3
    61 
    62 /** Proteon ProNET Token Ring hardware type.
    63  */
    64 #define HW_PRONET               4
    65 
    66 /** Chaos hardware type.
    67  */
    68 #define HW_CHAOS                5
    69 
    70 /** IEEE 802 Networks hardware type.
    71  */
    72 #define HW_IEEE802              6
    73 
    74 /** ARCNET hardware type.
    75  */
    76 #define HW_ARCNET               7
    77 
    78 /** Hyperchannel hardware type.
    79  */
    80 #define HW_Hyperchannel         8
    81 
    82 /** Lanstar hardware type.
    83  */
    84 #define HW_Lanstar              9
    85 
    86 /** Autonet Short Address hardware type.
    87  */
    88 #define HW_ASA          10
    89 
    90 /** LocalTalk hardware type.
    91  */
    92 #define HW_LocalTalk            11
    93 
    94 /** LocalNet (IBM PCNet or SYTEK LocalNET) hardware type.
    95  */
    96 #define HW_LocalNet             12
    97 
    98 /** Ultra link hardware type.
    99  */
    100 #define HW_Ultra_link           13
    101 
    102 /** SMDS hardware type.
    103  */
    104 #define HW_SMDS         14
    105 
    106 /** Frame Relay DLCI hardware type.
    107  */
    108 #define HW_DLCI         15
    109 
    110 /** Asynchronous Transmission Mode (ATM) hardware type.
    111  */
    112 #define HW_ATM          16
    113 
    114 /** HDLC hardware type.
    115  */
    116 #define HW_HDLC         17
    117 
    118 /** Fibre Channel hardware type.
    119  */
    120 #define HW_Fibre_Channel                18
    121 
    122 /** Asynchronous Transmission Mode (ATM) hardware type.
    123  */
    124 #define HW_ATM2         19
    125 
    126 /** Serial Line hardware type.
    127  */
    128 #define HW_Serial_Line          20
    129 
    130 /** Asynchronous Transmission Mode (ATM) hardware type.
    131  */
    132 #define HW_ATM3         21
    133 
    134 /** MIL-STD-188-220 hardware type.
    135  */
    136 #define HW_MIL_STD_188_220              22
    137 
    138 /** Metricom hardware type.
    139  */
    140 #define HW_METRICOM             23
    141 
    142 /** IEEE 1394.1995 hardware type.
    143  */
    144 #define HW_IEEE1394             24
    145 
    146 /** MAPOS hardware type.
    147  */
    148 #define HW_MAPOS                25
    149 
    150 /** Twinaxial hardware type.
    151  */
    152 #define HW_Twinaxial            26
    153 
    154 /** EUI-64 hardware type.
    155  */
    156 #define HW_EUI64                27
    157 
    158 /** HIPARP hardware type.
    159  */
    160 #define HW_HIPARP               28
    161 
    162 /** IP and ARP over ISO 7816-3 hardware type.
    163  */
    164 #define HW_ISO_7816_3           29
    165 
    166 /** ARPSec hardware type.
    167  */
    168 #define HW_ARPSec               30
    169 
    170 /** IPsec tunnel hardware type.
    171  */
    172 #define HW_IPsec_tunnel         31
    173 
    174 /** InfiniBand (TM) hardware type.
    175  */
    176 #define HW_INFINIBAND           32
    177 
    178 /** TIA-102 Project 25 Common Air Interface (CAI) hardware type.
    179  */
    180 #define HW_CAI          33
    181 
    182 /** Wiegand Interface hardware type.
    183  */
    184 #define HW_Wiegand              34
    185 
    186 /** Pure IP hardware type.
    187  */
    188 #define HW_Pure_IP              35
    18953
    19054/*@}*/
     
    19458/** @}
    19559 */
     60
  • uspace/lib/net/include/net_interface.h

    ra93d79a r8fb1bf82  
    4444/*@{*/
    4545
    46 extern int net_get_device_conf_req(int, device_id_t, measured_string_ref *,
     46extern int net_get_device_conf_req(int, device_id_t, measured_string_t **,
    4747    size_t, char **);
    48 extern int net_get_conf_req(int, measured_string_ref *, size_t, char **);
    49 extern void net_free_settings(measured_string_ref, char *);
     48extern int net_get_conf_req(int, measured_string_t **, size_t, char **);
     49extern void net_free_settings(measured_string_t *, char *);
    5050extern int net_connect_module(void);
    5151
  • uspace/lib/net/include/netif_interface.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup netif
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
    33 #ifndef __NET_NETIF_INTERFACE_H__
    34 #define __NET_NETIF_INTERFACE_H__
     33#ifndef LIBNET_NETIF_INTERFACE_H_
     34#define LIBNET_NETIF_INTERFACE_H_
    3535
    3636#include <netif_remote.h>
  • uspace/lib/net/include/netif_local.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup netif
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    3636 */
    3737
    38 #ifndef __NET_NETIF_LOCAL_H__
    39 #define __NET_NETIF_LOCAL_H__
     38#ifndef NET_NETIF_LOCAL_H_
     39#define NET_NETIF_LOCAL_H_
    4040
    4141#include <async.h>
     
    4343#include <ipc/ipc.h>
    4444#include <ipc/services.h>
    45 #include <err.h>
    4645
    4746#include <adt/measured_strings.h>
     
    4948#include <net/packet.h>
    5049
    51 /** Network interface device specific data.
    52  *
    53  */
     50/** Network interface device specific data. */
    5451typedef struct {
    5552        device_id_t device_id;  /**< Device identifier. */
     
    6764DEVICE_MAP_DECLARE(netif_device_map, netif_device_t);
    6865
    69 /** Network interface module skeleton global data.
    70  *
    71  */
     66/** Network interface module skeleton global data. */
    7267typedef struct {
    7368        int net_phone;                  /**< Networking module phone. */
     
    8176 *
    8277 * This function has to be implemented in user code.
    83  *
    8478 */
    8579extern int netif_initialize(void);
     
    8983 * This has to be implemented in user code.
    9084 *
    91  * @param[in] device_id The device identifier.
    92  * @param[in] irq       The device interrupt number.
    93  * @param[in] io        The device input/output address.
    94  *
    95  * @return EOK on success.
    96  * @return Other error codes as defined for the find_device() function.
    97  * @return Other error codes as defined for the specific module message
    98  *         implementation.
    99  *
     85 * @param[in] device_id The device identifier.
     86 * @param[in] irq       The device interrupt number.
     87 * @param[in] io        The device input/output address.
     88 *
     89 * @return              EOK on success.
     90 * @return              Other error codes as defined for the find_device()
     91 *                      function.
     92 * @return              Other error codes as defined for the specific module
     93 *                      message implementation.
    10094 */
    10195extern int netif_probe_message(device_id_t device_id, int irq, uintptr_t io);
     
    10599 * This has to be implemented in user code.
    106100 *
    107  * @param[in] device_id The device identifier.
    108  * @param[in] packet    The packet queue.
    109  * @param[in] sender    The sending module service.
    110  *
    111  * @return EOK on success.
    112  * @return EFORWARD if the device is not active (in the NETIF_ACTIVE state).
    113  * @return Other error codes as defined for the find_device() function.
    114  * @return Other error codes as defined for the specific module message
    115  *         implementation.
    116  *
    117  */
    118 extern int netif_send_message(device_id_t device_id, packet_t packet,
     101 * @param[in] device_id The device identifier.
     102 * @param[in] packet    The packet queue.
     103 * @param[in] sender    The sending module service.
     104 *
     105 * @return              EOK on success.
     106 * @return              EFORWARD if the device is not active (in the
     107 *                      NETIF_ACTIVE state).
     108 * @return              Other error codes as defined for the find_device()
     109 *                      function.
     110 * @return              Other error codes as defined for the specific module
     111 *                      message implementation.
     112 */
     113extern int netif_send_message(device_id_t device_id, packet_t *packet,
    119114    services_t sender);
    120115
     
    123118 * This has to be implemented in user code.
    124119 *
    125  * @param[in] device The device structure.
    126  *
    127  * @return EOK on success.
    128  * @return Other error codes as defined for the find_device() function.
    129  * @return Other error codes as defined for the specific module message
    130  *         implementation.
    131  *
     120 * @param[in] device    The device structure.
     121 *
     122 * @return              EOK on success.
     123 * @return              Other error codes as defined for the find_device()
     124 *                      function.
     125 * @return              Other error codes as defined for the specific module
     126 *                      message implementation.
    132127 */
    133128extern int netif_start_message(netif_device_t *device);
     
    137132 * This has to be implemented in user code.
    138133 *
    139  * @param[in] device The device structure.
    140  *
    141  * @return EOK on success.
    142  * @return Other error codes as defined for the find_device() function.
    143  * @return Other error codes as defined for the specific module message
    144  *         implementation.
    145  *
     134 * @param[in] device    The device structure.
     135 *
     136 * @return              EOK on success.
     137 * @return              Other error codes as defined for the find_device()
     138 *                      function.
     139 * @return              Other error codes as defined for the specific module
     140 *                      message implementation.
    146141 */
    147142extern int netif_stop_message(netif_device_t *device);
     
    151146 * This has to be implemented in user code.
    152147 *
    153  * @param[in]  device_id The device identifier.
    154  * @param[out] address   The device local hardware address.
    155  *
    156  * @return EOK on success.
    157  * @return EBADMEM if the address parameter is NULL.
    158  * @return ENOENT if there no such device.
    159  * @return Other error codes as defined for the find_device() function.
    160  * @return Other error codes as defined for the specific module message
    161  *         implementation.
    162  *
     148 * @param[in] device_id The device identifier.
     149 * @param[out] address  The device local hardware address.
     150 *
     151 * @return              EOK on success.
     152 * @return              EBADMEM if the address parameter is NULL.
     153 * @return              ENOENT if there no such device.
     154 * @return              Other error codes as defined for the find_device()
     155 *                      function.
     156 * @return              Other error codes as defined for the specific module
     157 *                      message implementation.
    163158 */
    164159extern int netif_get_addr_message(device_id_t device_id,
    165     measured_string_ref address);
     160    measured_string_t *address);
    166161
    167162/** Process the netif driver specific message.
     
    170165 * skeleton. This has to be implemented in user code.
    171166 *
    172  * @param[in]  callid       The message identifier.
    173  * @param[in]  call         The message parameters.
    174  * @param[out] answer       The message answer parameters.
     167 * @param[in] callid    The message identifier.
     168 * @param[in] call      The message parameters.
     169 * @param[out] answer   The message answer parameters.
    175170 * @param[out] answer_count The last parameter for the actual answer in
    176  *                          the answer parameter.
    177  *
    178  * @return EOK on success.
    179  * @return ENOTSUP if the message is not known.
    180  * @return Other error codes as defined for the specific module message
    181  *         implementation.
    182  *
     171 *                      the answer parameter.
     172 *
     173 * @return              EOK on success.
     174 * @return              ENOTSUP if the message is not known.
     175 * @return              Other error codes as defined for the specific module
     176 *                      message implementation.
    183177 */
    184178extern int netif_specific_message(ipc_callid_t callid, ipc_call_t *call,
     
    189183 * This has to be implemented in user code.
    190184 *
    191  * @param[in]  device_id The device identifier.
    192  * @param[out] stats     The device usage statistics.
    193  *
    194  * @return EOK on success.
    195  * @return Other error codes as defined for the find_device() function.
    196  * @return Other error codes as defined for the specific module message
    197  *         implementation.
    198  *
     185 * @param[in] device_id The device identifier.
     186 * @param[out] stats    The device usage statistics.
     187 *
     188 * @return              EOK on success.
     189 * @return              Other error codes as defined for the find_device()
     190 *                      function.
     191 * @return              Other error codes as defined for the specific module
     192 *                      message implementation.
    199193 */
    200194extern int netif_get_device_stats(device_id_t device_id,
    201     device_stats_ref stats);
    202 
    203 extern int netif_get_addr_req_local(int, device_id_t, measured_string_ref *,
     195    device_stats_t *stats);
     196
     197extern int netif_get_addr_req_local(int, device_id_t, measured_string_t **,
    204198    char **);
    205199extern int netif_probe_req_local(int, device_id_t, int, int);
    206 extern int netif_send_msg_local(int, device_id_t, packet_t, services_t);
     200extern int netif_send_msg_local(int, device_id_t, packet_t *, services_t);
    207201extern int netif_start_req_local(int, device_id_t);
    208202extern int netif_stop_req_local(int, device_id_t);
    209 extern int netif_stats_req_local(int, device_id_t, device_stats_ref);
     203extern int netif_stats_req_local(int, device_id_t, device_stats_t *);
    210204extern int netif_bind_service_local(services_t, device_id_t, services_t,
    211205    async_client_conn_t);
    212206
    213207extern int find_device(device_id_t, netif_device_t **);
    214 extern void null_device_stats(device_stats_ref);
     208extern void null_device_stats(device_stats_t *);
    215209extern void netif_pq_release(packet_id_t);
    216 extern packet_t netif_packet_get_1(size_t);
     210extern packet_t *netif_packet_get_1(size_t);
    217211extern int netif_init_module(async_client_conn_t);
    218212
  • uspace/lib/net/include/netif_remote.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup netif
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
    33 #ifndef __NET_NETIF_REMOTE_H__
    34 #define __NET_NETIF_REMOTE_H__
     33#ifndef LIBNET_NETIF_REMOTE_H_
     34#define LIBNET_NETIF_REMOTE_H_
    3535
     36#include <async.h>
    3637#include <ipc/services.h>
    3738#include <adt/measured_strings.h>
     39
    3840#include <net/device.h>
     41#include <net/packet.h>
    3942
    40 extern int netif_get_addr_req_remote(int, device_id_t, measured_string_ref *,
     43extern int netif_get_addr_req_remote(int, device_id_t, measured_string_t **,
    4144    char **);
    4245extern int netif_probe_req_remote(int, device_id_t, int, int);
    43 extern int netif_send_msg_remote(int, device_id_t, packet_t, services_t);
     46extern int netif_send_msg_remote(int, device_id_t, packet_t *, services_t);
    4447extern int netif_start_req_remote(int, device_id_t);
    4548extern int netif_stop_req_remote(int, device_id_t);
    46 extern int netif_stats_req_remote(int, device_id_t, device_stats_ref);
     49extern int netif_stats_req_remote(int, device_id_t, device_stats_t *);
    4750extern int netif_bind_service_remote(services_t, device_id_t, services_t,
    4851    async_client_conn_t);
  • uspace/lib/net/include/nil_interface.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_nil
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    33 #ifndef __NET_NIL_INTERFACE_H__
    34 #define __NET_NIL_INTERFACE_H__
     33#ifndef LIBNET_NIL_INTERFACE_H_
     34#define LIBNET_NIL_INTERFACE_H_
    3535
    3636#include <async.h>
     
    4747
    4848#define nil_packet_size_req(nil_phone, device_id, packet_dimension) \
    49         generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, device_id, \
    50             packet_dimension)
     49        generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, \
     50            device_id, packet_dimension)
    5151
    5252#define nil_get_addr_req(nil_phone, device_id, address, data) \
  • uspace/lib/net/include/nil_local.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_nil
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
     
    3636 */
    3737
    38 #ifndef __NET_NIL_LOCAL_H__
    39 #define __NET_NIL_LOCAL_H__
     38#ifndef LIBNET_NIL_LOCAL_H_
     39#define LIBNET_NIL_LOCAL_H_
    4040
    4141#include <ipc/ipc.h>
     
    4545 * Is called by the module_start() function.
    4646 *
    47  * @param[in] net_phone The networking moduel phone.
    48  *
    49  * @return EOK on success.
    50  * @return Other error codes as defined for each specific module initialize function.
    51  *
     47 * @param[in] net_phone The networking moduel phone.
     48 * @return              EOK on success.
     49 * @return              Other error codes as defined for each specific module
     50 *                      initialize function.
    5251 */
    5352extern int nil_initialize(int);
    5453
     54/** Notify the network interface layer about the device state change.
     55 *
     56 * @param[in] nil_phone The network interface layer phone.
     57 * @param[in] device_id The device identifier.
     58 * @param[in] state     The new device state.
     59 * @return              EOK on success.
     60 * @return              Other error codes as defined for each specific module
     61 *                      device state function.
     62 */
    5563extern int nil_device_state_msg_local(int, device_id_t, int);
    56 extern int nil_received_msg_local(int, device_id_t, packet_t, services_t);
     64
     65
     66/** Pass the packet queue to the network interface layer.
     67 *
     68 * Process and redistribute the received packet queue to the registered
     69 * upper layers.
     70 *
     71 * @param[in] nil_phone The network interface layer phone.
     72 * @param[in] device_id The source device identifier.
     73 * @param[in] packet    The received packet or the received packet queue.
     74 * @param target        The target service. Ignored parameter.
     75 * @return              EOK on success.
     76 * @return              Other error codes as defined for each specific module
     77 *                      received function.
     78 */
     79extern int nil_received_msg_local(int, device_id_t, packet_t *, services_t);
    5780
    5881/** Message processing function.
    5982 *
    60  * @param[in]  name         Module name.
    61  * @param[in]  callid       The message identifier.
    62  * @param[in]  call         The message parameters.
    63  * @param[out] answer       The message answer parameters.
    64  * @param[out] answer_count The last parameter for the actual answer
    65  *                          in the answer parameter.
    66  *
    67  * @return EOK on success.
    68  * @return ENOTSUP if the message is not known.
    69  * @return Other error codes as defined for each specific
    70  *         module message function.
     83 * @param[in] name      Module name.
     84 * @param[in] callid    The message identifier.
     85 * @param[in] call      The message parameters.
     86 * @param[out] answer   The message answer parameters.
     87 * @param[out] answer_count The last parameter for the actual answer in the
     88 *                      answer parameter.
     89 * @return              EOK on success.
     90 * @return              ENOTSUP if the message is not known.
     91 * @return              Other error codes as defined for each specific module
     92 *                      message function.
    7193 *
    7294 * @see nil_interface.h
    7395 * @see IS_NET_NIL_MESSAGE()
     96 */
     97extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *,
     98    ipc_call_t *, int *);
     99
     100/** Pass the parameters to the module specific nil_message() function.
    74101 *
     102 * @param[in] name      Module name.
     103 * @param[in] callid    The message identifier.
     104 * @param[in] call      The message parameters.
     105 * @param[out] answer   The message answer parameters.
     106 * @param[out] answer_count The last parameter for the actual answer in the
     107 *                      answer parameter.
     108 * @return              EOK on success.
     109 * @return              ENOTSUP if the message is not known.
     110 * @return              Other error codes as defined for each specific module
     111 *                      message function.
    75112 */
    76 extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *,
    77     int *);
    78 
    79113extern int nil_module_message_standalone(const char *, ipc_callid_t,
    80114    ipc_call_t *, ipc_call_t *, int *);
     115
     116/** Start the standalone nil layer module.
     117 *
     118 * Initialize the client connection serving function, initialize
     119 * the module, register the module service and start the async
     120 * manager, processing IPC messages in an infinite loop.
     121 *
     122 * @param[in] client_connection The client connection processing function.
     123 *                      The module skeleton propagates its own one.
     124 * @return              EOK on success.
     125 * @return              Other error codes as defined for the pm_init() function.
     126 * @return              Other error codes as defined for the nil_initialize()
     127 *                      function.
     128 * @return              Other error codes as defined for the REGISTER_ME() macro
     129 *                      function.
     130 */
    81131extern int nil_module_start_standalone(async_client_conn_t);
    82132
  • uspace/lib/net/include/nil_remote.h

    ra93d79a r8fb1bf82  
    3939
    4040extern int nil_device_state_msg_remote(int, device_id_t, int);
    41 extern int nil_received_msg_remote(int, device_id_t, packet_t, services_t);
     41extern int nil_received_msg_remote(int, device_id_t, packet_t *, services_t);
    4242
    4343#endif
  • uspace/lib/net/include/packet_client.h

    ra93d79a r8fb1bf82  
    6161 * @param[in] type      The type to be allocated at the beginning of the packet
    6262 *                      content.
    63  * @returns             The typed pointer to the allocated memory.
    64  * @returns             NULL if the packet is not valid.
    65  * @returns             NULL if there is not enough memory left.
     63 * @return              The typed pointer to the allocated memory.
     64 * @return              NULL if the packet is not valid.
     65 * @return              NULL if there is not enough memory left.
    6666 */
    6767#define PACKET_PREFIX(packet, type) \
     
    7676 * @param[in] type      The type to be allocated at the end of the packet
    7777 *                      content.
    78  * @returns             The typed pointer to the allocated memory.
    79  * @returns             NULL if the packet is not valid.
    80  * @returns             NULL if there is not enough memory left.
     78 * @return              The typed pointer to the allocated memory.
     79 * @return              NULL if the packet is not valid.
     80 * @return              NULL if there is not enough memory left.
    8181 */
    8282#define PACKET_SUFFIX(packet, type) \
     
    9292 * @param[in] suffix    The type of the suffix to be removed from the end of
    9393 *                      the packet content.
    94  * @returns             EOK on success.
    95  * @returns             EINVAL if the packet is not valid.
    96  * @returns             ENOMEM if there is not enough memory left.
     94 * @return              EOK on success.
     95 * @return              EINVAL if the packet is not valid.
     96 * @return              ENOMEM if there is not enough memory left.
    9797 */
    9898#define PACKET_TRIM(packet, prefix, suffix) \
    9999        packet_trim((packet), sizeof(prefix), sizeof(suffix))
    100100
    101 extern void *packet_prefix(packet_t, size_t);
    102 extern void *packet_suffix(packet_t, size_t);
    103 extern int packet_trim(packet_t, size_t, size_t);
    104 extern int packet_copy_data(packet_t, const void *, size_t);
    105 extern packet_id_t packet_get_id(const packet_t);
    106 extern size_t packet_get_data_length(const packet_t);
    107 extern void *packet_get_data(const packet_t);
    108 extern int packet_get_addr(const packet_t, uint8_t **, uint8_t **);
    109 extern int packet_set_addr(packet_t, const uint8_t *, const uint8_t *, size_t);
    110 extern packet_t packet_get_copy(int phone, packet_t packet);
     101extern void *packet_prefix(packet_t *, size_t);
     102extern void *packet_suffix(packet_t *, size_t);
     103extern int packet_trim(packet_t *, size_t, size_t);
     104extern int packet_copy_data(packet_t *, const void *, size_t);
     105extern packet_id_t packet_get_id(const packet_t *);
     106extern size_t packet_get_data_length(const packet_t *);
     107extern void *packet_get_data(const packet_t *);
     108extern int packet_get_addr(const packet_t *, uint8_t **, uint8_t **);
     109extern int packet_set_addr(packet_t *, const uint8_t *, const uint8_t *, size_t);
     110extern packet_t *packet_get_copy(int, packet_t *);
    111111
    112112/*@}*/
  • uspace/lib/net/include/packet_remote.h

    ra93d79a r8fb1bf82  
    3737#include <sys/types.h>
    3838
    39 extern int packet_translate_remote(int, packet_ref, packet_id_t);
    40 extern packet_t packet_get_4_remote(int, size_t, size_t, size_t, size_t);
    41 extern packet_t packet_get_1_remote(int, size_t);
     39extern int packet_translate_remote(int, packet_t **, packet_id_t);
     40extern packet_t *packet_get_4_remote(int, size_t, size_t, size_t, size_t);
     41extern packet_t *packet_get_1_remote(int, size_t);
    4242extern void pq_release_remote(int, packet_id_t);
    4343
  • uspace/lib/net/include/protocol_map.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_nil
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Internetwork layer services - network interface layer service type translation.
     34 * Internetwork layer services - network interface layer service type
     35 * translation.
    3536 */
    3637
    37 #ifndef __NET_PROTOCOL_MAP_H__
    38 #define __NET_PROTOCOL_MAP_H__
    39 
    40 #include <ipc/services.h>
     38#ifndef LIBNET_PROTOCOL_MAP_H_
     39#define LIBNET_PROTOCOL_MAP_H_
    4140
    4241#include <ethernet_lsap.h>
     
    4443#include <net_hardware.h>
    4544
    46 /** Maps the internetwork layer service to the network interface layer type.
    47  *  @param[in] nil Network interface layer service.
    48  *  @param[in] il Internetwork layer service.
    49  *  @returns Network interface layer type of the internetworking layer service.
    50  *  @returns 0 if mapping is not found.
    51  */
    52 static inline eth_type_t protocol_map(services_t nil, services_t il){
    53         switch(nil){
    54                 case SERVICE_ETHERNET:
    55                 case SERVICE_DP8390:
    56                         switch(il){
    57                                 case SERVICE_IP:
    58                                         return ETH_P_IP;
    59                                 case SERVICE_ARP:
    60                                         return ETH_P_ARP;
    61                                 default:
    62                                         return 0;
    63                         }
    64                 default:
    65                         return 0;
    66         }
    67 }
     45#include <ipc/services.h>
    6846
    69 /** Maps the network interface layer type to the internetwork layer service.
    70  *  @param[in] nil Network interface layer service.
    71  *  @param[in] protocol Network interface layer type.
    72  *  @returns Internetwork layer service of the network interface layer type.
    73  *  @returns 0 if mapping is not found.
    74  */
    75 static inline services_t protocol_unmap(services_t nil, int protocol){
    76         switch(nil){
    77                 case SERVICE_ETHERNET:
    78                 case SERVICE_DP8390:
    79                         switch(protocol){
    80                                 case ETH_P_IP:
    81                                         return SERVICE_IP;
    82                                 case ETH_P_ARP:
    83                                         return SERVICE_ARP;
    84                                 default:
    85                                         return 0;
    86                         }
    87                 default:
    88                         return 0;
    89         }
    90 }
    91 
    92 /** Maps the link service access point identifier to the Ethernet protocol identifier.
    93  *  @param[in] lsap Link service access point identifier.
    94  *  @returns Ethernet protocol identifier of the link service access point identifier.
    95  *  @returns ETH_LSAP_NULL if mapping is not found.
    96  */
    97 static inline eth_type_t lsap_map(eth_lsap_t lsap){
    98         switch(lsap){
    99                 case ETH_LSAP_IP:
    100                         return ETH_P_IP;
    101                 case ETH_LSAP_ARP:
    102                         return ETH_P_ARP;
    103                 default:
    104                         return ETH_LSAP_NULL;
    105         }
    106 }
    107 
    108 /** Maps the Ethernet protocol identifier to the link service access point identifier.
    109  *  @param[in] ethertype Ethernet protocol identifier.
    110  *  @returns Link service access point identifier.
    111  *  @returns 0 if mapping is not found.
    112  */
    113 static inline eth_lsap_t lsap_unmap(eth_type_t ethertype){
    114         switch(ethertype){
    115                 case ETH_P_IP:
    116                         return ETH_LSAP_IP;
    117                 case ETH_P_ARP:
    118                         return ETH_LSAP_ARP;
    119                 default:
    120                         return 0;
    121         }
    122 }
    123 
    124 /** Maps the network interface layer services to the hardware types.
    125  *  @param[in] nil The network interface service.
    126  *  @returns The hardware type of the network interface service.
    127  *  @returns 0 if mapping is not found.
    128  */
    129 static inline hw_type_t hardware_map(services_t nil){
    130         switch(nil){
    131                 case SERVICE_ETHERNET:
    132                 case SERVICE_DP8390:
    133                         return HW_ETHER;
    134                 default:
    135                         return 0;
    136         }
    137 }
     47extern eth_type_t protocol_map(services_t, services_t);
     48extern services_t protocol_unmap(services_t, int);
     49extern eth_type_t lsap_map(eth_lsap_t);
     50extern eth_lsap_t lsap_unmap(eth_type_t);
     51extern hw_type_t hardware_map(services_t);
    13852
    13953#endif
  • uspace/lib/net/include/socket_core.h

    ra93d79a r8fb1bf82  
    6666typedef struct socket_core socket_core_t;
    6767
    68 /** Type definition of the socket core pointer.
    69  * @see socket_core
    70  */
    71 typedef socket_core_t *socket_core_ref;
    72 
    7368/** Type definition of the socket port.
    7469 * @see socket_port
    7570 */
    7671typedef struct socket_port socket_port_t;
    77 
    78 /** Type definition of the socket port pointer.
    79  * @see socket_port
    80  */
    81 typedef socket_port_t *socket_port_ref;
    8272
    8373/** Socket core. */
     
    111101 * the other use the remote addresses.
    112102 */
    113 GENERIC_CHAR_MAP_DECLARE(socket_port_map, socket_core_ref);
     103GENERIC_CHAR_MAP_DECLARE(socket_port_map, socket_core_t *);
    114104
    115105/** Ports map.
     
    118108INT_MAP_DECLARE(socket_ports, socket_port_t);
    119109
    120 extern void socket_cores_release(int, socket_cores_ref, socket_ports_ref,
    121     void (*)(socket_core_ref));
    122 extern int socket_bind(socket_cores_ref, socket_ports_ref, int, void *, size_t,
     110extern void socket_cores_release(int, socket_cores_t *, socket_ports_t *,
     111    void (*)(socket_core_t *));
     112extern int socket_bind(socket_cores_t *, socket_ports_t *, int, void *, size_t,
    123113    int, int, int);
    124 extern int socket_bind_free_port(socket_ports_ref, socket_core_ref, int, int,
     114extern int socket_bind_free_port(socket_ports_t *, socket_core_t *, int, int,
    125115    int);
    126 extern int socket_create(socket_cores_ref, int, void *, int *);
    127 extern int socket_destroy(int, int, socket_cores_ref, socket_ports_ref,
    128     void (*)(socket_core_ref));
    129 extern int socket_reply_packets(packet_t, size_t *);
    130 extern socket_core_ref socket_port_find(socket_ports_ref, int, const char *,
     116extern int socket_create(socket_cores_t *, int, void *, int *);
     117extern int socket_destroy(int, int, socket_cores_t *, socket_ports_t *,
     118    void (*)(socket_core_t *));
     119extern int socket_reply_packets(packet_t *, size_t *);
     120extern socket_core_t *socket_port_find(socket_ports_t *, int, const char *,
    131121    size_t);
    132 extern void socket_port_release(socket_ports_ref, socket_core_ref);
    133 extern int socket_port_add(socket_ports_ref, int, socket_core_ref,
     122extern void socket_port_release(socket_ports_t *, socket_core_t *);
     123extern int socket_port_add(socket_ports_t *, int, socket_core_t *,
    134124    const char *, size_t);
    135125
  • uspace/lib/net/include/tl_common.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_tl
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Transport layer common functions.
     34 * Transport layer common functions.
    3535 */
    3636
    37 #ifndef __NET_TL_COMMON_H__
    38 #define __NET_TL_COMMON_H__
     37#ifndef LIBNET_TL_COMMON_H_
     38#define LIBNET_TL_COMMON_H_
     39
     40#include <ipc/services.h>
    3941
    4042#include <net/socket_codes.h>
     
    4446
    4547/** Device packet dimensions.
    46  *  Maps devices to the packet dimensions.
    47  *  @see device.h
     48 * Maps devices to the packet dimensions.
     49 * @see device.h
    4850 */
    4951DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t);
    5052
    51 extern int tl_get_ip_packet_dimension(int, packet_dimensions_ref,
    52     device_id_t, packet_dimension_ref *);
    53 
    54 /** Gets the address port.
    55  *  Supports AF_INET and AF_INET6 address families.
    56  *  @param[in,out] addr The address to be updated.
    57  *  @param[in] addrlen The address length.
    58  *  @param[out] port The set port.
    59  *  @returns EOK on success.
    60  *  @returns EINVAL if the address length does not match the address family.
    61  *  @returns EAFNOSUPPORT if the address family is not supported.
    62  */
    63 extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port);
    64 
    65 /** Updates IP device packet dimensions cache.
    66  *  @param[in,out] packet_dimensions The packet dimensions cache.
    67  *  @param[in] device_id The device identifier.
    68  *  @param[in] content The new maximum content size.
    69  *  @returns EOK on success.
    70  *  @returns ENOENT if the packet dimension is not cached.
    71  */
    72 extern int tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions, device_id_t device_id, size_t content);
    73 
    74 /** Sets the address port.
    75  *  Supports AF_INET and AF_INET6 address families.
    76  *  @param[in,out] addr The address to be updated.
    77  *  @param[in] addrlen The address length.
    78  *  @param[in] port The port to be set.
    79  *  @returns EOK on success.
    80  *  @returns EINVAL if the address length does not match the address family.
    81  *  @returns EAFNOSUPPORT if the address family is not supported.
    82  */
    83 extern int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port);
    84 
    85 /** Prepares the packet for ICMP error notification.
    86  *  Keeps the first packet and releases all the others.
    87  *  Releases all the packets on error.
    88  *  @param[in] packet_phone The packet server module phone.
    89  *  @param[in] icmp_phone The ICMP module phone.
    90  *  @param[in] packet The packet to be send.
    91  *  @param[in] error The packet error reporting service. Prefixes the received packet.
    92  *  @returns EOK on success.
    93  *  @returns ENOENT if no packet may be sent.
    94  */
    95 extern int tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet, services_t error);
    96 
    97 /** Receives data from the socket into a packet.
    98  *  @param[in] packet_phone The packet server module phone.
    99  *  @param[out] packet The new created packet.
    100  *  @param[in] prefix Reserved packet data prefix length.
    101  *  @param[in] dimension The packet dimension.
    102  *  @param[in] addr The destination address.
    103  *  @param[in] addrlen The address length.
    104  *  @returns Number of bytes received.
    105  *  @returns EINVAL if the client does not send data.
    106  *  @returns ENOMEM if there is not enough memory left.
    107  *  @returns Other error codes as defined for the async_data_read_finalize() function.
    108  */
    109 extern int tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix, const packet_dimension_ref dimension, const struct sockaddr * addr, socklen_t addrlen);
     53extern int tl_get_ip_packet_dimension(int, packet_dimensions_t *,
     54    device_id_t, packet_dimension_t **);
     55extern int tl_get_address_port(const struct sockaddr *, int, uint16_t *);
     56extern int tl_update_ip_packet_dimension(packet_dimensions_t *, device_id_t,
     57    size_t);
     58extern int tl_set_address_port(struct sockaddr *, int, uint16_t);
     59extern int tl_prepare_icmp_packet(int, int, packet_t *, services_t);
     60extern int tl_socket_read_packet_data(int, packet_t **, size_t,
     61    const packet_dimension_t *, const struct sockaddr *, socklen_t);
    11062
    11163#endif
  • uspace/lib/net/include/tl_interface.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_tl
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
     
    3535 */
    3636
    37 #ifndef __NET_TL_INTERFACE_H__
    38 #define __NET_TL_INTERFACE_H__
     37#ifndef LIBNET_TL_INTERFACE_H_
     38#define LIBNET_TL_INTERFACE_H_
    3939
    4040#include <async.h>
     
    5252/*@{*/
    5353
    54 /** Notify the remote transport layer modules about the received packet/s.
    55  *
    56  * @param[in] tl_phone  The transport layer module phone used for remote calls.
    57  * @param[in] device_id The device identifier.
    58  * @param[in] packet    The received packet or the received packet queue.
    59  *                      The packet queue is used to carry a fragmented
    60  *                      datagram. The first packet contains the headers,
    61  *                      the others contain only data.
    62  * @param[in] target    The target transport layer module service to be
    63  *                      delivered to.
    64  * @param[in] error     The packet error reporting service. Prefixes the
    65  *                      received packet.
    66  *
    67  * @return EOK on success.
    68  *
    69  */
    70 inline static int tl_received_msg(int tl_phone, device_id_t device_id,
    71     packet_t packet, services_t target, services_t error)
    72 {
    73         return generic_received_msg_remote(tl_phone, NET_TL_RECEIVED, device_id,
    74             packet_get_id(packet), target, error);
    75 }
     54extern int tl_received_msg(int, device_id_t, packet_t *, services_t, services_t);
    7655
    7756/*@}*/
  • uspace/lib/net/include/tl_local.h

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup tl_local
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    33 #ifndef __TL_LOCAL_H__
    34 #define __TL_LOCAL_H__
     33#ifndef LIBNET_TL_LOCAL_H_
     34#define LIBNET_TL_LOCAL_H_
    3535
    3636#include <ipc/ipc.h>
    3737#include <async.h>
    3838
     39/** Starts the TL module.
     40 *
     41 * Initializes the client connection serving function, initializes the module,
     42 * registers the module service and starts the async manager, processing IPC
     43 * messages in an infinite loop.
     44 *
     45 * @param[in] client_connection The client connection processing function. The
     46 *                      module skeleton propagates its own one.
     47 * @return              EOK on successful module termination.
     48 * @return              Other error codes as defined for the module initialize
     49 *                      function.
     50 * @return              Other error codes as defined for the REGISTER_ME() macro
     51 *                      function.
     52 */
    3953extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *,
    4054    ipc_call_t *, int *);
     55
     56
     57/** Processes the TL module message.
     58 *
     59 * @param[in] callid    The message identifier.
     60 * @param[in] call      The message parameters.
     61 * @param[out] answer   The message answer parameters.
     62 * @param[out] answer_count The last parameter for the actual answer in the
     63 *                      answer parameter.
     64 * @return              EOK on success.
     65 * @return              Other error codes as defined for the module's message
     66 *                      standalone function.
     67 */
    4168extern int tl_module_start_standalone(async_client_conn_t);
    4269
  • uspace/lib/net/netif/netif_local.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup netif
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    4343#include <ipc/services.h>
    4444#include <ipc/netif.h>
    45 #include <err.h>
     45#include <errno.h>
    4646
    4747#include <generic.h>
     
    5858DEVICE_MAP_IMPLEMENT(netif_device_map, netif_device_t);
    5959
    60 /** Network interface global data.
    61  */
     60/** Network interface global data. */
    6261netif_globals_t netif_globals;
    6362
     
    6564 *
    6665 * @param[in] netif_phone The network interface phone.
    67  * @param[in] device_id   The device identifier.
    68  * @param[in] irq         The device interrupt number.
    69  * @param[in] io          The device input/output address.
    70  *
    71  * @return EOK on success.
    72  * @return Other errro codes as defined for the netif_probe_message().
    73  *
    74  */
    75 int netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
     66 * @param[in] device_id The device identifier.
     67 * @param[in] irq       The device interrupt number.
     68 * @param[in] io        The device input/output address.
     69 * @return              EOK on success.
     70 * @return              Other error codes as defined for the
     71 *                      netif_probe_message().
     72 */
     73int
     74netif_probe_req_local(int netif_phone, device_id_t device_id, int irq, int io)
    7675{
    7776        fibril_rwlock_write_lock(&netif_globals.lock);
     
    8584 *
    8685 * @param[in] netif_phone The network interface phone.
    87  * @param[in] device_id   The device identifier.
    88  * @param[in] packet      The packet queue.
    89  * @param[in] sender      The sending module service.
    90  *
    91  * @return EOK on success.
    92  * @return Other error codes as defined for the generic_send_msg() function.
    93  *
     86 * @param[in] device_id The device identifier.
     87 * @param[in] packet    The packet queue.
     88 * @param[in] sender    The sending module service.
     89 * @return              EOK on success.
     90 * @return              Other error codes as defined for the generic_send_msg()
     91 *                      function.
    9492 */
    9593int netif_send_msg_local(int netif_phone, device_id_t device_id,
    96     packet_t packet, services_t sender)
     94    packet_t *packet, services_t sender)
    9795{
    9896        fibril_rwlock_write_lock(&netif_globals.lock);
     
    106104 *
    107105 * @param[in] netif_phone The network interface phone.
    108  * @param[in] device_id   The device identifier.
    109  *
    110  * @return EOK on success.
    111  * @return Other error codes as defined for the find_device() function.
    112  * @return Other error codes as defined for the netif_start_message() function.
    113  *
     106 * @param[in] device_id The device identifier.
     107 * @return              EOK on success.
     108 * @return              Other error codes as defined for the find_device()
     109 *                      function.
     110 * @return              Other error codes as defined for the
     111 *                      netif_start_message() function.
    114112 */
    115113int netif_start_req_local(int netif_phone, device_id_t device_id)
    116114{
    117         ERROR_DECLARE;
     115        int rc;
    118116       
    119117        fibril_rwlock_write_lock(&netif_globals.lock);
    120118       
    121119        netif_device_t *device;
    122         if (ERROR_OCCURRED(find_device(device_id, &device))) {
     120        rc = find_device(device_id, &device);
     121        if (rc != EOK) {
    123122                fibril_rwlock_write_unlock(&netif_globals.lock);
    124                 return ERROR_CODE;
     123                return rc;
    125124        }
    126125       
     
    141140 *
    142141 * @param[in] netif_phone The network interface phone.
    143  * @param[in] device_id   The device identifier.
    144  *
    145  * @return EOK on success.
    146  * @return Other error codes as defined for the find_device() function.
    147  * @return Other error codes as defined for the netif_stop_message() function.
    148  *
     142 * @param[in] device_id The device identifier.
     143 * @return              EOK on success.
     144 * @return              Other error codes as defined for the find_device()
     145 *                      function.
     146 * @return              Other error codes as defined for the
     147 *                      netif_stop_message() function.
    149148 */
    150149int netif_stop_req_local(int netif_phone, device_id_t device_id)
    151150{
    152         ERROR_DECLARE;
     151        int rc;
    153152       
    154153        fibril_rwlock_write_lock(&netif_globals.lock);
    155154       
    156155        netif_device_t *device;
    157         if (ERROR_OCCURRED(find_device(device_id, &device))) {
     156        rc = find_device(device_id, &device);
     157        if (rc != EOK) {
    158158                fibril_rwlock_write_unlock(&netif_globals.lock);
    159                 return ERROR_CODE;
     159                return rc;
    160160        }
    161161       
     
    175175/** Return the device usage statistics.
    176176 *
    177  * @param[in]  netif_phone The network interface phone.
    178  * @param[in]  device_id   The device identifier.
    179  * @param[out] stats       The device usage statistics.
    180  *
     177 * @param[in] netif_phone The network interface phone.
     178 * @param[in] device_id The device identifier.
     179 * @param[out] stats    The device usage statistics.
    181180 * @return EOK on success.
    182  *
    183181 */
    184182int netif_stats_req_local(int netif_phone, device_id_t device_id,
    185     device_stats_ref stats)
     183    device_stats_t *stats)
    186184{
    187185        fibril_rwlock_read_lock(&netif_globals.lock);
     
    194192/** Return the device local hardware address.
    195193 *
    196  * @param[in]  netif_phone The network interface phone.
    197  * @param[in]  device_id   The device identifier.
    198  * @param[out] address     The device local hardware address.
    199  * @param[out] data        The address data.
    200  *
    201  * @return EOK on success.
    202  * @return EBADMEM if the address parameter is NULL.
    203  * @return ENOENT if there no such device.
    204  * @return Other error codes as defined for the netif_get_addr_message()
    205  *         function.
    206  *
     194 * @param[in] netif_phone The network interface phone.
     195 * @param[in] device_id The device identifier.
     196 * @param[out] address  The device local hardware address.
     197 * @param[out] data     The address data.
     198 * @return              EOK on success.
     199 * @return              EBADMEM if the address parameter is NULL.
     200 * @return              ENOENT if there no such device.
     201 * @return              Other error codes as defined for the
     202 *                      netif_get_addr_message() function.
    207203 */
    208204int netif_get_addr_req_local(int netif_phone, device_id_t device_id,
    209     measured_string_ref *address, char **data)
    210 {
    211         ERROR_DECLARE;
    212        
    213         if ((!address) || (!data))
     205    measured_string_t **address, char **data)
     206{
     207        int rc;
     208       
     209        if (!address || !data)
    214210                return EBADMEM;
    215211       
     
    217213       
    218214        measured_string_t translation;
    219         if (!ERROR_OCCURRED(netif_get_addr_message(device_id, &translation))) {
     215        rc = netif_get_addr_message(device_id, &translation);
     216        if (rc == EOK) {
    220217                *address = measured_string_copy(&translation);
    221                 ERROR_CODE = (*address) ? EOK : ENOMEM;
     218                rc = (*address) ? EOK : ENOMEM;
    222219        }
    223220       
     
    226223        *data = (**address).value;
    227224       
    228         return ERROR_CODE;
     225        return rc;
    229226}
    230227
    231228/** Find the device specific data.
    232229 *
    233  * @param[in]  device_id The device identifier.
    234  * @param[out] device    The device specific data.
    235  *
    236  * @return EOK on success.
    237  * @return ENOENT if device is not found.
    238  * @return EPERM if the device is not initialized.
    239  *
     230 * @param[in] device_id The device identifier.
     231 * @param[out] device   The device specific data.
     232 * @return              EOK on success.
     233 * @return              ENOENT if device is not found.
     234 * @return              EPERM if the device is not initialized.
    240235 */
    241236int find_device(device_id_t device_id, netif_device_t **device)
     
    256251/** Clear the usage statistics.
    257252 *
    258  * @param[in] stats The usage statistics.
    259  *
    260  */
    261 void null_device_stats(device_stats_ref stats)
     253 * @param[in] stats     The usage statistics.
     254 */
     255void null_device_stats(device_stats_t *stats)
    262256{
    263257        bzero(stats, sizeof(device_stats_t));
     
    266260/** Initialize the netif module.
    267261 *
    268  *  @param[in] client_connection The client connection functio to be
    269  *                               registered.
    270  *
    271  *  @return EOK on success.
    272  *  @return Other error codes as defined for each specific module
    273  *          message function.
    274  *
     262 * @param[in] client_connection The client connection functio to be registered.
     263 * @return              EOK on success.
     264 * @return              Other error codes as defined for each specific module
     265 *                      message function.
    275266 */
    276267int netif_init_module(async_client_conn_t client_connection)
    277268{
    278         ERROR_DECLARE;
     269        int rc;
    279270       
    280271        async_set_client_connection(client_connection);
     
    283274        netif_device_map_initialize(&netif_globals.device_map);
    284275       
    285         ERROR_PROPAGATE(pm_init());
     276        rc = pm_init();
     277        if (rc != EOK)
     278                return rc;
    286279       
    287280        fibril_rwlock_initialize(&netif_globals.lock);
    288         if (ERROR_OCCURRED(netif_initialize())) {
     281       
     282        rc = netif_initialize();
     283        if (rc != EOK) {
    289284                pm_destroy();
    290                 return ERROR_CODE;
     285                return rc;
    291286        }
    292287       
     
    298293 * Prepared for future optimization.
    299294 *
    300  * @param[in] packet_id The packet identifier.
    301  *
     295 * @param[in] packet_id The packet identifier.
    302296 */
    303297void netif_pq_release(packet_id_t packet_id)
     
    308302/** Allocate new packet to handle the given content size.
    309303 *
    310  * @param[in] content The minimum content size.
    311  *
    312  * @return The allocated packet.
    313  * @return NULL if there is an error.
    314  *
    315  */
    316 packet_t netif_packet_get_1(size_t content)
     304 * @param[in] content   The minimum content size.
     305 * @return              The allocated packet.
     306 * @return              NULL if there is an error.
     307 *
     308 */
     309packet_t *netif_packet_get_1(size_t content)
    317310{
    318311        return packet_get_1_remote(netif_globals.net_phone, content);
    319312}
    320313
    321 /** Register the device notification receiver, the network interface layer module.
    322  *
    323  * @param[in] name      Module name.
    324  * @param[in] device_id The device identifier.
    325  * @param[in] phone     The network interface layer module phone.
    326  *
    327  * @return EOK on success.
    328  * @return ENOENT if there is no such device.
    329  * @return ELIMIT if there is another module registered.
    330  *
     314/** Register the device notification receiver, the network interface layer
     315 * module.
     316 *
     317 * @param[in] name      Module name.
     318 * @param[in] device_id The device identifier.
     319 * @param[in] phone     The network interface layer module phone.
     320 * @return              EOK on success.
     321 * @return              ENOENT if there is no such device.
     322 * @return              ELIMIT if there is another module registered.
    331323 */
    332324static int register_message(const char *name, device_id_t device_id, int phone)
    333325{
    334         ERROR_DECLARE;
    335        
    336326        netif_device_t *device;
    337         ERROR_PROPAGATE(find_device(device_id, &device));
    338         if(device->nil_phone > 0)
     327        int rc;
     328       
     329        rc = find_device(device_id, &device);
     330        if (rc != EOK)
     331                return rc;
     332       
     333        if (device->nil_phone > 0)
    339334                return ELIMIT;
    340335       
     
    347342/** Process the netif module messages.
    348343 *
    349  * @param[in]  name         Module name.
    350  * @param[in]  callid       The message identifier.
    351  * @param[in]  call         The message parameters.
    352  * @param[out] answer       The message answer parameters.
    353  * @param[out] answer_count The last parameter for the actual answer
    354  *                          in the answer parameter.
    355  *
    356  * @return EOK on success.
    357  * @return ENOTSUP if the message is not known.
    358  * @return Other error codes as defined for each specific module message function.
     344 * @param[in] name      Module name.
     345 * @param[in] callid    The message identifier.
     346 * @param[in] call      The message parameters.
     347 * @param[out] answer   The message answer parameters.
     348 * @param[out] answer_count The last parameter for the actual answer in the
     349 *                      answer parameter.
     350 * @return              EOK on success.
     351 * @return              ENOTSUP if the message is not known.
     352 * @return              Other error codes as defined for each specific module
     353 *                      message function.
    359354 *
    360355 * @see IS_NET_NETIF_MESSAGE()
     
    364359    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
    365360{
    366         ERROR_DECLARE;
    367        
    368361        size_t length;
    369362        device_stats_t stats;
    370         packet_t packet;
     363        packet_t *packet;
    371364        measured_string_t address;
     365        int rc;
    372366       
    373367        *answer_count = 0;
    374368        switch (IPC_GET_METHOD(*call)) {
    375                 case IPC_M_PHONE_HUNGUP:
    376                         return EOK;
    377                 case NET_NETIF_PROBE:
    378                         return netif_probe_req_local(0, IPC_GET_DEVICE(call),
    379                             NETIF_GET_IRQ(call), NETIF_GET_IO(call));
    380                 case IPC_M_CONNECT_TO_ME:
    381                         fibril_rwlock_write_lock(&netif_globals.lock);
    382                         ERROR_CODE = register_message(name, IPC_GET_DEVICE(call),
    383                             IPC_GET_PHONE(call));
    384                         fibril_rwlock_write_unlock(&netif_globals.lock);
    385                         return ERROR_CODE;
    386                 case NET_NETIF_SEND:
    387                         ERROR_PROPAGATE(packet_translate_remote(netif_globals.net_phone,
    388                             &packet, IPC_GET_PACKET(call)));
    389                         return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
    390                             IPC_GET_SENDER(call));
    391                 case NET_NETIF_START:
    392                         return netif_start_req_local(0, IPC_GET_DEVICE(call));
    393                 case NET_NETIF_STATS:
    394                         fibril_rwlock_read_lock(&netif_globals.lock);
    395                         if (!ERROR_OCCURRED(async_data_read_receive(&callid, &length))) {
    396                                 if (length < sizeof(device_stats_t))
    397                                         ERROR_CODE = EOVERFLOW;
    398                                 else {
    399                                         if (!ERROR_OCCURRED(netif_get_device_stats(
    400                                             IPC_GET_DEVICE(call), &stats)))
    401                                                 ERROR_CODE = async_data_read_finalize(callid, &stats,
    402                                                     sizeof(device_stats_t));
    403                                 }
    404                         }
     369        case IPC_M_PHONE_HUNGUP:
     370                return EOK;
     371       
     372        case NET_NETIF_PROBE:
     373                return netif_probe_req_local(0, IPC_GET_DEVICE(call),
     374                    NETIF_GET_IRQ(call), NETIF_GET_IO(call));
     375                   
     376        case IPC_M_CONNECT_TO_ME:
     377                fibril_rwlock_write_lock(&netif_globals.lock);
     378                rc = register_message(name, IPC_GET_DEVICE(call),
     379                    IPC_GET_PHONE(call));
     380                fibril_rwlock_write_unlock(&netif_globals.lock);
     381                return rc;
     382               
     383        case NET_NETIF_SEND:
     384                rc = packet_translate_remote(netif_globals.net_phone, &packet,
     385                    IPC_GET_PACKET(call));
     386                if (rc != EOK)
     387                        return rc;
     388                return netif_send_msg_local(0, IPC_GET_DEVICE(call), packet,
     389                    IPC_GET_SENDER(call));
     390               
     391        case NET_NETIF_START:
     392                return netif_start_req_local(0, IPC_GET_DEVICE(call));
     393               
     394        case NET_NETIF_STATS:
     395                fibril_rwlock_read_lock(&netif_globals.lock);
     396
     397                rc = async_data_read_receive(&callid, &length);
     398                if (rc != EOK) {
    405399                        fibril_rwlock_read_unlock(&netif_globals.lock);
    406                         return ERROR_CODE;
    407                 case NET_NETIF_STOP:
    408                         return netif_stop_req_local(0, IPC_GET_DEVICE(call));
    409                 case NET_NETIF_GET_ADDR:
    410                         fibril_rwlock_read_lock(&netif_globals.lock);
    411                         if (!ERROR_OCCURRED(netif_get_addr_message(IPC_GET_DEVICE(call),
    412                             &address)))
    413                                 ERROR_CODE = measured_strings_reply(&address, 1);
     400                        return rc;
     401                }
     402                if (length < sizeof(device_stats_t)) {
    414403                        fibril_rwlock_read_unlock(&netif_globals.lock);
    415                         return ERROR_CODE;
     404                        return EOVERFLOW;
     405                }
     406
     407                rc = netif_get_device_stats(IPC_GET_DEVICE(call), &stats);
     408                if (rc == EOK) {
     409                        rc = async_data_read_finalize(callid, &stats,
     410                            sizeof(device_stats_t));
     411                }
     412
     413                fibril_rwlock_read_unlock(&netif_globals.lock);
     414                return rc;
     415
     416        case NET_NETIF_STOP:
     417                return netif_stop_req_local(0, IPC_GET_DEVICE(call));
     418               
     419        case NET_NETIF_GET_ADDR:
     420                fibril_rwlock_read_lock(&netif_globals.lock);
     421                rc = netif_get_addr_message(IPC_GET_DEVICE(call), &address);
     422                if (rc == EOK)
     423                        rc = measured_strings_reply(&address, 1);
     424                fibril_rwlock_read_unlock(&netif_globals.lock);
     425                return rc;
    416426        }
    417427       
     
    421431/** Start the network interface module.
    422432 *
    423  * Initialize the client connection serving function, initialize
    424  * the module, registers the module service and start the async
    425  * manager, processing IPC messages in an infinite loop.
    426  *
    427  * @param[in] client_connection The client connection processing
    428  *                              function. The module skeleton propagates
    429  *                              its own one.
    430  *
    431  * @return EOK on success.
    432  * @return Other error codes as defined for each specific module message
    433  *         function.
    434  *
     433 * Initialize the client connection serving function, initialize the module,
     434 * registers the module service and start the async manager, processing IPC
     435 * messages in an infinite loop.
     436 *
     437 * @param[in] client_connection The client connection processing function.
     438 *                      The module skeleton propagates its own one.
     439 * @return              EOK on success.
     440 * @return              Other error codes as defined for each specific module
     441 *                      message function.
    435442 */
    436443int netif_module_start_standalone(async_client_conn_t client_connection)
    437444{
    438         ERROR_DECLARE;
    439        
    440         ERROR_PROPAGATE(netif_init_module(client_connection));
     445        int rc;
     446       
     447        rc = netif_init_module(client_connection);
     448        if (rc != EOK)
     449                return rc;
    441450       
    442451        async_manager();
  • uspace/lib/net/netif/netif_remote.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup netif
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    3535 */
    3636
     37#include <netif_remote.h>
     38#include <packet_client.h>
     39#include <generic.h>
     40
    3741#include <ipc/services.h>
    3842#include <ipc/netif.h>
     
    4145#include <adt/measured_strings.h>
    4246#include <net/packet.h>
    43 #include <packet_client.h>
    4447#include <net/device.h>
    45 #include <netif_remote.h>
    46 #include <generic.h>
    4748
     49/** Return the device local hardware address.
     50 *
     51 * @param[in] netif_phone The network interface phone.
     52 * @param[in] device_id The device identifier.
     53 * @param[out] address  The device local hardware address.
     54 * @param[out] data     The address data.
     55 * @return              EOK on success.
     56 * @return              EBADMEM if the address parameter is NULL.
     57 * @return              ENOENT if there no such device.
     58 * @return              Other error codes as defined for the
     59 *                      netif_get_addr_message() function.
     60 */
    4861int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
    49     measured_string_ref *address, char **data)
     62    measured_string_t **address, char **data)
    5063{
    5164        return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id,
     
    5366}
    5467
    55 int netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
     68/** Probe the existence of the device.
     69 *
     70 * @param[in] netif_phone The network interface phone.
     71 * @param[in] device_id The device identifier.
     72 * @param[in] irq       The device interrupt number.
     73 * @param[in] io        The device input/output address.
     74 * @return              EOK on success.
     75 * @return              Other error codes as defined for the
     76 *                      netif_probe_message().
     77 */
     78int
     79netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
    5680{
    5781        return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io);
    5882}
    5983
    60 int netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t packet,
     84/** Send the packet queue.
     85 *
     86 * @param[in] netif_phone The network interface phone.
     87 * @param[in] device_id The device identifier.
     88 * @param[in] packet    The packet queue.
     89 * @param[in] sender    The sending module service.
     90 * @return              EOK on success.
     91 * @return              Other error codes as defined for the generic_send_msg()
     92 *                      function.
     93 */
     94int
     95netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t *packet,
    6196    services_t sender)
    6297{
     
    65100}
    66101
     102/** Start the device.
     103 *
     104 * @param[in] netif_phone The network interface phone.
     105 * @param[in] device_id The device identifier.
     106 * @return              EOK on success.
     107 * @return              Other error codes as defined for the find_device()
     108 *                      function.
     109 * @return              Other error codes as defined for the
     110 *                      netif_start_message() function.
     111 */
    67112int netif_start_req_remote(int netif_phone, device_id_t device_id)
    68113{
     
    70115}
    71116
     117/** Stop the device.
     118 *
     119 * @param[in] netif_phone The network interface phone.
     120 * @param[in] device_id The device identifier.
     121 * @return              EOK on success.
     122 * @return              Other error codes as defined for the find_device()
     123 *                      function.
     124 * @return              Other error codes as defined for the
     125 *                      netif_stop_message() function.
     126 */
    72127int netif_stop_req_remote(int netif_phone, device_id_t device_id)
    73128{
     
    75130}
    76131
     132/** Return the device usage statistics.
     133 *
     134 * @param[in] netif_phone The network interface phone.
     135 * @param[in] device_id The device identifier.
     136 * @param[out] stats    The device usage statistics.
     137 * @return EOK on success.
     138 */
    77139int netif_stats_req_remote(int netif_phone, device_id_t device_id,
    78     device_stats_ref stats)
     140    device_stats_t *stats)
    79141{
    80142        if (!stats)
     
    99161 * @param[in] receiver  The message receiver.
    100162 *
    101  * @return The phone of the needed service.
    102  * @return EOK on success.
    103  * @return Other error codes as defined for the bind_service() function.
    104  *
     163 * @return              The phone of the needed service.
     164 * @return              EOK on success.
     165 * @return              Other error codes as defined for the bind_service()
     166 *                      function.
    105167 */
    106 int netif_bind_service_remote(services_t service, device_id_t device_id, services_t me,
    107     async_client_conn_t receiver)
     168int
     169netif_bind_service_remote(services_t service, device_id_t device_id,
     170    services_t me, async_client_conn_t receiver)
    108171{
    109172        return bind_service(service, device_id, me, 0, receiver);
  • uspace/lib/net/nil/nil_remote.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_nil
     29/** @addtogroup libnet
    3030 * @{
    3131 */
     
    4747/** Notify the network interface layer about the device state change.
    4848 *
    49  * @param[in] nil_phone The network interface layer phone.
    50  * @param[in] device_id The device identifier.
    51  * @param[in] state     The new device state.
    52  *
    53  * @return EOK on success.
    54  * @return Other error codes as defined for each specific module device
    55  *         state function.
    56  *
     49 * @param[in] nil_phone The network interface layer phone.
     50 * @param[in] device_id The device identifier.
     51 * @param[in] state     The new device state.
     52 * @return              EOK on success.
     53 * @return              Other error codes as defined for each specific module
     54 *                      device state function.
    5755 */
    5856int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state)
     
    6765 * upper layers.
    6866 *
    69  * @param[in] nil_phone The network interface layer phone.
    70  * @param[in] device_id The source device identifier.
    71  * @param[in] packet    The received packet or the received packet queue.
    72  * @param     target    The target service. Ignored parameter.
    73  *
    74  * @return EOK on success.
    75  * @return Other error codes as defined for each specific module
    76  *         received function.
    77  *
     67 * @param[in] nil_phone The network interface layer phone.
     68 * @param[in] device_id The source device identifier.
     69 * @param[in] packet    The received packet or the received packet queue.
     70 * @param target        The target service. Ignored parameter.
     71 * @return              EOK on success.
     72 * @return              Other error codes as defined for each specific module
     73 *                      received function.
    7874 */
    7975int nil_received_msg_remote(int nil_phone, device_id_t device_id,
    80     packet_t packet, services_t target)
     76    packet_t *packet, services_t target)
    8177{
    82         return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED, device_id,
    83             packet_get_id(packet), target, 0);
     78        return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED,
     79            device_id, packet_get_id(packet), target, 0);
    8480}
    8581
  • uspace/lib/net/tl/icmp_client.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup icmp
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP client interface implementation.
    35  *  @see icmp_client.h
     34 * ICMP client interface implementation.
     35 * @see icmp_client.h
    3636 */
    3737
     38#include <icmp_client.h>
     39#include <icmp_header.h>
     40#include <packet_client.h>
     41
    3842#ifdef CONFIG_DEBUG
    39         #include <stdio.h>
     43#include <stdio.h>
    4044#endif
    4145
     
    4448
    4549#include <net/icmp_codes.h>
    46 #include <icmp_client.h>
    4750#include <net/packet.h>
    48 #include <packet_client.h>
    49 #include <icmp_header.h>
    5051
    51 int icmp_client_process_packet(packet_t packet, icmp_type_t * type, icmp_code_t * code, icmp_param_t * pointer, icmp_param_t * mtu){
    52         icmp_header_ref header;
     52/** Processes the received packet prefixed with an ICMP header.
     53 *
     54 * @param[in] packet    The received packet.
     55 * @param[out] type     The ICMP header type.
     56 * @param[out] code     The ICMP header code.
     57 * @param[out] pointer  The ICMP header pointer.
     58 * @param[out] mtu      The ICMP header MTU.
     59 * @return              The ICMP header length.
     60 * @return              Zero if the packet contains no data.
     61 */
     62int
     63icmp_client_process_packet(packet_t *packet, icmp_type_t *type,
     64    icmp_code_t *code, icmp_param_t *pointer, icmp_param_t *mtu)
     65{
     66        icmp_header_t *header;
    5367
    54         header = (icmp_header_ref) packet_get_data(packet);
    55         if((! header)
    56                 || (packet_get_data_length(packet) < sizeof(icmp_header_t))){
     68        header = (icmp_header_t *) packet_get_data(packet);
     69        if (!header ||
     70            (packet_get_data_length(packet) < sizeof(icmp_header_t))) {
    5771                return 0;
    5872        }
    59         if(type){
     73
     74        if (type)
    6075                *type = header->type;
    61         }
    62         if(code){
     76        if (code)
    6377                *code = header->code;
    64         }
    65         if(pointer){
     78        if (pointer)
    6679                *pointer = header->un.param.pointer;
    67         }
    68         if(mtu){
     80        if (mtu)
    6981                *mtu = header->un.frag.mtu;
    70         }
     82
    7183        // remove debug dump
    7284#ifdef CONFIG_DEBUG
    73         printf("ICMP error %d (%d) in packet %d\n", header->type, header->code, packet_get_id(packet));
     85        printf("ICMP error %d (%d) in packet %d\n", header->type, header->code,
     86            packet_get_id(packet));
    7487#endif
    7588        return sizeof(icmp_header_t);
    7689}
    7790
    78 size_t icmp_client_header_length(packet_t packet){
    79         if(packet_get_data_length(packet) < sizeof(icmp_header_t)){
     91/** Returns the ICMP header length.
     92 *
     93 * @param[in] packet    The packet.
     94 * @return              The ICMP header length in bytes.
     95 */
     96size_t icmp_client_header_length(packet_t *packet)
     97{
     98        if (packet_get_data_length(packet) < sizeof(icmp_header_t))
    8099                return 0;
    81         }
     100
    82101        return sizeof(icmp_header_t);
    83102}
  • uspace/lib/net/tl/icmp_remote.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup icmp
     29/** @addtogroup libnet
    3030 *  @{
    3131 */
    3232
    3333/** @file
    34  *  ICMP interface implementation for remote modules.
    35  *  @see icmp_interface.h
     34 * ICMP interface implementation for remote modules.
     35 * @see icmp_interface.h
    3636 */
     37
     38#include <icmp_interface.h>
     39#include <net/modules.h>
     40#include <packet_client.h>
    3741
    3842#include <async.h>
     
    4347#include <sys/types.h>
    4448
    45 #include <net/modules.h>
    46 #include <icmp_interface.h>
    47 #include <packet_client.h>
    48 
    49 int icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code, icmp_param_t mtu, packet_t packet){
    50         async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu);
     49/** Sends the Destination Unreachable error notification packet.
     50 *
     51 * Beginning of the packet is sent as the notification packet data.
     52 * The source and the destination addresses should be set in the original
     53 * packet.
     54 *
     55 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
     56 * @param[in] code      The error specific code.
     57 * @param[in] mtu       The error MTU value.
     58 * @param[in] packet    The original packet.
     59 * @return              EOK on success.
     60 * @return              EPERM if the ICMP error notifications are disabled.
     61 * @return              ENOMEM if there is not enough memory left.
     62 */
     63int
     64icmp_destination_unreachable_msg(int icmp_phone, icmp_code_t code,
     65    icmp_param_t mtu, packet_t *packet)
     66{
     67        async_msg_3(icmp_phone, NET_ICMP_DEST_UNREACH, (ipcarg_t) code,
     68            (ipcarg_t) packet_get_id(packet), (ipcarg_t) mtu);
    5169        return EOK;
    5270}
    5371
    54 int icmp_source_quench_msg(int icmp_phone, packet_t packet){
    55         async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0, (ipcarg_t) packet_get_id(packet));
     72/** Sends the Source Quench error notification packet.
     73 *
     74 * Beginning of the packet is sent as the notification packet data.
     75 * The source and the destination addresses should be set in the original
     76 * packet.
     77 *
     78 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
     79 * @param[in] packet    The original packet.
     80 * @return              EOK on success.
     81 * @return              EPERM if the ICMP error notifications are disabled.
     82 * @return              ENOMEM if there is not enough memory left.
     83 */
     84int icmp_source_quench_msg(int icmp_phone, packet_t *packet)
     85{
     86        async_msg_2(icmp_phone, NET_ICMP_SOURCE_QUENCH, 0,
     87            (ipcarg_t) packet_get_id(packet));
    5688        return EOK;
    5789}
    5890
    59 int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t packet){
    60         async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet));
     91/** Sends the Time Exceeded error notification packet.
     92 *
     93 * Beginning of the packet is sent as the notification packet data.
     94 * The source and the destination addresses should be set in the original
     95 * packet.
     96 *
     97 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
     98 * @param[in] code      The error specific code.
     99 * @param[in] packet    The original packet.
     100 * @return              EOK on success.
     101 * @return              EPERM if the ICMP error notifications are disabled.
     102 * @return              ENOMEM if there is not enough memory left.
     103 */
     104int icmp_time_exceeded_msg(int icmp_phone, icmp_code_t code, packet_t *packet)
     105{
     106        async_msg_2(icmp_phone, NET_ICMP_TIME_EXCEEDED, (ipcarg_t) code,
     107            (ipcarg_t) packet_get_id(packet));
    61108        return EOK;
    62109}
    63110
    64 int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code, icmp_param_t pointer, packet_t packet){
    65         async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code, (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer);
     111/** Sends the Parameter Problem error notification packet.
     112 *
     113 * Beginning of the packet is sent as the notification packet data.
     114 * The source and the destination addresses should be set in the original
     115 * packet.
     116 *
     117 * @param[in] icmp_phone The ICMP module phone used for (semi)remote calls.
     118 * @param[in] code      The error specific code.
     119 * @param[in] pointer   The problematic parameter offset.
     120 * @param[in] packet    The original packet.
     121 * @return              EOK on success.
     122 * @return              EPERM if the ICMP error notifications are disabled.
     123 * @return              ENOMEM if there is not enough memory left.
     124 */
     125int icmp_parameter_problem_msg(int icmp_phone, icmp_code_t code,
     126    icmp_param_t pointer, packet_t *packet)
     127{
     128        async_msg_3(icmp_phone, NET_ICMP_PARAMETERPROB, (ipcarg_t) code,
     129            (ipcarg_t) packet_get_id(packet), (ipcarg_t) pointer);
    66130        return EOK;
    67131}
     
    69133/** @}
    70134 */
     135
  • uspace/lib/net/tl/socket_core.c

    ra93d79a r8fb1bf82  
    4848#include <stdlib.h>
    4949#include <errno.h>
    50 #include <err.h>
    5150
    5251#include <adt/dynamic_fifo.h>
     
    6968INT_MAP_IMPLEMENT(socket_cores, socket_core_t);
    7069
    71 GENERIC_CHAR_MAP_IMPLEMENT(socket_port_map, socket_core_ref);
     70GENERIC_CHAR_MAP_IMPLEMENT(socket_port_map, socket_core_t *);
    7271
    7372INT_MAP_IMPLEMENT(socket_ports, socket_port_t);
     
    8685 */
    8786static void
    88 socket_destroy_core(int packet_phone, socket_core_ref socket,
    89     socket_cores_ref local_sockets, socket_ports_ref global_sockets,
    90     void (* socket_release)(socket_core_ref socket))
     87socket_destroy_core(int packet_phone, socket_core_t *socket,
     88    socket_cores_t *local_sockets, socket_ports_t *global_sockets,
     89    void (* socket_release)(socket_core_t *socket))
    9190{
    9291        int packet_id;
     
    122121 */
    123122void
    124 socket_cores_release(int packet_phone, socket_cores_ref local_sockets,
    125     socket_ports_ref global_sockets,
    126     void (* socket_release)(socket_core_ref socket))
     123socket_cores_release(int packet_phone, socket_cores_t *local_sockets,
     124    socket_ports_t *global_sockets,
     125    void (* socket_release)(socket_core_t *socket))
    127126{
    128127        int index;
     
    157156 * @param[in] key       The socket key identifier.
    158157 * @param[in] key_length The socket key length.
    159  * @returns             EOK on success.
    160  * @returns             ENOMEM if there is not enough memory left.
     158 * @return              EOK on success.
     159 * @return              ENOMEM if there is not enough memory left.
    161160 */
    162161static int
    163 socket_port_add_core(socket_port_ref socket_port, socket_core_ref socket,
     162socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket,
    164163    const char *key, size_t key_length)
    165164{
    166         ERROR_DECLARE;
    167 
    168         socket_core_ref *socket_ref;
     165        socket_core_t **socket_ref;
     166        int rc;
    169167
    170168        // create a wrapper
     
    175173        *socket_ref = socket;
    176174        // add the wrapper
    177         if (ERROR_OCCURRED(socket_port_map_add(&socket_port->map, key,
    178             key_length, socket_ref))) {
     175        rc = socket_port_map_add(&socket_port->map, key, key_length,
     176            socket_ref);
     177        if (rc != EOK) {
    179178                free(socket_ref);
    180                 return ERROR_CODE;
     179                return rc;
    181180        }
    182181       
     
    195194 * @param[in] socket    The socket to be added.
    196195 * @param[in] port      The port number to be bound to.
    197  * @returns             EOK on success.
    198  * @returns             ENOMEM if there is not enough memory left.
    199  * @returns             Other error codes as defined for the
     196 * @return              EOK on success.
     197 * @return              ENOMEM if there is not enough memory left.
     198 * @return              Other error codes as defined for the
    200199 *                       socket_ports_add() function.
    201200 */
    202201static int
    203 socket_bind_insert(socket_ports_ref global_sockets, socket_core_ref socket,
     202socket_bind_insert(socket_ports_t *global_sockets, socket_core_t *socket,
    204203    int port)
    205204{
    206         ERROR_DECLARE;
    207 
    208         socket_port_ref socket_port;
     205        socket_port_t *socket_port;
     206        int rc;
    209207
    210208        // create a wrapper
     
    214212
    215213        socket_port->count = 0;
    216         if (ERROR_OCCURRED(socket_port_map_initialize(&socket_port->map)) ||
    217             ERROR_OCCURRED(socket_port_add_core(socket_port, socket,
    218             SOCKET_MAP_KEY_LISTENING, 0))) {
    219                 socket_port_map_destroy(&socket_port->map);
    220                 free(socket_port);
    221                 return ERROR_CODE;
    222         }
     214        rc = socket_port_map_initialize(&socket_port->map);
     215        if (rc != EOK)
     216                goto fail;
     217       
     218        rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,
     219            0);
     220        if (rc != EOK)
     221                goto fail;
    223222       
    224223        // register the incomming port
    225         ERROR_CODE = socket_ports_add(global_sockets, port, socket_port);
    226         if (ERROR_CODE < 0) {
    227                 socket_port_map_destroy(&socket_port->map);
    228                 free(socket_port);
    229                 return ERROR_CODE;
    230         }
     224        rc = socket_ports_add(global_sockets, port, socket_port);
     225        if (rc < 0)
     226                goto fail;
    231227       
    232228        socket->port = port;
    233229        return EOK;
     230
     231fail:
     232        socket_port_map_destroy(&socket_port->map);
     233        free(socket_port);
     234        return rc;
     235       
    234236}
    235237
     
    246248 * @param[in] free_ports_end The maximum free port.
    247249 * @param[in] last_used_port The last used free port.
    248  * @returns             EOK on success.
    249  * @returns             ENOTSOCK if the socket was not found.
    250  * @returns             EAFNOSUPPORT if the address family is not supported.
    251  * @returns             EADDRINUSE if the port is already in use.
    252  * @returns             Other error codes as defined for the
     250 * @return              EOK on success.
     251 * @return              ENOTSOCK if the socket was not found.
     252 * @return              EAFNOSUPPORT if the address family is not supported.
     253 * @return              EADDRINUSE if the port is already in use.
     254 * @return              Other error codes as defined for the
    253255 *                      socket_bind_free_port() function.
    254  * @returns             Other error codes as defined for the
     256 * @return              Other error codes as defined for the
    255257 *                      socket_bind_insert() function.
    256258 */
    257259int
    258 socket_bind(socket_cores_ref local_sockets, socket_ports_ref global_sockets,
     260socket_bind(socket_cores_t *local_sockets, socket_ports_t *global_sockets,
    259261    int socket_id, void *addr, size_t addrlen, int free_ports_start,
    260262    int free_ports_end, int last_used_port)
    261263{
    262         socket_core_ref socket;
    263         socket_port_ref socket_port;
     264        socket_core_t *socket;
     265        socket_port_t *socket_port;
    264266        struct sockaddr *address;
    265267        struct sockaddr_in *address_in;
     
    320322 * @param[in] free_ports_end The maximum free port.
    321323 * @param[in] last_used_port The last used free port.
    322  * @returns             EOK on success.
    323  * @returns             ENOTCONN if no free port was found.
    324  * @returns             Other error codes as defined for the
     324 * @return              EOK on success.
     325 * @return              ENOTCONN if no free port was found.
     326 * @return              Other error codes as defined for the
    325327 *                      socket_bind_insert() function.
    326328 */
    327329int
    328 socket_bind_free_port(socket_ports_ref global_sockets, socket_core_ref socket,
     330socket_bind_free_port(socket_ports_t *global_sockets, socket_core_t *socket,
    329331    int free_ports_start, int free_ports_end, int last_used_port)
    330332{
     
    365367 *                      requested. A negative identifier is requested if set to
    366368 *                      false.
    367  * @returns             The new socket identifier.
    368  * @returns             ELIMIT if there is no socket identifier available.
    369  */
    370 static int socket_generate_new_id(socket_cores_ref local_sockets, int positive)
     369 * @return              The new socket identifier.
     370 * @return              ELIMIT if there is no socket identifier available.
     371 */
     372static int socket_generate_new_id(socket_cores_t *local_sockets, int positive)
    371373{
    372374        int socket_id;
     
    408410 *                      chosen if set to zero or negative. A negative identifier
    409411 *                      is chosen if set to negative.
    410  * @returns             EOK on success.
    411  * @returns             EINVAL if the socket_id parameter is NULL.
    412  * @returns             ENOMEM if there is not enough memory left.
     412 * @return              EOK on success.
     413 * @return              EINVAL if the socket_id parameter is NULL.
     414 * @return              ENOMEM if there is not enough memory left.
    413415 */
    414416int
    415 socket_create(socket_cores_ref local_sockets, int app_phone,
     417socket_create(socket_cores_t *local_sockets, int app_phone,
    416418    void *specific_data, int *socket_id)
    417419{
    418         ERROR_DECLARE;
    419 
    420         socket_core_ref socket;
    421         int res;
     420        socket_core_t *socket;
    422421        int positive;
     422        int rc;
    423423
    424424        if (!socket_id)
     
    437437        }
    438438       
    439         socket = (socket_core_ref) malloc(sizeof(*socket));
     439        socket = (socket_core_t *) malloc(sizeof(*socket));
    440440        if (!socket)
    441441                return ENOMEM;
     
    447447        socket->key_length = 0;
    448448        socket->specific_data = specific_data;
    449         if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->received,
    450             SOCKET_INITIAL_RECEIVED_SIZE))) {
     449        rc = dyn_fifo_initialize(&socket->received, SOCKET_INITIAL_RECEIVED_SIZE);
     450        if (rc != EOK) {
    451451                free(socket);
    452                 return ERROR_CODE;
    453         }
    454         if (ERROR_OCCURRED(dyn_fifo_initialize(&socket->accepted,
    455             SOCKET_INITIAL_ACCEPTED_SIZE))) {
     452                return rc;
     453        }
     454       
     455        rc = dyn_fifo_initialize(&socket->accepted, SOCKET_INITIAL_ACCEPTED_SIZE);
     456        if (rc != EOK) {
    456457                dyn_fifo_destroy(&socket->received);
    457458                free(socket);
    458                 return ERROR_CODE;
     459                return rc;
    459460        }
    460461        socket->socket_id = *socket_id;
    461         res = socket_cores_add(local_sockets, socket->socket_id, socket);
    462         if (res < 0) {
     462        rc = socket_cores_add(local_sockets, socket->socket_id, socket);
     463        if (rc < 0) {
    463464                dyn_fifo_destroy(&socket->received);
    464465                dyn_fifo_destroy(&socket->accepted);
    465466                free(socket);
    466                 return res;
     467                return rc;
    467468        }
    468469       
     
    481482 * @param[in,out] global_sockets The global sockets to be updated.
    482483 * @param[in] socket_release The client release callback function.
    483  * @returns             EOK on success.
    484  * @returns             ENOTSOCK if the socket is not found.
     484 * @return              EOK on success.
     485 * @return              ENOTSOCK if the socket is not found.
    485486 */
    486487int
    487 socket_destroy(int packet_phone, int socket_id, socket_cores_ref local_sockets,
    488     socket_ports_ref global_sockets,
    489     void (*socket_release)(socket_core_ref socket))
    490 {
    491         socket_core_ref socket;
     488socket_destroy(int packet_phone, int socket_id, socket_cores_t *local_sockets,
     489    socket_ports_t *global_sockets,
     490    void (*socket_release)(socket_core_t *socket))
     491{
     492        socket_core_t *socket;
    492493        int accepted_id;
    493494
     
    515516 * @param[in] packet    The packet to be transfered.
    516517 * @param[out] length   The total data length.
    517  * @returns             EOK on success.
    518  * @returns             EBADMEM if the length parameter is NULL.
    519  * @returns             ENOMEM if there is not enough memory left.
    520  * @returns             Other error codes as defined for the data_reply()
     518 * @return              EOK on success.
     519 * @return              EBADMEM if the length parameter is NULL.
     520 * @return              ENOMEM if there is not enough memory left.
     521 * @return              Other error codes as defined for the data_reply()
    521522 *                      function.
    522523 */
    523 int socket_reply_packets(packet_t packet, size_t *length)
    524 {
    525         ERROR_DECLARE;
    526 
    527         packet_t next_packet;
     524int socket_reply_packets(packet_t *packet, size_t *length)
     525{
     526        packet_t *next_packet;
    528527        size_t fragments;
    529528        size_t *lengths;
    530529        size_t index;
     530        int rc;
    531531
    532532        if (!length)
     
    536536        if (!next_packet) {
    537537                // write all if only one fragment
    538                 ERROR_PROPAGATE(data_reply(packet_get_data(packet),
    539                     packet_get_data_length(packet)));
     538                rc = data_reply(packet_get_data(packet),
     539                    packet_get_data_length(packet));
     540                if (rc != EOK)
     541                        return rc;
    540542                // store the total length
    541543                *length = packet_get_data_length(packet);
     
    564566               
    565567                // write the fragment lengths
    566                 if (ERROR_OCCURRED(data_reply(lengths,
    567                     sizeof(int) * (fragments + 1)))) {
     568                rc = data_reply(lengths, sizeof(int) * (fragments + 1));
     569                if (rc != EOK) {
    568570                        free(lengths);
    569                         return ERROR_CODE;
     571                        return rc;
    570572                }
    571573                next_packet = packet;
     
    573575                // write the fragments
    574576                for (index = 0; index < fragments; ++index) {
    575                         ERROR_CODE = data_reply(packet_get_data(next_packet),
     577                        rc = data_reply(packet_get_data(next_packet),
    576578                            lengths[index]);
    577                         if (ERROR_OCCURRED(ERROR_CODE)) {
     579                        if (rc != EOK) {
    578580                                free(lengths);
    579                                 return ERROR_CODE;
     581                                return rc;
    580582                        }
    581583                        next_packet = pq_next(next_packet);
     
    596598 * @param[in] key       The socket key identifier.
    597599 * @param[in] key_length The socket key length.
    598  * @returns             The found socket.
    599  * @returns             NULL if no socket was found.
    600  */
    601 socket_core_ref
    602 socket_port_find(socket_ports_ref global_sockets, int port, const char *key,
     600 * @return              The found socket.
     601 * @return              NULL if no socket was found.
     602 */
     603socket_core_t *
     604socket_port_find(socket_ports_t *global_sockets, int port, const char *key,
    603605    size_t key_length)
    604606{
    605         socket_port_ref socket_port;
    606         socket_core_ref *socket_ref;
     607        socket_port_t *socket_port;
     608        socket_core_t **socket_ref;
    607609
    608610        socket_port = socket_ports_find(global_sockets, port);
     
    626628 */
    627629void
    628 socket_port_release(socket_ports_ref global_sockets, socket_core_ref socket)
    629 {
    630         socket_port_ref socket_port;
    631         socket_core_ref *socket_ref;
     630socket_port_release(socket_ports_t *global_sockets, socket_core_t *socket)
     631{
     632        socket_port_t *socket_port;
     633        socket_core_t **socket_ref;
    632634
    633635        if (!socket->port)
     
    671673 * @param[in] key       The socket key identifier.
    672674 * @param[in] key_length The socket key length.
    673  * @returns             EOK on success.
    674  * @returns             ENOENT if the port is not already used.
    675  * @returns             Other error codes as defined for the
     675 * @return              EOK on success.
     676 * @return              ENOENT if the port is not already used.
     677 * @return              Other error codes as defined for the
    676678 *                      socket_port_add_core() function.
    677679 */
    678680int
    679 socket_port_add(socket_ports_ref global_sockets, int port,
    680     socket_core_ref socket, const char *key, size_t key_length)
    681 {
    682         ERROR_DECLARE;
    683 
    684         socket_port_ref socket_port;
     681socket_port_add(socket_ports_t *global_sockets, int port,
     682    socket_core_t *socket, const char *key, size_t key_length)
     683{
     684        socket_port_t *socket_port;
     685        int rc;
    685686
    686687        // find ports
     
    690691       
    691692        // add the socket
    692         ERROR_PROPAGATE(socket_port_add_core(socket_port, socket, key,
    693             key_length));
     693        rc = socket_port_add_core(socket_port, socket, key, key_length);
     694        if (rc != EOK)
     695                return rc;
    694696       
    695697        socket->port = port;
  • uspace/lib/net/tl/tl_common.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net_tl
    30  *  @{
     29/** @addtogroup libnet
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Transport layer common functions implementation.
    35  *  @see tl_common.h
    36  */
     34 * Transport layer common functions implementation.
     35 * @see tl_common.h
     36 */
     37
     38#include <tl_common.h>
     39#include <packet_client.h>
     40#include <packet_remote.h>
     41#include <icmp_interface.h>
     42#include <ip_remote.h>
     43#include <ip_interface.h>
     44#include <tl_interface.h>
    3745
    3846#include <net/socket_codes.h>
     
    4048#include <net/in6.h>
    4149#include <net/inet.h>
     50#include <net/device.h>
     51#include <net/packet.h>
     52
    4253#include <async.h>
    4354#include <ipc/services.h>
    4455#include <errno.h>
    45 #include <err.h>
    46 
    47 #include <net/packet.h>
    48 #include <packet_client.h>
    49 #include <packet_remote.h>
    50 #include <net/device.h>
    51 #include <icmp_interface.h>
    52 #include <ip_remote.h>
    53 #include <ip_interface.h>
    54 #include <tl_interface.h>
    55 #include <tl_common.h>
    5656
    5757DEVICE_MAP_IMPLEMENT(packet_dimensions, packet_dimension_t);
    5858
     59/** Gets the address port.
     60 *
     61 * Supports AF_INET and AF_INET6 address families.
     62 *
     63 * @param[in,out] addr  The address to be updated.
     64 * @param[in] addrlen   The address length.
     65 * @param[out] port     The set port.
     66 * @return              EOK on success.
     67 * @return              EINVAL if the address length does not match the address
     68 *                      family.
     69 * @return              EAFNOSUPPORT if the address family is not supported.
     70 */
    5971int
    6072tl_get_address_port(const struct sockaddr *addr, int addrlen, uint16_t *port)
     
    7486                *port = ntohs(address_in->sin_port);
    7587                break;
     88       
    7689        case AF_INET6:
    7790                if (addrlen != sizeof(struct sockaddr_in6))
    78                                 return EINVAL;
     91                        return EINVAL;
    7992
    8093                address_in6 = (struct sockaddr_in6 *) addr;
    8194                *port = ntohs(address_in6->sin6_port);
    8295                break;
     96       
    8397        default:
    8498                return EAFNOSUPPORT;
     
    93107 * The reply is cached then.
    94108 *
    95  * @param[in]  ip_phone          The IP moduel phone for (semi)remote calls.
    96  * @param[in]  packet_dimensions The packet dimensions cache.
    97  * @param[in]  device_id         The device identifier.
    98  * @param[out] packet_dimension  The IP packet dimensions.
    99  *
    100  * @return EOK on success.
    101  * @return EBADMEM if the packet_dimension parameter is NULL.
    102  * @return ENOMEM if there is not enough memory left.
    103  * @return EINVAL if the packet_dimensions cache is not valid.
    104  * @return Other codes as defined for the ip_packet_size_req() function.
    105  *
    106  */
    107 int tl_get_ip_packet_dimension(int ip_phone,
    108     packet_dimensions_ref packet_dimensions, device_id_t device_id,
    109     packet_dimension_ref *packet_dimension)
    110 {
    111         ERROR_DECLARE;
     109 * @param[in] ip_phone  The IP moduel phone for (semi)remote calls.
     110 * @param[in] packet_dimensions The packet dimensions cache.
     111 * @param[in] device_id The device identifier.
     112 * @param[out] packet_dimension The IP packet dimensions.
     113 * @return              EOK on success.
     114 * @return              EBADMEM if the packet_dimension parameter is NULL.
     115 * @return              ENOMEM if there is not enough memory left.
     116 * @return              EINVAL if the packet_dimensions cache is not valid.
     117 * @return              Other codes as defined for the ip_packet_size_req()
     118 *                      function.
     119 */
     120int
     121tl_get_ip_packet_dimension(int ip_phone,
     122    packet_dimensions_t *packet_dimensions, device_id_t device_id,
     123    packet_dimension_t **packet_dimension)
     124{
     125        int rc;
    112126       
    113127        if (!packet_dimension)
     
    122136                        return ENOMEM;
    123137               
    124                 if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,
    125                     *packet_dimension))) {
     138                rc = ip_packet_size_req(ip_phone, device_id, *packet_dimension);
     139                if (rc != EOK) {
    126140                        free(*packet_dimension);
    127                         return ERROR_CODE;
     141                        return rc;
    128142                }
    129143               
    130                 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id,
     144                rc = packet_dimensions_add(packet_dimensions, device_id,
    131145                    *packet_dimension);
    132                 if (ERROR_CODE < 0) {
     146                if (rc < 0) {
    133147                        free(*packet_dimension);
    134                         return ERROR_CODE;
     148                        return rc;
    135149                }
    136150        }
     
    139153}
    140154
    141 int
    142 tl_update_ip_packet_dimension(packet_dimensions_ref packet_dimensions,
     155/** Updates IP device packet dimensions cache.
     156 *
     157 * @param[in,out] packet_dimensions The packet dimensions cache.
     158 * @param[in] device_id The device identifier.
     159 * @param[in] content   The new maximum content size.
     160 * @return              EOK on success.
     161 * @return              ENOENT if the packet dimension is not cached.
     162 */
     163int
     164tl_update_ip_packet_dimension(packet_dimensions_t *packet_dimensions,
    143165    device_id_t device_id, size_t content)
    144166{
    145         packet_dimension_ref packet_dimension;
     167        packet_dimension_t *packet_dimension;
    146168
    147169        packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
    148170        if (!packet_dimension)
    149171                return ENOENT;
     172
    150173        packet_dimension->content = content;
    151174
     
    160183                                packet_dimensions_exclude(packet_dimensions,
    161184                                    DEVICE_INVALID_ID);
    162 
    163185                }
    164186        }
     
    167189}
    168190
     191/** Sets the address port.
     192 *
     193 * Supports AF_INET and AF_INET6 address families.
     194 *
     195 * @param[in,out] addr  The address to be updated.
     196 * @param[in] addrlen   The address length.
     197 * @param[in] port      The port to be set.
     198 * @return              EOK on success.
     199 * @return              EINVAL if the address length does not match the address
     200 *                      family.
     201 * @return              EAFNOSUPPORT if the address family is not supported.
     202 */
    169203int tl_set_address_port(struct sockaddr * addr, int addrlen, uint16_t port)
    170204{
     
    187221                address_in->sin_port = htons(port);
    188222                return EOK;
     223       
    189224        case AF_INET6:
    190225                if (length != sizeof(struct sockaddr_in6))
     
    193228                address_in6->sin6_port = htons(port);
    194229                return EOK;
     230       
    195231        default:
    196232                return EAFNOSUPPORT;
     
    198234}
    199235
    200 int
    201 tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t packet,
     236/** Prepares the packet for ICMP error notification.
     237 *
     238 * Keeps the first packet and releases all the others.
     239 * Releases all the packets on error.
     240 *
     241 * @param[in] packet_phone The packet server module phone.
     242 * @param[in] icmp_phone The ICMP module phone.
     243 * @param[in] packet    The packet to be send.
     244 * @param[in] error     The packet error reporting service. Prefixes the
     245 *                      received packet.
     246 * @return              EOK on success.
     247 * @return              ENOENT if no packet may be sent.
     248 */
     249int
     250tl_prepare_icmp_packet(int packet_phone, int icmp_phone, packet_t *packet,
    202251    services_t error)
    203252{
    204         packet_t next;
     253        packet_t *next;
    205254        uint8_t *src;
    206255        int length;
     
    223272}
    224273
    225 int
    226 tl_socket_read_packet_data(int packet_phone, packet_ref packet, size_t prefix,
    227     const packet_dimension_ref dimension, const struct sockaddr *addr,
     274/** Receives data from the socket into a packet.
     275 *
     276 * @param[in] packet_phone The packet server module phone.
     277 * @param[out] packet   The new created packet.
     278 * @param[in] prefix    Reserved packet data prefix length.
     279 * @param[in] dimension The packet dimension.
     280 * @param[in] addr      The destination address.
     281 * @param[in] addrlen   The address length.
     282 * @return              Number of bytes received.
     283 * @return              EINVAL if the client does not send data.
     284 * @return              ENOMEM if there is not enough memory left.
     285 * @return              Other error codes as defined for the
     286 *                      async_data_read_finalize() function.
     287 */
     288int
     289tl_socket_read_packet_data(int packet_phone, packet_t **packet, size_t prefix,
     290    const packet_dimension_t *dimension, const struct sockaddr *addr,
    228291    socklen_t addrlen)
    229292{
    230         ERROR_DECLARE;
    231 
    232293        ipc_callid_t callid;
    233294        size_t length;
    234         void * data;
     295        void *data;
     296        int rc;
    235297
    236298        if (!dimension)
     
    255317
    256318        // read the data into the packet
    257         if (ERROR_OCCURRED(async_data_write_finalize(callid, data, length)) ||
    258             // set the packet destination address
    259             ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr,
    260             addrlen))) {
     319        rc = async_data_write_finalize(callid, data, length);
     320        if (rc != EOK) {
    261321                pq_release_remote(packet_phone, packet_get_id(*packet));
    262                 return ERROR_CODE;
     322                return rc;
     323        }
     324       
     325        // set the packet destination address
     326        rc = packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen);
     327        if (rc != EOK) {
     328                pq_release_remote(packet_phone, packet_get_id(*packet));
     329                return rc;
    263330        }
    264331
  • uspace/lib/net/tl/tl_interface.c

    ra93d79a r8fb1bf82  
    2727 */
    2828
    29 /** @addtogroup net
     29/** @addtogroup libnet
    3030 * @{
    3131 */
    3232
    33 /** @file
     33#include <tl_interface.h>
     34#include <generic.h>
     35#include <packet_client.h>
     36
     37#include <ipc/services.h>
     38#include <ipc/tl.h>
     39
     40#include <net/device.h>
     41#include <net/packet.h>
     42
     43/** Notify the remote transport layer modules about the received packet/s.
    3444 *
    35  * Start the networking subsystem.
    36  * Perform networking self-test if executed
    37  * with the -s argument.
     45 * @param[in] tl_phone  The transport layer module phone used for remote calls.
     46 * @param[in] device_id The device identifier.
     47 * @param[in] packet    The received packet or the received packet queue.
     48 *                      The packet queue is used to carry a fragmented
     49 *                      datagram. The first packet contains the headers,
     50 *                      the others contain only data.
     51 * @param[in] target    The target transport layer module service to be
     52 *                      delivered to.
     53 * @param[in] error     The packet error reporting service. Prefixes the
     54 *                      received packet.
     55 *
     56 * @return EOK on success.
    3857 *
    3958 */
    40 
    41 #define NAME  "netstart"
    42 
    43 #include <async.h>
    44 #include <stdio.h>
    45 #include <task.h>
    46 #include <str_error.h>
    47 #include <err.h>
    48 #include <ipc/ipc.h>
    49 #include <ipc/services.h>
    50 #include <ipc/net_net.h>
    51 
    52 #include <net/modules.h>
    53 
    54 #include "self_test.h"
    55 
    56 /** Start a module.
    57  *
    58  * @param[in] desc The module description
    59  * @param[in] path The module absolute path.
    60  *
    61  * @returns true on succesful spanwning
    62  * @returns false on failure
    63  *
    64  */
    65 static bool spawn(const char *desc, const char *path)
     59int
     60tl_received_msg(int tl_phone, device_id_t device_id, packet_t *packet,
     61    services_t target, services_t error)
    6662{
    67         printf("%s: Spawning %s (%s)\n", NAME, desc, path);
    68        
    69         const char *argv[2];
    70        
    71         argv[0] = path;
    72         argv[1] = NULL;
    73        
    74         int err;
    75         if (task_spawn(path, argv, &err) == 0) {
    76                 fprintf(stderr, "%s: Error spawning %s (%s)\n", NAME, path,
    77                     str_error(err));
    78                 return false;
    79         }
    80        
    81         return true;
    82 }
    83 
    84 int main(int argc, char *argv[])
    85 {
    86         ERROR_DECLARE;
    87        
    88         /* Run self-tests */
    89         if ((argc > 1) && (str_cmp(argv[1], "-s") == 0))
    90                 ERROR_PROPAGATE(self_test());
    91        
    92         if (!spawn("networking service", "/srv/net"))
    93                 return EINVAL;
    94        
    95         printf("%s: Initializing networking\n", NAME);
    96        
    97         int net_phone = connect_to_service(SERVICE_NETWORKING);
    98         if (ERROR_OCCURRED(ipc_call_sync_0_0(net_phone, NET_NET_STARTUP))) {
    99                 fprintf(stderr, "%s: Startup error %d\n", NAME, ERROR_CODE);
    100                 return ERROR_CODE;
    101         }
    102        
    103         return EOK;
     63        return generic_received_msg_remote(tl_phone, NET_TL_RECEIVED, device_id,
     64            packet_get_id(packet), target, error);
    10465}
    10566
Note: See TracChangeset for help on using the changeset viewer.