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


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/nildummy
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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.