Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ipv4_routing.h Source File

ipv4_routing.h

Go to the documentation of this file.
00001 /**
00002  * @file ipv4_routing.h
00003  * @brief IPv4 routing
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _IPV4_ROUTING_H
00030 #define _IPV4_ROUTING_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "ipv4/ipv4.h"
00035 
00036 //IPv4 routing support
00037 #ifndef IPV4_ROUTING_SUPPORT
00038    #define IPV4_ROUTING_SUPPORT DISABLED
00039 #elif (IPV4_ROUTING_SUPPORT != ENABLED && IPV4_ROUTING_SUPPORT != DISABLED)
00040    #error IPV4_ROUTING_SUPPORT parameter is not valid
00041 #endif
00042 
00043 //Size of the IPv4 routing table
00044 #ifndef IPV4_ROUTING_TABLE_SIZE
00045    #define IPV4_ROUTING_TABLE_SIZE 8
00046 #elif (IPV4_ROUTING_TABLE_SIZE < 1)
00047    #error IPV4_ROUTING_TABLE_SIZE parameter is not valid
00048 #endif
00049 
00050 
00051 /**
00052  * @brief Routing table entry
00053  **/
00054 
00055 typedef struct
00056 {
00057    bool_t valid;            ///<Valid entry
00058    Ipv4Addr networkDest;    ///<Network destination
00059    Ipv4Addr networkMask;    ///<Subnet mask for this route
00060    NetInterface *interface; ///<Outgoing network interface
00061    Ipv4Addr nextHop;        ///<Next hop
00062    uint_t metric;           ///<Metric value
00063 } Ipv4RoutingTableEntry;
00064 
00065 
00066 //IPv4 routing related functions
00067 error_t ipv4InitRouting(void);
00068 error_t ipv4EnableRouting(NetInterface *interface, bool_t enable);
00069 
00070 error_t ipv4AddRoute(Ipv4Addr networkDest, Ipv4Addr networkMask,
00071    NetInterface *interface, Ipv4Addr nextHop, uint_t metric);
00072 
00073 error_t ipv4DeleteRoute(Ipv4Addr networkDest, Ipv4Addr networkMask);
00074 error_t ipv4DeleteAllRoutes(void);
00075 
00076 error_t ipv4ForwardPacket(NetInterface *srcInterface,
00077    const NetBuffer *ipPacket, size_t ipPacketOffset);
00078 
00079 #endif
00080