6.3   OSPF, Open Shortest Path First

OSPF is an optional and separately purchasable product available from Wind River Systems. The implementation of OSPF supported under VxWorks is OSPF version 2, as defined in RFC-1583. OSPF is an "open" protocol because it was defined in an open way by the Internet Engineering Task Force (IETF). It is a shortest-path-first protocol because its routing protocol is of the Shortest Path First family.

In addition to implementing routing management, the library associated with this implementation of OSPF provides interfaces that you can use to configure the OSPF MIBs (as defined in RFC-1253). You can invoke these services directly, or you can invoke these services indirectly by using the relevant method routines of an SNMP agent. Because OSPF is a complicated protocol to set up and maintain, it is best to use an SNMP agent to handle configuration.

Another consequence of the complexity of OSPF is that documenting it is beyond the scope of this manual. This manual assumes that you already have a good understanding of OSPF and require only the specifics of this implementation. If this is not the case, you should study RFC-1253 and the OSPF reference entries. You should also consult one of the many published texts on OSPF and routing protocols.1

6.3.1   Including OSPF in VxWorks

To include OSPF, reconfigure VxWorks. The relevant configuration macro is INCLUDE_OSPF.

To start OSPF, call ospfInit( ) after VxWorks has completed booting. This routine is defined as follows:

STATUS ospfInit 
    ( 
    int priority,   /* Priority of tasks. */ 
    int options,  
    int stackSize,  /* Task stack size. */ 
    int routerId    /* The ID for this router. */ 
    )

After OSPF is up and running, you must configure the OSPF MIB. To do this, use the various m2Ospf routines. The parameters to these routines are specified in the OSPF MIB as defined in RFC1253. The RFC provides explanations for all of these routines and parameters. In addition, the VxWorks implementation of OSPF supports additional configuration functions:

ospfAddExtRoute( )
Imports an external route into the OSPF domain.

ospfDelExtRoute( )
Deletes a route imported using ospfAddExtRoute( ).

ospfAddNbmaDest( )
Adds a destination on a NBMA (Non Broadcast Multi Access) link.

These routines are not MIB routines. They are convenience interfaces provided for adding and removing external routes. For more information, see reference entries for these routines.

Example 6-1:  Sample OSPF Configuration

This section provides an example router setup as well as the code necessary to make the example work. In the example system, a router is attached to 2 subnets 160.10.10.00 and 160.10.11.00 with 0xffffff00 as the subnetmask. The interface addresses are 160.10.10.5 and 160.10.11.5. The diagram in Figure 6-1 shows this setup.

To set this up programatically, execute the following code:

void ospfSetup () 
    { 
    /* This is a generic setup for all interfaces in the system. */ 
    M2_OSPF_AREA_ENTRY  area; 
    M2_OSPF_IF_ENTRY    intf; 
    area.ospfAreaId = 0x2;   /* using area id 2 
    area.ospfAuthType = 0;   /* no authentication 
    if (m2OspfAreaEntrySet (M2_OSPF_AREA_ID | 
        M2_OSPF_AUTH_TYPE, area) != OK) 
        { 
            return (ERROR); 
        }; 
 
    /* First we set up Interface A */ 
 
    /* set the interface address */ 
    intf.ospfIfIpAddress = 0xa00a0a05; /* 160.10.10.5 */ 
 
    /* address less interface is false */  
    intf.ospfAddressLessIf = 0; 
 
    /* interface area id set to 2 */  
    intf.ospfIfAreaId =  2; 
 
    /* interface type */ 
    intf.ospfIfType =  1; 
 
    /* router priority */ 
    intf.ospfIfRtrPriority = 5; 
 
    /* various  time   intervals */ 
    intf.ospfIfTransitDelay   =   1; 
    intf.ospfIfRetransInterval  =  3; 
    intf.ospfIfHelloInterval = 10; 
    intf.ospfIfRtrDeadInterval = 40; 
    intf.ospfIfPollInterval = 30; 
 
    /* enable ospf on interface */ 
    intf.ospfIfAdminStat = 1; 
 
    /* set the parameters for this interface */ 
    if (m2OspfIfEntrySet( 
        M2_OSPF_ADDRESS_LESS_IF | 
        M2_OSPF_IF_AREA_ID | 
        M2_OSPF_IF_TYPE | 
        M2_OSPF_IF_RTR_PRIORITY | 
        M2_OSPF_IF_RETRANS_INTERVAL | 
        M2_OSPF_IF_HELLO_INTERVAL | 
        M2_OSPF_IF_RTR_DEAD_INTERVAL | 
        M2_OSPF_IF_POLL_INTERVAL | 
        M2_OSPF_IF_ADMIN_STAT, 
        & intf) != OK) 
        { 
        return (ERROR); 
        } 
 
    /* similar sequence for Interface B */ 
    intf.ospfIfIpAddress = 0xa00a0b05; /* 160.10.11.5 */ 
    intf.ospfAddressLessIf  = 0; 
    intf.ospfIfAreaId   =    2; 
    intf.ospfIfType   =    1; 
    intf.ospfIfRtrPriority =  0; 
    intf.ospfIfTransitDelay  =  1; 
    intf.ospfIfRetransInterval  =  3; 
    intf.ospfIfHelloInterval = 10; 
    intf.ospfIfRtrDeadInterval = 40; 
    intf.ospfIfPollInterval = 30; 
    intf.ospfIfAdminStat = 1; 
 
    if (m2OspfIfEntrySet ( M2_OSPF_ADDRESS_LESS_IF | 
        M2_OSPF_IF_AREA_ID | 
        M2_OSPF_IF_TYPE | 
        M2_OSPF_IF_RTR_PRIORITY | 
        M2_OSPF_IF_RETRANS_INTERVAL | 
        M2_OSPF_IF_HELLO_INTERVAL | 
        M2_OSPF_IF_RTR_DEAD_INTERVAL | 
        M2_OSPF_IF_POLL_INTERVAL | 
        M2_OSPF_IF_ADMIN_STAT, & intf) != OK) 
        { 
        return (ERROR); 
        } 
    }

After this code has executed, the system uses OSPF to route between the two interfaces, A and B. The system continues to use OSPF until either the system is shut off or further calls are made into the system using the m2Ospf interfaces.


1:  For example, Routing in the Internet by Christian Huitema.