/*
    NetIPModule.h, Copyright  (c) by Boris Lutz,
    Swiss Federal Institute of Technology,
    Computer Engineering and Networks Laboratory.
 
    TOPSY -- A Teachable Operating System.
             Implementation of a tiny and simple
             micro kernel for teaching purposes.
 
    For further information, please visit http://www.tik.ee.ethz.ch/~topsy
 
    This software is provided under the terms of the GNU General Public
    Licence. A full copy of the GNU GPL is provided in the file COPYING
    found in the development root of Topsy.
*/
/*
 
    File:                  $Source: /home/ruf/cvs_Topsy/cvs/Topsy/Net/Modules/IP/NetIPModule.h,v $
    Affiliation:           ETH Zuerich, TIK
    Version:               $Revision: 2922 $
    Last Date of Change:   $Date: 2007-03-19 17:48:52 +0100 (Mon, 19 Mär 2007) $  by: $Author: baderma $
 
*/
#ifndef _NET_IP_MODULE_H_
#define _NET_IP_MODULE_H_

#include "NetHAL.h"
#include "NetModulesNew.h"


typedef struct
{
  u8      bitfield1;    /* bit field: version:4, hdr_len:4; */
  u8  tos;
  u16 tot_len;
  u16 id;
  u16 frag_off;
  u8  ttl;
  u8  protocol;
  u16 checksum;

  u8  saddr0;
  u8  saddr1;       /* problems with alignment of u32... */
  u8  saddr2;
  u8  saddr3;

  u8  daddr0;
  u8  daddr1;
  u8  daddr2;
  u8  daddr3;

  /* options */
}
NetIPHdr;


#define NETIP_PROTOCOL_ICMP 1
#define NETIP_PROTOCOL_UDP  17
#define NETIP_PROTOCOL_TCP  6
#define NETIP_FRAGOFF_MASK  0x1FFF
#define NETIP_DEFAULT_MTU 1500
#define NETIP_DEFAULT_TTL 64
#define NETIP_DEFAULT_TOS 0

// function prototypes for IPModuleDown
void netIPModuleDownInit (NetModule this);
int netIPModuleDownConfig (NetModule this, Message *msg);
void netIPModuleDownMain (LWPool lw, ThreadArg arg);
// function prototypes for IPModuleUp
void netIPModuleUpInit (NetModule this);
int netIPModuleUpConfig (NetModule this, Message *msg);
void netIPModuleUpMain (LWPool lw, ThreadArg arg);
// function prototypes for IPForward
void netIPForwardInit(NetModule this);
int netIPForwardConfig(NetModule this, Message *msg);
void netIPForwardMain(LWPool lw, ThreadArg arg);
// function prototypes for DUMMY ROUTER
void netIPDummyRouteInit(NetModule this);
int netIPDummyRouteConfig(NetModule this, Message *msg);
void netIPDummyRouteMain(LWPool lw, ThreadArg arg);

#endif

