pim_cmd.c 129 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853
  1. /*
  2. PIM for Quagga
  3. Copyright (C) 2008 Everton da Silva Marques
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; see the file COPYING; if not, write to the
  14. Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
  15. MA 02110-1301 USA
  16. $QuaggaId: $Format:%an, %ai, %h$ $
  17. */
  18. #include <sys/ioctl.h>
  19. #include <zebra.h>
  20. #include "command.h"
  21. #include "if.h"
  22. #include "prefix.h"
  23. #include "zclient.h"
  24. #include "pimd.h"
  25. #include "pim_cmd.h"
  26. #include "pim_iface.h"
  27. #include "pim_vty.h"
  28. #include "pim_mroute.h"
  29. #include "pim_str.h"
  30. #include "pim_igmp.h"
  31. #include "pim_igmpv3.h"
  32. #include "pim_sock.h"
  33. #include "pim_time.h"
  34. #include "pim_util.h"
  35. #include "pim_oil.h"
  36. #include "pim_neighbor.h"
  37. #include "pim_pim.h"
  38. #include "pim_ifchannel.h"
  39. #include "pim_hello.h"
  40. #include "pim_msg.h"
  41. #include "pim_upstream.h"
  42. #include "pim_rpf.h"
  43. #include "pim_macro.h"
  44. #include "pim_ssmpingd.h"
  45. #include "pim_zebra.h"
  46. #include "pim_static.h"
  47. static struct cmd_node pim_global_node = {
  48. PIM_NODE,
  49. "",
  50. 1 /* vtysh ? yes */
  51. };
  52. static struct cmd_node interface_node = {
  53. INTERFACE_NODE,
  54. "%s(config-if)# ",
  55. 1 /* vtysh ? yes */
  56. };
  57. static void pim_if_membership_clear(struct interface *ifp)
  58. {
  59. struct pim_interface *pim_ifp;
  60. pim_ifp = ifp->info;
  61. zassert(pim_ifp);
  62. if (PIM_IF_TEST_PIM(pim_ifp->options) &&
  63. PIM_IF_TEST_IGMP(pim_ifp->options)) {
  64. return;
  65. }
  66. pim_ifchannel_membership_clear(ifp);
  67. }
  68. /*
  69. When PIM is disabled on interface, IGMPv3 local membership
  70. information is not injected into PIM interface state.
  71. The function pim_if_membership_refresh() fetches all IGMPv3 local
  72. membership information into PIM. It is intented to be called
  73. whenever PIM is enabled on the interface in order to collect missed
  74. local membership information.
  75. */
  76. static void pim_if_membership_refresh(struct interface *ifp)
  77. {
  78. struct pim_interface *pim_ifp;
  79. struct listnode *sock_node;
  80. struct igmp_sock *igmp;
  81. pim_ifp = ifp->info;
  82. zassert(pim_ifp);
  83. if (!PIM_IF_TEST_PIM(pim_ifp->options))
  84. return;
  85. if (!PIM_IF_TEST_IGMP(pim_ifp->options))
  86. return;
  87. /*
  88. First clear off membership from all PIM (S,G) entries on the
  89. interface
  90. */
  91. pim_ifchannel_membership_clear(ifp);
  92. /*
  93. Then restore PIM (S,G) membership from all IGMPv3 (S,G) entries on
  94. the interface
  95. */
  96. /* scan igmp sockets */
  97. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  98. struct listnode *grpnode;
  99. struct igmp_group *grp;
  100. /* scan igmp groups */
  101. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  102. struct listnode *srcnode;
  103. struct igmp_source *src;
  104. /* scan group sources */
  105. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
  106. if (IGMP_SOURCE_TEST_FORWARDING(src->source_flags)) {
  107. pim_ifchannel_local_membership_add(ifp,
  108. src->source_addr,
  109. grp->group_addr);
  110. }
  111. } /* scan group sources */
  112. } /* scan igmp groups */
  113. } /* scan igmp sockets */
  114. /*
  115. Finally delete every PIM (S,G) entry lacking all state info
  116. */
  117. pim_ifchannel_delete_on_noinfo(ifp);
  118. }
  119. static void pim_show_assert(struct vty *vty)
  120. {
  121. struct listnode *ifnode;
  122. struct interface *ifp;
  123. time_t now;
  124. now = pim_time_monotonic_sec();
  125. vty_out(vty,
  126. "Interface Address Source Group State Winner Uptime Timer%s",
  127. VTY_NEWLINE);
  128. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  129. struct pim_interface *pim_ifp;
  130. struct in_addr ifaddr;
  131. struct listnode *ch_node;
  132. struct pim_ifchannel *ch;
  133. pim_ifp = ifp->info;
  134. if (!pim_ifp)
  135. continue;
  136. ifaddr = pim_ifp->primary_address;
  137. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  138. char ch_src_str[100];
  139. char ch_grp_str[100];
  140. char winner_str[100];
  141. char uptime[10];
  142. char timer[10];
  143. pim_inet4_dump("<ch_src?>", ch->source_addr,
  144. ch_src_str, sizeof(ch_src_str));
  145. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  146. ch_grp_str, sizeof(ch_grp_str));
  147. pim_inet4_dump("<assrt_win?>", ch->ifassert_winner,
  148. winner_str, sizeof(winner_str));
  149. pim_time_uptime(uptime, sizeof(uptime), now - ch->ifassert_creation);
  150. pim_time_timer_to_mmss(timer, sizeof(timer),
  151. ch->t_ifassert_timer);
  152. vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %-15s %-8s %-5s%s",
  153. ifp->name,
  154. inet_ntoa(ifaddr),
  155. ch_src_str,
  156. ch_grp_str,
  157. pim_ifchannel_ifassert_name(ch->ifassert_state),
  158. winner_str,
  159. uptime,
  160. timer,
  161. VTY_NEWLINE);
  162. } /* scan interface channels */
  163. } /* scan interfaces */
  164. }
  165. static void pim_show_assert_internal(struct vty *vty)
  166. {
  167. struct listnode *ifnode;
  168. struct interface *ifp;
  169. vty_out(vty,
  170. "CA: CouldAssert%s"
  171. "ECA: Evaluate CouldAssert%s"
  172. "ATD: AssertTrackingDesired%s"
  173. "eATD: Evaluate AssertTrackingDesired%s%s",
  174. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  175. vty_out(vty,
  176. "Interface Address Source Group CA eCA ATD eATD%s",
  177. VTY_NEWLINE);
  178. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  179. struct pim_interface *pim_ifp;
  180. struct in_addr ifaddr;
  181. struct listnode *ch_node;
  182. struct pim_ifchannel *ch;
  183. pim_ifp = ifp->info;
  184. if (!pim_ifp)
  185. continue;
  186. ifaddr = pim_ifp->primary_address;
  187. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  188. char ch_src_str[100];
  189. char ch_grp_str[100];
  190. pim_inet4_dump("<ch_src?>", ch->source_addr,
  191. ch_src_str, sizeof(ch_src_str));
  192. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  193. ch_grp_str, sizeof(ch_grp_str));
  194. vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-3s %-3s %-4s%s",
  195. ifp->name,
  196. inet_ntoa(ifaddr),
  197. ch_src_str,
  198. ch_grp_str,
  199. PIM_IF_FLAG_TEST_COULD_ASSERT(ch->flags) ? "yes" : "no",
  200. pim_macro_ch_could_assert_eval(ch) ? "yes" : "no",
  201. PIM_IF_FLAG_TEST_ASSERT_TRACKING_DESIRED(ch->flags) ? "yes" : "no",
  202. pim_macro_assert_tracking_desired_eval(ch) ? "yes" : "no",
  203. VTY_NEWLINE);
  204. } /* scan interface channels */
  205. } /* scan interfaces */
  206. }
  207. static void pim_show_assert_metric(struct vty *vty)
  208. {
  209. struct listnode *ifnode;
  210. struct interface *ifp;
  211. vty_out(vty,
  212. "Interface Address Source Group RPT Pref Metric Address %s",
  213. VTY_NEWLINE);
  214. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  215. struct pim_interface *pim_ifp;
  216. struct in_addr ifaddr;
  217. struct listnode *ch_node;
  218. struct pim_ifchannel *ch;
  219. pim_ifp = ifp->info;
  220. if (!pim_ifp)
  221. continue;
  222. ifaddr = pim_ifp->primary_address;
  223. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  224. char ch_src_str[100];
  225. char ch_grp_str[100];
  226. char addr_str[100];
  227. struct pim_assert_metric am;
  228. am = pim_macro_spt_assert_metric(&ch->upstream->rpf, pim_ifp->primary_address);
  229. pim_inet4_dump("<ch_src?>", ch->source_addr,
  230. ch_src_str, sizeof(ch_src_str));
  231. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  232. ch_grp_str, sizeof(ch_grp_str));
  233. pim_inet4_dump("<addr?>", am.ip_address,
  234. addr_str, sizeof(addr_str));
  235. vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %4u %6u %-15s%s",
  236. ifp->name,
  237. inet_ntoa(ifaddr),
  238. ch_src_str,
  239. ch_grp_str,
  240. am.rpt_bit_flag ? "yes" : "no",
  241. am.metric_preference,
  242. am.route_metric,
  243. addr_str,
  244. VTY_NEWLINE);
  245. } /* scan interface channels */
  246. } /* scan interfaces */
  247. }
  248. static void pim_show_assert_winner_metric(struct vty *vty)
  249. {
  250. struct listnode *ifnode;
  251. struct interface *ifp;
  252. vty_out(vty,
  253. "Interface Address Source Group RPT Pref Metric Address %s",
  254. VTY_NEWLINE);
  255. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  256. struct pim_interface *pim_ifp;
  257. struct in_addr ifaddr;
  258. struct listnode *ch_node;
  259. struct pim_ifchannel *ch;
  260. pim_ifp = ifp->info;
  261. if (!pim_ifp)
  262. continue;
  263. ifaddr = pim_ifp->primary_address;
  264. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  265. char ch_src_str[100];
  266. char ch_grp_str[100];
  267. char addr_str[100];
  268. struct pim_assert_metric *am;
  269. char pref_str[5];
  270. char metr_str[7];
  271. am = &ch->ifassert_winner_metric;
  272. pim_inet4_dump("<ch_src?>", ch->source_addr,
  273. ch_src_str, sizeof(ch_src_str));
  274. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  275. ch_grp_str, sizeof(ch_grp_str));
  276. pim_inet4_dump("<addr?>", am->ip_address,
  277. addr_str, sizeof(addr_str));
  278. if (am->metric_preference == PIM_ASSERT_METRIC_PREFERENCE_MAX)
  279. snprintf(pref_str, sizeof(pref_str), "INFI");
  280. else
  281. snprintf(pref_str, sizeof(pref_str), "%4u", am->metric_preference);
  282. if (am->route_metric == PIM_ASSERT_ROUTE_METRIC_MAX)
  283. snprintf(metr_str, sizeof(metr_str), "INFI");
  284. else
  285. snprintf(metr_str, sizeof(metr_str), "%6u", am->route_metric);
  286. vty_out(vty, "%-9s %-15s %-15s %-15s %-3s %-4s %-6s %-15s%s",
  287. ifp->name,
  288. inet_ntoa(ifaddr),
  289. ch_src_str,
  290. ch_grp_str,
  291. am->rpt_bit_flag ? "yes" : "no",
  292. pref_str,
  293. metr_str,
  294. addr_str,
  295. VTY_NEWLINE);
  296. } /* scan interface channels */
  297. } /* scan interfaces */
  298. }
  299. static void pim_show_membership(struct vty *vty)
  300. {
  301. struct listnode *ifnode;
  302. struct interface *ifp;
  303. vty_out(vty,
  304. "Interface Address Source Group Membership%s",
  305. VTY_NEWLINE);
  306. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  307. struct pim_interface *pim_ifp;
  308. struct in_addr ifaddr;
  309. struct listnode *ch_node;
  310. struct pim_ifchannel *ch;
  311. pim_ifp = ifp->info;
  312. if (!pim_ifp)
  313. continue;
  314. ifaddr = pim_ifp->primary_address;
  315. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  316. char ch_src_str[100];
  317. char ch_grp_str[100];
  318. pim_inet4_dump("<ch_src?>", ch->source_addr,
  319. ch_src_str, sizeof(ch_src_str));
  320. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  321. ch_grp_str, sizeof(ch_grp_str));
  322. vty_out(vty, "%-9s %-15s %-15s %-15s %-10s%s",
  323. ifp->name,
  324. inet_ntoa(ifaddr),
  325. ch_src_str,
  326. ch_grp_str,
  327. ch->local_ifmembership == PIM_IFMEMBERSHIP_NOINFO ?
  328. "NOINFO" : "INCLUDE",
  329. VTY_NEWLINE);
  330. } /* scan interface channels */
  331. } /* scan interfaces */
  332. }
  333. static void igmp_show_interfaces(struct vty *vty)
  334. {
  335. struct listnode *node;
  336. struct interface *ifp;
  337. time_t now;
  338. now = pim_time_monotonic_sec();
  339. vty_out(vty,
  340. "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s",
  341. VTY_NEWLINE);
  342. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  343. struct pim_interface *pim_ifp;
  344. struct listnode *sock_node;
  345. struct igmp_sock *igmp;
  346. pim_ifp = ifp->info;
  347. if (!pim_ifp)
  348. continue;
  349. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  350. char uptime[10];
  351. int mloop;
  352. pim_time_uptime(uptime, sizeof(uptime), now - igmp->sock_creation);
  353. mloop = pim_socket_mcastloop_get(igmp->fd);
  354. vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
  355. ifp->name,
  356. inet_ntoa(igmp->ifaddr),
  357. ifp->ifindex,
  358. igmp->fd,
  359. uptime,
  360. if_is_multicast(ifp) ? "yes" : "no",
  361. if_is_broadcast(ifp) ? "yes" : "no",
  362. (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
  363. (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
  364. (ifp->flags & IFF_PROMISC) ? "yes" : "no",
  365. PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
  366. VTY_NEWLINE);
  367. }
  368. }
  369. }
  370. static void igmp_show_interface_join(struct vty *vty)
  371. {
  372. struct listnode *node;
  373. struct interface *ifp;
  374. time_t now;
  375. now = pim_time_monotonic_sec();
  376. vty_out(vty,
  377. "Interface Address Source Group Socket Uptime %s",
  378. VTY_NEWLINE);
  379. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  380. struct pim_interface *pim_ifp;
  381. struct listnode *join_node;
  382. struct igmp_join *ij;
  383. struct in_addr pri_addr;
  384. char pri_addr_str[100];
  385. pim_ifp = ifp->info;
  386. if (!pim_ifp)
  387. continue;
  388. if (!pim_ifp->igmp_join_list)
  389. continue;
  390. pri_addr = pim_find_primary_addr(ifp);
  391. pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
  392. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_join_list, join_node, ij)) {
  393. char group_str[100];
  394. char source_str[100];
  395. char uptime[10];
  396. pim_time_uptime(uptime, sizeof(uptime), now - ij->sock_creation);
  397. pim_inet4_dump("<grp?>", ij->group_addr, group_str, sizeof(group_str));
  398. pim_inet4_dump("<src?>", ij->source_addr, source_str, sizeof(source_str));
  399. vty_out(vty, "%-9s %-15s %-15s %-15s %6d %8s%s",
  400. ifp->name,
  401. pri_addr_str,
  402. source_str,
  403. group_str,
  404. ij->sock_fd,
  405. uptime,
  406. VTY_NEWLINE);
  407. } /* for (pim_ifp->igmp_join_list) */
  408. } /* for (iflist) */
  409. }
  410. static void show_interface_address(struct vty *vty)
  411. {
  412. struct listnode *ifpnode;
  413. struct interface *ifp;
  414. vty_out(vty,
  415. "Interface Primary Secondary %s",
  416. VTY_NEWLINE);
  417. for (ALL_LIST_ELEMENTS_RO(iflist, ifpnode, ifp)) {
  418. struct listnode *ifcnode;
  419. struct connected *ifc;
  420. struct in_addr pri_addr;
  421. char pri_addr_str[100];
  422. pri_addr = pim_find_primary_addr(ifp);
  423. pim_inet4_dump("<pri?>", pri_addr, pri_addr_str, sizeof(pri_addr_str));
  424. for (ALL_LIST_ELEMENTS_RO(ifp->connected, ifcnode, ifc)) {
  425. char sec_addr_str[100];
  426. struct prefix *p = ifc->address;
  427. if (p->family != AF_INET)
  428. continue;
  429. if (p->u.prefix4.s_addr == pri_addr.s_addr) {
  430. sec_addr_str[0] = '\0';
  431. }
  432. else {
  433. pim_inet4_dump("<sec?>", p->u.prefix4, sec_addr_str, sizeof(sec_addr_str));
  434. }
  435. vty_out(vty, "%-9s %-15s %-15s%s",
  436. ifp->name,
  437. pri_addr_str,
  438. sec_addr_str,
  439. VTY_NEWLINE);
  440. }
  441. }
  442. }
  443. static void pim_show_dr(struct vty *vty)
  444. {
  445. struct listnode *node;
  446. struct interface *ifp;
  447. time_t now;
  448. now = pim_time_monotonic_sec();
  449. vty_out(vty,
  450. "NonPri: Number of neighbors missing DR Priority hello option%s%s",
  451. VTY_NEWLINE, VTY_NEWLINE);
  452. vty_out(vty, "Interface Address DR Uptime Elections Changes NonPri%s", VTY_NEWLINE);
  453. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  454. struct pim_interface *pim_ifp;
  455. struct in_addr ifaddr;
  456. char dr_str[100];
  457. char dr_uptime[10];
  458. pim_ifp = ifp->info;
  459. if (!pim_ifp)
  460. continue;
  461. if (pim_ifp->pim_sock_fd < 0)
  462. continue;
  463. ifaddr = pim_ifp->primary_address;
  464. pim_time_uptime_begin(dr_uptime, sizeof(dr_uptime),
  465. now, pim_ifp->pim_dr_election_last);
  466. pim_inet4_dump("<dr?>", pim_ifp->pim_dr_addr,
  467. dr_str, sizeof(dr_str));
  468. vty_out(vty, "%-9s %-15s %-15s %8s %9d %7d %6d%s",
  469. ifp->name,
  470. inet_ntoa(ifaddr),
  471. dr_str,
  472. dr_uptime,
  473. pim_ifp->pim_dr_election_count,
  474. pim_ifp->pim_dr_election_changes,
  475. pim_ifp->pim_dr_num_nondrpri_neighbors,
  476. VTY_NEWLINE);
  477. }
  478. }
  479. static void pim_show_hello(struct vty *vty)
  480. {
  481. struct listnode *node;
  482. struct interface *ifp;
  483. time_t now;
  484. now = pim_time_monotonic_sec();
  485. vty_out(vty, "Interface Address Period Timer StatStart Recv Rfail Send Sfail%s", VTY_NEWLINE);
  486. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  487. struct pim_interface *pim_ifp;
  488. struct in_addr ifaddr;
  489. char hello_period[10];
  490. char hello_timer[10];
  491. char stat_uptime[10];
  492. pim_ifp = ifp->info;
  493. if (!pim_ifp)
  494. continue;
  495. if (pim_ifp->pim_sock_fd < 0)
  496. continue;
  497. ifaddr = pim_ifp->primary_address;
  498. pim_time_timer_to_mmss(hello_timer, sizeof(hello_timer), pim_ifp->t_pim_hello_timer);
  499. pim_time_mmss(hello_period, sizeof(hello_period), pim_ifp->pim_hello_period);
  500. pim_time_uptime(stat_uptime, sizeof(stat_uptime), now - pim_ifp->pim_ifstat_start);
  501. vty_out(vty, "%-9s %-15s %6s %5s %9s %4u %5u %4u %5u%s",
  502. ifp->name,
  503. inet_ntoa(ifaddr),
  504. hello_period,
  505. hello_timer,
  506. stat_uptime,
  507. pim_ifp->pim_ifstat_hello_recv,
  508. pim_ifp->pim_ifstat_hello_recvfail,
  509. pim_ifp->pim_ifstat_hello_sent,
  510. pim_ifp->pim_ifstat_hello_sendfail,
  511. VTY_NEWLINE);
  512. }
  513. }
  514. static void pim_show_interfaces(struct vty *vty)
  515. {
  516. struct listnode *node;
  517. struct interface *ifp;
  518. time_t now;
  519. now = pim_time_monotonic_sec();
  520. vty_out(vty, "Interface Address ifIndex Socket Uptime Multi Broad MLoop AllMu Prmsc Del%s", VTY_NEWLINE);
  521. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  522. struct pim_interface *pim_ifp;
  523. struct in_addr ifaddr;
  524. char uptime[10];
  525. int mloop;
  526. pim_ifp = ifp->info;
  527. if (!pim_ifp)
  528. continue;
  529. if (pim_ifp->pim_sock_fd < 0)
  530. continue;
  531. ifaddr = pim_ifp->primary_address;
  532. pim_time_uptime(uptime, sizeof(uptime), now - pim_ifp->pim_sock_creation);
  533. mloop = pim_socket_mcastloop_get(pim_ifp->pim_sock_fd);
  534. vty_out(vty, "%-9s %-15s %7d %6d %8s %5s %5s %5s %5s %5s %3s%s",
  535. ifp->name,
  536. inet_ntoa(ifaddr),
  537. ifp->ifindex,
  538. pim_ifp->pim_sock_fd,
  539. uptime,
  540. if_is_multicast(ifp) ? "yes" : "no",
  541. if_is_broadcast(ifp) ? "yes" : "no",
  542. (mloop < 0) ? "?" : (mloop ? "yes" : "no"),
  543. (ifp->flags & IFF_ALLMULTI) ? "yes" : "no",
  544. (ifp->flags & IFF_PROMISC) ? "yes" : "no",
  545. PIM_IF_IS_DELETED(ifp) ? "yes" : "no",
  546. VTY_NEWLINE);
  547. }
  548. }
  549. static void pim_show_join(struct vty *vty)
  550. {
  551. struct listnode *ifnode;
  552. struct interface *ifp;
  553. time_t now;
  554. now = pim_time_monotonic_sec();
  555. vty_out(vty,
  556. "Interface Address Source Group State Uptime Expire Prune%s",
  557. VTY_NEWLINE);
  558. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  559. struct pim_interface *pim_ifp;
  560. struct in_addr ifaddr;
  561. struct listnode *ch_node;
  562. struct pim_ifchannel *ch;
  563. pim_ifp = ifp->info;
  564. if (!pim_ifp)
  565. continue;
  566. ifaddr = pim_ifp->primary_address;
  567. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, ch_node, ch)) {
  568. char ch_src_str[100];
  569. char ch_grp_str[100];
  570. char uptime[10];
  571. char expire[10];
  572. char prune[10];
  573. pim_inet4_dump("<ch_src?>", ch->source_addr,
  574. ch_src_str, sizeof(ch_src_str));
  575. pim_inet4_dump("<ch_grp?>", ch->group_addr,
  576. ch_grp_str, sizeof(ch_grp_str));
  577. pim_time_uptime_begin(uptime, sizeof(uptime), now, ch->ifjoin_creation);
  578. pim_time_timer_to_mmss(expire, sizeof(expire),
  579. ch->t_ifjoin_expiry_timer);
  580. pim_time_timer_to_mmss(prune, sizeof(prune),
  581. ch->t_ifjoin_prune_pending_timer);
  582. vty_out(vty, "%-9s %-15s %-15s %-15s %-6s %8s %-6s %5s%s",
  583. ifp->name,
  584. inet_ntoa(ifaddr),
  585. ch_src_str,
  586. ch_grp_str,
  587. pim_ifchannel_ifjoin_name(ch->ifjoin_state),
  588. uptime,
  589. expire,
  590. prune,
  591. VTY_NEWLINE);
  592. } /* scan interface channels */
  593. } /* scan interfaces */
  594. }
  595. static void pim_show_neighbors(struct vty *vty)
  596. {
  597. struct listnode *node;
  598. struct interface *ifp;
  599. time_t now;
  600. now = pim_time_monotonic_sec();
  601. vty_out(vty,
  602. "Recv flags: H=holdtime L=lan_prune_delay P=dr_priority G=generation_id A=address_list%s"
  603. " T=can_disable_join_suppression%s%s",
  604. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  605. vty_out(vty, "Interface Address Neighbor Uptime Timer Holdt DrPri GenId Recv %s", VTY_NEWLINE);
  606. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  607. struct pim_interface *pim_ifp;
  608. struct in_addr ifaddr;
  609. struct listnode *neighnode;
  610. struct pim_neighbor *neigh;
  611. pim_ifp = ifp->info;
  612. if (!pim_ifp)
  613. continue;
  614. if (pim_ifp->pim_sock_fd < 0)
  615. continue;
  616. ifaddr = pim_ifp->primary_address;
  617. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
  618. char uptime[10];
  619. char holdtime[10];
  620. char expire[10];
  621. char neigh_src_str[100];
  622. char recv[7];
  623. pim_inet4_dump("<src?>", neigh->source_addr,
  624. neigh_src_str, sizeof(neigh_src_str));
  625. pim_time_uptime(uptime, sizeof(uptime), now - neigh->creation);
  626. pim_time_mmss(holdtime, sizeof(holdtime), neigh->holdtime);
  627. pim_time_timer_to_mmss(expire, sizeof(expire), neigh->t_expire_timer);
  628. recv[0] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_HOLDTIME) ? 'H' : ' ';
  629. recv[1] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? 'L' : ' ';
  630. recv[2] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_DR_PRIORITY) ? 'P' : ' ';
  631. recv[3] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_GENERATION_ID) ? 'G' : ' ';
  632. recv[4] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_ADDRESS_LIST) ? 'A' : ' ';
  633. recv[5] = PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION) ? 'T' : ' ';
  634. recv[6] = '\0';
  635. vty_out(vty, "%-9s %-15s %-15s %8s %5s %5s %5u %08x %6s%s",
  636. ifp->name,
  637. inet_ntoa(ifaddr),
  638. neigh_src_str,
  639. uptime,
  640. expire,
  641. holdtime,
  642. neigh->dr_priority,
  643. neigh->generation_id,
  644. recv,
  645. VTY_NEWLINE);
  646. }
  647. }
  648. }
  649. static void pim_show_lan_prune_delay(struct vty *vty)
  650. {
  651. struct listnode *node;
  652. struct interface *ifp;
  653. vty_out(vty,
  654. "PrDly=propagation_delay (msec) OvInt=override_interval (msec)%s"
  655. "HiDly=highest_propagation_delay (msec) HiInt=highest_override_interval (msec)%s"
  656. "NoDly=number_of_non_lan_delay_neighbors%s"
  657. "T=t_bit LPD=lan_prune_delay_hello_option%s%s",
  658. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  659. vty_out(vty, "Interface Address PrDly OvInt NoDly HiDly HiInt T | Neighbor LPD PrDly OvInt T%s", VTY_NEWLINE);
  660. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  661. struct pim_interface *pim_ifp;
  662. struct in_addr ifaddr;
  663. struct listnode *neighnode;
  664. struct pim_neighbor *neigh;
  665. pim_ifp = ifp->info;
  666. if (!pim_ifp)
  667. continue;
  668. if (pim_ifp->pim_sock_fd < 0)
  669. continue;
  670. ifaddr = pim_ifp->primary_address;
  671. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
  672. char neigh_src_str[100];
  673. pim_inet4_dump("<src?>", neigh->source_addr,
  674. neigh_src_str, sizeof(neigh_src_str));
  675. vty_out(vty, "%-9s %-15s %5u %5u %5u %5u %5u %1u | %-15s %-3s %5u %5u %1u%s",
  676. ifp->name,
  677. inet_ntoa(ifaddr),
  678. pim_ifp->pim_propagation_delay_msec,
  679. pim_ifp->pim_override_interval_msec,
  680. pim_ifp->pim_number_of_nonlandelay_neighbors,
  681. pim_ifp->pim_neighbors_highest_propagation_delay_msec,
  682. pim_ifp->pim_neighbors_highest_override_interval_msec,
  683. PIM_FORCE_BOOLEAN(PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPRESSION(pim_ifp->options)),
  684. neigh_src_str,
  685. PIM_OPTION_IS_SET(neigh->hello_options, PIM_OPTION_MASK_LAN_PRUNE_DELAY) ? "yes" : "no",
  686. neigh->propagation_delay_msec,
  687. neigh->override_interval_msec,
  688. PIM_FORCE_BOOLEAN(PIM_OPTION_IS_SET(neigh->hello_options,
  689. PIM_OPTION_MASK_CAN_DISABLE_JOIN_SUPPRESSION)),
  690. VTY_NEWLINE);
  691. }
  692. }
  693. }
  694. static void pim_show_jp_override_interval(struct vty *vty)
  695. {
  696. struct listnode *node;
  697. struct interface *ifp;
  698. vty_out(vty,
  699. "EffPDelay=effective_propagation_delay (msec)%s"
  700. "EffOvrInt=override_interval (msec)%s"
  701. "JPOvrInt=jp_override_interval (msec)%s%s",
  702. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  703. vty_out(vty, "Interface Address LAN_Delay EffPDelay EffOvrInt JPOvrInt%s", VTY_NEWLINE);
  704. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  705. struct pim_interface *pim_ifp;
  706. struct in_addr ifaddr;
  707. pim_ifp = ifp->info;
  708. if (!pim_ifp)
  709. continue;
  710. if (pim_ifp->pim_sock_fd < 0)
  711. continue;
  712. ifaddr = pim_ifp->primary_address;
  713. vty_out(vty, "%-9s %-15s %-9s %9u %9u %8u%s",
  714. ifp->name,
  715. inet_ntoa(ifaddr),
  716. pim_if_lan_delay_enabled(ifp) ? "enabled" : "disabled",
  717. pim_if_effective_propagation_delay_msec(ifp),
  718. pim_if_effective_override_interval_msec(ifp),
  719. pim_if_jp_override_interval_msec(ifp),
  720. VTY_NEWLINE);
  721. }
  722. }
  723. static void pim_show_neighbors_secondary(struct vty *vty)
  724. {
  725. struct listnode *node;
  726. struct interface *ifp;
  727. vty_out(vty, "Interface Address Neighbor Secondary %s", VTY_NEWLINE);
  728. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  729. struct pim_interface *pim_ifp;
  730. struct in_addr ifaddr;
  731. struct listnode *neighnode;
  732. struct pim_neighbor *neigh;
  733. pim_ifp = ifp->info;
  734. if (!pim_ifp)
  735. continue;
  736. if (pim_ifp->pim_sock_fd < 0)
  737. continue;
  738. ifaddr = pim_ifp->primary_address;
  739. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_neighbor_list, neighnode, neigh)) {
  740. char neigh_src_str[100];
  741. struct listnode *prefix_node;
  742. struct prefix *p;
  743. if (!neigh->prefix_list)
  744. continue;
  745. pim_inet4_dump("<src?>", neigh->source_addr,
  746. neigh_src_str, sizeof(neigh_src_str));
  747. for (ALL_LIST_ELEMENTS_RO(neigh->prefix_list, prefix_node, p)) {
  748. char neigh_sec_str[100];
  749. if (p->family != AF_INET)
  750. continue;
  751. pim_inet4_dump("<src?>", p->u.prefix4,
  752. neigh_sec_str, sizeof(neigh_sec_str));
  753. vty_out(vty, "%-9s %-15s %-15s %-15s%s",
  754. ifp->name,
  755. inet_ntoa(ifaddr),
  756. neigh_src_str,
  757. neigh_sec_str,
  758. VTY_NEWLINE);
  759. }
  760. }
  761. }
  762. }
  763. static void pim_show_upstream(struct vty *vty)
  764. {
  765. struct listnode *upnode;
  766. struct pim_upstream *up;
  767. time_t now;
  768. now = pim_time_monotonic_sec();
  769. vty_out(vty, "Source Group State Uptime JoinTimer RefCnt%s", VTY_NEWLINE);
  770. for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
  771. char src_str[100];
  772. char grp_str[100];
  773. char uptime[10];
  774. char join_timer[10];
  775. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  776. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  777. pim_time_uptime(uptime, sizeof(uptime), now - up->state_transition);
  778. pim_time_timer_to_hhmmss(join_timer, sizeof(join_timer), up->t_join_timer);
  779. vty_out(vty, "%-15s %-15s %-5s %-8s %-9s %6d%s",
  780. src_str,
  781. grp_str,
  782. up->join_state == PIM_UPSTREAM_JOINED ? "Jnd" : "NtJnd",
  783. uptime,
  784. join_timer,
  785. up->ref_count,
  786. VTY_NEWLINE);
  787. }
  788. }
  789. static void pim_show_join_desired(struct vty *vty)
  790. {
  791. struct listnode *ifnode;
  792. struct listnode *chnode;
  793. struct interface *ifp;
  794. struct pim_interface *pim_ifp;
  795. struct pim_ifchannel *ch;
  796. char src_str[100];
  797. char grp_str[100];
  798. vty_out(vty,
  799. "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD%s",
  800. VTY_NEWLINE);
  801. /* scan all interfaces */
  802. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  803. pim_ifp = ifp->info;
  804. if (!pim_ifp)
  805. continue;
  806. /* scan per-interface (S,G) state */
  807. for (ALL_LIST_ELEMENTS_RO(pim_ifp->pim_ifchannel_list, chnode, ch)) {
  808. struct pim_upstream *up = ch->upstream;
  809. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  810. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  811. vty_out(vty, "%-9s %-15s %-15s %-10s %-5s %-10s %-11s %-6s%s",
  812. ifp->name,
  813. src_str,
  814. grp_str,
  815. pim_macro_ch_lost_assert(ch) ? "yes" : "no",
  816. pim_macro_chisin_joins(ch) ? "yes" : "no",
  817. pim_macro_chisin_pim_include(ch) ? "yes" : "no",
  818. PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) ? "yes" : "no",
  819. pim_upstream_evaluate_join_desired(up) ? "yes" : "no",
  820. VTY_NEWLINE);
  821. }
  822. }
  823. }
  824. static void pim_show_upstream_rpf(struct vty *vty)
  825. {
  826. struct listnode *upnode;
  827. struct pim_upstream *up;
  828. vty_out(vty,
  829. "Source Group RpfIface RibNextHop RpfAddress %s",
  830. VTY_NEWLINE);
  831. for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, upnode, up)) {
  832. char src_str[100];
  833. char grp_str[100];
  834. char rpf_nexthop_str[100];
  835. char rpf_addr_str[100];
  836. struct pim_rpf *rpf;
  837. const char *rpf_ifname;
  838. rpf = &up->rpf;
  839. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  840. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  841. pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rpf_nexthop_str, sizeof(rpf_nexthop_str));
  842. pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
  843. rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
  844. vty_out(vty, "%-15s %-15s %-8s %-15s %-15s%s",
  845. src_str,
  846. grp_str,
  847. rpf_ifname,
  848. rpf_nexthop_str,
  849. rpf_addr_str,
  850. VTY_NEWLINE);
  851. }
  852. }
  853. static void show_rpf_refresh_stats(struct vty *vty, time_t now)
  854. {
  855. char refresh_uptime[10];
  856. pim_time_uptime_begin(refresh_uptime, sizeof(refresh_uptime), now, qpim_rpf_cache_refresh_last);
  857. vty_out(vty,
  858. "RPF Cache Refresh Delay: %ld msecs%s"
  859. "RPF Cache Refresh Timer: %ld msecs%s"
  860. "RPF Cache Refresh Requests: %lld%s"
  861. "RPF Cache Refresh Events: %lld%s"
  862. "RPF Cache Refresh Last: %s%s",
  863. qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
  864. pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
  865. (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
  866. (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
  867. refresh_uptime, VTY_NEWLINE);
  868. }
  869. static void show_scan_oil_stats(struct vty *vty, time_t now)
  870. {
  871. char uptime_scan_oil[10];
  872. char uptime_mroute_add[10];
  873. char uptime_mroute_del[10];
  874. pim_time_uptime_begin(uptime_scan_oil, sizeof(uptime_scan_oil), now, qpim_scan_oil_last);
  875. pim_time_uptime_begin(uptime_mroute_add, sizeof(uptime_mroute_add), now, qpim_mroute_add_last);
  876. pim_time_uptime_begin(uptime_mroute_del, sizeof(uptime_mroute_del), now, qpim_mroute_del_last);
  877. vty_out(vty,
  878. "Scan OIL - Last: %s Events: %lld%s"
  879. "MFC Add - Last: %s Events: %lld%s"
  880. "MFC Del - Last: %s Events: %lld%s",
  881. uptime_scan_oil, (long long) qpim_scan_oil_events, VTY_NEWLINE,
  882. uptime_mroute_add, (long long) qpim_mroute_add_events, VTY_NEWLINE,
  883. uptime_mroute_del, (long long) qpim_mroute_del_events, VTY_NEWLINE);
  884. }
  885. static void pim_show_rpf(struct vty *vty)
  886. {
  887. struct listnode *up_node;
  888. struct pim_upstream *up;
  889. time_t now = pim_time_monotonic_sec();
  890. show_rpf_refresh_stats(vty, now);
  891. vty_out(vty, "%s", VTY_NEWLINE);
  892. vty_out(vty,
  893. "Source Group RpfIface RpfAddress RibNextHop Metric Pref%s",
  894. VTY_NEWLINE);
  895. for (ALL_LIST_ELEMENTS_RO(qpim_upstream_list, up_node, up)) {
  896. char src_str[100];
  897. char grp_str[100];
  898. char rpf_addr_str[100];
  899. char rib_nexthop_str[100];
  900. const char *rpf_ifname;
  901. struct pim_rpf *rpf = &up->rpf;
  902. pim_inet4_dump("<src?>", up->source_addr, src_str, sizeof(src_str));
  903. pim_inet4_dump("<grp?>", up->group_addr, grp_str, sizeof(grp_str));
  904. pim_inet4_dump("<rpf?>", rpf->rpf_addr, rpf_addr_str, sizeof(rpf_addr_str));
  905. pim_inet4_dump("<nexthop?>", rpf->source_nexthop.mrib_nexthop_addr, rib_nexthop_str, sizeof(rib_nexthop_str));
  906. rpf_ifname = rpf->source_nexthop.interface ? rpf->source_nexthop.interface->name : "<ifname?>";
  907. vty_out(vty, "%-15s %-15s %-8s %-15s %-15s %6d %4d%s",
  908. src_str,
  909. grp_str,
  910. rpf_ifname,
  911. rpf_addr_str,
  912. rib_nexthop_str,
  913. rpf->source_nexthop.mrib_route_metric,
  914. rpf->source_nexthop.mrib_metric_preference,
  915. VTY_NEWLINE);
  916. }
  917. }
  918. static void igmp_show_querier(struct vty *vty)
  919. {
  920. struct listnode *node;
  921. struct interface *ifp;
  922. vty_out(vty, "Interface Address Querier StartCount Query-Timer Other-Timer%s", VTY_NEWLINE);
  923. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  924. struct pim_interface *pim_ifp = ifp->info;
  925. struct listnode *sock_node;
  926. struct igmp_sock *igmp;
  927. if (!pim_ifp)
  928. continue;
  929. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  930. char query_hhmmss[10];
  931. char other_hhmmss[10];
  932. pim_time_timer_to_hhmmss(query_hhmmss, sizeof(query_hhmmss), igmp->t_igmp_query_timer);
  933. pim_time_timer_to_hhmmss(other_hhmmss, sizeof(other_hhmmss), igmp->t_other_querier_timer);
  934. vty_out(vty, "%-9s %-15s %-7s %10d %11s %11s%s",
  935. ifp->name,
  936. inet_ntoa(igmp->ifaddr),
  937. igmp->t_igmp_query_timer ? "THIS" : "OTHER",
  938. igmp->startup_query_count,
  939. query_hhmmss,
  940. other_hhmmss,
  941. VTY_NEWLINE);
  942. }
  943. }
  944. }
  945. static void igmp_show_groups(struct vty *vty)
  946. {
  947. struct listnode *ifnode;
  948. struct interface *ifp;
  949. time_t now;
  950. now = pim_time_monotonic_sec();
  951. vty_out(vty, "Interface Address Group Mode Timer Srcs V Uptime %s", VTY_NEWLINE);
  952. /* scan interfaces */
  953. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  954. struct pim_interface *pim_ifp = ifp->info;
  955. struct listnode *sock_node;
  956. struct igmp_sock *igmp;
  957. if (!pim_ifp)
  958. continue;
  959. /* scan igmp sockets */
  960. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  961. char ifaddr_str[100];
  962. struct listnode *grpnode;
  963. struct igmp_group *grp;
  964. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  965. /* scan igmp groups */
  966. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  967. char group_str[100];
  968. char hhmmss[10];
  969. char uptime[10];
  970. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  971. pim_time_timer_to_hhmmss(hhmmss, sizeof(hhmmss), grp->t_group_timer);
  972. pim_time_uptime(uptime, sizeof(uptime), now - grp->group_creation);
  973. vty_out(vty, "%-9s %-15s %-15s %4s %8s %4d %d %8s%s",
  974. ifp->name,
  975. ifaddr_str,
  976. group_str,
  977. grp->group_filtermode_isexcl ? "EXCL" : "INCL",
  978. hhmmss,
  979. grp->group_source_list ? listcount(grp->group_source_list) : 0,
  980. igmp_group_compat_mode(igmp, grp),
  981. uptime,
  982. VTY_NEWLINE);
  983. } /* scan igmp groups */
  984. } /* scan igmp sockets */
  985. } /* scan interfaces */
  986. }
  987. static void igmp_show_group_retransmission(struct vty *vty)
  988. {
  989. struct listnode *ifnode;
  990. struct interface *ifp;
  991. vty_out(vty, "Interface Address Group RetTimer Counter RetSrcs%s", VTY_NEWLINE);
  992. /* scan interfaces */
  993. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  994. struct pim_interface *pim_ifp = ifp->info;
  995. struct listnode *sock_node;
  996. struct igmp_sock *igmp;
  997. if (!pim_ifp)
  998. continue;
  999. /* scan igmp sockets */
  1000. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  1001. char ifaddr_str[100];
  1002. struct listnode *grpnode;
  1003. struct igmp_group *grp;
  1004. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1005. /* scan igmp groups */
  1006. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  1007. char group_str[100];
  1008. char grp_retr_mmss[10];
  1009. struct listnode *src_node;
  1010. struct igmp_source *src;
  1011. int grp_retr_sources = 0;
  1012. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  1013. pim_time_timer_to_mmss(grp_retr_mmss, sizeof(grp_retr_mmss), grp->t_group_query_retransmit_timer);
  1014. /* count group sources with retransmission state */
  1015. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
  1016. if (src->source_query_retransmit_count > 0) {
  1017. ++grp_retr_sources;
  1018. }
  1019. }
  1020. vty_out(vty, "%-9s %-15s %-15s %-8s %7d %7d%s",
  1021. ifp->name,
  1022. ifaddr_str,
  1023. group_str,
  1024. grp_retr_mmss,
  1025. grp->group_specific_query_retransmit_count,
  1026. grp_retr_sources,
  1027. VTY_NEWLINE);
  1028. } /* scan igmp groups */
  1029. } /* scan igmp sockets */
  1030. } /* scan interfaces */
  1031. }
  1032. static void igmp_show_parameters(struct vty *vty)
  1033. {
  1034. struct listnode *ifnode;
  1035. struct interface *ifp;
  1036. vty_out(vty,
  1037. "QRV: Robustness Variable SQI: Startup Query Interval%s"
  1038. "QQI: Query Interval OQPI: Other Querier Present Interval%s"
  1039. "QRI: Query Response Interval LMQT: Last Member Query Time%s"
  1040. "GMI: Group Membership Interval OHPI: Older Host Present Interval%s%s",
  1041. VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
  1042. vty_out(vty,
  1043. "Interface Address QRV QQI QRI GMI SQI OQPI LMQT OHPI %s",
  1044. VTY_NEWLINE);
  1045. /* scan interfaces */
  1046. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  1047. struct pim_interface *pim_ifp = ifp->info;
  1048. struct listnode *sock_node;
  1049. struct igmp_sock *igmp;
  1050. if (!pim_ifp)
  1051. continue;
  1052. /* scan igmp sockets */
  1053. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  1054. char ifaddr_str[100];
  1055. long gmi_dsec; /* Group Membership Interval */
  1056. long oqpi_dsec; /* Other Querier Present Interval */
  1057. int sqi;
  1058. long lmqt_dsec;
  1059. long ohpi_dsec;
  1060. long qri_dsec;
  1061. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1062. gmi_dsec = PIM_IGMP_GMI_MSEC(igmp->querier_robustness_variable,
  1063. igmp->querier_query_interval,
  1064. pim_ifp->igmp_query_max_response_time_dsec) / 100;
  1065. sqi = PIM_IGMP_SQI(pim_ifp->igmp_default_query_interval);
  1066. oqpi_dsec = PIM_IGMP_OQPI_MSEC(igmp->querier_robustness_variable,
  1067. igmp->querier_query_interval,
  1068. pim_ifp->igmp_query_max_response_time_dsec) / 100;
  1069. lmqt_dsec = PIM_IGMP_LMQT_MSEC(pim_ifp->igmp_query_max_response_time_dsec,
  1070. igmp->querier_robustness_variable) / 100;
  1071. ohpi_dsec = PIM_IGMP_OHPI_DSEC(igmp->querier_robustness_variable,
  1072. igmp->querier_query_interval,
  1073. pim_ifp->igmp_query_max_response_time_dsec);
  1074. qri_dsec = pim_ifp->igmp_query_max_response_time_dsec;
  1075. vty_out(vty,
  1076. "%-9s %-15s %3d %3d %3ld.%ld %3ld.%ld %3d %3ld.%ld %3ld.%ld %3ld.%ld%s",
  1077. ifp->name,
  1078. ifaddr_str,
  1079. igmp->querier_robustness_variable,
  1080. igmp->querier_query_interval,
  1081. qri_dsec / 10, qri_dsec % 10,
  1082. gmi_dsec / 10, gmi_dsec % 10,
  1083. sqi,
  1084. oqpi_dsec / 10, oqpi_dsec % 10,
  1085. lmqt_dsec / 10, lmqt_dsec % 10,
  1086. ohpi_dsec / 10, ohpi_dsec % 10,
  1087. VTY_NEWLINE);
  1088. } /* scan igmp sockets */
  1089. } /* scan interfaces */
  1090. }
  1091. static void igmp_show_sources(struct vty *vty)
  1092. {
  1093. struct listnode *ifnode;
  1094. struct interface *ifp;
  1095. time_t now;
  1096. now = pim_time_monotonic_sec();
  1097. vty_out(vty, "Interface Address Group Source Timer Fwd Uptime %s", VTY_NEWLINE);
  1098. /* scan interfaces */
  1099. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  1100. struct pim_interface *pim_ifp = ifp->info;
  1101. struct listnode *sock_node;
  1102. struct igmp_sock *igmp;
  1103. if (!pim_ifp)
  1104. continue;
  1105. /* scan igmp sockets */
  1106. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  1107. char ifaddr_str[100];
  1108. struct listnode *grpnode;
  1109. struct igmp_group *grp;
  1110. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1111. /* scan igmp groups */
  1112. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  1113. char group_str[100];
  1114. struct listnode *srcnode;
  1115. struct igmp_source *src;
  1116. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  1117. /* scan group sources */
  1118. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
  1119. char source_str[100];
  1120. char mmss[10];
  1121. char uptime[10];
  1122. pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
  1123. pim_time_timer_to_mmss(mmss, sizeof(mmss), src->t_source_timer);
  1124. pim_time_uptime(uptime, sizeof(uptime), now - src->source_creation);
  1125. vty_out(vty, "%-9s %-15s %-15s %-15s %5s %3s %8s%s",
  1126. ifp->name,
  1127. ifaddr_str,
  1128. group_str,
  1129. source_str,
  1130. mmss,
  1131. IGMP_SOURCE_TEST_FORWARDING(src->source_flags) ? "Y" : "N",
  1132. uptime,
  1133. VTY_NEWLINE);
  1134. } /* scan group sources */
  1135. } /* scan igmp groups */
  1136. } /* scan igmp sockets */
  1137. } /* scan interfaces */
  1138. }
  1139. static void igmp_show_source_retransmission(struct vty *vty)
  1140. {
  1141. struct listnode *ifnode;
  1142. struct interface *ifp;
  1143. vty_out(vty, "Interface Address Group Source Counter%s", VTY_NEWLINE);
  1144. /* scan interfaces */
  1145. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  1146. struct pim_interface *pim_ifp = ifp->info;
  1147. struct listnode *sock_node;
  1148. struct igmp_sock *igmp;
  1149. if (!pim_ifp)
  1150. continue;
  1151. /* scan igmp sockets */
  1152. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  1153. char ifaddr_str[100];
  1154. struct listnode *grpnode;
  1155. struct igmp_group *grp;
  1156. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  1157. /* scan igmp groups */
  1158. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grpnode, grp)) {
  1159. char group_str[100];
  1160. struct listnode *srcnode;
  1161. struct igmp_source *src;
  1162. pim_inet4_dump("<group?>", grp->group_addr, group_str, sizeof(group_str));
  1163. /* scan group sources */
  1164. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, srcnode, src)) {
  1165. char source_str[100];
  1166. pim_inet4_dump("<source?>", src->source_addr, source_str, sizeof(source_str));
  1167. vty_out(vty, "%-9s %-15s %-15s %-15s %7d%s",
  1168. ifp->name,
  1169. ifaddr_str,
  1170. group_str,
  1171. source_str,
  1172. src->source_query_retransmit_count,
  1173. VTY_NEWLINE);
  1174. } /* scan group sources */
  1175. } /* scan igmp groups */
  1176. } /* scan igmp sockets */
  1177. } /* scan interfaces */
  1178. }
  1179. static void clear_igmp_interfaces()
  1180. {
  1181. struct listnode *ifnode;
  1182. struct listnode *ifnextnode;
  1183. struct interface *ifp;
  1184. for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
  1185. pim_if_addr_del_all_igmp(ifp);
  1186. }
  1187. for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
  1188. pim_if_addr_add_all(ifp);
  1189. }
  1190. }
  1191. static void clear_pim_interfaces()
  1192. {
  1193. struct listnode *ifnode;
  1194. struct listnode *ifnextnode;
  1195. struct interface *ifp;
  1196. for (ALL_LIST_ELEMENTS(iflist, ifnode, ifnextnode, ifp)) {
  1197. if (ifp->info) {
  1198. pim_neighbor_delete_all(ifp, "interface cleared");
  1199. }
  1200. }
  1201. }
  1202. static void clear_interfaces()
  1203. {
  1204. clear_igmp_interfaces();
  1205. clear_pim_interfaces();
  1206. }
  1207. DEFUN (pim_interface,
  1208. pim_interface_cmd,
  1209. "interface IFNAME",
  1210. "Select an interface to configure\n"
  1211. "Interface's name\n")
  1212. {
  1213. struct interface *ifp;
  1214. const char *ifname = argv[0];
  1215. size_t sl;
  1216. sl = strlen(ifname);
  1217. if (sl > INTERFACE_NAMSIZ) {
  1218. vty_out(vty, "%% Interface name %s is invalid: length exceeds "
  1219. "%d characters%s",
  1220. ifname, INTERFACE_NAMSIZ, VTY_NEWLINE);
  1221. return CMD_WARNING;
  1222. }
  1223. ifp = if_lookup_by_name_len(ifname, sl);
  1224. if (!ifp) {
  1225. vty_out(vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE);
  1226. /* Returning here would prevent pimd from booting when there are
  1227. interface commands in pimd.conf, since all interfaces are
  1228. unknown at pimd boot time (the zebra daemon has not been
  1229. contacted for interface discovery). */
  1230. ifp = if_get_by_name_len(ifname, sl);
  1231. if (!ifp) {
  1232. vty_out(vty, "%% Could not create interface %s%s", ifname, VTY_NEWLINE);
  1233. return CMD_WARNING;
  1234. }
  1235. }
  1236. vty->index = ifp;
  1237. vty->node = INTERFACE_NODE;
  1238. return CMD_SUCCESS;
  1239. }
  1240. DEFUN (clear_ip_interfaces,
  1241. clear_ip_interfaces_cmd,
  1242. "clear ip interfaces",
  1243. CLEAR_STR
  1244. IP_STR
  1245. "Reset interfaces\n")
  1246. {
  1247. clear_interfaces();
  1248. return CMD_SUCCESS;
  1249. }
  1250. DEFUN (clear_ip_igmp_interfaces,
  1251. clear_ip_igmp_interfaces_cmd,
  1252. "clear ip igmp interfaces",
  1253. CLEAR_STR
  1254. IP_STR
  1255. CLEAR_IP_IGMP_STR
  1256. "Reset IGMP interfaces\n")
  1257. {
  1258. clear_igmp_interfaces();
  1259. return CMD_SUCCESS;
  1260. }
  1261. static void mroute_add_all()
  1262. {
  1263. struct listnode *node;
  1264. struct channel_oil *c_oil;
  1265. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1266. if (pim_mroute_add(&c_oil->oil)) {
  1267. /* just log warning */
  1268. char source_str[100];
  1269. char group_str[100];
  1270. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1271. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1272. zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
  1273. __FILE__, __PRETTY_FUNCTION__,
  1274. source_str, group_str);
  1275. }
  1276. }
  1277. }
  1278. static void mroute_del_all()
  1279. {
  1280. struct listnode *node;
  1281. struct channel_oil *c_oil;
  1282. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1283. if (pim_mroute_del(&c_oil->oil)) {
  1284. /* just log warning */
  1285. char source_str[100];
  1286. char group_str[100];
  1287. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1288. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1289. zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
  1290. __FILE__, __PRETTY_FUNCTION__,
  1291. source_str, group_str);
  1292. }
  1293. }
  1294. }
  1295. static void static_mroute_add_all()
  1296. {
  1297. struct listnode *node;
  1298. struct static_route *s_route;
  1299. for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
  1300. if (pim_mroute_add(&s_route->mc)) {
  1301. /* just log warning */
  1302. char source_str[100];
  1303. char group_str[100];
  1304. pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
  1305. pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
  1306. zlog_warn("%s %s: (S,G)=(%s,%s) failure writing MFC",
  1307. __FILE__, __PRETTY_FUNCTION__,
  1308. source_str, group_str);
  1309. }
  1310. }
  1311. }
  1312. static void static_mroute_del_all()
  1313. {
  1314. struct listnode *node;
  1315. struct static_route *s_route;
  1316. for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
  1317. if (pim_mroute_del(&s_route->mc)) {
  1318. /* just log warning */
  1319. char source_str[100];
  1320. char group_str[100];
  1321. pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
  1322. pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
  1323. zlog_warn("%s %s: (S,G)=(%s,%s) failure clearing MFC",
  1324. __FILE__, __PRETTY_FUNCTION__,
  1325. source_str, group_str);
  1326. }
  1327. }
  1328. }
  1329. DEFUN (clear_ip_mroute,
  1330. clear_ip_mroute_cmd,
  1331. "clear ip mroute",
  1332. CLEAR_STR
  1333. IP_STR
  1334. "Reset multicast routes\n")
  1335. {
  1336. mroute_del_all();
  1337. mroute_add_all();
  1338. return CMD_SUCCESS;
  1339. }
  1340. DEFUN (clear_ip_pim_interfaces,
  1341. clear_ip_pim_interfaces_cmd,
  1342. "clear ip pim interfaces",
  1343. CLEAR_STR
  1344. IP_STR
  1345. CLEAR_IP_PIM_STR
  1346. "Reset PIM interfaces\n")
  1347. {
  1348. clear_pim_interfaces();
  1349. return CMD_SUCCESS;
  1350. }
  1351. DEFUN (clear_ip_pim_oil,
  1352. clear_ip_pim_oil_cmd,
  1353. "clear ip pim oil",
  1354. CLEAR_STR
  1355. IP_STR
  1356. CLEAR_IP_PIM_STR
  1357. "Rescan PIM OIL (output interface list)\n")
  1358. {
  1359. pim_scan_oil();
  1360. return CMD_SUCCESS;
  1361. }
  1362. DEFUN (show_ip_igmp_interface,
  1363. show_ip_igmp_interface_cmd,
  1364. "show ip igmp interface",
  1365. SHOW_STR
  1366. IP_STR
  1367. IGMP_STR
  1368. "IGMP interface information\n")
  1369. {
  1370. igmp_show_interfaces(vty);
  1371. return CMD_SUCCESS;
  1372. }
  1373. DEFUN (show_ip_igmp_join,
  1374. show_ip_igmp_join_cmd,
  1375. "show ip igmp join",
  1376. SHOW_STR
  1377. IP_STR
  1378. IGMP_STR
  1379. "IGMP static join information\n")
  1380. {
  1381. igmp_show_interface_join(vty);
  1382. return CMD_SUCCESS;
  1383. }
  1384. DEFUN (show_ip_igmp_groups,
  1385. show_ip_igmp_groups_cmd,
  1386. "show ip igmp groups",
  1387. SHOW_STR
  1388. IP_STR
  1389. IGMP_STR
  1390. IGMP_GROUP_STR)
  1391. {
  1392. igmp_show_groups(vty);
  1393. return CMD_SUCCESS;
  1394. }
  1395. DEFUN (show_ip_igmp_groups_retransmissions,
  1396. show_ip_igmp_groups_retransmissions_cmd,
  1397. "show ip igmp groups retransmissions",
  1398. SHOW_STR
  1399. IP_STR
  1400. IGMP_STR
  1401. IGMP_GROUP_STR
  1402. "IGMP group retransmissions\n")
  1403. {
  1404. igmp_show_group_retransmission(vty);
  1405. return CMD_SUCCESS;
  1406. }
  1407. DEFUN (show_ip_igmp_parameters,
  1408. show_ip_igmp_parameters_cmd,
  1409. "show ip igmp parameters",
  1410. SHOW_STR
  1411. IP_STR
  1412. IGMP_STR
  1413. "IGMP parameters information\n")
  1414. {
  1415. igmp_show_parameters(vty);
  1416. return CMD_SUCCESS;
  1417. }
  1418. DEFUN (show_ip_igmp_sources,
  1419. show_ip_igmp_sources_cmd,
  1420. "show ip igmp sources",
  1421. SHOW_STR
  1422. IP_STR
  1423. IGMP_STR
  1424. IGMP_SOURCE_STR)
  1425. {
  1426. igmp_show_sources(vty);
  1427. return CMD_SUCCESS;
  1428. }
  1429. DEFUN (show_ip_igmp_sources_retransmissions,
  1430. show_ip_igmp_sources_retransmissions_cmd,
  1431. "show ip igmp sources retransmissions",
  1432. SHOW_STR
  1433. IP_STR
  1434. IGMP_STR
  1435. IGMP_SOURCE_STR
  1436. "IGMP source retransmissions\n")
  1437. {
  1438. igmp_show_source_retransmission(vty);
  1439. return CMD_SUCCESS;
  1440. }
  1441. DEFUN (show_ip_igmp_querier,
  1442. show_ip_igmp_querier_cmd,
  1443. "show ip igmp querier",
  1444. SHOW_STR
  1445. IP_STR
  1446. IGMP_STR
  1447. "IGMP querier information\n")
  1448. {
  1449. igmp_show_querier(vty);
  1450. return CMD_SUCCESS;
  1451. }
  1452. DEFUN (show_ip_pim_address,
  1453. show_ip_pim_address_cmd,
  1454. "show ip pim address",
  1455. SHOW_STR
  1456. IP_STR
  1457. PIM_STR
  1458. "PIM interface address\n")
  1459. {
  1460. show_interface_address(vty);
  1461. return CMD_SUCCESS;
  1462. }
  1463. DEFUN (show_ip_pim_assert,
  1464. show_ip_pim_assert_cmd,
  1465. "show ip pim assert",
  1466. SHOW_STR
  1467. IP_STR
  1468. PIM_STR
  1469. "PIM interface assert\n")
  1470. {
  1471. pim_show_assert(vty);
  1472. return CMD_SUCCESS;
  1473. }
  1474. DEFUN (show_ip_pim_assert_internal,
  1475. show_ip_pim_assert_internal_cmd,
  1476. "show ip pim assert-internal",
  1477. SHOW_STR
  1478. IP_STR
  1479. PIM_STR
  1480. "PIM interface internal assert state\n")
  1481. {
  1482. pim_show_assert_internal(vty);
  1483. return CMD_SUCCESS;
  1484. }
  1485. DEFUN (show_ip_pim_assert_metric,
  1486. show_ip_pim_assert_metric_cmd,
  1487. "show ip pim assert-metric",
  1488. SHOW_STR
  1489. IP_STR
  1490. PIM_STR
  1491. "PIM interface assert metric\n")
  1492. {
  1493. pim_show_assert_metric(vty);
  1494. return CMD_SUCCESS;
  1495. }
  1496. DEFUN (show_ip_pim_assert_winner_metric,
  1497. show_ip_pim_assert_winner_metric_cmd,
  1498. "show ip pim assert-winner-metric",
  1499. SHOW_STR
  1500. IP_STR
  1501. PIM_STR
  1502. "PIM interface assert winner metric\n")
  1503. {
  1504. pim_show_assert_winner_metric(vty);
  1505. return CMD_SUCCESS;
  1506. }
  1507. DEFUN (show_ip_pim_dr,
  1508. show_ip_pim_dr_cmd,
  1509. "show ip pim designated-router",
  1510. SHOW_STR
  1511. IP_STR
  1512. PIM_STR
  1513. "PIM interface designated router\n")
  1514. {
  1515. pim_show_dr(vty);
  1516. return CMD_SUCCESS;
  1517. }
  1518. DEFUN (show_ip_pim_hello,
  1519. show_ip_pim_hello_cmd,
  1520. "show ip pim hello",
  1521. SHOW_STR
  1522. IP_STR
  1523. PIM_STR
  1524. "PIM interface hello information\n")
  1525. {
  1526. pim_show_hello(vty);
  1527. return CMD_SUCCESS;
  1528. }
  1529. DEFUN (show_ip_pim_interface,
  1530. show_ip_pim_interface_cmd,
  1531. "show ip pim interface",
  1532. SHOW_STR
  1533. IP_STR
  1534. PIM_STR
  1535. "PIM interface information\n")
  1536. {
  1537. pim_show_interfaces(vty);
  1538. return CMD_SUCCESS;
  1539. }
  1540. DEFUN (show_ip_pim_join,
  1541. show_ip_pim_join_cmd,
  1542. "show ip pim join",
  1543. SHOW_STR
  1544. IP_STR
  1545. PIM_STR
  1546. "PIM interface join information\n")
  1547. {
  1548. pim_show_join(vty);
  1549. return CMD_SUCCESS;
  1550. }
  1551. DEFUN (show_ip_pim_lan_prune_delay,
  1552. show_ip_pim_lan_prune_delay_cmd,
  1553. "show ip pim lan-prune-delay",
  1554. SHOW_STR
  1555. IP_STR
  1556. PIM_STR
  1557. "PIM neighbors LAN prune delay parameters\n")
  1558. {
  1559. pim_show_lan_prune_delay(vty);
  1560. return CMD_SUCCESS;
  1561. }
  1562. DEFUN (show_ip_pim_local_membership,
  1563. show_ip_pim_local_membership_cmd,
  1564. "show ip pim local-membership",
  1565. SHOW_STR
  1566. IP_STR
  1567. PIM_STR
  1568. "PIM interface local-membership\n")
  1569. {
  1570. pim_show_membership(vty);
  1571. return CMD_SUCCESS;
  1572. }
  1573. DEFUN (show_ip_pim_jp_override_interval,
  1574. show_ip_pim_jp_override_interval_cmd,
  1575. "show ip pim jp-override-interval",
  1576. SHOW_STR
  1577. IP_STR
  1578. PIM_STR
  1579. "PIM interface J/P override interval\n")
  1580. {
  1581. pim_show_jp_override_interval(vty);
  1582. return CMD_SUCCESS;
  1583. }
  1584. DEFUN (show_ip_pim_neighbor,
  1585. show_ip_pim_neighbor_cmd,
  1586. "show ip pim neighbor",
  1587. SHOW_STR
  1588. IP_STR
  1589. PIM_STR
  1590. "PIM neighbor information\n")
  1591. {
  1592. pim_show_neighbors(vty);
  1593. return CMD_SUCCESS;
  1594. }
  1595. DEFUN (show_ip_pim_secondary,
  1596. show_ip_pim_secondary_cmd,
  1597. "show ip pim secondary",
  1598. SHOW_STR
  1599. IP_STR
  1600. PIM_STR
  1601. "PIM neighbor addresses\n")
  1602. {
  1603. pim_show_neighbors_secondary(vty);
  1604. return CMD_SUCCESS;
  1605. }
  1606. DEFUN (show_ip_pim_upstream,
  1607. show_ip_pim_upstream_cmd,
  1608. "show ip pim upstream",
  1609. SHOW_STR
  1610. IP_STR
  1611. PIM_STR
  1612. "PIM upstream information\n")
  1613. {
  1614. pim_show_upstream(vty);
  1615. return CMD_SUCCESS;
  1616. }
  1617. DEFUN (show_ip_pim_upstream_join_desired,
  1618. show_ip_pim_upstream_join_desired_cmd,
  1619. "show ip pim upstream-join-desired",
  1620. SHOW_STR
  1621. IP_STR
  1622. PIM_STR
  1623. "PIM upstream join-desired\n")
  1624. {
  1625. pim_show_join_desired(vty);
  1626. return CMD_SUCCESS;
  1627. }
  1628. DEFUN (show_ip_pim_upstream_rpf,
  1629. show_ip_pim_upstream_rpf_cmd,
  1630. "show ip pim upstream-rpf",
  1631. SHOW_STR
  1632. IP_STR
  1633. PIM_STR
  1634. "PIM upstream source rpf\n")
  1635. {
  1636. pim_show_upstream_rpf(vty);
  1637. return CMD_SUCCESS;
  1638. }
  1639. DEFUN (show_ip_pim_rpf,
  1640. show_ip_pim_rpf_cmd,
  1641. "show ip pim rpf",
  1642. SHOW_STR
  1643. IP_STR
  1644. PIM_STR
  1645. "PIM cached source rpf information\n")
  1646. {
  1647. pim_show_rpf(vty);
  1648. return CMD_SUCCESS;
  1649. }
  1650. static void show_multicast_interfaces(struct vty *vty)
  1651. {
  1652. struct listnode *node;
  1653. struct interface *ifp;
  1654. vty_out(vty, "%s", VTY_NEWLINE);
  1655. vty_out(vty, "Interface Address ifi Vif PktsIn PktsOut BytesIn BytesOut%s",
  1656. VTY_NEWLINE);
  1657. for (ALL_LIST_ELEMENTS_RO(iflist, node, ifp)) {
  1658. struct pim_interface *pim_ifp;
  1659. struct in_addr ifaddr;
  1660. struct sioc_vif_req vreq;
  1661. pim_ifp = ifp->info;
  1662. if (!pim_ifp)
  1663. continue;
  1664. memset(&vreq, 0, sizeof(vreq));
  1665. vreq.vifi = pim_ifp->mroute_vif_index;
  1666. if (ioctl(qpim_mroute_socket_fd, SIOCGETVIFCNT, &vreq)) {
  1667. int e = errno;
  1668. vty_out(vty,
  1669. "ioctl(SIOCGETVIFCNT=%lu) failure for interface %s vif_index=%d: errno=%d: %s%s",
  1670. (unsigned long)SIOCGETVIFCNT,
  1671. ifp->name,
  1672. pim_ifp->mroute_vif_index,
  1673. e,
  1674. safe_strerror(e),
  1675. VTY_NEWLINE);
  1676. continue;
  1677. }
  1678. ifaddr = pim_ifp->primary_address;
  1679. vty_out(vty, "%-9s %-15s %3d %3d %7lu %7lu %10lu %10lu%s",
  1680. ifp->name,
  1681. inet_ntoa(ifaddr),
  1682. ifp->ifindex,
  1683. pim_ifp->mroute_vif_index,
  1684. vreq.icount,
  1685. vreq.ocount,
  1686. vreq.ibytes,
  1687. vreq.obytes,
  1688. VTY_NEWLINE);
  1689. }
  1690. }
  1691. DEFUN (show_ip_multicast,
  1692. show_ip_multicast_cmd,
  1693. "show ip multicast",
  1694. SHOW_STR
  1695. IP_STR
  1696. "Multicast global information\n")
  1697. {
  1698. time_t now = pim_time_monotonic_sec();
  1699. if (PIM_MROUTE_IS_ENABLED) {
  1700. char uptime[10];
  1701. vty_out(vty, "Mroute socket descriptor: %d%s",
  1702. qpim_mroute_socket_fd,
  1703. VTY_NEWLINE);
  1704. pim_time_uptime(uptime, sizeof(uptime), now - qpim_mroute_socket_creation);
  1705. vty_out(vty, "Mroute socket uptime: %s%s",
  1706. uptime,
  1707. VTY_NEWLINE);
  1708. }
  1709. else {
  1710. vty_out(vty, "Multicast disabled%s",
  1711. VTY_NEWLINE);
  1712. }
  1713. vty_out(vty, "%s", VTY_NEWLINE);
  1714. vty_out(vty, "Zclient update socket: ");
  1715. if (qpim_zclient_update) {
  1716. vty_out(vty, "%d failures=%d%s", qpim_zclient_update->sock,
  1717. qpim_zclient_update->fail, VTY_NEWLINE);
  1718. }
  1719. else {
  1720. vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
  1721. }
  1722. vty_out(vty, "Zclient lookup socket: ");
  1723. if (qpim_zclient_lookup) {
  1724. vty_out(vty, "%d failures=%d%s", qpim_zclient_lookup->sock,
  1725. qpim_zclient_lookup->fail, VTY_NEWLINE);
  1726. }
  1727. else {
  1728. vty_out(vty, "<null zclient>%s", VTY_NEWLINE);
  1729. }
  1730. vty_out(vty, "%s", VTY_NEWLINE);
  1731. vty_out(vty, "Current highest VifIndex: %d%s",
  1732. qpim_mroute_oif_highest_vif_index,
  1733. VTY_NEWLINE);
  1734. vty_out(vty, "Maximum highest VifIndex: %d%s",
  1735. MAXVIFS - 1,
  1736. VTY_NEWLINE);
  1737. vty_out(vty, "%s", VTY_NEWLINE);
  1738. vty_out(vty, "Upstream Join Timer: %d secs%s",
  1739. qpim_t_periodic,
  1740. VTY_NEWLINE);
  1741. vty_out(vty, "Join/Prune Holdtime: %d secs%s",
  1742. PIM_JP_HOLDTIME,
  1743. VTY_NEWLINE);
  1744. vty_out(vty, "%s", VTY_NEWLINE);
  1745. show_rpf_refresh_stats(vty, now);
  1746. vty_out(vty, "%s", VTY_NEWLINE);
  1747. show_scan_oil_stats(vty, now);
  1748. show_multicast_interfaces(vty);
  1749. return CMD_SUCCESS;
  1750. }
  1751. static void show_mroute(struct vty *vty)
  1752. {
  1753. struct listnode *node;
  1754. struct channel_oil *c_oil;
  1755. struct static_route *s_route;
  1756. time_t now;
  1757. vty_out(vty, "Proto: I=IGMP P=PIM S=STATIC%s%s", VTY_NEWLINE, VTY_NEWLINE);
  1758. vty_out(vty, "Source Group Proto Input iVifI Output oVifI TTL Uptime %s",
  1759. VTY_NEWLINE);
  1760. now = pim_time_monotonic_sec();
  1761. /* print list of PIM and IGMP routes */
  1762. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1763. char group_str[100];
  1764. char source_str[100];
  1765. int oif_vif_index;
  1766. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1767. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1768. for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
  1769. struct interface *ifp_in;
  1770. struct interface *ifp_out;
  1771. char oif_uptime[10];
  1772. int ttl;
  1773. char proto[5];
  1774. ttl = c_oil->oil.mfcc_ttls[oif_vif_index];
  1775. if (ttl < 1)
  1776. continue;
  1777. ifp_in = pim_if_find_by_vif_index(c_oil->oil.mfcc_parent);
  1778. ifp_out = pim_if_find_by_vif_index(oif_vif_index);
  1779. pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - c_oil->oif_creation[oif_vif_index]);
  1780. proto[0] = '\0';
  1781. if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) {
  1782. strcat(proto, "P");
  1783. }
  1784. if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_IGMP) {
  1785. strcat(proto, "I");
  1786. }
  1787. vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
  1788. source_str,
  1789. group_str,
  1790. proto,
  1791. ifp_in ? ifp_in->name : "<iif?>",
  1792. c_oil->oil.mfcc_parent,
  1793. ifp_out ? ifp_out->name : "<oif?>",
  1794. oif_vif_index,
  1795. ttl,
  1796. oif_uptime,
  1797. VTY_NEWLINE);
  1798. }
  1799. }
  1800. /* Print list of static routes */
  1801. for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
  1802. char group_str[100];
  1803. char source_str[100];
  1804. int oif_vif_index;
  1805. pim_inet4_dump("<group?>", s_route->group, group_str, sizeof(group_str));
  1806. pim_inet4_dump("<source?>", s_route->source, source_str, sizeof(source_str));
  1807. for (oif_vif_index = 0; oif_vif_index < MAXVIFS; ++oif_vif_index) {
  1808. struct interface *ifp_in;
  1809. struct interface *ifp_out;
  1810. char oif_uptime[10];
  1811. int ttl;
  1812. char proto[5];
  1813. ttl = s_route->oif_ttls[oif_vif_index];
  1814. if (ttl < 1)
  1815. continue;
  1816. ifp_in = pim_if_find_by_vif_index(s_route->iif);
  1817. ifp_out = pim_if_find_by_vif_index(oif_vif_index);
  1818. pim_time_uptime(oif_uptime, sizeof(oif_uptime), now - s_route->creation[oif_vif_index]);
  1819. proto[0] = '\0';
  1820. strcat(proto, "S");
  1821. vty_out(vty, "%-15s %-15s %-5s %-5s %5d %-6s %5d %3d %8s %s",
  1822. source_str,
  1823. group_str,
  1824. proto,
  1825. ifp_in ? ifp_in->name : "<iif?>",
  1826. s_route->iif,
  1827. ifp_out ? ifp_out->name : "<oif?>",
  1828. oif_vif_index,
  1829. ttl,
  1830. oif_uptime,
  1831. VTY_NEWLINE);
  1832. }
  1833. }
  1834. }
  1835. DEFUN (show_ip_mroute,
  1836. show_ip_mroute_cmd,
  1837. "show ip mroute",
  1838. SHOW_STR
  1839. IP_STR
  1840. MROUTE_STR)
  1841. {
  1842. show_mroute(vty);
  1843. return CMD_SUCCESS;
  1844. }
  1845. static void show_mroute_count(struct vty *vty)
  1846. {
  1847. struct listnode *node;
  1848. struct channel_oil *c_oil;
  1849. struct static_route *s_route;
  1850. vty_out(vty, "%s", VTY_NEWLINE);
  1851. vty_out(vty, "Source Group Packets Bytes WrongIf %s",
  1852. VTY_NEWLINE);
  1853. /* Print PIM and IGMP route counts */
  1854. for (ALL_LIST_ELEMENTS_RO(qpim_channel_oil_list, node, c_oil)) {
  1855. char group_str[100];
  1856. char source_str[100];
  1857. struct sioc_sg_req sgreq;
  1858. memset(&sgreq, 0, sizeof(sgreq));
  1859. sgreq.src = c_oil->oil.mfcc_origin;
  1860. sgreq.grp = c_oil->oil.mfcc_mcastgrp;
  1861. pim_inet4_dump("<group?>", c_oil->oil.mfcc_mcastgrp, group_str, sizeof(group_str));
  1862. pim_inet4_dump("<source?>", c_oil->oil.mfcc_origin, source_str, sizeof(source_str));
  1863. if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
  1864. int e = errno;
  1865. vty_out(vty,
  1866. "ioctl(SIOCGETSGCNT=%lu) failure for (S,G)=(%s,%s): errno=%d: %s%s",
  1867. (unsigned long)SIOCGETSGCNT,
  1868. source_str,
  1869. group_str,
  1870. e,
  1871. safe_strerror(e),
  1872. VTY_NEWLINE);
  1873. continue;
  1874. }
  1875. vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
  1876. source_str,
  1877. group_str,
  1878. sgreq.pktcnt,
  1879. sgreq.bytecnt,
  1880. sgreq.wrong_if,
  1881. VTY_NEWLINE);
  1882. }
  1883. /* Print static route counts */
  1884. for (ALL_LIST_ELEMENTS_RO(qpim_static_route_list, node, s_route)) {
  1885. char group_str[100];
  1886. char source_str[100];
  1887. struct sioc_sg_req sgreq;
  1888. memset(&sgreq, 0, sizeof(sgreq));
  1889. sgreq.src = s_route->mc.mfcc_origin;
  1890. sgreq.grp = s_route->mc.mfcc_mcastgrp;
  1891. pim_inet4_dump("<group?>", s_route->mc.mfcc_mcastgrp, group_str, sizeof(group_str));
  1892. pim_inet4_dump("<source?>", s_route->mc.mfcc_origin, source_str, sizeof(source_str));
  1893. if (ioctl(qpim_mroute_socket_fd, SIOCGETSGCNT, &sgreq)) {
  1894. int e = errno;
  1895. vty_out(vty,
  1896. "ioctl(SIOCGETSGCNT=%d) failure for (S,G)=(%s,%s): errno=%d: %s%s",
  1897. SIOCGETSGCNT,
  1898. source_str,
  1899. group_str,
  1900. e,
  1901. safe_strerror(e),
  1902. VTY_NEWLINE);
  1903. continue;
  1904. }
  1905. vty_out(vty, "%-15s %-15s %7ld %10ld %7ld %s",
  1906. source_str,
  1907. group_str,
  1908. sgreq.pktcnt,
  1909. sgreq.bytecnt,
  1910. sgreq.wrong_if,
  1911. VTY_NEWLINE);
  1912. }
  1913. }
  1914. DEFUN (show_ip_mroute_count,
  1915. show_ip_mroute_count_cmd,
  1916. "show ip mroute count",
  1917. SHOW_STR
  1918. IP_STR
  1919. MROUTE_STR
  1920. "Route and packet count data\n")
  1921. {
  1922. show_mroute_count(vty);
  1923. return CMD_SUCCESS;
  1924. }
  1925. DEFUN (show_ip_rib,
  1926. show_ip_rib_cmd,
  1927. "show ip rib A.B.C.D",
  1928. SHOW_STR
  1929. IP_STR
  1930. RIB_STR
  1931. "Unicast address\n")
  1932. {
  1933. struct in_addr addr;
  1934. const char *addr_str;
  1935. struct pim_nexthop nexthop;
  1936. char nexthop_addr_str[100];
  1937. int result;
  1938. addr_str = argv[0];
  1939. result = inet_pton(AF_INET, addr_str, &addr);
  1940. if (result <= 0) {
  1941. vty_out(vty, "Bad unicast address %s: errno=%d: %s%s",
  1942. addr_str, errno, safe_strerror(errno), VTY_NEWLINE);
  1943. return CMD_WARNING;
  1944. }
  1945. if (pim_nexthop_lookup(&nexthop, addr)) {
  1946. vty_out(vty, "Failure querying RIB nexthop for unicast address %s%s",
  1947. addr_str, VTY_NEWLINE);
  1948. return CMD_WARNING;
  1949. }
  1950. vty_out(vty, "Address NextHop Interface Metric Preference%s",
  1951. VTY_NEWLINE);
  1952. pim_inet4_dump("<nexthop?>", nexthop.mrib_nexthop_addr,
  1953. nexthop_addr_str, sizeof(nexthop_addr_str));
  1954. vty_out(vty, "%-15s %-15s %-9s %6d %10d%s",
  1955. addr_str,
  1956. nexthop_addr_str,
  1957. nexthop.interface ? nexthop.interface->name : "<ifname?>",
  1958. nexthop.mrib_route_metric,
  1959. nexthop.mrib_metric_preference,
  1960. VTY_NEWLINE);
  1961. return CMD_SUCCESS;
  1962. }
  1963. static void show_ssmpingd(struct vty *vty)
  1964. {
  1965. struct listnode *node;
  1966. struct ssmpingd_sock *ss;
  1967. time_t now;
  1968. vty_out(vty, "Source Socket Address Port Uptime Requests%s",
  1969. VTY_NEWLINE);
  1970. if (!qpim_ssmpingd_list)
  1971. return;
  1972. now = pim_time_monotonic_sec();
  1973. for (ALL_LIST_ELEMENTS_RO(qpim_ssmpingd_list, node, ss)) {
  1974. char source_str[100];
  1975. char ss_uptime[10];
  1976. struct sockaddr_in bind_addr;
  1977. socklen_t len = sizeof(bind_addr);
  1978. char bind_addr_str[100];
  1979. pim_inet4_dump("<src?>", ss->source_addr, source_str, sizeof(source_str));
  1980. if (pim_socket_getsockname(ss->sock_fd, (struct sockaddr *) &bind_addr, &len)) {
  1981. vty_out(vty, "%% Failure reading socket name for ssmpingd source %s on fd=%d%s",
  1982. source_str, ss->sock_fd, VTY_NEWLINE);
  1983. }
  1984. pim_inet4_dump("<addr?>", bind_addr.sin_addr, bind_addr_str, sizeof(bind_addr_str));
  1985. pim_time_uptime(ss_uptime, sizeof(ss_uptime), now - ss->creation);
  1986. vty_out(vty, "%-15s %6d %-15s %5d %8s %8lld%s",
  1987. source_str,
  1988. ss->sock_fd,
  1989. bind_addr_str,
  1990. ntohs(bind_addr.sin_port),
  1991. ss_uptime,
  1992. (long long)ss->requests,
  1993. VTY_NEWLINE);
  1994. }
  1995. }
  1996. DEFUN (show_ip_ssmpingd,
  1997. show_ip_ssmpingd_cmd,
  1998. "show ip ssmpingd",
  1999. SHOW_STR
  2000. IP_STR
  2001. SHOW_SSMPINGD_STR)
  2002. {
  2003. show_ssmpingd(vty);
  2004. return CMD_SUCCESS;
  2005. }
  2006. DEFUN (ip_multicast_routing,
  2007. ip_multicast_routing_cmd,
  2008. PIM_CMD_IP_MULTICAST_ROUTING,
  2009. IP_STR
  2010. "Enable IP multicast forwarding\n")
  2011. {
  2012. pim_mroute_socket_enable();
  2013. pim_if_add_vif_all();
  2014. mroute_add_all();
  2015. static_mroute_add_all();
  2016. return CMD_SUCCESS;
  2017. }
  2018. DEFUN (no_ip_multicast_routing,
  2019. no_ip_multicast_routing_cmd,
  2020. PIM_CMD_NO " " PIM_CMD_IP_MULTICAST_ROUTING,
  2021. NO_STR
  2022. IP_STR
  2023. "Global IP configuration subcommands\n"
  2024. "Enable IP multicast forwarding\n")
  2025. {
  2026. mroute_del_all();
  2027. static_mroute_del_all();
  2028. pim_if_del_vif_all();
  2029. pim_mroute_socket_disable();
  2030. return CMD_SUCCESS;
  2031. }
  2032. DEFUN (ip_ssmpingd,
  2033. ip_ssmpingd_cmd,
  2034. "ip ssmpingd [A.B.C.D]",
  2035. IP_STR
  2036. CONF_SSMPINGD_STR
  2037. "Source address\n")
  2038. {
  2039. int result;
  2040. struct in_addr source_addr;
  2041. const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
  2042. result = inet_pton(AF_INET, source_str, &source_addr);
  2043. if (result <= 0) {
  2044. vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
  2045. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2046. return CMD_WARNING;
  2047. }
  2048. result = pim_ssmpingd_start(source_addr);
  2049. if (result) {
  2050. vty_out(vty, "%% Failure starting ssmpingd for source %s: %d%s",
  2051. source_str, result, VTY_NEWLINE);
  2052. return CMD_WARNING;
  2053. }
  2054. return CMD_SUCCESS;
  2055. }
  2056. DEFUN (no_ip_ssmpingd,
  2057. no_ip_ssmpingd_cmd,
  2058. "no ip ssmpingd [A.B.C.D]",
  2059. NO_STR
  2060. IP_STR
  2061. CONF_SSMPINGD_STR
  2062. "Source address\n")
  2063. {
  2064. int result;
  2065. struct in_addr source_addr;
  2066. const char *source_str = (argc > 0) ? argv[0] : "0.0.0.0";
  2067. result = inet_pton(AF_INET, source_str, &source_addr);
  2068. if (result <= 0) {
  2069. vty_out(vty, "%% Bad source address %s: errno=%d: %s%s",
  2070. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2071. return CMD_WARNING;
  2072. }
  2073. result = pim_ssmpingd_stop(source_addr);
  2074. if (result) {
  2075. vty_out(vty, "%% Failure stopping ssmpingd for source %s: %d%s",
  2076. source_str, result, VTY_NEWLINE);
  2077. return CMD_WARNING;
  2078. }
  2079. return CMD_SUCCESS;
  2080. }
  2081. DEFUN (interface_ip_igmp,
  2082. interface_ip_igmp_cmd,
  2083. "ip igmp",
  2084. IP_STR
  2085. IFACE_IGMP_STR)
  2086. {
  2087. struct interface *ifp;
  2088. struct pim_interface *pim_ifp;
  2089. ifp = vty->index;
  2090. pim_ifp = ifp->info;
  2091. if (!pim_ifp) {
  2092. pim_ifp = pim_if_new(ifp, 1 /* igmp=true */, 0 /* pim=false */);
  2093. if (!pim_ifp) {
  2094. vty_out(vty, "Could not enable IGMP on interface %s%s",
  2095. ifp->name, VTY_NEWLINE);
  2096. return CMD_WARNING;
  2097. }
  2098. }
  2099. else {
  2100. PIM_IF_DO_IGMP(pim_ifp->options);
  2101. }
  2102. pim_if_addr_add_all(ifp);
  2103. pim_if_membership_refresh(ifp);
  2104. return CMD_SUCCESS;
  2105. }
  2106. DEFUN (interface_no_ip_igmp,
  2107. interface_no_ip_igmp_cmd,
  2108. "no ip igmp",
  2109. NO_STR
  2110. IP_STR
  2111. IFACE_IGMP_STR)
  2112. {
  2113. struct interface *ifp;
  2114. struct pim_interface *pim_ifp;
  2115. ifp = vty->index;
  2116. pim_ifp = ifp->info;
  2117. if (!pim_ifp)
  2118. return CMD_SUCCESS;
  2119. PIM_IF_DONT_IGMP(pim_ifp->options);
  2120. pim_if_membership_clear(ifp);
  2121. pim_if_addr_del_all_igmp(ifp);
  2122. if (!PIM_IF_TEST_PIM(pim_ifp->options)) {
  2123. pim_if_delete(ifp);
  2124. }
  2125. return CMD_SUCCESS;
  2126. }
  2127. DEFUN (interface_ip_igmp_join,
  2128. interface_ip_igmp_join_cmd,
  2129. "ip igmp join A.B.C.D A.B.C.D",
  2130. IP_STR
  2131. IFACE_IGMP_STR
  2132. "IGMP join multicast group\n"
  2133. "Multicast group address\n"
  2134. "Source address\n")
  2135. {
  2136. struct interface *ifp;
  2137. const char *group_str;
  2138. const char *source_str;
  2139. struct in_addr group_addr;
  2140. struct in_addr source_addr;
  2141. int result;
  2142. ifp = vty->index;
  2143. /* Group address */
  2144. group_str = argv[0];
  2145. result = inet_pton(AF_INET, group_str, &group_addr);
  2146. if (result <= 0) {
  2147. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2148. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2149. return CMD_WARNING;
  2150. }
  2151. /* Source address */
  2152. source_str = argv[1];
  2153. result = inet_pton(AF_INET, source_str, &source_addr);
  2154. if (result <= 0) {
  2155. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  2156. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2157. return CMD_WARNING;
  2158. }
  2159. result = pim_if_igmp_join_add(ifp, group_addr, source_addr);
  2160. if (result) {
  2161. vty_out(vty, "%% Failure joining IGMP group %s source %s on interface %s: %d%s",
  2162. group_str, source_str, ifp->name, result, VTY_NEWLINE);
  2163. return CMD_WARNING;
  2164. }
  2165. return CMD_SUCCESS;
  2166. }
  2167. DEFUN (interface_no_ip_igmp_join,
  2168. interface_no_ip_igmp_join_cmd,
  2169. "no ip igmp join A.B.C.D A.B.C.D",
  2170. NO_STR
  2171. IP_STR
  2172. IFACE_IGMP_STR
  2173. "IGMP join multicast group\n"
  2174. "Multicast group address\n"
  2175. "Source address\n")
  2176. {
  2177. struct interface *ifp;
  2178. const char *group_str;
  2179. const char *source_str;
  2180. struct in_addr group_addr;
  2181. struct in_addr source_addr;
  2182. int result;
  2183. ifp = vty->index;
  2184. /* Group address */
  2185. group_str = argv[0];
  2186. result = inet_pton(AF_INET, group_str, &group_addr);
  2187. if (result <= 0) {
  2188. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2189. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2190. return CMD_WARNING;
  2191. }
  2192. /* Source address */
  2193. source_str = argv[1];
  2194. result = inet_pton(AF_INET, source_str, &source_addr);
  2195. if (result <= 0) {
  2196. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  2197. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2198. return CMD_WARNING;
  2199. }
  2200. result = pim_if_igmp_join_del(ifp, group_addr, source_addr);
  2201. if (result) {
  2202. vty_out(vty, "%% Failure leaving IGMP group %s source %s on interface %s: %d%s",
  2203. group_str, source_str, ifp->name, result, VTY_NEWLINE);
  2204. return CMD_WARNING;
  2205. }
  2206. return CMD_SUCCESS;
  2207. }
  2208. /*
  2209. CLI reconfiguration affects the interface level (struct pim_interface).
  2210. This function propagates the reconfiguration to every active socket
  2211. for that interface.
  2212. */
  2213. static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp)
  2214. {
  2215. struct interface *ifp;
  2216. struct pim_interface *pim_ifp;
  2217. zassert(igmp);
  2218. /* other querier present? */
  2219. if (igmp->t_other_querier_timer)
  2220. return;
  2221. /* this is the querier */
  2222. zassert(igmp->interface);
  2223. zassert(igmp->interface->info);
  2224. ifp = igmp->interface;
  2225. pim_ifp = ifp->info;
  2226. if (PIM_DEBUG_IGMP_TRACE) {
  2227. char ifaddr_str[100];
  2228. pim_inet4_dump("<ifaddr?>", igmp->ifaddr, ifaddr_str, sizeof(ifaddr_str));
  2229. zlog_debug("%s: Querier %s on %s reconfig query_interval=%d",
  2230. __PRETTY_FUNCTION__,
  2231. ifaddr_str,
  2232. ifp->name,
  2233. pim_ifp->igmp_default_query_interval);
  2234. }
  2235. /*
  2236. igmp_startup_mode_on() will reset QQI:
  2237. igmp->querier_query_interval = pim_ifp->igmp_default_query_interval;
  2238. */
  2239. igmp_startup_mode_on(igmp);
  2240. }
  2241. static void igmp_sock_query_reschedule(struct igmp_sock *igmp)
  2242. {
  2243. if (igmp->t_igmp_query_timer) {
  2244. /* other querier present */
  2245. zassert(igmp->t_igmp_query_timer);
  2246. zassert(!igmp->t_other_querier_timer);
  2247. pim_igmp_general_query_off(igmp);
  2248. pim_igmp_general_query_on(igmp);
  2249. zassert(igmp->t_igmp_query_timer);
  2250. zassert(!igmp->t_other_querier_timer);
  2251. }
  2252. else {
  2253. /* this is the querier */
  2254. zassert(!igmp->t_igmp_query_timer);
  2255. zassert(igmp->t_other_querier_timer);
  2256. pim_igmp_other_querier_timer_off(igmp);
  2257. pim_igmp_other_querier_timer_on(igmp);
  2258. zassert(!igmp->t_igmp_query_timer);
  2259. zassert(igmp->t_other_querier_timer);
  2260. }
  2261. }
  2262. static void change_query_interval(struct pim_interface *pim_ifp,
  2263. int query_interval)
  2264. {
  2265. struct listnode *sock_node;
  2266. struct igmp_sock *igmp;
  2267. pim_ifp->igmp_default_query_interval = query_interval;
  2268. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  2269. igmp_sock_query_interval_reconfig(igmp);
  2270. igmp_sock_query_reschedule(igmp);
  2271. }
  2272. }
  2273. static void change_query_max_response_time(struct pim_interface *pim_ifp,
  2274. int query_max_response_time_dsec)
  2275. {
  2276. struct listnode *sock_node;
  2277. struct igmp_sock *igmp;
  2278. pim_ifp->igmp_query_max_response_time_dsec = query_max_response_time_dsec;
  2279. /*
  2280. Below we modify socket/group/source timers in order to quickly
  2281. reflect the change. Otherwise, those timers would eventually catch
  2282. up.
  2283. */
  2284. /* scan all sockets */
  2285. for (ALL_LIST_ELEMENTS_RO(pim_ifp->igmp_socket_list, sock_node, igmp)) {
  2286. struct listnode *grp_node;
  2287. struct igmp_group *grp;
  2288. /* reschedule socket general query */
  2289. igmp_sock_query_reschedule(igmp);
  2290. /* scan socket groups */
  2291. for (ALL_LIST_ELEMENTS_RO(igmp->igmp_group_list, grp_node, grp)) {
  2292. struct listnode *src_node;
  2293. struct igmp_source *src;
  2294. /* reset group timers for groups in EXCLUDE mode */
  2295. if (grp->group_filtermode_isexcl) {
  2296. igmp_group_reset_gmi(grp);
  2297. }
  2298. /* scan group sources */
  2299. for (ALL_LIST_ELEMENTS_RO(grp->group_source_list, src_node, src)) {
  2300. /* reset source timers for sources with running timers */
  2301. if (src->t_source_timer) {
  2302. igmp_source_reset_gmi(igmp, grp, src);
  2303. }
  2304. }
  2305. }
  2306. }
  2307. }
  2308. #define IGMP_QUERY_INTERVAL_MIN (1)
  2309. #define IGMP_QUERY_INTERVAL_MAX (1800)
  2310. DEFUN (interface_ip_igmp_query_interval,
  2311. interface_ip_igmp_query_interval_cmd,
  2312. PIM_CMD_IP_IGMP_QUERY_INTERVAL " <1-1800>",
  2313. IP_STR
  2314. IFACE_IGMP_STR
  2315. IFACE_IGMP_QUERY_INTERVAL_STR
  2316. "Query interval in seconds\n")
  2317. {
  2318. struct interface *ifp;
  2319. struct pim_interface *pim_ifp;
  2320. int query_interval;
  2321. int query_interval_dsec;
  2322. ifp = vty->index;
  2323. pim_ifp = ifp->info;
  2324. if (!pim_ifp) {
  2325. vty_out(vty,
  2326. "IGMP not enabled on interface %s. Please enable IGMP first.%s",
  2327. ifp->name,
  2328. VTY_NEWLINE);
  2329. return CMD_WARNING;
  2330. }
  2331. query_interval = atoi(argv[0]);
  2332. query_interval_dsec = 10 * query_interval;
  2333. /*
  2334. It seems we don't need to check bounds since command.c does it
  2335. already, but we verify them anyway for extra safety.
  2336. */
  2337. if (query_interval < IGMP_QUERY_INTERVAL_MIN) {
  2338. vty_out(vty, "General query interval %d lower than minimum %d%s",
  2339. query_interval,
  2340. IGMP_QUERY_INTERVAL_MIN,
  2341. VTY_NEWLINE);
  2342. return CMD_WARNING;
  2343. }
  2344. if (query_interval > IGMP_QUERY_INTERVAL_MAX) {
  2345. vty_out(vty, "General query interval %d higher than maximum %d%s",
  2346. query_interval,
  2347. IGMP_QUERY_INTERVAL_MAX,
  2348. VTY_NEWLINE);
  2349. return CMD_WARNING;
  2350. }
  2351. if (query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
  2352. vty_out(vty,
  2353. "Can't set general query interval %d dsec <= query max response time %d dsec.%s",
  2354. query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
  2355. VTY_NEWLINE);
  2356. return CMD_WARNING;
  2357. }
  2358. change_query_interval(pim_ifp, query_interval);
  2359. return CMD_SUCCESS;
  2360. }
  2361. DEFUN (interface_no_ip_igmp_query_interval,
  2362. interface_no_ip_igmp_query_interval_cmd,
  2363. PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_INTERVAL,
  2364. NO_STR
  2365. IP_STR
  2366. IFACE_IGMP_STR
  2367. IFACE_IGMP_QUERY_INTERVAL_STR)
  2368. {
  2369. struct interface *ifp;
  2370. struct pim_interface *pim_ifp;
  2371. int default_query_interval_dsec;
  2372. ifp = vty->index;
  2373. pim_ifp = ifp->info;
  2374. if (!pim_ifp)
  2375. return CMD_SUCCESS;
  2376. default_query_interval_dsec = IGMP_GENERAL_QUERY_INTERVAL * 10;
  2377. if (default_query_interval_dsec <= pim_ifp->igmp_query_max_response_time_dsec) {
  2378. vty_out(vty,
  2379. "Can't set default general query interval %d dsec <= query max response time %d dsec.%s",
  2380. default_query_interval_dsec, pim_ifp->igmp_query_max_response_time_dsec,
  2381. VTY_NEWLINE);
  2382. return CMD_WARNING;
  2383. }
  2384. change_query_interval(pim_ifp, IGMP_GENERAL_QUERY_INTERVAL);
  2385. return CMD_SUCCESS;
  2386. }
  2387. #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN (1)
  2388. #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX (25)
  2389. DEFUN (interface_ip_igmp_query_max_response_time,
  2390. interface_ip_igmp_query_max_response_time_cmd,
  2391. PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME " <1-25>",
  2392. IP_STR
  2393. IFACE_IGMP_STR
  2394. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR
  2395. "Query response value in seconds\n")
  2396. {
  2397. struct interface *ifp;
  2398. struct pim_interface *pim_ifp;
  2399. int query_max_response_time;
  2400. ifp = vty->index;
  2401. pim_ifp = ifp->info;
  2402. if (!pim_ifp) {
  2403. vty_out(vty,
  2404. "IGMP not enabled on interface %s. Please enable IGMP first.%s",
  2405. ifp->name,
  2406. VTY_NEWLINE);
  2407. return CMD_WARNING;
  2408. }
  2409. query_max_response_time = atoi(argv[0]);
  2410. /*
  2411. It seems we don't need to check bounds since command.c does it
  2412. already, but we verify them anyway for extra safety.
  2413. */
  2414. if (query_max_response_time < IGMP_QUERY_MAX_RESPONSE_TIME_MIN) {
  2415. vty_out(vty, "Query max response time %d sec lower than minimum %d sec%s",
  2416. query_max_response_time,
  2417. IGMP_QUERY_MAX_RESPONSE_TIME_MIN,
  2418. VTY_NEWLINE);
  2419. return CMD_WARNING;
  2420. }
  2421. if (query_max_response_time > IGMP_QUERY_MAX_RESPONSE_TIME_MAX) {
  2422. vty_out(vty, "Query max response time %d sec higher than maximum %d sec%s",
  2423. query_max_response_time,
  2424. IGMP_QUERY_MAX_RESPONSE_TIME_MAX,
  2425. VTY_NEWLINE);
  2426. return CMD_WARNING;
  2427. }
  2428. if (query_max_response_time >= pim_ifp->igmp_default_query_interval) {
  2429. vty_out(vty,
  2430. "Can't set query max response time %d sec >= general query interval %d sec%s",
  2431. query_max_response_time, pim_ifp->igmp_default_query_interval,
  2432. VTY_NEWLINE);
  2433. return CMD_WARNING;
  2434. }
  2435. change_query_max_response_time(pim_ifp, 10 * query_max_response_time);
  2436. return CMD_SUCCESS;
  2437. }
  2438. DEFUN (interface_no_ip_igmp_query_max_response_time,
  2439. interface_no_ip_igmp_query_max_response_time_cmd,
  2440. PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME,
  2441. NO_STR
  2442. IP_STR
  2443. IFACE_IGMP_STR
  2444. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_STR)
  2445. {
  2446. struct interface *ifp;
  2447. struct pim_interface *pim_ifp;
  2448. int default_query_interval_dsec;
  2449. ifp = vty->index;
  2450. pim_ifp = ifp->info;
  2451. if (!pim_ifp)
  2452. return CMD_SUCCESS;
  2453. default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
  2454. if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
  2455. vty_out(vty,
  2456. "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
  2457. IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
  2458. VTY_NEWLINE);
  2459. return CMD_WARNING;
  2460. }
  2461. change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
  2462. return CMD_SUCCESS;
  2463. }
  2464. #define IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC (10)
  2465. #define IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC (250)
  2466. DEFUN (interface_ip_igmp_query_max_response_time_dsec,
  2467. interface_ip_igmp_query_max_response_time_dsec_cmd,
  2468. PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC " <10-250>",
  2469. IP_STR
  2470. IFACE_IGMP_STR
  2471. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR
  2472. "Query response value in deciseconds\n")
  2473. {
  2474. struct interface *ifp;
  2475. struct pim_interface *pim_ifp;
  2476. int query_max_response_time_dsec;
  2477. int default_query_interval_dsec;
  2478. ifp = vty->index;
  2479. pim_ifp = ifp->info;
  2480. if (!pim_ifp) {
  2481. vty_out(vty,
  2482. "IGMP not enabled on interface %s. Please enable IGMP first.%s",
  2483. ifp->name,
  2484. VTY_NEWLINE);
  2485. return CMD_WARNING;
  2486. }
  2487. query_max_response_time_dsec = atoi(argv[0]);
  2488. /*
  2489. It seems we don't need to check bounds since command.c does it
  2490. already, but we verify them anyway for extra safety.
  2491. */
  2492. if (query_max_response_time_dsec < IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC) {
  2493. vty_out(vty, "Query max response time %d dsec lower than minimum %d dsec%s",
  2494. query_max_response_time_dsec,
  2495. IGMP_QUERY_MAX_RESPONSE_TIME_MIN_DSEC,
  2496. VTY_NEWLINE);
  2497. return CMD_WARNING;
  2498. }
  2499. if (query_max_response_time_dsec > IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC) {
  2500. vty_out(vty, "Query max response time %d dsec higher than maximum %d dsec%s",
  2501. query_max_response_time_dsec,
  2502. IGMP_QUERY_MAX_RESPONSE_TIME_MAX_DSEC,
  2503. VTY_NEWLINE);
  2504. return CMD_WARNING;
  2505. }
  2506. default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
  2507. if (query_max_response_time_dsec >= default_query_interval_dsec) {
  2508. vty_out(vty,
  2509. "Can't set query max response time %d dsec >= general query interval %d dsec%s",
  2510. query_max_response_time_dsec, default_query_interval_dsec,
  2511. VTY_NEWLINE);
  2512. return CMD_WARNING;
  2513. }
  2514. change_query_max_response_time(pim_ifp, query_max_response_time_dsec);
  2515. return CMD_SUCCESS;
  2516. }
  2517. DEFUN (interface_no_ip_igmp_query_max_response_time_dsec,
  2518. interface_no_ip_igmp_query_max_response_time_dsec_cmd,
  2519. PIM_CMD_NO " " PIM_CMD_IP_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC,
  2520. NO_STR
  2521. IP_STR
  2522. IFACE_IGMP_STR
  2523. IFACE_IGMP_QUERY_MAX_RESPONSE_TIME_DSEC_STR)
  2524. {
  2525. struct interface *ifp;
  2526. struct pim_interface *pim_ifp;
  2527. int default_query_interval_dsec;
  2528. ifp = vty->index;
  2529. pim_ifp = ifp->info;
  2530. if (!pim_ifp)
  2531. return CMD_SUCCESS;
  2532. default_query_interval_dsec = 10 * pim_ifp->igmp_default_query_interval;
  2533. if (IGMP_QUERY_MAX_RESPONSE_TIME_DSEC >= default_query_interval_dsec) {
  2534. vty_out(vty,
  2535. "Can't set default query max response time %d dsec >= general query interval %d dsec.%s",
  2536. IGMP_QUERY_MAX_RESPONSE_TIME_DSEC, default_query_interval_dsec,
  2537. VTY_NEWLINE);
  2538. return CMD_WARNING;
  2539. }
  2540. change_query_max_response_time(pim_ifp, IGMP_QUERY_MAX_RESPONSE_TIME_DSEC);
  2541. return CMD_SUCCESS;
  2542. }
  2543. DEFUN (interface_ip_pim_ssm,
  2544. interface_ip_pim_ssm_cmd,
  2545. "ip pim ssm",
  2546. IP_STR
  2547. PIM_STR
  2548. IFACE_PIM_STR)
  2549. {
  2550. struct interface *ifp;
  2551. struct pim_interface *pim_ifp;
  2552. ifp = vty->index;
  2553. pim_ifp = ifp->info;
  2554. if (!pim_ifp) {
  2555. pim_ifp = pim_if_new(ifp, 0 /* igmp=false */, 1 /* pim=true */);
  2556. if (!pim_ifp) {
  2557. vty_out(vty, "Could not enable PIM on interface%s", VTY_NEWLINE);
  2558. return CMD_WARNING;
  2559. }
  2560. }
  2561. else {
  2562. PIM_IF_DO_PIM(pim_ifp->options);
  2563. }
  2564. pim_if_addr_add_all(ifp);
  2565. pim_if_membership_refresh(ifp);
  2566. return CMD_SUCCESS;
  2567. }
  2568. DEFUN (interface_no_ip_pim_ssm,
  2569. interface_no_ip_pim_ssm_cmd,
  2570. "no ip pim ssm",
  2571. NO_STR
  2572. IP_STR
  2573. PIM_STR
  2574. IFACE_PIM_STR)
  2575. {
  2576. struct interface *ifp;
  2577. struct pim_interface *pim_ifp;
  2578. ifp = vty->index;
  2579. pim_ifp = ifp->info;
  2580. if (!pim_ifp)
  2581. return CMD_SUCCESS;
  2582. PIM_IF_DONT_PIM(pim_ifp->options);
  2583. pim_if_membership_clear(ifp);
  2584. /*
  2585. pim_if_addr_del_all() removes all sockets from
  2586. pim_ifp->igmp_socket_list.
  2587. */
  2588. pim_if_addr_del_all(ifp);
  2589. /*
  2590. pim_sock_delete() removes all neighbors from
  2591. pim_ifp->pim_neighbor_list.
  2592. */
  2593. pim_sock_delete(ifp, "pim unconfigured on interface");
  2594. if (!PIM_IF_TEST_IGMP(pim_ifp->options)) {
  2595. pim_if_delete(ifp);
  2596. }
  2597. return CMD_SUCCESS;
  2598. }
  2599. DEFUN (interface_ip_mroute,
  2600. interface_ip_mroute_cmd,
  2601. "ip mroute INTERFACE A.B.C.D",
  2602. IP_STR
  2603. "Add multicast route\n"
  2604. "Outgoing interface name\n"
  2605. "Group address\n")
  2606. {
  2607. struct interface *iif;
  2608. struct interface *oif;
  2609. const char *oifname;
  2610. const char *grp_str;
  2611. struct in_addr grp_addr;
  2612. struct in_addr src_addr;
  2613. int result;
  2614. iif = vty->index;
  2615. oifname = argv[0];
  2616. oif = if_lookup_by_name(oifname);
  2617. if (!oif) {
  2618. vty_out(vty, "No such interface name %s%s",
  2619. oifname, VTY_NEWLINE);
  2620. return CMD_WARNING;
  2621. }
  2622. grp_str = argv[1];
  2623. result = inet_pton(AF_INET, grp_str, &grp_addr);
  2624. if (result <= 0) {
  2625. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2626. grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2627. return CMD_WARNING;
  2628. }
  2629. src_addr.s_addr = INADDR_ANY;
  2630. if (pim_static_add(iif, oif, grp_addr, src_addr)) {
  2631. vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
  2632. return CMD_WARNING;
  2633. }
  2634. return CMD_SUCCESS;
  2635. }
  2636. DEFUN (interface_ip_mroute_source,
  2637. interface_ip_mroute_source_cmd,
  2638. "ip mroute INTERFACE A.B.C.D A.B.C.D",
  2639. IP_STR
  2640. "Add multicast route\n"
  2641. "Outgoing interface name\n"
  2642. "Group address\n"
  2643. "Source address\n")
  2644. {
  2645. struct interface *iif;
  2646. struct interface *oif;
  2647. const char *oifname;
  2648. const char *grp_str;
  2649. struct in_addr grp_addr;
  2650. const char *src_str;
  2651. struct in_addr src_addr;
  2652. int result;
  2653. iif = vty->index;
  2654. oifname = argv[0];
  2655. oif = if_lookup_by_name(oifname);
  2656. if (!oif) {
  2657. vty_out(vty, "No such interface name %s%s",
  2658. oifname, VTY_NEWLINE);
  2659. return CMD_WARNING;
  2660. }
  2661. grp_str = argv[1];
  2662. result = inet_pton(AF_INET, grp_str, &grp_addr);
  2663. if (result <= 0) {
  2664. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2665. grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2666. return CMD_WARNING;
  2667. }
  2668. src_str = argv[2];
  2669. result = inet_pton(AF_INET, src_str, &src_addr);
  2670. if (result <= 0) {
  2671. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  2672. src_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2673. return CMD_WARNING;
  2674. }
  2675. if (pim_static_add(iif, oif, grp_addr, src_addr)) {
  2676. vty_out(vty, "Failed to add route%s", VTY_NEWLINE);
  2677. return CMD_WARNING;
  2678. }
  2679. return CMD_SUCCESS;
  2680. }
  2681. DEFUN (interface_no_ip_mroute,
  2682. interface_no_ip_mroute_cmd,
  2683. "no ip mroute INTERFACE A.B.C.D",
  2684. NO_STR
  2685. IP_STR
  2686. "Add multicast route\n"
  2687. "Outgoing interface name\n"
  2688. "Group Address\n")
  2689. {
  2690. struct interface *iif;
  2691. struct interface *oif;
  2692. const char *oifname;
  2693. const char *grp_str;
  2694. struct in_addr grp_addr;
  2695. struct in_addr src_addr;
  2696. int result;
  2697. iif = vty->index;
  2698. oifname = argv[0];
  2699. oif = if_lookup_by_name(oifname);
  2700. if (!oif) {
  2701. vty_out(vty, "No such interface name %s%s",
  2702. oifname, VTY_NEWLINE);
  2703. return CMD_WARNING;
  2704. }
  2705. grp_str = argv[1];
  2706. result = inet_pton(AF_INET, grp_str, &grp_addr);
  2707. if (result <= 0) {
  2708. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2709. grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2710. return CMD_WARNING;
  2711. }
  2712. src_addr.s_addr = INADDR_ANY;
  2713. if (pim_static_del(iif, oif, grp_addr, src_addr)) {
  2714. vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
  2715. return CMD_WARNING;
  2716. }
  2717. return CMD_SUCCESS;
  2718. }
  2719. DEFUN (interface_no_ip_mroute_source,
  2720. interface_no_ip_mroute_source_cmd,
  2721. "no ip mroute INTERFACE A.B.C.D A.B.C.D",
  2722. NO_STR
  2723. IP_STR
  2724. "Add multicast route\n"
  2725. "Outgoing interface name\n"
  2726. "Group Address\n"
  2727. "Source Address\n")
  2728. {
  2729. struct interface *iif;
  2730. struct interface *oif;
  2731. const char *oifname;
  2732. const char *grp_str;
  2733. struct in_addr grp_addr;
  2734. const char *src_str;
  2735. struct in_addr src_addr;
  2736. int result;
  2737. iif = vty->index;
  2738. oifname = argv[0];
  2739. oif = if_lookup_by_name(oifname);
  2740. if (!oif) {
  2741. vty_out(vty, "No such interface name %s%s",
  2742. oifname, VTY_NEWLINE);
  2743. return CMD_WARNING;
  2744. }
  2745. grp_str = argv[1];
  2746. result = inet_pton(AF_INET, grp_str, &grp_addr);
  2747. if (result <= 0) {
  2748. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  2749. grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2750. return CMD_WARNING;
  2751. }
  2752. src_str = argv[2];
  2753. result = inet_pton(AF_INET, src_str, &src_addr);
  2754. if (result <= 0) {
  2755. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  2756. src_str, errno, safe_strerror(errno), VTY_NEWLINE);
  2757. return CMD_WARNING;
  2758. }
  2759. if (pim_static_del(iif, oif, grp_addr, src_addr)) {
  2760. vty_out(vty, "Failed to remove route%s", VTY_NEWLINE);
  2761. return CMD_WARNING;
  2762. }
  2763. return CMD_SUCCESS;
  2764. }
  2765. DEFUN (debug_igmp,
  2766. debug_igmp_cmd,
  2767. "debug igmp",
  2768. DEBUG_STR
  2769. DEBUG_IGMP_STR)
  2770. {
  2771. PIM_DO_DEBUG_IGMP_EVENTS;
  2772. PIM_DO_DEBUG_IGMP_PACKETS;
  2773. PIM_DO_DEBUG_IGMP_TRACE;
  2774. return CMD_SUCCESS;
  2775. }
  2776. DEFUN (no_debug_igmp,
  2777. no_debug_igmp_cmd,
  2778. "no debug igmp",
  2779. NO_STR
  2780. DEBUG_STR
  2781. DEBUG_IGMP_STR)
  2782. {
  2783. PIM_DONT_DEBUG_IGMP_EVENTS;
  2784. PIM_DONT_DEBUG_IGMP_PACKETS;
  2785. PIM_DONT_DEBUG_IGMP_TRACE;
  2786. return CMD_SUCCESS;
  2787. }
  2788. ALIAS (no_debug_igmp,
  2789. undebug_igmp_cmd,
  2790. "undebug igmp",
  2791. UNDEBUG_STR
  2792. DEBUG_IGMP_STR)
  2793. DEFUN (debug_igmp_events,
  2794. debug_igmp_events_cmd,
  2795. "debug igmp events",
  2796. DEBUG_STR
  2797. DEBUG_IGMP_STR
  2798. DEBUG_IGMP_EVENTS_STR)
  2799. {
  2800. PIM_DO_DEBUG_IGMP_EVENTS;
  2801. return CMD_SUCCESS;
  2802. }
  2803. DEFUN (no_debug_igmp_events,
  2804. no_debug_igmp_events_cmd,
  2805. "no debug igmp events",
  2806. NO_STR
  2807. DEBUG_STR
  2808. DEBUG_IGMP_STR
  2809. DEBUG_IGMP_EVENTS_STR)
  2810. {
  2811. PIM_DONT_DEBUG_IGMP_EVENTS;
  2812. return CMD_SUCCESS;
  2813. }
  2814. ALIAS (no_debug_igmp_events,
  2815. undebug_igmp_events_cmd,
  2816. "undebug igmp events",
  2817. UNDEBUG_STR
  2818. DEBUG_IGMP_STR
  2819. DEBUG_IGMP_EVENTS_STR)
  2820. DEFUN (debug_igmp_packets,
  2821. debug_igmp_packets_cmd,
  2822. "debug igmp packets",
  2823. DEBUG_STR
  2824. DEBUG_IGMP_STR
  2825. DEBUG_IGMP_PACKETS_STR)
  2826. {
  2827. PIM_DO_DEBUG_IGMP_PACKETS;
  2828. return CMD_SUCCESS;
  2829. }
  2830. DEFUN (no_debug_igmp_packets,
  2831. no_debug_igmp_packets_cmd,
  2832. "no debug igmp packets",
  2833. NO_STR
  2834. DEBUG_STR
  2835. DEBUG_IGMP_STR
  2836. DEBUG_IGMP_PACKETS_STR)
  2837. {
  2838. PIM_DONT_DEBUG_IGMP_PACKETS;
  2839. return CMD_SUCCESS;
  2840. }
  2841. ALIAS (no_debug_igmp_packets,
  2842. undebug_igmp_packets_cmd,
  2843. "undebug igmp packets",
  2844. UNDEBUG_STR
  2845. DEBUG_IGMP_STR
  2846. DEBUG_IGMP_PACKETS_STR)
  2847. DEFUN (debug_igmp_trace,
  2848. debug_igmp_trace_cmd,
  2849. "debug igmp trace",
  2850. DEBUG_STR
  2851. DEBUG_IGMP_STR
  2852. DEBUG_IGMP_TRACE_STR)
  2853. {
  2854. PIM_DO_DEBUG_IGMP_TRACE;
  2855. return CMD_SUCCESS;
  2856. }
  2857. DEFUN (no_debug_igmp_trace,
  2858. no_debug_igmp_trace_cmd,
  2859. "no debug igmp trace",
  2860. NO_STR
  2861. DEBUG_STR
  2862. DEBUG_IGMP_STR
  2863. DEBUG_IGMP_TRACE_STR)
  2864. {
  2865. PIM_DONT_DEBUG_IGMP_TRACE;
  2866. return CMD_SUCCESS;
  2867. }
  2868. ALIAS (no_debug_igmp_trace,
  2869. undebug_igmp_trace_cmd,
  2870. "undebug igmp trace",
  2871. UNDEBUG_STR
  2872. DEBUG_IGMP_STR
  2873. DEBUG_IGMP_TRACE_STR)
  2874. DEFUN (debug_mroute,
  2875. debug_mroute_cmd,
  2876. "debug mroute",
  2877. DEBUG_STR
  2878. DEBUG_MROUTE_STR)
  2879. {
  2880. PIM_DO_DEBUG_MROUTE;
  2881. return CMD_SUCCESS;
  2882. }
  2883. DEFUN (no_debug_mroute,
  2884. no_debug_mroute_cmd,
  2885. "no debug mroute",
  2886. NO_STR
  2887. DEBUG_STR
  2888. DEBUG_MROUTE_STR)
  2889. {
  2890. PIM_DONT_DEBUG_MROUTE;
  2891. return CMD_SUCCESS;
  2892. }
  2893. ALIAS (no_debug_mroute,
  2894. undebug_mroute_cmd,
  2895. "undebug mroute",
  2896. UNDEBUG_STR
  2897. DEBUG_MROUTE_STR)
  2898. DEFUN (debug_static,
  2899. debug_static_cmd,
  2900. "debug static",
  2901. DEBUG_STR
  2902. DEBUG_STATIC_STR)
  2903. {
  2904. PIM_DO_DEBUG_STATIC;
  2905. return CMD_SUCCESS;
  2906. }
  2907. DEFUN (no_debug_static,
  2908. no_debug_static_cmd,
  2909. "no debug static",
  2910. NO_STR
  2911. DEBUG_STR
  2912. DEBUG_STATIC_STR)
  2913. {
  2914. PIM_DONT_DEBUG_STATIC;
  2915. return CMD_SUCCESS;
  2916. }
  2917. ALIAS (no_debug_static,
  2918. undebug_static_cmd,
  2919. "undebug static",
  2920. UNDEBUG_STR
  2921. DEBUG_STATIC_STR)
  2922. DEFUN (debug_pim,
  2923. debug_pim_cmd,
  2924. "debug pim",
  2925. DEBUG_STR
  2926. DEBUG_PIM_STR)
  2927. {
  2928. PIM_DO_DEBUG_PIM_EVENTS;
  2929. PIM_DO_DEBUG_PIM_PACKETS;
  2930. PIM_DO_DEBUG_PIM_TRACE;
  2931. return CMD_SUCCESS;
  2932. }
  2933. DEFUN (no_debug_pim,
  2934. no_debug_pim_cmd,
  2935. "no debug pim",
  2936. NO_STR
  2937. DEBUG_STR
  2938. DEBUG_PIM_STR)
  2939. {
  2940. PIM_DONT_DEBUG_PIM_EVENTS;
  2941. PIM_DONT_DEBUG_PIM_PACKETS;
  2942. PIM_DONT_DEBUG_PIM_TRACE;
  2943. PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
  2944. PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
  2945. return CMD_SUCCESS;
  2946. }
  2947. ALIAS (no_debug_pim,
  2948. undebug_pim_cmd,
  2949. "undebug pim",
  2950. UNDEBUG_STR
  2951. DEBUG_PIM_STR)
  2952. DEFUN (debug_pim_events,
  2953. debug_pim_events_cmd,
  2954. "debug pim events",
  2955. DEBUG_STR
  2956. DEBUG_PIM_STR
  2957. DEBUG_PIM_EVENTS_STR)
  2958. {
  2959. PIM_DO_DEBUG_PIM_EVENTS;
  2960. return CMD_SUCCESS;
  2961. }
  2962. DEFUN (no_debug_pim_events,
  2963. no_debug_pim_events_cmd,
  2964. "no debug pim events",
  2965. NO_STR
  2966. DEBUG_STR
  2967. DEBUG_PIM_STR
  2968. DEBUG_PIM_EVENTS_STR)
  2969. {
  2970. PIM_DONT_DEBUG_PIM_EVENTS;
  2971. return CMD_SUCCESS;
  2972. }
  2973. ALIAS (no_debug_pim_events,
  2974. undebug_pim_events_cmd,
  2975. "undebug pim events",
  2976. UNDEBUG_STR
  2977. DEBUG_PIM_STR
  2978. DEBUG_PIM_EVENTS_STR)
  2979. DEFUN (debug_pim_packets,
  2980. debug_pim_packets_cmd,
  2981. "debug pim packets",
  2982. DEBUG_STR
  2983. DEBUG_PIM_STR
  2984. DEBUG_PIM_PACKETS_STR)
  2985. {
  2986. PIM_DO_DEBUG_PIM_PACKETS;
  2987. vty_out (vty, "PIM Packet debugging is on %s", VTY_NEWLINE);
  2988. return CMD_SUCCESS;
  2989. }
  2990. DEFUN (debug_pim_packets_filter,
  2991. debug_pim_packets_filter_cmd,
  2992. "debug pim packets (hello|joins)",
  2993. DEBUG_STR
  2994. DEBUG_PIM_STR
  2995. DEBUG_PIM_PACKETS_STR
  2996. DEBUG_PIM_HELLO_PACKETS_STR
  2997. DEBUG_PIM_J_P_PACKETS_STR)
  2998. {
  2999. if (strncmp(argv[0],"h",1) == 0)
  3000. {
  3001. PIM_DO_DEBUG_PIM_HELLO;
  3002. vty_out (vty, "PIM Hello debugging is on %s", VTY_NEWLINE);
  3003. }
  3004. else if (strncmp(argv[0],"j",1) == 0)
  3005. {
  3006. PIM_DO_DEBUG_PIM_J_P;
  3007. vty_out (vty, "PIM Join/Prune debugging is on %s", VTY_NEWLINE);
  3008. }
  3009. return CMD_SUCCESS;
  3010. }
  3011. DEFUN (no_debug_pim_packets,
  3012. no_debug_pim_packets_cmd,
  3013. "no debug pim packets",
  3014. NO_STR
  3015. DEBUG_STR
  3016. DEBUG_PIM_STR
  3017. DEBUG_PIM_PACKETS_STR
  3018. DEBUG_PIM_HELLO_PACKETS_STR
  3019. DEBUG_PIM_J_P_PACKETS_STR)
  3020. {
  3021. PIM_DONT_DEBUG_PIM_PACKETS;
  3022. vty_out (vty, "PIM Packet debugging is off %s", VTY_NEWLINE);
  3023. return CMD_SUCCESS;
  3024. }
  3025. DEFUN (no_debug_pim_packets_filter,
  3026. no_debug_pim_packets_filter_cmd,
  3027. "no debug pim packets (hello|joins)",
  3028. NO_STR
  3029. DEBUG_STR
  3030. DEBUG_PIM_STR
  3031. DEBUG_PIM_PACKETS_STR
  3032. DEBUG_PIM_HELLO_PACKETS_STR
  3033. DEBUG_PIM_J_P_PACKETS_STR)
  3034. {
  3035. if (strncmp(argv[0],"h",1) == 0)
  3036. {
  3037. PIM_DONT_DEBUG_PIM_HELLO;
  3038. vty_out (vty, "PIM Hello debugging is off %s", VTY_NEWLINE);
  3039. }
  3040. else if (strncmp(argv[0],"j",1) == 0)
  3041. {
  3042. PIM_DONT_DEBUG_PIM_J_P;
  3043. vty_out (vty, "PIM Join/Prune debugging is off %s", VTY_NEWLINE);
  3044. }
  3045. return CMD_SUCCESS;
  3046. }
  3047. ALIAS (no_debug_pim_packets,
  3048. undebug_pim_packets_cmd,
  3049. "undebug pim packets",
  3050. UNDEBUG_STR
  3051. DEBUG_PIM_STR
  3052. DEBUG_PIM_PACKETS_STR)
  3053. DEFUN (debug_pim_packetdump_send,
  3054. debug_pim_packetdump_send_cmd,
  3055. "debug pim packet-dump send",
  3056. DEBUG_STR
  3057. DEBUG_PIM_STR
  3058. DEBUG_PIM_PACKETDUMP_STR
  3059. DEBUG_PIM_PACKETDUMP_SEND_STR)
  3060. {
  3061. PIM_DO_DEBUG_PIM_PACKETDUMP_SEND;
  3062. return CMD_SUCCESS;
  3063. }
  3064. DEFUN (no_debug_pim_packetdump_send,
  3065. no_debug_pim_packetdump_send_cmd,
  3066. "no debug pim packet-dump send",
  3067. NO_STR
  3068. DEBUG_STR
  3069. DEBUG_PIM_STR
  3070. DEBUG_PIM_PACKETDUMP_STR
  3071. DEBUG_PIM_PACKETDUMP_SEND_STR)
  3072. {
  3073. PIM_DONT_DEBUG_PIM_PACKETDUMP_SEND;
  3074. return CMD_SUCCESS;
  3075. }
  3076. ALIAS (no_debug_pim_packetdump_send,
  3077. undebug_pim_packetdump_send_cmd,
  3078. "undebug pim packet-dump send",
  3079. UNDEBUG_STR
  3080. DEBUG_PIM_STR
  3081. DEBUG_PIM_PACKETDUMP_STR
  3082. DEBUG_PIM_PACKETDUMP_SEND_STR)
  3083. DEFUN (debug_pim_packetdump_recv,
  3084. debug_pim_packetdump_recv_cmd,
  3085. "debug pim packet-dump receive",
  3086. DEBUG_STR
  3087. DEBUG_PIM_STR
  3088. DEBUG_PIM_PACKETDUMP_STR
  3089. DEBUG_PIM_PACKETDUMP_RECV_STR)
  3090. {
  3091. PIM_DO_DEBUG_PIM_PACKETDUMP_RECV;
  3092. return CMD_SUCCESS;
  3093. }
  3094. DEFUN (no_debug_pim_packetdump_recv,
  3095. no_debug_pim_packetdump_recv_cmd,
  3096. "no debug pim packet-dump receive",
  3097. NO_STR
  3098. DEBUG_STR
  3099. DEBUG_PIM_STR
  3100. DEBUG_PIM_PACKETDUMP_STR
  3101. DEBUG_PIM_PACKETDUMP_RECV_STR)
  3102. {
  3103. PIM_DONT_DEBUG_PIM_PACKETDUMP_RECV;
  3104. return CMD_SUCCESS;
  3105. }
  3106. ALIAS (no_debug_pim_packetdump_recv,
  3107. undebug_pim_packetdump_recv_cmd,
  3108. "undebug pim packet-dump receive",
  3109. UNDEBUG_STR
  3110. DEBUG_PIM_STR
  3111. DEBUG_PIM_PACKETDUMP_STR
  3112. DEBUG_PIM_PACKETDUMP_RECV_STR)
  3113. DEFUN (debug_pim_trace,
  3114. debug_pim_trace_cmd,
  3115. "debug pim trace",
  3116. DEBUG_STR
  3117. DEBUG_PIM_STR
  3118. DEBUG_PIM_TRACE_STR)
  3119. {
  3120. PIM_DO_DEBUG_PIM_TRACE;
  3121. return CMD_SUCCESS;
  3122. }
  3123. DEFUN (no_debug_pim_trace,
  3124. no_debug_pim_trace_cmd,
  3125. "no debug pim trace",
  3126. NO_STR
  3127. DEBUG_STR
  3128. DEBUG_PIM_STR
  3129. DEBUG_PIM_TRACE_STR)
  3130. {
  3131. PIM_DONT_DEBUG_PIM_TRACE;
  3132. return CMD_SUCCESS;
  3133. }
  3134. ALIAS (no_debug_pim_trace,
  3135. undebug_pim_trace_cmd,
  3136. "undebug pim trace",
  3137. UNDEBUG_STR
  3138. DEBUG_PIM_STR
  3139. DEBUG_PIM_TRACE_STR)
  3140. DEFUN (debug_ssmpingd,
  3141. debug_ssmpingd_cmd,
  3142. "debug ssmpingd",
  3143. DEBUG_STR
  3144. DEBUG_PIM_STR
  3145. DEBUG_SSMPINGD_STR)
  3146. {
  3147. PIM_DO_DEBUG_SSMPINGD;
  3148. return CMD_SUCCESS;
  3149. }
  3150. DEFUN (no_debug_ssmpingd,
  3151. no_debug_ssmpingd_cmd,
  3152. "no debug ssmpingd",
  3153. NO_STR
  3154. DEBUG_STR
  3155. DEBUG_PIM_STR
  3156. DEBUG_SSMPINGD_STR)
  3157. {
  3158. PIM_DONT_DEBUG_SSMPINGD;
  3159. return CMD_SUCCESS;
  3160. }
  3161. ALIAS (no_debug_ssmpingd,
  3162. undebug_ssmpingd_cmd,
  3163. "undebug ssmpingd",
  3164. UNDEBUG_STR
  3165. DEBUG_PIM_STR
  3166. DEBUG_SSMPINGD_STR)
  3167. DEFUN (debug_pim_zebra,
  3168. debug_pim_zebra_cmd,
  3169. "debug pim zebra",
  3170. DEBUG_STR
  3171. DEBUG_PIM_STR
  3172. DEBUG_PIM_ZEBRA_STR)
  3173. {
  3174. PIM_DO_DEBUG_ZEBRA;
  3175. return CMD_SUCCESS;
  3176. }
  3177. DEFUN (no_debug_pim_zebra,
  3178. no_debug_pim_zebra_cmd,
  3179. "no debug pim zebra",
  3180. NO_STR
  3181. DEBUG_STR
  3182. DEBUG_PIM_STR
  3183. DEBUG_PIM_ZEBRA_STR)
  3184. {
  3185. PIM_DONT_DEBUG_ZEBRA;
  3186. return CMD_SUCCESS;
  3187. }
  3188. ALIAS (no_debug_pim_zebra,
  3189. undebug_pim_zebra_cmd,
  3190. "undebug pim zebra",
  3191. UNDEBUG_STR
  3192. DEBUG_PIM_STR
  3193. DEBUG_PIM_ZEBRA_STR)
  3194. DEFUN (show_debugging_pim,
  3195. show_debugging_pim_cmd,
  3196. "show debugging pim",
  3197. SHOW_STR
  3198. DEBUG_STR
  3199. PIM_STR)
  3200. {
  3201. pim_debug_config_write(vty);
  3202. return CMD_SUCCESS;
  3203. }
  3204. static struct igmp_sock *find_igmp_sock_by_fd(int fd)
  3205. {
  3206. struct listnode *ifnode;
  3207. struct interface *ifp;
  3208. /* scan all interfaces */
  3209. for (ALL_LIST_ELEMENTS_RO(iflist, ifnode, ifp)) {
  3210. struct pim_interface *pim_ifp;
  3211. struct igmp_sock *igmp;
  3212. if (!ifp->info)
  3213. continue;
  3214. pim_ifp = ifp->info;
  3215. /* lookup igmp socket under current interface */
  3216. igmp = igmp_sock_lookup_by_fd(pim_ifp->igmp_socket_list, fd);
  3217. if (igmp)
  3218. return igmp;
  3219. }
  3220. return 0;
  3221. }
  3222. DEFUN (test_igmp_receive_report,
  3223. test_igmp_receive_report_cmd,
  3224. "test igmp receive report <0-65535> A.B.C.D <1-6> .LINE",
  3225. "Test\n"
  3226. "Test IGMP protocol\n"
  3227. "Test IGMP message\n"
  3228. "Test IGMP report\n"
  3229. "Socket\n"
  3230. "IGMP group address\n"
  3231. "Record type\n"
  3232. "Sources\n")
  3233. {
  3234. char buf[1000];
  3235. char *igmp_msg;
  3236. struct ip *ip_hdr;
  3237. size_t ip_hlen; /* ip header length in bytes */
  3238. int ip_msg_len;
  3239. int igmp_msg_len;
  3240. const char *socket;
  3241. int socket_fd;
  3242. const char *grp_str;
  3243. struct in_addr grp_addr;
  3244. const char *record_type_str;
  3245. int record_type;
  3246. const char *src_str;
  3247. int result;
  3248. struct igmp_sock *igmp;
  3249. char *group_record;
  3250. int num_sources;
  3251. struct in_addr *sources;
  3252. struct in_addr *src_addr;
  3253. int argi;
  3254. socket = argv[0];
  3255. socket_fd = atoi(socket);
  3256. igmp = find_igmp_sock_by_fd(socket_fd);
  3257. if (!igmp) {
  3258. vty_out(vty, "Could not find IGMP socket %s: fd=%d%s",
  3259. socket, socket_fd, VTY_NEWLINE);
  3260. return CMD_WARNING;
  3261. }
  3262. grp_str = argv[1];
  3263. result = inet_pton(AF_INET, grp_str, &grp_addr);
  3264. if (result <= 0) {
  3265. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  3266. grp_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3267. return CMD_WARNING;
  3268. }
  3269. record_type_str = argv[2];
  3270. record_type = atoi(record_type_str);
  3271. /*
  3272. Tweak IP header
  3273. */
  3274. ip_hdr = (struct ip *) buf;
  3275. ip_hdr->ip_p = PIM_IP_PROTO_IGMP;
  3276. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  3277. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  3278. ip_hdr->ip_src = igmp->ifaddr;
  3279. ip_hdr->ip_dst = igmp->ifaddr;
  3280. /*
  3281. Build IGMP v3 report message
  3282. */
  3283. igmp_msg = buf + ip_hlen;
  3284. group_record = igmp_msg + IGMP_V3_REPORT_GROUPPRECORD_OFFSET;
  3285. *igmp_msg = PIM_IGMP_V3_MEMBERSHIP_REPORT; /* type */
  3286. *(uint16_t *) (igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = 0; /* for computing checksum */
  3287. *(uint16_t *) (igmp_msg + IGMP_V3_REPORT_NUMGROUPS_OFFSET) = htons(1); /* one group record */
  3288. *(uint8_t *) (group_record + IGMP_V3_GROUP_RECORD_TYPE_OFFSET) = record_type;
  3289. memcpy(group_record + IGMP_V3_GROUP_RECORD_GROUP_OFFSET, &grp_addr, sizeof(struct in_addr));
  3290. /* Scan LINE sources */
  3291. sources = (struct in_addr *) (group_record + IGMP_V3_GROUP_RECORD_SOURCE_OFFSET);
  3292. src_addr = sources;
  3293. for (argi = 3; argi < argc; ++argi,++src_addr) {
  3294. src_str = argv[argi];
  3295. result = inet_pton(AF_INET, src_str, src_addr);
  3296. if (result <= 0) {
  3297. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  3298. src_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3299. return CMD_WARNING;
  3300. }
  3301. }
  3302. num_sources = src_addr - sources;
  3303. *(uint16_t *)(group_record + IGMP_V3_GROUP_RECORD_NUMSOURCES_OFFSET) = htons(num_sources);
  3304. igmp_msg_len = IGMP_V3_MSG_MIN_SIZE + (num_sources << 4); /* v3 report for one single group record */
  3305. /* compute checksum */
  3306. *(uint16_t *)(igmp_msg + IGMP_V3_CHECKSUM_OFFSET) = in_cksum(igmp_msg, igmp_msg_len);
  3307. /* "receive" message */
  3308. ip_msg_len = ip_hlen + igmp_msg_len;
  3309. result = pim_igmp_packet(igmp, buf, ip_msg_len);
  3310. if (result) {
  3311. vty_out(vty, "pim_igmp_packet(len=%d) returned: %d%s",
  3312. ip_msg_len, result, VTY_NEWLINE);
  3313. return CMD_WARNING;
  3314. }
  3315. return CMD_SUCCESS;
  3316. }
  3317. static int hexval(uint8_t ch)
  3318. {
  3319. return isdigit(ch) ? (ch - '0') : (10 + tolower(ch) - 'a');
  3320. }
  3321. DEFUN (test_pim_receive_dump,
  3322. test_pim_receive_dump_cmd,
  3323. "test pim receive dump INTERFACE A.B.C.D .LINE",
  3324. "Test\n"
  3325. "Test PIM protocol\n"
  3326. "Test PIM message reception\n"
  3327. "Test PIM packet dump reception from neighbor\n"
  3328. "Interface\n"
  3329. "Neighbor address\n"
  3330. "Packet dump\n")
  3331. {
  3332. uint8_t buf[1000];
  3333. uint8_t *pim_msg;
  3334. struct ip *ip_hdr;
  3335. size_t ip_hlen; /* ip header length in bytes */
  3336. int ip_msg_len;
  3337. int pim_msg_size;
  3338. const char *neigh_str;
  3339. struct in_addr neigh_addr;
  3340. const char *ifname;
  3341. struct interface *ifp;
  3342. int argi;
  3343. int result;
  3344. /* Find interface */
  3345. ifname = argv[0];
  3346. ifp = if_lookup_by_name(ifname);
  3347. if (!ifp) {
  3348. vty_out(vty, "No such interface name %s%s",
  3349. ifname, VTY_NEWLINE);
  3350. return CMD_WARNING;
  3351. }
  3352. /* Neighbor address */
  3353. neigh_str = argv[1];
  3354. result = inet_pton(AF_INET, neigh_str, &neigh_addr);
  3355. if (result <= 0) {
  3356. vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
  3357. neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3358. return CMD_WARNING;
  3359. }
  3360. /*
  3361. Tweak IP header
  3362. */
  3363. ip_hdr = (struct ip *) buf;
  3364. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  3365. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  3366. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  3367. ip_hdr->ip_src = neigh_addr;
  3368. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  3369. /*
  3370. Build PIM hello message
  3371. */
  3372. pim_msg = buf + ip_hlen;
  3373. pim_msg_size = 0;
  3374. /* Scan LINE dump into buffer */
  3375. for (argi = 2; argi < argc; ++argi) {
  3376. const char *str = argv[argi];
  3377. int str_len = strlen(str);
  3378. int str_last = str_len - 1;
  3379. int i;
  3380. if (str_len % 2) {
  3381. vty_out(vty, "%% Uneven hex array arg %d=%s%s",
  3382. argi, str, VTY_NEWLINE);
  3383. return CMD_WARNING;
  3384. }
  3385. for (i = 0; i < str_last; i += 2) {
  3386. uint8_t octet;
  3387. int left;
  3388. uint8_t h1 = str[i];
  3389. uint8_t h2 = str[i + 1];
  3390. if (!isxdigit(h1) || !isxdigit(h2)) {
  3391. vty_out(vty, "%% Non-hex octet %c%c at hex array arg %d=%s%s",
  3392. h1, h2, argi, str, VTY_NEWLINE);
  3393. return CMD_WARNING;
  3394. }
  3395. octet = (hexval(h1) << 4) + hexval(h2);
  3396. left = sizeof(buf) - ip_hlen - pim_msg_size;
  3397. if (left < 1) {
  3398. vty_out(vty, "%% Overflow buf_size=%zu buf_left=%d at hex array arg %d=%s octet %02x%s",
  3399. sizeof(buf), left, argi, str, octet, VTY_NEWLINE);
  3400. return CMD_WARNING;
  3401. }
  3402. pim_msg[pim_msg_size++] = octet;
  3403. }
  3404. }
  3405. ip_msg_len = ip_hlen + pim_msg_size;
  3406. vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s",
  3407. sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE);
  3408. /* "receive" message */
  3409. result = pim_pim_packet(ifp, buf, ip_msg_len);
  3410. if (result) {
  3411. vty_out(vty, "%% pim_pim_packet(len=%d) returned failure: %d%s",
  3412. ip_msg_len, result, VTY_NEWLINE);
  3413. return CMD_WARNING;
  3414. }
  3415. return CMD_SUCCESS;
  3416. }
  3417. DEFUN (test_pim_receive_hello,
  3418. test_pim_receive_hello_cmd,
  3419. "test pim receive hello INTERFACE A.B.C.D <0-65535> <0-65535> <0-65535> <0-32767> <0-65535> <0-1>[LINE]",
  3420. "Test\n"
  3421. "Test PIM protocol\n"
  3422. "Test PIM message reception\n"
  3423. "Test PIM hello reception from neighbor\n"
  3424. "Interface\n"
  3425. "Neighbor address\n"
  3426. "Neighbor holdtime\n"
  3427. "Neighbor DR priority\n"
  3428. "Neighbor generation ID\n"
  3429. "Neighbor propagation delay (msec)\n"
  3430. "Neighbor override interval (msec)\n"
  3431. "Neighbor LAN prune delay T-bit\n"
  3432. "Neighbor secondary addresses\n")
  3433. {
  3434. uint8_t buf[1000];
  3435. uint8_t *pim_msg;
  3436. struct ip *ip_hdr;
  3437. size_t ip_hlen; /* ip header length in bytes */
  3438. int ip_msg_len;
  3439. int pim_tlv_size;
  3440. int pim_msg_size;
  3441. const char *neigh_str;
  3442. struct in_addr neigh_addr;
  3443. const char *ifname;
  3444. struct interface *ifp;
  3445. uint16_t neigh_holdtime;
  3446. uint16_t neigh_propagation_delay;
  3447. uint16_t neigh_override_interval;
  3448. int neigh_can_disable_join_suppression;
  3449. uint32_t neigh_dr_priority;
  3450. uint32_t neigh_generation_id;
  3451. int argi;
  3452. int result;
  3453. /* Find interface */
  3454. ifname = argv[0];
  3455. ifp = if_lookup_by_name(ifname);
  3456. if (!ifp) {
  3457. vty_out(vty, "No such interface name %s%s",
  3458. ifname, VTY_NEWLINE);
  3459. return CMD_WARNING;
  3460. }
  3461. /* Neighbor address */
  3462. neigh_str = argv[1];
  3463. result = inet_pton(AF_INET, neigh_str, &neigh_addr);
  3464. if (result <= 0) {
  3465. vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
  3466. neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3467. return CMD_WARNING;
  3468. }
  3469. neigh_holdtime = atoi(argv[2]);
  3470. neigh_dr_priority = atoi(argv[3]);
  3471. neigh_generation_id = atoi(argv[4]);
  3472. neigh_propagation_delay = atoi(argv[5]);
  3473. neigh_override_interval = atoi(argv[6]);
  3474. neigh_can_disable_join_suppression = atoi(argv[7]);
  3475. /*
  3476. Tweak IP header
  3477. */
  3478. ip_hdr = (struct ip *) buf;
  3479. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  3480. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  3481. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  3482. ip_hdr->ip_src = neigh_addr;
  3483. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  3484. /*
  3485. Build PIM hello message
  3486. */
  3487. pim_msg = buf + ip_hlen;
  3488. /* Scan LINE addresses */
  3489. for (argi = 8; argi < argc; ++argi) {
  3490. const char *sec_str = argv[argi];
  3491. struct in_addr sec_addr;
  3492. result = inet_pton(AF_INET, sec_str, &sec_addr);
  3493. if (result <= 0) {
  3494. vty_out(vty, "Bad neighbor secondary address %s: errno=%d: %s%s",
  3495. sec_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3496. return CMD_WARNING;
  3497. }
  3498. vty_out(vty,
  3499. "FIXME WRITEME consider neighbor secondary address %s%s",
  3500. sec_str, VTY_NEWLINE);
  3501. }
  3502. pim_tlv_size = pim_hello_build_tlv(ifp->name,
  3503. pim_msg + PIM_PIM_MIN_LEN,
  3504. sizeof(buf) - ip_hlen - PIM_PIM_MIN_LEN,
  3505. neigh_holdtime,
  3506. neigh_dr_priority,
  3507. neigh_generation_id,
  3508. neigh_propagation_delay,
  3509. neigh_override_interval,
  3510. neigh_can_disable_join_suppression,
  3511. 0 /* FIXME secondary address list */);
  3512. if (pim_tlv_size < 0) {
  3513. vty_out(vty, "pim_hello_build_tlv() returned failure: %d%s",
  3514. pim_tlv_size, VTY_NEWLINE);
  3515. return CMD_WARNING;
  3516. }
  3517. pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN;
  3518. pim_msg_build_header(pim_msg, pim_msg_size,
  3519. PIM_MSG_TYPE_HELLO);
  3520. /* "receive" message */
  3521. ip_msg_len = ip_hlen + pim_msg_size;
  3522. result = pim_pim_packet(ifp, buf, ip_msg_len);
  3523. if (result) {
  3524. vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
  3525. ip_msg_len, result, VTY_NEWLINE);
  3526. return CMD_WARNING;
  3527. }
  3528. return CMD_SUCCESS;
  3529. }
  3530. DEFUN (test_pim_receive_assert,
  3531. test_pim_receive_assert_cmd,
  3532. "test pim receive assert INTERFACE A.B.C.D A.B.C.D A.B.C.D <0-65535> <0-65535> <0-1>",
  3533. "Test\n"
  3534. "Test PIM protocol\n"
  3535. "Test PIM message reception\n"
  3536. "Test reception of PIM assert\n"
  3537. "Interface\n"
  3538. "Neighbor address\n"
  3539. "Assert multicast group address\n"
  3540. "Assert unicast source address\n"
  3541. "Assert metric preference\n"
  3542. "Assert route metric\n"
  3543. "Assert RPT bit flag\n")
  3544. {
  3545. uint8_t buf[1000];
  3546. uint8_t *buf_pastend = buf + sizeof(buf);
  3547. uint8_t *pim_msg;
  3548. struct ip *ip_hdr;
  3549. size_t ip_hlen; /* ip header length in bytes */
  3550. int ip_msg_len;
  3551. int pim_msg_size;
  3552. const char *neigh_str;
  3553. struct in_addr neigh_addr;
  3554. const char *group_str;
  3555. struct in_addr group_addr;
  3556. const char *source_str;
  3557. struct in_addr source_addr;
  3558. const char *ifname;
  3559. struct interface *ifp;
  3560. uint32_t assert_metric_preference;
  3561. uint32_t assert_route_metric;
  3562. uint32_t assert_rpt_bit_flag;
  3563. int remain;
  3564. int result;
  3565. /* Find interface */
  3566. ifname = argv[0];
  3567. ifp = if_lookup_by_name(ifname);
  3568. if (!ifp) {
  3569. vty_out(vty, "No such interface name %s%s",
  3570. ifname, VTY_NEWLINE);
  3571. return CMD_WARNING;
  3572. }
  3573. /* Neighbor address */
  3574. neigh_str = argv[1];
  3575. result = inet_pton(AF_INET, neigh_str, &neigh_addr);
  3576. if (result <= 0) {
  3577. vty_out(vty, "Bad neighbor address %s: errno=%d: %s%s",
  3578. neigh_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3579. return CMD_WARNING;
  3580. }
  3581. /* Group address */
  3582. group_str = argv[2];
  3583. result = inet_pton(AF_INET, group_str, &group_addr);
  3584. if (result <= 0) {
  3585. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  3586. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3587. return CMD_WARNING;
  3588. }
  3589. /* Source address */
  3590. source_str = argv[3];
  3591. result = inet_pton(AF_INET, source_str, &source_addr);
  3592. if (result <= 0) {
  3593. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  3594. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3595. return CMD_WARNING;
  3596. }
  3597. assert_metric_preference = atoi(argv[4]);
  3598. assert_route_metric = atoi(argv[5]);
  3599. assert_rpt_bit_flag = atoi(argv[6]);
  3600. remain = buf_pastend - buf;
  3601. if (remain < (int) sizeof(struct ip)) {
  3602. vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s",
  3603. remain, sizeof(struct ip), VTY_NEWLINE);
  3604. return CMD_WARNING;
  3605. }
  3606. /*
  3607. Tweak IP header
  3608. */
  3609. ip_hdr = (struct ip *) buf;
  3610. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  3611. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  3612. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  3613. ip_hdr->ip_src = neigh_addr;
  3614. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  3615. /*
  3616. Build PIM assert message
  3617. */
  3618. pim_msg = buf + ip_hlen; /* skip ip header */
  3619. pim_msg_size = pim_assert_build_msg(pim_msg, buf_pastend - pim_msg, ifp,
  3620. group_addr, source_addr,
  3621. assert_metric_preference,
  3622. assert_route_metric,
  3623. assert_rpt_bit_flag);
  3624. if (pim_msg_size < 0) {
  3625. vty_out(vty, "Failure building PIM assert message: size=%d%s",
  3626. pim_msg_size, VTY_NEWLINE);
  3627. return CMD_WARNING;
  3628. }
  3629. /* "receive" message */
  3630. ip_msg_len = ip_hlen + pim_msg_size;
  3631. result = pim_pim_packet(ifp, buf, ip_msg_len);
  3632. if (result) {
  3633. vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
  3634. ip_msg_len, result, VTY_NEWLINE);
  3635. return CMD_WARNING;
  3636. }
  3637. return CMD_SUCCESS;
  3638. }
  3639. static int recv_joinprune(struct vty *vty,
  3640. const char *argv[],
  3641. int src_is_join)
  3642. {
  3643. uint8_t buf[1000];
  3644. const uint8_t *buf_pastend = buf + sizeof(buf);
  3645. uint8_t *pim_msg;
  3646. uint8_t *pim_msg_curr;
  3647. int pim_msg_size;
  3648. struct ip *ip_hdr;
  3649. size_t ip_hlen; /* ip header length in bytes */
  3650. int ip_msg_len;
  3651. uint16_t neigh_holdtime;
  3652. const char *neigh_dst_str;
  3653. struct in_addr neigh_dst_addr;
  3654. const char *neigh_src_str;
  3655. struct in_addr neigh_src_addr;
  3656. const char *group_str;
  3657. struct in_addr group_addr;
  3658. const char *source_str;
  3659. struct in_addr source_addr;
  3660. const char *ifname;
  3661. struct interface *ifp;
  3662. int result;
  3663. int remain;
  3664. uint16_t num_joined;
  3665. uint16_t num_pruned;
  3666. /* Find interface */
  3667. ifname = argv[0];
  3668. ifp = if_lookup_by_name(ifname);
  3669. if (!ifp) {
  3670. vty_out(vty, "No such interface name %s%s",
  3671. ifname, VTY_NEWLINE);
  3672. return CMD_WARNING;
  3673. }
  3674. neigh_holdtime = atoi(argv[1]);
  3675. /* Neighbor destination address */
  3676. neigh_dst_str = argv[2];
  3677. result = inet_pton(AF_INET, neigh_dst_str, &neigh_dst_addr);
  3678. if (result <= 0) {
  3679. vty_out(vty, "Bad neighbor destination address %s: errno=%d: %s%s",
  3680. neigh_dst_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3681. return CMD_WARNING;
  3682. }
  3683. /* Neighbor source address */
  3684. neigh_src_str = argv[3];
  3685. result = inet_pton(AF_INET, neigh_src_str, &neigh_src_addr);
  3686. if (result <= 0) {
  3687. vty_out(vty, "Bad neighbor source address %s: errno=%d: %s%s",
  3688. neigh_src_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3689. return CMD_WARNING;
  3690. }
  3691. /* Multicast group address */
  3692. group_str = argv[4];
  3693. result = inet_pton(AF_INET, group_str, &group_addr);
  3694. if (result <= 0) {
  3695. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  3696. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3697. return CMD_WARNING;
  3698. }
  3699. /* Multicast source address */
  3700. source_str = argv[5];
  3701. result = inet_pton(AF_INET, source_str, &source_addr);
  3702. if (result <= 0) {
  3703. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  3704. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3705. return CMD_WARNING;
  3706. }
  3707. /*
  3708. Tweak IP header
  3709. */
  3710. ip_hdr = (struct ip *) buf;
  3711. ip_hdr->ip_p = PIM_IP_PROTO_PIM;
  3712. ip_hlen = PIM_IP_HEADER_MIN_LEN; /* ip header length in bytes */
  3713. ip_hdr->ip_hl = ip_hlen >> 2; /* ip header length in 4-byte words */
  3714. ip_hdr->ip_src = neigh_src_addr;
  3715. ip_hdr->ip_dst = qpim_all_pim_routers_addr;
  3716. /*
  3717. Build PIM message
  3718. */
  3719. pim_msg = buf + ip_hlen;
  3720. /* skip room for pim header */
  3721. pim_msg_curr = pim_msg + PIM_MSG_HEADER_LEN;
  3722. remain = buf_pastend - pim_msg_curr;
  3723. pim_msg_curr = pim_msg_addr_encode_ipv4_ucast(pim_msg_curr,
  3724. remain,
  3725. neigh_dst_addr);
  3726. if (!pim_msg_curr) {
  3727. vty_out(vty, "Failure encoding destination address %s: space left=%d%s",
  3728. neigh_dst_str, remain, VTY_NEWLINE);
  3729. return CMD_WARNING;
  3730. }
  3731. remain = buf_pastend - pim_msg_curr;
  3732. if (remain < 4) {
  3733. vty_out(vty, "Group will not fit: space left=%d%s",
  3734. remain, VTY_NEWLINE);
  3735. return CMD_WARNING;
  3736. }
  3737. *pim_msg_curr = 0; /* reserved */
  3738. ++pim_msg_curr;
  3739. *pim_msg_curr = 1; /* number of groups */
  3740. ++pim_msg_curr;
  3741. *((uint16_t *) pim_msg_curr) = htons(neigh_holdtime);
  3742. ++pim_msg_curr;
  3743. ++pim_msg_curr;
  3744. remain = buf_pastend - pim_msg_curr;
  3745. pim_msg_curr = pim_msg_addr_encode_ipv4_group(pim_msg_curr,
  3746. remain,
  3747. group_addr);
  3748. if (!pim_msg_curr) {
  3749. vty_out(vty, "Failure encoding group address %s: space left=%d%s",
  3750. group_str, remain, VTY_NEWLINE);
  3751. return CMD_WARNING;
  3752. }
  3753. remain = buf_pastend - pim_msg_curr;
  3754. if (remain < 4) {
  3755. vty_out(vty, "Sources will not fit: space left=%d%s",
  3756. remain, VTY_NEWLINE);
  3757. return CMD_WARNING;
  3758. }
  3759. if (src_is_join) {
  3760. num_joined = 1;
  3761. num_pruned = 0;
  3762. }
  3763. else {
  3764. num_joined = 0;
  3765. num_pruned = 1;
  3766. }
  3767. /* number of joined sources */
  3768. *((uint16_t *) pim_msg_curr) = htons(num_joined);
  3769. ++pim_msg_curr;
  3770. ++pim_msg_curr;
  3771. /* number of pruned sources */
  3772. *((uint16_t *) pim_msg_curr) = htons(num_pruned);
  3773. ++pim_msg_curr;
  3774. ++pim_msg_curr;
  3775. remain = buf_pastend - pim_msg_curr;
  3776. pim_msg_curr = pim_msg_addr_encode_ipv4_source(pim_msg_curr,
  3777. remain,
  3778. source_addr);
  3779. if (!pim_msg_curr) {
  3780. vty_out(vty, "Failure encoding source address %s: space left=%d%s",
  3781. source_str, remain, VTY_NEWLINE);
  3782. return CMD_WARNING;
  3783. }
  3784. /* Add PIM header */
  3785. pim_msg_size = pim_msg_curr - pim_msg;
  3786. pim_msg_build_header(pim_msg, pim_msg_size,
  3787. PIM_MSG_TYPE_JOIN_PRUNE);
  3788. /*
  3789. "Receive" message
  3790. */
  3791. ip_msg_len = ip_hlen + pim_msg_size;
  3792. result = pim_pim_packet(ifp, buf, ip_msg_len);
  3793. if (result) {
  3794. vty_out(vty, "pim_pim_packet(len=%d) returned failure: %d%s",
  3795. ip_msg_len, result, VTY_NEWLINE);
  3796. return CMD_WARNING;
  3797. }
  3798. return CMD_SUCCESS;
  3799. }
  3800. DEFUN (test_pim_receive_join,
  3801. test_pim_receive_join_cmd,
  3802. "test pim receive join INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
  3803. "Test\n"
  3804. "Test PIM protocol\n"
  3805. "Test PIM message reception\n"
  3806. "Test PIM join reception from neighbor\n"
  3807. "Interface\n"
  3808. "Neighbor holdtime\n"
  3809. "Upstream neighbor unicast destination address\n"
  3810. "Downstream neighbor unicast source address\n"
  3811. "Multicast group address\n"
  3812. "Unicast source address\n")
  3813. {
  3814. return recv_joinprune(vty, argv, 1 /* src_is_join=true */);
  3815. }
  3816. DEFUN (test_pim_receive_prune,
  3817. test_pim_receive_prune_cmd,
  3818. "test pim receive prune INTERFACE <0-65535> A.B.C.D A.B.C.D A.B.C.D A.B.C.D",
  3819. "Test\n"
  3820. "Test PIM protocol\n"
  3821. "Test PIM message reception\n"
  3822. "Test PIM prune reception from neighbor\n"
  3823. "Interface\n"
  3824. "Neighbor holdtime\n"
  3825. "Upstream neighbor unicast destination address\n"
  3826. "Downstream neighbor unicast source address\n"
  3827. "Multicast group address\n"
  3828. "Unicast source address\n")
  3829. {
  3830. return recv_joinprune(vty, argv, 0 /* src_is_join=false */);
  3831. }
  3832. DEFUN (test_pim_receive_upcall,
  3833. test_pim_receive_upcall_cmd,
  3834. "test pim receive upcall (nocache|wrongvif|wholepkt) <0-65535> A.B.C.D A.B.C.D",
  3835. "Test\n"
  3836. "Test PIM protocol\n"
  3837. "Test PIM message reception\n"
  3838. "Test reception of kernel upcall\n"
  3839. "NOCACHE kernel upcall\n"
  3840. "WRONGVIF kernel upcall\n"
  3841. "WHOLEPKT kernel upcall\n"
  3842. "Input interface vif index\n"
  3843. "Multicast group address\n"
  3844. "Multicast source address\n")
  3845. {
  3846. struct igmpmsg msg;
  3847. const char *upcall_type;
  3848. const char *group_str;
  3849. const char *source_str;
  3850. int result;
  3851. upcall_type = argv[0];
  3852. if (upcall_type[0] == 'n')
  3853. msg.im_msgtype = IGMPMSG_NOCACHE;
  3854. else if (upcall_type[1] == 'r')
  3855. msg.im_msgtype = IGMPMSG_WRONGVIF;
  3856. else if (upcall_type[1] == 'h')
  3857. msg.im_msgtype = IGMPMSG_WHOLEPKT;
  3858. else {
  3859. vty_out(vty, "Unknown kernel upcall type: %s%s",
  3860. upcall_type, VTY_NEWLINE);
  3861. return CMD_WARNING;
  3862. }
  3863. msg.im_vif = atoi(argv[1]);
  3864. /* Group address */
  3865. group_str = argv[2];
  3866. result = inet_pton(AF_INET, group_str, &msg.im_dst);
  3867. if (result <= 0) {
  3868. vty_out(vty, "Bad group address %s: errno=%d: %s%s",
  3869. group_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3870. return CMD_WARNING;
  3871. }
  3872. /* Source address */
  3873. source_str = argv[3];
  3874. result = inet_pton(AF_INET, source_str, &msg.im_src);
  3875. if (result <= 0) {
  3876. vty_out(vty, "Bad source address %s: errno=%d: %s%s",
  3877. source_str, errno, safe_strerror(errno), VTY_NEWLINE);
  3878. return CMD_WARNING;
  3879. }
  3880. msg.im_mbz = 0; /* Must be zero */
  3881. result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
  3882. if (result) {
  3883. vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s",
  3884. sizeof(msg), result, VTY_NEWLINE);
  3885. return CMD_WARNING;
  3886. }
  3887. return CMD_SUCCESS;
  3888. }
  3889. void pim_cmd_init()
  3890. {
  3891. install_node (&pim_global_node, pim_global_config_write); /* PIM_NODE */
  3892. install_node (&interface_node, pim_interface_config_write); /* INTERFACE_NODE */
  3893. install_element (CONFIG_NODE, &ip_multicast_routing_cmd);
  3894. install_element (CONFIG_NODE, &no_ip_multicast_routing_cmd);
  3895. install_element (CONFIG_NODE, &ip_ssmpingd_cmd);
  3896. install_element (CONFIG_NODE, &no_ip_ssmpingd_cmd);
  3897. #if 0
  3898. install_element (CONFIG_NODE, &interface_cmd); /* from if.h */
  3899. #else
  3900. install_element (CONFIG_NODE, &pim_interface_cmd);
  3901. #endif
  3902. install_element (CONFIG_NODE, &no_interface_cmd); /* from if.h */
  3903. install_default (INTERFACE_NODE);
  3904. install_element (INTERFACE_NODE, &interface_ip_igmp_cmd);
  3905. install_element (INTERFACE_NODE, &interface_no_ip_igmp_cmd);
  3906. install_element (INTERFACE_NODE, &interface_ip_igmp_join_cmd);
  3907. install_element (INTERFACE_NODE, &interface_no_ip_igmp_join_cmd);
  3908. install_element (INTERFACE_NODE, &interface_ip_igmp_query_interval_cmd);
  3909. install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_interval_cmd);
  3910. install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_cmd);
  3911. install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_cmd);
  3912. install_element (INTERFACE_NODE, &interface_ip_igmp_query_max_response_time_dsec_cmd);
  3913. install_element (INTERFACE_NODE, &interface_no_ip_igmp_query_max_response_time_dsec_cmd);
  3914. install_element (INTERFACE_NODE, &interface_ip_pim_ssm_cmd);
  3915. install_element (INTERFACE_NODE, &interface_no_ip_pim_ssm_cmd);
  3916. // Static mroutes NEB
  3917. install_element (INTERFACE_NODE, &interface_ip_mroute_cmd);
  3918. install_element (INTERFACE_NODE, &interface_ip_mroute_source_cmd);
  3919. install_element (INTERFACE_NODE, &interface_no_ip_mroute_cmd);
  3920. install_element (INTERFACE_NODE, &interface_no_ip_mroute_source_cmd);
  3921. install_element (VIEW_NODE, &show_ip_igmp_interface_cmd);
  3922. install_element (VIEW_NODE, &show_ip_igmp_join_cmd);
  3923. install_element (VIEW_NODE, &show_ip_igmp_parameters_cmd);
  3924. install_element (VIEW_NODE, &show_ip_igmp_groups_cmd);
  3925. install_element (VIEW_NODE, &show_ip_igmp_groups_retransmissions_cmd);
  3926. install_element (VIEW_NODE, &show_ip_igmp_sources_cmd);
  3927. install_element (VIEW_NODE, &show_ip_igmp_sources_retransmissions_cmd);
  3928. install_element (VIEW_NODE, &show_ip_igmp_querier_cmd);
  3929. install_element (VIEW_NODE, &show_ip_pim_assert_cmd);
  3930. install_element (VIEW_NODE, &show_ip_pim_assert_internal_cmd);
  3931. install_element (VIEW_NODE, &show_ip_pim_assert_metric_cmd);
  3932. install_element (VIEW_NODE, &show_ip_pim_assert_winner_metric_cmd);
  3933. install_element (VIEW_NODE, &show_ip_pim_dr_cmd);
  3934. install_element (VIEW_NODE, &show_ip_pim_hello_cmd);
  3935. install_element (VIEW_NODE, &show_ip_pim_interface_cmd);
  3936. install_element (VIEW_NODE, &show_ip_pim_join_cmd);
  3937. install_element (VIEW_NODE, &show_ip_pim_jp_override_interval_cmd);
  3938. install_element (VIEW_NODE, &show_ip_pim_lan_prune_delay_cmd);
  3939. install_element (VIEW_NODE, &show_ip_pim_local_membership_cmd);
  3940. install_element (VIEW_NODE, &show_ip_pim_neighbor_cmd);
  3941. install_element (VIEW_NODE, &show_ip_pim_rpf_cmd);
  3942. install_element (VIEW_NODE, &show_ip_pim_secondary_cmd);
  3943. install_element (VIEW_NODE, &show_ip_pim_upstream_cmd);
  3944. install_element (VIEW_NODE, &show_ip_pim_upstream_join_desired_cmd);
  3945. install_element (VIEW_NODE, &show_ip_pim_upstream_rpf_cmd);
  3946. install_element (VIEW_NODE, &show_ip_multicast_cmd);
  3947. install_element (VIEW_NODE, &show_ip_mroute_cmd);
  3948. install_element (VIEW_NODE, &show_ip_mroute_count_cmd);
  3949. install_element (VIEW_NODE, &show_ip_rib_cmd);
  3950. install_element (VIEW_NODE, &show_ip_ssmpingd_cmd);
  3951. install_element (VIEW_NODE, &show_debugging_pim_cmd);
  3952. install_element (ENABLE_NODE, &clear_ip_interfaces_cmd);
  3953. install_element (ENABLE_NODE, &clear_ip_igmp_interfaces_cmd);
  3954. install_element (ENABLE_NODE, &clear_ip_mroute_cmd);
  3955. install_element (ENABLE_NODE, &clear_ip_pim_interfaces_cmd);
  3956. install_element (ENABLE_NODE, &clear_ip_pim_oil_cmd);
  3957. install_element (ENABLE_NODE, &show_ip_igmp_interface_cmd);
  3958. install_element (ENABLE_NODE, &show_ip_igmp_join_cmd);
  3959. install_element (ENABLE_NODE, &show_ip_igmp_parameters_cmd);
  3960. install_element (ENABLE_NODE, &show_ip_igmp_groups_cmd);
  3961. install_element (ENABLE_NODE, &show_ip_igmp_groups_retransmissions_cmd);
  3962. install_element (ENABLE_NODE, &show_ip_igmp_sources_cmd);
  3963. install_element (ENABLE_NODE, &show_ip_igmp_sources_retransmissions_cmd);
  3964. install_element (ENABLE_NODE, &show_ip_igmp_querier_cmd);
  3965. install_element (ENABLE_NODE, &show_ip_pim_address_cmd);
  3966. install_element (ENABLE_NODE, &show_ip_pim_assert_cmd);
  3967. install_element (ENABLE_NODE, &show_ip_pim_assert_internal_cmd);
  3968. install_element (ENABLE_NODE, &show_ip_pim_assert_metric_cmd);
  3969. install_element (ENABLE_NODE, &show_ip_pim_assert_winner_metric_cmd);
  3970. install_element (ENABLE_NODE, &show_ip_pim_dr_cmd);
  3971. install_element (ENABLE_NODE, &show_ip_pim_hello_cmd);
  3972. install_element (ENABLE_NODE, &show_ip_pim_interface_cmd);
  3973. install_element (ENABLE_NODE, &show_ip_pim_join_cmd);
  3974. install_element (ENABLE_NODE, &show_ip_pim_jp_override_interval_cmd);
  3975. install_element (ENABLE_NODE, &show_ip_pim_lan_prune_delay_cmd);
  3976. install_element (ENABLE_NODE, &show_ip_pim_local_membership_cmd);
  3977. install_element (ENABLE_NODE, &show_ip_pim_neighbor_cmd);
  3978. install_element (ENABLE_NODE, &show_ip_pim_rpf_cmd);
  3979. install_element (ENABLE_NODE, &show_ip_pim_secondary_cmd);
  3980. install_element (ENABLE_NODE, &show_ip_pim_upstream_cmd);
  3981. install_element (ENABLE_NODE, &show_ip_pim_upstream_join_desired_cmd);
  3982. install_element (ENABLE_NODE, &show_ip_pim_upstream_rpf_cmd);
  3983. install_element (ENABLE_NODE, &show_ip_multicast_cmd);
  3984. install_element (ENABLE_NODE, &show_ip_mroute_cmd);
  3985. install_element (ENABLE_NODE, &show_ip_mroute_count_cmd);
  3986. install_element (ENABLE_NODE, &show_ip_rib_cmd);
  3987. install_element (ENABLE_NODE, &show_ip_ssmpingd_cmd);
  3988. install_element (ENABLE_NODE, &show_debugging_pim_cmd);
  3989. install_element (ENABLE_NODE, &test_igmp_receive_report_cmd);
  3990. install_element (ENABLE_NODE, &test_pim_receive_assert_cmd);
  3991. install_element (ENABLE_NODE, &test_pim_receive_dump_cmd);
  3992. install_element (ENABLE_NODE, &test_pim_receive_hello_cmd);
  3993. install_element (ENABLE_NODE, &test_pim_receive_join_cmd);
  3994. install_element (ENABLE_NODE, &test_pim_receive_prune_cmd);
  3995. install_element (ENABLE_NODE, &test_pim_receive_upcall_cmd);
  3996. install_element (ENABLE_NODE, &debug_igmp_cmd);
  3997. install_element (ENABLE_NODE, &no_debug_igmp_cmd);
  3998. install_element (ENABLE_NODE, &undebug_igmp_cmd);
  3999. install_element (ENABLE_NODE, &debug_igmp_events_cmd);
  4000. install_element (ENABLE_NODE, &no_debug_igmp_events_cmd);
  4001. install_element (ENABLE_NODE, &undebug_igmp_events_cmd);
  4002. install_element (ENABLE_NODE, &debug_igmp_packets_cmd);
  4003. install_element (ENABLE_NODE, &no_debug_igmp_packets_cmd);
  4004. install_element (ENABLE_NODE, &undebug_igmp_packets_cmd);
  4005. install_element (ENABLE_NODE, &debug_igmp_trace_cmd);
  4006. install_element (ENABLE_NODE, &no_debug_igmp_trace_cmd);
  4007. install_element (ENABLE_NODE, &undebug_igmp_trace_cmd);
  4008. install_element (ENABLE_NODE, &debug_mroute_cmd);
  4009. install_element (ENABLE_NODE, &no_debug_mroute_cmd);
  4010. install_element (ENABLE_NODE, &debug_static_cmd);
  4011. install_element (ENABLE_NODE, &no_debug_static_cmd);
  4012. install_element (ENABLE_NODE, &debug_pim_cmd);
  4013. install_element (ENABLE_NODE, &no_debug_pim_cmd);
  4014. install_element (ENABLE_NODE, &undebug_pim_cmd);
  4015. install_element (ENABLE_NODE, &debug_pim_events_cmd);
  4016. install_element (ENABLE_NODE, &no_debug_pim_events_cmd);
  4017. install_element (ENABLE_NODE, &undebug_pim_events_cmd);
  4018. install_element (ENABLE_NODE, &debug_pim_packets_cmd);
  4019. install_element (ENABLE_NODE, &debug_pim_packets_filter_cmd);
  4020. install_element (ENABLE_NODE, &no_debug_pim_packets_cmd);
  4021. install_element (ENABLE_NODE, &no_debug_pim_packets_filter_cmd);
  4022. install_element (ENABLE_NODE, &undebug_pim_packets_cmd);
  4023. install_element (ENABLE_NODE, &debug_pim_packetdump_send_cmd);
  4024. install_element (ENABLE_NODE, &no_debug_pim_packetdump_send_cmd);
  4025. install_element (ENABLE_NODE, &undebug_pim_packetdump_send_cmd);
  4026. install_element (ENABLE_NODE, &debug_pim_packetdump_recv_cmd);
  4027. install_element (ENABLE_NODE, &no_debug_pim_packetdump_recv_cmd);
  4028. install_element (ENABLE_NODE, &undebug_pim_packetdump_recv_cmd);
  4029. install_element (ENABLE_NODE, &debug_pim_trace_cmd);
  4030. install_element (ENABLE_NODE, &no_debug_pim_trace_cmd);
  4031. install_element (ENABLE_NODE, &undebug_pim_trace_cmd);
  4032. install_element (ENABLE_NODE, &debug_ssmpingd_cmd);
  4033. install_element (ENABLE_NODE, &no_debug_ssmpingd_cmd);
  4034. install_element (ENABLE_NODE, &undebug_ssmpingd_cmd);
  4035. install_element (ENABLE_NODE, &debug_pim_zebra_cmd);
  4036. install_element (ENABLE_NODE, &no_debug_pim_zebra_cmd);
  4037. install_element (ENABLE_NODE, &undebug_pim_zebra_cmd);
  4038. install_element (CONFIG_NODE, &debug_igmp_cmd);
  4039. install_element (CONFIG_NODE, &no_debug_igmp_cmd);
  4040. install_element (CONFIG_NODE, &undebug_igmp_cmd);
  4041. install_element (CONFIG_NODE, &debug_igmp_events_cmd);
  4042. install_element (CONFIG_NODE, &no_debug_igmp_events_cmd);
  4043. install_element (CONFIG_NODE, &undebug_igmp_events_cmd);
  4044. install_element (CONFIG_NODE, &debug_igmp_packets_cmd);
  4045. install_element (CONFIG_NODE, &no_debug_igmp_packets_cmd);
  4046. install_element (CONFIG_NODE, &undebug_igmp_packets_cmd);
  4047. install_element (CONFIG_NODE, &debug_igmp_trace_cmd);
  4048. install_element (CONFIG_NODE, &no_debug_igmp_trace_cmd);
  4049. install_element (CONFIG_NODE, &undebug_igmp_trace_cmd);
  4050. install_element (CONFIG_NODE, &debug_mroute_cmd);
  4051. install_element (CONFIG_NODE, &no_debug_mroute_cmd);
  4052. install_element (CONFIG_NODE, &debug_static_cmd);
  4053. install_element (CONFIG_NODE, &no_debug_static_cmd);
  4054. install_element (CONFIG_NODE, &debug_pim_cmd);
  4055. install_element (CONFIG_NODE, &no_debug_pim_cmd);
  4056. install_element (CONFIG_NODE, &undebug_pim_cmd);
  4057. install_element (CONFIG_NODE, &debug_pim_events_cmd);
  4058. install_element (CONFIG_NODE, &no_debug_pim_events_cmd);
  4059. install_element (CONFIG_NODE, &undebug_pim_events_cmd);
  4060. install_element (CONFIG_NODE, &debug_pim_packets_cmd);
  4061. install_element (CONFIG_NODE, &debug_pim_packets_filter_cmd);
  4062. install_element (CONFIG_NODE, &no_debug_pim_packets_cmd);
  4063. install_element (CONFIG_NODE, &no_debug_pim_packets_filter_cmd);
  4064. install_element (CONFIG_NODE, &undebug_pim_packets_cmd);
  4065. install_element (CONFIG_NODE, &debug_pim_trace_cmd);
  4066. install_element (CONFIG_NODE, &no_debug_pim_trace_cmd);
  4067. install_element (CONFIG_NODE, &undebug_pim_trace_cmd);
  4068. install_element (CONFIG_NODE, &debug_ssmpingd_cmd);
  4069. install_element (CONFIG_NODE, &no_debug_ssmpingd_cmd);
  4070. install_element (CONFIG_NODE, &undebug_ssmpingd_cmd);
  4071. install_element (CONFIG_NODE, &debug_pim_zebra_cmd);
  4072. install_element (CONFIG_NODE, &no_debug_pim_zebra_cmd);
  4073. install_element (CONFIG_NODE, &undebug_pim_zebra_cmd);
  4074. }