/*
* Copyright (c) 2009 Lukas Mejdrech
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/** @addtogroup net
* @{
*/
/** @file
* Networking subsystem compilation configuration.
*/
#ifndef __NET_NET_H__
#define __NET_NET_H__
#include <ipc/ipc.h>
#include "../include/device.h"
#include "../structures/char_map.h"
#include "../structures/generic_char_map.h"
#include "../structures/measured_strings.h"
#include "../structures/module_map.h"
#include "../structures/packet/packet.h"
#define LO_NAME "lo"
#define LO_FILENAME "/srv/lo"
#define DP8390_NAME "dp8390"
#define DP8390_FILENAME "/srv/dp8390"
#define ETHERNET_NAME "ethernet"
#define ETHERNET_FILENAME "/srv/eth"
#define IP_NAME "ip"
#define IP_FILENAME "/srv/ip"
#define CONF_NAME "NAME"
#define CONF_NETIF "NETIF"
#define CONF_NIL "NIL"
#define CONF_IL "IL"
#define CONF_IRQ "IRQ"
#define CONF_IO "IO"
#define CONF_MTU "MTU"
typedef struct netif netif_t;
typedef netif_t * netif_ref;
typedef struct net_globals net_globals_t;
DEVICE_MAP_DECLARE( netifs, netif_t )
GENERIC_CHAR_MAP_DECLARE( measured_strings, measured_string_t )
/** A present network interface device.
*/
struct netif{
/** A system-unique network interface identifier.
*/
device_id_t id;
/** A serving network interface driver module index.
*/
module_ref driver;
/** A serving link layer module index.
*/
module_ref nil;
/** A serving internet layer module index.
*/
module_ref il;
/** A system-unique network interface name.
*/
char * name;
/** Configuration.
*/
measured_strings_t configuration;
};
/** A net module global variables.
*/
struct net_globals{
/** Present network interfaces.
*/
netifs_t netifs;
/** Network interface structure indices by names.
*/
char_map_t netif_names;
/** Available modules.
*/
modules_t modules;
/** Global configuration.
*/
measured_strings_t configuration;
};
int add_configuration( measured_strings_ref configuration, const char * name, const char * value );
int net_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int net_initialize( void );
int module_message( ipc_callid_t callid, ipc_call_t * call, ipc_call_t * answer, int * answer_count );
int read_netif_configuration( char * name, netif_ref netif );
#endif
/** @}
*/