/*
* 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_nil
* @{
*/
/** @file
* Network interface layer interface.
* The same interface is used for standalone remote device modules as well as for bundle device modules.
* The standalone remote device modules have to be compiled with the nil_remote.c source file.
* The bundle device modules with the appropriate network interface layer source file (eth.c etc.).
* The upper layers cannot be bundled with the network interface layer.
*/
#ifndef __NET_NIL_INTERFACE_H__
#define __NET_NIL_INTERFACE_H__
#include <async.h>
#include <errno.h>
#include <ipc/ipc.h>
#include "../messages.h"
#include "../structures/measured_strings.h"
#include "../structures/packet/packet.h"
#include "../nil/nil_messages.h"
#include "device.h"
/** Returns the device local hardware address.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param address The device local hardware address. Output parameter.
* @param data The address data. Output parameter.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
* @returns Other error codes as defined for the generic_get_addr() function.
*/
#define nil_get_addr( nil_phone, device_id, address, data ) \
generic_get_addr( nil_phone, NET_NIL_ADDR, device_id, address, data )
/** Returns the device broadcast hardware address.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param address The device broadcast hardware address. Output parameter.
* @param data The address data. Output parameter.
* @returns EOK on success.
* @returns EBADMEM if the address parameter is NULL.
* @returns ENOENT if there no such device.
* @returns Other error codes as defined for the generic_get_addr() function.
*/
#define nil_get_broadcast_addr( nil_phone, device_id, address, data ) \
generic_get_addr( nil_phone, NET_NIL_BROADCAST_ADDR, device_id, address, data )
/** Sends the packet queue.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param packet The packet queue. Input parameter.
* @param sender The sending module service. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for the generic_send_msg() function.
*/
#define nil_send_msg( nil_phone, device_id, packet, sender ) \
generic_send_msg( nil_phone, NET_NIL_SEND, device_id, packet_get_id( packet ), sender )
/** Returns the device packet dimensions for sending.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param addr_len The minimum reserved address length. Output parameter.
* @param prefix The minimum reserved prefix size. Output parameter.
* @param content The maximum content size. Output parameter.
* @param suffix The minimum reserved suffix size. Output parameter.
* @returns EOK on success.
* @returns EBADMEM if either one of the parameters is NULL.
* @returns ENOENT if there is no such device.
* @returns Other error codes as defined for the generic_packet_size_req() function.
*/
#define nil_packet_size_req( nil_phone, device_id, addr_len, prefix, content, suffix ) \
generic_packet_size_req( nil_phone, NET_NIL_PACKET_SPACE, device_id, addr_len, prefix, content, suffix )
/** Registers new device or updates the MTU of an existing one.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The new device identifier. Input parameter.
* @param mtu The device maximum transmission unit. Input parameter.
* @param netif_service The device driver service. Input parameter.
* @returns EOK on success.
* @returns EEXIST if the device with the different service exists.
* @returns ENOMEM if there is not enough memory left.
* @returns Other error codes as defined for the generic_device_req() function.
*/
#define nil_device_req( nil_phone, device_id, mtu, netif_service ) \
generic_device_req( nil_phone, NET_NIL_DEVICE, device_id, mtu, netif_service )
/** Notifies the network interface layer about the device state change.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The device identifier. Input parameter.
* @param state The new device state. Input parameter.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module device state function.
*/
int nil_device_state_msg( int nil_phone, device_id_t device_id, int state );
/** Passes the packet queue to the network interface layer.
* Processes and redistributes the received packet queue to the registered upper layers.
* @param nil_phone The network interface layer phone. Input parameter.
* @param device_id The source device identifier. Input parameter.
* @param packet The received packet or the received packet queue. Input parameter.
* @param target The target service. Ignored parameter.
* @returns EOK on success.
* @returns Other error codes as defined for each specific module received function.
*/
int nil_received_msg( int nil_phone, device_id_t device_id, packet_t packet, services_t target );
#endif
/** @}
*/