📄 c-drp3.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title> Dynamic Routing Protocols </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-drp.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-drp.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-drp2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-netapi.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="88563">6.3 OSPF, Open Shortest Path First</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88565"> </a>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. </p><dd><p class="Body"><a name="88566"> </a>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. </p><dd><p class="Body"><a name="88567"> </a>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.<sup><a href="#foot"><b class="FootnoteMarker">1</b></a></sup></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="88571">6.3.1 Including OSPF in VxWorks</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="88574"> </a>To include OSPF, reconfigure VxWorks. The relevant configuration macro is <b class="symbol_UC">INCLUDE_OSPF</b>. </p><dd><p class="Body"><a name="88577"> </a>To start OSPF, call <b class="routine"><i class="routine">ospfInit</i></b><b>( )</b> after VxWorks has completed booting. This routine is defined as follows: </p><dl class="margin"><dd><pre class="Code2"><b><a name="88578">STATUS ospfInit ( int priority, /* Priority of tasks. */ int options, int stackSize, /* Task stack size. */ int routerId /* The ID for this router. */ )</a></b></pre></dl><dd><p class="Body"><a name="88581"> </a>After OSPF is up and running, you must configure the OSPF MIB. To do this, use the various <b class="routine"><i class="routine">m2Ospf </i></b>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:</p></dl><dl class="margin"><dd><div class="Item"><a name="88584"> </a><b class="routine"><i class="routine">ospfAddExtRoute</i></b><b>( )</b></div><dl class="margin"><dd><div class="Indent"><a name="88585"> </a>Imports an external route into the OSPF domain. </div><br></dl><dd><div class="Item"><a name="88587"> </a><b class="routine"><i class="routine">ospfDelExtRoute</i></b><b>( )</b></div><dl class="margin"><dd><div class="Indent"><a name="88588"> </a>Deletes a route imported using <b class="routine"><i class="routine">ospfAddExtRoute</i></b><b>( )</b>. </div><br></dl><dd><div class="Item"><a name="88590"> </a><b class="routine"><i class="routine">ospfAddNbmaDest</i></b><b>( )</b></div><dl class="margin"><dd><div class="Indent"><a name="88591"> </a>Adds a destination on a NBMA (Non Broadcast Multi Access) link.</div><br></dl></dl><dl class="margin"><dd><p class="Body"><a name="88592"> </a>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.</p></dl></dl><h4 class="EntityTitle"><a name="88593"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-1: Sample OSPF Configuration </font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="93387"> </a>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 <a href="c-drp3.html#93365">Figure 6-1</a> shows this setup.<div class="frame"><h4 class="EntityTitle"><a name="93365"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6-1: Example Router Setup</font></a></h4><dl class="margin"><div class="CellBody"><a name="93386"> </a><img class="figure" border="0" src="images/c-drpa.gif"></div></dl></div></p><dd><p class="Body"><a name="88623"> </a>To set this up programatically, execute the following code:</p></dl><dl class="margin"><dd><pre class="Code"><b><a name="88624">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); } }</a></b></pre></dl><dl class="margin"><dd><p class="Body"><a name="88625"> </a>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 <b class="routine"><i class="routine">m2Ospf </i></b>interfaces.</p></dl></dl><a name="foot"><hr></a><p class="FootnoteNumberMarker">1: <span class="Footnote"><a name="88570"> </a>For example, <i class="title">Routing in the Internet</i> by Christian Huitema.</span><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-drp.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-drp.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-drp2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-netapi.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc. conversion tool: Quadralay WebWorks Publisher 4.0.11 template: CSS Template, Jan 1998 - Jefro --->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -