ÿØÿà JFIF    ÿÛ „  ( %"1!%)+...383,7(-.+  -+++--++++---+-+-----+---------------+---+-++7-----ÿÀ  ß â" ÿÄ     ÿÄ H    !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ   ÿÄ %  !1AQa"23‘ÿÚ   ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6  öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ "Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷󲍷˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%ÌÁ²h´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ǍýʏTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆѪQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»& î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$˝Úsäÿ ÷Û #°xŸëí(l »ý3—¥5m! rt`†0~'j2(]S¦¦kv,ÚÇ l¦øJA£Šƒ J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉ䢍mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ­‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U  Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD é©¤&‡ïDbàÁôMÁ." ¤‡ú*õ'VŽ|¼´Úgllº¼klz[Æüï÷Aób‡Eÿ dÑ»Xx9ÃÜ£ÁT/`¼¸vI±Ýµ·Ë‚“G³þ*Ÿû´r|*}<¨îºœ @¦mÄ’M¹”.œ«Y–|6ÏU¤jç¥ÕÞqO ˜kDÆÁ¨5ÿ š;ÐЦ¦€GÙk \ –Þ=â¼=SͧµªS°ÚÍpÜãQűÀõ¬?ÃÁ1Ñ•õZà?hóœ€ L¦l{Y*K˜Ù›zc˜–ˆâ ø+¾ ­-Ök¥%ùEÜA'}ˆ><ÊIè“bpÍ/qÞâvoX€w,\úªò6Z[XdÒæ­@Ö—€$òJí#é>'°Ú ôª˜<)4ryÙ£|óAÅn5žêŸyÒäMÝ2{"}‰–¤l÷ûWX\l¾Á¸góÉOÔ /óñB¤f¸çñ[.P˜ZsÊË*ßT܈§QN¢’¡¨§V¼(Üù*eÕ“”5T¨‹Âê¥FŒã½Dü[8'Ò¥a…Ú¶k7a *•›¼'Ò·\8¨ª\@\õ¢¦íq+DÙrmÎ…_ªæ»ŠÓœ¡¯’Ré9MÅ×D™lælffc+ŒÑ,ý™ÿ ¯þǤ=Å’Á7µ÷ÚÛ/“Ü€ñýã¼àí¾ÕÑ+ƒ,uµMâÀÄbm:ÒÎPæ{˜Gz[ƒ¯«® KHà`ߨŠéí¯P8Aq.C‰ à€kòpj´kN¶qô€…Õ,ÜNŠª-­{Zö’æû44‰sŽè‰îVíRœÕm" 6?³D9¡ÇTíÅꋇ`4«¸ÝÁô ï’ýorqКÇZ«x4Žâéþuïf¹µö[P ,Q£éaX±`PÉÍZ ¸äYúg üAx ’6Lê‚xÝÓ*äQ  Ï’¨hÍ =²,6ï#rÃ<¯–£»ƒ‹,–ê•€ aÛsñ'%Æ"®ÛüìBᝠHÚ3ß°©$“XnœÖ’î2ËTeûìxîß ¦å¿çÉ ðK§þ{‘t‚Ϋ¬jéîZ[ ”š7L¥4VÚCE×]m¤Øy”ä4-dz£œ§¸x.*ãÊÊ b÷•h:©‡¦s`BTÁRû¾g⻩‹jø sF¢àJøFl‘È•Xᓁà~*j¯ +(ÚÕ6-£¯÷GŠØy‚<Ç’.F‹Hœw(+)ÜÜâÈzÄäT§FߘãÏ;DmVœ3Àu@mÚüXÝü•3B¨òÌÁÛ<·ÃÜ z,Ì@õÅ·d2]ü8s÷IôÞ¯^Ç9¢u„~ëAŸï4«M? K]­ÅàPl@s_ p:°¬ZR”´›JC[CS.h‹ƒïËœ«Æ]–÷ó‚wR×k7X‰k›‘´ù¦=¡«‰¨¨Â')—71ó’c‡Ðúµ `é.{§p¹ój\Ž{1h{o±Ý=áUÊïGÖŒõ–-BÄm+AZX¶¡ ïHðæ¥JmÙ;…䡟ˆ¦ ° äšiÉg«$üMk5¤L“’çÊvïâï ,=f“"íἊ5ô¬x6{ɏžID0e¸vçmi'︧ºð9$ò¹÷*£’9ÿ ²TÔ…×>JV¥}Œ}$p[bÔ®*[jzS*8 ”·T›Í–ñUîƒwo$áè=LT™ç—~ô·¤ÈÚ$榍q‰„+´kFm)ž‹©i–ËqÞŠ‰à¶ü( ‚•§ •°ò·‡#5ª•µÊ﯅¡X¨šÁ*F#TXJÊ ušJVÍ&=iÄs1‚3•'fý§5Ñ<=[íÞ­ PÚ;ѱÌ_~Ä££8rÞ ²w;’hDT°>ÈG¬8Á²ÚzŽ®ò®qZcqJêäÞ-ö[ܘbň±çb“ж31²n×iƒðÕ;1¶þÉ ªX‰,ßqÏ$>•î íZ¥Z 1{ç൵+ƒÕµ¥°T$§K]á»Ûï*·¤tMI’ÂZbŽÕiÒ˜}bÓ0£ª5›¨ [5Ž^ÝœWøÂÝh° ¢OWun£¤5 a2Z.G2³YL]jåtì”ä ÁÓ‘%"©<Ôúʰsº UZvä‡ÄiÆÒM .÷V·™ø#kèýiíÌ–ª)µT[)BˆõÑ xB¾B€ÖT¨.¥~ð@VĶr#¸ü*åZNDŽH;âi ],©£öØpù(šºãö¼T.uCê•4@ÿ GÕÛ)Cx›®0ø#:ÏðFÒbR\(€€Ä®fã4Þ‰Fä¯HXƒÅ,†öEÑÔÜ]Öv²?tLÃvBY£ú6Êu5ÅAQ³1‘’¬x–HŒÐ‡ ^ ¸KwJôÖŽ5×CÚ¨vÜ«/B0$×k°=ðbÇ(Ï)w±A†Á† 11Í=èQšµ626ŒÜ/`G«µ<}—-Ö7KEHÈÉðóȤmݱû±·ø«Snmá=“䫚mݱŸ¡¶~ó·“äUóJæúòB|E LêŽy´jDÔ$G¢þÐñ7óR8ýÒ…Ç› WVe#·Ÿ p·Fx~•ݤF÷0Èÿ K¯æS<6’¡WШ; ´ÿ ¥Êø\Òuî†åÝ–VNœkÒ7oòX¨Á­Ø÷FÎÑä±g÷ÿ M~Çî=p,X´ ÝÌÚÅ‹’ÃjÖ.ØöÏñ qïQ¤ÓZE†° =6·]܈ s¸>v•Ž^Ý\wq9r‰Î\¸¡kURÒ$­*‹Nq?Þª*!sŠÆ:TU_u±T+øX¡ ®¹¡,ÄâÃBTsÜ$Ø›4m椴zÜK]’’›Pƒ @€#â˜`é¹=I‡fiV•Ôî“nRm+µFPOhÍ0B£ €+¬5c v•:P'ÒyÎ ‰V~‚Ó†ÖuókDoh$å\*ö%Ю=£«…aȼ½÷Û.-½VŒŠ¼'lyî±1¬3ó#ÞE¿ÔS¤gV£m›=§\û"—WU¤ÚǼÿ ÂnÁGŒÃ ‚õN D³õNÚíŒÕ;HôyÄÈ©P¹Ä{:?R‘Ô¨âF÷ø£bÅó® JS|‚R÷ivýáâ€Æé¡è³´IئÑT!§˜•ت‚¬â@q€wnïCWÄ@JU€ê¯m6]Ï:£âx'+ÒðXvÓ¦Úm=–´7œ $ì“B£~p%ÕŸUþ« N@¼üï~w˜ñø5®—'Ôe»¤5ã//€ž~‰Tþ›Å7•#¤× Íö pÄ$ùeåì*«ÓŠEØWEÈsßg ¦ûvžSsLpºÊW–âµEWöˬH; ™!CYõZ ÃÄf æ#1W. \uWâ\,\Çf j’<qTbên›Î[vxx£ë 'ö¨1›˜ÀM¼Pÿ H)ƒêêŒA7s,|F“ 꺸k³9Ìö*ç®;Ö!Ö$Eiž•¹ÒÚ†ýóéÝû¾ÕS®ó$’NÝäŸz¤5r¦ãÄÃD÷Üø!°ø‡Ô&@m™Ì^Ãä­d q5Lnÿ N;.6½·N|#ä"1Nƒx“ã<3('&ñßt  ~ªu”1Tb㫨9ê–›–bìd$ߣ=#ÕãÒmU¯eí$EFù5ýYô櫨æì™Ç—±ssM]·á¿0ÕåJRÓªîiƒ+O58ÖñªŠÒx" \µâá¨i’¤i —Ö ” M+M¤ë9‚‰A¦°Qõ¾ßøK~¼Ã‘g…Ö´~÷Ï[3GUœÒ½#…kàÔ®Ò”‰³·dWV‰IP‰Ú8u¹”E ÖqLj¾êÕCBš{A^Âß;–¨`¯¬ìö ˼ ×tìø.tƐm*n¨y4o&Àx¥n¦×î‡aupáÛj8¿m›è¶ã!o½;ß0y^ý×^EÑ¿ÒjzŒ­)vÚÑnÄL …^ªô× ‡—‚3k Îý­hï]içå–îÏ*÷ñþ»Ô CÒjøjÍznˆ´ ¹#b'Fô‹ ‰v¥'’à'T´ƒHýÍ%M‰ ƒ&ÆÇŒï1 ‘ –Þ ‰i¬s žR-Ÿ kЬá¬7:þ 0ŒÅÒÕ/aÙ¬ÃÝ#Úøœ ©aiVc‰. ¹¦ãµ” ›Yg¦›ÆÎýº°f³7ƒhá·¸­}&D9¡ÂsÉÙÞèŠõØàC™¨ñbFC|´Ü(ŸƒÚÒ-%»'a Ì¿)ËÇn¿úÿ ÞŽX…4ÊÅH^ôΑí@ù¹Eh¶“L8Çjù ¼ÎåVªóR©Ï5uà V4lZß®=€xÖŸ–ÑÈ ÷”¨°¾__yM1tÉ?uÆþIkÄgæ@þ[¢†°XÃJ£j·:nkÅ¢u ‘}âGzö­/IµèЬ¼48q¦F°ŽR¼=ûì{´¯RýicS ÕÛ íNtÍÙï£,w4rêì®»~x(©Uñ§#Ñ&œÕ¤>ÎåÍÓ9’Ö{9eV­[Öjâ²ãu]˜å2›qÑšÕJç0€sÄ|Êëè0튔bÁ>“{×_F`Ø©ºê:µä,v¤ðfc1±"«ÔÍän1#=· Âøv~H½ÐßA¾¿Ü€Óš]Õ; I¾÷ç‚Qi†î¹9ywÔKG˜áñ zQY—§ÃÕZ07§X‚ Áh;ÁM)iÌCH-¯T‘ë|A0{Ò½LÚ–TâÖkÜ’dÀ“rmm»”جPF³ÖcbE§T€ÒxKºû’Ó®7±²(\4ŽÃ¸Uu@j™yĵ;³µ!Á¢b.W¤=mõ´êµK k ¸K^ÜÛ#p*Ü14qkZç5ïë †°5Ï%ÍÛ<Õ¤×Ô¥ê†C Õ´¼ú$ƒÖ“”]Ù¬qÞÚ[4©ý!ûÏ—Áb쳐XµA¬â~`›Çr¸8ìùÝ䫦<>ä÷«?xs´ÇÑ /á;¹øüÊÈÙà{"@Žïzâ¬[âß‚ U_<ÇŸ½4èN˜ú61®qŠu ¦þF£»äJ_ˆÙÎ~ ÞAã–݄ϗrŠD;xTž‘ô`É«…suãO`?³à™ô Lý#Íc5öoæØ‚y´´÷«ZR§<&JÇ+éâô´€i!Àˆ0æAoàðLèÖ-2ŸõW.’t^–(KÁmHµV@xÜÇy®Ñø­â^:Ú3w· 7½¹°ñ¸â¹®:',«Mœ—n­Á+Ãbš LÈ‘ÄnRÓÅœ%¦²‰¨ùQ:¤f‚ "PÕtô¸…cæl…&˜Ú˜Ôkv‹ž+vŠ,=¢v­6—Xy*¥t£«<™:“aîϲ=¦6rO]XI¿Œ÷¤zÚ­›¶ 6÷”w\d ü~v®ˆÌk«^m<ÿ ¢‰Õ\)ùºŽ;… lîÙÅEŠ®cѾ@vnMÏ,¼“ñ•ŽBxðÃzãÇç%3ˆ"}Ù•Åî> BÉú;Ò]V+P˜F_´ßé> Øše|ï‡ÄOmFæÇ ãqÞ$/xÐx­z`ï9"œÜij‚!7.\Td…9M‡•iŽ‹¾‘50ÞŽn¥ß4ÉôO ¹*í^QêËÜÇÌ8=ާs‰'ÂëÙ«á%Pú[O †ÅP¯Vsް.‰,kc¶ ¬A9n˜XÎ-ÞšN["¹QÕ‰ƒMýÁߺXJæÍaLj¾×Ãmã¾ãÚ uñÒþåQô¦¥ /ÄUx:‚ÍÜ’ Đ©ØÝ3V¨‰ÕnÐ6ó*óúK­«…c ¯U òhsý­jóÔj#,ímŒRµ«lbïUTŒÑ8†Ä0œÏr`ð¡¬É Ї ë"À² ™ 6¥ f¶ ¢ÚoܱԷ-<Àî)†a¶ž'Ú»¨TXqØæ¶÷YÄHy˜9ÈIW­YÀuMFë ºÏ’AqÌ4·/Ú †ô'i$øä­=Ä Ý|öK×40è|È6p‘0§)o¥ctî§H+CA-“ xØ|ÐXАç l8íºð3Ø:³¤¬KX¯UÿÙ #!/usr/bin/perl # # Copyright (c) IBM Corp. 2009, 2010, All Rights Reserved # # Author(s): Vasileios Pappas # Jens Osterkamp # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. use NetSNMP::OID (':all'); use NetSNMP::ASN (':all'); use NetSNMP::agent (':all'); sub STP_PROP_VALUE() { 0x01} sub STP_PROP_FILE() { 0x02} sub STP_PROP_DEC() { 0x04} sub STP_PROP_HEX() { 0x08} sub FDB_STATUS_OTHER { 1 } sub FDB_STATUS_INVALID { 2 } sub FDB_STATUS_LEARNED { 3 } sub FDB_STATUS_SELF { 4 } sub FDB_STATUS_MGMT { 5 } my %oid_value; my %oid_type; my %oid_next; my (%indexes, %interfaces, %macs, %ages, %locals, %vlans, %tagged); my $oid; $subagent=0; my $netdir="/sys/class/net/"; my $targetbridge; $cache_timout=60; $last_populated=0; my $regoid = ".1.3.6.1.2.1.17"; # are we running embedded ? If not, register as subagent if (!$agent) { $agent = new NetSNMP::agent('Name' => 'dot1qbridge', 'AgentX' => 1); $subagent = 1; if ( $#ARGV != 0) { usage($0); exit(); } $targetbridge = $ARGV[0]; } else { if (!defined($bridge)) { usage($0); exit(); } $targetbridge = $bridge; } $agent->register("dot1qbridge", ".1.3.6.1.2.1.17", \&request_handler) or die "registration of handler failed !\n"; if ($subagent) { # register handler for graceful shutdown $SIG{'INT'} = \&shutdown; $SIG{'QUIT'} = \&shutdown; $running = 1; while($running) { $agent->agent_check_and_process(1); } $agent->shutdown(); } sub usage { my $name = shift; if ($subagent) { print $name."\n\n"; print "usage: \t$name start snmp bridge module". " for bridge \n\n"; print "arguments: bridge name of the Linux bridge". " which you want to provide info via snmp for.\n\n"; } else { print 'usage in snmpd.conf: perl $bridge="br0"; perl do \n'; } print "number of arguments given $#ARGV\n\n"; } sub request_handler { my ($handler, $registration_info, $request_info, $requests)=@_; my $request; populate_mib($targetbridge); for($request = $requests; $request; $request = $request->next()) { if($request_info->getMode() == MODE_GET) { mode_get($request); } elsif($request_info->getMode() == MODE_GETNEXT) { mode_get_next($request); } else { print STDERR "mode not implemented.\n"; } } } sub mode_get{ my ($request)=@_; my $oid=$request->getOID(); $SNMP::use_numeric = 1; my $noid=SNMP::translateObj($oid); reply($request, $noid) if (exists $oid_value{$noid}); } sub find_next{ my ($noid) = @_; my $nextoid = $oid_next{$noid}; if(!defined($nextoid) || !defined($oid_value{$nextoid})) { # find the lowest OID whis is higher than $noid $prev = ".1.3.6.1.2.1.18"; $prev_oid = new NetSNMP::OID($prev); $noid_oid = new NetSNMP::OID($noid); #print "looking for next of $noid\n"; for my $candidate (keys %oid_value) { #print "evaluating $candidate\n"; $candidate_oid = new NetSNMP::OID($candidate); if ($noid_oid < $candidate_oid && $prev_oid > $candidate_oid) { #print "found candidate $candidate\n"; $prev = $candidate; $prev_oid = $candidate_oid; } } if ($prev eq ".1.3.6.1.2.1.18") { return; # no OID higher than $noid found } $nextoid = $prev; } return $nextoid; } sub mode_get_next{ my ($request)=@_; my $oid=$request->getOID(); $SNMP::use_numeric = 1; my $noid=SNMP::translateObj($oid); my $nextoid = find_next($noid); #print "found $nextoid\n"; if(defined($nextoid)) { my $type = $oid_type{$nextoid}; my $value = $oid_value{$nextoid}; if (defined($type) and defined($value)) { reply($request, $nextoid); } } } sub reply{ my ($request, $oid)=@_; my $type=$oid_type{$oid}; my $value=$oid_value{$oid}; $request->setOID(new NetSNMP::OID($oid)); $request->setValue($type, $value); } # Populated MIB OID # ## dot1dBasePort: 1.3.6.1.2.1.17.1.4.1.1. # INTEGER32 # # dot1dBasePortIfIndex: 1.3.6.1.2.1.17.1.4.1.2. # INTEGER32 # # dot1dStp*: 1.3.6.1.2.1.17.2.<1-14> # INTEGER, OCTET STRING # # dot1dTpFdbAddress: 1.3.6.1.2.1.17.4.3.1.1. # OCTET STRING (SIZE (6)) # # dot1dTpFdbPort: 1.3.6.1.2.1.17.4.3.1.2. # INTEGER32 # # dot1dTpFdbStatus: 1.3.6.1.2.1.17.4.3.1.3. # INTEGER # 1 : other # 2 : invalid # 3 : learned # 4 : self # 5 : mgmt # sub populate_mib { my $now; my $bridge = shift; my $seconds_passed; $ports=0; $oid=""; $now=time(); $seconds_passed=$now-$last_populated; return if($seconds_passed <= $cache_timout); $last_populated=$now; %oid_value=(); %oid_type=(); %oid_next=(); %indexes=(); %interfaces=(); %macs=(); %ages=(); %locals=(); %vlans=(); %tagged=(); # first populated oid $oid_next{".1.3.6.1.2.1.17"}=".1.3.6.1.2.1.17.1.1"; createbaseinfo($bridge); readindexes($bridge); readforwards($bridge); readvlans($bridge); createports($bridge); stpproperties($bridge); stpportproperties($bridge); dot1dTpproperties(); my $prevoid = $oid; my $curroid = createmacs($bridge); $oid_next{$prevoid} = $curroid; portproperties($bridge); dot1qbase($bridge); dot1qfdb($bridge); dot1qcurrentvlans($bridge); return 0; } sub findbridges() { my @bridges; opendir(DIR, $netdir) or die "unable to open $netdir !\n"; while(my $br=readdir(DIR)){ next if $br eq "."; next if $br eq ".."; next unless -d $netdir.$br."/bridge"; push @bridges, $br; } close(DIR); return @bridges; } sub createbaseinfo() { my $bridge = shift; $oid=".1.3.6.1.2.1.17.1.1"; $oid_value{$oid}=mac2hex(readfile($netdir.$bridge."/address", 0)); $oid_type{$oid}=ASN_OCTET_STR; $oid_next{$oid}=".1.3.6.1.2.1.17.1.2"; opendir(DIR, $netdir.$bridge."/brif/") or die "Could not open ".$netdir.$bridge."brif !\n"; foreach $entry (readdir(DIR)) { next if $entry eq "."; next if $entry eq ".."; # only count non-vlan interfaces next if $entry =~ /\.[0-9]*/; $ports++; } closedir(DIR); $oid=".1.3.6.1.2.1.17.1.2"; $oid_value{$oid}=$ports; $oid_type{$oid}=ASN_INTEGER; $oid_next{$oid}=".1.3.6.1.2.1.17.1.3"; $oid=".1.3.6.1.2.1.17.1.3"; $oid_value{$oid}="2"; # transparent only $oid_type{$oid}=ASN_INTEGER; $oid_next{$oid}=".1.3.6.1.2.1.17.1.4.1.1.1"; } sub createmacs() { my $bridge = shift; my $start_oid = $oid = ".1.3.6.1.2.1.17.4.3.1"; foreach my $mac (sort {$a cmp $b} keys %macs) { my $mac_oid=mac2oid($mac); unless(defined($first_mac_oid)){ $first_mac_oid=$mac_oid; $oid_next{$oid.".1"}=$oid.".1".$mac_oid; $oid_next{$oid.".2"}=$oid.".2".$mac_oid; $oid_next{$oid.".3"}=$oid.".3".$mac_oid; } my $port=$macs{$mac}{$bridge}; my $baseport=$baseports{$bridge}{$port}; my $status=$locals{$mac}{$bridge}; my $age=$ages{$mac}{$bridge}; $oid_value{$oid.".1".$mac_oid}=mac2hex($mac); $oid_type{$oid.".1".$mac_oid}=ASN_OCTET_STR; if(defined($prv_mac_oid)){ $oid_next{$oid.".1".$prv_mac_oid}= $oid.".1".$mac_oid; } $oid_value{$oid.".2".$mac_oid}=$baseport; $oid_type{$oid.".2".$mac_oid}=ASN_INTEGER; if(defined($prv_mac_oid)){ $oid_next{$oid.".2".$prv_mac_oid}= $oid.".2".$mac_oid; } $oid_value{$oid.".3".$mac_oid}=$status; $oid_type{$oid.".3".$mac_oid}=ASN_INTEGER; if(defined($prv_mac_oid)){ $oid_next{$oid.".3".$prv_mac_oid}= $oid.".3".$mac_oid; } $prv_mac_oid=$mac_oid; } if ($prv_mac_oid and $first_mac_oid) { $oid_next{$oid.".1".$prv_mac_oid}=$oid.".2".$first_mac_oid; $oid_next{$oid.".2".$prv_mac_oid}=$oid.".3".$first_mac_oid; $oid_next{$oid.".3".$prv_mac_oid}=".1.3.6.1.2.1.17.4.4.1.1.1"; } undef $prv_mac_oid; undef $first_mac_oid; return $start_oid.".1".$first_mac_oid; } # TODO: is this sequence complete ? sub createports() { my $bridge = shift; my ($baseport, $prev_baseport, $first_baseport); $baseport=1; my $oid= '.1.3.6.1.2.1.17.1.4.1'; foreach my $port (keys %{$interfaces{$bridge}}) { unless(defined($first_baseport)){ $first_baseport=$baseport; $oid_next{$oid.".1"}=$oid.".1.".$baseport; $oid_next{$oid.".2"}=$oid.".2.".$baseport; } my $index=$indexes{$bridge}{$port}; $baseports{$bridge}{$port}=$baseport; $oid_value{$oid.".1.".$baseport}=$baseport; $oid_type{$oid.".1.".$baseport}=ASN_INTEGER; if(defined($prv_baseport)){ $oid_next{$oid.".1.".$prv_baseport}= $oid.".1.".$baseport; } $oid_value{$oid.".2.".$baseport}=$index; $oid_type{$oid.".2.".$baseport}=ASN_INTEGER; if(defined($prv_baseport)){ $oid_next{$oid.".2.".$prv_baseport}= $oid.".2.".$baseport; } $prv_baseport=$baseport; $baseport++; } if ( $prv_baseport and $first_baseport ) { $oid_next{$oid.".1.".$prv_baseport}=$oid.".2.".$first_baseport; $oid_next{$oid.".2.".$prv_baseport}=".1.3.6.1.2.1.17.2.1"; } undef $prv_baseport; undef $first_baseport; } sub stpproperties() { my $bridge = shift; my $dir = $netdir.$bridge."/bridge/"; @stpprops = ( { oid => ".1.3.6.1.2.1.17.2.1", flags => STP_PROP_VALUE, value => "3", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.2" }, { oid => ".1.3.6.1.2.1.17.2.2", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."priority", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.3" }, { oid => ".1.3.6.1.2.1.17.2.3", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."topology_change_timer", type => ASN_TIMETICKS, nextoid => ".1.3.6.1.2.1.17.2.4" }, { oid => ".1.3.6.1.2.1.17.2.4", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."topology_change", type => ASN_COUNTER, nextoid => ".1.3.6.1.2.1.17.2.5" }, { oid => ".1.3.6.1.2.1.17.2.5", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."root_id", type => ASN_OCTET_STR, nextoid => ".1.3.6.1.2.1.17.2.6" }, { oid => ".1.3.6.1.2.1.17.2.6", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."root_path_cost", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.7" }, { oid => ".1.3.6.1.2.1.17.2.7", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."root_port", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.8" }, { oid => ".1.3.6.1.2.1.17.2.8", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."max_age", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.9" }, { oid => ".1.3.6.1.2.1.17.2.9", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."hello_time", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.11" }, # TODO ...17.2.10 { oid => ".1.3.6.1.2.1.17.2.11", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."forward_delay", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.12" }, { oid => ".1.3.6.1.2.1.17.2.12", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."max_age", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.13" }, { oid => ".1.3.6.1.2.1.17.2.13", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."hello_time", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.14" }, { oid => ".1.3.6.1.2.1.17.2.14", flags => STP_PROP_FILE | STP_PROP_DEC, value => $dir."forward_delay", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.2.15.1.1.1" }, ); for ($i=0; $i <= $#stpprops; $i++) { my %props = %{$stpprops[$i]}; $oid = $props{'oid'}; if ( $props{'flags'} & STP_PROP_VALUE,) { $oid_value{$oid} = $props{'value'}; } if ( $props{'flags'} & STP_PROP_FILE,) { $oid_value{$oid} = readfile($props{'value'}, $props{'flags'}); } $oid_type{$oid} = $props{'type'}; $oid_next{$oid} = $props{'nextoid'}; } } sub stpportproperties { my $bridge = shift; my $brifdir = $netdir.$bridge."/brif/"; my ($baseport, $first_baseport, $prev_baseport); $oid='.1.3.6.1.2.1.17.2.15.1'; foreach my $port (keys %{$interfaces{$bridge}}) { $baseport = $baseports{$bridge}{$port}; unless(defined($first_baseport)){ $first_baseport=$baseport; $oid_next{$oid.".1"}=$oid.".1.".$baseport; $oid_next{$oid.".2"}=$oid.".2.".$baseport; } my $interface = $interfaces{$bridge}{$port}; my $ifdir = $brifdir.$interface; # dot1dStpPort $oid_value{$oid.".1.".$baseport}=$baseport; $oid_type{$oid.".1.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".1.".$prev_baseport}= $oid.".1.".$baseport; } # dot1dStpPortPriority $oid_value{$oid.".2.".$baseport}=readfile($ifdir."/priority", 0); $oid_type{$oid.".2.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".2.".$prev_baseport}= $oid.".2.".$baseport; } # dot1dStpPortState my @translation = (1, 3, 4, 5, 2); my $state = readfile($ifdir."/state", 0); $oid_value{$oid.".3.".$baseport}=$translation[$state]; $oid_type{$oid.".3.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".3.".$prev_baseport}= $oid.".3.".$baseport; } # dot1dStpPortEnable @translation = (2, 1, 1, 1, 1); $oid_value{$oid.".4.".$baseport}=$translation[$state]; $oid_type{$oid.".4.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".4.".$prev_baseport}= $oid.".4.".$baseport; } # dot1dStpPortPathCost $oid_value{$oid.".5.".$baseport}=readfile($ifdir."/path_cost", 0); $oid_type{$oid.".5.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".5.".$prev_baseport}= $oid.".5.".$baseport; } # dot1dStpPortDesignatedRoot $oid_value{$oid.".6.".$baseport}=readfile($ifdir."/designated_root", 0); $oid_type{$oid.".6.".$baseport}=ASN_OCTET_STR; if(defined($prev_baseport)){ $oid_next{$oid.".6.".$prev_baseport}= $oid.".6.".$baseport; } # dot1dStpPortDesignatedCost $oid_value{$oid.".7.".$baseport}=readfile($ifdir."/designated_cost", 0); $oid_type{$oid.".7.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".7.".$prev_baseport}= $oid.".7.".$baseport; } # dot1dStpPortDesignatedBridge $oid_value{$oid.".8.".$baseport}=readfile($ifdir."/designated_bridge", 0); $oid_type{$oid.".8.".$baseport}=ASN_OCTET_STR; if(defined($prev_baseport)){ $oid_next{$oid.".8.".$prev_baseport}= $oid.".8.".$baseport; } # dot1dStpPortDesignatedPort $oid_value{$oid.".9.".$baseport}=readfile($ifdir."/designated_port", 0); $oid_type{$oid.".9.".$baseport}=ASN_OCTET_STR; if(defined($prev_baseport)){ $oid_next{$oid.".9.".$prev_baseport}= $oid.".9.".$baseport; } # dot1dStpPortForwardTransitions (no value in bridge module) # dot1dStpPortPathCost32 $oid_value{$oid.".11.".$baseport}=readfile($ifdir."/path_cost", 0); $oid_type{$oid.".11.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".11.".$prev_baseport}= $oid.".11.".$baseport; } $prev_baseport=$baseport; } if ( $prev_baseport and $first_baseport ) { $oid_next{$oid.".1.".$prev_baseport}=$oid.".2.".$first_baseport; $oid_next{$oid.".2.".$prev_baseport}=$oid.".3.".$first_baseport; $oid_next{$oid.".3.".$prev_baseport}=$oid.".4.".$first_baseport; $oid_next{$oid.".4.".$prev_baseport}=$oid.".5.".$first_baseport; $oid_next{$oid.".5.".$prev_baseport}=$oid.".6.".$first_baseport; $oid_next{$oid.".6.".$prev_baseport}=$oid.".7.".$first_baseport; $oid_next{$oid.".7.".$prev_baseport}=$oid.".8.".$first_baseport; $oid_next{$oid.".8.".$prev_baseport}=$oid.".9.".$first_baseport; $oid_next{$oid.".9.".$prev_baseport}=$oid.".11.".$first_baseport; $oid_next{$oid.".11.".$prev_baseport}=".1.3.6.1.2.1.17.4.1"; } $oid = $oid.".11.".$prev_baseport; undef $prev_baseport; undef $first_baseport; } sub dot1dTpproperties() { @stpprops = ( { oid => ".1.3.6.1.2.1.17.4.1", flags => STP_PROP_VALUE, value => "0", type => ASN_COUNTER, nextoid => ".1.3.6.1.2.1.17.4.2" }, { oid => ".1.3.6.1.2.1.17.4.2", flags => STP_PROP_VALUE, value => "300", type => ASN_INTEGER, nextoid => ".1.3.6.1.2.1.17.4.3" }, ); for ($i=0; $i <= $#stpprops; $i++) { my %props = %{$stpprops[$i]}; $oid = $props{'oid'}; if ( $props{'flags'} & STP_PROP_VALUE,) { $oid_value{$oid} = $props{'value'}; } if ( $props{'flags'} & STP_PROP_FILE,) { $oid_value{$oid} = readfile($props{'value'}, $props{'flags'}); } $oid_type{$oid} = $props{'type'}; $oid_next{$oid} = $props{'nextoid'}; } } sub portproperties { my $bridge = shift; my ($baseport, $first_baseport, $prev_baseport); $oid='.1.3.6.1.2.1.17.4.4.1'; foreach my $port (keys %{$interfaces{$bridge}}) { $baseport = $baseports{$bridge}{$port}; unless(defined($first_baseport)){ $first_baseport=$baseport; $oid_next{$oid.".1"}=$oid.".1.".$baseport; $oid_next{$oid.".2"}=$oid.".2.".$baseport; } my $interface = $interfaces{$bridge}{$port}; my $ifdir = $netdir.$interface; # dot1dTpPort $oid_value{$oid.".1.".$baseport}=$baseport; $oid_type{$oid.".1.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".1.".$prev_baseport}= $oid.".1.".$baseport; } # dot1dTpPortMaxInfo $oid_value{$oid.".2.".$baseport}=readfile($ifdir."/mtu", 0); $oid_type{$oid.".2.".$baseport}=ASN_INTEGER; if(defined($prev_baseport)){ $oid_next{$oid.".2.".$prev_baseport}= $oid.".2.".$baseport; } # dot1dTpPortInFrames $oid_value{$oid.".3.".$baseport}=readfile($ifdir."/statistics/rx_packets", 0); $oid_type{$oid.".3.".$baseport}=ASN_COUNTER; if(defined($prev_baseport)){ $oid_next{$oid.".3.".$prev_baseport}= $oid.".3.".$baseport; } # dot1dTpPortOutFrames $oid_value{$oid.".4.".$baseport}=readfile($ifdir."/statistics/tx_packets", 0); $oid_type{$oid.".4.".$baseport}=ASN_COUNTER; if(defined($prev_baseport)){ $oid_next{$oid.".4.".$prev_baseport}= $oid.".4.".$baseport; } # dot1dTpPortInDiscards $oid_value{$oid.".5.".$baseport}=readfile($ifdir."/statistics/rx_dropped", 0); $oid_type{$oid.".5.".$baseport}=ASN_COUNTER; if(defined($prev_baseport)){ $oid_next{$oid.".5.".$prev_baseport}= $oid.".5.".$baseport; } $prev_baseport=$baseport; } if ( $prev_baseport and $first_baseport ) { $oid_next{$oid.".1.".$prev_baseport}=$oid.".2.".$first_baseport; $oid_next{$oid.".2.".$prev_baseport}=$oid.".3.".$first_baseport; $oid_next{$oid.".3.".$prev_baseport}=$oid.".4.".$first_baseport; $oid_next{$oid.".4.".$prev_baseport}=$oid.".5.".$first_baseport; $oid_next{$oid.".5.".$prev_baseport}=".1.3.6.1.2.1.17.5.1"; } $oid = $oid.".5.".$prev_baseport; undef $prev_baseport; undef $first_baseport; } sub dot1qbase() { my $bridge = shift; my $oid=".1.3.6.1.2.1.17.7.1.1"; $oid_next{".1.3.6.1.2.1.17.7"}=$oid.".1"; $oid_next{".1.3.6.1.2.1.17.7.1"}=$oid.".1"; $oid_value{$oid.".1"}=1; $oid_type{$oid.".1"}=ASN_INTEGER; $oid_next{$oid.".1"}=$oid.".2"; $oid_value{$oid.".2"}=4094; $oid_type{$oid.".2"}=ASN_UNSIGNED; $oid_next{$oid.".2"}=$oid.".3"; $oid_value{$oid.".3"}=4094; $oid_type{$oid.".3"}=ASN_UNSIGNED; $oid_next{$oid.".3"}=$oid.".4"; $oid_value{$oid.".4"}=0; # filled in by currentvlans $oid_type{$oid.".4"}=ASN_UNSIGNED; $oid_next{$oid.".4"}=$oid.".5"; $oid_value{$oid.".5"}=2; $oid_type{$oid.".5"}=ASN_INTEGER; $oid_next{$oid.".5"}=0; # filled in by dot1qfdb } sub dot1qfdb() { my $bridge = shift; my $oid=".1.3.6.1.2.1.17.7.1.2"; foreach my $vlan (sort {$a<=>$b} keys %vlans){ unless(defined($first_vlan)){ $first_vlan=$vlan; $oid_next{".1.3.6.1.2.1.17.7.1.1.5"}=$oid.".1.1.".$vlan; $oid_next{$oid}=$oid.".1.1.".$vlan; $oid_next{$oid.".1"}=$oid.".1.1.".$vlan; $oid_next{$oid.".1.1"}=$oid.".1.1.".$vlan; $oid_next{$oid.".1.2"}=$oid.".1.2.".$vlan; } $oid_value{$oid.".1.1.".$vlan}=$vlan; $oid_type{$oid.".1.1.".$vlan}=ASN_UNSIGNED; if(defined($prv_vlan)){ $oid_next{$oid.".1.1.".$prv_vlan}=$oid.".1.1.".$vlan; } $oid_value{$oid.".1.2.".$vlan}=0; # to be filled later $oid_type{$oid.".1.2.".$vlan}=ASN_COUNTER; if(defined($prv_vlan)){ $oid_next{$oid.".1.2.".$prv_vlan}=$oid.".1.2.".$vlan; } $prv_vlan=$vlan; } if($prv_vlan and $first_vlan){ $oid_next{$oid.".1.1.".$prv_vlan}=$oid.".1.2.".$first_vlan; $oid_next{$oid.".1.2.".$prv_vlan}=0; # to be filled later } my %macvlan=(); my %vlanmac=(); foreach my $vlan (sort {$a<=>$b} keys %vlans){ my $count=0; foreach my $mac (sort {$a cmp $b} keys %macs) { my $vbridge=$bridge."_vlan".$vlan; next unless(defined($macs{$mac}{$vbridge})); $count++; my $mac_oid=mac2oid($mac); $macvlan{$vlan.$mac_oid}=$mac; $vlanmac{$vlan.$mac_oid}=$vlan; } $oid_value{$oid.".1.2.".$vlan}=$count; } foreach my $vmac_oid (sort {$a cmp $b} keys %vlanmac){ my $mac=$macvlan{$vmac_oid}; my $vlan=$vlanmac{$vmac_oid}; #print "VMAC: $vmac_oid ($vlan:$mac)\n"; unless(defined($first_vmac_oid)){ $first_vmac_oid=$vmac_oid; $oid_next{$oid.".1.2.".$prv_vlan}=$oid.".2.1.".$vmac_oid; $oid_next{$oid.".2"}=$oid.".2.1.".$vmac_oid; $oid_next{$oid.".2.1"}=$oid.".2.1.".$vmac_oid; $oid_next{$oid.".2.2"}=$oid.".2.2.".$vmac_oid; $oid_next{$oid.".2.3"}=$oid.".2.3.".$vmac_oid; } my $port=$macs{$mac}{$bridge}; my $baseport=$baseports{$bridge}{$port}; my $status=$locals{$mac}{$bridge}; my $age=$ages{$mac}{$bridge}; print "VLAN $vlan: $mac -> $port:$baseport ($status, $age)\n"; $oid_value{$oid.".2.1.".$vmac_oid}=mac2hex($mac); $oid_type{$oid.".2.1.".$vmac_oid}=ASN_OCTET_STR; if(defined($prv_vmac_oid)){ $oid_next{$oid.".2.1.".$prv_vmac_oid}=$oid.".2.1.".$vmac_oid; } $oid_value{$oid.".2.2.".$vmac_oid}=$baseport; $oid_type{$oid.".2.2.".$vmac_oid}=ASN_INTEGER; if(defined($prv_vmac_oid)){ $oid_next{$oid.".2.2.".$prv_vmac_oid}=$oid.".2.2.".$vmac_oid; } $oid_value{$oid.".2.3.".$vmac_oid}=$status; $oid_type{$oid.".2.3.".$vmac_oid}=ASN_INTEGER; if(defined($prv_vmac_oid)){ $oid_next{$oid.".2.3.".$prv_vmac_oid}=$oid.".2.3.".$vmac_oid; } $prv_vmac_oid=$vmac_oid; } if ($prv_vmac_oid and $first_vmac_oid) { $oid_next{$oid.".2.1.".$prv_vmac_oid}=$oid.".2.2.".$first_vmac_oid; $oid_next{$oid.".2.2.".$prv_vmac_oid}=$oid.".2.3.".$first_vmac_oid; $oid_next{$oid.".2.3.".$prv_vmac_oid}=".1.3.6.1.2.1.17.7.1.4.1"; } undef $first_vmac_oid; undef $prv_vmac_oid; undef $first_vlan; undef $prv_vlan; } sub dot1qcurrentvlans() { my $bridge = shift; my $oid=".1.3.6.1.2.1.17.7.1.4.1"; $oid_next{".1.3.6.1.2.1.17.7.1.4"}=$oid; $oid_value{$oid}=0; # can't keep track of this info $oid_type{$oid}=ASN_COUNTER; my $count=0; $oid=".1.3.6.1.2.1.17.7.1.4.2"; foreach my $vlan (sort {$a<=>$b} keys %vlans){ $count++; my @allports=(); my @untaggedports=(); foreach my $port (keys %{$vlans{$vlan}}){ $baseport=$baseports{$bridge}{$port}; push @allports, $baseport; push @untaggedports, $baseport unless($tagged{$vlan}{$port}); } #print "ADDING: vlan $vlan (@allports, @untaggedports)\n"; unless(defined($first_vlan)){ $first_vlan=$vlan; $oid_next{".1.3.6.1.2.1.17.7.1.4.1"}=$oid.".1.0.".$vlan; $oid_next{$oid}=$oid.".1.0.".$vlan; $oid_next{$oid.".1"}=$oid.".1.0.".$vlan; $oid_next{$oid.".2"}=$oid.".2.0.".$vlan; $oid_next{$oid.".3"}=$oid.".3.0.".$vlan; $oid_next{$oid.".4"}=$oid.".4.0.".$vlan; $oid_next{$oid.".5"}=$oid.".5.0.".$vlan; $oid_next{$oid.".6"}=$oid.".6.0.".$vlan; $oid_next{$oid.".7"}=$oid.".7.0.".$vlan; } $oid_value{$oid.".1.0.".$vlan}=0; # can't keep track of this $oid_type{$oid.".1.0.".$vlan}=ASN_TIMETICKS; if(defined($prv_vlan)){ $oid_next{$oid.".1.0.".$prv_vlan}=$oid.".1.0.".$vlan; } $oid_value{$oid.".2.0.".$vlan}=$vlan; $oid_type{$oid.".2.0.".$vlan}=ASN_UNSIGNED; if(defined($prv_vlan)){ $oid_next{$oid.".2.0.".$prv_vlan}=$oid.".2.0.".$vlan; } $oid_value{$oid.".3.0.".$vlan}=$vlan; $oid_type{$oid.".3.0.".$vlan}=ASN_UNSIGNED; if(defined($prv_vlan)){ $oid_next{$oid.".3.0.".$prv_vlan}=$oid.".3.0.".$vlan; } $oid_value{$oid.".4.0.".$vlan}=getportlist(@allports); $oid_type{$oid.".4.0.".$vlan}=ASN_OCTET_STR; if(defined($prv_vlan)){ $oid_next{$oid.".4.0.".$prv_vlan}=$oid.".4.0.".$vlan; } $oid_value{$oid.".5.0.".$vlan}=getportlist(@untaggedports); $oid_type{$oid.".5.0.".$vlan}=ASN_OCTET_STR; if(defined($prv_vlan)){ $oid_next{$oid.".5.0.".$prv_vlan}=$oid.".5.0.".$vlan; } $oid_value{$oid.".6.0.".$vlan}=1; $oid_type{$oid.".6.0.".$vlan}=ASN_INTEGER; if(defined($prv_vlan)){ $oid_next{$oid.".6.0.".$prv_vlan}=$oid.".6.0.".$vlan; } $oid_value{$oid.".7.0.".$vlan}=0; $oid_type{$oid.".7.0.".$vlan}=ASN_TIMETICKS; if(defined($prv_vlan)){ $oid_next{$oid.".7.0.".$prv_vlan}=$oid.".7.0.".$vlan; } $prv_vlan=$vlan; } $oid_value{".1.3.6.1.2.1.17.7.1.1.4"}=$count; if($prv_vlan and $first_vlan){ $oid_next{$oid.".1.0.".$prv_vlan}=$oid.".2.0.".$first_vlan; $oid_next{$oid.".2.0.".$prv_vlan}=$oid.".3.0.".$first_vlan; $oid_next{$oid.".3.0.".$prv_vlan}=$oid.".4.0.".$first_vlan; $oid_next{$oid.".4.0.".$prv_vlan}=$oid.".5.0.".$first_vlan; $oid_next{$oid.".5.0.".$prv_vlan}=$oid.".6.0.".$first_vlan; $oid_next{$oid.".6.0.".$prv_vlan}=$oid.".7.0.".$first_vlan; $oid_next{$oid.".7.0.".$prv_vlan}=".1.3.6.1.2.1.17.7.1.4.3"; } undef $prv_vlan; undef $first_vlan; } sub readforwards() { my $bridge = shift; my $fdb=$netdir.$bridge."/brforward"; open(FWD, $fdb) or return -1; while(sysread(FWD, $data, 20)){ my $mac; my ($b1,$b2,$b3,$b4,$b5,$b6,$port,$local,$age,$hi)= unpack("C6 C C L C x3", $data); $mac=sprintf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", $b1,$b2,$b3,$b4,$b5,$b6); $age=$age/100; $macs{$mac}{$bridge}=$port; $ages{$mac}{$bridge}=$age; $locals{$mac}{$bridge}=FDB_STATUS_LEARNED; next if ($local); $macs{$mac}{$bridge}=$bridge; $locals{$mac}{$bridge}=FDB_STATUS_SELF; } close(FWD); } sub readindexes() { my $bridge = shift; my $brifdir=$netdir.$bridge."/brif/"; opendir(DIR, $brifdir) or return -1; my @interfaces = readdir(DIR); next if ($#interfaces lt 2); foreach my $if (@interfaces) { next if $if eq "."; next if $if eq ".."; my $port=hex(readfile($brifdir.$if."/port_no", 0)); my $index=readfile($netdir.$if."/ifindex", 0); $indexes{$bridge}{$port}=$index; $interfaces{$bridge}{$port}=$if; } $indexes{$bridge}{$bridge}=readfile($netdir.$bridge."/ifindex", 0); close(DIR); } sub readvlans() { my $bridge = shift; my $brifdir = $netdir.$bridge."/brif/"; my %ifs; opendir(DIR, $brifdir) or return -1; my @interfaces = readdir(DIR); return if ($#interfaces < 2); foreach my $if (@interfaces) { next if $if eq "."; next if $if eq ".."; $ifs{$if}=1; } close(DIR); opendir(DIR, $netdir) or return -1; @interfaces = readdir(DIR); return 0 if ($#interfaces < 2); foreach my $if (@interfaces) { next if $if eq "."; next if $if eq ".."; next unless($if=~/^(.*)\.(\d+)$/); my $pif=$1; my $vlan=$2; next unless(defined($ifs{$pif})); tracevlan($vlan, $if, $bridge); } close(DIR); } sub tracevlan{ my ($vlan, $interface, $bridge)=@_; my $brifdir=$netdir.$interface."/brport/bridge/brif/"; opendir(DIR, $brifdir) or return -1; my @interfaces = readdir(DIR); return if ($#interfaces < 2); foreach my $if (@interfaces) { next if $if eq "."; next if $if eq ".."; my $port; my $index; if($if=~/^(.*)\.(\d+)$/){ my $pif=$1; $brifdir=$netdir.$pif."/brport/bridge/brif/"; $port=hex(readfile($brifdir.$pif."/port_no", 0)); $index=readfile($netdir.$pif."/ifindex", 0); #$indexes{$bridge}{$port}=$index; #$interfaces{$bridge}{$port}=$if; $tagged{$vlan}{$port}=1; }else{ my $brid=readfile($netdir.$if."/brport/bridge/ifindex", 0); $brifdir=$netdir.$if."/brport/bridge/brif/"; $port=hex(readfile($brifdir.$if."/port_no", 0)); $port=$brid*1000+$port; #create a unique port number $index=readfile($netdir.$if."/ifindex", 0); $indexes{$bridge}{$port}=$index; $interfaces{$bridge}{$port}=$if; $tagged{$vlan}{$port}=0; } $vlans{$vlan}{$port}=1; #print "VLAN: $vlan -> $if ($port <-> $index)\n"; } close(DIR); my $brid=readfile($netdir.$interface."/brport/bridge/ifindex", 0); my $fdb=$netdir.$interface."/brport/bridge/brforward"; my $vbridge=$bridge."_vlan".$vlan; open(FWD, $fdb) or return -1; while(sysread(FWD, $data, 20)){ my $mac; my ($b1,$b2,$b3,$b4,$b5,$b6,$port,$local,$age,$hi)= unpack("C6 C C L C x3", $data); $mac=sprintf("%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", $b1,$b2,$b3,$b4,$b5,$b6); $port=$brid*1000+$port unless(defined($indexes{$bridge}{$port})); #create a unique port number $age=$age/100; #$macs{$mac}{$bridge}=$port; $macs{$mac}{$vbridge}=$port; #$ages{$mac}{$bridge}=$age; $ages{$mac}{$vbridge}=$age; #$locals{$mac}{$bridge}=FDB_STATUS_LEARNED; $locals{$mac}{$vbridge}=FDB_STATUS_LEARNED; next if ($local); #$macs{$mac}{$bridge}=$bridge; $macs{$mac}{$vbridge}=$bridge; #$locals{$mac}{$bridge}=FDB_STATUS_SELF; $locals{$mac}{$vbridge}=FDB_STATUS_SELF; } close(FWD); } sub readfile() { my $file = shift; my $flags = shift; open(FILE, $file) or print "Could not open file $file !\n"; my $value=; chomp $value; close(FILE); if ($flags & STP_PROP_HEX) { return hex($value); } return $value; } sub getportlist{ my @ports=@_; my $portlist=""; @ports=sort {$a <=> $b} @ports; my $last=1; foreach my $port (@ports){ for(my $i=$last; $i<$port; $i++){ $portlist=$portlist."0"; } $portlist=$portlist."1"; $last=$port+1; } return pack('B*',$portlist); } sub mac2oid{ my ($mac)=@_; my @octets=split(/:/,$mac); $mac=""; foreach my $octet (@octets){ $mac=$mac.".".hex($octet); } return $mac; } sub mac2hex{ my ($mac)=@_; my @decimals; my @octets=split(/:/,$mac); foreach my $octet (@octets){ push @decimals, hex($octet); } return pack("CCCCCC", @decimals); } sub shutdown { $running = 0; }