ospf_vty.c 220 KB

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