ospf_vty.c 224 KB

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