Subversion Repositories HelenOS

Rev

Rev 3901 | Rev 3991 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright (c) 2009 Lukas Mejdrech
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  *
  9.  * - Redistributions of source code must retain the above copyright
  10.  *   notice, this list of conditions and the following disclaimer.
  11.  * - Redistributions in binary form must reproduce the above copyright
  12.  *   notice, this list of conditions and the following disclaimer in the
  13.  *   documentation and/or other materials provided with the distribution.
  14.  * - The name of the author may not be used to endorse or promote products
  15.  *   derived from this software without specific prior written permission.
  16.  *
  17.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  18.  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  20.  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  21.  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  22.  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  24.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  25.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  26.  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27.  */
  28.  
  29. /** @addtogroup arp
  30.  *  @{
  31.  */
  32.  
  33. /** @file
  34.  *  ARP module.
  35.  */
  36.  
  37. #ifndef __NET_ARP_H__
  38. #define __NET_ARP_H__
  39.  
  40. #include <ipc/ipc.h>
  41.  
  42. #include "../../netif/device.h"
  43.  
  44. #include "../../structures/generic_char_map.h"
  45. #include "../../structures/int_map.h"
  46. #include "../../structures/measured_strings.h"
  47.  
  48.  
  49. /** Type definition of the ARP global data.
  50.  *  @see arp_globals
  51.  */
  52. typedef struct arp_globals  arp_globals_t;
  53.  
  54. /** Type definition of the ARP device specific data.
  55.  *  @see arp_device
  56.  */
  57. typedef struct arp_device   arp_device_t;
  58.  
  59. /** Type definition of the ARP device specific data pointer.
  60.  *  @see arp_device
  61.  */
  62. typedef arp_device_t *      arp_device_ref;
  63.  
  64. /** Type definition of the ARP protocol specific data.
  65.  *  @see arp_proto
  66.  */
  67. typedef struct arp_proto    arp_proto_t;
  68.  
  69. /** Type definition of the ARP protocol specific data pointer.
  70.  *  @see arp_proto
  71.  */
  72. typedef arp_proto_t *       arp_proto_ref;
  73.  
  74. /** ARP address cache.
  75.  *  Maps devices to the ARP device specific data.
  76.  *  @see device.h
  77.  */
  78. DEVICE_MAP_DECLARE( arp_cache, arp_device_t )
  79.  
  80. /** ARP protocol map.
  81.  *  Maps protocol identifiers to the ARP protocol specific data.
  82.  *  @see int_map.h
  83.  */
  84. INT_MAP_DECLARE( arp_protos, arp_proto_t )
  85.  
  86. /** ARP address map.
  87.  *  Translates addresses.
  88.  *  @see generic_char_map.h
  89.  */
  90. GENERIC_CHAR_MAP_DECLARE( arp_addr, measured_string_t )
  91.  
  92. /** ARP device specific data.
  93.  */
  94. struct arp_device{
  95.     /** Device identifier.
  96.      */
  97.     device_id_t         device_id;
  98.     /** Hardware type.
  99.      */
  100.     ipcarg_t            hardware;
  101.     /** Reserved packet prefix length.
  102.      */
  103.     ipcarg_t            prefix;
  104.     /** Maximal packet content length.
  105.      */
  106.     ipcarg_t            content;
  107.     /** Reserved packet suffix length.
  108.      */
  109.     ipcarg_t            suffix;
  110.     /** Packet address length.
  111.      *  The hardware address length is used.
  112.      */
  113.     ipcarg_t            addr_len;
  114.     /** Actual device hardware address.
  115.      */
  116.     measured_string_ref addr;
  117.     /** Actual device hardware address data.
  118.      */
  119.     char *              addr_data;
  120.     /** Broadcast device hardware address.
  121.      */
  122.     measured_string_ref broadcast_addr;
  123.     /** Broadcast device hardware address data.
  124.      */
  125.     char *              broadcast_data;
  126.     /** Device driver service.
  127.      */
  128.     services_t          service;
  129.     /** Driver phone.
  130.      */
  131.     int                 phone;
  132.     /** Protocol map.
  133.      *  Address map for each protocol.
  134.      */
  135.     arp_protos_t        protos;
  136. };
  137.  
  138. /** ARP protocol specific data.
  139.  */
  140. struct arp_proto{
  141.     /** Protocol service.
  142.      */
  143.     services_t          service;
  144. //  int                 phone;
  145.     /** Actual device protocol address.
  146.      */
  147.     measured_string_ref addr;
  148.     /** Actual device protocol address data.
  149.      */
  150.     char *              addr_data;
  151.     /** Address map.
  152.      */
  153.     arp_addr_t          addresses;
  154. };
  155.  
  156. /** ARP global data.
  157.  */
  158. struct  arp_globals{
  159.     /** Networking module phone.
  160.      */
  161.     int         networking_phone;
  162.     /** ARP address cache.
  163.      */
  164.     arp_cache_t cache;
  165. };
  166.  
  167. #endif
  168.  
  169. /** @}
  170.  */
  171.