ospf_vty.c 220 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727
  1. /* OSPF VTY interface.
  2. * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
  3. * Copyright (C) 2000 Toshiaki Takada
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  19. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. */
  22. #include <zebra.h>
  23. #include "memory.h"
  24. #include "thread.h"
  25. #include "prefix.h"
  26. #include "table.h"
  27. #include "vty.h"
  28. #include "command.h"
  29. #include "plist.h"
  30. #include "log.h"
  31. #include "zclient.h"
  32. #include "ospfd/ospfd.h"
  33. #include "ospfd/ospf_asbr.h"
  34. #include "ospfd/ospf_lsa.h"
  35. #include "ospfd/ospf_lsdb.h"
  36. #include "ospfd/ospf_ism.h"
  37. #include "ospfd/ospf_interface.h"
  38. #include "ospfd/ospf_nsm.h"
  39. #include "ospfd/ospf_neighbor.h"
  40. #include "ospfd/ospf_flood.h"
  41. #include "ospfd/ospf_abr.h"
  42. #include "ospfd/ospf_spf.h"
  43. #include "ospfd/ospf_route.h"
  44. #include "ospfd/ospf_zebra.h"
  45. /*#include "ospfd/ospf_routemap.h" */
  46. #include "ospfd/ospf_vty.h"
  47. #include "ospfd/ospf_dump.h"
  48. static const char *ospf_network_type_str[] =
  49. {
  50. "Null",
  51. "POINTOPOINT",
  52. "BROADCAST",
  53. "NBMA",
  54. "POINTOMULTIPOINT",
  55. "VIRTUALLINK",
  56. "LOOPBACK"
  57. };
  58. /* Utility functions. */
  59. static int
  60. ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
  61. {
  62. char *endptr = NULL;
  63. unsigned long ret;
  64. /* match "A.B.C.D". */
  65. if (strchr (str, '.') != NULL)
  66. {
  67. ret = inet_aton (str, area_id);
  68. if (!ret)
  69. return -1;
  70. *format = OSPF_AREA_ID_FORMAT_ADDRESS;
  71. }
  72. /* match "<0-4294967295>". */
  73. else
  74. {
  75. if (*str == '-')
  76. return -1;
  77. errno = 0;
  78. ret = strtoul (str, &endptr, 10);
  79. if (*endptr != '\0' || errno || ret > UINT32_MAX)
  80. return -1;
  81. area_id->s_addr = htonl (ret);
  82. *format = OSPF_AREA_ID_FORMAT_DECIMAL;
  83. }
  84. return 0;
  85. }
  86. static int
  87. str2metric (const char *str, int *metric)
  88. {
  89. /* Sanity check. */
  90. if (str == NULL)
  91. return 0;
  92. *metric = strtol (str, NULL, 10);
  93. if (*metric < 0 && *metric > 16777214)
  94. {
  95. /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
  96. return 0;
  97. }
  98. return 1;
  99. }
  100. static int
  101. str2metric_type (const char *str, int *metric_type)
  102. {
  103. /* Sanity check. */
  104. if (str == NULL)
  105. return 0;
  106. if (strncmp (str, "1", 1) == 0)
  107. *metric_type = EXTERNAL_METRIC_TYPE_1;
  108. else if (strncmp (str, "2", 1) == 0)
  109. *metric_type = EXTERNAL_METRIC_TYPE_2;
  110. else
  111. return 0;
  112. return 1;
  113. }
  114. int
  115. ospf_oi_count (struct interface *ifp)
  116. {
  117. struct route_node *rn;
  118. int i = 0;
  119. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  120. if (rn->info)
  121. i++;
  122. return i;
  123. }
  124. DEFUN (router_ospf,
  125. router_ospf_cmd,
  126. "router ospf",
  127. "Enable a routing process\n"
  128. "Start OSPF configuration\n")
  129. {
  130. vty->node = OSPF_NODE;
  131. vty->index = ospf_get ();
  132. return CMD_SUCCESS;
  133. }
  134. DEFUN (no_router_ospf,
  135. no_router_ospf_cmd,
  136. "no router ospf",
  137. NO_STR
  138. "Enable a routing process\n"
  139. "Start OSPF configuration\n")
  140. {
  141. struct ospf *ospf;
  142. ospf = ospf_lookup ();
  143. if (ospf == NULL)
  144. {
  145. vty_out (vty, "There isn't active ospf instance%s", VTY_NEWLINE);
  146. return CMD_WARNING;
  147. }
  148. ospf_finish (ospf);
  149. return CMD_SUCCESS;
  150. }
  151. DEFUN (ospf_router_id,
  152. ospf_router_id_cmd,
  153. "ospf router-id A.B.C.D",
  154. "OSPF specific commands\n"
  155. "router-id for the OSPF process\n"
  156. "OSPF router-id in IP address format\n")
  157. {
  158. struct ospf *ospf = vty->index;
  159. struct in_addr router_id;
  160. int ret;
  161. ret = inet_aton (argv[0], &router_id);
  162. if (!ret)
  163. {
  164. vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
  165. return CMD_WARNING;
  166. }
  167. ospf->router_id_static = router_id;
  168. ospf_router_id_update (ospf);
  169. return CMD_SUCCESS;
  170. }
  171. ALIAS (ospf_router_id,
  172. router_ospf_id_cmd,
  173. "router-id A.B.C.D",
  174. "router-id for the OSPF process\n"
  175. "OSPF router-id in IP address format\n")
  176. DEFUN (no_ospf_router_id,
  177. no_ospf_router_id_cmd,
  178. "no ospf router-id",
  179. NO_STR
  180. "OSPF specific commands\n"
  181. "router-id for the OSPF process\n")
  182. {
  183. struct ospf *ospf = vty->index;
  184. ospf->router_id_static.s_addr = 0;
  185. ospf_router_id_update (ospf);
  186. return CMD_SUCCESS;
  187. }
  188. ALIAS (no_ospf_router_id,
  189. no_router_ospf_id_cmd,
  190. "no router-id",
  191. NO_STR
  192. "router-id for the OSPF process\n")
  193. static void
  194. ospf_passive_interface_default (struct ospf *ospf, u_char newval)
  195. {
  196. struct listnode *ln;
  197. struct interface *ifp;
  198. struct ospf_interface *oi;
  199. ospf->passive_interface_default = newval;
  200. for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
  201. {
  202. if (ifp &&
  203. OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
  204. UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
  205. }
  206. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
  207. {
  208. if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
  209. UNSET_IF_PARAM (oi->params, passive_interface);
  210. /* update multicast memberships */
  211. ospf_if_set_multicast(oi);
  212. }
  213. }
  214. static void
  215. ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
  216. struct in_addr addr,
  217. struct ospf_if_params *params, u_char value)
  218. {
  219. u_char dflt;
  220. params->passive_interface = value;
  221. if (params != IF_DEF_PARAMS (ifp))
  222. {
  223. if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
  224. dflt = IF_DEF_PARAMS (ifp)->passive_interface;
  225. else
  226. dflt = ospf->passive_interface_default;
  227. if (value != dflt)
  228. SET_IF_PARAM (params, passive_interface);
  229. else
  230. UNSET_IF_PARAM (params, passive_interface);
  231. ospf_free_if_params (ifp, addr);
  232. ospf_if_update_params (ifp, addr);
  233. }
  234. else
  235. {
  236. if (value != ospf->passive_interface_default)
  237. SET_IF_PARAM (params, passive_interface);
  238. else
  239. UNSET_IF_PARAM (params, passive_interface);
  240. }
  241. }
  242. DEFUN (ospf_passive_interface,
  243. ospf_passive_interface_addr_cmd,
  244. "passive-interface IFNAME A.B.C.D",
  245. "Suppress routing updates on an interface\n"
  246. "Interface's name\n")
  247. {
  248. struct interface *ifp;
  249. struct in_addr addr;
  250. int ret;
  251. struct ospf_if_params *params;
  252. struct route_node *rn;
  253. struct ospf *ospf = vty->index;
  254. if (argc == 0)
  255. {
  256. ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
  257. return CMD_SUCCESS;
  258. }
  259. ifp = if_get_by_name (argv[0]);
  260. params = IF_DEF_PARAMS (ifp);
  261. if (argc == 2)
  262. {
  263. ret = inet_aton(argv[1], &addr);
  264. if (!ret)
  265. {
  266. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  267. VTY_NEWLINE);
  268. return CMD_WARNING;
  269. }
  270. params = ospf_get_if_params (ifp, addr);
  271. ospf_if_update_params (ifp, addr);
  272. }
  273. ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_PASSIVE);
  274. /* XXX We should call ospf_if_set_multicast on exactly those
  275. * interfaces for which the passive property changed. It is too much
  276. * work to determine this set, so we do this for every interface.
  277. * This is safe and reasonable because ospf_if_set_multicast uses a
  278. * record of joined groups to avoid systems calls if the desired
  279. * memberships match the current memership.
  280. */
  281. for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
  282. {
  283. struct ospf_interface *oi = rn->info;
  284. if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
  285. ospf_if_set_multicast(oi);
  286. }
  287. /*
  288. * XXX It is not clear what state transitions the interface needs to
  289. * undergo when going from active to passive. Fixing this will
  290. * require precise identification of interfaces having such a
  291. * transition.
  292. */
  293. return CMD_SUCCESS;
  294. }
  295. ALIAS (ospf_passive_interface,
  296. ospf_passive_interface_cmd,
  297. "passive-interface IFNAME",
  298. "Suppress routing updates on an interface\n"
  299. "Interface's name\n")
  300. ALIAS (ospf_passive_interface,
  301. ospf_passive_interface_default_cmd,
  302. "passive-interface default",
  303. "Suppress routing updates on an interface\n"
  304. "Suppress routing updates on interfaces by default\n")
  305. DEFUN (no_ospf_passive_interface,
  306. no_ospf_passive_interface_addr_cmd,
  307. "no passive-interface IFNAME A.B.C.D",
  308. NO_STR
  309. "Allow routing updates on an interface\n"
  310. "Interface's name\n")
  311. {
  312. struct interface *ifp;
  313. struct in_addr addr;
  314. struct ospf_if_params *params;
  315. int ret;
  316. struct route_node *rn;
  317. struct ospf *ospf = vty->index;
  318. if (argc == 0)
  319. {
  320. ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
  321. return CMD_SUCCESS;
  322. }
  323. ifp = if_get_by_name (argv[0]);
  324. params = IF_DEF_PARAMS (ifp);
  325. if (argc == 2)
  326. {
  327. ret = inet_aton(argv[1], &addr);
  328. if (!ret)
  329. {
  330. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  331. VTY_NEWLINE);
  332. return CMD_WARNING;
  333. }
  334. params = ospf_lookup_if_params (ifp, addr);
  335. if (params == NULL)
  336. return CMD_SUCCESS;
  337. }
  338. ospf_passive_interface_update (ospf, ifp, addr, params, OSPF_IF_ACTIVE);
  339. /* XXX We should call ospf_if_set_multicast on exactly those
  340. * interfaces for which the passive property changed. It is too much
  341. * work to determine this set, so we do this for every interface.
  342. * This is safe and reasonable because ospf_if_set_multicast uses a
  343. * record of joined groups to avoid systems calls if the desired
  344. * memberships match the current memership.
  345. */
  346. for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
  347. {
  348. struct ospf_interface *oi = rn->info;
  349. if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
  350. ospf_if_set_multicast(oi);
  351. }
  352. return CMD_SUCCESS;
  353. }
  354. ALIAS (no_ospf_passive_interface,
  355. no_ospf_passive_interface_cmd,
  356. "no passive-interface IFNAME",
  357. NO_STR
  358. "Allow routing updates on an interface\n"
  359. "Interface's name\n")
  360. ALIAS (no_ospf_passive_interface,
  361. no_ospf_passive_interface_default_cmd,
  362. "no passive-interface default",
  363. NO_STR
  364. "Allow routing updates on an interface\n"
  365. "Allow routing updates on interfaces by default\n")
  366. DEFUN (ospf_network_area,
  367. ospf_network_area_cmd,
  368. "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
  369. "Enable routing on an IP network\n"
  370. "OSPF network prefix\n"
  371. "Set the OSPF area ID\n"
  372. "OSPF area ID in IP address format\n"
  373. "OSPF area ID as a decimal value\n")
  374. {
  375. struct ospf *ospf= vty->index;
  376. struct prefix_ipv4 p;
  377. struct in_addr area_id;
  378. int ret, format;
  379. /* Get network prefix and Area ID. */
  380. VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
  381. VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
  382. ret = ospf_network_set (ospf, &p, area_id);
  383. if (ret == 0)
  384. {
  385. vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
  386. return CMD_WARNING;
  387. }
  388. return CMD_SUCCESS;
  389. }
  390. DEFUN (no_ospf_network_area,
  391. no_ospf_network_area_cmd,
  392. "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
  393. NO_STR
  394. "Enable routing on an IP network\n"
  395. "OSPF network prefix\n"
  396. "Set the OSPF area ID\n"
  397. "OSPF area ID in IP address format\n"
  398. "OSPF area ID as a decimal value\n")
  399. {
  400. struct ospf *ospf = (struct ospf *) vty->index;
  401. struct prefix_ipv4 p;
  402. struct in_addr area_id;
  403. int ret, format;
  404. /* Get network prefix and Area ID. */
  405. VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
  406. VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
  407. ret = ospf_network_unset (ospf, &p, area_id);
  408. if (ret == 0)
  409. {
  410. vty_out (vty, "Can't find specified network area configuration.%s",
  411. VTY_NEWLINE);
  412. return CMD_WARNING;
  413. }
  414. return CMD_SUCCESS;
  415. }
  416. DEFUN (ospf_area_range,
  417. ospf_area_range_cmd,
  418. "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
  419. "OSPF area parameters\n"
  420. "OSPF area ID in IP address format\n"
  421. "OSPF area ID as a decimal value\n"
  422. "Summarize routes matching address/mask (border routers only)\n"
  423. "Area range prefix\n")
  424. {
  425. struct ospf *ospf = vty->index;
  426. struct prefix_ipv4 p;
  427. struct in_addr area_id;
  428. int format;
  429. u_int32_t cost;
  430. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  431. VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
  432. ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
  433. if (argc > 2)
  434. {
  435. VTY_GET_INTEGER ("range cost", cost, argv[2]);
  436. ospf_area_range_cost_set (ospf, area_id, &p, cost);
  437. }
  438. return CMD_SUCCESS;
  439. }
  440. ALIAS (ospf_area_range,
  441. ospf_area_range_advertise_cmd,
  442. "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
  443. "OSPF area parameters\n"
  444. "OSPF area ID in IP address format\n"
  445. "OSPF area ID as a decimal value\n"
  446. "OSPF area range for route advertise (default)\n"
  447. "Area range prefix\n"
  448. "Advertise this range (default)\n")
  449. ALIAS (ospf_area_range,
  450. ospf_area_range_cost_cmd,
  451. "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
  452. "OSPF area parameters\n"
  453. "OSPF area ID in IP address format\n"
  454. "OSPF area ID as a decimal value\n"
  455. "Summarize routes matching address/mask (border routers only)\n"
  456. "Area range prefix\n"
  457. "User specified metric for this range\n"
  458. "Advertised metric for this range\n")
  459. ALIAS (ospf_area_range,
  460. ospf_area_range_advertise_cost_cmd,
  461. "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
  462. "OSPF area parameters\n"
  463. "OSPF area ID in IP address format\n"
  464. "OSPF area ID as a decimal value\n"
  465. "Summarize routes matching address/mask (border routers only)\n"
  466. "Area range prefix\n"
  467. "Advertise this range (default)\n"
  468. "User specified metric for this range\n"
  469. "Advertised metric for this range\n")
  470. DEFUN (ospf_area_range_not_advertise,
  471. ospf_area_range_not_advertise_cmd,
  472. "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
  473. "OSPF area parameters\n"
  474. "OSPF area ID in IP address format\n"
  475. "OSPF area ID as a decimal value\n"
  476. "Summarize routes matching address/mask (border routers only)\n"
  477. "Area range prefix\n"
  478. "DoNotAdvertise this range\n")
  479. {
  480. struct ospf *ospf = vty->index;
  481. struct prefix_ipv4 p;
  482. struct in_addr area_id;
  483. int format;
  484. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  485. VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
  486. ospf_area_range_set (ospf, area_id, &p, 0);
  487. return CMD_SUCCESS;
  488. }
  489. DEFUN (no_ospf_area_range,
  490. no_ospf_area_range_cmd,
  491. "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
  492. NO_STR
  493. "OSPF area parameters\n"
  494. "OSPF area ID in IP address format\n"
  495. "OSPF area ID as a decimal value\n"
  496. "Summarize routes matching address/mask (border routers only)\n"
  497. "Area range prefix\n")
  498. {
  499. struct ospf *ospf = vty->index;
  500. struct prefix_ipv4 p;
  501. struct in_addr area_id;
  502. int format;
  503. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  504. VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
  505. ospf_area_range_unset (ospf, area_id, &p);
  506. return CMD_SUCCESS;
  507. }
  508. ALIAS (no_ospf_area_range,
  509. no_ospf_area_range_advertise_cmd,
  510. "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
  511. NO_STR
  512. "OSPF area parameters\n"
  513. "OSPF area ID in IP address format\n"
  514. "OSPF area ID as a decimal value\n"
  515. "Summarize routes matching address/mask (border routers only)\n"
  516. "Area range prefix\n"
  517. "Advertise this range (default)\n"
  518. "DoNotAdvertise this range\n")
  519. ALIAS (no_ospf_area_range,
  520. no_ospf_area_range_cost_cmd,
  521. "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
  522. NO_STR
  523. "OSPF area parameters\n"
  524. "OSPF area ID in IP address format\n"
  525. "OSPF area ID as a decimal value\n"
  526. "Summarize routes matching address/mask (border routers only)\n"
  527. "Area range prefix\n"
  528. "User specified metric for this range\n"
  529. "Advertised metric for this range\n")
  530. ALIAS (no_ospf_area_range,
  531. no_ospf_area_range_advertise_cost_cmd,
  532. "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
  533. NO_STR
  534. "OSPF area parameters\n"
  535. "OSPF area ID in IP address format\n"
  536. "OSPF area ID as a decimal value\n"
  537. "Summarize routes matching address/mask (border routers only)\n"
  538. "Area range prefix\n"
  539. "Advertise this range (default)\n"
  540. "User specified metric for this range\n"
  541. "Advertised metric for this range\n")
  542. DEFUN (ospf_area_range_substitute,
  543. ospf_area_range_substitute_cmd,
  544. "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
  545. "OSPF area parameters\n"
  546. "OSPF area ID in IP address format\n"
  547. "OSPF area ID as a decimal value\n"
  548. "Summarize routes matching address/mask (border routers only)\n"
  549. "Area range prefix\n"
  550. "Announce area range as another prefix\n"
  551. "Network prefix to be announced instead of range\n")
  552. {
  553. struct ospf *ospf = vty->index;
  554. struct prefix_ipv4 p, s;
  555. struct in_addr area_id;
  556. int format;
  557. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  558. VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
  559. VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
  560. ospf_area_range_substitute_set (ospf, area_id, &p, &s);
  561. return CMD_SUCCESS;
  562. }
  563. DEFUN (no_ospf_area_range_substitute,
  564. no_ospf_area_range_substitute_cmd,
  565. "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
  566. NO_STR
  567. "OSPF area parameters\n"
  568. "OSPF area ID in IP address format\n"
  569. "OSPF area ID as a decimal value\n"
  570. "Summarize routes matching address/mask (border routers only)\n"
  571. "Area range prefix\n"
  572. "Announce area range as another prefix\n"
  573. "Network prefix to be announced instead of range\n")
  574. {
  575. struct ospf *ospf = vty->index;
  576. struct prefix_ipv4 p, s;
  577. struct in_addr area_id;
  578. int format;
  579. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  580. VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
  581. VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
  582. ospf_area_range_substitute_unset (ospf, area_id, &p);
  583. return CMD_SUCCESS;
  584. }
  585. /* Command Handler Logic in VLink stuff is delicate!!
  586. ALTER AT YOUR OWN RISK!!!!
  587. Various dummy values are used to represent 'NoChange' state for
  588. VLink configuration NOT being changed by a VLink command, and
  589. special syntax is used within the command strings so that the
  590. typed in command verbs can be seen in the configuration command
  591. bacckend handler. This is to drastically reduce the verbeage
  592. required to coe up with a reasonably compatible Cisco VLink command
  593. - Matthew Grant <grantma@anathoth.gen.nz>
  594. Wed, 21 Feb 2001 15:13:52 +1300
  595. */
  596. /* Configuration data for virtual links
  597. */
  598. struct ospf_vl_config_data {
  599. struct vty *vty; /* vty stuff */
  600. struct in_addr area_id; /* area ID from command line */
  601. int format; /* command line area ID format */
  602. struct in_addr vl_peer; /* command line vl_peer */
  603. int auth_type; /* Authehntication type, if given */
  604. char *auth_key; /* simple password if present */
  605. int crypto_key_id; /* Cryptographic key ID */
  606. char *md5_key; /* MD5 authentication key */
  607. int hello_interval; /* Obvious what these are... */
  608. int retransmit_interval;
  609. int transmit_delay;
  610. int dead_interval;
  611. };
  612. static void
  613. ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
  614. struct vty *vty)
  615. {
  616. memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
  617. vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
  618. vl_config->vty = vty;
  619. }
  620. static struct ospf_vl_data *
  621. ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
  622. {
  623. struct ospf_area *area;
  624. struct ospf_vl_data *vl_data;
  625. struct vty *vty;
  626. struct in_addr area_id;
  627. vty = vl_config->vty;
  628. area_id = vl_config->area_id;
  629. if (area_id.s_addr == OSPF_AREA_BACKBONE)
  630. {
  631. vty_out (vty,
  632. "Configuring VLs over the backbone is not allowed%s",
  633. VTY_NEWLINE);
  634. return NULL;
  635. }
  636. area = ospf_area_get (ospf, area_id, vl_config->format);
  637. if (area->external_routing != OSPF_AREA_DEFAULT)
  638. {
  639. if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
  640. vty_out (vty, "Area %s is %s%s",
  641. inet_ntoa (area_id),
  642. area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
  643. VTY_NEWLINE);
  644. else
  645. vty_out (vty, "Area %ld is %s%s",
  646. (u_long)ntohl (area_id.s_addr),
  647. area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
  648. VTY_NEWLINE);
  649. return NULL;
  650. }
  651. if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
  652. {
  653. vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
  654. if (vl_data->vl_oi == NULL)
  655. {
  656. vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
  657. ospf_vl_add (ospf, vl_data);
  658. ospf_spf_calculate_schedule (ospf);
  659. }
  660. }
  661. return vl_data;
  662. }
  663. static int
  664. ospf_vl_set_security (struct ospf_vl_data *vl_data,
  665. struct ospf_vl_config_data *vl_config)
  666. {
  667. struct crypt_key *ck;
  668. struct vty *vty;
  669. struct interface *ifp = vl_data->vl_oi->ifp;
  670. vty = vl_config->vty;
  671. if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
  672. {
  673. SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
  674. IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
  675. }
  676. if (vl_config->auth_key)
  677. {
  678. memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
  679. strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
  680. OSPF_AUTH_SIMPLE_SIZE);
  681. }
  682. else if (vl_config->md5_key)
  683. {
  684. if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
  685. != NULL)
  686. {
  687. vty_out (vty, "OSPF: Key %d already exists%s",
  688. vl_config->crypto_key_id, VTY_NEWLINE);
  689. return CMD_WARNING;
  690. }
  691. ck = ospf_crypt_key_new ();
  692. ck->key_id = vl_config->crypto_key_id;
  693. memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
  694. strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
  695. ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
  696. }
  697. else if (vl_config->crypto_key_id != 0)
  698. {
  699. /* Delete a key */
  700. if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
  701. vl_config->crypto_key_id) == NULL)
  702. {
  703. vty_out (vty, "OSPF: Key %d does not exist%s",
  704. vl_config->crypto_key_id, VTY_NEWLINE);
  705. return CMD_WARNING;
  706. }
  707. ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
  708. }
  709. return CMD_SUCCESS;
  710. }
  711. static int
  712. ospf_vl_set_timers (struct ospf_vl_data *vl_data,
  713. struct ospf_vl_config_data *vl_config)
  714. {
  715. struct interface *ifp = ifp = vl_data->vl_oi->ifp;
  716. /* Virtual Link data initialised to defaults, so only set
  717. if a value given */
  718. if (vl_config->hello_interval)
  719. {
  720. SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
  721. IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
  722. }
  723. if (vl_config->dead_interval)
  724. {
  725. SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
  726. IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
  727. }
  728. if (vl_config->retransmit_interval)
  729. {
  730. SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
  731. IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
  732. }
  733. if (vl_config->transmit_delay)
  734. {
  735. SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
  736. IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
  737. }
  738. return CMD_SUCCESS;
  739. }
  740. /* The business end of all of the above */
  741. static int
  742. ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
  743. {
  744. struct ospf_vl_data *vl_data;
  745. int ret;
  746. vl_data = ospf_find_vl_data (ospf, vl_config);
  747. if (!vl_data)
  748. return CMD_WARNING;
  749. /* Process this one first as it can have a fatal result, which can
  750. only logically occur if the virtual link exists already
  751. Thus a command error does not result in a change to the
  752. running configuration such as unexpectedly altered timer
  753. values etc.*/
  754. ret = ospf_vl_set_security (vl_data, vl_config);
  755. if (ret != CMD_SUCCESS)
  756. return ret;
  757. /* Set any time based parameters, these area already range checked */
  758. ret = ospf_vl_set_timers (vl_data, vl_config);
  759. if (ret != CMD_SUCCESS)
  760. return ret;
  761. return CMD_SUCCESS;
  762. }
  763. /* This stuff exists to make specifying all the alias commands A LOT simpler
  764. */
  765. #define VLINK_HELPSTR_IPADDR \
  766. "OSPF area parameters\n" \
  767. "OSPF area ID in IP address format\n" \
  768. "OSPF area ID as a decimal value\n" \
  769. "Configure a virtual link\n" \
  770. "Router ID of the remote ABR\n"
  771. #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
  772. "Enable authentication on this virtual link\n" \
  773. "dummy string \n"
  774. #define VLINK_HELPSTR_AUTHTYPE_ALL \
  775. VLINK_HELPSTR_AUTHTYPE_SIMPLE \
  776. "Use null authentication\n" \
  777. "Use message-digest authentication\n"
  778. #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
  779. "Time between HELLO packets\n" \
  780. "Time between retransmitting lost link state advertisements\n" \
  781. "Link state transmit delay\n" \
  782. "Interval after which a neighbor is declared dead\n"
  783. #define VLINK_HELPSTR_TIME_PARAM \
  784. VLINK_HELPSTR_TIME_PARAM_NOSECS \
  785. "Seconds\n"
  786. #define VLINK_HELPSTR_AUTH_SIMPLE \
  787. "Authentication password (key)\n" \
  788. "The OSPF password (key)"
  789. #define VLINK_HELPSTR_AUTH_MD5 \
  790. "Message digest authentication password (key)\n" \
  791. "dummy string \n" \
  792. "Key ID\n" \
  793. "Use MD5 algorithm\n" \
  794. "The OSPF password (key)"
  795. DEFUN (ospf_area_vlink,
  796. ospf_area_vlink_cmd,
  797. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
  798. VLINK_HELPSTR_IPADDR)
  799. {
  800. struct ospf *ospf = vty->index;
  801. struct ospf_vl_config_data vl_config;
  802. char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
  803. char md5_key[OSPF_AUTH_MD5_SIZE+1];
  804. int i;
  805. int ret;
  806. ospf_vl_config_data_init(&vl_config, vty);
  807. /* Read off first 2 parameters and check them */
  808. ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
  809. if (ret < 0)
  810. {
  811. vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
  812. return CMD_WARNING;
  813. }
  814. ret = inet_aton (argv[1], &vl_config.vl_peer);
  815. if (! ret)
  816. {
  817. vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
  818. VTY_NEWLINE);
  819. return CMD_WARNING;
  820. }
  821. if (argc <=2)
  822. {
  823. /* Thats all folks! - BUGS B. strikes again!!!*/
  824. return ospf_vl_set (ospf, &vl_config);
  825. }
  826. /* Deal with other parameters */
  827. for (i=2; i < argc; i++)
  828. {
  829. /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
  830. switch (argv[i][0])
  831. {
  832. case 'a':
  833. if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
  834. {
  835. /* authentication-key - this option can occur anywhere on
  836. command line. At start of command line
  837. must check for authentication option. */
  838. memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
  839. strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
  840. vl_config.auth_key = auth_key;
  841. i++;
  842. }
  843. else if (strncmp (argv[i], "authentication", 14) == 0)
  844. {
  845. /* authentication - this option can only occur at start
  846. of command line */
  847. vl_config.auth_type = OSPF_AUTH_SIMPLE;
  848. if ((i+1) < argc)
  849. {
  850. if (strncmp (argv[i+1], "n", 1) == 0)
  851. {
  852. /* "authentication null" */
  853. vl_config.auth_type = OSPF_AUTH_NULL;
  854. i++;
  855. }
  856. else if (strncmp (argv[i+1], "m", 1) == 0
  857. && strcmp (argv[i+1], "message-digest-") != 0)
  858. {
  859. /* "authentication message-digest" */
  860. vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
  861. i++;
  862. }
  863. }
  864. }
  865. break;
  866. case 'm':
  867. /* message-digest-key */
  868. i++;
  869. vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
  870. if (vl_config.crypto_key_id < 0)
  871. return CMD_WARNING;
  872. i++;
  873. memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
  874. strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
  875. vl_config.md5_key = md5_key;
  876. break;
  877. case 'h':
  878. /* Hello interval */
  879. i++;
  880. vl_config.hello_interval = strtol (argv[i], NULL, 10);
  881. if (vl_config.hello_interval < 0)
  882. return CMD_WARNING;
  883. break;
  884. case 'r':
  885. /* Retransmit Interval */
  886. i++;
  887. vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
  888. if (vl_config.retransmit_interval < 0)
  889. return CMD_WARNING;
  890. break;
  891. case 't':
  892. /* Transmit Delay */
  893. i++;
  894. vl_config.transmit_delay = strtol (argv[i], NULL, 10);
  895. if (vl_config.transmit_delay < 0)
  896. return CMD_WARNING;
  897. break;
  898. case 'd':
  899. /* Dead Interval */
  900. i++;
  901. vl_config.dead_interval = strtol (argv[i], NULL, 10);
  902. if (vl_config.dead_interval < 0)
  903. return CMD_WARNING;
  904. break;
  905. }
  906. }
  907. /* Action configuration */
  908. return ospf_vl_set (ospf, &vl_config);
  909. }
  910. DEFUN (no_ospf_area_vlink,
  911. no_ospf_area_vlink_cmd,
  912. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
  913. NO_STR
  914. VLINK_HELPSTR_IPADDR)
  915. {
  916. struct ospf *ospf = vty->index;
  917. struct ospf_area *area;
  918. struct ospf_vl_config_data vl_config;
  919. struct ospf_vl_data *vl_data = NULL;
  920. char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
  921. int i;
  922. int ret, format;
  923. ospf_vl_config_data_init(&vl_config, vty);
  924. ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
  925. if (ret < 0)
  926. {
  927. vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
  928. return CMD_WARNING;
  929. }
  930. area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
  931. if (!area)
  932. {
  933. vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
  934. return CMD_WARNING;
  935. }
  936. ret = inet_aton (argv[1], &vl_config.vl_peer);
  937. if (! ret)
  938. {
  939. vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
  940. VTY_NEWLINE);
  941. return CMD_WARNING;
  942. }
  943. if (argc <=2)
  944. {
  945. /* Basic VLink no command */
  946. /* Thats all folks! - BUGS B. strikes again!!!*/
  947. if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
  948. ospf_vl_delete (ospf, vl_data);
  949. ospf_area_check_free (ospf, vl_config.area_id);
  950. return CMD_SUCCESS;
  951. }
  952. /* If we are down here, we are reseting parameters */
  953. /* Deal with other parameters */
  954. for (i=2; i < argc; i++)
  955. {
  956. /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
  957. switch (argv[i][0])
  958. {
  959. case 'a':
  960. if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
  961. {
  962. /* authentication-key - this option can occur anywhere on
  963. command line. At start of command line
  964. must check for authentication option. */
  965. memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
  966. vl_config.auth_key = auth_key;
  967. }
  968. else if (strncmp (argv[i], "authentication", 14) == 0)
  969. {
  970. /* authentication - this option can only occur at start
  971. of command line */
  972. vl_config.auth_type = OSPF_AUTH_NOTSET;
  973. }
  974. break;
  975. case 'm':
  976. /* message-digest-key */
  977. /* Delete one key */
  978. i++;
  979. vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
  980. if (vl_config.crypto_key_id < 0)
  981. return CMD_WARNING;
  982. vl_config.md5_key = NULL;
  983. break;
  984. case 'h':
  985. /* Hello interval */
  986. vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
  987. break;
  988. case 'r':
  989. /* Retransmit Interval */
  990. vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
  991. break;
  992. case 't':
  993. /* Transmit Delay */
  994. vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
  995. break;
  996. case 'd':
  997. /* Dead Interval */
  998. i++;
  999. vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
  1000. break;
  1001. }
  1002. }
  1003. /* Action configuration */
  1004. return ospf_vl_set (ospf, &vl_config);
  1005. }
  1006. ALIAS (ospf_area_vlink,
  1007. ospf_area_vlink_param1_cmd,
  1008. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1009. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
  1010. VLINK_HELPSTR_IPADDR
  1011. VLINK_HELPSTR_TIME_PARAM)
  1012. ALIAS (no_ospf_area_vlink,
  1013. no_ospf_area_vlink_param1_cmd,
  1014. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1015. "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
  1016. NO_STR
  1017. VLINK_HELPSTR_IPADDR
  1018. VLINK_HELPSTR_TIME_PARAM)
  1019. ALIAS (ospf_area_vlink,
  1020. ospf_area_vlink_param2_cmd,
  1021. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1022. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
  1023. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
  1024. VLINK_HELPSTR_IPADDR
  1025. VLINK_HELPSTR_TIME_PARAM
  1026. VLINK_HELPSTR_TIME_PARAM)
  1027. ALIAS (no_ospf_area_vlink,
  1028. no_ospf_area_vlink_param2_cmd,
  1029. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1030. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
  1031. "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
  1032. NO_STR
  1033. VLINK_HELPSTR_IPADDR
  1034. VLINK_HELPSTR_TIME_PARAM
  1035. VLINK_HELPSTR_TIME_PARAM)
  1036. ALIAS (ospf_area_vlink,
  1037. ospf_area_vlink_param3_cmd,
  1038. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1039. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
  1040. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
  1041. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
  1042. VLINK_HELPSTR_IPADDR
  1043. VLINK_HELPSTR_TIME_PARAM
  1044. VLINK_HELPSTR_TIME_PARAM
  1045. VLINK_HELPSTR_TIME_PARAM)
  1046. ALIAS (no_ospf_area_vlink,
  1047. no_ospf_area_vlink_param3_cmd,
  1048. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1049. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
  1050. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
  1051. "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
  1052. NO_STR
  1053. VLINK_HELPSTR_IPADDR
  1054. VLINK_HELPSTR_TIME_PARAM
  1055. VLINK_HELPSTR_TIME_PARAM
  1056. VLINK_HELPSTR_TIME_PARAM)
  1057. ALIAS (ospf_area_vlink,
  1058. ospf_area_vlink_param4_cmd,
  1059. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1060. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
  1061. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
  1062. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
  1063. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
  1064. VLINK_HELPSTR_IPADDR
  1065. VLINK_HELPSTR_TIME_PARAM
  1066. VLINK_HELPSTR_TIME_PARAM
  1067. VLINK_HELPSTR_TIME_PARAM
  1068. VLINK_HELPSTR_TIME_PARAM)
  1069. ALIAS (no_ospf_area_vlink,
  1070. no_ospf_area_vlink_param4_cmd,
  1071. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1072. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
  1073. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
  1074. "(hello-interval|retransmit-interval|transmit-delay|dead-interval) "
  1075. "(hello-interval|retransmit-interval|transmit-delay|dead-interval)",
  1076. NO_STR
  1077. VLINK_HELPSTR_IPADDR
  1078. VLINK_HELPSTR_TIME_PARAM
  1079. VLINK_HELPSTR_TIME_PARAM
  1080. VLINK_HELPSTR_TIME_PARAM
  1081. VLINK_HELPSTR_TIME_PARAM)
  1082. ALIAS (ospf_area_vlink,
  1083. ospf_area_vlink_authtype_args_cmd,
  1084. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1085. "(authentication|) (message-digest|null)",
  1086. VLINK_HELPSTR_IPADDR
  1087. VLINK_HELPSTR_AUTHTYPE_ALL)
  1088. ALIAS (ospf_area_vlink,
  1089. ospf_area_vlink_authtype_cmd,
  1090. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1091. "(authentication|)",
  1092. VLINK_HELPSTR_IPADDR
  1093. VLINK_HELPSTR_AUTHTYPE_SIMPLE)
  1094. ALIAS (no_ospf_area_vlink,
  1095. no_ospf_area_vlink_authtype_cmd,
  1096. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1097. "(authentication|)",
  1098. NO_STR
  1099. VLINK_HELPSTR_IPADDR
  1100. VLINK_HELPSTR_AUTHTYPE_SIMPLE)
  1101. ALIAS (ospf_area_vlink,
  1102. ospf_area_vlink_md5_cmd,
  1103. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1104. "(message-digest-key|) <1-255> md5 KEY",
  1105. VLINK_HELPSTR_IPADDR
  1106. VLINK_HELPSTR_AUTH_MD5)
  1107. ALIAS (no_ospf_area_vlink,
  1108. no_ospf_area_vlink_md5_cmd,
  1109. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1110. "(message-digest-key|) <1-255>",
  1111. NO_STR
  1112. VLINK_HELPSTR_IPADDR
  1113. VLINK_HELPSTR_AUTH_MD5)
  1114. ALIAS (ospf_area_vlink,
  1115. ospf_area_vlink_authkey_cmd,
  1116. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1117. "(authentication-key|) AUTH_KEY",
  1118. VLINK_HELPSTR_IPADDR
  1119. VLINK_HELPSTR_AUTH_SIMPLE)
  1120. ALIAS (no_ospf_area_vlink,
  1121. no_ospf_area_vlink_authkey_cmd,
  1122. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1123. "(authentication-key|)",
  1124. NO_STR
  1125. VLINK_HELPSTR_IPADDR
  1126. VLINK_HELPSTR_AUTH_SIMPLE)
  1127. ALIAS (ospf_area_vlink,
  1128. ospf_area_vlink_authtype_args_authkey_cmd,
  1129. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1130. "(authentication|) (message-digest|null) "
  1131. "(authentication-key|) AUTH_KEY",
  1132. VLINK_HELPSTR_IPADDR
  1133. VLINK_HELPSTR_AUTHTYPE_ALL
  1134. VLINK_HELPSTR_AUTH_SIMPLE)
  1135. ALIAS (ospf_area_vlink,
  1136. ospf_area_vlink_authtype_authkey_cmd,
  1137. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1138. "(authentication|) "
  1139. "(authentication-key|) AUTH_KEY",
  1140. VLINK_HELPSTR_IPADDR
  1141. VLINK_HELPSTR_AUTHTYPE_SIMPLE
  1142. VLINK_HELPSTR_AUTH_SIMPLE)
  1143. ALIAS (no_ospf_area_vlink,
  1144. no_ospf_area_vlink_authtype_authkey_cmd,
  1145. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1146. "(authentication|) "
  1147. "(authentication-key|)",
  1148. NO_STR
  1149. VLINK_HELPSTR_IPADDR
  1150. VLINK_HELPSTR_AUTHTYPE_SIMPLE
  1151. VLINK_HELPSTR_AUTH_SIMPLE)
  1152. ALIAS (ospf_area_vlink,
  1153. ospf_area_vlink_authtype_args_md5_cmd,
  1154. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1155. "(authentication|) (message-digest|null) "
  1156. "(message-digest-key|) <1-255> md5 KEY",
  1157. VLINK_HELPSTR_IPADDR
  1158. VLINK_HELPSTR_AUTHTYPE_ALL
  1159. VLINK_HELPSTR_AUTH_MD5)
  1160. ALIAS (ospf_area_vlink,
  1161. ospf_area_vlink_authtype_md5_cmd,
  1162. "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1163. "(authentication|) "
  1164. "(message-digest-key|) <1-255> md5 KEY",
  1165. VLINK_HELPSTR_IPADDR
  1166. VLINK_HELPSTR_AUTHTYPE_SIMPLE
  1167. VLINK_HELPSTR_AUTH_MD5)
  1168. ALIAS (no_ospf_area_vlink,
  1169. no_ospf_area_vlink_authtype_md5_cmd,
  1170. "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
  1171. "(authentication|) "
  1172. "(message-digest-key|)",
  1173. NO_STR
  1174. VLINK_HELPSTR_IPADDR
  1175. VLINK_HELPSTR_AUTHTYPE_SIMPLE
  1176. VLINK_HELPSTR_AUTH_MD5)
  1177. DEFUN (ospf_area_shortcut,
  1178. ospf_area_shortcut_cmd,
  1179. "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
  1180. "OSPF area parameters\n"
  1181. "OSPF area ID in IP address format\n"
  1182. "OSPF area ID as a decimal value\n"
  1183. "Configure the area's shortcutting mode\n"
  1184. "Set default shortcutting behavior\n"
  1185. "Enable shortcutting through the area\n"
  1186. "Disable shortcutting through the area\n")
  1187. {
  1188. struct ospf *ospf = vty->index;
  1189. struct ospf_area *area;
  1190. struct in_addr area_id;
  1191. int mode;
  1192. int format;
  1193. VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
  1194. area = ospf_area_get (ospf, area_id, format);
  1195. if (strncmp (argv[1], "de", 2) == 0)
  1196. mode = OSPF_SHORTCUT_DEFAULT;
  1197. else if (strncmp (argv[1], "di", 2) == 0)
  1198. mode = OSPF_SHORTCUT_DISABLE;
  1199. else if (strncmp (argv[1], "e", 1) == 0)
  1200. mode = OSPF_SHORTCUT_ENABLE;
  1201. else
  1202. return CMD_WARNING;
  1203. ospf_area_shortcut_set (ospf, area, mode);
  1204. if (ospf->abr_type != OSPF_ABR_SHORTCUT)
  1205. vty_out (vty, "Shortcut area setting will take effect "
  1206. "only when the router is configured as Shortcut ABR%s",
  1207. VTY_NEWLINE);
  1208. return CMD_SUCCESS;
  1209. }
  1210. DEFUN (no_ospf_area_shortcut,
  1211. no_ospf_area_shortcut_cmd,
  1212. "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
  1213. NO_STR
  1214. "OSPF area parameters\n"
  1215. "OSPF area ID in IP address format\n"
  1216. "OSPF area ID as a decimal value\n"
  1217. "Deconfigure the area's shortcutting mode\n"
  1218. "Deconfigure enabled shortcutting through the area\n"
  1219. "Deconfigure disabled shortcutting through the area\n")
  1220. {
  1221. struct ospf *ospf = vty->index;
  1222. struct ospf_area *area;
  1223. struct in_addr area_id;
  1224. int format;
  1225. VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
  1226. area = ospf_area_lookup_by_area_id (ospf, area_id);
  1227. if (!area)
  1228. return CMD_SUCCESS;
  1229. ospf_area_shortcut_unset (ospf, area);
  1230. return CMD_SUCCESS;
  1231. }
  1232. DEFUN (ospf_area_stub,
  1233. ospf_area_stub_cmd,
  1234. "area (A.B.C.D|<0-4294967295>) stub",
  1235. "OSPF area parameters\n"
  1236. "OSPF area ID in IP address format\n"
  1237. "OSPF area ID as a decimal value\n"
  1238. "Configure OSPF area as stub\n")
  1239. {
  1240. struct ospf *ospf = vty->index;
  1241. struct in_addr area_id;
  1242. int ret, format;
  1243. VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
  1244. ret = ospf_area_stub_set (ospf, area_id);
  1245. if (ret == 0)
  1246. {
  1247. vty_out (vty, "First deconfigure all virtual link through this area%s",
  1248. VTY_NEWLINE);
  1249. return CMD_WARNING;
  1250. }
  1251. ospf_area_no_summary_unset (ospf, area_id);
  1252. return CMD_SUCCESS;
  1253. }
  1254. DEFUN (ospf_area_stub_no_summary,
  1255. ospf_area_stub_no_summary_cmd,
  1256. "area (A.B.C.D|<0-4294967295>) stub no-summary",
  1257. "OSPF stub parameters\n"
  1258. "OSPF area ID in IP address format\n"
  1259. "OSPF area ID as a decimal value\n"
  1260. "Configure OSPF area as stub\n"
  1261. "Do not inject inter-area routes into stub\n")
  1262. {
  1263. struct ospf *ospf = vty->index;
  1264. struct in_addr area_id;
  1265. int ret, format;
  1266. VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
  1267. ret = ospf_area_stub_set (ospf, area_id);
  1268. if (ret == 0)
  1269. {
  1270. vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
  1271. VTY_NEWLINE);
  1272. return CMD_WARNING;
  1273. }
  1274. ospf_area_no_summary_set (ospf, area_id);
  1275. return CMD_SUCCESS;
  1276. }
  1277. DEFUN (no_ospf_area_stub,
  1278. no_ospf_area_stub_cmd,
  1279. "no area (A.B.C.D|<0-4294967295>) stub",
  1280. NO_STR
  1281. "OSPF area parameters\n"
  1282. "OSPF area ID in IP address format\n"
  1283. "OSPF area ID as a decimal value\n"
  1284. "Configure OSPF area as stub\n")
  1285. {
  1286. struct ospf *ospf = vty->index;
  1287. struct in_addr area_id;
  1288. int format;
  1289. VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
  1290. ospf_area_stub_unset (ospf, area_id);
  1291. ospf_area_no_summary_unset (ospf, area_id);
  1292. return CMD_SUCCESS;
  1293. }
  1294. DEFUN (no_ospf_area_stub_no_summary,
  1295. no_ospf_area_stub_no_summary_cmd,
  1296. "no area (A.B.C.D|<0-4294967295>) stub no-summary",
  1297. NO_STR
  1298. "OSPF area parameters\n"
  1299. "OSPF area ID in IP address format\n"
  1300. "OSPF area ID as a decimal value\n"
  1301. "Configure OSPF area as stub\n"
  1302. "Do not inject inter-area routes into area\n")
  1303. {
  1304. struct ospf *ospf = vty->index;
  1305. struct in_addr area_id;
  1306. int format;
  1307. VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
  1308. ospf_area_no_summary_unset (ospf, area_id);
  1309. return CMD_SUCCESS;
  1310. }
  1311. static int
  1312. ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
  1313. int nosum)
  1314. {
  1315. struct ospf *ospf = vty->index;
  1316. struct in_addr area_id;
  1317. int ret, format;
  1318. VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
  1319. ret = ospf_area_nssa_set (ospf, area_id);
  1320. if (ret == 0)
  1321. {
  1322. vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
  1323. VTY_NEWLINE);
  1324. return CMD_WARNING;
  1325. }
  1326. if (argc > 1)
  1327. {
  1328. if (strncmp (argv[1], "translate-c", 11) == 0)
  1329. ospf_area_nssa_translator_role_set (ospf, area_id,
  1330. OSPF_NSSA_ROLE_CANDIDATE);
  1331. else if (strncmp (argv[1], "translate-n", 11) == 0)
  1332. ospf_area_nssa_translator_role_set (ospf, area_id,
  1333. OSPF_NSSA_ROLE_NEVER);
  1334. else if (strncmp (argv[1], "translate-a", 11) == 0)
  1335. ospf_area_nssa_translator_role_set (ospf, area_id,
  1336. OSPF_NSSA_ROLE_ALWAYS);
  1337. }
  1338. else
  1339. {
  1340. ospf_area_nssa_translator_role_set (ospf, area_id,
  1341. OSPF_NSSA_ROLE_CANDIDATE);
  1342. }
  1343. if (nosum)
  1344. ospf_area_no_summary_set (ospf, area_id);
  1345. else
  1346. ospf_area_no_summary_unset (ospf, area_id);
  1347. ospf_schedule_abr_task (ospf);
  1348. return CMD_SUCCESS;
  1349. }
  1350. DEFUN (ospf_area_nssa_translate_no_summary,
  1351. ospf_area_nssa_translate_no_summary_cmd,
  1352. "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
  1353. "OSPF area parameters\n"
  1354. "OSPF area ID in IP address format\n"
  1355. "OSPF area ID as a decimal value\n"
  1356. "Configure OSPF area as nssa\n"
  1357. "Configure NSSA-ABR for translate election (default)\n"
  1358. "Configure NSSA-ABR to never translate\n"
  1359. "Configure NSSA-ABR to always translate\n"
  1360. "Do not inject inter-area routes into nssa\n")
  1361. {
  1362. return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
  1363. }
  1364. DEFUN (ospf_area_nssa_translate,
  1365. ospf_area_nssa_translate_cmd,
  1366. "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
  1367. "OSPF area parameters\n"
  1368. "OSPF area ID in IP address format\n"
  1369. "OSPF area ID as a decimal value\n"
  1370. "Configure OSPF area as nssa\n"
  1371. "Configure NSSA-ABR for translate election (default)\n"
  1372. "Configure NSSA-ABR to never translate\n"
  1373. "Configure NSSA-ABR to always translate\n")
  1374. {
  1375. return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
  1376. }
  1377. DEFUN (ospf_area_nssa,
  1378. ospf_area_nssa_cmd,
  1379. "area (A.B.C.D|<0-4294967295>) nssa",
  1380. "OSPF area parameters\n"
  1381. "OSPF area ID in IP address format\n"
  1382. "OSPF area ID as a decimal value\n"
  1383. "Configure OSPF area as nssa\n")
  1384. {
  1385. return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
  1386. }
  1387. DEFUN (ospf_area_nssa_no_summary,
  1388. ospf_area_nssa_no_summary_cmd,
  1389. "area (A.B.C.D|<0-4294967295>) nssa no-summary",
  1390. "OSPF area parameters\n"
  1391. "OSPF area ID in IP address format\n"
  1392. "OSPF area ID as a decimal value\n"
  1393. "Configure OSPF area as nssa\n"
  1394. "Do not inject inter-area routes into nssa\n")
  1395. {
  1396. return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
  1397. }
  1398. DEFUN (no_ospf_area_nssa,
  1399. no_ospf_area_nssa_cmd,
  1400. "no area (A.B.C.D|<0-4294967295>) nssa",
  1401. NO_STR
  1402. "OSPF area parameters\n"
  1403. "OSPF area ID in IP address format\n"
  1404. "OSPF area ID as a decimal value\n"
  1405. "Configure OSPF area as nssa\n")
  1406. {
  1407. struct ospf *ospf = vty->index;
  1408. struct in_addr area_id;
  1409. int format;
  1410. VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
  1411. ospf_area_nssa_unset (ospf, area_id);
  1412. ospf_area_no_summary_unset (ospf, area_id);
  1413. ospf_schedule_abr_task (ospf);
  1414. return CMD_SUCCESS;
  1415. }
  1416. DEFUN (no_ospf_area_nssa_no_summary,
  1417. no_ospf_area_nssa_no_summary_cmd,
  1418. "no area (A.B.C.D|<0-4294967295>) nssa no-summary",
  1419. NO_STR
  1420. "OSPF area parameters\n"
  1421. "OSPF area ID in IP address format\n"
  1422. "OSPF area ID as a decimal value\n"
  1423. "Configure OSPF area as nssa\n"
  1424. "Do not inject inter-area routes into nssa\n")
  1425. {
  1426. struct ospf *ospf = vty->index;
  1427. struct in_addr area_id;
  1428. int format;
  1429. VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
  1430. ospf_area_no_summary_unset (ospf, area_id);
  1431. return CMD_SUCCESS;
  1432. }
  1433. DEFUN (ospf_area_default_cost,
  1434. ospf_area_default_cost_cmd,
  1435. "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
  1436. "OSPF area parameters\n"
  1437. "OSPF area ID in IP address format\n"
  1438. "OSPF area ID as a decimal value\n"
  1439. "Set the summary-default cost of a NSSA or stub area\n"
  1440. "Stub's advertised default summary cost\n")
  1441. {
  1442. struct ospf *ospf = vty->index;
  1443. struct ospf_area *area;
  1444. struct in_addr area_id;
  1445. u_int32_t cost;
  1446. int format;
  1447. struct prefix_ipv4 p;
  1448. VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
  1449. VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
  1450. area = ospf_area_get (ospf, area_id, format);
  1451. if (area->external_routing == OSPF_AREA_DEFAULT)
  1452. {
  1453. vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
  1454. return CMD_WARNING;
  1455. }
  1456. area->default_cost = cost;
  1457. p.family = AF_INET;
  1458. p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
  1459. p.prefixlen = 0;
  1460. if (IS_DEBUG_OSPF_EVENT)
  1461. zlog_debug ("ospf_abr_announce_stub_defaults(): "
  1462. "announcing 0.0.0.0/0 to area %s",
  1463. inet_ntoa (area->area_id));
  1464. ospf_abr_announce_network_to_area (&p, area->default_cost, area);
  1465. return CMD_SUCCESS;
  1466. }
  1467. DEFUN (no_ospf_area_default_cost,
  1468. no_ospf_area_default_cost_cmd,
  1469. "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
  1470. NO_STR
  1471. "OSPF area parameters\n"
  1472. "OSPF area ID in IP address format\n"
  1473. "OSPF area ID as a decimal value\n"
  1474. "Set the summary-default cost of a NSSA or stub area\n"
  1475. "Stub's advertised default summary cost\n")
  1476. {
  1477. struct ospf *ospf = vty->index;
  1478. struct ospf_area *area;
  1479. struct in_addr area_id;
  1480. int format;
  1481. struct prefix_ipv4 p;
  1482. VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
  1483. VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
  1484. area = ospf_area_lookup_by_area_id (ospf, area_id);
  1485. if (area == NULL)
  1486. return CMD_SUCCESS;
  1487. if (area->external_routing == OSPF_AREA_DEFAULT)
  1488. {
  1489. vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
  1490. return CMD_WARNING;
  1491. }
  1492. area->default_cost = 1;
  1493. p.family = AF_INET;
  1494. p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
  1495. p.prefixlen = 0;
  1496. if (IS_DEBUG_OSPF_EVENT)
  1497. zlog_debug ("ospf_abr_announce_stub_defaults(): "
  1498. "announcing 0.0.0.0/0 to area %s",
  1499. inet_ntoa (area->area_id));
  1500. ospf_abr_announce_network_to_area (&p, area->default_cost, area);
  1501. ospf_area_check_free (ospf, area_id);
  1502. return CMD_SUCCESS;
  1503. }
  1504. DEFUN (ospf_area_export_list,
  1505. ospf_area_export_list_cmd,
  1506. "area (A.B.C.D|<0-4294967295>) export-list NAME",
  1507. "OSPF area parameters\n"
  1508. "OSPF area ID in IP address format\n"
  1509. "OSPF area ID as a decimal value\n"
  1510. "Set the filter for networks announced to other areas\n"
  1511. "Name of the access-list\n")
  1512. {
  1513. struct ospf *ospf = vty->index;
  1514. struct ospf_area *area;
  1515. struct in_addr area_id;
  1516. int format;
  1517. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1518. area = ospf_area_get (ospf, area_id, format);
  1519. ospf_area_export_list_set (ospf, area, argv[1]);
  1520. return CMD_SUCCESS;
  1521. }
  1522. DEFUN (no_ospf_area_export_list,
  1523. no_ospf_area_export_list_cmd,
  1524. "no area (A.B.C.D|<0-4294967295>) export-list NAME",
  1525. NO_STR
  1526. "OSPF area parameters\n"
  1527. "OSPF area ID in IP address format\n"
  1528. "OSPF area ID as a decimal value\n"
  1529. "Unset the filter for networks announced to other areas\n"
  1530. "Name of the access-list\n")
  1531. {
  1532. struct ospf *ospf = vty->index;
  1533. struct ospf_area *area;
  1534. struct in_addr area_id;
  1535. int format;
  1536. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1537. area = ospf_area_lookup_by_area_id (ospf, area_id);
  1538. if (area == NULL)
  1539. return CMD_SUCCESS;
  1540. ospf_area_export_list_unset (ospf, area);
  1541. return CMD_SUCCESS;
  1542. }
  1543. DEFUN (ospf_area_import_list,
  1544. ospf_area_import_list_cmd,
  1545. "area (A.B.C.D|<0-4294967295>) import-list NAME",
  1546. "OSPF area parameters\n"
  1547. "OSPF area ID in IP address format\n"
  1548. "OSPF area ID as a decimal value\n"
  1549. "Set the filter for networks from other areas announced to the specified one\n"
  1550. "Name of the access-list\n")
  1551. {
  1552. struct ospf *ospf = vty->index;
  1553. struct ospf_area *area;
  1554. struct in_addr area_id;
  1555. int format;
  1556. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1557. area = ospf_area_get (ospf, area_id, format);
  1558. ospf_area_import_list_set (ospf, area, argv[1]);
  1559. return CMD_SUCCESS;
  1560. }
  1561. DEFUN (no_ospf_area_import_list,
  1562. no_ospf_area_import_list_cmd,
  1563. "no area (A.B.C.D|<0-4294967295>) import-list NAME",
  1564. NO_STR
  1565. "OSPF area parameters\n"
  1566. "OSPF area ID in IP address format\n"
  1567. "OSPF area ID as a decimal value\n"
  1568. "Unset the filter for networks announced to other areas\n"
  1569. "Name of the access-list\n")
  1570. {
  1571. struct ospf *ospf = vty->index;
  1572. struct ospf_area *area;
  1573. struct in_addr area_id;
  1574. int format;
  1575. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1576. area = ospf_area_lookup_by_area_id (ospf, area_id);
  1577. if (area == NULL)
  1578. return CMD_SUCCESS;
  1579. ospf_area_import_list_unset (ospf, area);
  1580. return CMD_SUCCESS;
  1581. }
  1582. DEFUN (ospf_area_filter_list,
  1583. ospf_area_filter_list_cmd,
  1584. "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
  1585. "OSPF area parameters\n"
  1586. "OSPF area ID in IP address format\n"
  1587. "OSPF area ID as a decimal value\n"
  1588. "Filter networks between OSPF areas\n"
  1589. "Filter prefixes between OSPF areas\n"
  1590. "Name of an IP prefix-list\n"
  1591. "Filter networks sent to this area\n"
  1592. "Filter networks sent from this area\n")
  1593. {
  1594. struct ospf *ospf = vty->index;
  1595. struct ospf_area *area;
  1596. struct in_addr area_id;
  1597. struct prefix_list *plist;
  1598. int format;
  1599. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1600. area = ospf_area_get (ospf, area_id, format);
  1601. plist = prefix_list_lookup (AFI_IP, argv[1]);
  1602. if (strncmp (argv[2], "in", 2) == 0)
  1603. {
  1604. PREFIX_LIST_IN (area) = plist;
  1605. if (PREFIX_NAME_IN (area))
  1606. free (PREFIX_NAME_IN (area));
  1607. PREFIX_NAME_IN (area) = strdup (argv[1]);
  1608. ospf_schedule_abr_task (ospf);
  1609. }
  1610. else
  1611. {
  1612. PREFIX_LIST_OUT (area) = plist;
  1613. if (PREFIX_NAME_OUT (area))
  1614. free (PREFIX_NAME_OUT (area));
  1615. PREFIX_NAME_OUT (area) = strdup (argv[1]);
  1616. ospf_schedule_abr_task (ospf);
  1617. }
  1618. return CMD_SUCCESS;
  1619. }
  1620. DEFUN (no_ospf_area_filter_list,
  1621. no_ospf_area_filter_list_cmd,
  1622. "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
  1623. NO_STR
  1624. "OSPF area parameters\n"
  1625. "OSPF area ID in IP address format\n"
  1626. "OSPF area ID as a decimal value\n"
  1627. "Filter networks between OSPF areas\n"
  1628. "Filter prefixes between OSPF areas\n"
  1629. "Name of an IP prefix-list\n"
  1630. "Filter networks sent to this area\n"
  1631. "Filter networks sent from this area\n")
  1632. {
  1633. struct ospf *ospf = vty->index;
  1634. struct ospf_area *area;
  1635. struct in_addr area_id;
  1636. int format;
  1637. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1638. if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
  1639. return CMD_SUCCESS;
  1640. if (strncmp (argv[2], "in", 2) == 0)
  1641. {
  1642. if (PREFIX_NAME_IN (area))
  1643. if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
  1644. return CMD_SUCCESS;
  1645. PREFIX_LIST_IN (area) = NULL;
  1646. if (PREFIX_NAME_IN (area))
  1647. free (PREFIX_NAME_IN (area));
  1648. PREFIX_NAME_IN (area) = NULL;
  1649. ospf_schedule_abr_task (ospf);
  1650. }
  1651. else
  1652. {
  1653. if (PREFIX_NAME_OUT (area))
  1654. if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
  1655. return CMD_SUCCESS;
  1656. PREFIX_LIST_OUT (area) = NULL;
  1657. if (PREFIX_NAME_OUT (area))
  1658. free (PREFIX_NAME_OUT (area));
  1659. PREFIX_NAME_OUT (area) = NULL;
  1660. ospf_schedule_abr_task (ospf);
  1661. }
  1662. return CMD_SUCCESS;
  1663. }
  1664. DEFUN (ospf_area_authentication_message_digest,
  1665. ospf_area_authentication_message_digest_cmd,
  1666. "area (A.B.C.D|<0-4294967295>) authentication message-digest",
  1667. "OSPF area parameters\n"
  1668. "OSPF area ID in IP address format\n"
  1669. "OSPF area ID as a decimal value\n"
  1670. "Enable authentication\n"
  1671. "Use message-digest authentication\n")
  1672. {
  1673. struct ospf *ospf = vty->index;
  1674. struct ospf_area *area;
  1675. struct in_addr area_id;
  1676. int format;
  1677. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1678. area = ospf_area_get (ospf, area_id, format);
  1679. area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
  1680. return CMD_SUCCESS;
  1681. }
  1682. DEFUN (ospf_area_authentication,
  1683. ospf_area_authentication_cmd,
  1684. "area (A.B.C.D|<0-4294967295>) authentication",
  1685. "OSPF area parameters\n"
  1686. "OSPF area ID in IP address format\n"
  1687. "OSPF area ID as a decimal value\n"
  1688. "Enable authentication\n")
  1689. {
  1690. struct ospf *ospf = vty->index;
  1691. struct ospf_area *area;
  1692. struct in_addr area_id;
  1693. int format;
  1694. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1695. area = ospf_area_get (ospf, area_id, format);
  1696. area->auth_type = OSPF_AUTH_SIMPLE;
  1697. return CMD_SUCCESS;
  1698. }
  1699. DEFUN (no_ospf_area_authentication,
  1700. no_ospf_area_authentication_cmd,
  1701. "no area (A.B.C.D|<0-4294967295>) authentication",
  1702. NO_STR
  1703. "OSPF area parameters\n"
  1704. "OSPF area ID in IP address format\n"
  1705. "OSPF area ID as a decimal value\n"
  1706. "Enable authentication\n")
  1707. {
  1708. struct ospf *ospf = vty->index;
  1709. struct ospf_area *area;
  1710. struct in_addr area_id;
  1711. int format;
  1712. VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
  1713. area = ospf_area_lookup_by_area_id (ospf, area_id);
  1714. if (area == NULL)
  1715. return CMD_SUCCESS;
  1716. area->auth_type = OSPF_AUTH_NULL;
  1717. ospf_area_check_free (ospf, area_id);
  1718. return CMD_SUCCESS;
  1719. }
  1720. DEFUN (ospf_abr_type,
  1721. ospf_abr_type_cmd,
  1722. "ospf abr-type (cisco|ibm|shortcut|standard)",
  1723. "OSPF specific commands\n"
  1724. "Set OSPF ABR type\n"
  1725. "Alternative ABR, cisco implementation\n"
  1726. "Alternative ABR, IBM implementation\n"
  1727. "Shortcut ABR\n"
  1728. "Standard behavior (RFC2328)\n")
  1729. {
  1730. struct ospf *ospf = vty->index;
  1731. u_char abr_type = OSPF_ABR_UNKNOWN;
  1732. if (strncmp (argv[0], "c", 1) == 0)
  1733. abr_type = OSPF_ABR_CISCO;
  1734. else if (strncmp (argv[0], "i", 1) == 0)
  1735. abr_type = OSPF_ABR_IBM;
  1736. else if (strncmp (argv[0], "sh", 2) == 0)
  1737. abr_type = OSPF_ABR_SHORTCUT;
  1738. else if (strncmp (argv[0], "st", 2) == 0)
  1739. abr_type = OSPF_ABR_STAND;
  1740. else
  1741. return CMD_WARNING;
  1742. /* If ABR type value is changed, schedule ABR task. */
  1743. if (ospf->abr_type != abr_type)
  1744. {
  1745. ospf->abr_type = abr_type;
  1746. ospf_schedule_abr_task (ospf);
  1747. }
  1748. return CMD_SUCCESS;
  1749. }
  1750. DEFUN (no_ospf_abr_type,
  1751. no_ospf_abr_type_cmd,
  1752. "no ospf abr-type (cisco|ibm|shortcut|standard)",
  1753. NO_STR
  1754. "OSPF specific commands\n"
  1755. "Set OSPF ABR type\n"
  1756. "Alternative ABR, cisco implementation\n"
  1757. "Alternative ABR, IBM implementation\n"
  1758. "Shortcut ABR\n")
  1759. {
  1760. struct ospf *ospf = vty->index;
  1761. u_char abr_type = OSPF_ABR_UNKNOWN;
  1762. if (strncmp (argv[0], "c", 1) == 0)
  1763. abr_type = OSPF_ABR_CISCO;
  1764. else if (strncmp (argv[0], "i", 1) == 0)
  1765. abr_type = OSPF_ABR_IBM;
  1766. else if (strncmp (argv[0], "sh", 2) == 0)
  1767. abr_type = OSPF_ABR_SHORTCUT;
  1768. else if (strncmp (argv[0], "st", 2) == 0)
  1769. abr_type = OSPF_ABR_STAND;
  1770. else
  1771. return CMD_WARNING;
  1772. /* If ABR type value is changed, schedule ABR task. */
  1773. if (ospf->abr_type == abr_type)
  1774. {
  1775. ospf->abr_type = OSPF_ABR_DEFAULT;
  1776. ospf_schedule_abr_task (ospf);
  1777. }
  1778. return CMD_SUCCESS;
  1779. }
  1780. DEFUN (ospf_log_adjacency_changes,
  1781. ospf_log_adjacency_changes_cmd,
  1782. "log-adjacency-changes",
  1783. "Log changes in adjacency state\n")
  1784. {
  1785. struct ospf *ospf = vty->index;
  1786. SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
  1787. return CMD_SUCCESS;
  1788. }
  1789. DEFUN (ospf_log_adjacency_changes_detail,
  1790. ospf_log_adjacency_changes_detail_cmd,
  1791. "log-adjacency-changes detail",
  1792. "Log changes in adjacency state\n"
  1793. "Log all state changes\n")
  1794. {
  1795. struct ospf *ospf = vty->index;
  1796. SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
  1797. SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
  1798. return CMD_SUCCESS;
  1799. }
  1800. DEFUN (no_ospf_log_adjacency_changes,
  1801. no_ospf_log_adjacency_changes_cmd,
  1802. "no log-adjacency-changes",
  1803. NO_STR
  1804. "Log changes in adjacency state\n")
  1805. {
  1806. struct ospf *ospf = vty->index;
  1807. UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
  1808. UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
  1809. return CMD_SUCCESS;
  1810. }
  1811. DEFUN (no_ospf_log_adjacency_changes_detail,
  1812. no_ospf_log_adjacency_changes_detail_cmd,
  1813. "no log-adjacency-changes detail",
  1814. NO_STR
  1815. "Log changes in adjacency state\n"
  1816. "Log all state changes\n")
  1817. {
  1818. struct ospf *ospf = vty->index;
  1819. UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
  1820. return CMD_SUCCESS;
  1821. }
  1822. DEFUN (ospf_compatible_rfc1583,
  1823. ospf_compatible_rfc1583_cmd,
  1824. "compatible rfc1583",
  1825. "OSPF compatibility list\n"
  1826. "compatible with RFC 1583\n")
  1827. {
  1828. struct ospf *ospf = vty->index;
  1829. if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
  1830. {
  1831. SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
  1832. ospf_spf_calculate_schedule (ospf);
  1833. }
  1834. return CMD_SUCCESS;
  1835. }
  1836. DEFUN (no_ospf_compatible_rfc1583,
  1837. no_ospf_compatible_rfc1583_cmd,
  1838. "no compatible rfc1583",
  1839. NO_STR
  1840. "OSPF compatibility list\n"
  1841. "compatible with RFC 1583\n")
  1842. {
  1843. struct ospf *ospf = vty->index;
  1844. if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
  1845. {
  1846. UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
  1847. ospf_spf_calculate_schedule (ospf);
  1848. }
  1849. return CMD_SUCCESS;
  1850. }
  1851. ALIAS (ospf_compatible_rfc1583,
  1852. ospf_rfc1583_flag_cmd,
  1853. "ospf rfc1583compatibility",
  1854. "OSPF specific commands\n"
  1855. "Enable the RFC1583Compatibility flag\n")
  1856. ALIAS (no_ospf_compatible_rfc1583,
  1857. no_ospf_rfc1583_flag_cmd,
  1858. "no ospf rfc1583compatibility",
  1859. NO_STR
  1860. "OSPF specific commands\n"
  1861. "Disable the RFC1583Compatibility flag\n")
  1862. static int
  1863. ospf_timers_spf_set (struct vty *vty, unsigned int delay,
  1864. unsigned int hold,
  1865. unsigned int max)
  1866. {
  1867. struct ospf *ospf = vty->index;
  1868. ospf->spf_delay = delay;
  1869. ospf->spf_holdtime = hold;
  1870. ospf->spf_max_holdtime = max;
  1871. return CMD_SUCCESS;
  1872. }
  1873. DEFUN (ospf_timers_throttle_spf,
  1874. ospf_timers_throttle_spf_cmd,
  1875. "timers throttle spf <0-600000> <0-600000> <0-600000>",
  1876. "Adjust routing timers\n"
  1877. "Throttling adaptive timer\n"
  1878. "OSPF SPF timers\n"
  1879. "Delay (msec) from first change received till SPF calculation\n"
  1880. "Initial hold time (msec) between consecutive SPF calculations\n"
  1881. "Maximum hold time (msec)\n")
  1882. {
  1883. unsigned int delay, hold, max;
  1884. if (argc != 3)
  1885. {
  1886. vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
  1887. return CMD_WARNING;
  1888. }
  1889. VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
  1890. VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
  1891. VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
  1892. return ospf_timers_spf_set (vty, delay, hold, max);
  1893. }
  1894. DEFUN_DEPRECATED (ospf_timers_spf,
  1895. ospf_timers_spf_cmd,
  1896. "timers spf <0-4294967295> <0-4294967295>",
  1897. "Adjust routing timers\n"
  1898. "OSPF SPF timers\n"
  1899. "Delay (s) between receiving a change to SPF calculation\n"
  1900. "Hold time (s) between consecutive SPF calculations\n")
  1901. {
  1902. unsigned int delay, hold;
  1903. if (argc != 2)
  1904. {
  1905. vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
  1906. return CMD_WARNING;
  1907. }
  1908. VTY_GET_INTEGER ("SPF delay timer", delay, argv[0]);
  1909. VTY_GET_INTEGER ("SPF hold timer", hold, argv[1]);
  1910. /* truncate down the second values if they're greater than 600000ms */
  1911. if (delay > (600000 / 1000))
  1912. delay = 600000;
  1913. else if (delay == 0)
  1914. /* 0s delay was probably specified because of lack of ms resolution */
  1915. delay = OSPF_SPF_DELAY_DEFAULT;
  1916. if (hold > (600000 / 1000))
  1917. hold = 600000;
  1918. return ospf_timers_spf_set (vty, delay * 1000, hold * 1000, hold * 1000);
  1919. }
  1920. DEFUN (no_ospf_timers_throttle_spf,
  1921. no_ospf_timers_throttle_spf_cmd,
  1922. "no timers throttle spf",
  1923. NO_STR
  1924. "Adjust routing timers\n"
  1925. "Throttling adaptive timer\n"
  1926. "OSPF SPF timers\n")
  1927. {
  1928. return ospf_timers_spf_set (vty,
  1929. OSPF_SPF_DELAY_DEFAULT,
  1930. OSPF_SPF_HOLDTIME_DEFAULT,
  1931. OSPF_SPF_MAX_HOLDTIME_DEFAULT);
  1932. }
  1933. ALIAS_DEPRECATED (no_ospf_timers_throttle_spf,
  1934. no_ospf_timers_spf_cmd,
  1935. "no timers spf",
  1936. NO_STR
  1937. "Adjust routing timers\n"
  1938. "OSPF SPF timers\n")
  1939. DEFUN (ospf_neighbor,
  1940. ospf_neighbor_cmd,
  1941. "neighbor A.B.C.D",
  1942. NEIGHBOR_STR
  1943. "Neighbor IP address\n")
  1944. {
  1945. struct ospf *ospf = vty->index;
  1946. struct in_addr nbr_addr;
  1947. unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
  1948. unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
  1949. VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
  1950. if (argc > 1)
  1951. VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
  1952. if (argc > 2)
  1953. VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
  1954. ospf_nbr_nbma_set (ospf, nbr_addr);
  1955. if (argc > 1)
  1956. ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
  1957. if (argc > 2)
  1958. ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
  1959. return CMD_SUCCESS;
  1960. }
  1961. ALIAS (ospf_neighbor,
  1962. ospf_neighbor_priority_poll_interval_cmd,
  1963. "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
  1964. NEIGHBOR_STR
  1965. "Neighbor IP address\n"
  1966. "Neighbor Priority\n"
  1967. "Priority\n"
  1968. "Dead Neighbor Polling interval\n"
  1969. "Seconds\n")
  1970. ALIAS (ospf_neighbor,
  1971. ospf_neighbor_priority_cmd,
  1972. "neighbor A.B.C.D priority <0-255>",
  1973. NEIGHBOR_STR
  1974. "Neighbor IP address\n"
  1975. "Neighbor Priority\n"
  1976. "Seconds\n")
  1977. DEFUN (ospf_neighbor_poll_interval,
  1978. ospf_neighbor_poll_interval_cmd,
  1979. "neighbor A.B.C.D poll-interval <1-65535>",
  1980. NEIGHBOR_STR
  1981. "Neighbor IP address\n"
  1982. "Dead Neighbor Polling interval\n"
  1983. "Seconds\n")
  1984. {
  1985. struct ospf *ospf = vty->index;
  1986. struct in_addr nbr_addr;
  1987. unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
  1988. unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
  1989. VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
  1990. if (argc > 1)
  1991. VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
  1992. if (argc > 2)
  1993. VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
  1994. ospf_nbr_nbma_set (ospf, nbr_addr);
  1995. if (argc > 1)
  1996. ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
  1997. if (argc > 2)
  1998. ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
  1999. return CMD_SUCCESS;
  2000. }
  2001. ALIAS (ospf_neighbor_poll_interval,
  2002. ospf_neighbor_poll_interval_priority_cmd,
  2003. "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
  2004. NEIGHBOR_STR
  2005. "Neighbor address\n"
  2006. "OSPF dead-router polling interval\n"
  2007. "Seconds\n"
  2008. "OSPF priority of non-broadcast neighbor\n"
  2009. "Priority\n")
  2010. DEFUN (no_ospf_neighbor,
  2011. no_ospf_neighbor_cmd,
  2012. "no neighbor A.B.C.D",
  2013. NO_STR
  2014. NEIGHBOR_STR
  2015. "Neighbor IP address\n")
  2016. {
  2017. struct ospf *ospf = vty->index;
  2018. struct in_addr nbr_addr;
  2019. VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
  2020. (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
  2021. return CMD_SUCCESS;
  2022. }
  2023. ALIAS (no_ospf_neighbor,
  2024. no_ospf_neighbor_priority_cmd,
  2025. "no neighbor A.B.C.D priority <0-255>",
  2026. NO_STR
  2027. NEIGHBOR_STR
  2028. "Neighbor IP address\n"
  2029. "Neighbor Priority\n"
  2030. "Priority\n")
  2031. ALIAS (no_ospf_neighbor,
  2032. no_ospf_neighbor_poll_interval_cmd,
  2033. "no neighbor A.B.C.D poll-interval <1-65535>",
  2034. NO_STR
  2035. NEIGHBOR_STR
  2036. "Neighbor IP address\n"
  2037. "Dead Neighbor Polling interval\n"
  2038. "Seconds\n")
  2039. ALIAS (no_ospf_neighbor,
  2040. no_ospf_neighbor_priority_pollinterval_cmd,
  2041. "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
  2042. NO_STR
  2043. NEIGHBOR_STR
  2044. "Neighbor IP address\n"
  2045. "Neighbor Priority\n"
  2046. "Priority\n"
  2047. "Dead Neighbor Polling interval\n"
  2048. "Seconds\n")
  2049. DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
  2050. "refresh timer <10-1800>",
  2051. "Adjust refresh parameters\n"
  2052. "Set refresh timer\n"
  2053. "Timer value in seconds\n")
  2054. {
  2055. struct ospf *ospf = vty->index;
  2056. unsigned int interval;
  2057. VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
  2058. interval = (interval / 10) * 10;
  2059. ospf_timers_refresh_set (ospf, interval);
  2060. return CMD_SUCCESS;
  2061. }
  2062. DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
  2063. "no refresh timer <10-1800>",
  2064. "Adjust refresh parameters\n"
  2065. "Unset refresh timer\n"
  2066. "Timer value in seconds\n")
  2067. {
  2068. struct ospf *ospf = vty->index;
  2069. unsigned int interval;
  2070. if (argc == 1)
  2071. {
  2072. VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
  2073. if (ospf->lsa_refresh_interval != interval ||
  2074. interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
  2075. return CMD_SUCCESS;
  2076. }
  2077. ospf_timers_refresh_unset (ospf);
  2078. return CMD_SUCCESS;
  2079. }
  2080. ALIAS (no_ospf_refresh_timer,
  2081. no_ospf_refresh_timer_cmd,
  2082. "no refresh timer",
  2083. "Adjust refresh parameters\n"
  2084. "Unset refresh timer\n")
  2085. DEFUN (ospf_auto_cost_reference_bandwidth,
  2086. ospf_auto_cost_reference_bandwidth_cmd,
  2087. "auto-cost reference-bandwidth <1-4294967>",
  2088. "Calculate OSPF interface cost according to bandwidth\n"
  2089. "Use reference bandwidth method to assign OSPF cost\n"
  2090. "The reference bandwidth in terms of Mbits per second\n")
  2091. {
  2092. struct ospf *ospf = vty->index;
  2093. u_int32_t refbw;
  2094. struct listnode *node;
  2095. struct interface *ifp;
  2096. refbw = strtol (argv[0], NULL, 10);
  2097. if (refbw < 1 || refbw > 4294967)
  2098. {
  2099. vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
  2100. return CMD_WARNING;
  2101. }
  2102. /* If reference bandwidth is changed. */
  2103. if ((refbw * 1000) == ospf->ref_bandwidth)
  2104. return CMD_SUCCESS;
  2105. ospf->ref_bandwidth = refbw * 1000;
  2106. for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
  2107. ospf_if_recalculate_output_cost (ifp);
  2108. return CMD_SUCCESS;
  2109. }
  2110. DEFUN (no_ospf_auto_cost_reference_bandwidth,
  2111. no_ospf_auto_cost_reference_bandwidth_cmd,
  2112. "no auto-cost reference-bandwidth",
  2113. NO_STR
  2114. "Calculate OSPF interface cost according to bandwidth\n"
  2115. "Use reference bandwidth method to assign OSPF cost\n")
  2116. {
  2117. struct ospf *ospf = vty->index;
  2118. struct listnode *node, *nnode;
  2119. struct interface *ifp;
  2120. if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
  2121. return CMD_SUCCESS;
  2122. ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
  2123. vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
  2124. vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
  2125. for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
  2126. ospf_if_recalculate_output_cost (ifp);
  2127. return CMD_SUCCESS;
  2128. }
  2129. const char *ospf_abr_type_descr_str[] =
  2130. {
  2131. "Unknown",
  2132. "Standard (RFC2328)",
  2133. "Alternative IBM",
  2134. "Alternative Cisco",
  2135. "Alternative Shortcut"
  2136. };
  2137. const char *ospf_shortcut_mode_descr_str[] =
  2138. {
  2139. "Default",
  2140. "Enabled",
  2141. "Disabled"
  2142. };
  2143. static void
  2144. show_ip_ospf_area (struct vty *vty, struct ospf_area *area)
  2145. {
  2146. /* Show Area ID. */
  2147. vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
  2148. /* Show Area type/mode. */
  2149. if (OSPF_IS_AREA_BACKBONE (area))
  2150. vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
  2151. else
  2152. {
  2153. if (area->external_routing == OSPF_AREA_STUB)
  2154. vty_out (vty, " (Stub%s%s)",
  2155. area->no_summary ? ", no summary" : "",
  2156. area->shortcut_configured ? "; " : "");
  2157. else if (area->external_routing == OSPF_AREA_NSSA)
  2158. vty_out (vty, " (NSSA%s%s)",
  2159. area->no_summary ? ", no summary" : "",
  2160. area->shortcut_configured ? "; " : "");
  2161. vty_out (vty, "%s", VTY_NEWLINE);
  2162. vty_out (vty, " Shortcutting mode: %s",
  2163. ospf_shortcut_mode_descr_str[area->shortcut_configured]);
  2164. vty_out (vty, ", S-bit consensus: %s%s",
  2165. area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
  2166. }
  2167. /* Show number of interfaces. */
  2168. vty_out (vty, " Number of interfaces in this area: Total: %d, "
  2169. "Active: %d%s", listcount (area->oiflist),
  2170. area->act_ints, VTY_NEWLINE);
  2171. if (area->external_routing == OSPF_AREA_NSSA)
  2172. {
  2173. vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
  2174. if (! IS_OSPF_ABR (area->ospf))
  2175. vty_out (vty, " It is not ABR, therefore not Translator. %s",
  2176. VTY_NEWLINE);
  2177. else if (area->NSSATranslatorState)
  2178. {
  2179. vty_out (vty, " We are an ABR and ");
  2180. if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
  2181. vty_out (vty, "the NSSA Elected Translator. %s",
  2182. VTY_NEWLINE);
  2183. else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
  2184. vty_out (vty, "always an NSSA Translator. %s",
  2185. VTY_NEWLINE);
  2186. }
  2187. else
  2188. {
  2189. vty_out (vty, " We are an ABR, but ");
  2190. if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
  2191. vty_out (vty, "not the NSSA Elected Translator. %s",
  2192. VTY_NEWLINE);
  2193. else
  2194. vty_out (vty, "never an NSSA Translator. %s",
  2195. VTY_NEWLINE);
  2196. }
  2197. }
  2198. /* Stub-router state for this area */
  2199. if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
  2200. {
  2201. char timebuf[OSPF_TIME_DUMP_SIZE];
  2202. vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
  2203. VTY_NEWLINE);
  2204. if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
  2205. vty_out (vty, " Administratively activated (indefinitely)%s",
  2206. VTY_NEWLINE);
  2207. if (area->t_stub_router)
  2208. vty_out (vty, " Active from startup, %s remaining%s",
  2209. ospf_timer_dump (area->t_stub_router, timebuf,
  2210. sizeof(timebuf)), VTY_NEWLINE);
  2211. }
  2212. /* Show number of fully adjacent neighbors. */
  2213. vty_out (vty, " Number of fully adjacent neighbors in this area:"
  2214. " %d%s", area->full_nbrs, VTY_NEWLINE);
  2215. /* Show authentication type. */
  2216. vty_out (vty, " Area has ");
  2217. if (area->auth_type == OSPF_AUTH_NULL)
  2218. vty_out (vty, "no authentication%s", VTY_NEWLINE);
  2219. else if (area->auth_type == OSPF_AUTH_SIMPLE)
  2220. vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
  2221. else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
  2222. vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
  2223. if (!OSPF_IS_AREA_BACKBONE (area))
  2224. vty_out (vty, " Number of full virtual adjacencies going through"
  2225. " this area: %d%s", area->full_vls, VTY_NEWLINE);
  2226. /* Show SPF calculation times. */
  2227. vty_out (vty, " SPF algorithm executed %d times%s",
  2228. area->spf_calculation, VTY_NEWLINE);
  2229. /* Show number of LSA. */
  2230. vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
  2231. vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
  2232. ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
  2233. ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
  2234. vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
  2235. ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
  2236. ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
  2237. vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
  2238. ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
  2239. ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
  2240. vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
  2241. ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
  2242. ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
  2243. vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
  2244. ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
  2245. ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
  2246. #ifdef HAVE_OPAQUE_LSA
  2247. vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
  2248. ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
  2249. ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
  2250. vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
  2251. ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
  2252. ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
  2253. #endif /* HAVE_OPAQUE_LSA */
  2254. vty_out (vty, "%s", VTY_NEWLINE);
  2255. }
  2256. DEFUN (show_ip_ospf,
  2257. show_ip_ospf_cmd,
  2258. "show ip ospf",
  2259. SHOW_STR
  2260. IP_STR
  2261. "OSPF information\n")
  2262. {
  2263. struct listnode *node, *nnode;
  2264. struct ospf_area * area;
  2265. struct ospf *ospf;
  2266. struct timeval result;
  2267. char timebuf[OSPF_TIME_DUMP_SIZE];
  2268. /* Check OSPF is enable. */
  2269. ospf = ospf_lookup ();
  2270. if (ospf == NULL)
  2271. {
  2272. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2273. return CMD_SUCCESS;
  2274. }
  2275. /* Show Router ID. */
  2276. vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
  2277. inet_ntoa (ospf->router_id),
  2278. VTY_NEWLINE);
  2279. /* Graceful shutdown */
  2280. if (ospf->t_deferred_shutdown)
  2281. vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
  2282. ospf_timer_dump (ospf->t_deferred_shutdown,
  2283. timebuf, sizeof (timebuf)), VTY_NEWLINE);
  2284. /* Show capability. */
  2285. vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
  2286. vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
  2287. vty_out (vty, " RFC1583Compatibility flag is %s%s",
  2288. CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
  2289. "enabled" : "disabled", VTY_NEWLINE);
  2290. #ifdef HAVE_OPAQUE_LSA
  2291. vty_out (vty, " OpaqueCapability flag is %s%s%s",
  2292. CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ?
  2293. "enabled" : "disabled",
  2294. IS_OPAQUE_LSA_ORIGINATION_BLOCKED (ospf->opaque) ?
  2295. " (origination blocked)" : "",
  2296. VTY_NEWLINE);
  2297. #endif /* HAVE_OPAQUE_LSA */
  2298. /* Show stub-router configuration */
  2299. if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
  2300. || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
  2301. {
  2302. vty_out (vty, " Stub router advertisement is configured%s",
  2303. VTY_NEWLINE);
  2304. if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
  2305. vty_out (vty, " Enabled for %us after start-up%s",
  2306. ospf->stub_router_startup_time, VTY_NEWLINE);
  2307. if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
  2308. vty_out (vty, " Enabled for %us prior to full shutdown%s",
  2309. ospf->stub_router_shutdown_time, VTY_NEWLINE);
  2310. }
  2311. /* Show SPF timers. */
  2312. vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
  2313. " Minimum hold time between consecutive SPFs %d millisec(s)%s"
  2314. " Maximum hold time between consecutive SPFs %d millisec(s)%s"
  2315. " Hold time multiplier is currently %d%s",
  2316. ospf->spf_delay, VTY_NEWLINE,
  2317. ospf->spf_holdtime, VTY_NEWLINE,
  2318. ospf->spf_max_holdtime, VTY_NEWLINE,
  2319. ospf->spf_hold_multiplier, VTY_NEWLINE);
  2320. vty_out (vty, " SPF algorithm ");
  2321. if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
  2322. {
  2323. result = tv_sub (recent_relative_time (), ospf->ts_spf);
  2324. vty_out (vty, "last executed %s ago%s",
  2325. ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
  2326. VTY_NEWLINE);
  2327. }
  2328. else
  2329. vty_out (vty, "has not been run%s", VTY_NEWLINE);
  2330. vty_out (vty, " SPF timer %s%s%s",
  2331. (ospf->t_spf_calc ? "due in " : "is "),
  2332. ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
  2333. VTY_NEWLINE);
  2334. /* Show refresh parameters. */
  2335. vty_out (vty, " Refresh timer %d secs%s",
  2336. ospf->lsa_refresh_interval, VTY_NEWLINE);
  2337. /* Show ABR/ASBR flags. */
  2338. if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
  2339. vty_out (vty, " This router is an ABR, ABR type is: %s%s",
  2340. ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
  2341. if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
  2342. vty_out (vty, " This router is an ASBR "
  2343. "(injecting external routing information)%s", VTY_NEWLINE);
  2344. /* Show Number of AS-external-LSAs. */
  2345. vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
  2346. ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
  2347. ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
  2348. #ifdef HAVE_OPAQUE_LSA
  2349. vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
  2350. ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
  2351. ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
  2352. #endif /* HAVE_OPAQUE_LSA */
  2353. /* Show number of areas attached. */
  2354. vty_out (vty, " Number of areas attached to this router: %d%s",
  2355. listcount (ospf->areas), VTY_NEWLINE);
  2356. if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
  2357. {
  2358. if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
  2359. vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
  2360. else
  2361. vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
  2362. }
  2363. vty_out (vty, "%s",VTY_NEWLINE);
  2364. /* Show each area status. */
  2365. for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
  2366. show_ip_ospf_area (vty, area);
  2367. return CMD_SUCCESS;
  2368. }
  2369. static void
  2370. show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf,
  2371. struct interface *ifp)
  2372. {
  2373. int is_up;
  2374. struct ospf_neighbor *nbr;
  2375. struct route_node *rn;
  2376. /* Is interface up? */
  2377. vty_out (vty, "%s is %s%s", ifp->name,
  2378. ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
  2379. vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Kbit %s%s",
  2380. ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
  2381. VTY_NEWLINE);
  2382. /* Is interface OSPF enabled? */
  2383. if (ospf_oi_count(ifp) == 0)
  2384. {
  2385. vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
  2386. return;
  2387. }
  2388. else if (!is_up)
  2389. {
  2390. vty_out (vty, " OSPF is enabled, but not running on this interface%s",
  2391. VTY_NEWLINE);
  2392. return;
  2393. }
  2394. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  2395. {
  2396. struct ospf_interface *oi = rn->info;
  2397. if (oi == NULL)
  2398. continue;
  2399. /* Show OSPF interface information. */
  2400. vty_out (vty, " Internet Address %s/%d,",
  2401. inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
  2402. if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
  2403. {
  2404. struct in_addr *dest;
  2405. const char *dstr;
  2406. if (CONNECTED_PEER(oi->connected)
  2407. || oi->type == OSPF_IFTYPE_VIRTUALLINK)
  2408. dstr = "Peer";
  2409. else
  2410. dstr = "Broadcast";
  2411. /* For Vlinks, showing the peer address is probably more
  2412. * informative than the local interface that is being used
  2413. */
  2414. if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
  2415. dest = &oi->vl_data->peer_addr;
  2416. else
  2417. dest = &oi->connected->destination->u.prefix4;
  2418. vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
  2419. }
  2420. vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
  2421. VTY_NEWLINE);
  2422. vty_out (vty, " MTU mismatch detection:%s%s",
  2423. OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
  2424. vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
  2425. inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
  2426. oi->output_cost, VTY_NEWLINE);
  2427. vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
  2428. OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
  2429. PRIORITY (oi), VTY_NEWLINE);
  2430. /* Show DR information. */
  2431. if (DR (oi).s_addr == 0)
  2432. vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
  2433. else
  2434. {
  2435. nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &DR (oi));
  2436. if (nbr == NULL)
  2437. vty_out (vty, " No designated router on this network%s", VTY_NEWLINE);
  2438. else
  2439. {
  2440. vty_out (vty, " Designated Router (ID) %s,",
  2441. inet_ntoa (nbr->router_id));
  2442. vty_out (vty, " Interface Address %s%s",
  2443. inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
  2444. }
  2445. }
  2446. /* Show BDR information. */
  2447. if (BDR (oi).s_addr == 0)
  2448. vty_out (vty, " No backup designated router on this network%s",
  2449. VTY_NEWLINE);
  2450. else
  2451. {
  2452. nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
  2453. if (nbr == NULL)
  2454. vty_out (vty, " No backup designated router on this network%s",
  2455. VTY_NEWLINE);
  2456. else
  2457. {
  2458. vty_out (vty, " Backup Designated Router (ID) %s,",
  2459. inet_ntoa (nbr->router_id));
  2460. vty_out (vty, " Interface Address %s%s",
  2461. inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
  2462. }
  2463. }
  2464. /* Next network-LSA sequence number we'll use, if we're elected DR */
  2465. if (oi->params && ntohl (oi->params->network_lsa_seqnum)
  2466. != OSPF_INITIAL_SEQUENCE_NUMBER)
  2467. vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
  2468. ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
  2469. vty_out (vty, " Multicast group memberships:");
  2470. if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
  2471. || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
  2472. {
  2473. if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
  2474. vty_out (vty, " OSPFAllRouters");
  2475. if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
  2476. vty_out (vty, " OSPFDesignatedRouters");
  2477. }
  2478. else
  2479. vty_out (vty, " <None>");
  2480. vty_out (vty, "%s", VTY_NEWLINE);
  2481. vty_out (vty, " Timer intervals configured,");
  2482. vty_out (vty, " Hello ");
  2483. if (OSPF_IF_PARAM (oi, fast_hello) == 0)
  2484. vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
  2485. else
  2486. vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
  2487. vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
  2488. OSPF_IF_PARAM (oi, v_wait),
  2489. OSPF_IF_PARAM (oi, v_wait),
  2490. OSPF_IF_PARAM (oi, retransmit_interval),
  2491. VTY_NEWLINE);
  2492. if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
  2493. {
  2494. char timebuf[OSPF_TIME_DUMP_SIZE];
  2495. vty_out (vty, " Hello due in %s%s",
  2496. ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
  2497. VTY_NEWLINE);
  2498. }
  2499. else /* passive-interface is set */
  2500. vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
  2501. vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
  2502. ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
  2503. VTY_NEWLINE);
  2504. }
  2505. }
  2506. DEFUN (show_ip_ospf_interface,
  2507. show_ip_ospf_interface_cmd,
  2508. "show ip ospf interface [INTERFACE]",
  2509. SHOW_STR
  2510. IP_STR
  2511. "OSPF information\n"
  2512. "Interface information\n"
  2513. "Interface name\n")
  2514. {
  2515. struct interface *ifp;
  2516. struct ospf *ospf;
  2517. struct listnode *node;
  2518. ospf = ospf_lookup ();
  2519. if (ospf == NULL)
  2520. {
  2521. vty_out (vty, "OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2522. return CMD_SUCCESS;
  2523. }
  2524. /* Show All Interfaces. */
  2525. if (argc == 0)
  2526. for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
  2527. show_ip_ospf_interface_sub (vty, ospf, ifp);
  2528. /* Interface name is specified. */
  2529. else
  2530. {
  2531. if ((ifp = if_lookup_by_name (argv[0])) == NULL)
  2532. vty_out (vty, "No such interface name%s", VTY_NEWLINE);
  2533. else
  2534. show_ip_ospf_interface_sub (vty, ospf, ifp);
  2535. }
  2536. return CMD_SUCCESS;
  2537. }
  2538. static void
  2539. show_ip_ospf_neighbour_header (struct vty *vty)
  2540. {
  2541. vty_out (vty, "%s%15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
  2542. VTY_NEWLINE,
  2543. "Neighbor ID", "Pri", "State", "Dead Time",
  2544. "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
  2545. VTY_NEWLINE);
  2546. }
  2547. static void
  2548. show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi)
  2549. {
  2550. struct route_node *rn;
  2551. struct ospf_neighbor *nbr;
  2552. char msgbuf[16];
  2553. char timebuf[OSPF_TIME_DUMP_SIZE];
  2554. for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
  2555. if ((nbr = rn->info))
  2556. /* Do not show myself. */
  2557. if (nbr != oi->nbr_self)
  2558. /* Down state is not shown. */
  2559. if (nbr->state != NSM_Down)
  2560. {
  2561. ospf_nbr_state_message (nbr, msgbuf, 16);
  2562. if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
  2563. vty_out (vty, "%-15s %3d %-15s ",
  2564. "-", nbr->priority,
  2565. msgbuf);
  2566. else
  2567. vty_out (vty, "%-15s %3d %-15s ",
  2568. inet_ntoa (nbr->router_id), nbr->priority,
  2569. msgbuf);
  2570. vty_out (vty, "%9s ",
  2571. ospf_timer_dump (nbr->t_inactivity, timebuf,
  2572. sizeof(timebuf)));
  2573. vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
  2574. vty_out (vty, "%-20s %5ld %5ld %5d%s",
  2575. IF_NAME (oi), ospf_ls_retransmit_count (nbr),
  2576. ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
  2577. VTY_NEWLINE);
  2578. }
  2579. }
  2580. DEFUN (show_ip_ospf_neighbor,
  2581. show_ip_ospf_neighbor_cmd,
  2582. "show ip ospf neighbor",
  2583. SHOW_STR
  2584. IP_STR
  2585. "OSPF information\n"
  2586. "Neighbor list\n")
  2587. {
  2588. struct ospf *ospf;
  2589. struct ospf_interface *oi;
  2590. struct listnode *node;
  2591. ospf = ospf_lookup ();
  2592. if (ospf == NULL)
  2593. {
  2594. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2595. return CMD_SUCCESS;
  2596. }
  2597. show_ip_ospf_neighbour_header (vty);
  2598. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
  2599. show_ip_ospf_neighbor_sub (vty, oi);
  2600. return CMD_SUCCESS;
  2601. }
  2602. DEFUN (show_ip_ospf_neighbor_all,
  2603. show_ip_ospf_neighbor_all_cmd,
  2604. "show ip ospf neighbor all",
  2605. SHOW_STR
  2606. IP_STR
  2607. "OSPF information\n"
  2608. "Neighbor list\n"
  2609. "include down status neighbor\n")
  2610. {
  2611. struct ospf *ospf = ospf_lookup ();
  2612. struct listnode *node;
  2613. struct ospf_interface *oi;
  2614. if (ospf == NULL)
  2615. {
  2616. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2617. return CMD_SUCCESS;
  2618. }
  2619. show_ip_ospf_neighbour_header (vty);
  2620. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
  2621. {
  2622. struct listnode *nbr_node;
  2623. struct ospf_nbr_nbma *nbr_nbma;
  2624. show_ip_ospf_neighbor_sub (vty, oi);
  2625. /* print Down neighbor status */
  2626. for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
  2627. {
  2628. if (nbr_nbma->nbr == NULL
  2629. || nbr_nbma->nbr->state == NSM_Down)
  2630. {
  2631. vty_out (vty, "%-15s %3d %-15s %9s ",
  2632. "-", nbr_nbma->priority, "Down", "-");
  2633. vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
  2634. inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
  2635. 0, 0, 0, VTY_NEWLINE);
  2636. }
  2637. }
  2638. }
  2639. return CMD_SUCCESS;
  2640. }
  2641. DEFUN (show_ip_ospf_neighbor_int,
  2642. show_ip_ospf_neighbor_int_cmd,
  2643. "show ip ospf neighbor IFNAME",
  2644. SHOW_STR
  2645. IP_STR
  2646. "OSPF information\n"
  2647. "Neighbor list\n"
  2648. "Interface name\n")
  2649. {
  2650. struct ospf *ospf;
  2651. struct interface *ifp;
  2652. struct route_node *rn;
  2653. ifp = if_lookup_by_name (argv[0]);
  2654. if (!ifp)
  2655. {
  2656. vty_out (vty, "No such interface.%s", VTY_NEWLINE);
  2657. return CMD_WARNING;
  2658. }
  2659. ospf = ospf_lookup ();
  2660. if (ospf == NULL)
  2661. {
  2662. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2663. return CMD_SUCCESS;
  2664. }
  2665. show_ip_ospf_neighbour_header (vty);
  2666. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  2667. {
  2668. struct ospf_interface *oi = rn->info;
  2669. if (oi == NULL)
  2670. continue;
  2671. show_ip_ospf_neighbor_sub (vty, oi);
  2672. }
  2673. return CMD_SUCCESS;
  2674. }
  2675. static void
  2676. show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi,
  2677. struct ospf_nbr_nbma *nbr_nbma)
  2678. {
  2679. char timebuf[OSPF_TIME_DUMP_SIZE];
  2680. /* Show neighbor ID. */
  2681. vty_out (vty, " Neighbor %s,", "-");
  2682. /* Show interface address. */
  2683. vty_out (vty, " interface address %s%s",
  2684. inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
  2685. /* Show Area ID. */
  2686. vty_out (vty, " In the area %s via interface %s%s",
  2687. ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
  2688. /* Show neighbor priority and state. */
  2689. vty_out (vty, " Neighbor priority is %d, State is %s,",
  2690. nbr_nbma->priority, "Down");
  2691. /* Show state changes. */
  2692. vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
  2693. /* Show PollInterval */
  2694. vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
  2695. /* Show poll-interval timer. */
  2696. vty_out (vty, " Poll timer due in %s%s",
  2697. ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
  2698. VTY_NEWLINE);
  2699. /* Show poll-interval timer thread. */
  2700. vty_out (vty, " Thread Poll Timer %s%s",
  2701. nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
  2702. }
  2703. static void
  2704. show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
  2705. struct ospf_neighbor *nbr)
  2706. {
  2707. char timebuf[OSPF_TIME_DUMP_SIZE];
  2708. /* Show neighbor ID. */
  2709. if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
  2710. vty_out (vty, " Neighbor %s,", "-");
  2711. else
  2712. vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
  2713. /* Show interface address. */
  2714. vty_out (vty, " interface address %s%s",
  2715. inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
  2716. /* Show Area ID. */
  2717. vty_out (vty, " In the area %s via interface %s%s",
  2718. ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
  2719. /* Show neighbor priority and state. */
  2720. vty_out (vty, " Neighbor priority is %d, State is %s,",
  2721. nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
  2722. /* Show state changes. */
  2723. vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
  2724. if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
  2725. {
  2726. struct timeval res
  2727. = tv_sub (recent_relative_time (), nbr->ts_last_progress);
  2728. vty_out (vty, " Most recent state change statistics:%s",
  2729. VTY_NEWLINE);
  2730. vty_out (vty, " Progressive change %s ago%s",
  2731. ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
  2732. VTY_NEWLINE);
  2733. }
  2734. if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
  2735. {
  2736. struct timeval res
  2737. = tv_sub (recent_relative_time (), nbr->ts_last_regress);
  2738. vty_out (vty, " Regressive change %s ago, due to %s%s",
  2739. ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
  2740. (nbr->last_regress_str ? nbr->last_regress_str : "??"),
  2741. VTY_NEWLINE);
  2742. }
  2743. /* Show Designated Rotuer ID. */
  2744. vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
  2745. /* Show Backup Designated Rotuer ID. */
  2746. vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
  2747. /* Show options. */
  2748. vty_out (vty, " Options %d %s%s", nbr->options,
  2749. ospf_options_dump (nbr->options), VTY_NEWLINE);
  2750. /* Show Router Dead interval timer. */
  2751. vty_out (vty, " Dead timer due in %s%s",
  2752. ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
  2753. VTY_NEWLINE);
  2754. /* Show Database Summary list. */
  2755. vty_out (vty, " Database Summary List %d%s",
  2756. ospf_db_summary_count (nbr), VTY_NEWLINE);
  2757. /* Show Link State Request list. */
  2758. vty_out (vty, " Link State Request List %ld%s",
  2759. ospf_ls_request_count (nbr), VTY_NEWLINE);
  2760. /* Show Link State Retransmission list. */
  2761. vty_out (vty, " Link State Retransmission List %ld%s",
  2762. ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
  2763. /* Show inactivity timer thread. */
  2764. vty_out (vty, " Thread Inactivity Timer %s%s",
  2765. nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
  2766. /* Show Database Description retransmission thread. */
  2767. vty_out (vty, " Thread Database Description Retransmision %s%s",
  2768. nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
  2769. /* Show Link State Request Retransmission thread. */
  2770. vty_out (vty, " Thread Link State Request Retransmission %s%s",
  2771. nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
  2772. /* Show Link State Update Retransmission thread. */
  2773. vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
  2774. nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
  2775. }
  2776. DEFUN (show_ip_ospf_neighbor_id,
  2777. show_ip_ospf_neighbor_id_cmd,
  2778. "show ip ospf neighbor A.B.C.D",
  2779. SHOW_STR
  2780. IP_STR
  2781. "OSPF information\n"
  2782. "Neighbor list\n"
  2783. "Neighbor ID\n")
  2784. {
  2785. struct ospf *ospf;
  2786. struct listnode *node;
  2787. struct ospf_neighbor *nbr;
  2788. struct ospf_interface *oi;
  2789. struct in_addr router_id;
  2790. int ret;
  2791. ret = inet_aton (argv[0], &router_id);
  2792. if (!ret)
  2793. {
  2794. vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
  2795. return CMD_WARNING;
  2796. }
  2797. ospf = ospf_lookup ();
  2798. if (ospf == NULL)
  2799. {
  2800. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2801. return CMD_SUCCESS;
  2802. }
  2803. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
  2804. if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
  2805. show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
  2806. return CMD_SUCCESS;
  2807. }
  2808. DEFUN (show_ip_ospf_neighbor_detail,
  2809. show_ip_ospf_neighbor_detail_cmd,
  2810. "show ip ospf neighbor detail",
  2811. SHOW_STR
  2812. IP_STR
  2813. "OSPF information\n"
  2814. "Neighbor list\n"
  2815. "detail of all neighbors\n")
  2816. {
  2817. struct ospf *ospf;
  2818. struct ospf_interface *oi;
  2819. struct listnode *node;
  2820. ospf = ospf_lookup ();
  2821. if (ospf == NULL)
  2822. {
  2823. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2824. return CMD_SUCCESS;
  2825. }
  2826. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
  2827. {
  2828. struct route_node *rn;
  2829. struct ospf_neighbor *nbr;
  2830. for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
  2831. if ((nbr = rn->info))
  2832. if (nbr != oi->nbr_self)
  2833. if (nbr->state != NSM_Down)
  2834. show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
  2835. }
  2836. return CMD_SUCCESS;
  2837. }
  2838. DEFUN (show_ip_ospf_neighbor_detail_all,
  2839. show_ip_ospf_neighbor_detail_all_cmd,
  2840. "show ip ospf neighbor detail all",
  2841. SHOW_STR
  2842. IP_STR
  2843. "OSPF information\n"
  2844. "Neighbor list\n"
  2845. "detail of all neighbors\n"
  2846. "include down status neighbor\n")
  2847. {
  2848. struct ospf *ospf;
  2849. struct listnode *node;
  2850. struct ospf_interface *oi;
  2851. ospf = ospf_lookup ();
  2852. if (ospf == NULL)
  2853. {
  2854. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2855. return CMD_SUCCESS;
  2856. }
  2857. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
  2858. {
  2859. struct route_node *rn;
  2860. struct ospf_neighbor *nbr;
  2861. struct ospf_nbr_nbma *nbr_nbma;
  2862. for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
  2863. if ((nbr = rn->info))
  2864. if (nbr != oi->nbr_self)
  2865. if (oi->type == OSPF_IFTYPE_NBMA && nbr->state != NSM_Down)
  2866. show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info);
  2867. if (oi->type == OSPF_IFTYPE_NBMA)
  2868. {
  2869. struct listnode *nd;
  2870. for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
  2871. if (nbr_nbma->nbr == NULL
  2872. || nbr_nbma->nbr->state == NSM_Down)
  2873. show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma);
  2874. }
  2875. }
  2876. return CMD_SUCCESS;
  2877. }
  2878. DEFUN (show_ip_ospf_neighbor_int_detail,
  2879. show_ip_ospf_neighbor_int_detail_cmd,
  2880. "show ip ospf neighbor IFNAME detail",
  2881. SHOW_STR
  2882. IP_STR
  2883. "OSPF information\n"
  2884. "Neighbor list\n"
  2885. "Interface name\n"
  2886. "detail of all neighbors")
  2887. {
  2888. struct ospf *ospf;
  2889. struct ospf_interface *oi;
  2890. struct interface *ifp;
  2891. struct route_node *rn, *nrn;
  2892. struct ospf_neighbor *nbr;
  2893. ifp = if_lookup_by_name (argv[0]);
  2894. if (!ifp)
  2895. {
  2896. vty_out (vty, "No such interface.%s", VTY_NEWLINE);
  2897. return CMD_WARNING;
  2898. }
  2899. ospf = ospf_lookup ();
  2900. if (ospf == NULL)
  2901. {
  2902. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  2903. return CMD_SUCCESS;
  2904. }
  2905. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  2906. if ((oi = rn->info))
  2907. for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
  2908. if ((nbr = nrn->info))
  2909. if (nbr != oi->nbr_self)
  2910. if (nbr->state != NSM_Down)
  2911. show_ip_ospf_neighbor_detail_sub (vty, oi, nbr);
  2912. return CMD_SUCCESS;
  2913. }
  2914. /* Show functions */
  2915. static int
  2916. show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
  2917. {
  2918. struct router_lsa *rl;
  2919. struct summary_lsa *sl;
  2920. struct as_external_lsa *asel;
  2921. struct prefix_ipv4 p;
  2922. if (lsa != NULL)
  2923. /* If self option is set, check LSA self flag. */
  2924. if (self == 0 || IS_LSA_SELF (lsa))
  2925. {
  2926. /* LSA common part show. */
  2927. vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
  2928. vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
  2929. inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
  2930. (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
  2931. /* LSA specific part show. */
  2932. switch (lsa->data->type)
  2933. {
  2934. case OSPF_ROUTER_LSA:
  2935. rl = (struct router_lsa *) lsa->data;
  2936. vty_out (vty, " %-d", ntohs (rl->links));
  2937. break;
  2938. case OSPF_SUMMARY_LSA:
  2939. sl = (struct summary_lsa *) lsa->data;
  2940. p.family = AF_INET;
  2941. p.prefix = sl->header.id;
  2942. p.prefixlen = ip_masklen (sl->mask);
  2943. apply_mask_ipv4 (&p);
  2944. vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
  2945. break;
  2946. case OSPF_AS_EXTERNAL_LSA:
  2947. case OSPF_AS_NSSA_LSA:
  2948. asel = (struct as_external_lsa *) lsa->data;
  2949. p.family = AF_INET;
  2950. p.prefix = asel->header.id;
  2951. p.prefixlen = ip_masklen (asel->mask);
  2952. apply_mask_ipv4 (&p);
  2953. vty_out (vty, " %s %s/%d [0x%lx]",
  2954. IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
  2955. inet_ntoa (p.prefix), p.prefixlen,
  2956. (u_long)ntohl (asel->e[0].route_tag));
  2957. break;
  2958. case OSPF_NETWORK_LSA:
  2959. case OSPF_ASBR_SUMMARY_LSA:
  2960. #ifdef HAVE_OPAQUE_LSA
  2961. case OSPF_OPAQUE_LINK_LSA:
  2962. case OSPF_OPAQUE_AREA_LSA:
  2963. case OSPF_OPAQUE_AS_LSA:
  2964. #endif /* HAVE_OPAQUE_LSA */
  2965. default:
  2966. break;
  2967. }
  2968. vty_out (vty, VTY_NEWLINE);
  2969. }
  2970. return 0;
  2971. }
  2972. static const char *show_database_desc[] =
  2973. {
  2974. "unknown",
  2975. "Router Link States",
  2976. "Net Link States",
  2977. "Summary Link States",
  2978. "ASBR-Summary Link States",
  2979. "AS External Link States",
  2980. "Group Membership LSA",
  2981. "NSSA-external Link States",
  2982. #ifdef HAVE_OPAQUE_LSA
  2983. "Type-8 LSA",
  2984. "Link-Local Opaque-LSA",
  2985. "Area-Local Opaque-LSA",
  2986. "AS-external Opaque-LSA",
  2987. #endif /* HAVE_OPAQUE_LSA */
  2988. };
  2989. static const char *show_database_header[] =
  2990. {
  2991. "",
  2992. "Link ID ADV Router Age Seq# CkSum Link count",
  2993. "Link ID ADV Router Age Seq# CkSum",
  2994. "Link ID ADV Router Age Seq# CkSum Route",
  2995. "Link ID ADV Router Age Seq# CkSum",
  2996. "Link ID ADV Router Age Seq# CkSum Route",
  2997. " --- header for Group Member ----",
  2998. "Link ID ADV Router Age Seq# CkSum Route",
  2999. #ifdef HAVE_OPAQUE_LSA
  3000. " --- type-8 ---",
  3001. "Opaque-Type/Id ADV Router Age Seq# CkSum",
  3002. "Opaque-Type/Id ADV Router Age Seq# CkSum",
  3003. "Opaque-Type/Id ADV Router Age Seq# CkSum",
  3004. #endif /* HAVE_OPAQUE_LSA */
  3005. };
  3006. static void
  3007. show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
  3008. {
  3009. struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
  3010. vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
  3011. vty_out (vty, " Options: 0x%-2x : %s%s",
  3012. lsa->data->options,
  3013. ospf_options_dump(lsa->data->options),
  3014. VTY_NEWLINE);
  3015. vty_out (vty, " LS Flags: 0x%-2x %s%s",
  3016. lsa->flags,
  3017. ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
  3018. VTY_NEWLINE);
  3019. if (lsa->data->type == OSPF_ROUTER_LSA)
  3020. {
  3021. vty_out (vty, " Flags: 0x%x" , rlsa->flags);
  3022. if (rlsa->flags)
  3023. vty_out (vty, " :%s%s%s%s",
  3024. IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
  3025. IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
  3026. IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
  3027. IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
  3028. vty_out (vty, "%s", VTY_NEWLINE);
  3029. }
  3030. vty_out (vty, " LS Type: %s%s",
  3031. LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
  3032. vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
  3033. LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
  3034. vty_out (vty, " Advertising Router: %s%s",
  3035. inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
  3036. vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
  3037. VTY_NEWLINE);
  3038. vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
  3039. VTY_NEWLINE);
  3040. vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
  3041. }
  3042. const char *link_type_desc[] =
  3043. {
  3044. "(null)",
  3045. "another Router (point-to-point)",
  3046. "a Transit Network",
  3047. "Stub Network",
  3048. "a Virtual Link",
  3049. };
  3050. const char *link_id_desc[] =
  3051. {
  3052. "(null)",
  3053. "Neighboring Router ID",
  3054. "Designated Router address",
  3055. "Net",
  3056. "Neighboring Router ID",
  3057. };
  3058. const char *link_data_desc[] =
  3059. {
  3060. "(null)",
  3061. "Router Interface address",
  3062. "Router Interface address",
  3063. "Network Mask",
  3064. "Router Interface address",
  3065. };
  3066. /* Show router-LSA each Link information. */
  3067. static void
  3068. show_ip_ospf_database_router_links (struct vty *vty,
  3069. struct router_lsa *rl)
  3070. {
  3071. int len, i, type;
  3072. len = ntohs (rl->header.length) - 4;
  3073. for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
  3074. {
  3075. type = rl->link[i].type;
  3076. vty_out (vty, " Link connected to: %s%s",
  3077. link_type_desc[type], VTY_NEWLINE);
  3078. vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
  3079. inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
  3080. vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
  3081. inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
  3082. vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
  3083. vty_out (vty, " TOS 0 Metric: %d%s",
  3084. ntohs (rl->link[i].metric), VTY_NEWLINE);
  3085. vty_out (vty, "%s", VTY_NEWLINE);
  3086. }
  3087. }
  3088. /* Show router-LSA detail information. */
  3089. static int
  3090. show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3091. {
  3092. if (lsa != NULL)
  3093. {
  3094. struct router_lsa *rl = (struct router_lsa *) lsa->data;
  3095. show_ip_ospf_database_header (vty, lsa);
  3096. vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
  3097. VTY_NEWLINE, VTY_NEWLINE);
  3098. show_ip_ospf_database_router_links (vty, rl);
  3099. vty_out (vty, "%s", VTY_NEWLINE);
  3100. }
  3101. return 0;
  3102. }
  3103. /* Show network-LSA detail information. */
  3104. static int
  3105. show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3106. {
  3107. int length, i;
  3108. if (lsa != NULL)
  3109. {
  3110. struct network_lsa *nl = (struct network_lsa *) lsa->data;
  3111. show_ip_ospf_database_header (vty, lsa);
  3112. vty_out (vty, " Network Mask: /%d%s",
  3113. ip_masklen (nl->mask), VTY_NEWLINE);
  3114. length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
  3115. for (i = 0; length > 0; i++, length -= 4)
  3116. vty_out (vty, " Attached Router: %s%s",
  3117. inet_ntoa (nl->routers[i]), VTY_NEWLINE);
  3118. vty_out (vty, "%s", VTY_NEWLINE);
  3119. }
  3120. return 0;
  3121. }
  3122. /* Show summary-LSA detail information. */
  3123. static int
  3124. show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3125. {
  3126. if (lsa != NULL)
  3127. {
  3128. struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
  3129. show_ip_ospf_database_header (vty, lsa);
  3130. vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
  3131. VTY_NEWLINE);
  3132. vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
  3133. VTY_NEWLINE);
  3134. vty_out (vty, "%s", VTY_NEWLINE);
  3135. }
  3136. return 0;
  3137. }
  3138. /* Show summary-ASBR-LSA detail information. */
  3139. static int
  3140. show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3141. {
  3142. if (lsa != NULL)
  3143. {
  3144. struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
  3145. show_ip_ospf_database_header (vty, lsa);
  3146. vty_out (vty, " Network Mask: /%d%s",
  3147. ip_masklen (sl->mask), VTY_NEWLINE);
  3148. vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
  3149. VTY_NEWLINE);
  3150. vty_out (vty, "%s", VTY_NEWLINE);
  3151. }
  3152. return 0;
  3153. }
  3154. /* Show AS-external-LSA detail information. */
  3155. static int
  3156. show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3157. {
  3158. if (lsa != NULL)
  3159. {
  3160. struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
  3161. show_ip_ospf_database_header (vty, lsa);
  3162. vty_out (vty, " Network Mask: /%d%s",
  3163. ip_masklen (al->mask), VTY_NEWLINE);
  3164. vty_out (vty, " Metric Type: %s%s",
  3165. IS_EXTERNAL_METRIC (al->e[0].tos) ?
  3166. "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
  3167. vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
  3168. vty_out (vty, " Metric: %d%s",
  3169. GET_METRIC (al->e[0].metric), VTY_NEWLINE);
  3170. vty_out (vty, " Forward Address: %s%s",
  3171. inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
  3172. vty_out (vty, " External Route Tag: %lu%s%s",
  3173. (u_long)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
  3174. }
  3175. return 0;
  3176. }
  3177. #if 0
  3178. static int
  3179. show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
  3180. {
  3181. struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
  3182. /* show_ip_ospf_database_header (vty, lsa); */
  3183. zlog_debug( " Network Mask: /%d%s",
  3184. ip_masklen (al->mask), "\n");
  3185. zlog_debug( " Metric Type: %s%s",
  3186. IS_EXTERNAL_METRIC (al->e[0].tos) ?
  3187. "2 (Larger than any link state path)" : "1", "\n");
  3188. zlog_debug( " TOS: 0%s", "\n");
  3189. zlog_debug( " Metric: %d%s",
  3190. GET_METRIC (al->e[0].metric), "\n");
  3191. zlog_debug( " Forward Address: %s%s",
  3192. inet_ntoa (al->e[0].fwd_addr), "\n");
  3193. zlog_debug( " External Route Tag: %u%s%s",
  3194. ntohl (al->e[0].route_tag), "\n", "\n");
  3195. return 0;
  3196. }
  3197. #endif
  3198. /* Show AS-NSSA-LSA detail information. */
  3199. static int
  3200. show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3201. {
  3202. if (lsa != NULL)
  3203. {
  3204. struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
  3205. show_ip_ospf_database_header (vty, lsa);
  3206. vty_out (vty, " Network Mask: /%d%s",
  3207. ip_masklen (al->mask), VTY_NEWLINE);
  3208. vty_out (vty, " Metric Type: %s%s",
  3209. IS_EXTERNAL_METRIC (al->e[0].tos) ?
  3210. "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
  3211. vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
  3212. vty_out (vty, " Metric: %d%s",
  3213. GET_METRIC (al->e[0].metric), VTY_NEWLINE);
  3214. vty_out (vty, " NSSA: Forward Address: %s%s",
  3215. inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
  3216. vty_out (vty, " External Route Tag: %u%s%s",
  3217. ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
  3218. }
  3219. return 0;
  3220. }
  3221. static int
  3222. show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
  3223. {
  3224. return 0;
  3225. }
  3226. #ifdef HAVE_OPAQUE_LSA
  3227. static int
  3228. show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
  3229. {
  3230. if (lsa != NULL)
  3231. {
  3232. show_ip_ospf_database_header (vty, lsa);
  3233. show_opaque_info_detail (vty, lsa);
  3234. vty_out (vty, "%s", VTY_NEWLINE);
  3235. }
  3236. return 0;
  3237. }
  3238. #endif /* HAVE_OPAQUE_LSA */
  3239. int (*show_function[])(struct vty *, struct ospf_lsa *) =
  3240. {
  3241. NULL,
  3242. show_router_lsa_detail,
  3243. show_network_lsa_detail,
  3244. show_summary_lsa_detail,
  3245. show_summary_asbr_lsa_detail,
  3246. show_as_external_lsa_detail,
  3247. show_func_dummy,
  3248. show_as_nssa_lsa_detail, /* almost same as external */
  3249. #ifdef HAVE_OPAQUE_LSA
  3250. NULL, /* type-8 */
  3251. show_opaque_lsa_detail,
  3252. show_opaque_lsa_detail,
  3253. show_opaque_lsa_detail,
  3254. #endif /* HAVE_OPAQUE_LSA */
  3255. };
  3256. static void
  3257. show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
  3258. struct in_addr *adv_router)
  3259. {
  3260. memset (lp, 0, sizeof (struct prefix_ls));
  3261. lp->family = 0;
  3262. if (id == NULL)
  3263. lp->prefixlen = 0;
  3264. else if (adv_router == NULL)
  3265. {
  3266. lp->prefixlen = 32;
  3267. lp->id = *id;
  3268. }
  3269. else
  3270. {
  3271. lp->prefixlen = 64;
  3272. lp->id = *id;
  3273. lp->adv_router = *adv_router;
  3274. }
  3275. }
  3276. static void
  3277. show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
  3278. struct in_addr *id, struct in_addr *adv_router)
  3279. {
  3280. struct prefix_ls lp;
  3281. struct route_node *rn, *start;
  3282. struct ospf_lsa *lsa;
  3283. show_lsa_prefix_set (vty, &lp, id, adv_router);
  3284. start = route_node_get (rt, (struct prefix *) &lp);
  3285. if (start)
  3286. {
  3287. route_lock_node (start);
  3288. for (rn = start; rn; rn = route_next_until (rn, start))
  3289. if ((lsa = rn->info))
  3290. {
  3291. if (show_function[lsa->data->type] != NULL)
  3292. show_function[lsa->data->type] (vty, lsa);
  3293. }
  3294. route_unlock_node (start);
  3295. }
  3296. }
  3297. /* Show detail LSA information
  3298. -- if id is NULL then show all LSAs. */
  3299. static void
  3300. show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
  3301. struct in_addr *id, struct in_addr *adv_router)
  3302. {
  3303. struct listnode *node;
  3304. struct ospf_area *area;
  3305. switch (type)
  3306. {
  3307. case OSPF_AS_EXTERNAL_LSA:
  3308. #ifdef HAVE_OPAQUE_LSA
  3309. case OSPF_OPAQUE_AS_LSA:
  3310. #endif /* HAVE_OPAQUE_LSA */
  3311. vty_out (vty, " %s %s%s",
  3312. show_database_desc[type],
  3313. VTY_NEWLINE, VTY_NEWLINE);
  3314. show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
  3315. break;
  3316. default:
  3317. for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
  3318. {
  3319. vty_out (vty, "%s %s (Area %s)%s%s",
  3320. VTY_NEWLINE, show_database_desc[type],
  3321. ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
  3322. show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
  3323. }
  3324. break;
  3325. }
  3326. }
  3327. static void
  3328. show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
  3329. struct in_addr *adv_router)
  3330. {
  3331. struct route_node *rn;
  3332. struct ospf_lsa *lsa;
  3333. for (rn = route_top (rt); rn; rn = route_next (rn))
  3334. if ((lsa = rn->info))
  3335. if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
  3336. {
  3337. if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
  3338. continue;
  3339. if (show_function[lsa->data->type] != NULL)
  3340. show_function[lsa->data->type] (vty, lsa);
  3341. }
  3342. }
  3343. /* Show detail LSA information. */
  3344. static void
  3345. show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
  3346. struct in_addr *adv_router)
  3347. {
  3348. struct listnode *node;
  3349. struct ospf_area *area;
  3350. switch (type)
  3351. {
  3352. case OSPF_AS_EXTERNAL_LSA:
  3353. #ifdef HAVE_OPAQUE_LSA
  3354. case OSPF_OPAQUE_AS_LSA:
  3355. #endif /* HAVE_OPAQUE_LSA */
  3356. vty_out (vty, " %s %s%s",
  3357. show_database_desc[type],
  3358. VTY_NEWLINE, VTY_NEWLINE);
  3359. show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
  3360. adv_router);
  3361. break;
  3362. default:
  3363. for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
  3364. {
  3365. vty_out (vty, "%s %s (Area %s)%s%s",
  3366. VTY_NEWLINE, show_database_desc[type],
  3367. ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
  3368. show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
  3369. adv_router);
  3370. }
  3371. break;
  3372. }
  3373. }
  3374. static void
  3375. show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
  3376. {
  3377. struct ospf_lsa *lsa;
  3378. struct route_node *rn;
  3379. struct ospf_area *area;
  3380. struct listnode *node;
  3381. int type;
  3382. for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
  3383. {
  3384. for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
  3385. {
  3386. switch (type)
  3387. {
  3388. case OSPF_AS_EXTERNAL_LSA:
  3389. #ifdef HAVE_OPAQUE_LSA
  3390. case OSPF_OPAQUE_AS_LSA:
  3391. #endif /* HAVE_OPAQUE_LSA */
  3392. continue;
  3393. default:
  3394. break;
  3395. }
  3396. if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
  3397. (!self && ospf_lsdb_count (area->lsdb, type) > 0))
  3398. {
  3399. vty_out (vty, " %s (Area %s)%s%s",
  3400. show_database_desc[type],
  3401. ospf_area_desc_string (area),
  3402. VTY_NEWLINE, VTY_NEWLINE);
  3403. vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
  3404. LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
  3405. show_lsa_summary (vty, lsa, self);
  3406. vty_out (vty, "%s", VTY_NEWLINE);
  3407. }
  3408. }
  3409. }
  3410. for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
  3411. {
  3412. switch (type)
  3413. {
  3414. case OSPF_AS_EXTERNAL_LSA:
  3415. #ifdef HAVE_OPAQUE_LSA
  3416. case OSPF_OPAQUE_AS_LSA:
  3417. #endif /* HAVE_OPAQUE_LSA */
  3418. break;
  3419. default:
  3420. continue;
  3421. }
  3422. if (ospf_lsdb_count_self (ospf->lsdb, type) ||
  3423. (!self && ospf_lsdb_count (ospf->lsdb, type)))
  3424. {
  3425. vty_out (vty, " %s%s%s",
  3426. show_database_desc[type],
  3427. VTY_NEWLINE, VTY_NEWLINE);
  3428. vty_out (vty, "%s%s", show_database_header[type],
  3429. VTY_NEWLINE);
  3430. LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
  3431. show_lsa_summary (vty, lsa, self);
  3432. vty_out (vty, "%s", VTY_NEWLINE);
  3433. }
  3434. }
  3435. vty_out (vty, "%s", VTY_NEWLINE);
  3436. }
  3437. static void
  3438. show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
  3439. {
  3440. struct route_node *rn;
  3441. vty_out (vty, "%s MaxAge Link States:%s%s",
  3442. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  3443. for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
  3444. {
  3445. struct ospf_lsa *lsa;
  3446. if ((lsa = rn->info) != NULL)
  3447. {
  3448. vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
  3449. vty_out (vty, "Link State ID: %s%s",
  3450. inet_ntoa (lsa->data->id), VTY_NEWLINE);
  3451. vty_out (vty, "Advertising Router: %s%s",
  3452. inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
  3453. vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
  3454. vty_out (vty, "%s", VTY_NEWLINE);
  3455. }
  3456. }
  3457. }
  3458. #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
  3459. #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
  3460. #ifdef HAVE_OPAQUE_LSA
  3461. #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
  3462. #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
  3463. #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
  3464. #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
  3465. #else /* HAVE_OPAQUE_LSA */
  3466. #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC ""
  3467. #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC ""
  3468. #define OSPF_LSA_TYPE_OPAQUE_AS_DESC ""
  3469. #define OSPF_LSA_TYPE_OPAQUE_CMD_STR ""
  3470. #endif /* HAVE_OPAQUE_LSA */
  3471. #define OSPF_LSA_TYPES_CMD_STR \
  3472. "asbr-summary|external|network|router|summary" \
  3473. OSPF_LSA_TYPE_NSSA_CMD_STR \
  3474. OSPF_LSA_TYPE_OPAQUE_CMD_STR
  3475. #define OSPF_LSA_TYPES_DESC \
  3476. "ASBR summary link states\n" \
  3477. "External link states\n" \
  3478. "Network link states\n" \
  3479. "Router link states\n" \
  3480. "Network summary link states\n" \
  3481. OSPF_LSA_TYPE_NSSA_DESC \
  3482. OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
  3483. OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
  3484. OSPF_LSA_TYPE_OPAQUE_AS_DESC
  3485. DEFUN (show_ip_ospf_database,
  3486. show_ip_ospf_database_cmd,
  3487. "show ip ospf database",
  3488. SHOW_STR
  3489. IP_STR
  3490. "OSPF information\n"
  3491. "Database summary\n")
  3492. {
  3493. struct ospf *ospf;
  3494. int type, ret;
  3495. struct in_addr id, adv_router;
  3496. ospf = ospf_lookup ();
  3497. if (ospf == NULL)
  3498. {
  3499. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  3500. return CMD_SUCCESS;
  3501. }
  3502. vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
  3503. inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
  3504. /* Show all LSA. */
  3505. if (argc == 0)
  3506. {
  3507. show_ip_ospf_database_summary (vty, ospf, 0);
  3508. return CMD_SUCCESS;
  3509. }
  3510. /* Set database type to show. */
  3511. if (strncmp (argv[0], "r", 1) == 0)
  3512. type = OSPF_ROUTER_LSA;
  3513. else if (strncmp (argv[0], "ne", 2) == 0)
  3514. type = OSPF_NETWORK_LSA;
  3515. else if (strncmp (argv[0], "ns", 2) == 0)
  3516. type = OSPF_AS_NSSA_LSA;
  3517. else if (strncmp (argv[0], "su", 2) == 0)
  3518. type = OSPF_SUMMARY_LSA;
  3519. else if (strncmp (argv[0], "a", 1) == 0)
  3520. type = OSPF_ASBR_SUMMARY_LSA;
  3521. else if (strncmp (argv[0], "e", 1) == 0)
  3522. type = OSPF_AS_EXTERNAL_LSA;
  3523. else if (strncmp (argv[0], "se", 2) == 0)
  3524. {
  3525. show_ip_ospf_database_summary (vty, ospf, 1);
  3526. return CMD_SUCCESS;
  3527. }
  3528. else if (strncmp (argv[0], "m", 1) == 0)
  3529. {
  3530. show_ip_ospf_database_maxage (vty, ospf);
  3531. return CMD_SUCCESS;
  3532. }
  3533. #ifdef HAVE_OPAQUE_LSA
  3534. else if (strncmp (argv[0], "opaque-l", 8) == 0)
  3535. type = OSPF_OPAQUE_LINK_LSA;
  3536. else if (strncmp (argv[0], "opaque-ar", 9) == 0)
  3537. type = OSPF_OPAQUE_AREA_LSA;
  3538. else if (strncmp (argv[0], "opaque-as", 9) == 0)
  3539. type = OSPF_OPAQUE_AS_LSA;
  3540. #endif /* HAVE_OPAQUE_LSA */
  3541. else
  3542. return CMD_WARNING;
  3543. /* `show ip ospf database LSA'. */
  3544. if (argc == 1)
  3545. show_lsa_detail (vty, ospf, type, NULL, NULL);
  3546. else if (argc >= 2)
  3547. {
  3548. ret = inet_aton (argv[1], &id);
  3549. if (!ret)
  3550. return CMD_WARNING;
  3551. /* `show ip ospf database LSA ID'. */
  3552. if (argc == 2)
  3553. show_lsa_detail (vty, ospf, type, &id, NULL);
  3554. /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
  3555. else if (argc == 3)
  3556. {
  3557. if (strncmp (argv[2], "s", 1) == 0)
  3558. adv_router = ospf->router_id;
  3559. else
  3560. {
  3561. ret = inet_aton (argv[2], &adv_router);
  3562. if (!ret)
  3563. return CMD_WARNING;
  3564. }
  3565. show_lsa_detail (vty, ospf, type, &id, &adv_router);
  3566. }
  3567. }
  3568. return CMD_SUCCESS;
  3569. }
  3570. ALIAS (show_ip_ospf_database,
  3571. show_ip_ospf_database_type_cmd,
  3572. "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
  3573. SHOW_STR
  3574. IP_STR
  3575. "OSPF information\n"
  3576. "Database summary\n"
  3577. OSPF_LSA_TYPES_DESC
  3578. "LSAs in MaxAge list\n"
  3579. "Self-originated link states\n")
  3580. ALIAS (show_ip_ospf_database,
  3581. show_ip_ospf_database_type_id_cmd,
  3582. "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
  3583. SHOW_STR
  3584. IP_STR
  3585. "OSPF information\n"
  3586. "Database summary\n"
  3587. OSPF_LSA_TYPES_DESC
  3588. "Link State ID (as an IP address)\n")
  3589. ALIAS (show_ip_ospf_database,
  3590. show_ip_ospf_database_type_id_adv_router_cmd,
  3591. "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
  3592. SHOW_STR
  3593. IP_STR
  3594. "OSPF information\n"
  3595. "Database summary\n"
  3596. OSPF_LSA_TYPES_DESC
  3597. "Link State ID (as an IP address)\n"
  3598. "Advertising Router link states\n"
  3599. "Advertising Router (as an IP address)\n")
  3600. ALIAS (show_ip_ospf_database,
  3601. show_ip_ospf_database_type_id_self_cmd,
  3602. "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
  3603. SHOW_STR
  3604. IP_STR
  3605. "OSPF information\n"
  3606. "Database summary\n"
  3607. OSPF_LSA_TYPES_DESC
  3608. "Link State ID (as an IP address)\n"
  3609. "Self-originated link states\n"
  3610. "\n")
  3611. DEFUN (show_ip_ospf_database_type_adv_router,
  3612. show_ip_ospf_database_type_adv_router_cmd,
  3613. "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
  3614. SHOW_STR
  3615. IP_STR
  3616. "OSPF information\n"
  3617. "Database summary\n"
  3618. OSPF_LSA_TYPES_DESC
  3619. "Advertising Router link states\n"
  3620. "Advertising Router (as an IP address)\n")
  3621. {
  3622. struct ospf *ospf;
  3623. int type, ret;
  3624. struct in_addr adv_router;
  3625. ospf = ospf_lookup ();
  3626. if (ospf == NULL)
  3627. {
  3628. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  3629. return CMD_SUCCESS;
  3630. }
  3631. vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
  3632. inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
  3633. if (argc != 2)
  3634. return CMD_WARNING;
  3635. /* Set database type to show. */
  3636. if (strncmp (argv[0], "r", 1) == 0)
  3637. type = OSPF_ROUTER_LSA;
  3638. else if (strncmp (argv[0], "ne", 2) == 0)
  3639. type = OSPF_NETWORK_LSA;
  3640. else if (strncmp (argv[0], "ns", 2) == 0)
  3641. type = OSPF_AS_NSSA_LSA;
  3642. else if (strncmp (argv[0], "s", 1) == 0)
  3643. type = OSPF_SUMMARY_LSA;
  3644. else if (strncmp (argv[0], "a", 1) == 0)
  3645. type = OSPF_ASBR_SUMMARY_LSA;
  3646. else if (strncmp (argv[0], "e", 1) == 0)
  3647. type = OSPF_AS_EXTERNAL_LSA;
  3648. #ifdef HAVE_OPAQUE_LSA
  3649. else if (strncmp (argv[0], "opaque-l", 8) == 0)
  3650. type = OSPF_OPAQUE_LINK_LSA;
  3651. else if (strncmp (argv[0], "opaque-ar", 9) == 0)
  3652. type = OSPF_OPAQUE_AREA_LSA;
  3653. else if (strncmp (argv[0], "opaque-as", 9) == 0)
  3654. type = OSPF_OPAQUE_AS_LSA;
  3655. #endif /* HAVE_OPAQUE_LSA */
  3656. else
  3657. return CMD_WARNING;
  3658. /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
  3659. if (strncmp (argv[1], "s", 1) == 0)
  3660. adv_router = ospf->router_id;
  3661. else
  3662. {
  3663. ret = inet_aton (argv[1], &adv_router);
  3664. if (!ret)
  3665. return CMD_WARNING;
  3666. }
  3667. show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
  3668. return CMD_SUCCESS;
  3669. }
  3670. ALIAS (show_ip_ospf_database_type_adv_router,
  3671. show_ip_ospf_database_type_self_cmd,
  3672. "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
  3673. SHOW_STR
  3674. IP_STR
  3675. "OSPF information\n"
  3676. "Database summary\n"
  3677. OSPF_LSA_TYPES_DESC
  3678. "Self-originated link states\n")
  3679. DEFUN (ip_ospf_authentication_args,
  3680. ip_ospf_authentication_args_addr_cmd,
  3681. "ip ospf authentication (null|message-digest) A.B.C.D",
  3682. "IP Information\n"
  3683. "OSPF interface commands\n"
  3684. "Enable authentication on this interface\n"
  3685. "Use null authentication\n"
  3686. "Use message-digest authentication\n"
  3687. "Address of interface")
  3688. {
  3689. struct interface *ifp;
  3690. struct in_addr addr;
  3691. int ret;
  3692. struct ospf_if_params *params;
  3693. ifp = vty->index;
  3694. params = IF_DEF_PARAMS (ifp);
  3695. if (argc == 2)
  3696. {
  3697. ret = inet_aton(argv[1], &addr);
  3698. if (!ret)
  3699. {
  3700. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3701. VTY_NEWLINE);
  3702. return CMD_WARNING;
  3703. }
  3704. params = ospf_get_if_params (ifp, addr);
  3705. ospf_if_update_params (ifp, addr);
  3706. }
  3707. /* Handle null authentication */
  3708. if ( argv[0][0] == 'n' )
  3709. {
  3710. SET_IF_PARAM (params, auth_type);
  3711. params->auth_type = OSPF_AUTH_NULL;
  3712. return CMD_SUCCESS;
  3713. }
  3714. /* Handle message-digest authentication */
  3715. if ( argv[0][0] == 'm' )
  3716. {
  3717. SET_IF_PARAM (params, auth_type);
  3718. params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
  3719. return CMD_SUCCESS;
  3720. }
  3721. vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
  3722. return CMD_WARNING;
  3723. }
  3724. ALIAS (ip_ospf_authentication_args,
  3725. ip_ospf_authentication_args_cmd,
  3726. "ip ospf authentication (null|message-digest)",
  3727. "IP Information\n"
  3728. "OSPF interface commands\n"
  3729. "Enable authentication on this interface\n"
  3730. "Use null authentication\n"
  3731. "Use message-digest authentication\n")
  3732. DEFUN (ip_ospf_authentication,
  3733. ip_ospf_authentication_addr_cmd,
  3734. "ip ospf authentication A.B.C.D",
  3735. "IP Information\n"
  3736. "OSPF interface commands\n"
  3737. "Enable authentication on this interface\n"
  3738. "Address of interface")
  3739. {
  3740. struct interface *ifp;
  3741. struct in_addr addr;
  3742. int ret;
  3743. struct ospf_if_params *params;
  3744. ifp = vty->index;
  3745. params = IF_DEF_PARAMS (ifp);
  3746. if (argc == 1)
  3747. {
  3748. ret = inet_aton(argv[0], &addr);
  3749. if (!ret)
  3750. {
  3751. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3752. VTY_NEWLINE);
  3753. return CMD_WARNING;
  3754. }
  3755. params = ospf_get_if_params (ifp, addr);
  3756. ospf_if_update_params (ifp, addr);
  3757. }
  3758. SET_IF_PARAM (params, auth_type);
  3759. params->auth_type = OSPF_AUTH_SIMPLE;
  3760. return CMD_SUCCESS;
  3761. }
  3762. ALIAS (ip_ospf_authentication,
  3763. ip_ospf_authentication_cmd,
  3764. "ip ospf authentication",
  3765. "IP Information\n"
  3766. "OSPF interface commands\n"
  3767. "Enable authentication on this interface\n")
  3768. DEFUN (no_ip_ospf_authentication,
  3769. no_ip_ospf_authentication_addr_cmd,
  3770. "no ip ospf authentication A.B.C.D",
  3771. NO_STR
  3772. "IP Information\n"
  3773. "OSPF interface commands\n"
  3774. "Enable authentication on this interface\n"
  3775. "Address of interface")
  3776. {
  3777. struct interface *ifp;
  3778. struct in_addr addr;
  3779. int ret;
  3780. struct ospf_if_params *params;
  3781. ifp = vty->index;
  3782. params = IF_DEF_PARAMS (ifp);
  3783. if (argc == 1)
  3784. {
  3785. ret = inet_aton(argv[0], &addr);
  3786. if (!ret)
  3787. {
  3788. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3789. VTY_NEWLINE);
  3790. return CMD_WARNING;
  3791. }
  3792. params = ospf_lookup_if_params (ifp, addr);
  3793. if (params == NULL)
  3794. return CMD_SUCCESS;
  3795. }
  3796. params->auth_type = OSPF_AUTH_NOTSET;
  3797. UNSET_IF_PARAM (params, auth_type);
  3798. if (params != IF_DEF_PARAMS (ifp))
  3799. {
  3800. ospf_free_if_params (ifp, addr);
  3801. ospf_if_update_params (ifp, addr);
  3802. }
  3803. return CMD_SUCCESS;
  3804. }
  3805. ALIAS (no_ip_ospf_authentication,
  3806. no_ip_ospf_authentication_cmd,
  3807. "no ip ospf authentication",
  3808. NO_STR
  3809. "IP Information\n"
  3810. "OSPF interface commands\n"
  3811. "Enable authentication on this interface\n")
  3812. DEFUN (ip_ospf_authentication_key,
  3813. ip_ospf_authentication_key_addr_cmd,
  3814. "ip ospf authentication-key AUTH_KEY A.B.C.D",
  3815. "IP Information\n"
  3816. "OSPF interface commands\n"
  3817. "Authentication password (key)\n"
  3818. "The OSPF password (key)\n"
  3819. "Address of interface")
  3820. {
  3821. struct interface *ifp;
  3822. struct in_addr addr;
  3823. int ret;
  3824. struct ospf_if_params *params;
  3825. ifp = vty->index;
  3826. params = IF_DEF_PARAMS (ifp);
  3827. if (argc == 2)
  3828. {
  3829. ret = inet_aton(argv[1], &addr);
  3830. if (!ret)
  3831. {
  3832. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3833. VTY_NEWLINE);
  3834. return CMD_WARNING;
  3835. }
  3836. params = ospf_get_if_params (ifp, addr);
  3837. ospf_if_update_params (ifp, addr);
  3838. }
  3839. memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
  3840. strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
  3841. SET_IF_PARAM (params, auth_simple);
  3842. return CMD_SUCCESS;
  3843. }
  3844. ALIAS (ip_ospf_authentication_key,
  3845. ip_ospf_authentication_key_cmd,
  3846. "ip ospf authentication-key AUTH_KEY",
  3847. "IP Information\n"
  3848. "OSPF interface commands\n"
  3849. "Authentication password (key)\n"
  3850. "The OSPF password (key)")
  3851. ALIAS (ip_ospf_authentication_key,
  3852. ospf_authentication_key_cmd,
  3853. "ospf authentication-key AUTH_KEY",
  3854. "OSPF interface commands\n"
  3855. "Authentication password (key)\n"
  3856. "The OSPF password (key)")
  3857. DEFUN (no_ip_ospf_authentication_key,
  3858. no_ip_ospf_authentication_key_addr_cmd,
  3859. "no ip ospf authentication-key A.B.C.D",
  3860. NO_STR
  3861. "IP Information\n"
  3862. "OSPF interface commands\n"
  3863. "Authentication password (key)\n"
  3864. "Address of interface")
  3865. {
  3866. struct interface *ifp;
  3867. struct in_addr addr;
  3868. int ret;
  3869. struct ospf_if_params *params;
  3870. ifp = vty->index;
  3871. params = IF_DEF_PARAMS (ifp);
  3872. if (argc == 1)
  3873. {
  3874. ret = inet_aton(argv[0], &addr);
  3875. if (!ret)
  3876. {
  3877. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3878. VTY_NEWLINE);
  3879. return CMD_WARNING;
  3880. }
  3881. params = ospf_lookup_if_params (ifp, addr);
  3882. if (params == NULL)
  3883. return CMD_SUCCESS;
  3884. }
  3885. memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
  3886. UNSET_IF_PARAM (params, auth_simple);
  3887. if (params != IF_DEF_PARAMS (ifp))
  3888. {
  3889. ospf_free_if_params (ifp, addr);
  3890. ospf_if_update_params (ifp, addr);
  3891. }
  3892. return CMD_SUCCESS;
  3893. }
  3894. ALIAS (no_ip_ospf_authentication_key,
  3895. no_ip_ospf_authentication_key_cmd,
  3896. "no ip ospf authentication-key",
  3897. NO_STR
  3898. "IP Information\n"
  3899. "OSPF interface commands\n"
  3900. "Authentication password (key)\n")
  3901. ALIAS (no_ip_ospf_authentication_key,
  3902. no_ospf_authentication_key_cmd,
  3903. "no ospf authentication-key",
  3904. NO_STR
  3905. "OSPF interface commands\n"
  3906. "Authentication password (key)\n")
  3907. DEFUN (ip_ospf_message_digest_key,
  3908. ip_ospf_message_digest_key_addr_cmd,
  3909. "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
  3910. "IP Information\n"
  3911. "OSPF interface commands\n"
  3912. "Message digest authentication password (key)\n"
  3913. "Key ID\n"
  3914. "Use MD5 algorithm\n"
  3915. "The OSPF password (key)"
  3916. "Address of interface")
  3917. {
  3918. struct interface *ifp;
  3919. struct crypt_key *ck;
  3920. u_char key_id;
  3921. struct in_addr addr;
  3922. int ret;
  3923. struct ospf_if_params *params;
  3924. ifp = vty->index;
  3925. params = IF_DEF_PARAMS (ifp);
  3926. if (argc == 3)
  3927. {
  3928. ret = inet_aton(argv[2], &addr);
  3929. if (!ret)
  3930. {
  3931. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3932. VTY_NEWLINE);
  3933. return CMD_WARNING;
  3934. }
  3935. params = ospf_get_if_params (ifp, addr);
  3936. ospf_if_update_params (ifp, addr);
  3937. }
  3938. key_id = strtol (argv[0], NULL, 10);
  3939. if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
  3940. {
  3941. vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
  3942. return CMD_WARNING;
  3943. }
  3944. ck = ospf_crypt_key_new ();
  3945. ck->key_id = (u_char) key_id;
  3946. memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
  3947. strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
  3948. ospf_crypt_key_add (params->auth_crypt, ck);
  3949. SET_IF_PARAM (params, auth_crypt);
  3950. return CMD_SUCCESS;
  3951. }
  3952. ALIAS (ip_ospf_message_digest_key,
  3953. ip_ospf_message_digest_key_cmd,
  3954. "ip ospf message-digest-key <1-255> md5 KEY",
  3955. "IP Information\n"
  3956. "OSPF interface commands\n"
  3957. "Message digest authentication password (key)\n"
  3958. "Key ID\n"
  3959. "Use MD5 algorithm\n"
  3960. "The OSPF password (key)")
  3961. ALIAS (ip_ospf_message_digest_key,
  3962. ospf_message_digest_key_cmd,
  3963. "ospf message-digest-key <1-255> md5 KEY",
  3964. "OSPF interface commands\n"
  3965. "Message digest authentication password (key)\n"
  3966. "Key ID\n"
  3967. "Use MD5 algorithm\n"
  3968. "The OSPF password (key)")
  3969. DEFUN (no_ip_ospf_message_digest_key,
  3970. no_ip_ospf_message_digest_key_addr_cmd,
  3971. "no ip ospf message-digest-key <1-255> A.B.C.D",
  3972. NO_STR
  3973. "IP Information\n"
  3974. "OSPF interface commands\n"
  3975. "Message digest authentication password (key)\n"
  3976. "Key ID\n"
  3977. "Address of interface")
  3978. {
  3979. struct interface *ifp;
  3980. struct crypt_key *ck;
  3981. int key_id;
  3982. struct in_addr addr;
  3983. int ret;
  3984. struct ospf_if_params *params;
  3985. ifp = vty->index;
  3986. params = IF_DEF_PARAMS (ifp);
  3987. if (argc == 2)
  3988. {
  3989. ret = inet_aton(argv[1], &addr);
  3990. if (!ret)
  3991. {
  3992. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  3993. VTY_NEWLINE);
  3994. return CMD_WARNING;
  3995. }
  3996. params = ospf_lookup_if_params (ifp, addr);
  3997. if (params == NULL)
  3998. return CMD_SUCCESS;
  3999. }
  4000. key_id = strtol (argv[0], NULL, 10);
  4001. ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
  4002. if (ck == NULL)
  4003. {
  4004. vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
  4005. return CMD_WARNING;
  4006. }
  4007. ospf_crypt_key_delete (params->auth_crypt, key_id);
  4008. if (params != IF_DEF_PARAMS (ifp))
  4009. {
  4010. ospf_free_if_params (ifp, addr);
  4011. ospf_if_update_params (ifp, addr);
  4012. }
  4013. return CMD_SUCCESS;
  4014. }
  4015. ALIAS (no_ip_ospf_message_digest_key,
  4016. no_ip_ospf_message_digest_key_cmd,
  4017. "no ip ospf message-digest-key <1-255>",
  4018. NO_STR
  4019. "IP Information\n"
  4020. "OSPF interface commands\n"
  4021. "Message digest authentication password (key)\n"
  4022. "Key ID\n")
  4023. ALIAS (no_ip_ospf_message_digest_key,
  4024. no_ospf_message_digest_key_cmd,
  4025. "no ospf message-digest-key <1-255>",
  4026. NO_STR
  4027. "OSPF interface commands\n"
  4028. "Message digest authentication password (key)\n"
  4029. "Key ID\n")
  4030. DEFUN (ip_ospf_cost,
  4031. ip_ospf_cost_u32_inet4_cmd,
  4032. "ip ospf cost <1-65535> A.B.C.D",
  4033. "IP Information\n"
  4034. "OSPF interface commands\n"
  4035. "Interface cost\n"
  4036. "Cost\n"
  4037. "Address of interface")
  4038. {
  4039. struct interface *ifp = vty->index;
  4040. u_int32_t cost;
  4041. struct in_addr addr;
  4042. int ret;
  4043. struct ospf_if_params *params;
  4044. params = IF_DEF_PARAMS (ifp);
  4045. cost = strtol (argv[0], NULL, 10);
  4046. /* cost range is <1-65535>. */
  4047. if (cost < 1 || cost > 65535)
  4048. {
  4049. vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
  4050. return CMD_WARNING;
  4051. }
  4052. if (argc == 2)
  4053. {
  4054. ret = inet_aton(argv[1], &addr);
  4055. if (!ret)
  4056. {
  4057. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4058. VTY_NEWLINE);
  4059. return CMD_WARNING;
  4060. }
  4061. params = ospf_get_if_params (ifp, addr);
  4062. ospf_if_update_params (ifp, addr);
  4063. }
  4064. SET_IF_PARAM (params, output_cost_cmd);
  4065. params->output_cost_cmd = cost;
  4066. ospf_if_recalculate_output_cost (ifp);
  4067. return CMD_SUCCESS;
  4068. }
  4069. ALIAS (ip_ospf_cost,
  4070. ip_ospf_cost_u32_cmd,
  4071. "ip ospf cost <1-65535>",
  4072. "IP Information\n"
  4073. "OSPF interface commands\n"
  4074. "Interface cost\n"
  4075. "Cost")
  4076. ALIAS (ip_ospf_cost,
  4077. ospf_cost_u32_cmd,
  4078. "ospf cost <1-65535>",
  4079. "OSPF interface commands\n"
  4080. "Interface cost\n"
  4081. "Cost")
  4082. ALIAS (ip_ospf_cost,
  4083. ospf_cost_u32_inet4_cmd,
  4084. "ospf cost <1-65535> A.B.C.D",
  4085. "OSPF interface commands\n"
  4086. "Interface cost\n"
  4087. "Cost\n"
  4088. "Address of interface")
  4089. DEFUN (no_ip_ospf_cost,
  4090. no_ip_ospf_cost_inet4_cmd,
  4091. "no ip ospf cost A.B.C.D",
  4092. NO_STR
  4093. "IP Information\n"
  4094. "OSPF interface commands\n"
  4095. "Interface cost\n"
  4096. "Address of interface")
  4097. {
  4098. struct interface *ifp = vty->index;
  4099. struct in_addr addr;
  4100. int ret;
  4101. struct ospf_if_params *params;
  4102. ifp = vty->index;
  4103. params = IF_DEF_PARAMS (ifp);
  4104. if (argc == 1)
  4105. {
  4106. ret = inet_aton(argv[0], &addr);
  4107. if (!ret)
  4108. {
  4109. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4110. VTY_NEWLINE);
  4111. return CMD_WARNING;
  4112. }
  4113. params = ospf_lookup_if_params (ifp, addr);
  4114. if (params == NULL)
  4115. return CMD_SUCCESS;
  4116. }
  4117. UNSET_IF_PARAM (params, output_cost_cmd);
  4118. if (params != IF_DEF_PARAMS (ifp))
  4119. {
  4120. ospf_free_if_params (ifp, addr);
  4121. ospf_if_update_params (ifp, addr);
  4122. }
  4123. ospf_if_recalculate_output_cost (ifp);
  4124. return CMD_SUCCESS;
  4125. }
  4126. ALIAS (no_ip_ospf_cost,
  4127. no_ip_ospf_cost_cmd,
  4128. "no ip ospf cost",
  4129. NO_STR
  4130. "IP Information\n"
  4131. "OSPF interface commands\n"
  4132. "Interface cost\n")
  4133. ALIAS (no_ip_ospf_cost,
  4134. no_ospf_cost_cmd,
  4135. "no ospf cost",
  4136. NO_STR
  4137. "OSPF interface commands\n"
  4138. "Interface cost\n")
  4139. ALIAS (no_ip_ospf_cost,
  4140. no_ospf_cost_inet4_cmd,
  4141. "no ospf cost A.B.C.D",
  4142. NO_STR
  4143. "OSPF interface commands\n"
  4144. "Interface cost\n"
  4145. "Address of interface")
  4146. DEFUN (no_ip_ospf_cost2,
  4147. no_ip_ospf_cost_u32_cmd,
  4148. "no ip ospf cost <1-65535>",
  4149. NO_STR
  4150. "IP Information\n"
  4151. "OSPF interface commands\n"
  4152. "Interface cost\n"
  4153. "Cost")
  4154. {
  4155. struct interface *ifp = vty->index;
  4156. struct in_addr addr;
  4157. u_int32_t cost;
  4158. int ret;
  4159. struct ospf_if_params *params;
  4160. ifp = vty->index;
  4161. params = IF_DEF_PARAMS (ifp);
  4162. /* According to the semantics we are mimicking "no ip ospf cost N" is
  4163. * always treated as "no ip ospf cost" regardless of the actual value
  4164. * of N already configured for the interface. Thus the first argument
  4165. * is always checked to be a number, but is ignored after that.
  4166. */
  4167. cost = strtol (argv[0], NULL, 10);
  4168. if (cost < 1 || cost > 65535)
  4169. {
  4170. vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
  4171. return CMD_WARNING;
  4172. }
  4173. if (argc == 2)
  4174. {
  4175. ret = inet_aton(argv[1], &addr);
  4176. if (!ret)
  4177. {
  4178. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4179. VTY_NEWLINE);
  4180. return CMD_WARNING;
  4181. }
  4182. params = ospf_lookup_if_params (ifp, addr);
  4183. if (params == NULL)
  4184. return CMD_SUCCESS;
  4185. }
  4186. UNSET_IF_PARAM (params, output_cost_cmd);
  4187. if (params != IF_DEF_PARAMS (ifp))
  4188. {
  4189. ospf_free_if_params (ifp, addr);
  4190. ospf_if_update_params (ifp, addr);
  4191. }
  4192. ospf_if_recalculate_output_cost (ifp);
  4193. return CMD_SUCCESS;
  4194. }
  4195. ALIAS (no_ip_ospf_cost2,
  4196. no_ospf_cost_u32_cmd,
  4197. "no ospf cost <1-65535>",
  4198. NO_STR
  4199. "OSPF interface commands\n"
  4200. "Interface cost\n"
  4201. "Cost")
  4202. ALIAS (no_ip_ospf_cost2,
  4203. no_ip_ospf_cost_u32_inet4_cmd,
  4204. "no ip ospf cost <1-65535> A.B.C.D",
  4205. NO_STR
  4206. "IP Information\n"
  4207. "OSPF interface commands\n"
  4208. "Interface cost\n"
  4209. "Cost\n"
  4210. "Address of interface")
  4211. ALIAS (no_ip_ospf_cost2,
  4212. no_ospf_cost_u32_inet4_cmd,
  4213. "no ospf cost <1-65535> A.B.C.D",
  4214. NO_STR
  4215. "OSPF interface commands\n"
  4216. "Interface cost\n"
  4217. "Cost\n"
  4218. "Address of interface")
  4219. static void
  4220. ospf_nbr_timer_update (struct ospf_interface *oi)
  4221. {
  4222. struct route_node *rn;
  4223. struct ospf_neighbor *nbr;
  4224. for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
  4225. if ((nbr = rn->info))
  4226. {
  4227. nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
  4228. nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
  4229. nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
  4230. nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
  4231. }
  4232. }
  4233. static int
  4234. ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
  4235. const char *nbr_str,
  4236. const char *fast_hello_str)
  4237. {
  4238. struct interface *ifp = vty->index;
  4239. u_int32_t seconds;
  4240. u_char hellomult;
  4241. struct in_addr addr;
  4242. int ret;
  4243. struct ospf_if_params *params;
  4244. struct ospf_interface *oi;
  4245. struct route_node *rn;
  4246. params = IF_DEF_PARAMS (ifp);
  4247. if (nbr_str)
  4248. {
  4249. ret = inet_aton(nbr_str, &addr);
  4250. if (!ret)
  4251. {
  4252. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4253. VTY_NEWLINE);
  4254. return CMD_WARNING;
  4255. }
  4256. params = ospf_get_if_params (ifp, addr);
  4257. ospf_if_update_params (ifp, addr);
  4258. }
  4259. if (interval_str)
  4260. {
  4261. VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
  4262. 1, 65535);
  4263. /* reset fast_hello too, just to be sure */
  4264. UNSET_IF_PARAM (params, fast_hello);
  4265. params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
  4266. }
  4267. else if (fast_hello_str)
  4268. {
  4269. VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
  4270. 1, 10);
  4271. /* 1s dead-interval with sub-second hellos desired */
  4272. seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
  4273. SET_IF_PARAM (params, fast_hello);
  4274. params->fast_hello = hellomult;
  4275. }
  4276. else
  4277. {
  4278. vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
  4279. VTY_NEWLINE);
  4280. return CMD_WARNING;
  4281. }
  4282. SET_IF_PARAM (params, v_wait);
  4283. params->v_wait = seconds;
  4284. /* Update timer values in neighbor structure. */
  4285. if (nbr_str)
  4286. {
  4287. struct ospf *ospf;
  4288. if ((ospf = ospf_lookup()))
  4289. {
  4290. oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
  4291. if (oi)
  4292. ospf_nbr_timer_update (oi);
  4293. }
  4294. }
  4295. else
  4296. {
  4297. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  4298. if ((oi = rn->info))
  4299. ospf_nbr_timer_update (oi);
  4300. }
  4301. return CMD_SUCCESS;
  4302. }
  4303. DEFUN (ip_ospf_dead_interval,
  4304. ip_ospf_dead_interval_addr_cmd,
  4305. "ip ospf dead-interval <1-65535> A.B.C.D",
  4306. "IP Information\n"
  4307. "OSPF interface commands\n"
  4308. "Interval after which a neighbor is declared dead\n"
  4309. "Seconds\n"
  4310. "Address of interface\n")
  4311. {
  4312. if (argc == 2)
  4313. return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
  4314. else
  4315. return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
  4316. }
  4317. ALIAS (ip_ospf_dead_interval,
  4318. ip_ospf_dead_interval_cmd,
  4319. "ip ospf dead-interval <1-65535>",
  4320. "IP Information\n"
  4321. "OSPF interface commands\n"
  4322. "Interval after which a neighbor is declared dead\n"
  4323. "Seconds\n")
  4324. ALIAS (ip_ospf_dead_interval,
  4325. ospf_dead_interval_cmd,
  4326. "ospf dead-interval <1-65535>",
  4327. "OSPF interface commands\n"
  4328. "Interval after which a neighbor is declared dead\n"
  4329. "Seconds\n")
  4330. DEFUN (ip_ospf_dead_interval_minimal,
  4331. ip_ospf_dead_interval_minimal_addr_cmd,
  4332. "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
  4333. "IP Information\n"
  4334. "OSPF interface commands\n"
  4335. "Interval after which a neighbor is declared dead\n"
  4336. "Minimal 1s dead-interval with fast sub-second hellos\n"
  4337. "Hello multiplier factor\n"
  4338. "Number of Hellos to send each second\n"
  4339. "Address of interface\n")
  4340. {
  4341. if (argc == 2)
  4342. return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
  4343. else
  4344. return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
  4345. }
  4346. ALIAS (ip_ospf_dead_interval_minimal,
  4347. ip_ospf_dead_interval_minimal_cmd,
  4348. "ip ospf dead-interval minimal hello-multiplier <1-10>",
  4349. "IP Information\n"
  4350. "OSPF interface commands\n"
  4351. "Interval after which a neighbor is declared dead\n"
  4352. "Minimal 1s dead-interval with fast sub-second hellos\n"
  4353. "Hello multiplier factor\n"
  4354. "Number of Hellos to send each second\n")
  4355. DEFUN (no_ip_ospf_dead_interval,
  4356. no_ip_ospf_dead_interval_addr_cmd,
  4357. "no ip ospf dead-interval A.B.C.D",
  4358. NO_STR
  4359. "IP Information\n"
  4360. "OSPF interface commands\n"
  4361. "Interval after which a neighbor is declared dead\n"
  4362. "Address of interface")
  4363. {
  4364. struct interface *ifp = vty->index;
  4365. struct in_addr addr;
  4366. int ret;
  4367. struct ospf_if_params *params;
  4368. struct ospf_interface *oi;
  4369. struct route_node *rn;
  4370. ifp = vty->index;
  4371. params = IF_DEF_PARAMS (ifp);
  4372. if (argc == 1)
  4373. {
  4374. ret = inet_aton(argv[0], &addr);
  4375. if (!ret)
  4376. {
  4377. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4378. VTY_NEWLINE);
  4379. return CMD_WARNING;
  4380. }
  4381. params = ospf_lookup_if_params (ifp, addr);
  4382. if (params == NULL)
  4383. return CMD_SUCCESS;
  4384. }
  4385. UNSET_IF_PARAM (params, v_wait);
  4386. params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
  4387. UNSET_IF_PARAM (params, fast_hello);
  4388. params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
  4389. if (params != IF_DEF_PARAMS (ifp))
  4390. {
  4391. ospf_free_if_params (ifp, addr);
  4392. ospf_if_update_params (ifp, addr);
  4393. }
  4394. /* Update timer values in neighbor structure. */
  4395. if (argc == 1)
  4396. {
  4397. struct ospf *ospf;
  4398. if ((ospf = ospf_lookup()))
  4399. {
  4400. oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
  4401. if (oi)
  4402. ospf_nbr_timer_update (oi);
  4403. }
  4404. }
  4405. else
  4406. {
  4407. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  4408. if ((oi = rn->info))
  4409. ospf_nbr_timer_update (oi);
  4410. }
  4411. return CMD_SUCCESS;
  4412. }
  4413. ALIAS (no_ip_ospf_dead_interval,
  4414. no_ip_ospf_dead_interval_cmd,
  4415. "no ip ospf dead-interval",
  4416. NO_STR
  4417. "IP Information\n"
  4418. "OSPF interface commands\n"
  4419. "Interval after which a neighbor is declared dead\n")
  4420. ALIAS (no_ip_ospf_dead_interval,
  4421. no_ospf_dead_interval_cmd,
  4422. "no ospf dead-interval",
  4423. NO_STR
  4424. "OSPF interface commands\n"
  4425. "Interval after which a neighbor is declared dead\n")
  4426. DEFUN (ip_ospf_hello_interval,
  4427. ip_ospf_hello_interval_addr_cmd,
  4428. "ip ospf hello-interval <1-65535> A.B.C.D",
  4429. "IP Information\n"
  4430. "OSPF interface commands\n"
  4431. "Time between HELLO packets\n"
  4432. "Seconds\n"
  4433. "Address of interface")
  4434. {
  4435. struct interface *ifp = vty->index;
  4436. u_int32_t seconds;
  4437. struct in_addr addr;
  4438. int ret;
  4439. struct ospf_if_params *params;
  4440. params = IF_DEF_PARAMS (ifp);
  4441. seconds = strtol (argv[0], NULL, 10);
  4442. /* HelloInterval range is <1-65535>. */
  4443. if (seconds < 1 || seconds > 65535)
  4444. {
  4445. vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
  4446. return CMD_WARNING;
  4447. }
  4448. if (argc == 2)
  4449. {
  4450. ret = inet_aton(argv[1], &addr);
  4451. if (!ret)
  4452. {
  4453. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4454. VTY_NEWLINE);
  4455. return CMD_WARNING;
  4456. }
  4457. params = ospf_get_if_params (ifp, addr);
  4458. ospf_if_update_params (ifp, addr);
  4459. }
  4460. SET_IF_PARAM (params, v_hello);
  4461. params->v_hello = seconds;
  4462. return CMD_SUCCESS;
  4463. }
  4464. ALIAS (ip_ospf_hello_interval,
  4465. ip_ospf_hello_interval_cmd,
  4466. "ip ospf hello-interval <1-65535>",
  4467. "IP Information\n"
  4468. "OSPF interface commands\n"
  4469. "Time between HELLO packets\n"
  4470. "Seconds\n")
  4471. ALIAS (ip_ospf_hello_interval,
  4472. ospf_hello_interval_cmd,
  4473. "ospf hello-interval <1-65535>",
  4474. "OSPF interface commands\n"
  4475. "Time between HELLO packets\n"
  4476. "Seconds\n")
  4477. DEFUN (no_ip_ospf_hello_interval,
  4478. no_ip_ospf_hello_interval_addr_cmd,
  4479. "no ip ospf hello-interval A.B.C.D",
  4480. NO_STR
  4481. "IP Information\n"
  4482. "OSPF interface commands\n"
  4483. "Time between HELLO packets\n"
  4484. "Address of interface")
  4485. {
  4486. struct interface *ifp = vty->index;
  4487. struct in_addr addr;
  4488. int ret;
  4489. struct ospf_if_params *params;
  4490. ifp = vty->index;
  4491. params = IF_DEF_PARAMS (ifp);
  4492. if (argc == 1)
  4493. {
  4494. ret = inet_aton(argv[0], &addr);
  4495. if (!ret)
  4496. {
  4497. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4498. VTY_NEWLINE);
  4499. return CMD_WARNING;
  4500. }
  4501. params = ospf_lookup_if_params (ifp, addr);
  4502. if (params == NULL)
  4503. return CMD_SUCCESS;
  4504. }
  4505. UNSET_IF_PARAM (params, v_hello);
  4506. params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
  4507. if (params != IF_DEF_PARAMS (ifp))
  4508. {
  4509. ospf_free_if_params (ifp, addr);
  4510. ospf_if_update_params (ifp, addr);
  4511. }
  4512. return CMD_SUCCESS;
  4513. }
  4514. ALIAS (no_ip_ospf_hello_interval,
  4515. no_ip_ospf_hello_interval_cmd,
  4516. "no ip ospf hello-interval",
  4517. NO_STR
  4518. "IP Information\n"
  4519. "OSPF interface commands\n"
  4520. "Time between HELLO packets\n")
  4521. ALIAS (no_ip_ospf_hello_interval,
  4522. no_ospf_hello_interval_cmd,
  4523. "no ospf hello-interval",
  4524. NO_STR
  4525. "OSPF interface commands\n"
  4526. "Time between HELLO packets\n")
  4527. DEFUN (ip_ospf_network,
  4528. ip_ospf_network_cmd,
  4529. "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
  4530. "IP Information\n"
  4531. "OSPF interface commands\n"
  4532. "Network type\n"
  4533. "Specify OSPF broadcast multi-access network\n"
  4534. "Specify OSPF NBMA network\n"
  4535. "Specify OSPF point-to-multipoint network\n"
  4536. "Specify OSPF point-to-point network\n")
  4537. {
  4538. struct interface *ifp = vty->index;
  4539. int old_type = IF_DEF_PARAMS (ifp)->type;
  4540. struct route_node *rn;
  4541. if (old_type == OSPF_IFTYPE_LOOPBACK)
  4542. {
  4543. vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
  4544. return CMD_WARNING;
  4545. }
  4546. if (strncmp (argv[0], "b", 1) == 0)
  4547. IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
  4548. else if (strncmp (argv[0], "n", 1) == 0)
  4549. IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
  4550. else if (strncmp (argv[0], "point-to-m", 10) == 0)
  4551. IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
  4552. else if (strncmp (argv[0], "point-to-p", 10) == 0)
  4553. IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
  4554. if (IF_DEF_PARAMS (ifp)->type == old_type)
  4555. return CMD_SUCCESS;
  4556. SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
  4557. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  4558. {
  4559. struct ospf_interface *oi = rn->info;
  4560. if (!oi)
  4561. continue;
  4562. oi->type = IF_DEF_PARAMS (ifp)->type;
  4563. if (oi->state > ISM_Down)
  4564. {
  4565. OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
  4566. OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
  4567. }
  4568. }
  4569. return CMD_SUCCESS;
  4570. }
  4571. ALIAS (ip_ospf_network,
  4572. ospf_network_cmd,
  4573. "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
  4574. "OSPF interface commands\n"
  4575. "Network type\n"
  4576. "Specify OSPF broadcast multi-access network\n"
  4577. "Specify OSPF NBMA network\n"
  4578. "Specify OSPF point-to-multipoint network\n"
  4579. "Specify OSPF point-to-point network\n")
  4580. DEFUN (no_ip_ospf_network,
  4581. no_ip_ospf_network_cmd,
  4582. "no ip ospf network",
  4583. NO_STR
  4584. "IP Information\n"
  4585. "OSPF interface commands\n"
  4586. "Network type\n")
  4587. {
  4588. struct interface *ifp = vty->index;
  4589. int old_type = IF_DEF_PARAMS (ifp)->type;
  4590. struct route_node *rn;
  4591. IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
  4592. if (IF_DEF_PARAMS (ifp)->type == old_type)
  4593. return CMD_SUCCESS;
  4594. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  4595. {
  4596. struct ospf_interface *oi = rn->info;
  4597. if (!oi)
  4598. continue;
  4599. oi->type = IF_DEF_PARAMS (ifp)->type;
  4600. if (oi->state > ISM_Down)
  4601. {
  4602. OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
  4603. OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
  4604. }
  4605. }
  4606. return CMD_SUCCESS;
  4607. }
  4608. ALIAS (no_ip_ospf_network,
  4609. no_ospf_network_cmd,
  4610. "no ospf network",
  4611. NO_STR
  4612. "OSPF interface commands\n"
  4613. "Network type\n")
  4614. DEFUN (ip_ospf_priority,
  4615. ip_ospf_priority_addr_cmd,
  4616. "ip ospf priority <0-255> A.B.C.D",
  4617. "IP Information\n"
  4618. "OSPF interface commands\n"
  4619. "Router priority\n"
  4620. "Priority\n"
  4621. "Address of interface")
  4622. {
  4623. struct interface *ifp = vty->index;
  4624. long priority;
  4625. struct route_node *rn;
  4626. struct in_addr addr;
  4627. int ret;
  4628. struct ospf_if_params *params;
  4629. params = IF_DEF_PARAMS (ifp);
  4630. priority = strtol (argv[0], NULL, 10);
  4631. /* Router Priority range is <0-255>. */
  4632. if (priority < 0 || priority > 255)
  4633. {
  4634. vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
  4635. return CMD_WARNING;
  4636. }
  4637. if (argc == 2)
  4638. {
  4639. ret = inet_aton(argv[1], &addr);
  4640. if (!ret)
  4641. {
  4642. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4643. VTY_NEWLINE);
  4644. return CMD_WARNING;
  4645. }
  4646. params = ospf_get_if_params (ifp, addr);
  4647. ospf_if_update_params (ifp, addr);
  4648. }
  4649. SET_IF_PARAM (params, priority);
  4650. params->priority = priority;
  4651. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  4652. {
  4653. struct ospf_interface *oi = rn->info;
  4654. if (!oi)
  4655. continue;
  4656. if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
  4657. {
  4658. PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
  4659. OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
  4660. }
  4661. }
  4662. return CMD_SUCCESS;
  4663. }
  4664. ALIAS (ip_ospf_priority,
  4665. ip_ospf_priority_cmd,
  4666. "ip ospf priority <0-255>",
  4667. "IP Information\n"
  4668. "OSPF interface commands\n"
  4669. "Router priority\n"
  4670. "Priority\n")
  4671. ALIAS (ip_ospf_priority,
  4672. ospf_priority_cmd,
  4673. "ospf priority <0-255>",
  4674. "OSPF interface commands\n"
  4675. "Router priority\n"
  4676. "Priority\n")
  4677. DEFUN (no_ip_ospf_priority,
  4678. no_ip_ospf_priority_addr_cmd,
  4679. "no ip ospf priority A.B.C.D",
  4680. NO_STR
  4681. "IP Information\n"
  4682. "OSPF interface commands\n"
  4683. "Router priority\n"
  4684. "Address of interface")
  4685. {
  4686. struct interface *ifp = vty->index;
  4687. struct route_node *rn;
  4688. struct in_addr addr;
  4689. int ret;
  4690. struct ospf_if_params *params;
  4691. ifp = vty->index;
  4692. params = IF_DEF_PARAMS (ifp);
  4693. if (argc == 1)
  4694. {
  4695. ret = inet_aton(argv[0], &addr);
  4696. if (!ret)
  4697. {
  4698. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4699. VTY_NEWLINE);
  4700. return CMD_WARNING;
  4701. }
  4702. params = ospf_lookup_if_params (ifp, addr);
  4703. if (params == NULL)
  4704. return CMD_SUCCESS;
  4705. }
  4706. UNSET_IF_PARAM (params, priority);
  4707. params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
  4708. if (params != IF_DEF_PARAMS (ifp))
  4709. {
  4710. ospf_free_if_params (ifp, addr);
  4711. ospf_if_update_params (ifp, addr);
  4712. }
  4713. for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
  4714. {
  4715. struct ospf_interface *oi = rn->info;
  4716. if (!oi)
  4717. continue;
  4718. if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
  4719. {
  4720. PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
  4721. OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
  4722. }
  4723. }
  4724. return CMD_SUCCESS;
  4725. }
  4726. ALIAS (no_ip_ospf_priority,
  4727. no_ip_ospf_priority_cmd,
  4728. "no ip ospf priority",
  4729. NO_STR
  4730. "IP Information\n"
  4731. "OSPF interface commands\n"
  4732. "Router priority\n")
  4733. ALIAS (no_ip_ospf_priority,
  4734. no_ospf_priority_cmd,
  4735. "no ospf priority",
  4736. NO_STR
  4737. "OSPF interface commands\n"
  4738. "Router priority\n")
  4739. DEFUN (ip_ospf_retransmit_interval,
  4740. ip_ospf_retransmit_interval_addr_cmd,
  4741. "ip ospf retransmit-interval <3-65535> A.B.C.D",
  4742. "IP Information\n"
  4743. "OSPF interface commands\n"
  4744. "Time between retransmitting lost link state advertisements\n"
  4745. "Seconds\n"
  4746. "Address of interface")
  4747. {
  4748. struct interface *ifp = vty->index;
  4749. u_int32_t seconds;
  4750. struct in_addr addr;
  4751. int ret;
  4752. struct ospf_if_params *params;
  4753. params = IF_DEF_PARAMS (ifp);
  4754. seconds = strtol (argv[0], NULL, 10);
  4755. /* Retransmit Interval range is <3-65535>. */
  4756. if (seconds < 3 || seconds > 65535)
  4757. {
  4758. vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
  4759. return CMD_WARNING;
  4760. }
  4761. if (argc == 2)
  4762. {
  4763. ret = inet_aton(argv[1], &addr);
  4764. if (!ret)
  4765. {
  4766. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4767. VTY_NEWLINE);
  4768. return CMD_WARNING;
  4769. }
  4770. params = ospf_get_if_params (ifp, addr);
  4771. ospf_if_update_params (ifp, addr);
  4772. }
  4773. SET_IF_PARAM (params, retransmit_interval);
  4774. params->retransmit_interval = seconds;
  4775. return CMD_SUCCESS;
  4776. }
  4777. ALIAS (ip_ospf_retransmit_interval,
  4778. ip_ospf_retransmit_interval_cmd,
  4779. "ip ospf retransmit-interval <3-65535>",
  4780. "IP Information\n"
  4781. "OSPF interface commands\n"
  4782. "Time between retransmitting lost link state advertisements\n"
  4783. "Seconds\n")
  4784. ALIAS (ip_ospf_retransmit_interval,
  4785. ospf_retransmit_interval_cmd,
  4786. "ospf retransmit-interval <3-65535>",
  4787. "OSPF interface commands\n"
  4788. "Time between retransmitting lost link state advertisements\n"
  4789. "Seconds\n")
  4790. DEFUN (no_ip_ospf_retransmit_interval,
  4791. no_ip_ospf_retransmit_interval_addr_cmd,
  4792. "no ip ospf retransmit-interval A.B.C.D",
  4793. NO_STR
  4794. "IP Information\n"
  4795. "OSPF interface commands\n"
  4796. "Time between retransmitting lost link state advertisements\n"
  4797. "Address of interface")
  4798. {
  4799. struct interface *ifp = vty->index;
  4800. struct in_addr addr;
  4801. int ret;
  4802. struct ospf_if_params *params;
  4803. ifp = vty->index;
  4804. params = IF_DEF_PARAMS (ifp);
  4805. if (argc == 1)
  4806. {
  4807. ret = inet_aton(argv[0], &addr);
  4808. if (!ret)
  4809. {
  4810. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4811. VTY_NEWLINE);
  4812. return CMD_WARNING;
  4813. }
  4814. params = ospf_lookup_if_params (ifp, addr);
  4815. if (params == NULL)
  4816. return CMD_SUCCESS;
  4817. }
  4818. UNSET_IF_PARAM (params, retransmit_interval);
  4819. params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
  4820. if (params != IF_DEF_PARAMS (ifp))
  4821. {
  4822. ospf_free_if_params (ifp, addr);
  4823. ospf_if_update_params (ifp, addr);
  4824. }
  4825. return CMD_SUCCESS;
  4826. }
  4827. ALIAS (no_ip_ospf_retransmit_interval,
  4828. no_ip_ospf_retransmit_interval_cmd,
  4829. "no ip ospf retransmit-interval",
  4830. NO_STR
  4831. "IP Information\n"
  4832. "OSPF interface commands\n"
  4833. "Time between retransmitting lost link state advertisements\n")
  4834. ALIAS (no_ip_ospf_retransmit_interval,
  4835. no_ospf_retransmit_interval_cmd,
  4836. "no ospf retransmit-interval",
  4837. NO_STR
  4838. "OSPF interface commands\n"
  4839. "Time between retransmitting lost link state advertisements\n")
  4840. DEFUN (ip_ospf_transmit_delay,
  4841. ip_ospf_transmit_delay_addr_cmd,
  4842. "ip ospf transmit-delay <1-65535> A.B.C.D",
  4843. "IP Information\n"
  4844. "OSPF interface commands\n"
  4845. "Link state transmit delay\n"
  4846. "Seconds\n"
  4847. "Address of interface")
  4848. {
  4849. struct interface *ifp = vty->index;
  4850. u_int32_t seconds;
  4851. struct in_addr addr;
  4852. int ret;
  4853. struct ospf_if_params *params;
  4854. params = IF_DEF_PARAMS (ifp);
  4855. seconds = strtol (argv[0], NULL, 10);
  4856. /* Transmit Delay range is <1-65535>. */
  4857. if (seconds < 1 || seconds > 65535)
  4858. {
  4859. vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
  4860. return CMD_WARNING;
  4861. }
  4862. if (argc == 2)
  4863. {
  4864. ret = inet_aton(argv[1], &addr);
  4865. if (!ret)
  4866. {
  4867. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4868. VTY_NEWLINE);
  4869. return CMD_WARNING;
  4870. }
  4871. params = ospf_get_if_params (ifp, addr);
  4872. ospf_if_update_params (ifp, addr);
  4873. }
  4874. SET_IF_PARAM (params, transmit_delay);
  4875. params->transmit_delay = seconds;
  4876. return CMD_SUCCESS;
  4877. }
  4878. ALIAS (ip_ospf_transmit_delay,
  4879. ip_ospf_transmit_delay_cmd,
  4880. "ip ospf transmit-delay <1-65535>",
  4881. "IP Information\n"
  4882. "OSPF interface commands\n"
  4883. "Link state transmit delay\n"
  4884. "Seconds\n")
  4885. ALIAS (ip_ospf_transmit_delay,
  4886. ospf_transmit_delay_cmd,
  4887. "ospf transmit-delay <1-65535>",
  4888. "OSPF interface commands\n"
  4889. "Link state transmit delay\n"
  4890. "Seconds\n")
  4891. DEFUN (no_ip_ospf_transmit_delay,
  4892. no_ip_ospf_transmit_delay_addr_cmd,
  4893. "no ip ospf transmit-delay A.B.C.D",
  4894. NO_STR
  4895. "IP Information\n"
  4896. "OSPF interface commands\n"
  4897. "Link state transmit delay\n"
  4898. "Address of interface")
  4899. {
  4900. struct interface *ifp = vty->index;
  4901. struct in_addr addr;
  4902. int ret;
  4903. struct ospf_if_params *params;
  4904. ifp = vty->index;
  4905. params = IF_DEF_PARAMS (ifp);
  4906. if (argc == 1)
  4907. {
  4908. ret = inet_aton(argv[0], &addr);
  4909. if (!ret)
  4910. {
  4911. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  4912. VTY_NEWLINE);
  4913. return CMD_WARNING;
  4914. }
  4915. params = ospf_lookup_if_params (ifp, addr);
  4916. if (params == NULL)
  4917. return CMD_SUCCESS;
  4918. }
  4919. UNSET_IF_PARAM (params, transmit_delay);
  4920. params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
  4921. if (params != IF_DEF_PARAMS (ifp))
  4922. {
  4923. ospf_free_if_params (ifp, addr);
  4924. ospf_if_update_params (ifp, addr);
  4925. }
  4926. return CMD_SUCCESS;
  4927. }
  4928. ALIAS (no_ip_ospf_transmit_delay,
  4929. no_ip_ospf_transmit_delay_cmd,
  4930. "no ip ospf transmit-delay",
  4931. NO_STR
  4932. "IP Information\n"
  4933. "OSPF interface commands\n"
  4934. "Link state transmit delay\n")
  4935. ALIAS (no_ip_ospf_transmit_delay,
  4936. no_ospf_transmit_delay_cmd,
  4937. "no ospf transmit-delay",
  4938. NO_STR
  4939. "OSPF interface commands\n"
  4940. "Link state transmit delay\n")
  4941. DEFUN (ospf_redistribute_source,
  4942. ospf_redistribute_source_cmd,
  4943. "redistribute " QUAGGA_REDIST_STR_OSPFD
  4944. " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
  4945. REDIST_STR
  4946. QUAGGA_REDIST_HELP_STR_OSPFD
  4947. "Metric for redistributed routes\n"
  4948. "OSPF default metric\n"
  4949. "OSPF exterior metric type for redistributed routes\n"
  4950. "Set OSPF External Type 1 metrics\n"
  4951. "Set OSPF External Type 2 metrics\n"
  4952. "Route map reference\n"
  4953. "Pointer to route-map entries\n")
  4954. {
  4955. struct ospf *ospf = vty->index;
  4956. int source;
  4957. int type = -1;
  4958. int metric = -1;
  4959. if (argc < 4)
  4960. return CMD_WARNING; /* should not happen */
  4961. /* Get distribute source. */
  4962. source = proto_redistnum(AFI_IP, argv[0]);
  4963. if (source < 0 || source == ZEBRA_ROUTE_OSPF)
  4964. return CMD_WARNING;
  4965. /* Get metric value. */
  4966. if (argv[1] != NULL)
  4967. if (!str2metric (argv[1], &metric))
  4968. return CMD_WARNING;
  4969. /* Get metric type. */
  4970. if (argv[2] != NULL)
  4971. if (!str2metric_type (argv[2], &type))
  4972. return CMD_WARNING;
  4973. if (argv[3] != NULL)
  4974. ospf_routemap_set (ospf, source, argv[3]);
  4975. else
  4976. ospf_routemap_unset (ospf, source);
  4977. return ospf_redistribute_set (ospf, source, type, metric);
  4978. }
  4979. DEFUN (no_ospf_redistribute_source,
  4980. no_ospf_redistribute_source_cmd,
  4981. "no redistribute " QUAGGA_REDIST_STR_OSPFD,
  4982. NO_STR
  4983. REDIST_STR
  4984. QUAGGA_REDIST_HELP_STR_OSPFD)
  4985. {
  4986. struct ospf *ospf = vty->index;
  4987. int source;
  4988. source = proto_redistnum(AFI_IP, argv[0]);
  4989. if (source < 0 || source == ZEBRA_ROUTE_OSPF)
  4990. return CMD_WARNING;
  4991. ospf_routemap_unset (ospf, source);
  4992. return ospf_redistribute_unset (ospf, source);
  4993. }
  4994. DEFUN (ospf_distribute_list_out,
  4995. ospf_distribute_list_out_cmd,
  4996. "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
  4997. "Filter networks in routing updates\n"
  4998. "Access-list name\n"
  4999. OUT_STR
  5000. QUAGGA_REDIST_HELP_STR_OSPFD)
  5001. {
  5002. struct ospf *ospf = vty->index;
  5003. int source;
  5004. /* Get distribute source. */
  5005. source = proto_redistnum(AFI_IP, argv[1]);
  5006. if (source < 0 || source == ZEBRA_ROUTE_OSPF)
  5007. return CMD_WARNING;
  5008. return ospf_distribute_list_out_set (ospf, source, argv[0]);
  5009. }
  5010. DEFUN (no_ospf_distribute_list_out,
  5011. no_ospf_distribute_list_out_cmd,
  5012. "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD,
  5013. NO_STR
  5014. "Filter networks in routing updates\n"
  5015. "Access-list name\n"
  5016. OUT_STR
  5017. QUAGGA_REDIST_HELP_STR_OSPFD)
  5018. {
  5019. struct ospf *ospf = vty->index;
  5020. int source;
  5021. source = proto_redistnum(AFI_IP, argv[1]);
  5022. if (source < 0 || source == ZEBRA_ROUTE_OSPF)
  5023. return CMD_WARNING;
  5024. return ospf_distribute_list_out_unset (ospf, source, argv[0]);
  5025. }
  5026. /* Default information originate. */
  5027. DEFUN (ospf_default_information_originate,
  5028. ospf_default_information_originate_cmd,
  5029. "default-information originate "
  5030. "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
  5031. "Control distribution of default information\n"
  5032. "Distribute a default route\n"
  5033. "Always advertise default route\n"
  5034. "OSPF default metric\n"
  5035. "OSPF metric\n"
  5036. "OSPF metric type for default routes\n"
  5037. "Set OSPF External Type 1 metrics\n"
  5038. "Set OSPF External Type 2 metrics\n"
  5039. "Route map reference\n"
  5040. "Pointer to route-map entries\n")
  5041. {
  5042. struct ospf *ospf = vty->index;
  5043. int default_originate = DEFAULT_ORIGINATE_ZEBRA;
  5044. int type = -1;
  5045. int metric = -1;
  5046. if (argc < 4)
  5047. return CMD_WARNING; /* this should not happen */
  5048. /* Check whether "always" was specified */
  5049. if (argv[0] != NULL)
  5050. default_originate = DEFAULT_ORIGINATE_ALWAYS;
  5051. /* Get metric value. */
  5052. if (argv[1] != NULL)
  5053. if (!str2metric (argv[1], &metric))
  5054. return CMD_WARNING;
  5055. /* Get metric type. */
  5056. if (argv[2] != NULL)
  5057. if (!str2metric_type (argv[2], &type))
  5058. return CMD_WARNING;
  5059. if (argv[3] != NULL)
  5060. ospf_routemap_set (ospf, DEFAULT_ROUTE, argv[3]);
  5061. else
  5062. ospf_routemap_unset (ospf, DEFAULT_ROUTE);
  5063. return ospf_redistribute_default_set (ospf, default_originate,
  5064. type, metric);
  5065. }
  5066. DEFUN (no_ospf_default_information_originate,
  5067. no_ospf_default_information_originate_cmd,
  5068. "no default-information originate",
  5069. NO_STR
  5070. "Control distribution of default information\n"
  5071. "Distribute a default route\n")
  5072. {
  5073. struct ospf *ospf = vty->index;
  5074. struct prefix_ipv4 p;
  5075. p.family = AF_INET;
  5076. p.prefix.s_addr = 0;
  5077. p.prefixlen = 0;
  5078. ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
  5079. if (EXTERNAL_INFO (DEFAULT_ROUTE)) {
  5080. ospf_external_info_delete (DEFAULT_ROUTE, p);
  5081. route_table_finish (EXTERNAL_INFO (DEFAULT_ROUTE));
  5082. EXTERNAL_INFO (DEFAULT_ROUTE) = NULL;
  5083. }
  5084. ospf_routemap_unset (ospf, DEFAULT_ROUTE);
  5085. return ospf_redistribute_default_unset (ospf);
  5086. }
  5087. DEFUN (ospf_default_metric,
  5088. ospf_default_metric_cmd,
  5089. "default-metric <0-16777214>",
  5090. "Set metric of redistributed routes\n"
  5091. "Default metric\n")
  5092. {
  5093. struct ospf *ospf = vty->index;
  5094. int metric = -1;
  5095. if (!str2metric (argv[0], &metric))
  5096. return CMD_WARNING;
  5097. ospf->default_metric = metric;
  5098. return CMD_SUCCESS;
  5099. }
  5100. DEFUN (no_ospf_default_metric,
  5101. no_ospf_default_metric_cmd,
  5102. "no default-metric",
  5103. NO_STR
  5104. "Set metric of redistributed routes\n")
  5105. {
  5106. struct ospf *ospf = vty->index;
  5107. ospf->default_metric = -1;
  5108. return CMD_SUCCESS;
  5109. }
  5110. ALIAS (no_ospf_default_metric,
  5111. no_ospf_default_metric_val_cmd,
  5112. "no default-metric <0-16777214>",
  5113. NO_STR
  5114. "Set metric of redistributed routes\n"
  5115. "Default metric\n")
  5116. DEFUN (ospf_distance,
  5117. ospf_distance_cmd,
  5118. "distance <1-255>",
  5119. "Define an administrative distance\n"
  5120. "OSPF Administrative distance\n")
  5121. {
  5122. struct ospf *ospf = vty->index;
  5123. ospf->distance_all = atoi (argv[0]);
  5124. return CMD_SUCCESS;
  5125. }
  5126. DEFUN (no_ospf_distance,
  5127. no_ospf_distance_cmd,
  5128. "no distance <1-255>",
  5129. NO_STR
  5130. "Define an administrative distance\n"
  5131. "OSPF Administrative distance\n")
  5132. {
  5133. struct ospf *ospf = vty->index;
  5134. ospf->distance_all = 0;
  5135. return CMD_SUCCESS;
  5136. }
  5137. DEFUN (no_ospf_distance_ospf,
  5138. no_ospf_distance_ospf_cmd,
  5139. "no distance ospf {intra-area|inter-area|external}",
  5140. NO_STR
  5141. "Define an administrative distance\n"
  5142. "OSPF Administrative distance\n"
  5143. "OSPF Distance\n"
  5144. "Intra-area routes\n"
  5145. "Inter-area routes\n"
  5146. "External routes\n")
  5147. {
  5148. struct ospf *ospf = vty->index;
  5149. if (argc < 3)
  5150. return CMD_WARNING;
  5151. if (argv[0] != NULL)
  5152. ospf->distance_intra = 0;
  5153. if (argv[1] != NULL)
  5154. ospf->distance_inter = 0;
  5155. if (argv[2] != NULL)
  5156. ospf->distance_external = 0;
  5157. if (argv[0] || argv[1] || argv[2])
  5158. return CMD_SUCCESS;
  5159. /* If no arguments are given, clear all distance information */
  5160. ospf->distance_intra = 0;
  5161. ospf->distance_inter = 0;
  5162. ospf->distance_external = 0;
  5163. return CMD_SUCCESS;
  5164. }
  5165. DEFUN (ospf_distance_ospf,
  5166. ospf_distance_ospf_cmd,
  5167. "distance ospf "
  5168. "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
  5169. "Define an administrative distance\n"
  5170. "OSPF Administrative distance\n"
  5171. "Intra-area routes\n"
  5172. "Distance for intra-area routes\n"
  5173. "Inter-area routes\n"
  5174. "Distance for inter-area routes\n"
  5175. "External routes\n"
  5176. "Distance for external routes\n")
  5177. {
  5178. struct ospf *ospf = vty->index;
  5179. if (argc < 3) /* should not happen */
  5180. return CMD_WARNING;
  5181. if (!argv[0] && !argv[1] && !argv[2])
  5182. {
  5183. vty_out(vty, "%% Command incomplete. (Arguments required)%s",
  5184. VTY_NEWLINE);
  5185. return CMD_WARNING;
  5186. }
  5187. if (argv[0] != NULL)
  5188. ospf->distance_intra = atoi(argv[0]);
  5189. if (argv[1] != NULL)
  5190. ospf->distance_inter = atoi(argv[1]);
  5191. if (argv[2] != NULL)
  5192. ospf->distance_external = atoi(argv[2]);
  5193. return CMD_SUCCESS;
  5194. }
  5195. DEFUN (ospf_distance_source,
  5196. ospf_distance_source_cmd,
  5197. "distance <1-255> A.B.C.D/M",
  5198. "Administrative distance\n"
  5199. "Distance value\n"
  5200. "IP source prefix\n")
  5201. {
  5202. struct ospf *ospf = vty->index;
  5203. ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
  5204. return CMD_SUCCESS;
  5205. }
  5206. DEFUN (no_ospf_distance_source,
  5207. no_ospf_distance_source_cmd,
  5208. "no distance <1-255> A.B.C.D/M",
  5209. NO_STR
  5210. "Administrative distance\n"
  5211. "Distance value\n"
  5212. "IP source prefix\n")
  5213. {
  5214. struct ospf *ospf = vty->index;
  5215. ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
  5216. return CMD_SUCCESS;
  5217. }
  5218. DEFUN (ospf_distance_source_access_list,
  5219. ospf_distance_source_access_list_cmd,
  5220. "distance <1-255> A.B.C.D/M WORD",
  5221. "Administrative distance\n"
  5222. "Distance value\n"
  5223. "IP source prefix\n"
  5224. "Access list name\n")
  5225. {
  5226. struct ospf *ospf = vty->index;
  5227. ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
  5228. return CMD_SUCCESS;
  5229. }
  5230. DEFUN (no_ospf_distance_source_access_list,
  5231. no_ospf_distance_source_access_list_cmd,
  5232. "no distance <1-255> A.B.C.D/M WORD",
  5233. NO_STR
  5234. "Administrative distance\n"
  5235. "Distance value\n"
  5236. "IP source prefix\n"
  5237. "Access list name\n")
  5238. {
  5239. struct ospf *ospf = vty->index;
  5240. ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
  5241. return CMD_SUCCESS;
  5242. }
  5243. DEFUN (ip_ospf_mtu_ignore,
  5244. ip_ospf_mtu_ignore_addr_cmd,
  5245. "ip ospf mtu-ignore A.B.C.D",
  5246. "IP Information\n"
  5247. "OSPF interface commands\n"
  5248. "Disable mtu mismatch detection\n"
  5249. "Address of interface")
  5250. {
  5251. struct interface *ifp = vty->index;
  5252. struct in_addr addr;
  5253. int ret;
  5254. struct ospf_if_params *params;
  5255. params = IF_DEF_PARAMS (ifp);
  5256. if (argc == 1)
  5257. {
  5258. ret = inet_aton(argv[0], &addr);
  5259. if (!ret)
  5260. {
  5261. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  5262. VTY_NEWLINE);
  5263. return CMD_WARNING;
  5264. }
  5265. params = ospf_get_if_params (ifp, addr);
  5266. ospf_if_update_params (ifp, addr);
  5267. }
  5268. params->mtu_ignore = 1;
  5269. if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
  5270. SET_IF_PARAM (params, mtu_ignore);
  5271. else
  5272. {
  5273. UNSET_IF_PARAM (params, mtu_ignore);
  5274. if (params != IF_DEF_PARAMS (ifp))
  5275. {
  5276. ospf_free_if_params (ifp, addr);
  5277. ospf_if_update_params (ifp, addr);
  5278. }
  5279. }
  5280. return CMD_SUCCESS;
  5281. }
  5282. ALIAS (ip_ospf_mtu_ignore,
  5283. ip_ospf_mtu_ignore_cmd,
  5284. "ip ospf mtu-ignore",
  5285. "IP Information\n"
  5286. "OSPF interface commands\n"
  5287. "Disable mtu mismatch detection\n")
  5288. DEFUN (no_ip_ospf_mtu_ignore,
  5289. no_ip_ospf_mtu_ignore_addr_cmd,
  5290. "no ip ospf mtu-ignore A.B.C.D",
  5291. "IP Information\n"
  5292. "OSPF interface commands\n"
  5293. "Disable mtu mismatch detection\n"
  5294. "Address of interface")
  5295. {
  5296. struct interface *ifp = vty->index;
  5297. struct in_addr addr;
  5298. int ret;
  5299. struct ospf_if_params *params;
  5300. params = IF_DEF_PARAMS (ifp);
  5301. if (argc == 1)
  5302. {
  5303. ret = inet_aton(argv[0], &addr);
  5304. if (!ret)
  5305. {
  5306. vty_out (vty, "Please specify interface address by A.B.C.D%s",
  5307. VTY_NEWLINE);
  5308. return CMD_WARNING;
  5309. }
  5310. params = ospf_get_if_params (ifp, addr);
  5311. ospf_if_update_params (ifp, addr);
  5312. }
  5313. params->mtu_ignore = 0;
  5314. if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
  5315. SET_IF_PARAM (params, mtu_ignore);
  5316. else
  5317. {
  5318. UNSET_IF_PARAM (params, mtu_ignore);
  5319. if (params != IF_DEF_PARAMS (ifp))
  5320. {
  5321. ospf_free_if_params (ifp, addr);
  5322. ospf_if_update_params (ifp, addr);
  5323. }
  5324. }
  5325. return CMD_SUCCESS;
  5326. }
  5327. ALIAS (no_ip_ospf_mtu_ignore,
  5328. no_ip_ospf_mtu_ignore_cmd,
  5329. "no ip ospf mtu-ignore",
  5330. "IP Information\n"
  5331. "OSPF interface commands\n"
  5332. "Disable mtu mismatch detection\n")
  5333. DEFUN (ospf_max_metric_router_lsa_admin,
  5334. ospf_max_metric_router_lsa_admin_cmd,
  5335. "max-metric router-lsa administrative",
  5336. "OSPF maximum / infinite-distance metric\n"
  5337. "Advertise own Router-LSA with infinite distance (stub router)\n"
  5338. "Administratively applied, for an indefinite period\n")
  5339. {
  5340. struct listnode *ln;
  5341. struct ospf_area *area;
  5342. struct ospf *ospf = vty->index;
  5343. for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
  5344. {
  5345. SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
  5346. if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
  5347. ospf_router_lsa_update_area (area);
  5348. }
  5349. /* Allows for areas configured later to get the property */
  5350. ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
  5351. return CMD_SUCCESS;
  5352. }
  5353. DEFUN (no_ospf_max_metric_router_lsa_admin,
  5354. no_ospf_max_metric_router_lsa_admin_cmd,
  5355. "no max-metric router-lsa administrative",
  5356. NO_STR
  5357. "OSPF maximum / infinite-distance metric\n"
  5358. "Advertise own Router-LSA with infinite distance (stub router)\n"
  5359. "Administratively applied, for an indefinite period\n")
  5360. {
  5361. struct listnode *ln;
  5362. struct ospf_area *area;
  5363. struct ospf *ospf = vty->index;
  5364. for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
  5365. {
  5366. UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
  5367. /* Don't trample on the start-up stub timer */
  5368. if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
  5369. && !area->t_stub_router)
  5370. {
  5371. UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
  5372. ospf_router_lsa_update_area (area);
  5373. }
  5374. }
  5375. ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
  5376. return CMD_SUCCESS;
  5377. }
  5378. DEFUN (ospf_max_metric_router_lsa_startup,
  5379. ospf_max_metric_router_lsa_startup_cmd,
  5380. "max-metric router-lsa on-startup <5-86400>",
  5381. "OSPF maximum / infinite-distance metric\n"
  5382. "Advertise own Router-LSA with infinite distance (stub router)\n"
  5383. "Automatically advertise stub Router-LSA on startup of OSPF\n"
  5384. "Time (seconds) to advertise self as stub-router\n")
  5385. {
  5386. unsigned int seconds;
  5387. struct ospf *ospf = vty->index;
  5388. if (argc != 1)
  5389. {
  5390. vty_out (vty, "%% Must supply stub-router period");
  5391. return CMD_WARNING;
  5392. }
  5393. VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
  5394. ospf->stub_router_startup_time = seconds;
  5395. return CMD_SUCCESS;
  5396. }
  5397. DEFUN (no_ospf_max_metric_router_lsa_startup,
  5398. no_ospf_max_metric_router_lsa_startup_cmd,
  5399. "no max-metric router-lsa on-startup",
  5400. NO_STR
  5401. "OSPF maximum / infinite-distance metric\n"
  5402. "Advertise own Router-LSA with infinite distance (stub router)\n"
  5403. "Automatically advertise stub Router-LSA on startup of OSPF\n")
  5404. {
  5405. struct listnode *ln;
  5406. struct ospf_area *area;
  5407. struct ospf *ospf = vty->index;
  5408. ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
  5409. for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
  5410. {
  5411. SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
  5412. OSPF_TIMER_OFF (area->t_stub_router);
  5413. /* Don't trample on admin stub routed */
  5414. if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
  5415. {
  5416. UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
  5417. ospf_router_lsa_update_area (area);
  5418. }
  5419. }
  5420. return CMD_SUCCESS;
  5421. }
  5422. DEFUN (ospf_max_metric_router_lsa_shutdown,
  5423. ospf_max_metric_router_lsa_shutdown_cmd,
  5424. "max-metric router-lsa on-shutdown <5-86400>",
  5425. "OSPF maximum / infinite-distance metric\n"
  5426. "Advertise own Router-LSA with infinite distance (stub router)\n"
  5427. "Advertise stub-router prior to full shutdown of OSPF\n"
  5428. "Time (seconds) to wait till full shutdown\n")
  5429. {
  5430. unsigned int seconds;
  5431. struct ospf *ospf = vty->index;
  5432. if (argc != 1)
  5433. {
  5434. vty_out (vty, "%% Must supply stub-router shutdown period");
  5435. return CMD_WARNING;
  5436. }
  5437. VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
  5438. ospf->stub_router_shutdown_time = seconds;
  5439. return CMD_SUCCESS;
  5440. }
  5441. DEFUN (no_ospf_max_metric_router_lsa_shutdown,
  5442. no_ospf_max_metric_router_lsa_shutdown_cmd,
  5443. "no max-metric router-lsa on-shutdown",
  5444. NO_STR
  5445. "OSPF maximum / infinite-distance metric\n"
  5446. "Advertise own Router-LSA with infinite distance (stub router)\n"
  5447. "Advertise stub-router prior to full shutdown of OSPF\n")
  5448. {
  5449. struct ospf *ospf = vty->index;
  5450. ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
  5451. return CMD_SUCCESS;
  5452. }
  5453. static void
  5454. config_write_stub_router (struct vty *vty, struct ospf *ospf)
  5455. {
  5456. struct listnode *ln;
  5457. struct ospf_area *area;
  5458. if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
  5459. vty_out (vty, " max-metric router-lsa on-startup %u%s",
  5460. ospf->stub_router_startup_time, VTY_NEWLINE);
  5461. if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
  5462. vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
  5463. ospf->stub_router_shutdown_time, VTY_NEWLINE);
  5464. for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
  5465. {
  5466. if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
  5467. {
  5468. vty_out (vty, " max-metric router-lsa administrative%s",
  5469. VTY_NEWLINE);
  5470. break;
  5471. }
  5472. }
  5473. return;
  5474. }
  5475. static void
  5476. show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
  5477. {
  5478. struct route_node *rn;
  5479. struct ospf_route *or;
  5480. struct listnode *pnode, *pnnode;
  5481. struct ospf_path *path;
  5482. vty_out (vty, "============ OSPF network routing table ============%s",
  5483. VTY_NEWLINE);
  5484. for (rn = route_top (rt); rn; rn = route_next (rn))
  5485. if ((or = rn->info) != NULL)
  5486. {
  5487. char buf1[19];
  5488. snprintf (buf1, 19, "%s/%d",
  5489. inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
  5490. switch (or->path_type)
  5491. {
  5492. case OSPF_PATH_INTER_AREA:
  5493. if (or->type == OSPF_DESTINATION_NETWORK)
  5494. vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
  5495. inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
  5496. else if (or->type == OSPF_DESTINATION_DISCARD)
  5497. vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
  5498. break;
  5499. case OSPF_PATH_INTRA_AREA:
  5500. vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
  5501. inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
  5502. break;
  5503. default:
  5504. break;
  5505. }
  5506. if (or->type == OSPF_DESTINATION_NETWORK)
  5507. for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
  5508. {
  5509. if (if_lookup_by_index(path->ifindex))
  5510. {
  5511. if (path->nexthop.s_addr == 0)
  5512. vty_out (vty, "%24s directly attached to %s%s",
  5513. "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
  5514. else
  5515. vty_out (vty, "%24s via %s, %s%s", "",
  5516. inet_ntoa (path->nexthop),
  5517. ifindex2ifname (path->ifindex), VTY_NEWLINE);
  5518. }
  5519. }
  5520. }
  5521. vty_out (vty, "%s", VTY_NEWLINE);
  5522. }
  5523. static void
  5524. show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
  5525. {
  5526. struct route_node *rn;
  5527. struct ospf_route *or;
  5528. struct listnode *pnode;
  5529. struct listnode *node;
  5530. struct ospf_path *path;
  5531. vty_out (vty, "============ OSPF router routing table =============%s",
  5532. VTY_NEWLINE);
  5533. for (rn = route_top (rtrs); rn; rn = route_next (rn))
  5534. if (rn->info)
  5535. {
  5536. int flag = 0;
  5537. vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
  5538. for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
  5539. {
  5540. if (flag++)
  5541. vty_out (vty, "%24s", "");
  5542. /* Show path. */
  5543. vty_out (vty, "%s [%d] area: %s",
  5544. (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
  5545. or->cost, inet_ntoa (or->u.std.area_id));
  5546. /* Show flags. */
  5547. vty_out (vty, "%s%s%s",
  5548. (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
  5549. (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
  5550. VTY_NEWLINE);
  5551. for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
  5552. {
  5553. if (if_lookup_by_index(path->ifindex))
  5554. {
  5555. if (path->nexthop.s_addr == 0)
  5556. vty_out (vty, "%24s directly attached to %s%s",
  5557. "", ifindex2ifname (path->ifindex),
  5558. VTY_NEWLINE);
  5559. else
  5560. vty_out (vty, "%24s via %s, %s%s", "",
  5561. inet_ntoa (path->nexthop),
  5562. ifindex2ifname (path->ifindex),
  5563. VTY_NEWLINE);
  5564. }
  5565. }
  5566. }
  5567. }
  5568. vty_out (vty, "%s", VTY_NEWLINE);
  5569. }
  5570. static void
  5571. show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
  5572. {
  5573. struct route_node *rn;
  5574. struct ospf_route *er;
  5575. struct listnode *pnode, *pnnode;
  5576. struct ospf_path *path;
  5577. vty_out (vty, "============ OSPF external routing table ===========%s",
  5578. VTY_NEWLINE);
  5579. for (rn = route_top (rt); rn; rn = route_next (rn))
  5580. if ((er = rn->info) != NULL)
  5581. {
  5582. char buf1[19];
  5583. snprintf (buf1, 19, "%s/%d",
  5584. inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
  5585. switch (er->path_type)
  5586. {
  5587. case OSPF_PATH_TYPE1_EXTERNAL:
  5588. vty_out (vty, "N E1 %-18s [%d] tag: %u%s", buf1,
  5589. er->cost, er->u.ext.tag, VTY_NEWLINE);
  5590. break;
  5591. case OSPF_PATH_TYPE2_EXTERNAL:
  5592. vty_out (vty, "N E2 %-18s [%d/%d] tag: %u%s", buf1, er->cost,
  5593. er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
  5594. break;
  5595. }
  5596. for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
  5597. {
  5598. if (if_lookup_by_index(path->ifindex))
  5599. {
  5600. if (path->nexthop.s_addr == 0)
  5601. vty_out (vty, "%24s directly attached to %s%s",
  5602. "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
  5603. else
  5604. vty_out (vty, "%24s via %s, %s%s", "",
  5605. inet_ntoa (path->nexthop),
  5606. ifindex2ifname (path->ifindex),
  5607. VTY_NEWLINE);
  5608. }
  5609. }
  5610. }
  5611. vty_out (vty, "%s", VTY_NEWLINE);
  5612. }
  5613. DEFUN (show_ip_ospf_border_routers,
  5614. show_ip_ospf_border_routers_cmd,
  5615. "show ip ospf border-routers",
  5616. SHOW_STR
  5617. IP_STR
  5618. "show all the ABR's and ASBR's\n"
  5619. "for this area\n")
  5620. {
  5621. struct ospf *ospf;
  5622. if ((ospf = ospf_lookup ()) == NULL)
  5623. {
  5624. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  5625. return CMD_SUCCESS;
  5626. }
  5627. if (ospf->new_table == NULL)
  5628. {
  5629. vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
  5630. return CMD_SUCCESS;
  5631. }
  5632. /* Show Network routes.
  5633. show_ip_ospf_route_network (vty, ospf->new_table); */
  5634. /* Show Router routes. */
  5635. show_ip_ospf_route_router (vty, ospf->new_rtrs);
  5636. return CMD_SUCCESS;
  5637. }
  5638. DEFUN (show_ip_ospf_route,
  5639. show_ip_ospf_route_cmd,
  5640. "show ip ospf route",
  5641. SHOW_STR
  5642. IP_STR
  5643. "OSPF information\n"
  5644. "OSPF routing table\n")
  5645. {
  5646. struct ospf *ospf;
  5647. if ((ospf = ospf_lookup ()) == NULL)
  5648. {
  5649. vty_out (vty, " OSPF Routing Process not enabled%s", VTY_NEWLINE);
  5650. return CMD_SUCCESS;
  5651. }
  5652. if (ospf->new_table == NULL)
  5653. {
  5654. vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
  5655. return CMD_SUCCESS;
  5656. }
  5657. /* Show Network routes. */
  5658. show_ip_ospf_route_network (vty, ospf->new_table);
  5659. /* Show Router routes. */
  5660. show_ip_ospf_route_router (vty, ospf->new_rtrs);
  5661. /* Show AS External routes. */
  5662. show_ip_ospf_route_external (vty, ospf->old_external_route);
  5663. return CMD_SUCCESS;
  5664. }
  5665. const char *ospf_abr_type_str[] =
  5666. {
  5667. "unknown",
  5668. "standard",
  5669. "ibm",
  5670. "cisco",
  5671. "shortcut"
  5672. };
  5673. const char *ospf_shortcut_mode_str[] =
  5674. {
  5675. "default",
  5676. "enable",
  5677. "disable"
  5678. };
  5679. static void
  5680. area_id2str (char *buf, int length, struct ospf_area *area)
  5681. {
  5682. memset (buf, 0, length);
  5683. if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
  5684. strncpy (buf, inet_ntoa (area->area_id), length);
  5685. else
  5686. sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
  5687. }
  5688. const char *ospf_int_type_str[] =
  5689. {
  5690. "unknown", /* should never be used. */
  5691. "point-to-point",
  5692. "broadcast",
  5693. "non-broadcast",
  5694. "point-to-multipoint",
  5695. "virtual-link", /* should never be used. */
  5696. "loopback"
  5697. };
  5698. /* Configuration write function for ospfd. */
  5699. static int
  5700. config_write_interface (struct vty *vty)
  5701. {
  5702. struct listnode *n1, *n2;
  5703. struct interface *ifp;
  5704. struct crypt_key *ck;
  5705. int write = 0;
  5706. struct route_node *rn = NULL;
  5707. struct ospf_if_params *params;
  5708. for (ALL_LIST_ELEMENTS_RO (iflist, n1, ifp))
  5709. {
  5710. if (memcmp (ifp->name, "VLINK", 5) == 0)
  5711. continue;
  5712. vty_out (vty, "!%s", VTY_NEWLINE);
  5713. vty_out (vty, "interface %s%s", ifp->name,
  5714. VTY_NEWLINE);
  5715. if (ifp->desc)
  5716. vty_out (vty, " description %s%s", ifp->desc,
  5717. VTY_NEWLINE);
  5718. write++;
  5719. params = IF_DEF_PARAMS (ifp);
  5720. do {
  5721. /* Interface Network print. */
  5722. if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
  5723. params->type != OSPF_IFTYPE_LOOPBACK)
  5724. {
  5725. if (params->type != ospf_default_iftype(ifp))
  5726. {
  5727. vty_out (vty, " ip ospf network %s",
  5728. ospf_int_type_str[params->type]);
  5729. if (params != IF_DEF_PARAMS (ifp))
  5730. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5731. vty_out (vty, "%s", VTY_NEWLINE);
  5732. }
  5733. }
  5734. /* OSPF interface authentication print */
  5735. if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
  5736. params->auth_type != OSPF_AUTH_NOTSET)
  5737. {
  5738. const char *auth_str;
  5739. /* Translation tables are not that much help here due to syntax
  5740. of the simple option */
  5741. switch (params->auth_type)
  5742. {
  5743. case OSPF_AUTH_NULL:
  5744. auth_str = " null";
  5745. break;
  5746. case OSPF_AUTH_SIMPLE:
  5747. auth_str = "";
  5748. break;
  5749. case OSPF_AUTH_CRYPTOGRAPHIC:
  5750. auth_str = " message-digest";
  5751. break;
  5752. default:
  5753. auth_str = "";
  5754. break;
  5755. }
  5756. vty_out (vty, " ip ospf authentication%s", auth_str);
  5757. if (params != IF_DEF_PARAMS (ifp))
  5758. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5759. vty_out (vty, "%s", VTY_NEWLINE);
  5760. }
  5761. /* Simple Authentication Password print. */
  5762. if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
  5763. params->auth_simple[0] != '\0')
  5764. {
  5765. vty_out (vty, " ip ospf authentication-key %s",
  5766. params->auth_simple);
  5767. if (params != IF_DEF_PARAMS (ifp))
  5768. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5769. vty_out (vty, "%s", VTY_NEWLINE);
  5770. }
  5771. /* Cryptographic Authentication Key print. */
  5772. for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
  5773. {
  5774. vty_out (vty, " ip ospf message-digest-key %d md5 %s",
  5775. ck->key_id, ck->auth_key);
  5776. if (params != IF_DEF_PARAMS (ifp))
  5777. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5778. vty_out (vty, "%s", VTY_NEWLINE);
  5779. }
  5780. /* Interface Output Cost print. */
  5781. if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
  5782. {
  5783. vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
  5784. if (params != IF_DEF_PARAMS (ifp))
  5785. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5786. vty_out (vty, "%s", VTY_NEWLINE);
  5787. }
  5788. /* Hello Interval print. */
  5789. if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
  5790. params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
  5791. {
  5792. vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
  5793. if (params != IF_DEF_PARAMS (ifp))
  5794. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5795. vty_out (vty, "%s", VTY_NEWLINE);
  5796. }
  5797. /* Router Dead Interval print. */
  5798. if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
  5799. params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
  5800. {
  5801. vty_out (vty, " ip ospf dead-interval ");
  5802. /* fast hello ? */
  5803. if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
  5804. vty_out (vty, "minimal hello-multiplier %d",
  5805. params->fast_hello);
  5806. else
  5807. vty_out (vty, "%u", params->v_wait);
  5808. if (params != IF_DEF_PARAMS (ifp))
  5809. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5810. vty_out (vty, "%s", VTY_NEWLINE);
  5811. }
  5812. /* Router Priority print. */
  5813. if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
  5814. params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
  5815. {
  5816. vty_out (vty, " ip ospf priority %u", params->priority);
  5817. if (params != IF_DEF_PARAMS (ifp))
  5818. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5819. vty_out (vty, "%s", VTY_NEWLINE);
  5820. }
  5821. /* Retransmit Interval print. */
  5822. if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
  5823. params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
  5824. {
  5825. vty_out (vty, " ip ospf retransmit-interval %u",
  5826. params->retransmit_interval);
  5827. if (params != IF_DEF_PARAMS (ifp))
  5828. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5829. vty_out (vty, "%s", VTY_NEWLINE);
  5830. }
  5831. /* Transmit Delay print. */
  5832. if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
  5833. params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
  5834. {
  5835. vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
  5836. if (params != IF_DEF_PARAMS (ifp))
  5837. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5838. vty_out (vty, "%s", VTY_NEWLINE);
  5839. }
  5840. /* MTU ignore print. */
  5841. if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
  5842. params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
  5843. {
  5844. if (params->mtu_ignore == 0)
  5845. vty_out (vty, " no ip ospf mtu-ignore");
  5846. else
  5847. vty_out (vty, " ip ospf mtu-ignore");
  5848. if (params != IF_DEF_PARAMS (ifp))
  5849. vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
  5850. vty_out (vty, "%s", VTY_NEWLINE);
  5851. }
  5852. while (1)
  5853. {
  5854. if (rn == NULL)
  5855. rn = route_top (IF_OIFS_PARAMS (ifp));
  5856. else
  5857. rn = route_next (rn);
  5858. if (rn == NULL)
  5859. break;
  5860. params = rn->info;
  5861. if (params != NULL)
  5862. break;
  5863. }
  5864. } while (rn);
  5865. #ifdef HAVE_OPAQUE_LSA
  5866. ospf_opaque_config_write_if (vty, ifp);
  5867. #endif /* HAVE_OPAQUE_LSA */
  5868. }
  5869. return write;
  5870. }
  5871. static int
  5872. config_write_network_area (struct vty *vty, struct ospf *ospf)
  5873. {
  5874. struct route_node *rn;
  5875. u_char buf[INET_ADDRSTRLEN];
  5876. /* `network area' print. */
  5877. for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
  5878. if (rn->info)
  5879. {
  5880. struct ospf_network *n = rn->info;
  5881. memset (buf, 0, INET_ADDRSTRLEN);
  5882. /* Create Area ID string by specified Area ID format. */
  5883. if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
  5884. strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
  5885. else
  5886. sprintf ((char *) buf, "%lu",
  5887. (unsigned long int) ntohl (n->area_id.s_addr));
  5888. /* Network print. */
  5889. vty_out (vty, " network %s/%d area %s%s",
  5890. inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
  5891. buf, VTY_NEWLINE);
  5892. }
  5893. return 0;
  5894. }
  5895. static int
  5896. config_write_ospf_area (struct vty *vty, struct ospf *ospf)
  5897. {
  5898. struct listnode *node;
  5899. struct ospf_area *area;
  5900. u_char buf[INET_ADDRSTRLEN];
  5901. /* Area configuration print. */
  5902. for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
  5903. {
  5904. struct route_node *rn1;
  5905. area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
  5906. if (area->auth_type != OSPF_AUTH_NULL)
  5907. {
  5908. if (area->auth_type == OSPF_AUTH_SIMPLE)
  5909. vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
  5910. else
  5911. vty_out (vty, " area %s authentication message-digest%s",
  5912. buf, VTY_NEWLINE);
  5913. }
  5914. if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
  5915. vty_out (vty, " area %s shortcut %s%s", buf,
  5916. ospf_shortcut_mode_str[area->shortcut_configured],
  5917. VTY_NEWLINE);
  5918. if ((area->external_routing == OSPF_AREA_STUB)
  5919. || (area->external_routing == OSPF_AREA_NSSA)
  5920. )
  5921. {
  5922. if (area->external_routing == OSPF_AREA_STUB)
  5923. vty_out (vty, " area %s stub", buf);
  5924. else if (area->external_routing == OSPF_AREA_NSSA)
  5925. {
  5926. vty_out (vty, " area %s nssa", buf);
  5927. switch (area->NSSATranslatorRole)
  5928. {
  5929. case OSPF_NSSA_ROLE_NEVER:
  5930. vty_out (vty, " translate-never");
  5931. break;
  5932. case OSPF_NSSA_ROLE_ALWAYS:
  5933. vty_out (vty, " translate-always");
  5934. break;
  5935. case OSPF_NSSA_ROLE_CANDIDATE:
  5936. default:
  5937. vty_out (vty, " translate-candidate");
  5938. }
  5939. }
  5940. if (area->no_summary)
  5941. vty_out (vty, " no-summary");
  5942. vty_out (vty, "%s", VTY_NEWLINE);
  5943. if (area->default_cost != 1)
  5944. vty_out (vty, " area %s default-cost %d%s", buf,
  5945. area->default_cost, VTY_NEWLINE);
  5946. }
  5947. for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
  5948. if (rn1->info)
  5949. {
  5950. struct ospf_area_range *range = rn1->info;
  5951. vty_out (vty, " area %s range %s/%d", buf,
  5952. inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
  5953. if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
  5954. vty_out (vty, " cost %d", range->cost_config);
  5955. if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
  5956. vty_out (vty, " not-advertise");
  5957. if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
  5958. vty_out (vty, " substitute %s/%d",
  5959. inet_ntoa (range->subst_addr), range->subst_masklen);
  5960. vty_out (vty, "%s", VTY_NEWLINE);
  5961. }
  5962. if (EXPORT_NAME (area))
  5963. vty_out (vty, " area %s export-list %s%s", buf,
  5964. EXPORT_NAME (area), VTY_NEWLINE);
  5965. if (IMPORT_NAME (area))
  5966. vty_out (vty, " area %s import-list %s%s", buf,
  5967. IMPORT_NAME (area), VTY_NEWLINE);
  5968. if (PREFIX_NAME_IN (area))
  5969. vty_out (vty, " area %s filter-list prefix %s in%s", buf,
  5970. PREFIX_NAME_IN (area), VTY_NEWLINE);
  5971. if (PREFIX_NAME_OUT (area))
  5972. vty_out (vty, " area %s filter-list prefix %s out%s", buf,
  5973. PREFIX_NAME_OUT (area), VTY_NEWLINE);
  5974. }
  5975. return 0;
  5976. }
  5977. static int
  5978. config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
  5979. {
  5980. struct ospf_nbr_nbma *nbr_nbma;
  5981. struct route_node *rn;
  5982. /* Static Neighbor configuration print. */
  5983. for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
  5984. if ((nbr_nbma = rn->info))
  5985. {
  5986. vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
  5987. if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
  5988. vty_out (vty, " priority %d", nbr_nbma->priority);
  5989. if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
  5990. vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
  5991. vty_out (vty, "%s", VTY_NEWLINE);
  5992. }
  5993. return 0;
  5994. }
  5995. static int
  5996. config_write_virtual_link (struct vty *vty, struct ospf *ospf)
  5997. {
  5998. struct listnode *node;
  5999. struct ospf_vl_data *vl_data;
  6000. u_char buf[INET_ADDRSTRLEN];
  6001. /* Virtual-Link print */
  6002. for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
  6003. {
  6004. struct listnode *n2;
  6005. struct crypt_key *ck;
  6006. struct ospf_interface *oi;
  6007. if (vl_data != NULL)
  6008. {
  6009. memset (buf, 0, INET_ADDRSTRLEN);
  6010. if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
  6011. strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
  6012. else
  6013. sprintf ((char *) buf, "%lu",
  6014. (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
  6015. oi = vl_data->vl_oi;
  6016. /* timers */
  6017. if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
  6018. OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
  6019. OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
  6020. OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
  6021. vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
  6022. buf,
  6023. inet_ntoa (vl_data->vl_peer),
  6024. OSPF_IF_PARAM (oi, v_hello),
  6025. OSPF_IF_PARAM (oi, retransmit_interval),
  6026. OSPF_IF_PARAM (oi, transmit_delay),
  6027. OSPF_IF_PARAM (oi, v_wait),
  6028. VTY_NEWLINE);
  6029. else
  6030. vty_out (vty, " area %s virtual-link %s%s", buf,
  6031. inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
  6032. /* Auth key */
  6033. if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
  6034. vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
  6035. buf,
  6036. inet_ntoa (vl_data->vl_peer),
  6037. IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
  6038. VTY_NEWLINE);
  6039. /* md5 keys */
  6040. for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
  6041. n2, ck))
  6042. vty_out (vty, " area %s virtual-link %s"
  6043. " message-digest-key %d md5 %s%s",
  6044. buf,
  6045. inet_ntoa (vl_data->vl_peer),
  6046. ck->key_id, ck->auth_key, VTY_NEWLINE);
  6047. }
  6048. }
  6049. return 0;
  6050. }
  6051. static int
  6052. config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
  6053. {
  6054. int type;
  6055. /* redistribute print. */
  6056. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  6057. if (type != zclient->redist_default && zclient->redist[type])
  6058. {
  6059. vty_out (vty, " redistribute %s", zebra_route_string(type));
  6060. if (ospf->dmetric[type].value >= 0)
  6061. vty_out (vty, " metric %d", ospf->dmetric[type].value);
  6062. if (ospf->dmetric[type].type == EXTERNAL_METRIC_TYPE_1)
  6063. vty_out (vty, " metric-type 1");
  6064. if (ROUTEMAP_NAME (ospf, type))
  6065. vty_out (vty, " route-map %s", ROUTEMAP_NAME (ospf, type));
  6066. vty_out (vty, "%s", VTY_NEWLINE);
  6067. }
  6068. return 0;
  6069. }
  6070. static int
  6071. config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
  6072. {
  6073. if (ospf->default_metric != -1)
  6074. vty_out (vty, " default-metric %d%s", ospf->default_metric,
  6075. VTY_NEWLINE);
  6076. return 0;
  6077. }
  6078. static int
  6079. config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
  6080. {
  6081. int type;
  6082. if (ospf)
  6083. {
  6084. /* distribute-list print. */
  6085. for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
  6086. if (DISTRIBUTE_NAME (ospf, type))
  6087. vty_out (vty, " distribute-list %s out %s%s",
  6088. DISTRIBUTE_NAME (ospf, type),
  6089. zebra_route_string(type), VTY_NEWLINE);
  6090. /* default-information print. */
  6091. if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
  6092. {
  6093. vty_out (vty, " default-information originate");
  6094. if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
  6095. vty_out (vty, " always");
  6096. if (ospf->dmetric[DEFAULT_ROUTE].value >= 0)
  6097. vty_out (vty, " metric %d",
  6098. ospf->dmetric[DEFAULT_ROUTE].value);
  6099. if (ospf->dmetric[DEFAULT_ROUTE].type == EXTERNAL_METRIC_TYPE_1)
  6100. vty_out (vty, " metric-type 1");
  6101. if (ROUTEMAP_NAME (ospf, DEFAULT_ROUTE))
  6102. vty_out (vty, " route-map %s",
  6103. ROUTEMAP_NAME (ospf, DEFAULT_ROUTE));
  6104. vty_out (vty, "%s", VTY_NEWLINE);
  6105. }
  6106. }
  6107. return 0;
  6108. }
  6109. static int
  6110. config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
  6111. {
  6112. struct route_node *rn;
  6113. struct ospf_distance *odistance;
  6114. if (ospf->distance_all)
  6115. vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
  6116. if (ospf->distance_intra
  6117. || ospf->distance_inter
  6118. || ospf->distance_external)
  6119. {
  6120. vty_out (vty, " distance ospf");
  6121. if (ospf->distance_intra)
  6122. vty_out (vty, " intra-area %d", ospf->distance_intra);
  6123. if (ospf->distance_inter)
  6124. vty_out (vty, " inter-area %d", ospf->distance_inter);
  6125. if (ospf->distance_external)
  6126. vty_out (vty, " external %d", ospf->distance_external);
  6127. vty_out (vty, "%s", VTY_NEWLINE);
  6128. }
  6129. for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
  6130. if ((odistance = rn->info) != NULL)
  6131. {
  6132. vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
  6133. inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
  6134. odistance->access_list ? odistance->access_list : "",
  6135. VTY_NEWLINE);
  6136. }
  6137. return 0;
  6138. }
  6139. /* OSPF configuration write function. */
  6140. static int
  6141. ospf_config_write (struct vty *vty)
  6142. {
  6143. struct ospf *ospf;
  6144. struct interface *ifp;
  6145. struct ospf_interface *oi;
  6146. struct listnode *node;
  6147. int write = 0;
  6148. ospf = ospf_lookup ();
  6149. if (ospf != NULL)
  6150. {
  6151. /* `router ospf' print. */
  6152. vty_out (vty, "router ospf%s", VTY_NEWLINE);
  6153. write++;
  6154. if (!ospf->networks)
  6155. return write;
  6156. /* Router ID print. */
  6157. if (ospf->router_id_static.s_addr != 0)
  6158. vty_out (vty, " ospf router-id %s%s",
  6159. inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
  6160. /* ABR type print. */
  6161. if (ospf->abr_type != OSPF_ABR_DEFAULT)
  6162. vty_out (vty, " ospf abr-type %s%s",
  6163. ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
  6164. /* log-adjacency-changes flag print. */
  6165. if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
  6166. {
  6167. vty_out(vty, " log-adjacency-changes");
  6168. if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
  6169. vty_out(vty, " detail");
  6170. vty_out(vty, "%s", VTY_NEWLINE);
  6171. }
  6172. /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
  6173. if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
  6174. vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
  6175. /* auto-cost reference-bandwidth configuration. */
  6176. if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
  6177. {
  6178. vty_out (vty, "! Important: ensure reference bandwidth "
  6179. "is consistent across all routers%s", VTY_NEWLINE);
  6180. vty_out (vty, " auto-cost reference-bandwidth %d%s",
  6181. ospf->ref_bandwidth / 1000, VTY_NEWLINE);
  6182. }
  6183. /* SPF timers print. */
  6184. if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
  6185. ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
  6186. ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
  6187. vty_out (vty, " timers throttle spf %d %d %d%s",
  6188. ospf->spf_delay, ospf->spf_holdtime,
  6189. ospf->spf_max_holdtime, VTY_NEWLINE);
  6190. /* Max-metric router-lsa print */
  6191. config_write_stub_router (vty, ospf);
  6192. /* SPF refresh parameters print. */
  6193. if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
  6194. vty_out (vty, " refresh timer %d%s",
  6195. ospf->lsa_refresh_interval, VTY_NEWLINE);
  6196. /* Redistribute information print. */
  6197. config_write_ospf_redistribute (vty, ospf);
  6198. /* passive-interface print. */
  6199. if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
  6200. vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
  6201. for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
  6202. if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
  6203. && IF_DEF_PARAMS (ifp)->passive_interface !=
  6204. ospf->passive_interface_default)
  6205. {
  6206. vty_out (vty, " %spassive-interface %s%s",
  6207. IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
  6208. ifp->name, VTY_NEWLINE);
  6209. }
  6210. for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
  6211. {
  6212. if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
  6213. continue;
  6214. if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
  6215. passive_interface))
  6216. {
  6217. if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
  6218. continue;
  6219. }
  6220. else if (oi->params->passive_interface == ospf->passive_interface_default)
  6221. continue;
  6222. vty_out (vty, " %spassive-interface %s %s%s",
  6223. oi->params->passive_interface ? "" : "no ",
  6224. oi->ifp->name,
  6225. inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
  6226. }
  6227. /* Network area print. */
  6228. config_write_network_area (vty, ospf);
  6229. /* Area config print. */
  6230. config_write_ospf_area (vty, ospf);
  6231. /* static neighbor print. */
  6232. config_write_ospf_nbr_nbma (vty, ospf);
  6233. /* Virtual-Link print. */
  6234. config_write_virtual_link (vty, ospf);
  6235. /* Default metric configuration. */
  6236. config_write_ospf_default_metric (vty, ospf);
  6237. /* Distribute-list and default-information print. */
  6238. config_write_ospf_distribute (vty, ospf);
  6239. /* Distance configuration. */
  6240. config_write_ospf_distance (vty, ospf);
  6241. #ifdef HAVE_OPAQUE_LSA
  6242. ospf_opaque_config_write_router (vty, ospf);
  6243. #endif /* HAVE_OPAQUE_LSA */
  6244. }
  6245. return write;
  6246. }
  6247. void
  6248. ospf_vty_show_init (void)
  6249. {
  6250. /* "show ip ospf" commands. */
  6251. install_element (VIEW_NODE, &show_ip_ospf_cmd);
  6252. install_element (ENABLE_NODE, &show_ip_ospf_cmd);
  6253. /* "show ip ospf database" commands. */
  6254. install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
  6255. install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
  6256. install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
  6257. install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
  6258. install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
  6259. install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
  6260. install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
  6261. install_element (ENABLE_NODE, &show_ip_ospf_database_type_cmd);
  6262. install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_cmd);
  6263. install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
  6264. install_element (ENABLE_NODE, &show_ip_ospf_database_type_adv_router_cmd);
  6265. install_element (ENABLE_NODE, &show_ip_ospf_database_type_id_self_cmd);
  6266. install_element (ENABLE_NODE, &show_ip_ospf_database_type_self_cmd);
  6267. install_element (ENABLE_NODE, &show_ip_ospf_database_cmd);
  6268. /* "show ip ospf interface" commands. */
  6269. install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
  6270. install_element (ENABLE_NODE, &show_ip_ospf_interface_cmd);
  6271. /* "show ip ospf neighbor" commands. */
  6272. install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
  6273. install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
  6274. install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
  6275. install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
  6276. install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
  6277. install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
  6278. install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
  6279. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
  6280. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_int_cmd);
  6281. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_id_cmd);
  6282. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
  6283. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_detail_cmd);
  6284. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_cmd);
  6285. install_element (ENABLE_NODE, &show_ip_ospf_neighbor_all_cmd);
  6286. /* "show ip ospf route" commands. */
  6287. install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
  6288. install_element (ENABLE_NODE, &show_ip_ospf_route_cmd);
  6289. install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
  6290. install_element (ENABLE_NODE, &show_ip_ospf_border_routers_cmd);
  6291. }
  6292. /* ospfd's interface node. */
  6293. static struct cmd_node interface_node =
  6294. {
  6295. INTERFACE_NODE,
  6296. "%s(config-if)# ",
  6297. 1
  6298. };
  6299. /* Initialization of OSPF interface. */
  6300. static void
  6301. ospf_vty_if_init (void)
  6302. {
  6303. /* Install interface node. */
  6304. install_node (&interface_node, config_write_interface);
  6305. install_element (CONFIG_NODE, &interface_cmd);
  6306. install_element (CONFIG_NODE, &no_interface_cmd);
  6307. install_default (INTERFACE_NODE);
  6308. /* "description" commands. */
  6309. install_element (INTERFACE_NODE, &interface_desc_cmd);
  6310. install_element (INTERFACE_NODE, &no_interface_desc_cmd);
  6311. /* "ip ospf authentication" commands. */
  6312. install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
  6313. install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
  6314. install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
  6315. install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
  6316. install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
  6317. install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
  6318. install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
  6319. install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
  6320. install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_addr_cmd);
  6321. install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
  6322. /* "ip ospf message-digest-key" commands. */
  6323. install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
  6324. install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
  6325. install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
  6326. install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
  6327. /* "ip ospf cost" commands. */
  6328. install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
  6329. install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
  6330. install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
  6331. install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
  6332. install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
  6333. install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
  6334. /* "ip ospf mtu-ignore" commands. */
  6335. install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
  6336. install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
  6337. install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
  6338. install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
  6339. /* "ip ospf dead-interval" commands. */
  6340. install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
  6341. install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
  6342. install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
  6343. install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
  6344. install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
  6345. install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
  6346. /* "ip ospf hello-interval" commands. */
  6347. install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
  6348. install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
  6349. install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
  6350. install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
  6351. /* "ip ospf network" commands. */
  6352. install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
  6353. install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
  6354. /* "ip ospf priority" commands. */
  6355. install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
  6356. install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
  6357. install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
  6358. install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
  6359. /* "ip ospf retransmit-interval" commands. */
  6360. install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
  6361. install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
  6362. install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
  6363. install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
  6364. /* "ip ospf transmit-delay" commands. */
  6365. install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
  6366. install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
  6367. install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
  6368. install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
  6369. /* These commands are compatibitliy for previous version. */
  6370. install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
  6371. install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
  6372. install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
  6373. install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
  6374. install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
  6375. install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
  6376. install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
  6377. install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
  6378. install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
  6379. install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
  6380. install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
  6381. install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
  6382. install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
  6383. install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
  6384. install_element (INTERFACE_NODE, &ospf_network_cmd);
  6385. install_element (INTERFACE_NODE, &no_ospf_network_cmd);
  6386. install_element (INTERFACE_NODE, &ospf_priority_cmd);
  6387. install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
  6388. install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
  6389. install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
  6390. install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
  6391. install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
  6392. }
  6393. static void
  6394. ospf_vty_zebra_init (void)
  6395. {
  6396. install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
  6397. install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
  6398. install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
  6399. install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
  6400. install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
  6401. install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
  6402. install_element (OSPF_NODE, &ospf_default_metric_cmd);
  6403. install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
  6404. install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
  6405. install_element (OSPF_NODE, &ospf_distance_cmd);
  6406. install_element (OSPF_NODE, &no_ospf_distance_cmd);
  6407. install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
  6408. install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
  6409. #if 0
  6410. install_element (OSPF_NODE, &ospf_distance_source_cmd);
  6411. install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
  6412. install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
  6413. install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
  6414. #endif /* 0 */
  6415. }
  6416. static struct cmd_node ospf_node =
  6417. {
  6418. OSPF_NODE,
  6419. "%s(config-router)# ",
  6420. 1
  6421. };
  6422. /* Install OSPF related vty commands. */
  6423. void
  6424. ospf_vty_init (void)
  6425. {
  6426. /* Install ospf top node. */
  6427. install_node (&ospf_node, ospf_config_write);
  6428. /* "router ospf" commands. */
  6429. install_element (CONFIG_NODE, &router_ospf_cmd);
  6430. install_element (CONFIG_NODE, &no_router_ospf_cmd);
  6431. install_default (OSPF_NODE);
  6432. /* "ospf router-id" commands. */
  6433. install_element (OSPF_NODE, &ospf_router_id_cmd);
  6434. install_element (OSPF_NODE, &no_ospf_router_id_cmd);
  6435. install_element (OSPF_NODE, &router_ospf_id_cmd);
  6436. install_element (OSPF_NODE, &no_router_ospf_id_cmd);
  6437. /* "passive-interface" commands. */
  6438. install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
  6439. install_element (OSPF_NODE, &ospf_passive_interface_cmd);
  6440. install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
  6441. install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
  6442. install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
  6443. install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
  6444. /* "ospf abr-type" commands. */
  6445. install_element (OSPF_NODE, &ospf_abr_type_cmd);
  6446. install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
  6447. /* "ospf log-adjacency-changes" commands. */
  6448. install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
  6449. install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
  6450. install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
  6451. install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
  6452. /* "ospf rfc1583-compatible" commands. */
  6453. install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
  6454. install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
  6455. install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
  6456. install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
  6457. /* "network area" commands. */
  6458. install_element (OSPF_NODE, &ospf_network_area_cmd);
  6459. install_element (OSPF_NODE, &no_ospf_network_area_cmd);
  6460. /* "area authentication" commands. */
  6461. install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
  6462. install_element (OSPF_NODE, &ospf_area_authentication_cmd);
  6463. install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
  6464. /* "area range" commands. */
  6465. install_element (OSPF_NODE, &ospf_area_range_cmd);
  6466. install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
  6467. install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
  6468. install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
  6469. install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
  6470. install_element (OSPF_NODE, &no_ospf_area_range_cmd);
  6471. install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
  6472. install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
  6473. install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
  6474. install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
  6475. install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
  6476. /* "area virtual-link" commands. */
  6477. install_element (OSPF_NODE, &ospf_area_vlink_cmd);
  6478. install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
  6479. install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
  6480. install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
  6481. install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
  6482. install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
  6483. install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
  6484. install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
  6485. install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
  6486. install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
  6487. install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
  6488. install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
  6489. install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
  6490. install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
  6491. install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
  6492. install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
  6493. install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
  6494. install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
  6495. install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
  6496. install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
  6497. install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
  6498. install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
  6499. install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
  6500. /* "area stub" commands. */
  6501. install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
  6502. install_element (OSPF_NODE, &ospf_area_stub_cmd);
  6503. install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
  6504. install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
  6505. /* "area nssa" commands. */
  6506. install_element (OSPF_NODE, &ospf_area_nssa_cmd);
  6507. install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
  6508. install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
  6509. install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
  6510. install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
  6511. install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
  6512. install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
  6513. install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
  6514. install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
  6515. install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
  6516. install_element (OSPF_NODE, &ospf_area_export_list_cmd);
  6517. install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
  6518. install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
  6519. install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
  6520. install_element (OSPF_NODE, &ospf_area_import_list_cmd);
  6521. install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
  6522. /* SPF timer commands */
  6523. install_element (OSPF_NODE, &ospf_timers_spf_cmd);
  6524. install_element (OSPF_NODE, &no_ospf_timers_spf_cmd);
  6525. install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
  6526. install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
  6527. /* refresh timer commands */
  6528. install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
  6529. install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
  6530. install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
  6531. /* max-metric commands */
  6532. install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
  6533. install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
  6534. install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
  6535. install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
  6536. install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
  6537. install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
  6538. /* reference bandwidth commands */
  6539. install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
  6540. install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
  6541. /* "neighbor" commands. */
  6542. install_element (OSPF_NODE, &ospf_neighbor_cmd);
  6543. install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
  6544. install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
  6545. install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
  6546. install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
  6547. install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
  6548. install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
  6549. install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
  6550. /* Init interface related vty commands. */
  6551. ospf_vty_if_init ();
  6552. /* Init zebra related vty commands. */
  6553. ospf_vty_zebra_init ();
  6554. }