Configuring IP Forwarding and IP Fragmentation

Jump to: navigation, search

Table of Contents >> Appendix A: Configuration Notes


IP Forwarding

Treck will not transfer packets from one interface to another, unless you do all of the following.

  1. Compile the code for IP forwarding via macro definition in trsystem.h.
  2. Enable IP forwarding globally via tfSetTreckOptions().
  3. Enable IP forwarding on each supporting interface when you open the device via tfNgOpenInterface(), tfNgConfigInterface(), tfOpenInterface() or tfConfigInterface().

Forwarding to unicast destinations, like www.treck.com, is the goal. Forwarding packets with multicast or broadcast addresses is not recommended because of the unintentional flood it could cause beyond the network managed by your Treck application.

Below is an IPv4 example showing the use of compile time macros and function calls tfSetTreckOptions() and tfNgOpenInterface(). Note: no configuration macro is needed to compile the option for forwarding IPv4 unicast packets.

/*
 * Changes you might make to TRSYSTEM.H
 */
 
/* (1) Support for forwarding IPv4 unicast packets is inherent */
 
/* Optionally, compile support for forwarding to IPv4 multicast destinations */
#define TM_IP_MCAST_FORWARD
 
/* Optionally, compile support for forwarding to Administratively Scoped
 * IPv4 multicast destinations (239.0.0.0 to 239.255.255.255) */
#define TM_IP_MCAST_ALLOW_ADMIN_FORWARD
/*
 * Treck functions you might call in your application
 */
 
/* (2) Allow Treck to forward IPv4 unicast packets and,
 * optionally, IPv4 multicast and directed broadcast packets */
errorCode = tfSetTreckOptions(TM_OPTION_IP_FORWARDING, 1);
assert(errorCode == TM_ENOERROR);
errorCode = tfSetTreckOptions(TM_OPTION_IP_MCAST_FORWARD, 1);
assert(errorCode == TM_ENOERROR);
errorCode = tfSetTreckOptions(TM_OPTION_IP_DBCAST_FORWARD, 1);
assert(errorCode == TM_ENOERROR);
 
/* (3) Enable forwarding to/from the "inner" and "outer" networks.
 * Optionally, enable multicast and directed broadcast forwarding. */
#define MY_IPV4_FWD_FLAGS  (  TM_DEV_IP_FORW_ENB        \
                            | TM_DEV_IP_FORW_MCAST_ENB  \
                            | TM_DEV_IP_FORW_DBROAD_ENB )
 
errorCode = tfNgOpenInterface(myInnerDevice, &myInnerIpAddr, 24,
                              MY_IPV4_FWD_FLAGS, 0,
                              1, 0);
assert(errorCode == TM_ENOERROR || errorCode == TM_EINPROGRESS);
 
errorCode = tfNgOpenInterface(myOuterDevice, &myOuterIpAddr, 24,
                              MY_IPV4_FWD_FLAGS, 0,
                              1, 0);
assert(errorCode == TM_ENOERROR || errorCode == TM_EINPROGRESS);

Below is an IPv6 example showing the use of the TM_6_USE_IP_FORWARD configuration macro and function calls tfSetTreckOptions() and tfNgOpenInterface().

/*
 * Changes you might make to TRSYSTEM.H
 */
 
/* (1) Compile support for forwarding IPv6 packets */
#define TM_6_USE_IP_FORWARD
/*
 * Treck functions you might call in your application
 */
 
/* (2) Allow Treck to forward IPv6 packets */
errorCode = tfSetTreckOptions(TM_6_OPTION_IP_FORWARDING, 1);
assert(errorCode == TM_ENOERROR);
 
/* (3) Enable forwarding to/from the "inner" and "outer" networks.
 * Optionally, enable forwarding to IPv6 multicast destinations. */
#define MY_IPV6_FWD_FLAGS  (  TM_6_DEV_IP_FORW_ENB       \
                            | TM_6_DEV_IP_FORW_MCAST_ENB )
 
errorCode = tfNgOpenInterface(myInnerDevice, &myInnerIpAddr, 64,
                              0, MY_IPV6_FWD_FLAGS,
                              1, myInnerCallback);
assert(errorCode == TM_ENOERROR || errorCode == TM_EINPROGRESS);
 
errorCode = tfNgOpenInterface(myOuterDevice, &myOuterIpAddr, 64,
                              0, MY_IPV6_FWD_FLAGS,
                              1, myOuterCallback);
assert(errorCode == TM_ENOERROR || errorCode == TM_EINPROGRESS);

IP Fragmentation

By default, if the TM_IP_FRAGMENT macro is defined in <trsystem.h>, then IP Fragmentation is turned on in the Treck stack. To disable IP Fragmentation, the user must turn off the IP Fragmentation option after the tfStartTreck() call as follows:

errorCode = tfSetTreckOptions(TM_OPTION_IP_FRAGMENT, 0UL);


Removing IP Fragmentation and IP Reassembly Code

To save code space, the user can optionally not compile the IP fragmentation and IP reassembly code in the Treck stack.


Warning Warning: In this case, no IP fragmentation or IP reassembly will ever take place in the Treck stack.


To do that, delete the following macro from <trsystem.h>:

#define TM_IP_FRAGMENT


Table of Contents >> Appendix A: Configuration Notes