Changeset 14f1db0 in mainline for uspace/lib/net


Ignore:
Timestamp:
2010-04-09T12:54:57Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1caa3c2
Parents:
24ab58b3
Message:

networking overhaul:

  • separation of conserns
  • removal of (almost all) overlaping symbols, libnetif is not needed anymore
  • again, it is possible to build the networking in multiple architecture configurations (however, currently only the bundling netif and nil layers is supported, more to come)
  • code style updates and fixes (still a huge amount of work to do)
Location:
uspace/lib/net
Files:
5 added
4 deleted
23 edited
6 moved

Legend:

Unmodified
Added
Removed
  • uspace/lib/net/Makefile

    r24ab58b3 r14f1db0  
    3737        generic/packet_remote.c \
    3838        adt/module_map.c \
    39         netif/netif.c \
    40         netif/netif_standalone.c \
     39        netif/netif_local.c \
     40        netif/netif_remote.c \
    4141        netif/netif_nil_bundle.c \
    4242        nil/nil_remote.c \
  • uspace/lib/net/generic/net_remote.c

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  Networking interface implementation for standalone remote modules.
     34 *  Networking interface implementation for remote modules.
    3535 *  @see net_interface.h
    3636 */
  • uspace/lib/net/generic/packet_remote.c

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  Packet client interface implementation for standalone remote modules.
     34 *  Packet client interface implementation for remote modules.
    3535 *  @see packet_client.h
    3636 */
     
    4747#include <packet/packet_header.h>
    4848#include <packet/packet_messages.h>
     49#include <packet_remote.h>
    4950
    50 /** Obtains the packet from the packet server as the shared memory block.
    51  *  Creates the local packet mapping as well.
    52  *  @param[in] phone The packet server module phone.
    53  *  @param[out] packet The packet reference pointer to store the received packet reference.
    54  *  @param[in] packet_id The packet identifier.
    55  *  @param[in] size The packet total size in bytes.
    56  *  @returns EOK on success.
    57  *  @returns Other error codes as defined for the pm_add() function.
    58  *  @returns Other error codes as defined for the async_share_in_start() function.
     51/** Obtain the packet from the packet server as the shared memory block.
     52 *
     53 * Create the local packet mapping as well.
     54 *
     55 * @param[in]  phone     The packet server module phone.
     56 * @param[out] packet    The packet reference pointer to store the received
     57 *                       packet reference.
     58 * @param[in]  packet_id The packet identifier.
     59 * @param[in]  size      The packet total size in bytes.
     60 *
     61 * @return EOK on success.
     62 * @return Other error codes as defined for the pm_add() function.
     63 * @return Other error codes as defined for the async_share_in_start() function.
     64 *
    5965 */
    60 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size);
    61 
    62 int packet_translate(int phone, packet_ref packet, packet_id_t packet_id){
     66static int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
    6367        ERROR_DECLARE;
    64 
    65         ipcarg_t size;
    66         packet_t next;
    67 
    68         if(! packet){
    69                 return EINVAL;
    70         }
    71         *packet = pm_find(packet_id);
    72         if(!(*packet)){
    73                 ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
    74                 ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
    75         }
    76         if((** packet).next){
    77                 return packet_translate(phone, &next, (** packet).next);
    78         }else return EOK;
    79 }
    80 
    81 int packet_return(int phone, packet_ref packet, packet_id_t packet_id, size_t size){
    82         ERROR_DECLARE;
    83 
    84         aid_t message;
     68       
    8569        ipc_call_t answer;
    86         ipcarg_t result;
    87 
    88         message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
     70        aid_t message = async_send_1(phone, NET_PACKET_GET, packet_id, &answer);
    8971        *packet = (packet_t) as_get_mappable_page(size);
    90         if(ERROR_OCCURRED(async_share_in_start_0_0(phone, * packet, size))
    91                 || ERROR_OCCURRED(pm_add(*packet))){
     72        if (ERROR_OCCURRED(async_share_in_start_0_0(phone, *packet, size))
     73            || ERROR_OCCURRED(pm_add(*packet))) {
    9274                munmap(*packet, size);
    9375                async_wait_for(message, NULL);
    9476                return ERROR_CODE;
    9577        }
     78       
     79        ipcarg_t result;
    9680        async_wait_for(message, &result);
     81       
    9782        return result;
    9883}
    9984
    100 packet_t packet_get_4(int phone, size_t max_content, size_t addr_len, size_t max_prefix, size_t max_suffix){
     85int packet_translate_remote(int phone, packet_ref packet, packet_id_t packet_id)
     86{
    10187        ERROR_DECLARE;
     88       
     89        if (!packet)
     90                return EINVAL;
     91       
     92        *packet = pm_find(packet_id);
     93        if (!(*packet)) {
     94                ipcarg_t size;
     95               
     96                ERROR_PROPAGATE(async_req_1_1(phone, NET_PACKET_GET_SIZE, packet_id, &size));
     97                ERROR_PROPAGATE(packet_return(phone, packet, packet_id, size));
     98        }
     99        if ((** packet).next) {
     100                packet_t next;
     101               
     102                return packet_translate_remote(phone, &next, (** packet).next);
     103        }
     104       
     105        return EOK;
     106}
    102107
     108packet_t packet_get_4_remote(int phone, size_t max_content, size_t addr_len,
     109    size_t max_prefix, size_t max_suffix)
     110{
     111        ERROR_DECLARE;
     112       
    103113        ipcarg_t packet_id;
    104114        ipcarg_t size;
    105         packet_t packet;
    106 
    107         if(ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content, addr_len, max_prefix, max_suffix, &packet_id, &size))){
     115       
     116        if (ERROR_OCCURRED(async_req_4_2(phone, NET_PACKET_CREATE_4, max_content,
     117            addr_len, max_prefix, max_suffix, &packet_id, &size)))
    108118                return NULL;
     119       
     120       
     121        packet_t packet = pm_find(packet_id);
     122        if (!packet) {
     123                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     124                        return NULL;
    109125        }
    110         packet = pm_find(packet_id);
    111         if(! packet){
    112                 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
    113                         return NULL;
    114                 }
    115         }
     126       
    116127        return packet;
    117128}
    118129
    119 packet_t packet_get_1(int phone, size_t content){
     130packet_t packet_get_1_remote(int phone, size_t content)
     131{
    120132        ERROR_DECLARE;
    121 
     133       
    122134        ipcarg_t packet_id;
    123135        ipcarg_t size;
    124         packet_t packet;
    125 
    126         if(ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content, &packet_id, &size))){
     136       
     137        if (ERROR_OCCURRED(async_req_1_2(phone, NET_PACKET_CREATE_1, content,
     138            &packet_id, &size)))
    127139                return NULL;
     140       
     141        packet_t packet = pm_find(packet_id);
     142        if (!packet) {
     143                if (ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size)))
     144                        return NULL;
    128145        }
    129         packet = pm_find(packet_id);
    130         if(! packet){
    131                 if(ERROR_OCCURRED(packet_return(phone, &packet, packet_id, size))){
    132                         return NULL;
    133                 }
    134         }
     146       
    135147        return packet;
    136148}
    137149
    138 void pq_release(int phone, packet_id_t packet_id){
     150void pq_release_remote(int phone, packet_id_t packet_id)
     151{
    139152        async_msg_1(phone, NET_PACKET_RELEASE, packet_id);
    140153}
  • uspace/lib/net/il/arp_remote.c

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  ARP interface implementation for standalone remote modules.
     34 *  ARP interface implementation for remote modules.
    3535 *  @see arp_interface.h
    3636 */
  • uspace/lib/net/il/ip_client.c

    r24ab58b3 r14f1db0  
    5656}
    5757
    58 int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, ip_pseudo_header_ref * header, size_t * headerlen){
     58int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, void **header, size_t * headerlen){
    5959        ipv4_pseudo_header_ref header_in;
    6060        struct sockaddr_in * address_in;
     
    8484                        header_in->protocol = protocol;
    8585                        header_in->data_length = htons(data_length);
    86                         *header = (ip_pseudo_header_ref) header_in;
     86                        *header = header_in;
    8787                        return EOK;
    8888                // TODO IPv6
     
    164164}
    165165
    166 int ip_client_set_pseudo_header_data_length(ip_pseudo_header_ref header, size_t headerlen, size_t data_length){
     166int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length){
    167167        ipv4_pseudo_header_ref header_in;
    168168
  • uspace/lib/net/il/ip_remote.c

    r24ab58b3 r14f1db0  
    3333/** @file
    3434 *
    35  * IP interface implementation for standalone remote modules.
     35 * IP interface implementation for remote modules.
    3636 *
    3737 * @see ip_interface.h
     
    5050#include <il_messages.h>
    5151#include <ip_messages.h>
    52 
    53 int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address,
    54     in_addr_t netmask, in_addr_t gateway)
     52#include <ip_remote.h>
     53
     54/** Add a route to the device routing table.
     55 *
     56 * The target network is routed using this device.
     57 *
     58 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     59 * @param[in] device_id The device identifier.
     60 * @param[in] address   The target network address.
     61 * @param[in] netmask   The target network mask.
     62 * @param[in] gateway   The target network gateway. Not used if zero.
     63 *
     64 */
     65int ip_add_route_req_remote(int ip_phone, device_id_t device_id,
     66    in_addr_t address, in_addr_t netmask, in_addr_t gateway)
    5567{
    5668        return (int) async_req_4_0(ip_phone, NET_IP_ADD_ROUTE,
     
    7183}
    7284
    73 int ip_device_req(int ip_phone, device_id_t device_id, services_t service)
    74 {
    75         return generic_device_req(ip_phone, NET_IL_DEVICE, device_id, 0, service);
    76 }
    77 
    78 int ip_get_route_req(int ip_phone, ip_protocol_t protocol,
     85/** Register the new device.
     86 *
     87 * Register itself as the ip packet receiver.
     88 * If the device uses ARP registers also the new ARP device.
     89 *
     90 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     91 * @param[in] device_id The new device identifier.
     92 * @param[in] netif     The underlying device network interface layer service.
     93 *
     94 * @return EOK on success.
     95 * @return ENOMEM if there is not enough memory left.
     96 * @return EINVAL if the device configuration is invalid.
     97 * @return ENOTSUP if the device uses IPv6.
     98 * @return ENOTSUP if the device uses DHCP.
     99 * @return Other error codes as defined for the net_get_device_conf_req()
     100 *         function.
     101 * @return Other error codes as defined for the arp_device_req() function.
     102 *
     103 */
     104int ip_device_req_remote(int ip_phone, device_id_t device_id,
     105    services_t service)
     106{
     107        return generic_device_req_remote(ip_phone, NET_IL_DEVICE, device_id, 0,
     108            service);
     109}
     110
     111/** Return the device identifier and the IP pseudo header based on the destination address.
     112 *
     113 * @param[in]  ip_phone    The IP module phone used for (semi)remote calls.
     114 * @param[in]  protocol    The transport protocol.
     115 * @param[in]  destination The destination address.
     116 * @param[in]  addrlen     The destination address length.
     117 * @param[out] device_id   The device identifier.
     118 * @param[out] header      The constructed IP pseudo header.
     119 * @param[out] headerlen   The IP pseudo header length.
     120 *
     121 */
     122int ip_get_route_req_remote(int ip_phone, ip_protocol_t protocol,
    79123    const struct sockaddr *destination, socklen_t addrlen,
    80     device_id_t *device_id, ip_pseudo_header_ref *header, size_t *headerlen)
     124    device_id_t *device_id, void **header, size_t *headerlen)
    81125{
    82126        if ((!destination) || (addrlen == 0))
     
    95139            && (async_data_read_start(ip_phone, headerlen, sizeof(*headerlen)) == EOK)
    96140            && (*headerlen > 0)) {
    97                 *header = (ip_pseudo_header_ref) malloc(*headerlen);
     141                *header = malloc(*headerlen);
    98142                if (*header) {
    99143                        if (async_data_read_start(ip_phone, *header, *headerlen) != EOK)
     
    113157}
    114158
    115 int ip_packet_size_req(int ip_phone, device_id_t device_id,
     159/** Return the device packet dimension for sending.
     160 *
     161 * @param[in]  ip_phone         The IP module phone used for (semi)remote calls.
     162 * @param[in]  device_id        The device identifier.
     163 * @param[out] packet_dimension The packet dimension.
     164 *
     165 * @return EOK on success.
     166 * @return ENOENT if there is no such device.
     167 * @return Other error codes as defined for the
     168 *         generic_packet_size_req_remote() function.
     169 *
     170 */
     171int ip_packet_size_req_remote(int ip_phone, device_id_t device_id,
    116172    packet_dimension_ref packet_dimension)
    117173{
    118         return generic_packet_size_req(ip_phone, NET_IL_PACKET_SPACE, device_id,
     174        return generic_packet_size_req_remote(ip_phone, NET_IL_PACKET_SPACE, device_id,
    119175            packet_dimension);
    120176}
    121177
    122 int ip_received_error_msg(int ip_phone, device_id_t device_id,
     178/** Notify the IP module about the received error notification packet.
     179 *
     180 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     181 * @param[in] device_id The device identifier.
     182 * @param[in] packet    The received packet or the received packet queue.
     183 * @param[in] target    The target internetwork module service to be
     184 *                      delivered to.
     185 * @param[in] error     The packet error reporting service. Prefixes the
     186 *                      received packet.
     187 *
     188 * @return EOK on success.
     189 *
     190 */
     191int ip_received_error_msg_remote(int ip_phone, device_id_t device_id,
    123192    packet_t packet, services_t target, services_t error)
    124193{
    125         return generic_received_msg(ip_phone, NET_IP_RECEIVED_ERROR, device_id,
    126             packet_get_id(packet), target, error);
    127 }
    128 
    129 int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet,
     194        return generic_received_msg_remote(ip_phone, NET_IP_RECEIVED_ERROR,
     195            device_id, packet_get_id(packet), target, error);
     196}
     197
     198/** Send the packet queue.
     199 *
     200 * The packets may get fragmented if needed.
     201 *
     202 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     203 * @param[in] device_id The device identifier.
     204 * @param[in] packet    The packet fragments as a packet queue. All the
     205 *                      packets have to have the same destination address.
     206 * @param[in] sender    The sending module service.
     207 * @param[in] error     The packet error reporting service. Prefixes the
     208 *                      received packet.
     209 *
     210 * @return EOK on success.
     211 * @return Other error codes as defined for the generic_send_msg() function.
     212 *
     213 */
     214int ip_send_msg_remote(int ip_phone, device_id_t device_id, packet_t packet,
    130215    services_t sender, services_t error)
    131216{
    132         return generic_send_msg(ip_phone, NET_IL_SEND, device_id,
     217        return generic_send_msg_remote(ip_phone, NET_IL_SEND, device_id,
    133218            packet_get_id(packet), sender, error);
    134219}
    135220
    136 int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway)
     221/** Set the default gateway.
     222 *
     223 * This gateway is used if no other route is found.
     224 *
     225 * @param[in] ip_phone  The IP module phone used for (semi)remote calls.
     226 * @param[in] device_id The device identifier.
     227 * @param[in] gateway   The default gateway.
     228 *
     229 */
     230int ip_set_gateway_req_remote(int ip_phone, device_id_t device_id,
     231    in_addr_t gateway)
    137232{
    138233        return (int) async_req_2_0(ip_phone, NET_IP_SET_GATEWAY,
  • uspace/lib/net/include/arp_interface.h

    r24ab58b3 r14f1db0  
    2929/** @addtogroup arp
    3030 *  @{
    31  */
    32 
    33 /** @file
    34  *  ARP module interface.
    35  *  The same interface is used for standalone remote modules as well as for bundle modules.
    36  *  The standalone remote modules have to be compiled with the arp_remote.c source file.
    37  *  The bundle modules with the arp.c source file.
    3831 */
    3932
  • uspace/lib/net/include/icmp_interface.h

    r24ab58b3 r14f1db0  
    2929/** @addtogroup icmp
    3030 *  @{
    31  */
    32 
    33 /** @file
    34  *  ICMP module interface.
    35  *  The same interface is used for standalone remote modules as well as for bundle modules.
    36  *  The standalone remote modules have to be compiled with the icmp_remote.c source file.
    37  *  The bundle modules with the icmp.c source file.
    3831 */
    3932
  • uspace/lib/net/include/il_interface.h

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  Internetwork layer module interface for the underlying network interface layer.
    35  *  This interface is always called by the standalone remote modules.
     34 * Internetwork layer module interface for the underlying network interface layer.
     35 * This interface is always called by the remote modules.
    3636 */
    3737
     
    5050
    5151/** @name Internetwork layer module interface
    52  *  This interface is used by other modules.
     52 * This interface is used by other modules.
    5353 */
    5454/*@{*/
    5555
    56 /** Notifies the internetwork layer modules about the device state change.
    57  *  @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
    58  *  @param[in] device_id The device identifier.
    59  *  @param[in] state The new device state.
    60  *  @param[in] target The target internetwork module service to be delivered to.
    61  *  @returns EOK on success.
     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 *
    6267 */
    63 static inline int il_device_state_msg(int il_phone, device_id_t device_id, device_state_t state, services_t target){
    64         return generic_device_state_msg(il_phone, NET_IL_DEVICE_STATE, device_id, state, target);
     68static 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);
    6573}
    6674
    67 /** Notifies the internetwork layer modules about the received packet/s.
    68  *  @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
    69  *  @param[in] device_id The device identifier.
    70  *  @param[in] packet The received packet or the received packet queue.
    71  *  @param[in] target The target internetwork module service to be delivered to.
    72  *  @returns EOK on success.
     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 *
    7386 */
    74 inline static int il_received_msg(int il_phone, device_id_t device_id, packet_t packet, services_t target){
    75         return generic_received_msg(il_phone, NET_IL_RECEIVED, device_id, packet_get_id(packet), target, 0);
     87inline 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);
    7692}
    7793
    78 /** Notifies the internetwork layer modules about the mtu change.
    79  *  @param[in] il_phone The internetwork layer module phone used for (semi)remote calls.
    80  *  @param[in] device_id The device identifier.
    81  *  @param[in] mtu The new mtu value.
    82  *  @param[in] target The target internetwork module service to be delivered to.
    83  *  @returns EOK on success.
     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 *
    84105 */
    85 inline static int il_mtu_changed_msg(int il_phone, device_id_t device_id, size_t mtu, services_t target){
    86         return generic_device_state_msg(il_phone, NET_IL_MTU_CHANGED, device_id, (int) mtu, target);
     106inline 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);
    87111}
    88112
  • uspace/lib/net/include/il_local.h

    r24ab58b3 r14f1db0  
    2727 */
    2828
    29 /** @addtogroup il_standalone
     29/** @addtogroup il_local
    3030 *  @{
    3131 */
    3232
    33 #ifndef __IL_STANDALONE_H__
    34 #define __IL_STANDALONE_H__
     33#ifndef __IL_LOCAL_H__
     34#define __IL_LOCAL_H__
    3535
    3636#include <ipc/ipc.h>
    3737#include <async.h>
    3838
    39 extern int il_module_message(ipc_callid_t callid, ipc_call_t *call,
     39extern int il_module_message_standalone(ipc_callid_t callid, ipc_call_t *call,
    4040    ipc_call_t *answer, int *answer_count);
    41 extern int il_module_start(async_client_conn_t client_connection);
     41extern int il_module_start_standalone(async_client_conn_t client_connection);
    4242
    4343#endif
  • uspace/lib/net/include/il_messages.h

    r24ab58b3 r14f1db0  
    2828
    2929/** @addtogroup net_il
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Internetwork layer modules messages.
    35  *  @see il_interface.h
    36  *  @see ip_interface.h
     34 * Internetwork layer modules messages.
     35 * @see il_interface.h
     36 * @see ip_interface.h
    3737 */
    3838
     
    7272
    7373/** @name Internetwork layer specific message parameters definitions
     74 *
    7475 */
    7576/*@{*/
    7677
    77 /** Returns the protocol number message parameter.
    78  *  @param[in] call The message call structure.
     78/** Return the protocol number message parameter.
     79 * @param[in] call The message call structure.
     80 *
    7981 */
    80 #define IL_GET_PROTO(call)              (int) IPC_GET_ARG1(*call)
     82#define IL_GET_PROTO(call)  (int) IPC_GET_ARG1(*call)
    8183
    82 /** Returns the registering service message parameter.
    83  *  @param[in] call The message call structure.
     84/** Return the registering service message parameter.
     85 * @param[in] call The message call structure.
     86 *
    8487 */
    85 #define IL_GET_SERVICE(call)    (services_t) IPC_GET_ARG2(*call)
     88#define IL_GET_SERVICE(call)  (services_t) IPC_GET_ARG2(*call)
    8689
    8790/*@}*/
  • uspace/lib/net/include/ip_client.h

    r24ab58b3 r14f1db0  
    8787 *  @returns EINVAL if the headerlen parameter is not IPv4 pseudo header length.
    8888 */
    89 extern int ip_client_set_pseudo_header_data_length(ip_pseudo_header_ref header, size_t headerlen, size_t data_length);
     89extern int ip_client_set_pseudo_header_data_length(void *header, size_t headerlen, size_t data_length);
    9090
    9191/** Constructs the IPv4 pseudo header.
     
    107107 *  @returns ENOMEM if there is not enough memory left.
    108108 */
    109 extern int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, ip_pseudo_header_ref * header, size_t * headerlen);
     109extern int ip_client_get_pseudo_header(ip_protocol_t protocol, struct sockaddr * src, socklen_t srclen, struct sockaddr * dest, socklen_t destlen, size_t data_length, void **header, size_t * headerlen);
    110110
    111111// TODO ipopt manipulation
  • uspace/lib/net/include/ip_interface.h

    r24ab58b3 r14f1db0  
    3131 */
    3232
    33 /** @file
    34  *  IP module interface.
    35  *  The same interface is used for standalone remote modules as well as for bundle modules.
    36  *  The standalone remote modules have to be compiled with the ip_remote.c source file.
    37  *  The bundle modules with the ip.c source file.
    38  */
    39 
    4033#ifndef __NET_IP_INTERFACE_H__
    4134#define __NET_IP_INTERFACE_H__
     
    5144#include <socket_codes.h>
    5245
     46#ifdef CONFIG_IL_TL_BUNDLE
     47
     48#include <ip_local.h>
     49
     50#define ip_received_error_msg  ip_received_error_msg_local
     51#define ip_set_gateway_req     ip_set_gateway_req_local
     52#define ip_packet_size_req     ip_packet_size_req_local
     53#define ip_device_req          ip_device_req_local
     54#define ip_add_route_req       ip_add_route_req_local
     55#define ip_send_msg            ip_send_msg_local
     56#define ip_get_route_req       ip_get_route_req_local
     57
     58#else
     59
     60#include <ip_remote.h>
     61
     62#define ip_received_error_msg  ip_received_error_msg_remote
     63#define ip_set_gateway_req     ip_set_gateway_req_remote
     64#define ip_packet_size_req     ip_packet_size_req_remote
     65#define ip_device_req          ip_device_req_remote
     66#define ip_add_route_req       ip_add_route_req_remote
     67#define ip_send_msg            ip_send_msg_remote
     68#define ip_get_route_req       ip_get_route_req_remote
     69
     70#endif
     71
    5372/** @name IP module interface
    5473 *  This interface is used by other modules.
    5574 */
    5675/*@{*/
    57 
    58 /** Type definition of the internet pseudo header pointer.
    59  */
    60 typedef void *          ip_pseudo_header_ref;
    6176
    6277/** The transport layer notification function type definition.
     
    8297extern int ip_bind_service(services_t service, int protocol, services_t me, async_client_conn_t receiver, tl_received_msg_t tl_received_msg);
    8398
    84 /** Registers the new device.
    85  *  Registers itself as the ip packet receiver.
    86  *  If the device uses ARP registers also the new ARP device.
    87  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    88  *  @param[in] device_id The new device identifier.
    89  *  @param[in] netif The underlying device network interface layer service.
    90  *  @returns EOK on success.
    91  *  @returns ENOMEM if there is not enough memory left.
    92  *  @returns EINVAL if the device configuration is invalid.
    93  *  @returns ENOTSUP if the device uses IPv6.
    94  *  @returns ENOTSUP if the device uses DHCP.
    95  *  @returns Other error codes as defined for the net_get_device_conf_req() function.
    96  *  @returns Other error codes as defined for the arp_device_req() function.
    97  */
    98 extern int ip_device_req(int, device_id_t, services_t);
    99 
    100 /** Sends the packet queue.
    101  *  The packets may get fragmented if needed.
    102  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    103  *  @param[in] device_id The device identifier.
    104  *  @param[in] packet The packet fragments as a~packet queue. All the packets have to have the same destination address.
    105  *  @param[in] sender The sending module service.
    106  *  @param[in] error The packet error reporting service. Prefixes the received packet.
    107  *  @returns EOK on success.
    108  *  @returns Other error codes as defined for the generic_send_msg() function.
    109  */
    110 extern int ip_send_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t sender, services_t error);
    111 
    11299/** Connects to the IP module.
    113100 *  @param service The IP module service. Ignored parameter.
     
    117104extern int ip_connect_module(services_t service);
    118105
    119 /** Adds a route to the device routing table.
    120  *  The target network is routed using this device.
    121  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    122  *  @param[in] device_id The device identifier.
    123  *  @param[in] address The target network address.
    124  *  @param[in] netmask The target network mask.
    125  *  @param[in] gateway The target network gateway. Not used if zero.
    126  */
    127 extern int ip_add_route_req(int ip_phone, device_id_t device_id, in_addr_t address, in_addr_t netmask, in_addr_t gateway);
    128 
    129 /** Sets the default gateway.
    130  *  This gateway is used if no other route is found.
    131  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    132  *  @param[in] device_id The device identifier.
    133  *  @param[in] gateway The default gateway.
    134  */
    135 extern int ip_set_gateway_req(int ip_phone, device_id_t device_id, in_addr_t gateway);
    136 
    137 /** Returns the device packet dimension for sending.
    138  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    139  *  @param[in] device_id The device identifier.
    140  *  @param[out] packet_dimension The packet dimension.
    141  *  @returns EOK on success.
    142  *  @returns ENOENT if there is no such device.
    143  *  @returns Other error codes as defined for the generic_packet_size_req() function.
    144  */
    145 extern int ip_packet_size_req(int ip_phone, device_id_t device_id, packet_dimension_ref packet_dimension);
    146 
    147 /** Notifies the IP module about the received error notification packet.
    148  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    149  *  @param[in] device_id The device identifier.
    150  *  @param[in] packet The received packet or the received packet queue.
    151  *  @param[in] target The target internetwork module service to be delivered to.
    152  *  @param[in] error The packet error reporting service. Prefixes the received packet.
    153  *  @returns EOK on success.
    154  */
    155 extern int ip_received_error_msg(int ip_phone, device_id_t device_id, packet_t packet, services_t target, services_t error);
    156 
    157 /** Returns the device identifier and the IP pseudo header based on the destination address.
    158  *  @param[in] ip_phone The IP module phone used for (semi)remote calls.
    159  *  @param[in] protocol The transport protocol.
    160  *  @param[in] destination The destination address.
    161  *  @param[in] addrlen The destination address length.
    162  *  @param[out] device_id The device identifier.
    163  *  @param[out] header The constructed IP pseudo header.
    164  *  @param[out] headerlen The IP pseudo header length.
    165  */
    166 extern int ip_get_route_req(int ip_phone, ip_protocol_t protocol, const struct sockaddr * destination, socklen_t addrlen, device_id_t * device_id, ip_pseudo_header_ref * header, size_t * headerlen);
    167 
    168106/*@}*/
    169107
  • uspace/lib/net/include/net_interface.h

    r24ab58b3 r14f1db0  
    2929/** @addtogroup net
    3030 *  @{
    31  */
    32 
    33 /** @file
    34  *  Networking module interface.
    35  *  The same interface is used for standalone remote modules as well as for bundle modules.
    36  *  The standalone remote modules have to be compiled with the net_remote.c source file.
    37  *  The bundle networking module is compiled with the net_bundle.c source file and the choosen bundle module implementation source files.
    3831 */
    3932
  • uspace/lib/net/include/netif_interface.h

    r24ab58b3 r14f1db0  
    2828
    2929/** @addtogroup netif
    30  *  @{
    31  */
    32 
    33 /** @file
    34  *  Network interface module interface.
    35  *  The same interface is used for standalone remote modules as well as for bundle network interface layer modules.
    36  *  The standalone remote modules have to be compiled with the netif_remote.c source file.
    37  *  The bundle network interface layer modules are compiled with the netif_nil_bundle.c source file and the choosen network interface layer implementation source file.
     30 * @{
    3831 */
    3932
     
    4134#define __NET_NETIF_INTERFACE_H__
    4235
    43 #include <ipc/services.h>
     36#ifdef CONFIG_NETIF_NIL_BUNDLE
    4437
    45 #include <net_messages.h>
    46 #include <adt/measured_strings.h>
    47 #include <packet/packet.h>
    48 #include <net_device.h>
     38#include <netif_local.h>
     39#include <netif_nil_bundle.h>
     40#include <packet/packet_server.h>
    4941
    50 /** @name Network interface module interface
    51  *  This interface is used by other modules.
    52  */
    53 /*@{*/
     42#define netif_module_message    netif_nil_module_message
     43#define netif_module_start      netif_nil_module_start
     44#define netif_get_addr_req      netif_get_addr_req_local
     45#define netif_probe_req         netif_probe_req_local
     46#define netif_send_msg          netif_send_msg_local
     47#define netif_start_req         netif_start_req_local
     48#define netif_stop_req          netif_stop_req_local
     49#define netif_stats_req         netif_stats_req_local
     50#define netif_bind_service      netif_bind_service_local
    5451
    55 /** Returns the device local hardware address.
    56  *  @param[in] netif_phone The network interface phone.
    57  *  @param[in] device_id The device identifier.
    58  *  @param[out] address The device local hardware address.
    59  *  @param[out] data The address data.
    60  *  @returns EOK on success.
    61  *  @returns EBADMEM if the address parameter is NULL.
    62  *  @returns ENOENT if there no such device.
    63  *  @returns Other error codes as defined for the netif_get_addr_message() function.
    64  */
    65 extern int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data);
     52#else /* CONFIG_NETIF_NIL_BUNDLE */
    6653
    67 /** Probes the existence of the device.
    68  *  @param[in] netif_phone The network interface phone.
    69  *  @param[in] device_id The device identifier.
    70  *  @param[in] irq The device interrupt number.
    71  *  @param[in] io The device input/output address.
    72  *  @returns EOK on success.
    73  *  @returns Other errro codes as defined for the netif_probe_message().
    74  */
    75 extern int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io);
     54#include <netif_remote.h>
     55#include <packet/packet_client.h>
    7656
    77 /** Sends the packet queue.
    78  *  @param[in] netif_phone The network interface phone.
    79  *  @param[in] device_id The device identifier.
    80  *  @param[in] packet The packet queue.
    81  *  @param[in] sender The sending module service.
    82  *  @returns EOK on success.
    83  *  @returns Other error codes as defined for the generic_send_msg() function.
    84  */
    85 extern int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender);
     57#define netif_module_message    netif_module_message_standalone
     58#define netif_module_start      netif_module_start_standalone
     59#define netif_get_addr_req      netif_get_addr_req_remote
     60#define netif_probe_req         netif_probe_req_remote
     61#define netif_send_msg          netif_send_msg_remote
     62#define netif_start_req         netif_start_req_remote
     63#define netif_stop_req          netif_stop_req_remote
     64#define netif_stats_req         netif_stats_req_remote
     65#define netif_bind_service      netif_bind_service_remote
    8666
    87 /** Starts the device.
    88  *  @param[in] netif_phone The network interface phone.
    89  *  @param[in] device_id The device identifier.
    90  *  @returns EOK on success.
    91  *  @returns Other error codes as defined for the find_device() function.
    92  *  @returns Other error codes as defined for the netif_start_message() function.
    93  */
    94 extern int netif_start_req(int netif_phone, device_id_t device_id);
    95 
    96 /** Stops the device.
    97  *  @param[in] netif_phone The network interface phone.
    98  *  @param[in] device_id The device identifier.
    99  *  @returns EOK on success.
    100  *  @returns Other error codes as defined for the find_device() function.
    101  *  @returns Other error codes as defined for the netif_stop_message() function.
    102  */
    103 extern int netif_stop_req(int netif_phone, device_id_t device_id);
    104 
    105 /** Returns the device usage statistics.
    106  *  @param[in] netif_phone The network interface phone.
    107  *  @param[in] device_id The device identifier.
    108  *  @param[out] stats The device usage statistics.
    109  *  @returns EOK on success.
    110  */
    111 extern int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats);
    112 
    113 /** Creates bidirectional connection with the network interface module and registers the message receiver.
    114  *  @param[in] service The network interface module service.
    115  *  @param[in] device_id The device identifier.
    116  *  @param[in] me The requesting module service.
    117  *  @param[in] receiver The message receiver.
    118  *  @returns The phone of the needed service.
    119  *  @returns EOK on success.
    120  *  @returns Other error codes as defined for the bind_service() function.
    121  */
    122 extern int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver);
    123 
    124 /*@}*/
     67#endif /* CONFIG_NETIF_NIL_BUNDLE */
    12568
    12669#endif
  • uspace/lib/net/include/netif_messages.h

    r24ab58b3 r14f1db0  
    2828
    2929/** @addtogroup netif
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Network interface common module messages.
    35  *  @see netif_interface.h
     34 * Network interface common module messages.
    3635 */
    3736
     
    7675/*@{*/
    7776
    78 /** Returns the interrupt number message parameter.
    79  *  @param[in] call The message call structure.
     77/** Return the interrupt number message parameter.
     78 * @param[in] call The message call structure.
    8079 */
    8180#define NETIF_GET_IRQ(call) \
    8281        ({int irq = (int) IPC_GET_ARG2(*call); irq;})
    8382
    84 /** Returns the input/output address message parameter.
    85  *  @param[in] call The message call structure.
     83/** Return the input/output address message parameter.
     84 * @param[in] call The message call structure.
    8685 */
    8786#define NETIF_GET_IO(call) \
  • uspace/lib/net/include/nil_interface.h

    r24ab58b3 r14f1db0  
    3131 */
    3232
    33 /** @file
    34  *  Network interface layer module interface.
    35  *  The same interface is used for standalone remote device modules as well as for bundle device modules.
    36  *  The standalone remote device modules have to be compiled with the nil_remote.c source file.
    37  *  The bundle device modules with the appropriate network interface layer source file (eth.c etc.).
    38  *  The upper layers cannot be bundled with the network interface layer.
    39  */
    40 
    4133#ifndef __NET_NIL_INTERFACE_H__
    4234#define __NET_NIL_INTERFACE_H__
     
    5345#include <net_device.h>
    5446
    55 /** @name Network interface layer module interface
    56  *  This interface is used by other modules.
    57  */
    58 /*@{*/
     47#define nil_bind_service(service, device_id, me, receiver) \
     48        bind_service(service, device_id, me, 0, receiver)
    5949
    60 /** Returns the device local hardware address.
    61  *  @param[in] nil_phone The network interface layer phone.
    62  *  @param[in] device_id The device identifier.
    63  *  @param[out] address The device local hardware address.
    64  *  @param[out] data The address data.
    65  *  @returns EOK on success.
    66  *  @returns EBADMEM if the address parameter and/or the data parameter is NULL.
    67  *  @returns ENOENT if there no such device.
    68  *  @returns Other error codes as defined for the generic_get_addr_req() function.
    69  */
    70 #define nil_get_addr_req(nil_phone, device_id, address, data)   \
     50#define nil_packet_size_req(nil_phone, device_id, packet_dimension) \
     51        generic_packet_size_req_remote(nil_phone, NET_NIL_PACKET_SPACE, device_id, \
     52            packet_dimension)
     53
     54#define nil_get_addr_req(nil_phone, device_id, address, data) \
    7155        generic_get_addr_req(nil_phone, NET_NIL_ADDR, device_id, address, data)
    7256
    73 /** Returns the device broadcast hardware address.
    74  *  @param[in] nil_phone The network interface layer phone.
    75  *  @param[in] device_id The device identifier.
    76  *  @param[out] address The device broadcast hardware address.
    77  *  @param[out] data The address data.
    78  *  @returns EOK on success.
    79  *  @returns EBADMEM if the address parameter is NULL.
    80  *  @returns ENOENT if there no such device.
    81  *  @returns Other error codes as defined for the generic_get_addr_req() function.
    82  */
    83 #define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \
    84         generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data)
     57#define nil_get_broadcast_addr_req(nil_phone, device_id, address, data) \
     58        generic_get_addr_req(nil_phone, NET_NIL_BROADCAST_ADDR, device_id, \
     59            address, data)
    8560
    86 /** Sends the packet queue.
    87  *  @param[in] nil_phone The network interface layer phone.
    88  *  @param[in] device_id The device identifier.
    89  *  @param[in] packet The packet queue.
    90  *  @param[in] sender The sending module service.
    91  *  @returns EOK on success.
    92  *  @returns Other error codes as defined for the generic_send_msg() function.
    93  */
    94 #define nil_send_msg(nil_phone, device_id, packet, sender)      \
    95         generic_send_msg(nil_phone, NET_NIL_SEND, device_id, packet_get_id(packet), sender, 0)
     61#define nil_send_msg(nil_phone, device_id, packet, sender) \
     62        generic_send_msg_remote(nil_phone, NET_NIL_SEND, device_id, \
     63            packet_get_id(packet), sender, 0)
    9664
    97 /** Returns the device packet dimension for sending.
    98  *  @param[in] nil_phone The network interface layer phone.
    99  *  @param[in] device_id The device identifier.
    100  *  @param[out] packet_dimension The packet dimensions.
    101  *  @returns EOK on success.
    102  *  @returns ENOENT if there is no such device.
    103  *  @returns Other error codes as defined for the generic_packet_size_req() function.
    104  */
    105 #define nil_packet_size_req(nil_phone, device_id, packet_dimension)     \
    106         generic_packet_size_req(nil_phone, NET_NIL_PACKET_SPACE, device_id, packet_dimension)
     65#define nil_device_req(nil_phone, device_id, mtu, netif_service) \
     66        generic_device_req_remote(nil_phone, NET_NIL_DEVICE, device_id, mtu, \
     67            netif_service)
    10768
    108 /** Registers new device or updates the MTU of an existing one.
    109  *  @param[in] nil_phone The network interface layer phone.
    110  *  @param[in] device_id The new device identifier.
    111  *  @param[in] mtu The device maximum transmission unit.
    112  *  @param[in] netif_service The device driver service.
    113  *  @returns EOK on success.
    114  *  @returns EEXIST if the device with the different service exists.
    115  *  @returns ENOMEM if there is not enough memory left.
    116  *  @returns Other error codes as defined for the generic_device_req() function.
    117  */
    118 #define nil_device_req(nil_phone, device_id, mtu, netif_service)        \
    119         generic_device_req(nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service)
    12069
    121 /** Notifies the network interface layer about the device state change.
    122  *  @param[in] nil_phone The network interface layer phone.
    123  *  @param[in] device_id The device identifier.
    124  *  @param[in] state The new device state.
    125  *  @returns EOK on success.
    126  *  @returns Other error codes as defined for each specific module device state function.
    127  */
    128 extern int nil_device_state_msg(int nil_phone, device_id_t device_id, int state);
     70#ifdef CONFIG_NETIF_NIL_BUNDLE
    12971
    130 /** Passes the packet queue to the network interface layer.
    131  *  Processes and redistributes the received packet queue to the registered upper layers.
    132  *  @param[in] nil_phone The network interface layer phone.
    133  *  @param[in] device_id The source device identifier.
    134  *  @param[in] packet The received packet or the received packet queue.
    135  *  @param target The target service. Ignored parameter.
    136  *  @returns EOK on success.
    137  *  @returns Other error codes as defined for each specific module received function.
    138  */
    139 extern int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target);
     72#include <nil_local.h>
     73#include <packet/packet_server.h>
    14074
    141 /** Creates bidirectional connection with the network interface layer module and registers the message receiver.
    142  *  @param[in] service The network interface layer module service.
    143  *  @param[in] device_id The device identifier.
    144  *  @param[in] me The requesting module service.
    145  *  @param[in] receiver The message receiver.
    146  *  @returns The phone of the needed service.
    147  *  @returns EOK on success.
    148  *  @returns Other error codes as defined for the bind_service() function.
    149  */
    150 #define nil_bind_service(service, device_id, me, receiver)      \
    151         bind_service(service, device_id, me, 0, receiver);
    152 /*@}*/
     75#define nil_device_state_msg  nil_device_state_msg_local
     76#define nil_received_msg      nil_received_msg_local
     77
     78#else /* CONFIG_NETIF_NIL_BUNDLE */
     79
     80#include <nil_remote.h>
     81#include <packet/packet_server.h>
     82
     83#define nil_device_state_msg  nil_device_state_msg_remote
     84#define nil_received_msg      nil_received_msg_remote
     85
     86#endif /* CONFIG_NETIF_NIL_BUNDLE */
    15387
    15488#endif
  • uspace/lib/net/include/nil_local.h

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  Network interface layer modules common skeleton.
    35  *  All network interface layer modules have to implement this interface.
     34 * Network interface layer modules common skeleton.
     35 * All network interface layer modules have to implement this interface.
    3636 */
    3737
    38 #ifndef __NET_NIL_MODULE_H__
    39 #define __NET_NIL_MODULE_H__
     38#ifndef __NET_NIL_LOCAL_H__
     39#define __NET_NIL_LOCAL_H__
    4040
    4141#include <ipc/ipc.h>
     
    5252 */
    5353extern int nil_initialize(int);
     54
     55extern int nil_device_state_msg_local(int, device_id_t, int);
     56extern int nil_received_msg_local(int, device_id_t, packet_t, services_t);
    5457
    5558/** Message processing function.
     
    7174 *
    7275 */
    73 extern int nil_message(const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *,
     76extern int nil_message_standalone(const char *, ipc_callid_t, ipc_call_t *, ipc_call_t *,
    7477    int *);
     78
     79extern int nil_module_message_standalone(const char *, ipc_callid_t,
     80    ipc_call_t *, ipc_call_t *, int *);
     81extern int nil_module_start_standalone(async_client_conn_t);
    7582
    7683#endif
  • uspace/lib/net/include/nil_messages.h

    r24ab58b3 r14f1db0  
    2828
    2929/** @addtogroup net_nil
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Network interface layer module messages.
    35  *  @see nil_interface.h
     34 * Network interface layer module messages.
    3635 */
    3736
     
    4342#include <net_messages.h>
    4443
    45 /**  Network interface layer module messages.
     44/** Network interface layer module messages.
    4645 */
    4746typedef enum {
     
    8079/*@{*/
    8180
    82 /** Returns the protocol service message parameter.
     81/** Return the protocol service message parameter.
    8382 */
    8483#define NIL_GET_PROTO(call) \
  • uspace/lib/net/include/nil_remote.h

    r24ab58b3 r14f1db0  
    11/*
    2  * Copyright (c) 2010 Martin Decky
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup netif_standalone
    30  *  @{
     29/** @addtogroup netif
     30 * @{
    3131 */
    3232
    33 #ifndef __NETIF_STANDALONE_H__
    34 #define __NETIF_STANDALONE_H__
     33#ifndef __NET_NIL_REMOTE_H__
     34#define __NET_NIL_REMOTE_H__
    3535
     36#include <async.h>
     37#include <fibril_synch.h>
    3638#include <ipc/ipc.h>
    37 #include <async.h>
    3839
    39 extern int netif_module_message(const char *, ipc_callid_t, ipc_call_t *,
    40     ipc_call_t *, int *);
    41 extern int netif_module_start(async_client_conn_t);
     40extern int nil_device_state_msg_remote(int, device_id_t, int);
     41extern int nil_received_msg_remote(int, device_id_t, packet_t, services_t);
    4242
    4343#endif
  • uspace/lib/net/include/packet_remote.h

    r24ab58b3 r14f1db0  
    11/*
    2  * Copyright (c) 2010 Martin Decky
     2 * Copyright (c) 2009 Lukas Mejdrech
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup tl_standalone
    30  *  @{
     29/** @addtogroup packet
     30 * @{
    3131 */
    3232
    33 #ifndef __TL_STANDALONE_H__
    34 #define __TL_STANDALONE_H__
     33#ifndef __NET_PACKET_REMOTE_H__
     34#define __NET_PACKET_REMOTE_H__
    3535
    36 #include <ipc/ipc.h>
    37 #include <async.h>
     36#include <packet/packet.h>
    3837
    39 extern int tl_module_message(ipc_callid_t callid, ipc_call_t *call,
    40     ipc_call_t *answer, int *answer_count);
    41 extern int tl_module_start(async_client_conn_t client_connection);
     38extern int packet_translate_remote(int, packet_ref, packet_id_t);
     39extern packet_t packet_get_4_remote(int, size_t, size_t, size_t, size_t);
     40extern packet_t packet_get_1_remote(int, size_t);
     41extern void pq_release_remote(int, packet_id_t);
    4242
    4343#endif
  • uspace/lib/net/include/tl_common.h

    r24ab58b3 r14f1db0  
    4949DEVICE_MAP_DECLARE(packet_dimensions, packet_dimension_t);
    5050
     51extern int tl_get_ip_packet_dimension(int, packet_dimensions_ref,
     52    device_id_t, packet_dimension_ref *);
     53
    5154/** Gets the address port.
    5255 *  Supports AF_INET and AF_INET6 address families.
     
    5962 */
    6063extern int tl_get_address_port(const struct sockaddr * addr, int addrlen, uint16_t * port);
    61 
    62 /** Gets IP packet dimensions.
    63  *  Tries to search a cache and queries the IP module if not found.
    64  *  The reply is cached then.
    65  *  @param[in] ip_phone The IP moduel phone for (semi)remote calls.
    66  *  @param[in] packet_dimensions The packet dimensions cache.
    67  *  @param[in] device_id The device identifier.
    68  *  @param[out] packet_dimension The IP packet dimensions.
    69  *  @returns EOK on success.
    70  *  @returns EBADMEM if the packet_dimension parameter is NULL.
    71  *  @return ENOMEM if there is not enough memory left.
    72  *  @returns EINVAL if the packet_dimensions cache is not valid.
    73  *  @returns Other codes as defined for the ip_packet_size_req() function.
    74  */
    75 extern int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension);
    7664
    7765/** Updates IP device packet dimensions cache.
  • uspace/lib/net/include/tl_interface.h

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  Transport layer module interface for the underlying internetwork layer.
     34 * Transport layer module interface for the underlying internetwork layer.
    3535 */
    3636
     
    4848
    4949/** @name Transport layer module interface
    50  *  This interface is used by other modules.
     50 * This interface is used by other modules.
    5151 */
    5252/*@{*/
    5353
    54 /** Notifies the remote transport layer modules about the received packet/s.
    55  *  @param[in] tl_phone The transport layer module phone used for remote calls.
    56  *  @param[in] device_id The device identifier.
    57  *  @param[in] packet The received packet or the received packet queue. The packet queue is used to carry a~fragmented datagram. The first packet contains the headers, the others contain only data.
    58  *  @param[in] target The target transport layer module service to be delivered to.
    59  *  @param[in] error The packet error reporting service. Prefixes the received packet.
    60  *  @returns EOK on success.
     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 *
    6169 */
    62 inline static int tl_received_msg(int tl_phone, device_id_t device_id, packet_t packet, services_t target, services_t error){
    63         return generic_received_msg(tl_phone, NET_TL_RECEIVED, device_id, packet_get_id(packet), target, error);
     70inline 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);
    6475}
    6576
  • uspace/lib/net/include/tl_local.h

    r24ab58b3 r14f1db0  
    2727 */
    2828
    29 /** @addtogroup nil_standalone
     29/** @addtogroup tl_local
    3030 *  @{
    3131 */
    3232
    33 #ifndef __NIL_STANDALONE_H__
    34 #define __NIL_STANDALONE_H__
     33#ifndef __TL_LOCAL_H__
     34#define __TL_LOCAL_H__
    3535
    3636#include <ipc/ipc.h>
    3737#include <async.h>
    3838
    39 extern int nil_module_message(const char *, ipc_callid_t, ipc_call_t *,
     39extern int tl_module_message_standalone(ipc_callid_t, ipc_call_t *,
    4040    ipc_call_t *, int *);
    41 extern int nil_module_start(async_client_conn_t);
     41extern int tl_module_start_standalone(async_client_conn_t);
    4242
    4343#endif
  • uspace/lib/net/netif/netif_nil_bundle.c

    r24ab58b3 r14f1db0  
    4141#include <net_messages.h>
    4242#include <packet/packet.h>
    43 #include <nil_module.h>
    4443#include <netif_nil_bundle.h>
    45 #include <netif.h>
     44#include <netif_local.h>
     45#include <nil_local.h>
    4646
    4747/** Distribute the messages between the module parts.
     
    6262    ipc_call_t *call, ipc_call_t *answer, int *answer_count)
    6363{
    64         if (IS_NET_NIL_MESSAGE(call)
     64        if ((IS_NET_NIL_MESSAGE(call))
    6565            || (IPC_GET_METHOD(*call) == IPC_M_CONNECT_TO_ME))
    66                 return nil_message(name, callid, call, answer, answer_count);
     66                return nil_message_standalone(name, callid, call, answer,
     67                    answer_count);
    6768        else
    68                 return netif_message(name, callid, call, answer, answer_count);
     69                return netif_module_message_standalone(name, callid, call, answer,
     70                    answer_count);
    6971}
    7072
    71 /** Starts the bundle network interface module.
    72  *  Initializes the client connection serving function, initializes both module parts, registers the module service and starts the async manager, processing IPC messages in an infinite loop.
    73  *  @param[in] client_connection The client connection processing function. The module skeleton propagates its own one.
    74  *  @returns EOK on success.
    75  *  @returns Other error codes as defined for each specific module message function.
     73/** Start the bundle network interface module.
     74 *
     75 * Initialize the client connection serving function, initialize
     76 * both module parts, register the module service and start the
     77 * async manager, processing IPC messages in an infinite loop.
     78 *
     79 * @param[in] client_connection The client connection processing
     80 *                              function. The module skeleton propagates
     81 *                              its own one.
     82 *
     83 * @return EOK on success.
     84 * @return Other error codes as defined for each specific module message
     85 *         function.
     86 *
    7687 */
    77 int netif_nil_module_start(async_client_conn_t client_connection){
     88int netif_nil_module_start(async_client_conn_t client_connection)
     89{
    7890        ERROR_DECLARE;
    79 
     91       
    8092        ERROR_PROPAGATE(netif_init_module(client_connection));
    81         if(ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))){
     93        if (ERROR_OCCURRED(nil_initialize(netif_globals.net_phone))) {
    8294                pm_destroy();
    8395                return ERROR_CODE;
    8496        }
    85         return netif_run_module();
     97       
     98        async_manager();
     99       
     100        pm_destroy();
     101        return EOK;
    86102}
    87103
  • uspace/lib/net/netif/netif_remote.c

    r24ab58b3 r14f1db0  
    2828
    2929/** @addtogroup netif
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Network interface module interface implementation for standalone remote modules.
    35  *  @see netif_interface.h
     34 * Network interface module interface implementation for remote modules.
    3635 */
    3736
     
    4342#include <packet/packet_client.h>
    4443#include <net_device.h>
    45 #include <netif_interface.h>
     44#include <netif_remote.h>
    4645#include <netif_messages.h>
    4746
    48 int netif_get_addr_req(int netif_phone, device_id_t device_id, measured_string_ref * address, char ** data){
    49         return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id, address, data);
     47int netif_get_addr_req_remote(int netif_phone, device_id_t device_id,
     48    measured_string_ref *address, char **data)
     49{
     50        return generic_get_addr_req(netif_phone, NET_NETIF_GET_ADDR, device_id,
     51            address, data);
    5052}
    5153
    52 int netif_probe_req(int netif_phone, device_id_t device_id, int irq, int io){
     54int netif_probe_req_remote(int netif_phone, device_id_t device_id, int irq, int io)
     55{
    5356        return async_req_3_0(netif_phone, NET_NETIF_PROBE, device_id, irq, io);
    5457}
    5558
    56 int netif_send_msg(int netif_phone, device_id_t device_id, packet_t packet, services_t sender){
    57         return generic_send_msg(netif_phone, NET_NETIF_SEND, device_id, packet_get_id(packet), sender, 0);
     59int netif_send_msg_remote(int netif_phone, device_id_t device_id, packet_t packet,
     60    services_t sender)
     61{
     62        return generic_send_msg_remote(netif_phone, NET_NETIF_SEND, device_id,
     63            packet_get_id(packet), sender, 0);
    5864}
    5965
    60 int netif_start_req(int netif_phone, device_id_t device_id){
     66int netif_start_req_remote(int netif_phone, device_id_t device_id)
     67{
    6168        return async_req_1_0(netif_phone, NET_NETIF_START, device_id);
    6269}
    6370
    64 int netif_stop_req(int netif_phone, device_id_t device_id){
     71int netif_stop_req_remote(int netif_phone, device_id_t device_id)
     72{
    6573        return async_req_1_0(netif_phone, NET_NETIF_STOP, device_id);
    6674}
    6775
    68 int netif_stats_req(int netif_phone, device_id_t device_id, device_stats_ref stats){
    69         aid_t message_id;
     76int netif_stats_req_remote(int netif_phone, device_id_t device_id,
     77    device_stats_ref stats)
     78{
     79        if (!stats)
     80                return EBADMEM;
     81       
     82        aid_t message_id = async_send_1(netif_phone, NET_NETIF_STATS,
     83            (ipcarg_t) device_id, NULL);
     84        async_data_read_start(netif_phone, stats, sizeof(*stats));
     85       
    7086        ipcarg_t result;
    71 
    72         if(! stats){
    73                 return EBADMEM;
    74         }
    75         message_id = async_send_1(netif_phone, NET_NETIF_STATS, (ipcarg_t) device_id, NULL);
    76         async_data_read_start(netif_phone, stats, sizeof(*stats));
    7787        async_wait_for(message_id, &result);
     88       
    7889        return (int) result;
    7990}
    8091
    81 int netif_bind_service(services_t service, device_id_t device_id, services_t me, async_client_conn_t receiver){
     92int netif_bind_service_remote(services_t service, device_id_t device_id, services_t me,
     93    async_client_conn_t receiver)
     94{
    8295        return bind_service(service, device_id, me, 0, receiver);
    8396}
  • uspace/lib/net/nil/nil_remote.c

    r24ab58b3 r14f1db0  
    2828
    2929/** @addtogroup net_nil
    30  *  @{
     30 * @{
    3131 */
    3232
    3333/** @file
    34  *  Network interface layer interface implementation for standalone remote modules.
    35  *  @see nil_interface.h
     34 * Network interface layer interface implementation for remote modules.
     35 * @see nil_interface.h
    3636 */
    3737
     
    4242#include <packet/packet_client.h>
    4343#include <nil_messages.h>
     44#include <nil_remote.h>
    4445
    45 int nil_device_state_msg(int nil_phone, device_id_t device_id, int state){
    46         return generic_device_state_msg(nil_phone, NET_NIL_DEVICE_STATE, device_id, state, 0);
     46/** Notify the network interface layer about the device state change.
     47 *
     48 * @param[in] nil_phone The network interface layer phone.
     49 * @param[in] device_id The device identifier.
     50 * @param[in] state     The new device state.
     51 *
     52 * @return EOK on success.
     53 * @return Other error codes as defined for each specific module device
     54 *         state function.
     55 *
     56 */
     57int nil_device_state_msg_remote(int nil_phone, device_id_t device_id, int state)
     58{
     59        return generic_device_state_msg_remote(nil_phone, NET_NIL_DEVICE_STATE,
     60            device_id, state, 0);
    4761}
    4862
    49 int nil_received_msg(int nil_phone, device_id_t device_id, packet_t packet, services_t target){
    50         return generic_received_msg(nil_phone, NET_NIL_RECEIVED, device_id, packet_get_id(packet), target, 0);
     63/** Pass the packet queue to the network interface layer.
     64 *
     65 * Process and redistribute the received packet queue to the registered
     66 * upper layers.
     67 *
     68 * @param[in] nil_phone The network interface layer phone.
     69 * @param[in] device_id The source device identifier.
     70 * @param[in] packet    The received packet or the received packet queue.
     71 * @param     target    The target service. Ignored parameter.
     72 *
     73 * @return EOK on success.
     74 * @return Other error codes as defined for each specific module
     75 *         received function.
     76 *
     77 */
     78int nil_received_msg_remote(int nil_phone, device_id_t device_id,
     79    packet_t packet, services_t target)
     80{
     81        return generic_received_msg_remote(nil_phone, NET_NIL_RECEIVED, device_id,
     82            packet_get_id(packet), target, 0);
    5183}
    5284
  • uspace/lib/net/tl/icmp_remote.c

    r24ab58b3 r14f1db0  
    3232
    3333/** @file
    34  *  ICMP interface implementation for standalone remote modules.
     34 *  ICMP interface implementation for remote modules.
    3535 *  @see icmp_interface.h
    3636 */
  • uspace/lib/net/tl/tl_common.c

    r24ab58b3 r14f1db0  
    4242#include <packet/packet.h>
    4343#include <packet/packet_client.h>
     44#include <packet_remote.h>
    4445#include <net_device.h>
    4546#include <icmp_interface.h>
     
    4748#include <in6.h>
    4849#include <inet.h>
    49 #include <ip_interface.h>
     50#include <ip_local.h>
     51#include <ip_remote.h>
    5052#include <socket_codes.h>
    5153#include <socket_errno.h>
     54#include <ip_interface.h>
     55#include <tl_interface.h>
    5256#include <tl_common.h>
    5357
     
    8286}
    8387
    84 int tl_get_ip_packet_dimension(int ip_phone, packet_dimensions_ref packet_dimensions, device_id_t device_id, packet_dimension_ref * packet_dimension){
     88/** Get IP packet dimensions.
     89 *
     90 * Try to search a cache and query the IP module if not found.
     91 * The reply is cached then.
     92 *
     93 * @param[in]  ip_phone          The IP moduel phone for (semi)remote calls.
     94 * @param[in]  packet_dimensions The packet dimensions cache.
     95 * @param[in]  device_id         The device identifier.
     96 * @param[out] packet_dimension  The IP packet dimensions.
     97 *
     98 * @return EOK on success.
     99 * @return EBADMEM if the packet_dimension parameter is NULL.
     100 * @return ENOMEM if there is not enough memory left.
     101 * @return EINVAL if the packet_dimensions cache is not valid.
     102 * @return Other codes as defined for the ip_packet_size_req() function.
     103 *
     104 */
     105int tl_get_ip_packet_dimension(int ip_phone,
     106    packet_dimensions_ref packet_dimensions, device_id_t device_id,
     107    packet_dimension_ref *packet_dimension)
     108{
    85109        ERROR_DECLARE;
    86 
    87         if(! packet_dimension){
     110       
     111        if (!packet_dimension)
    88112                return EBADMEM;
    89         }
    90 
     113       
    91114        *packet_dimension = packet_dimensions_find(packet_dimensions, device_id);
    92         if(! * packet_dimension){
    93                 // ask for and remember them if not found
    94                 *packet_dimension = malloc(sizeof(** packet_dimension));
    95                 if(! * packet_dimension){
     115        if (!*packet_dimension) {
     116                /* Ask for and remember them if not found */
     117                *packet_dimension = malloc(sizeof(**packet_dimension));
     118                if(!*packet_dimension)
    96119                        return ENOMEM;
    97                 }
    98                 if(ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id, * packet_dimension))){
     120               
     121                if (ERROR_OCCURRED(ip_packet_size_req(ip_phone, device_id,
     122                    *packet_dimension))) {
    99123                        free(*packet_dimension);
    100124                        return ERROR_CODE;
    101125                }
    102                 ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id, * packet_dimension);
    103                 if(ERROR_CODE < 0){
     126               
     127                ERROR_CODE = packet_dimensions_add(packet_dimensions, device_id,
     128                    *packet_dimension);
     129                if (ERROR_CODE < 0) {
    104130                        free(*packet_dimension);
    105131                        return ERROR_CODE;
    106132                }
    107133        }
     134       
    108135        return EOK;
    109136}
     
    169196        // detach the first packet and release the others
    170197        next = pq_detach(packet);
    171         if(next){
    172                 pq_release(packet_phone, packet_get_id(next));
    173         }
     198        if (next)
     199                pq_release_remote(packet_phone, packet_get_id(next));
     200       
    174201        length = packet_get_addr(packet, &src, NULL);
    175202        if((length > 0)
     
    180207                return EOK;
    181208        }else{
    182                 pq_release(packet_phone, packet_get_id(packet));
     209                pq_release_remote(packet_phone, packet_get_id(packet));
    183210        }
    184211        return ENOENT;
     
    200227        }
    201228        // get a new packet
    202         *packet = packet_get_4(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
     229        *packet = packet_get_4_remote(packet_phone, length, dimension->addr_len, prefix + dimension->prefix, dimension->suffix);
    203230        if(! packet){
    204231                return ENOMEM;
     
    207234        data = packet_suffix(*packet, length);
    208235        if(! data){
    209                 pq_release(packet_phone, packet_get_id(*packet));
     236                pq_release_remote(packet_phone, packet_get_id(*packet));
    210237                return ENOMEM;
    211238        }
     
    214241        // set the packet destination address
    215242                || ERROR_OCCURRED(packet_set_addr(*packet, NULL, (uint8_t *) addr, addrlen))){
    216                 pq_release(packet_phone, packet_get_id(*packet));
     243                pq_release_remote(packet_phone, packet_get_id(*packet));
    217244                return ERROR_CODE;
    218245        }
Note: See TracChangeset for help on using the changeset viewer.