Changeset 849ed54 in mainline for uspace/srv/net/nil


Ignore:
Timestamp:
2010-03-30T18:39:04Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7553689
Parents:
7d6fe4db
Message:

Networking work:
Split the networking stack into end-user library (libsocket) and two helper libraries (libnet and libnetif).
Don't use over-the-hand compiling and linking, but rather separation of conserns.
There might be still some issues and the non-modular networking architecture is currently broken, but this will be fixed soon.

Location:
uspace/srv/net/nil
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/nil/eth/Makefile

    r7d6fe4db r849ed54  
    2828#
    2929
    30 NET_BASE = ../..
    3130USPACE_PREFIX = ../../../..
     31LIBS = $(LIBNETIF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a
     32EXTRA_CFLAGS = -I$(LIBNETIF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include
    3233BINARY = eth
    3334
    3435SOURCES = \
    3536        eth.c \
    36         eth_module.c \
    37         $(NET_BASE)/checksum.c \
    38         $(NET_BASE)/module.c \
    39         $(NET_BASE)/modules.c \
    40         $(NET_BASE)/net/net_remote.c \
    41         $(NET_BASE)/netif/netif_remote.c \
    42         $(NET_BASE)/structures/measured_strings.c \
    43         $(NET_BASE)/structures/packet/packet.c \
    44         $(NET_BASE)/structures/packet/packet_client.c \
    45         $(NET_BASE)/structures/packet/packet_remote.c
     37        eth_module.c
    4638
    4739include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/net/nil/eth/eth.c

    r7d6fe4db r849ed54  
    4545#include <ipc/services.h>
    4646
    47 #include "../../err.h"
    48 #include "../../messages.h"
    49 #include "../../modules.h"
    50 
    51 #include "../../include/byteorder.h"
    52 #include "../../include/checksum.h"
    53 #include "../../include/ethernet_lsap.h"
    54 #include "../../include/ethernet_protocols.h"
    55 #include "../../include/protocol_map.h"
    56 #include "../../include/device.h"
    57 #include "../../include/netif_interface.h"
    58 #include "../../include/net_interface.h"
    59 #include "../../include/nil_interface.h"
    60 #include "../../include/il_interface.h"
    61 
    62 #include "../../structures/measured_strings.h"
    63 #include "../../structures/packet/packet_client.h"
    64 
    65 #include "../nil_module.h"
     47#include <net_err.h>
     48#include <net_messages.h>
     49#include <net_modules.h>
     50#include <net_byteorder.h>
     51#include <net_checksum.h>
     52#include <ethernet_lsap.h>
     53#include <ethernet_protocols.h>
     54#include <protocol_map.h>
     55#include <net_device.h>
     56#include <netif_interface.h>
     57#include <net_interface.h>
     58#include <nil_interface.h>
     59#include <il_interface.h>
     60#include <adt/measured_strings.h>
     61#include <packet/packet_client.h>
    6662
    6763#include "eth.h"
    6864#include "eth_header.h"
     65
     66/** The module name.
     67 */
     68#define NAME    "Ethernet protocol"
    6969
    7070/** Reserved packet prefix length.
     
    769769}
    770770
     771#ifdef CONFIG_NETWORKING_modular
     772
     773#include <nil_standalone.h>
     774
     775/** Default thread for new connections.
     776 *
     777 *  @param[in] iid The initial message identifier.
     778 *  @param[in] icall The initial message call structure.
     779 *
     780 */
     781static void nil_client_connection(ipc_callid_t iid, ipc_call_t * icall)
     782{
     783        /*
     784         * Accept the connection
     785         *  - Answer the first IPC_M_CONNECT_ME_TO call.
     786         */
     787        ipc_answer_0(iid, EOK);
     788       
     789        while(true) {
     790                ipc_call_t answer;
     791                int answer_count;
     792               
     793                /* Clear the answer structure */
     794                refresh_answer(&answer, &answer_count);
     795               
     796                /* Fetch the next message */
     797                ipc_call_t call;
     798                ipc_callid_t callid = async_get_call(&call);
     799               
     800                /* Process the message */
     801                int res = nil_module_message(callid, &call, &answer, &answer_count);
     802               
     803                /* End if said to either by the message or the processing result */
     804                if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
     805                        return;
     806               
     807                /* Answer the message */
     808                answer_call(callid, res, &answer, answer_count);
     809        }
     810}
     811
     812/** Starts the module.
     813 *
     814 *  @param argc The count of the command line arguments. Ignored parameter.
     815 *  @param argv The command line parameters. Ignored parameter.
     816 *
     817 *  @returns EOK on success.
     818 *  @returns Other error codes as defined for each specific module start function.
     819 *
     820 */
     821int main(int argc, char *argv[])
     822{
     823        ERROR_DECLARE;
     824       
     825        /* Print the module label */
     826        printf("Task %d - %s\n", task_get_id(), NAME);
     827       
     828        /* Start the module */
     829        if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) {
     830                printf(" - ERROR %i\n", ERROR_CODE);
     831                return ERROR_CODE;
     832        }
     833       
     834        return EOK;
     835}
     836
     837#endif /* CONFIG_NETWORKING_modular */
     838
    771839/** @}
    772840 */
  • uspace/srv/net/nil/eth/eth.h

    r7d6fe4db r849ed54  
    4141#include <ipc/services.h>
    4242
    43 #include "../../include/device.h"
    44 #include "../../structures/measured_strings.h"
     43#include <net_device.h>
     44#include <adt/measured_strings.h>
    4545
    4646/** Type definition of the Ethernet global data.
     
    147147};
    148148
     149/** Module initialization.
     150 *  Is called by the module_start() function.
     151 *  @param[in] net_phone The networking moduel phone.
     152 *  @returns EOK on success.
     153 *  @returns Other error codes as defined for each specific module initialize function.
     154 */
     155extern int nil_initialize(int net_phone);
     156
     157/** Message processing function.
     158 *  @param[in] callid The message identifier.
     159 *  @param[in] call The message parameters.
     160 *  @param[out] answer The message answer parameters.
     161 *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
     162 *  @returns EOK on success.
     163 *  @returns ENOTSUP if the message is not known.
     164 *  @returns Other error codes as defined for each specific module message function.
     165 *  @see nil_interface.h
     166 *  @see IS_NET_NIL_MESSAGE()
     167 */
     168extern int nil_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
     169
    149170#endif
    150171
  • uspace/srv/net/nil/eth/eth_module.c

    r7d6fe4db r849ed54  
    4242#include <ipc/services.h>
    4343
    44 #include "../../err.h"
    45 #include "../../modules.h"
    46 
    47 #include "../../include/net_interface.h"
    48 
    49 #include "../../structures/packet/packet.h"
    50 
    51 #include "../nil_module.h"
     44#include <net_err.h>
     45#include <net_modules.h>
     46#include <net_interface.h>
     47#include <packet/packet.h>
     48#include <nil_standalone.h>
    5249
    5350#include "eth.h"
    54 
    55 /** The module name.
    56  */
    57 #define NAME    "Ethernet protocol"
    58 
    59 /** Prints the module name.
    60  */
    61 void module_print_name(void);
    6251
    6352/** Starts the Ethernet module.
     
    6958 *  @returns Other error codes as defined for the REGISTER_ME() macro function.
    7059 */
    71 int module_start(async_client_conn_t client_connection);
    72 
    73 /** Passes the parameters to the module specific nil_message() function.
    74  *  @param[in] callid The message identifier.
    75  *  @param[in] call The message parameters.
    76  *  @param[out] answer The message answer parameters.
    77  *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
    78  *  @returns EOK on success.
    79  *  @returns ENOTSUP if the message is not known.
    80  *  @returns Other error codes as defined for each specific module message function.
    81  */
    82 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    83 
    84 void module_print_name(void){
    85         printf("%s", NAME);
    86 }
    87 
    88 int module_start(async_client_conn_t client_connection){
     60int nil_module_start(async_client_conn_t client_connection){
    8961        ERROR_DECLARE;
    9062
     
    10779}
    10880
    109 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     81/** Passes the parameters to the module specific nil_message() function.
     82 *  @param[in] callid The message identifier.
     83 *  @param[in] call The message parameters.
     84 *  @param[out] answer The message answer parameters.
     85 *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
     86 *  @returns EOK on success.
     87 *  @returns ENOTSUP if the message is not known.
     88 *  @returns Other error codes as defined for each specific module message function.
     89 */
     90int nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    11091        return nil_message(callid, call, answer, answer_count);
    11192}
  • uspace/srv/net/nil/nildummy/Makefile

    r7d6fe4db r849ed54  
    2828#
    2929
    30 NET_BASE = ../..
    3130USPACE_PREFIX = ../../../..
     31LIBS = $(LIBNETIF_PREFIX)/libnetif.a $(LIBNET_PREFIX)/libnet.a $(LIBSOCKET_PREFIX)/libsocket.a
     32EXTRA_CFLAGS = -I$(LIBNETIF_PREFIX)/include -I$(LIBNET_PREFIX)/include -I$(LIBSOCKET_PREFIX)/include
    3233BINARY = nildummy
    3334
    3435SOURCES = \
    3536        nildummy.c \
    36         nildummy_module.c \
    37         $(NET_BASE)/module.c \
    38         $(NET_BASE)/modules.c \
    39         $(NET_BASE)/net/net_remote.c \
    40         $(NET_BASE)/netif/netif_remote.c \
    41         $(NET_BASE)/structures/measured_strings.c \
    42         $(NET_BASE)/structures/packet/packet.c \
    43         $(NET_BASE)/structures/packet/packet_client.c \
    44         $(NET_BASE)/structures/packet/packet_remote.c
     37        nildummy_module.c
    4538
    4639include $(USPACE_PREFIX)/Makefile.common
  • uspace/srv/net/nil/nildummy/nildummy.c

    r7d6fe4db r849ed54  
    4545#include <ipc/services.h>
    4646
    47 #include "../../err.h"
    48 #include "../../messages.h"
    49 #include "../../modules.h"
    50 
    51 #include "../../include/device.h"
    52 #include "../../include/netif_interface.h"
    53 #include "../../include/nil_interface.h"
    54 #include "../../include/il_interface.h"
    55 
    56 #include "../../structures/measured_strings.h"
    57 #include "../../structures/packet/packet.h"
    58 
    59 #include "../nil_module.h"
     47#include <net_err.h>
     48#include <net_messages.h>
     49#include <net_modules.h>
     50#include <net_device.h>
     51#include <netif_interface.h>
     52#include <nil_interface.h>
     53#include <il_interface.h>
     54#include <adt/measured_strings.h>
     55#include <packet/packet.h>
     56#include <nil_module.h>
    6057
    6158#include "nildummy.h"
     59
     60/** The module name.
     61 */
     62#define NAME    "Dummy nil protocol"
    6263
    6364/** Default maximum transmission unit.
     
    373374}
    374375
     376#ifdef CONFIG_NETWORKING_modular
     377
     378#include <nil_standalone.h>
     379
     380/** Default thread for new connections.
     381 *
     382 *  @param[in] iid The initial message identifier.
     383 *  @param[in] icall The initial message call structure.
     384 *
     385 */
     386static void nil_client_connection(ipc_callid_t iid, ipc_call_t * icall)
     387{
     388        /*
     389         * Accept the connection
     390         *  - Answer the first IPC_M_CONNECT_ME_TO call.
     391         */
     392        ipc_answer_0(iid, EOK);
     393       
     394        while(true) {
     395                ipc_call_t answer;
     396                int answer_count;
     397               
     398                /* Clear the answer structure */
     399                refresh_answer(&answer, &answer_count);
     400               
     401                /* Fetch the next message */
     402                ipc_call_t call;
     403                ipc_callid_t callid = async_get_call(&call);
     404               
     405                /* Process the message */
     406                int res = nil_module_message(callid, &call, &answer, &answer_count);
     407               
     408                /* End if said to either by the message or the processing result */
     409                if ((IPC_GET_METHOD(call) == IPC_M_PHONE_HUNGUP) || (res == EHANGUP))
     410                        return;
     411               
     412                /* Answer the message */
     413                answer_call(callid, res, &answer, answer_count);
     414        }
     415}
     416
     417/** Starts the module.
     418 *
     419 *  @param argc The count of the command line arguments. Ignored parameter.
     420 *  @param argv The command line parameters. Ignored parameter.
     421 *
     422 *  @returns EOK on success.
     423 *  @returns Other error codes as defined for each specific module start function.
     424 *
     425 */
     426int main(int argc, char *argv[])
     427{
     428        ERROR_DECLARE;
     429       
     430        /* Print the module label */
     431        printf("Task %d - %s\n", task_get_id(), NAME);
     432       
     433        /* Start the module */
     434        if (ERROR_OCCURRED(nil_module_start(nil_client_connection))) {
     435                printf(" - ERROR %i\n", ERROR_CODE);
     436                return ERROR_CODE;
     437        }
     438       
     439        return EOK;
     440}
     441
     442#endif /* CONFIG_NETWORKING_modular */
     443
    375444/** @}
    376445 */
  • uspace/srv/net/nil/nildummy/nildummy.h

    r7d6fe4db r849ed54  
    4141#include <ipc/services.h>
    4242
    43 #include "../../include/device.h"
    44 #include "../../structures/measured_strings.h"
     43#include <net_device.h>
     44#include <adt/measured_strings.h>
    4545
    4646/** Type definition of the dummy nil global data.
  • uspace/srv/net/nil/nildummy/nildummy_module.c

    r7d6fe4db r849ed54  
    4242#include <ipc/services.h>
    4343
    44 #include "../../err.h"
    45 #include "../../modules.h"
    46 
    47 #include "../../include/net_interface.h"
    48 
    49 #include "../../structures/packet/packet.h"
    50 
    51 #include "../nil_module.h"
     44#include <net_err.h>
     45#include <net_modules.h>
     46#include <net_interface.h>
     47#include <packet/packet.h>
     48#include <nil_module.h>
     49#include <nil_standalone.h>
    5250
    5351#include "nildummy.h"
    54 
    55 /** The module name.
    56  */
    57 #define NAME    "Dummy nil protocol"
    58 
    59 /** Prints the module name.
    60  */
    61 void module_print_name(void);
    6252
    6353/** Starts the dummy nil module.
     
    6959 *  @returns Other error codes as defined for the REGISTER_ME() macro function.
    7060 */
    71 int module_start(async_client_conn_t client_connection);
    72 
    73 /** Passes the parameters to the module specific nil_message() function.
    74  *  @param[in] callid The message identifier.
    75  *  @param[in] call The message parameters.
    76  *  @param[out] answer The message answer parameters.
    77  *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
    78  *  @returns EOK on success.
    79  *  @returns ENOTSUP if the message is not known.
    80  *  @returns Other error codes as defined for each specific module message function.
    81  */
    82 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count);
    83 
    84 void module_print_name(void){
    85         printf("%s", NAME);
    86 }
    87 
    88 int module_start(async_client_conn_t client_connection){
     61int nil_module_start(async_client_conn_t client_connection){
    8962        ERROR_DECLARE;
    9063
     
    10780}
    10881
    109 int module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
     82/** Passes the parameters to the module specific nil_message() function.
     83 *  @param[in] callid The message identifier.
     84 *  @param[in] call The message parameters.
     85 *  @param[out] answer The message answer parameters.
     86 *  @param[out] answer_count The last parameter for the actual answer in the answer parameter.
     87 *  @returns EOK on success.
     88 *  @returns ENOTSUP if the message is not known.
     89 *  @returns Other error codes as defined for each specific module message function.
     90 */
     91int nil_module_message(ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count){
    11092        return nil_message(callid, call, answer, answer_count);
    11193}
Note: See TracChangeset for help on using the changeset viewer.