print-isoclns.c 108 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184
  1. /*
  2. * Copyright (c) 1992, 1993, 1994, 1995, 1996
  3. * The Regents of the University of California. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that: (1) source code distributions
  7. * retain the above copyright notice and this paragraph in its entirety, (2)
  8. * distributions including binary code include the above copyright notice and
  9. * this paragraph in its entirety in the documentation or other materials
  10. * provided with the distribution, and (3) all advertising materials mentioning
  11. * features or use of this software display the following acknowledgement:
  12. * ``This product includes software developed by the University of California,
  13. * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  14. * the University nor the names of its contributors may be used to endorse
  15. * or promote products derived from this software without specific prior
  16. * written permission.
  17. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  18. * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  19. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20. *
  21. * Original code by Matt Thomas, Digital Equipment Corporation
  22. *
  23. * Extensively modified by Hannes Gredler (hannes@gredler.at) for more
  24. * complete IS-IS & CLNP support.
  25. */
  26. /* \summary: ISO CLNS, ESIS, and ISIS printer */
  27. #ifdef HAVE_CONFIG_H
  28. #include "config.h"
  29. #endif
  30. #include <netdissect-stdinc.h>
  31. #include <string.h>
  32. #include "netdissect.h"
  33. #include "addrtoname.h"
  34. #include "ether.h"
  35. #include "nlpid.h"
  36. #include "extract.h"
  37. #include "gmpls.h"
  38. #include "oui.h"
  39. #include "signature.h"
  40. static const char tstr[] = " [|isis]";
  41. /*
  42. * IS-IS is defined in ISO 10589. Look there for protocol definitions.
  43. */
  44. #define SYSTEM_ID_LEN ETHER_ADDR_LEN
  45. #define NODE_ID_LEN SYSTEM_ID_LEN+1
  46. #define LSP_ID_LEN SYSTEM_ID_LEN+2
  47. #define ISIS_VERSION 1
  48. #define ESIS_VERSION 1
  49. #define CLNP_VERSION 1
  50. #define ISIS_PDU_TYPE_MASK 0x1F
  51. #define ESIS_PDU_TYPE_MASK 0x1F
  52. #define CLNP_PDU_TYPE_MASK 0x1F
  53. #define CLNP_FLAG_MASK 0xE0
  54. #define ISIS_LAN_PRIORITY_MASK 0x7F
  55. #define ISIS_PDU_L1_LAN_IIH 15
  56. #define ISIS_PDU_L2_LAN_IIH 16
  57. #define ISIS_PDU_PTP_IIH 17
  58. #define ISIS_PDU_L1_LSP 18
  59. #define ISIS_PDU_L2_LSP 20
  60. #define ISIS_PDU_L1_CSNP 24
  61. #define ISIS_PDU_L2_CSNP 25
  62. #define ISIS_PDU_L1_PSNP 26
  63. #define ISIS_PDU_L2_PSNP 27
  64. static const struct tok isis_pdu_values[] = {
  65. { ISIS_PDU_L1_LAN_IIH, "L1 Lan IIH"},
  66. { ISIS_PDU_L2_LAN_IIH, "L2 Lan IIH"},
  67. { ISIS_PDU_PTP_IIH, "p2p IIH"},
  68. { ISIS_PDU_L1_LSP, "L1 LSP"},
  69. { ISIS_PDU_L2_LSP, "L2 LSP"},
  70. { ISIS_PDU_L1_CSNP, "L1 CSNP"},
  71. { ISIS_PDU_L2_CSNP, "L2 CSNP"},
  72. { ISIS_PDU_L1_PSNP, "L1 PSNP"},
  73. { ISIS_PDU_L2_PSNP, "L2 PSNP"},
  74. { 0, NULL}
  75. };
  76. /*
  77. * A TLV is a tuple of a type, length and a value and is normally used for
  78. * encoding information in all sorts of places. This is an enumeration of
  79. * the well known types.
  80. *
  81. * list taken from rfc3359 plus some memory from veterans ;-)
  82. */
  83. #define ISIS_TLV_AREA_ADDR 1 /* iso10589 */
  84. #define ISIS_TLV_IS_REACH 2 /* iso10589 */
  85. #define ISIS_TLV_ESNEIGH 3 /* iso10589 */
  86. #define ISIS_TLV_PART_DIS 4 /* iso10589 */
  87. #define ISIS_TLV_PREFIX_NEIGH 5 /* iso10589 */
  88. #define ISIS_TLV_ISNEIGH 6 /* iso10589 */
  89. #define ISIS_TLV_ISNEIGH_VARLEN 7 /* iso10589 */
  90. #define ISIS_TLV_PADDING 8 /* iso10589 */
  91. #define ISIS_TLV_LSP 9 /* iso10589 */
  92. #define ISIS_TLV_AUTH 10 /* iso10589, rfc3567 */
  93. #define ISIS_TLV_CHECKSUM 12 /* rfc3358 */
  94. #define ISIS_TLV_CHECKSUM_MINLEN 2
  95. #define ISIS_TLV_POI 13 /* rfc6232 */
  96. #define ISIS_TLV_LSP_BUFFERSIZE 14 /* iso10589 rev2 */
  97. #define ISIS_TLV_LSP_BUFFERSIZE_MINLEN 2
  98. #define ISIS_TLV_EXT_IS_REACH 22 /* draft-ietf-isis-traffic-05 */
  99. #define ISIS_TLV_IS_ALIAS_ID 24 /* draft-ietf-isis-ext-lsp-frags-02 */
  100. #define ISIS_TLV_DECNET_PHASE4 42
  101. #define ISIS_TLV_LUCENT_PRIVATE 66
  102. #define ISIS_TLV_INT_IP_REACH 128 /* rfc1195, rfc2966 */
  103. #define ISIS_TLV_PROTOCOLS 129 /* rfc1195 */
  104. #define ISIS_TLV_EXT_IP_REACH 130 /* rfc1195, rfc2966 */
  105. #define ISIS_TLV_IDRP_INFO 131 /* rfc1195 */
  106. #define ISIS_TLV_IDRP_INFO_MINLEN 1
  107. #define ISIS_TLV_IPADDR 132 /* rfc1195 */
  108. #define ISIS_TLV_IPAUTH 133 /* rfc1195 */
  109. #define ISIS_TLV_TE_ROUTER_ID 134 /* draft-ietf-isis-traffic-05 */
  110. #define ISIS_TLV_EXTD_IP_REACH 135 /* draft-ietf-isis-traffic-05 */
  111. #define ISIS_TLV_HOSTNAME 137 /* rfc2763 */
  112. #define ISIS_TLV_SHARED_RISK_GROUP 138 /* draft-ietf-isis-gmpls-extensions */
  113. #define ISIS_TLV_MT_PORT_CAP 143 /* rfc6165 */
  114. #define ISIS_TLV_MT_CAPABILITY 144 /* rfc6329 */
  115. #define ISIS_TLV_NORTEL_PRIVATE1 176
  116. #define ISIS_TLV_NORTEL_PRIVATE2 177
  117. #define ISIS_TLV_RESTART_SIGNALING 211 /* rfc3847 */
  118. #define ISIS_TLV_RESTART_SIGNALING_FLAGLEN 1
  119. #define ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN 2
  120. #define ISIS_TLV_MT_IS_REACH 222 /* draft-ietf-isis-wg-multi-topology-05 */
  121. #define ISIS_TLV_MT_SUPPORTED 229 /* draft-ietf-isis-wg-multi-topology-05 */
  122. #define ISIS_TLV_MT_SUPPORTED_MINLEN 2
  123. #define ISIS_TLV_IP6ADDR 232 /* draft-ietf-isis-ipv6-02 */
  124. #define ISIS_TLV_MT_IP_REACH 235 /* draft-ietf-isis-wg-multi-topology-05 */
  125. #define ISIS_TLV_IP6_REACH 236 /* draft-ietf-isis-ipv6-02 */
  126. #define ISIS_TLV_MT_IP6_REACH 237 /* draft-ietf-isis-wg-multi-topology-05 */
  127. #define ISIS_TLV_PTP_ADJ 240 /* rfc3373 */
  128. #define ISIS_TLV_IIH_SEQNR 241 /* draft-shen-isis-iih-sequence-00 */
  129. #define ISIS_TLV_IIH_SEQNR_MINLEN 4
  130. #define ISIS_TLV_VENDOR_PRIVATE 250 /* draft-ietf-isis-experimental-tlv-01 */
  131. #define ISIS_TLV_VENDOR_PRIVATE_MINLEN 3
  132. static const struct tok isis_tlv_values[] = {
  133. { ISIS_TLV_AREA_ADDR, "Area address(es)"},
  134. { ISIS_TLV_IS_REACH, "IS Reachability"},
  135. { ISIS_TLV_ESNEIGH, "ES Neighbor(s)"},
  136. { ISIS_TLV_PART_DIS, "Partition DIS"},
  137. { ISIS_TLV_PREFIX_NEIGH, "Prefix Neighbors"},
  138. { ISIS_TLV_ISNEIGH, "IS Neighbor(s)"},
  139. { ISIS_TLV_ISNEIGH_VARLEN, "IS Neighbor(s) (variable length)"},
  140. { ISIS_TLV_PADDING, "Padding"},
  141. { ISIS_TLV_LSP, "LSP entries"},
  142. { ISIS_TLV_AUTH, "Authentication"},
  143. { ISIS_TLV_CHECKSUM, "Checksum"},
  144. { ISIS_TLV_POI, "Purge Originator Identifier"},
  145. { ISIS_TLV_LSP_BUFFERSIZE, "LSP Buffersize"},
  146. { ISIS_TLV_EXT_IS_REACH, "Extended IS Reachability"},
  147. { ISIS_TLV_IS_ALIAS_ID, "IS Alias ID"},
  148. { ISIS_TLV_DECNET_PHASE4, "DECnet Phase IV"},
  149. { ISIS_TLV_LUCENT_PRIVATE, "Lucent Proprietary"},
  150. { ISIS_TLV_INT_IP_REACH, "IPv4 Internal Reachability"},
  151. { ISIS_TLV_PROTOCOLS, "Protocols supported"},
  152. { ISIS_TLV_EXT_IP_REACH, "IPv4 External Reachability"},
  153. { ISIS_TLV_IDRP_INFO, "Inter-Domain Information Type"},
  154. { ISIS_TLV_IPADDR, "IPv4 Interface address(es)"},
  155. { ISIS_TLV_IPAUTH, "IPv4 authentication (deprecated)"},
  156. { ISIS_TLV_TE_ROUTER_ID, "Traffic Engineering Router ID"},
  157. { ISIS_TLV_EXTD_IP_REACH, "Extended IPv4 Reachability"},
  158. { ISIS_TLV_SHARED_RISK_GROUP, "Shared Risk Link Group"},
  159. { ISIS_TLV_MT_PORT_CAP, "Multi-Topology-Aware Port Capability"},
  160. { ISIS_TLV_MT_CAPABILITY, "Multi-Topology Capability"},
  161. { ISIS_TLV_NORTEL_PRIVATE1, "Nortel Proprietary"},
  162. { ISIS_TLV_NORTEL_PRIVATE2, "Nortel Proprietary"},
  163. { ISIS_TLV_HOSTNAME, "Hostname"},
  164. { ISIS_TLV_RESTART_SIGNALING, "Restart Signaling"},
  165. { ISIS_TLV_MT_IS_REACH, "Multi Topology IS Reachability"},
  166. { ISIS_TLV_MT_SUPPORTED, "Multi Topology"},
  167. { ISIS_TLV_IP6ADDR, "IPv6 Interface address(es)"},
  168. { ISIS_TLV_MT_IP_REACH, "Multi-Topology IPv4 Reachability"},
  169. { ISIS_TLV_IP6_REACH, "IPv6 reachability"},
  170. { ISIS_TLV_MT_IP6_REACH, "Multi-Topology IP6 Reachability"},
  171. { ISIS_TLV_PTP_ADJ, "Point-to-point Adjacency State"},
  172. { ISIS_TLV_IIH_SEQNR, "Hello PDU Sequence Number"},
  173. { ISIS_TLV_VENDOR_PRIVATE, "Vendor Private"},
  174. { 0, NULL }
  175. };
  176. #define ESIS_OPTION_PROTOCOLS 129
  177. #define ESIS_OPTION_QOS_MAINTENANCE 195 /* iso9542 */
  178. #define ESIS_OPTION_SECURITY 197 /* iso9542 */
  179. #define ESIS_OPTION_ES_CONF_TIME 198 /* iso9542 */
  180. #define ESIS_OPTION_PRIORITY 205 /* iso9542 */
  181. #define ESIS_OPTION_ADDRESS_MASK 225 /* iso9542 */
  182. #define ESIS_OPTION_SNPA_MASK 226 /* iso9542 */
  183. static const struct tok esis_option_values[] = {
  184. { ESIS_OPTION_PROTOCOLS, "Protocols supported"},
  185. { ESIS_OPTION_QOS_MAINTENANCE, "QoS Maintenance" },
  186. { ESIS_OPTION_SECURITY, "Security" },
  187. { ESIS_OPTION_ES_CONF_TIME, "ES Configuration Time" },
  188. { ESIS_OPTION_PRIORITY, "Priority" },
  189. { ESIS_OPTION_ADDRESS_MASK, "Addressk Mask" },
  190. { ESIS_OPTION_SNPA_MASK, "SNPA Mask" },
  191. { 0, NULL }
  192. };
  193. #define CLNP_OPTION_DISCARD_REASON 193
  194. #define CLNP_OPTION_QOS_MAINTENANCE 195 /* iso8473 */
  195. #define CLNP_OPTION_SECURITY 197 /* iso8473 */
  196. #define CLNP_OPTION_SOURCE_ROUTING 200 /* iso8473 */
  197. #define CLNP_OPTION_ROUTE_RECORDING 203 /* iso8473 */
  198. #define CLNP_OPTION_PADDING 204 /* iso8473 */
  199. #define CLNP_OPTION_PRIORITY 205 /* iso8473 */
  200. static const struct tok clnp_option_values[] = {
  201. { CLNP_OPTION_DISCARD_REASON, "Discard Reason"},
  202. { CLNP_OPTION_PRIORITY, "Priority"},
  203. { CLNP_OPTION_QOS_MAINTENANCE, "QoS Maintenance"},
  204. { CLNP_OPTION_SECURITY, "Security"},
  205. { CLNP_OPTION_SOURCE_ROUTING, "Source Routing"},
  206. { CLNP_OPTION_ROUTE_RECORDING, "Route Recording"},
  207. { CLNP_OPTION_PADDING, "Padding"},
  208. { 0, NULL }
  209. };
  210. static const struct tok clnp_option_rfd_class_values[] = {
  211. { 0x0, "General"},
  212. { 0x8, "Address"},
  213. { 0x9, "Source Routeing"},
  214. { 0xa, "Lifetime"},
  215. { 0xb, "PDU Discarded"},
  216. { 0xc, "Reassembly"},
  217. { 0, NULL }
  218. };
  219. static const struct tok clnp_option_rfd_general_values[] = {
  220. { 0x0, "Reason not specified"},
  221. { 0x1, "Protocol procedure error"},
  222. { 0x2, "Incorrect checksum"},
  223. { 0x3, "PDU discarded due to congestion"},
  224. { 0x4, "Header syntax error (cannot be parsed)"},
  225. { 0x5, "Segmentation needed but not permitted"},
  226. { 0x6, "Incomplete PDU received"},
  227. { 0x7, "Duplicate option"},
  228. { 0, NULL }
  229. };
  230. static const struct tok clnp_option_rfd_address_values[] = {
  231. { 0x0, "Destination address unreachable"},
  232. { 0x1, "Destination address unknown"},
  233. { 0, NULL }
  234. };
  235. static const struct tok clnp_option_rfd_source_routeing_values[] = {
  236. { 0x0, "Unspecified source routeing error"},
  237. { 0x1, "Syntax error in source routeing field"},
  238. { 0x2, "Unknown address in source routeing field"},
  239. { 0x3, "Path not acceptable"},
  240. { 0, NULL }
  241. };
  242. static const struct tok clnp_option_rfd_lifetime_values[] = {
  243. { 0x0, "Lifetime expired while data unit in transit"},
  244. { 0x1, "Lifetime expired during reassembly"},
  245. { 0, NULL }
  246. };
  247. static const struct tok clnp_option_rfd_pdu_discard_values[] = {
  248. { 0x0, "Unsupported option not specified"},
  249. { 0x1, "Unsupported protocol version"},
  250. { 0x2, "Unsupported security option"},
  251. { 0x3, "Unsupported source routeing option"},
  252. { 0x4, "Unsupported recording of route option"},
  253. { 0, NULL }
  254. };
  255. static const struct tok clnp_option_rfd_reassembly_values[] = {
  256. { 0x0, "Reassembly interference"},
  257. { 0, NULL }
  258. };
  259. /* array of 16 error-classes */
  260. static const struct tok *clnp_option_rfd_error_class[] = {
  261. clnp_option_rfd_general_values,
  262. NULL,
  263. NULL,
  264. NULL,
  265. NULL,
  266. NULL,
  267. NULL,
  268. NULL,
  269. clnp_option_rfd_address_values,
  270. clnp_option_rfd_source_routeing_values,
  271. clnp_option_rfd_lifetime_values,
  272. clnp_option_rfd_pdu_discard_values,
  273. clnp_option_rfd_reassembly_values,
  274. NULL,
  275. NULL,
  276. NULL
  277. };
  278. #define CLNP_OPTION_OPTION_QOS_MASK 0x3f
  279. #define CLNP_OPTION_SCOPE_MASK 0xc0
  280. #define CLNP_OPTION_SCOPE_SA_SPEC 0x40
  281. #define CLNP_OPTION_SCOPE_DA_SPEC 0x80
  282. #define CLNP_OPTION_SCOPE_GLOBAL 0xc0
  283. static const struct tok clnp_option_scope_values[] = {
  284. { CLNP_OPTION_SCOPE_SA_SPEC, "Source Address Specific"},
  285. { CLNP_OPTION_SCOPE_DA_SPEC, "Destination Address Specific"},
  286. { CLNP_OPTION_SCOPE_GLOBAL, "Globally unique"},
  287. { 0, NULL }
  288. };
  289. static const struct tok clnp_option_sr_rr_values[] = {
  290. { 0x0, "partial"},
  291. { 0x1, "complete"},
  292. { 0, NULL }
  293. };
  294. static const struct tok clnp_option_sr_rr_string_values[] = {
  295. { CLNP_OPTION_SOURCE_ROUTING, "source routing"},
  296. { CLNP_OPTION_ROUTE_RECORDING, "recording of route in progress"},
  297. { 0, NULL }
  298. };
  299. static const struct tok clnp_option_qos_global_values[] = {
  300. { 0x20, "reserved"},
  301. { 0x10, "sequencing vs. delay"},
  302. { 0x08, "congested"},
  303. { 0x04, "delay vs. cost"},
  304. { 0x02, "error vs. delay"},
  305. { 0x01, "error vs. cost"},
  306. { 0, NULL }
  307. };
  308. #define ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP 3 /* draft-ietf-isis-traffic-05 */
  309. #define ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID 4 /* rfc4205 */
  310. #define ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID 5 /* draft-ietf-isis-traffic-05 */
  311. #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR 6 /* draft-ietf-isis-traffic-05 */
  312. #define ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR 8 /* draft-ietf-isis-traffic-05 */
  313. #define ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW 9 /* draft-ietf-isis-traffic-05 */
  314. #define ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW 10 /* draft-ietf-isis-traffic-05 */
  315. #define ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW 11 /* rfc4124 */
  316. #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD 12 /* draft-ietf-tewg-diff-te-proto-06 */
  317. #define ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC 18 /* draft-ietf-isis-traffic-05 */
  318. #define ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE 19 /* draft-ietf-isis-link-attr-01 */
  319. #define ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE 20 /* rfc4205 */
  320. #define ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR 21 /* rfc4205 */
  321. #define ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS 22 /* rfc4124 */
  322. #define ISIS_SUBTLV_SPB_METRIC 29 /* rfc6329 */
  323. static const struct tok isis_ext_is_reach_subtlv_values[] = {
  324. { ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP, "Administrative groups" },
  325. { ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID, "Link Local/Remote Identifier" },
  326. { ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID, "Link Remote Identifier" },
  327. { ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR, "IPv4 interface address" },
  328. { ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR, "IPv4 neighbor address" },
  329. { ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW, "Maximum link bandwidth" },
  330. { ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW, "Reservable link bandwidth" },
  331. { ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW, "Unreserved bandwidth" },
  332. { ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC, "Traffic Engineering Metric" },
  333. { ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE, "Link Attribute" },
  334. { ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE, "Link Protection Type" },
  335. { ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR, "Interface Switching Capability" },
  336. { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD, "Bandwidth Constraints (old)" },
  337. { ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS, "Bandwidth Constraints" },
  338. { ISIS_SUBTLV_SPB_METRIC, "SPB Metric" },
  339. { 250, "Reserved for cisco specific extensions" },
  340. { 251, "Reserved for cisco specific extensions" },
  341. { 252, "Reserved for cisco specific extensions" },
  342. { 253, "Reserved for cisco specific extensions" },
  343. { 254, "Reserved for cisco specific extensions" },
  344. { 255, "Reserved for future expansion" },
  345. { 0, NULL }
  346. };
  347. #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32 1 /* draft-ietf-isis-admin-tags-01 */
  348. #define ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64 2 /* draft-ietf-isis-admin-tags-01 */
  349. #define ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR 117 /* draft-ietf-isis-wg-multi-topology-05 */
  350. static const struct tok isis_ext_ip_reach_subtlv_values[] = {
  351. { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32, "32-Bit Administrative tag" },
  352. { ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64, "64-Bit Administrative tag" },
  353. { ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR, "Management Prefix Color" },
  354. { 0, NULL }
  355. };
  356. static const struct tok isis_subtlv_link_attribute_values[] = {
  357. { 0x01, "Local Protection Available" },
  358. { 0x02, "Link excluded from local protection path" },
  359. { 0x04, "Local maintenance required"},
  360. { 0, NULL }
  361. };
  362. #define ISIS_SUBTLV_AUTH_SIMPLE 1
  363. #define ISIS_SUBTLV_AUTH_GENERIC 3 /* rfc 5310 */
  364. #define ISIS_SUBTLV_AUTH_MD5 54
  365. #define ISIS_SUBTLV_AUTH_MD5_LEN 16
  366. #define ISIS_SUBTLV_AUTH_PRIVATE 255
  367. static const struct tok isis_subtlv_auth_values[] = {
  368. { ISIS_SUBTLV_AUTH_SIMPLE, "simple text password"},
  369. { ISIS_SUBTLV_AUTH_GENERIC, "Generic Crypto key-id"},
  370. { ISIS_SUBTLV_AUTH_MD5, "HMAC-MD5 password"},
  371. { ISIS_SUBTLV_AUTH_PRIVATE, "Routing Domain private password"},
  372. { 0, NULL }
  373. };
  374. #define ISIS_SUBTLV_IDRP_RES 0
  375. #define ISIS_SUBTLV_IDRP_LOCAL 1
  376. #define ISIS_SUBTLV_IDRP_ASN 2
  377. static const struct tok isis_subtlv_idrp_values[] = {
  378. { ISIS_SUBTLV_IDRP_RES, "Reserved"},
  379. { ISIS_SUBTLV_IDRP_LOCAL, "Routing-Domain Specific"},
  380. { ISIS_SUBTLV_IDRP_ASN, "AS Number Tag"},
  381. { 0, NULL}
  382. };
  383. #define ISIS_SUBTLV_SPB_MCID 4
  384. #define ISIS_SUBTLV_SPB_DIGEST 5
  385. #define ISIS_SUBTLV_SPB_BVID 6
  386. #define ISIS_SUBTLV_SPB_INSTANCE 1
  387. #define ISIS_SUBTLV_SPBM_SI 3
  388. #define ISIS_SPB_MCID_LEN 51
  389. #define ISIS_SUBTLV_SPB_MCID_MIN_LEN 102
  390. #define ISIS_SUBTLV_SPB_DIGEST_MIN_LEN 33
  391. #define ISIS_SUBTLV_SPB_BVID_MIN_LEN 6
  392. #define ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN 19
  393. #define ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN 8
  394. static const struct tok isis_mt_port_cap_subtlv_values[] = {
  395. { ISIS_SUBTLV_SPB_MCID, "SPB MCID" },
  396. { ISIS_SUBTLV_SPB_DIGEST, "SPB Digest" },
  397. { ISIS_SUBTLV_SPB_BVID, "SPB BVID" },
  398. { 0, NULL }
  399. };
  400. static const struct tok isis_mt_capability_subtlv_values[] = {
  401. { ISIS_SUBTLV_SPB_INSTANCE, "SPB Instance" },
  402. { ISIS_SUBTLV_SPBM_SI, "SPBM Service Identifier and Unicast Address" },
  403. { 0, NULL }
  404. };
  405. struct isis_spb_mcid {
  406. uint8_t format_id;
  407. uint8_t name[32];
  408. uint8_t revision_lvl[2];
  409. uint8_t digest[16];
  410. };
  411. struct isis_subtlv_spb_mcid {
  412. struct isis_spb_mcid mcid;
  413. struct isis_spb_mcid aux_mcid;
  414. };
  415. struct isis_subtlv_spb_instance {
  416. uint8_t cist_root_id[8];
  417. uint8_t cist_external_root_path_cost[4];
  418. uint8_t bridge_priority[2];
  419. uint8_t spsourceid[4];
  420. uint8_t no_of_trees;
  421. };
  422. #define CLNP_SEGMENT_PART 0x80
  423. #define CLNP_MORE_SEGMENTS 0x40
  424. #define CLNP_REQUEST_ER 0x20
  425. static const struct tok clnp_flag_values[] = {
  426. { CLNP_SEGMENT_PART, "Segmentation permitted"},
  427. { CLNP_MORE_SEGMENTS, "more Segments"},
  428. { CLNP_REQUEST_ER, "request Error Report"},
  429. { 0, NULL}
  430. };
  431. #define ISIS_MASK_LSP_OL_BIT(x) ((x)&0x4)
  432. #define ISIS_MASK_LSP_ISTYPE_BITS(x) ((x)&0x3)
  433. #define ISIS_MASK_LSP_PARTITION_BIT(x) ((x)&0x80)
  434. #define ISIS_MASK_LSP_ATT_BITS(x) ((x)&0x78)
  435. #define ISIS_MASK_LSP_ATT_ERROR_BIT(x) ((x)&0x40)
  436. #define ISIS_MASK_LSP_ATT_EXPENSE_BIT(x) ((x)&0x20)
  437. #define ISIS_MASK_LSP_ATT_DELAY_BIT(x) ((x)&0x10)
  438. #define ISIS_MASK_LSP_ATT_DEFAULT_BIT(x) ((x)&0x8)
  439. #define ISIS_MASK_MTID(x) ((x)&0x0fff)
  440. #define ISIS_MASK_MTFLAGS(x) ((x)&0xf000)
  441. static const struct tok isis_mt_flag_values[] = {
  442. { 0x4000, "ATT bit set"},
  443. { 0x8000, "Overload bit set"},
  444. { 0, NULL}
  445. };
  446. #define ISIS_MASK_TLV_EXTD_IP_UPDOWN(x) ((x)&0x80)
  447. #define ISIS_MASK_TLV_EXTD_IP_SUBTLV(x) ((x)&0x40)
  448. #define ISIS_MASK_TLV_EXTD_IP6_IE(x) ((x)&0x40)
  449. #define ISIS_MASK_TLV_EXTD_IP6_SUBTLV(x) ((x)&0x20)
  450. #define ISIS_LSP_TLV_METRIC_SUPPORTED(x) ((x)&0x80)
  451. #define ISIS_LSP_TLV_METRIC_IE(x) ((x)&0x40)
  452. #define ISIS_LSP_TLV_METRIC_UPDOWN(x) ((x)&0x80)
  453. #define ISIS_LSP_TLV_METRIC_VALUE(x) ((x)&0x3f)
  454. #define ISIS_MASK_TLV_SHARED_RISK_GROUP(x) ((x)&0x1)
  455. static const struct tok isis_mt_values[] = {
  456. { 0, "IPv4 unicast"},
  457. { 1, "In-Band Management"},
  458. { 2, "IPv6 unicast"},
  459. { 3, "Multicast"},
  460. { 4095, "Development, Experimental or Proprietary"},
  461. { 0, NULL }
  462. };
  463. static const struct tok isis_iih_circuit_type_values[] = {
  464. { 1, "Level 1 only"},
  465. { 2, "Level 2 only"},
  466. { 3, "Level 1, Level 2"},
  467. { 0, NULL}
  468. };
  469. #define ISIS_LSP_TYPE_UNUSED0 0
  470. #define ISIS_LSP_TYPE_LEVEL_1 1
  471. #define ISIS_LSP_TYPE_UNUSED2 2
  472. #define ISIS_LSP_TYPE_LEVEL_2 3
  473. static const struct tok isis_lsp_istype_values[] = {
  474. { ISIS_LSP_TYPE_UNUSED0, "Unused 0x0 (invalid)"},
  475. { ISIS_LSP_TYPE_LEVEL_1, "L1 IS"},
  476. { ISIS_LSP_TYPE_UNUSED2, "Unused 0x2 (invalid)"},
  477. { ISIS_LSP_TYPE_LEVEL_2, "L2 IS"},
  478. { 0, NULL }
  479. };
  480. /*
  481. * Katz's point to point adjacency TLV uses codes to tell us the state of
  482. * the remote adjacency. Enumerate them.
  483. */
  484. #define ISIS_PTP_ADJ_UP 0
  485. #define ISIS_PTP_ADJ_INIT 1
  486. #define ISIS_PTP_ADJ_DOWN 2
  487. static const struct tok isis_ptp_adjancey_values[] = {
  488. { ISIS_PTP_ADJ_UP, "Up" },
  489. { ISIS_PTP_ADJ_INIT, "Initializing" },
  490. { ISIS_PTP_ADJ_DOWN, "Down" },
  491. { 0, NULL}
  492. };
  493. struct isis_tlv_ptp_adj {
  494. uint8_t adjacency_state;
  495. uint8_t extd_local_circuit_id[4];
  496. uint8_t neighbor_sysid[SYSTEM_ID_LEN];
  497. uint8_t neighbor_extd_local_circuit_id[4];
  498. };
  499. static void osi_print_cksum(netdissect_options *, const uint8_t *pptr,
  500. uint16_t checksum, int checksum_offset, u_int length);
  501. static int clnp_print(netdissect_options *, const uint8_t *, u_int);
  502. static void esis_print(netdissect_options *, const uint8_t *, u_int);
  503. static int isis_print(netdissect_options *, const uint8_t *, u_int);
  504. struct isis_metric_block {
  505. uint8_t metric_default;
  506. uint8_t metric_delay;
  507. uint8_t metric_expense;
  508. uint8_t metric_error;
  509. };
  510. struct isis_tlv_is_reach {
  511. struct isis_metric_block isis_metric_block;
  512. uint8_t neighbor_nodeid[NODE_ID_LEN];
  513. };
  514. struct isis_tlv_es_reach {
  515. struct isis_metric_block isis_metric_block;
  516. uint8_t neighbor_sysid[SYSTEM_ID_LEN];
  517. };
  518. struct isis_tlv_ip_reach {
  519. struct isis_metric_block isis_metric_block;
  520. uint8_t prefix[4];
  521. uint8_t mask[4];
  522. };
  523. static const struct tok isis_is_reach_virtual_values[] = {
  524. { 0, "IsNotVirtual"},
  525. { 1, "IsVirtual"},
  526. { 0, NULL }
  527. };
  528. static const struct tok isis_restart_flag_values[] = {
  529. { 0x1, "Restart Request"},
  530. { 0x2, "Restart Acknowledgement"},
  531. { 0x4, "Suppress adjacency advertisement"},
  532. { 0, NULL }
  533. };
  534. struct isis_common_header {
  535. uint8_t nlpid;
  536. uint8_t fixed_len;
  537. uint8_t version; /* Protocol version */
  538. uint8_t id_length;
  539. uint8_t pdu_type; /* 3 MSbits are reserved */
  540. uint8_t pdu_version; /* Packet format version */
  541. uint8_t reserved;
  542. uint8_t max_area;
  543. };
  544. struct isis_iih_lan_header {
  545. uint8_t circuit_type;
  546. uint8_t source_id[SYSTEM_ID_LEN];
  547. uint8_t holding_time[2];
  548. uint8_t pdu_len[2];
  549. uint8_t priority;
  550. uint8_t lan_id[NODE_ID_LEN];
  551. };
  552. struct isis_iih_ptp_header {
  553. uint8_t circuit_type;
  554. uint8_t source_id[SYSTEM_ID_LEN];
  555. uint8_t holding_time[2];
  556. uint8_t pdu_len[2];
  557. uint8_t circuit_id;
  558. };
  559. struct isis_lsp_header {
  560. uint8_t pdu_len[2];
  561. uint8_t remaining_lifetime[2];
  562. uint8_t lsp_id[LSP_ID_LEN];
  563. uint8_t sequence_number[4];
  564. uint8_t checksum[2];
  565. uint8_t typeblock;
  566. };
  567. struct isis_csnp_header {
  568. uint8_t pdu_len[2];
  569. uint8_t source_id[NODE_ID_LEN];
  570. uint8_t start_lsp_id[LSP_ID_LEN];
  571. uint8_t end_lsp_id[LSP_ID_LEN];
  572. };
  573. struct isis_psnp_header {
  574. uint8_t pdu_len[2];
  575. uint8_t source_id[NODE_ID_LEN];
  576. };
  577. struct isis_tlv_lsp {
  578. uint8_t remaining_lifetime[2];
  579. uint8_t lsp_id[LSP_ID_LEN];
  580. uint8_t sequence_number[4];
  581. uint8_t checksum[2];
  582. };
  583. #define ISIS_COMMON_HEADER_SIZE (sizeof(struct isis_common_header))
  584. #define ISIS_IIH_LAN_HEADER_SIZE (sizeof(struct isis_iih_lan_header))
  585. #define ISIS_IIH_PTP_HEADER_SIZE (sizeof(struct isis_iih_ptp_header))
  586. #define ISIS_LSP_HEADER_SIZE (sizeof(struct isis_lsp_header))
  587. #define ISIS_CSNP_HEADER_SIZE (sizeof(struct isis_csnp_header))
  588. #define ISIS_PSNP_HEADER_SIZE (sizeof(struct isis_psnp_header))
  589. void
  590. isoclns_print(netdissect_options *ndo, const uint8_t *p, u_int length)
  591. {
  592. if (!ND_TTEST(*p)) { /* enough bytes on the wire ? */
  593. ND_PRINT((ndo, "|OSI"));
  594. return;
  595. }
  596. if (ndo->ndo_eflag)
  597. ND_PRINT((ndo, "OSI NLPID %s (0x%02x): ", tok2str(nlpid_values, "Unknown", *p), *p));
  598. switch (*p) {
  599. case NLPID_CLNP:
  600. if (!clnp_print(ndo, p, length))
  601. print_unknown_data(ndo, p, "\n\t", length);
  602. break;
  603. case NLPID_ESIS:
  604. esis_print(ndo, p, length);
  605. return;
  606. case NLPID_ISIS:
  607. if (!isis_print(ndo, p, length))
  608. print_unknown_data(ndo, p, "\n\t", length);
  609. break;
  610. case NLPID_NULLNS:
  611. ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
  612. break;
  613. case NLPID_Q933:
  614. q933_print(ndo, p + 1, length - 1);
  615. break;
  616. case NLPID_IP:
  617. ip_print(ndo, p + 1, length - 1);
  618. break;
  619. case NLPID_IP6:
  620. ip6_print(ndo, p + 1, length - 1);
  621. break;
  622. case NLPID_PPP:
  623. ppp_print(ndo, p + 1, length - 1);
  624. break;
  625. default:
  626. if (!ndo->ndo_eflag)
  627. ND_PRINT((ndo, "OSI NLPID 0x%02x unknown", *p));
  628. ND_PRINT((ndo, "%slength: %u", ndo->ndo_eflag ? "" : ", ", length));
  629. if (length > 1)
  630. print_unknown_data(ndo, p, "\n\t", length);
  631. break;
  632. }
  633. }
  634. #define CLNP_PDU_ER 1
  635. #define CLNP_PDU_DT 28
  636. #define CLNP_PDU_MD 29
  637. #define CLNP_PDU_ERQ 30
  638. #define CLNP_PDU_ERP 31
  639. static const struct tok clnp_pdu_values[] = {
  640. { CLNP_PDU_ER, "Error Report"},
  641. { CLNP_PDU_MD, "MD"},
  642. { CLNP_PDU_DT, "Data"},
  643. { CLNP_PDU_ERQ, "Echo Request"},
  644. { CLNP_PDU_ERP, "Echo Response"},
  645. { 0, NULL }
  646. };
  647. struct clnp_header_t {
  648. uint8_t nlpid;
  649. uint8_t length_indicator;
  650. uint8_t version;
  651. uint8_t lifetime; /* units of 500ms */
  652. uint8_t type;
  653. uint8_t segment_length[2];
  654. uint8_t cksum[2];
  655. };
  656. struct clnp_segment_header_t {
  657. uint8_t data_unit_id[2];
  658. uint8_t segment_offset[2];
  659. uint8_t total_length[2];
  660. };
  661. /*
  662. * clnp_print
  663. * Decode CLNP packets. Return 0 on error.
  664. */
  665. static int
  666. clnp_print(netdissect_options *ndo,
  667. const uint8_t *pptr, u_int length)
  668. {
  669. const uint8_t *optr,*source_address,*dest_address;
  670. u_int li,tlen,nsap_offset,source_address_length,dest_address_length, clnp_pdu_type, clnp_flags;
  671. const struct clnp_header_t *clnp_header;
  672. const struct clnp_segment_header_t *clnp_segment_header;
  673. uint8_t rfd_error_major,rfd_error_minor;
  674. clnp_header = (const struct clnp_header_t *) pptr;
  675. ND_TCHECK(*clnp_header);
  676. li = clnp_header->length_indicator;
  677. optr = pptr;
  678. if (!ndo->ndo_eflag)
  679. ND_PRINT((ndo, "CLNP"));
  680. /*
  681. * Sanity checking of the header.
  682. */
  683. if (clnp_header->version != CLNP_VERSION) {
  684. ND_PRINT((ndo, "version %d packet not supported", clnp_header->version));
  685. return (0);
  686. }
  687. if (li > length) {
  688. ND_PRINT((ndo, " length indicator(%u) > PDU size (%u)!", li, length));
  689. return (0);
  690. }
  691. if (li < sizeof(struct clnp_header_t)) {
  692. ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
  693. while (pptr < ndo->ndo_snapend)
  694. ND_PRINT((ndo, "%02X", *pptr++));
  695. return (0);
  696. }
  697. /* FIXME further header sanity checking */
  698. clnp_pdu_type = clnp_header->type & CLNP_PDU_TYPE_MASK;
  699. clnp_flags = clnp_header->type & CLNP_FLAG_MASK;
  700. pptr += sizeof(struct clnp_header_t);
  701. li -= sizeof(struct clnp_header_t);
  702. if (li < 1) {
  703. ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
  704. return (0);
  705. }
  706. ND_TCHECK(*pptr);
  707. dest_address_length = *pptr;
  708. pptr += 1;
  709. li -= 1;
  710. if (li < dest_address_length) {
  711. ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
  712. return (0);
  713. }
  714. ND_TCHECK2(*pptr, dest_address_length);
  715. dest_address = pptr;
  716. pptr += dest_address_length;
  717. li -= dest_address_length;
  718. if (li < 1) {
  719. ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
  720. return (0);
  721. }
  722. ND_TCHECK(*pptr);
  723. source_address_length = *pptr;
  724. pptr += 1;
  725. li -= 1;
  726. if (li < source_address_length) {
  727. ND_PRINT((ndo, "li < size of fixed part of CLNP header and addresses"));
  728. return (0);
  729. }
  730. ND_TCHECK2(*pptr, source_address_length);
  731. source_address = pptr;
  732. pptr += source_address_length;
  733. li -= source_address_length;
  734. if (ndo->ndo_vflag < 1) {
  735. ND_PRINT((ndo, "%s%s > %s, %s, length %u",
  736. ndo->ndo_eflag ? "" : ", ",
  737. isonsap_string(ndo, source_address, source_address_length),
  738. isonsap_string(ndo, dest_address, dest_address_length),
  739. tok2str(clnp_pdu_values,"unknown (%u)",clnp_pdu_type),
  740. length));
  741. return (1);
  742. }
  743. ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
  744. ND_PRINT((ndo, "\n\t%s PDU, hlen: %u, v: %u, lifetime: %u.%us, Segment PDU length: %u, checksum: 0x%04x",
  745. tok2str(clnp_pdu_values, "unknown (%u)",clnp_pdu_type),
  746. clnp_header->length_indicator,
  747. clnp_header->version,
  748. clnp_header->lifetime/2,
  749. (clnp_header->lifetime%2)*5,
  750. EXTRACT_16BITS(clnp_header->segment_length),
  751. EXTRACT_16BITS(clnp_header->cksum)));
  752. osi_print_cksum(ndo, optr, EXTRACT_16BITS(clnp_header->cksum), 7,
  753. clnp_header->length_indicator);
  754. ND_PRINT((ndo, "\n\tFlags [%s]",
  755. bittok2str(clnp_flag_values, "none", clnp_flags)));
  756. ND_PRINT((ndo, "\n\tsource address (length %u): %s\n\tdest address (length %u): %s",
  757. source_address_length,
  758. isonsap_string(ndo, source_address, source_address_length),
  759. dest_address_length,
  760. isonsap_string(ndo, dest_address, dest_address_length)));
  761. if (clnp_flags & CLNP_SEGMENT_PART) {
  762. if (li < sizeof(const struct clnp_segment_header_t)) {
  763. ND_PRINT((ndo, "li < size of fixed part of CLNP header, addresses, and segment part"));
  764. return (0);
  765. }
  766. clnp_segment_header = (const struct clnp_segment_header_t *) pptr;
  767. ND_TCHECK(*clnp_segment_header);
  768. ND_PRINT((ndo, "\n\tData Unit ID: 0x%04x, Segment Offset: %u, Total PDU Length: %u",
  769. EXTRACT_16BITS(clnp_segment_header->data_unit_id),
  770. EXTRACT_16BITS(clnp_segment_header->segment_offset),
  771. EXTRACT_16BITS(clnp_segment_header->total_length)));
  772. pptr+=sizeof(const struct clnp_segment_header_t);
  773. li-=sizeof(const struct clnp_segment_header_t);
  774. }
  775. /* now walk the options */
  776. while (li >= 2) {
  777. u_int op, opli;
  778. const uint8_t *tptr;
  779. if (li < 2) {
  780. ND_PRINT((ndo, ", bad opts/li"));
  781. return (0);
  782. }
  783. ND_TCHECK2(*pptr, 2);
  784. op = *pptr++;
  785. opli = *pptr++;
  786. li -= 2;
  787. if (opli > li) {
  788. ND_PRINT((ndo, ", opt (%d) too long", op));
  789. return (0);
  790. }
  791. ND_TCHECK2(*pptr, opli);
  792. li -= opli;
  793. tptr = pptr;
  794. tlen = opli;
  795. ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
  796. tok2str(clnp_option_values,"Unknown",op),
  797. op,
  798. opli));
  799. /*
  800. * We've already checked that the entire option is present
  801. * in the captured packet with the ND_TCHECK2() call.
  802. * Therefore, we don't need to do ND_TCHECK()/ND_TCHECK2()
  803. * checks.
  804. * We do, however, need to check tlen, to make sure we
  805. * don't run past the end of the option.
  806. */
  807. switch (op) {
  808. case CLNP_OPTION_ROUTE_RECORDING: /* those two options share the format */
  809. case CLNP_OPTION_SOURCE_ROUTING:
  810. if (tlen < 2) {
  811. ND_PRINT((ndo, ", bad opt len"));
  812. return (0);
  813. }
  814. ND_PRINT((ndo, "%s %s",
  815. tok2str(clnp_option_sr_rr_values,"Unknown",*tptr),
  816. tok2str(clnp_option_sr_rr_string_values, "Unknown Option %u", op)));
  817. nsap_offset=*(tptr+1);
  818. if (nsap_offset == 0) {
  819. ND_PRINT((ndo, " Bad NSAP offset (0)"));
  820. break;
  821. }
  822. nsap_offset-=1; /* offset to nsap list */
  823. if (nsap_offset > tlen) {
  824. ND_PRINT((ndo, " Bad NSAP offset (past end of option)"));
  825. break;
  826. }
  827. tptr+=nsap_offset;
  828. tlen-=nsap_offset;
  829. while (tlen > 0) {
  830. source_address_length=*tptr;
  831. if (tlen < source_address_length+1) {
  832. ND_PRINT((ndo, "\n\t NSAP address goes past end of option"));
  833. break;
  834. }
  835. if (source_address_length > 0) {
  836. source_address=(tptr+1);
  837. ND_TCHECK2(*source_address, source_address_length);
  838. ND_PRINT((ndo, "\n\t NSAP address (length %u): %s",
  839. source_address_length,
  840. isonsap_string(ndo, source_address, source_address_length)));
  841. }
  842. tlen-=source_address_length+1;
  843. }
  844. break;
  845. case CLNP_OPTION_PRIORITY:
  846. if (tlen < 1) {
  847. ND_PRINT((ndo, ", bad opt len"));
  848. return (0);
  849. }
  850. ND_PRINT((ndo, "0x%1x", *tptr&0x0f));
  851. break;
  852. case CLNP_OPTION_QOS_MAINTENANCE:
  853. if (tlen < 1) {
  854. ND_PRINT((ndo, ", bad opt len"));
  855. return (0);
  856. }
  857. ND_PRINT((ndo, "\n\t Format Code: %s",
  858. tok2str(clnp_option_scope_values, "Reserved", *tptr&CLNP_OPTION_SCOPE_MASK)));
  859. if ((*tptr&CLNP_OPTION_SCOPE_MASK) == CLNP_OPTION_SCOPE_GLOBAL)
  860. ND_PRINT((ndo, "\n\t QoS Flags [%s]",
  861. bittok2str(clnp_option_qos_global_values,
  862. "none",
  863. *tptr&CLNP_OPTION_OPTION_QOS_MASK)));
  864. break;
  865. case CLNP_OPTION_SECURITY:
  866. if (tlen < 2) {
  867. ND_PRINT((ndo, ", bad opt len"));
  868. return (0);
  869. }
  870. ND_PRINT((ndo, "\n\t Format Code: %s, Security-Level %u",
  871. tok2str(clnp_option_scope_values,"Reserved",*tptr&CLNP_OPTION_SCOPE_MASK),
  872. *(tptr+1)));
  873. break;
  874. case CLNP_OPTION_DISCARD_REASON:
  875. if (tlen < 1) {
  876. ND_PRINT((ndo, ", bad opt len"));
  877. return (0);
  878. }
  879. rfd_error_major = (*tptr&0xf0) >> 4;
  880. rfd_error_minor = *tptr&0x0f;
  881. ND_PRINT((ndo, "\n\t Class: %s Error (0x%01x), %s (0x%01x)",
  882. tok2str(clnp_option_rfd_class_values,"Unknown",rfd_error_major),
  883. rfd_error_major,
  884. tok2str(clnp_option_rfd_error_class[rfd_error_major],"Unknown",rfd_error_minor),
  885. rfd_error_minor));
  886. break;
  887. case CLNP_OPTION_PADDING:
  888. ND_PRINT((ndo, "padding data"));
  889. break;
  890. /*
  891. * FIXME those are the defined Options that lack a decoder
  892. * you are welcome to contribute code ;-)
  893. */
  894. default:
  895. print_unknown_data(ndo, tptr, "\n\t ", opli);
  896. break;
  897. }
  898. if (ndo->ndo_vflag > 1)
  899. print_unknown_data(ndo, pptr, "\n\t ", opli);
  900. pptr += opli;
  901. }
  902. switch (clnp_pdu_type) {
  903. case CLNP_PDU_ER: /* fall through */
  904. case CLNP_PDU_ERP:
  905. ND_TCHECK(*pptr);
  906. if (*(pptr) == NLPID_CLNP) {
  907. ND_PRINT((ndo, "\n\t-----original packet-----\n\t"));
  908. /* FIXME recursion protection */
  909. clnp_print(ndo, pptr, length - clnp_header->length_indicator);
  910. break;
  911. }
  912. case CLNP_PDU_DT:
  913. case CLNP_PDU_MD:
  914. case CLNP_PDU_ERQ:
  915. default:
  916. /* dump the PDU specific data */
  917. if (length-(pptr-optr) > 0) {
  918. ND_PRINT((ndo, "\n\t undecoded non-header data, length %u", length-clnp_header->length_indicator));
  919. print_unknown_data(ndo, pptr, "\n\t ", length - (pptr - optr));
  920. }
  921. }
  922. return (1);
  923. trunc:
  924. ND_PRINT((ndo, "[|clnp]"));
  925. return (1);
  926. }
  927. #define ESIS_PDU_REDIRECT 6
  928. #define ESIS_PDU_ESH 2
  929. #define ESIS_PDU_ISH 4
  930. static const struct tok esis_pdu_values[] = {
  931. { ESIS_PDU_REDIRECT, "redirect"},
  932. { ESIS_PDU_ESH, "ESH"},
  933. { ESIS_PDU_ISH, "ISH"},
  934. { 0, NULL }
  935. };
  936. struct esis_header_t {
  937. uint8_t nlpid;
  938. uint8_t length_indicator;
  939. uint8_t version;
  940. uint8_t reserved;
  941. uint8_t type;
  942. uint8_t holdtime[2];
  943. uint8_t cksum[2];
  944. };
  945. static void
  946. esis_print(netdissect_options *ndo,
  947. const uint8_t *pptr, u_int length)
  948. {
  949. const uint8_t *optr;
  950. u_int li,esis_pdu_type,source_address_length, source_address_number;
  951. const struct esis_header_t *esis_header;
  952. if (!ndo->ndo_eflag)
  953. ND_PRINT((ndo, "ES-IS"));
  954. if (length <= 2) {
  955. ND_PRINT((ndo, ndo->ndo_qflag ? "bad pkt!" : "no header at all!"));
  956. return;
  957. }
  958. esis_header = (const struct esis_header_t *) pptr;
  959. ND_TCHECK(*esis_header);
  960. li = esis_header->length_indicator;
  961. optr = pptr;
  962. /*
  963. * Sanity checking of the header.
  964. */
  965. if (esis_header->nlpid != NLPID_ESIS) {
  966. ND_PRINT((ndo, " nlpid 0x%02x packet not supported", esis_header->nlpid));
  967. return;
  968. }
  969. if (esis_header->version != ESIS_VERSION) {
  970. ND_PRINT((ndo, " version %d packet not supported", esis_header->version));
  971. return;
  972. }
  973. if (li > length) {
  974. ND_PRINT((ndo, " length indicator(%u) > PDU size (%u)!", li, length));
  975. return;
  976. }
  977. if (li < sizeof(struct esis_header_t) + 2) {
  978. ND_PRINT((ndo, " length indicator %u < min PDU size:", li));
  979. while (pptr < ndo->ndo_snapend)
  980. ND_PRINT((ndo, "%02X", *pptr++));
  981. return;
  982. }
  983. esis_pdu_type = esis_header->type & ESIS_PDU_TYPE_MASK;
  984. if (ndo->ndo_vflag < 1) {
  985. ND_PRINT((ndo, "%s%s, length %u",
  986. ndo->ndo_eflag ? "" : ", ",
  987. tok2str(esis_pdu_values,"unknown type (%u)",esis_pdu_type),
  988. length));
  989. return;
  990. } else
  991. ND_PRINT((ndo, "%slength %u\n\t%s (%u)",
  992. ndo->ndo_eflag ? "" : ", ",
  993. length,
  994. tok2str(esis_pdu_values,"unknown type: %u", esis_pdu_type),
  995. esis_pdu_type));
  996. ND_PRINT((ndo, ", v: %u%s", esis_header->version, esis_header->version == ESIS_VERSION ? "" : "unsupported" ));
  997. ND_PRINT((ndo, ", checksum: 0x%04x", EXTRACT_16BITS(esis_header->cksum)));
  998. osi_print_cksum(ndo, pptr, EXTRACT_16BITS(esis_header->cksum), 7, li);
  999. ND_PRINT((ndo, ", holding time: %us, length indicator: %u",
  1000. EXTRACT_16BITS(esis_header->holdtime), li));
  1001. if (ndo->ndo_vflag > 1)
  1002. print_unknown_data(ndo, optr, "\n\t", sizeof(struct esis_header_t));
  1003. pptr += sizeof(struct esis_header_t);
  1004. li -= sizeof(struct esis_header_t);
  1005. switch (esis_pdu_type) {
  1006. case ESIS_PDU_REDIRECT: {
  1007. const uint8_t *dst, *snpa, *neta;
  1008. u_int dstl, snpal, netal;
  1009. ND_TCHECK(*pptr);
  1010. if (li < 1) {
  1011. ND_PRINT((ndo, ", bad redirect/li"));
  1012. return;
  1013. }
  1014. dstl = *pptr;
  1015. pptr++;
  1016. li--;
  1017. ND_TCHECK2(*pptr, dstl);
  1018. if (li < dstl) {
  1019. ND_PRINT((ndo, ", bad redirect/li"));
  1020. return;
  1021. }
  1022. dst = pptr;
  1023. pptr += dstl;
  1024. li -= dstl;
  1025. ND_PRINT((ndo, "\n\t %s", isonsap_string(ndo, dst, dstl)));
  1026. ND_TCHECK(*pptr);
  1027. if (li < 1) {
  1028. ND_PRINT((ndo, ", bad redirect/li"));
  1029. return;
  1030. }
  1031. snpal = *pptr;
  1032. pptr++;
  1033. li--;
  1034. ND_TCHECK2(*pptr, snpal);
  1035. if (li < snpal) {
  1036. ND_PRINT((ndo, ", bad redirect/li"));
  1037. return;
  1038. }
  1039. snpa = pptr;
  1040. pptr += snpal;
  1041. li -= snpal;
  1042. ND_TCHECK(*pptr);
  1043. if (li < 1) {
  1044. ND_PRINT((ndo, ", bad redirect/li"));
  1045. return;
  1046. }
  1047. netal = *pptr;
  1048. pptr++;
  1049. ND_TCHECK2(*pptr, netal);
  1050. if (li < netal) {
  1051. ND_PRINT((ndo, ", bad redirect/li"));
  1052. return;
  1053. }
  1054. neta = pptr;
  1055. pptr += netal;
  1056. li -= netal;
  1057. if (snpal == 6)
  1058. ND_PRINT((ndo, "\n\t SNPA (length: %u): %s",
  1059. snpal,
  1060. etheraddr_string(ndo, snpa)));
  1061. else
  1062. ND_PRINT((ndo, "\n\t SNPA (length: %u): %s",
  1063. snpal,
  1064. linkaddr_string(ndo, snpa, LINKADDR_OTHER, snpal)));
  1065. if (netal != 0)
  1066. ND_PRINT((ndo, "\n\t NET (length: %u) %s",
  1067. netal,
  1068. isonsap_string(ndo, neta, netal)));
  1069. break;
  1070. }
  1071. case ESIS_PDU_ESH:
  1072. ND_TCHECK(*pptr);
  1073. if (li < 1) {
  1074. ND_PRINT((ndo, ", bad esh/li"));
  1075. return;
  1076. }
  1077. source_address_number = *pptr;
  1078. pptr++;
  1079. li--;
  1080. ND_PRINT((ndo, "\n\t Number of Source Addresses: %u", source_address_number));
  1081. while (source_address_number > 0) {
  1082. ND_TCHECK(*pptr);
  1083. if (li < 1) {
  1084. ND_PRINT((ndo, ", bad esh/li"));
  1085. return;
  1086. }
  1087. source_address_length = *pptr;
  1088. pptr++;
  1089. li--;
  1090. ND_TCHECK2(*pptr, source_address_length);
  1091. if (li < source_address_length) {
  1092. ND_PRINT((ndo, ", bad esh/li"));
  1093. return;
  1094. }
  1095. ND_PRINT((ndo, "\n\t NET (length: %u): %s",
  1096. source_address_length,
  1097. isonsap_string(ndo, pptr, source_address_length)));
  1098. pptr += source_address_length;
  1099. li -= source_address_length;
  1100. source_address_number--;
  1101. }
  1102. break;
  1103. case ESIS_PDU_ISH: {
  1104. ND_TCHECK(*pptr);
  1105. if (li < 1) {
  1106. ND_PRINT((ndo, ", bad ish/li"));
  1107. return;
  1108. }
  1109. source_address_length = *pptr;
  1110. pptr++;
  1111. li--;
  1112. ND_TCHECK2(*pptr, source_address_length);
  1113. if (li < source_address_length) {
  1114. ND_PRINT((ndo, ", bad ish/li"));
  1115. return;
  1116. }
  1117. ND_PRINT((ndo, "\n\t NET (length: %u): %s", source_address_length, isonsap_string(ndo, pptr, source_address_length)));
  1118. pptr += source_address_length;
  1119. li -= source_address_length;
  1120. break;
  1121. }
  1122. default:
  1123. if (ndo->ndo_vflag <= 1) {
  1124. if (pptr < ndo->ndo_snapend)
  1125. print_unknown_data(ndo, pptr, "\n\t ", ndo->ndo_snapend - pptr);
  1126. }
  1127. return;
  1128. }
  1129. /* now walk the options */
  1130. while (li != 0) {
  1131. u_int op, opli;
  1132. const uint8_t *tptr;
  1133. if (li < 2) {
  1134. ND_PRINT((ndo, ", bad opts/li"));
  1135. return;
  1136. }
  1137. ND_TCHECK2(*pptr, 2);
  1138. op = *pptr++;
  1139. opli = *pptr++;
  1140. li -= 2;
  1141. if (opli > li) {
  1142. ND_PRINT((ndo, ", opt (%d) too long", op));
  1143. return;
  1144. }
  1145. li -= opli;
  1146. tptr = pptr;
  1147. ND_PRINT((ndo, "\n\t %s Option #%u, length %u, value: ",
  1148. tok2str(esis_option_values,"Unknown",op),
  1149. op,
  1150. opli));
  1151. switch (op) {
  1152. case ESIS_OPTION_ES_CONF_TIME:
  1153. if (opli == 2) {
  1154. ND_TCHECK2(*pptr, 2);
  1155. ND_PRINT((ndo, "%us", EXTRACT_16BITS(tptr)));
  1156. } else
  1157. ND_PRINT((ndo, "(bad length)"));
  1158. break;
  1159. case ESIS_OPTION_PROTOCOLS:
  1160. while (opli>0) {
  1161. ND_TCHECK(*tptr);
  1162. ND_PRINT((ndo, "%s (0x%02x)",
  1163. tok2str(nlpid_values,
  1164. "unknown",
  1165. *tptr),
  1166. *tptr));
  1167. if (opli>1) /* further NPLIDs ? - put comma */
  1168. ND_PRINT((ndo, ", "));
  1169. tptr++;
  1170. opli--;
  1171. }
  1172. break;
  1173. /*
  1174. * FIXME those are the defined Options that lack a decoder
  1175. * you are welcome to contribute code ;-)
  1176. */
  1177. case ESIS_OPTION_QOS_MAINTENANCE:
  1178. case ESIS_OPTION_SECURITY:
  1179. case ESIS_OPTION_PRIORITY:
  1180. case ESIS_OPTION_ADDRESS_MASK:
  1181. case ESIS_OPTION_SNPA_MASK:
  1182. default:
  1183. print_unknown_data(ndo, tptr, "\n\t ", opli);
  1184. break;
  1185. }
  1186. if (ndo->ndo_vflag > 1)
  1187. print_unknown_data(ndo, pptr, "\n\t ", opli);
  1188. pptr += opli;
  1189. }
  1190. trunc:
  1191. ND_PRINT((ndo, "[|esis]"));
  1192. }
  1193. static void
  1194. isis_print_mcid(netdissect_options *ndo,
  1195. const struct isis_spb_mcid *mcid)
  1196. {
  1197. int i;
  1198. ND_TCHECK(*mcid);
  1199. ND_PRINT((ndo, "ID: %d, Name: ", mcid->format_id));
  1200. if (fn_printzp(ndo, mcid->name, 32, ndo->ndo_snapend))
  1201. goto trunc;
  1202. ND_PRINT((ndo, "\n\t Lvl: %d", EXTRACT_16BITS(mcid->revision_lvl)));
  1203. ND_PRINT((ndo, ", Digest: "));
  1204. for(i=0;i<16;i++)
  1205. ND_PRINT((ndo, "%.2x ", mcid->digest[i]));
  1206. trunc:
  1207. ND_PRINT((ndo, "%s", tstr));
  1208. }
  1209. static int
  1210. isis_print_mt_port_cap_subtlv(netdissect_options *ndo,
  1211. const uint8_t *tptr, int len)
  1212. {
  1213. int stlv_type, stlv_len;
  1214. const struct isis_subtlv_spb_mcid *subtlv_spb_mcid;
  1215. int i;
  1216. while (len > 2)
  1217. {
  1218. ND_TCHECK2(*tptr, 2);
  1219. stlv_type = *(tptr++);
  1220. stlv_len = *(tptr++);
  1221. /* first lets see if we know the subTLVs name*/
  1222. ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
  1223. tok2str(isis_mt_port_cap_subtlv_values, "unknown", stlv_type),
  1224. stlv_type,
  1225. stlv_len));
  1226. /*len -= TLV_TYPE_LEN_OFFSET;*/
  1227. len = len -2;
  1228. /* Make sure the subTLV fits within the space left */
  1229. if (len < stlv_len)
  1230. goto trunc;
  1231. /* Make sure the entire subTLV is in the captured data */
  1232. ND_TCHECK2(*(tptr), stlv_len);
  1233. switch (stlv_type)
  1234. {
  1235. case ISIS_SUBTLV_SPB_MCID:
  1236. {
  1237. if (stlv_len < ISIS_SUBTLV_SPB_MCID_MIN_LEN)
  1238. goto trunc;
  1239. subtlv_spb_mcid = (const struct isis_subtlv_spb_mcid *)tptr;
  1240. ND_PRINT((ndo, "\n\t MCID: "));
  1241. isis_print_mcid(ndo, &(subtlv_spb_mcid->mcid));
  1242. /*tptr += SPB_MCID_MIN_LEN;
  1243. len -= SPB_MCID_MIN_LEN; */
  1244. ND_PRINT((ndo, "\n\t AUX-MCID: "));
  1245. isis_print_mcid(ndo, &(subtlv_spb_mcid->aux_mcid));
  1246. /*tptr += SPB_MCID_MIN_LEN;
  1247. len -= SPB_MCID_MIN_LEN; */
  1248. tptr = tptr + ISIS_SUBTLV_SPB_MCID_MIN_LEN;
  1249. len = len - ISIS_SUBTLV_SPB_MCID_MIN_LEN;
  1250. stlv_len = stlv_len - ISIS_SUBTLV_SPB_MCID_MIN_LEN;
  1251. break;
  1252. }
  1253. case ISIS_SUBTLV_SPB_DIGEST:
  1254. {
  1255. if (stlv_len < ISIS_SUBTLV_SPB_DIGEST_MIN_LEN)
  1256. goto trunc;
  1257. ND_PRINT((ndo, "\n\t RES: %d V: %d A: %d D: %d",
  1258. (*(tptr) >> 5), (((*tptr)>> 4) & 0x01),
  1259. ((*(tptr) >> 2) & 0x03), ((*tptr) & 0x03)));
  1260. tptr++;
  1261. ND_PRINT((ndo, "\n\t Digest: "));
  1262. for(i=1;i<=8; i++)
  1263. {
  1264. ND_PRINT((ndo, "%08x ", EXTRACT_32BITS(tptr)));
  1265. if (i%4 == 0 && i != 8)
  1266. ND_PRINT((ndo, "\n\t "));
  1267. tptr = tptr + 4;
  1268. }
  1269. len = len - ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
  1270. stlv_len = stlv_len - ISIS_SUBTLV_SPB_DIGEST_MIN_LEN;
  1271. break;
  1272. }
  1273. case ISIS_SUBTLV_SPB_BVID:
  1274. {
  1275. while (stlv_len >= ISIS_SUBTLV_SPB_BVID_MIN_LEN)
  1276. {
  1277. ND_PRINT((ndo, "\n\t ECT: %08x",
  1278. EXTRACT_32BITS(tptr)));
  1279. tptr = tptr+4;
  1280. ND_PRINT((ndo, " BVID: %d, U:%01x M:%01x ",
  1281. (EXTRACT_16BITS (tptr) >> 4) ,
  1282. (EXTRACT_16BITS (tptr) >> 3) & 0x01,
  1283. (EXTRACT_16BITS (tptr) >> 2) & 0x01));
  1284. tptr = tptr + 2;
  1285. len = len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
  1286. stlv_len = stlv_len - ISIS_SUBTLV_SPB_BVID_MIN_LEN;
  1287. }
  1288. break;
  1289. }
  1290. default:
  1291. break;
  1292. }
  1293. tptr += stlv_len;
  1294. len -= stlv_len;
  1295. }
  1296. return 0;
  1297. trunc:
  1298. ND_PRINT((ndo, "\n\t\t"));
  1299. ND_PRINT((ndo, "%s", tstr));
  1300. return(1);
  1301. }
  1302. static int
  1303. isis_print_mt_capability_subtlv(netdissect_options *ndo,
  1304. const uint8_t *tptr, int len)
  1305. {
  1306. int stlv_type, stlv_len, tmp;
  1307. while (len > 2)
  1308. {
  1309. ND_TCHECK2(*tptr, 2);
  1310. stlv_type = *(tptr++);
  1311. stlv_len = *(tptr++);
  1312. /* first lets see if we know the subTLVs name*/
  1313. ND_PRINT((ndo, "\n\t %s subTLV #%u, length: %u",
  1314. tok2str(isis_mt_capability_subtlv_values, "unknown", stlv_type),
  1315. stlv_type,
  1316. stlv_len));
  1317. len = len - 2;
  1318. /* Make sure the subTLV fits within the space left */
  1319. if (len < stlv_len)
  1320. goto trunc;
  1321. /* Make sure the entire subTLV is in the captured data */
  1322. ND_TCHECK2(*(tptr), stlv_len);
  1323. switch (stlv_type)
  1324. {
  1325. case ISIS_SUBTLV_SPB_INSTANCE:
  1326. if (stlv_len < ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN)
  1327. goto trunc;
  1328. ND_PRINT((ndo, "\n\t CIST Root-ID: %08x", EXTRACT_32BITS(tptr)));
  1329. tptr = tptr+4;
  1330. ND_PRINT((ndo, " %08x", EXTRACT_32BITS(tptr)));
  1331. tptr = tptr+4;
  1332. ND_PRINT((ndo, ", Path Cost: %08x", EXTRACT_32BITS(tptr)));
  1333. tptr = tptr+4;
  1334. ND_PRINT((ndo, ", Prio: %d", EXTRACT_16BITS(tptr)));
  1335. tptr = tptr + 2;
  1336. ND_PRINT((ndo, "\n\t RES: %d",
  1337. EXTRACT_16BITS(tptr) >> 5));
  1338. ND_PRINT((ndo, ", V: %d",
  1339. (EXTRACT_16BITS(tptr) >> 4) & 0x0001));
  1340. ND_PRINT((ndo, ", SPSource-ID: %d",
  1341. (EXTRACT_32BITS(tptr) & 0x000fffff)));
  1342. tptr = tptr+4;
  1343. ND_PRINT((ndo, ", No of Trees: %x", *(tptr)));
  1344. tmp = *(tptr++);
  1345. len = len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
  1346. stlv_len = stlv_len - ISIS_SUBTLV_SPB_INSTANCE_MIN_LEN;
  1347. while (tmp)
  1348. {
  1349. if (stlv_len < ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN)
  1350. goto trunc;
  1351. ND_PRINT((ndo, "\n\t U:%d, M:%d, A:%d, RES:%d",
  1352. *(tptr) >> 7, (*(tptr) >> 6) & 0x01,
  1353. (*(tptr) >> 5) & 0x01, (*(tptr) & 0x1f)));
  1354. tptr++;
  1355. ND_PRINT((ndo, ", ECT: %08x", EXTRACT_32BITS(tptr)));
  1356. tptr = tptr + 4;
  1357. ND_PRINT((ndo, ", BVID: %d, SPVID: %d",
  1358. (EXTRACT_24BITS(tptr) >> 12) & 0x000fff,
  1359. EXTRACT_24BITS(tptr) & 0x000fff));
  1360. tptr = tptr + 3;
  1361. len = len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
  1362. stlv_len = stlv_len - ISIS_SUBTLV_SPB_INSTANCE_VLAN_TUPLE_LEN;
  1363. tmp--;
  1364. }
  1365. break;
  1366. case ISIS_SUBTLV_SPBM_SI:
  1367. if (stlv_len < 8)
  1368. goto trunc;
  1369. ND_PRINT((ndo, "\n\t BMAC: %08x", EXTRACT_32BITS(tptr)));
  1370. tptr = tptr+4;
  1371. ND_PRINT((ndo, "%04x", EXTRACT_16BITS(tptr)));
  1372. tptr = tptr+2;
  1373. ND_PRINT((ndo, ", RES: %d, VID: %d", EXTRACT_16BITS(tptr) >> 12,
  1374. (EXTRACT_16BITS(tptr)) & 0x0fff));
  1375. tptr = tptr+2;
  1376. len = len - 8;
  1377. stlv_len = stlv_len - 8;
  1378. while (stlv_len >= 4) {
  1379. ND_TCHECK2(*tptr, 4);
  1380. ND_PRINT((ndo, "\n\t T: %d, R: %d, RES: %d, ISID: %d",
  1381. (EXTRACT_32BITS(tptr) >> 31),
  1382. (EXTRACT_32BITS(tptr) >> 30) & 0x01,
  1383. (EXTRACT_32BITS(tptr) >> 24) & 0x03f,
  1384. (EXTRACT_32BITS(tptr)) & 0x0ffffff));
  1385. tptr = tptr + 4;
  1386. len = len - 4;
  1387. stlv_len = stlv_len - 4;
  1388. }
  1389. break;
  1390. default:
  1391. break;
  1392. }
  1393. tptr += stlv_len;
  1394. len -= stlv_len;
  1395. }
  1396. return 0;
  1397. trunc:
  1398. ND_PRINT((ndo, "\n\t\t"));
  1399. ND_PRINT((ndo, "%s", tstr));
  1400. return(1);
  1401. }
  1402. /* shared routine for printing system, node and lsp-ids */
  1403. static char *
  1404. isis_print_id(const uint8_t *cp, int id_len)
  1405. {
  1406. int i;
  1407. static char id[sizeof("xxxx.xxxx.xxxx.yy-zz")];
  1408. char *pos = id;
  1409. int sysid_len;
  1410. sysid_len = SYSTEM_ID_LEN;
  1411. if (sysid_len > id_len)
  1412. sysid_len = id_len;
  1413. for (i = 1; i <= sysid_len; i++) {
  1414. snprintf(pos, sizeof(id) - (pos - id), "%02x", *cp++);
  1415. pos += strlen(pos);
  1416. if (i == 2 || i == 4)
  1417. *pos++ = '.';
  1418. }
  1419. if (id_len >= NODE_ID_LEN) {
  1420. snprintf(pos, sizeof(id) - (pos - id), ".%02x", *cp++);
  1421. pos += strlen(pos);
  1422. }
  1423. if (id_len == LSP_ID_LEN)
  1424. snprintf(pos, sizeof(id) - (pos - id), "-%02x", *cp);
  1425. return (id);
  1426. }
  1427. /* print the 4-byte metric block which is common found in the old-style TLVs */
  1428. static int
  1429. isis_print_metric_block(netdissect_options *ndo,
  1430. const struct isis_metric_block *isis_metric_block)
  1431. {
  1432. ND_PRINT((ndo, ", Default Metric: %d, %s",
  1433. ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_default),
  1434. ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_default) ? "External" : "Internal"));
  1435. if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_delay))
  1436. ND_PRINT((ndo, "\n\t\t Delay Metric: %d, %s",
  1437. ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_delay),
  1438. ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_delay) ? "External" : "Internal"));
  1439. if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_expense))
  1440. ND_PRINT((ndo, "\n\t\t Expense Metric: %d, %s",
  1441. ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_expense),
  1442. ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_expense) ? "External" : "Internal"));
  1443. if (!ISIS_LSP_TLV_METRIC_SUPPORTED(isis_metric_block->metric_error))
  1444. ND_PRINT((ndo, "\n\t\t Error Metric: %d, %s",
  1445. ISIS_LSP_TLV_METRIC_VALUE(isis_metric_block->metric_error),
  1446. ISIS_LSP_TLV_METRIC_IE(isis_metric_block->metric_error) ? "External" : "Internal"));
  1447. return(1); /* everything is ok */
  1448. }
  1449. static int
  1450. isis_print_tlv_ip_reach(netdissect_options *ndo,
  1451. const uint8_t *cp, const char *ident, int length)
  1452. {
  1453. int prefix_len;
  1454. const struct isis_tlv_ip_reach *tlv_ip_reach;
  1455. tlv_ip_reach = (const struct isis_tlv_ip_reach *)cp;
  1456. while (length > 0) {
  1457. if ((size_t)length < sizeof(*tlv_ip_reach)) {
  1458. ND_PRINT((ndo, "short IPv4 Reachability (%d vs %lu)",
  1459. length,
  1460. (unsigned long)sizeof(*tlv_ip_reach)));
  1461. return (0);
  1462. }
  1463. if (!ND_TTEST(*tlv_ip_reach))
  1464. return (0);
  1465. prefix_len = mask2plen(EXTRACT_32BITS(tlv_ip_reach->mask));
  1466. if (prefix_len == -1)
  1467. ND_PRINT((ndo, "%sIPv4 prefix: %s mask %s",
  1468. ident,
  1469. ipaddr_string(ndo, (tlv_ip_reach->prefix)),
  1470. ipaddr_string(ndo, (tlv_ip_reach->mask))));
  1471. else
  1472. ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
  1473. ident,
  1474. ipaddr_string(ndo, (tlv_ip_reach->prefix)),
  1475. prefix_len));
  1476. ND_PRINT((ndo, ", Distribution: %s, Metric: %u, %s",
  1477. ISIS_LSP_TLV_METRIC_UPDOWN(tlv_ip_reach->isis_metric_block.metric_default) ? "down" : "up",
  1478. ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_default),
  1479. ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_default) ? "External" : "Internal"));
  1480. if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_delay))
  1481. ND_PRINT((ndo, "%s Delay Metric: %u, %s",
  1482. ident,
  1483. ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_delay),
  1484. ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_delay) ? "External" : "Internal"));
  1485. if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_expense))
  1486. ND_PRINT((ndo, "%s Expense Metric: %u, %s",
  1487. ident,
  1488. ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_expense),
  1489. ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_expense) ? "External" : "Internal"));
  1490. if (!ISIS_LSP_TLV_METRIC_SUPPORTED(tlv_ip_reach->isis_metric_block.metric_error))
  1491. ND_PRINT((ndo, "%s Error Metric: %u, %s",
  1492. ident,
  1493. ISIS_LSP_TLV_METRIC_VALUE(tlv_ip_reach->isis_metric_block.metric_error),
  1494. ISIS_LSP_TLV_METRIC_IE(tlv_ip_reach->isis_metric_block.metric_error) ? "External" : "Internal"));
  1495. length -= sizeof(struct isis_tlv_ip_reach);
  1496. tlv_ip_reach++;
  1497. }
  1498. return (1);
  1499. }
  1500. /*
  1501. * this is the common IP-REACH subTLV decoder it is called
  1502. * from various EXTD-IP REACH TLVs (135,235,236,237)
  1503. */
  1504. static int
  1505. isis_print_ip_reach_subtlv(netdissect_options *ndo,
  1506. const uint8_t *tptr, int subt, int subl,
  1507. const char *ident)
  1508. {
  1509. /* first lets see if we know the subTLVs name*/
  1510. ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
  1511. ident, tok2str(isis_ext_ip_reach_subtlv_values, "unknown", subt),
  1512. subt, subl));
  1513. ND_TCHECK2(*tptr,subl);
  1514. switch(subt) {
  1515. case ISIS_SUBTLV_EXTD_IP_REACH_MGMT_PREFIX_COLOR: /* fall through */
  1516. case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG32:
  1517. while (subl >= 4) {
  1518. ND_PRINT((ndo, ", 0x%08x (=%u)",
  1519. EXTRACT_32BITS(tptr),
  1520. EXTRACT_32BITS(tptr)));
  1521. tptr+=4;
  1522. subl-=4;
  1523. }
  1524. break;
  1525. case ISIS_SUBTLV_EXTD_IP_REACH_ADMIN_TAG64:
  1526. while (subl >= 8) {
  1527. ND_PRINT((ndo, ", 0x%08x%08x",
  1528. EXTRACT_32BITS(tptr),
  1529. EXTRACT_32BITS(tptr+4)));
  1530. tptr+=8;
  1531. subl-=8;
  1532. }
  1533. break;
  1534. default:
  1535. if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
  1536. return(0);
  1537. break;
  1538. }
  1539. return(1);
  1540. trunc:
  1541. ND_PRINT((ndo, "%s", ident));
  1542. ND_PRINT((ndo, "%s", tstr));
  1543. return(0);
  1544. }
  1545. /*
  1546. * this is the common IS-REACH subTLV decoder it is called
  1547. * from isis_print_ext_is_reach()
  1548. */
  1549. static int
  1550. isis_print_is_reach_subtlv(netdissect_options *ndo,
  1551. const uint8_t *tptr, u_int subt, u_int subl,
  1552. const char *ident)
  1553. {
  1554. u_int te_class,priority_level,gmpls_switch_cap;
  1555. union { /* int to float conversion buffer for several subTLVs */
  1556. float f;
  1557. uint32_t i;
  1558. } bw;
  1559. /* first lets see if we know the subTLVs name*/
  1560. ND_PRINT((ndo, "%s%s subTLV #%u, length: %u",
  1561. ident, tok2str(isis_ext_is_reach_subtlv_values, "unknown", subt),
  1562. subt, subl));
  1563. ND_TCHECK2(*tptr, subl);
  1564. switch(subt) {
  1565. case ISIS_SUBTLV_EXT_IS_REACH_ADMIN_GROUP:
  1566. case ISIS_SUBTLV_EXT_IS_REACH_LINK_LOCAL_REMOTE_ID:
  1567. case ISIS_SUBTLV_EXT_IS_REACH_LINK_REMOTE_ID:
  1568. if (subl >= 4) {
  1569. ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr)));
  1570. if (subl == 8) /* rfc4205 */
  1571. ND_PRINT((ndo, ", 0x%08x", EXTRACT_32BITS(tptr+4)));
  1572. }
  1573. break;
  1574. case ISIS_SUBTLV_EXT_IS_REACH_IPV4_INTF_ADDR:
  1575. case ISIS_SUBTLV_EXT_IS_REACH_IPV4_NEIGHBOR_ADDR:
  1576. if (subl >= sizeof(struct in_addr))
  1577. ND_PRINT((ndo, ", %s", ipaddr_string(ndo, tptr)));
  1578. break;
  1579. case ISIS_SUBTLV_EXT_IS_REACH_MAX_LINK_BW :
  1580. case ISIS_SUBTLV_EXT_IS_REACH_RESERVABLE_BW:
  1581. if (subl >= 4) {
  1582. bw.i = EXTRACT_32BITS(tptr);
  1583. ND_PRINT((ndo, ", %.3f Mbps", bw.f * 8 / 1000000));
  1584. }
  1585. break;
  1586. case ISIS_SUBTLV_EXT_IS_REACH_UNRESERVED_BW :
  1587. if (subl >= 32) {
  1588. for (te_class = 0; te_class < 8; te_class++) {
  1589. bw.i = EXTRACT_32BITS(tptr);
  1590. ND_PRINT((ndo, "%s TE-Class %u: %.3f Mbps",
  1591. ident,
  1592. te_class,
  1593. bw.f * 8 / 1000000));
  1594. tptr+=4;
  1595. }
  1596. }
  1597. break;
  1598. case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS: /* fall through */
  1599. case ISIS_SUBTLV_EXT_IS_REACH_BW_CONSTRAINTS_OLD:
  1600. if (subl == 0)
  1601. break;
  1602. ND_PRINT((ndo, "%sBandwidth Constraints Model ID: %s (%u)",
  1603. ident,
  1604. tok2str(diffserv_te_bc_values, "unknown", *tptr),
  1605. *tptr));
  1606. tptr++;
  1607. /* decode BCs until the subTLV ends */
  1608. for (te_class = 0; te_class < (subl-1)/4; te_class++) {
  1609. bw.i = EXTRACT_32BITS(tptr);
  1610. ND_PRINT((ndo, "%s Bandwidth constraint CT%u: %.3f Mbps",
  1611. ident,
  1612. te_class,
  1613. bw.f * 8 / 1000000));
  1614. tptr+=4;
  1615. }
  1616. break;
  1617. case ISIS_SUBTLV_EXT_IS_REACH_TE_METRIC:
  1618. if (subl >= 3)
  1619. ND_PRINT((ndo, ", %u", EXTRACT_24BITS(tptr)));
  1620. break;
  1621. case ISIS_SUBTLV_EXT_IS_REACH_LINK_ATTRIBUTE:
  1622. if (subl == 2) {
  1623. ND_PRINT((ndo, ", [ %s ] (0x%04x)",
  1624. bittok2str(isis_subtlv_link_attribute_values,
  1625. "Unknown",
  1626. EXTRACT_16BITS(tptr)),
  1627. EXTRACT_16BITS(tptr)));
  1628. }
  1629. break;
  1630. case ISIS_SUBTLV_EXT_IS_REACH_LINK_PROTECTION_TYPE:
  1631. if (subl >= 2) {
  1632. ND_PRINT((ndo, ", %s, Priority %u",
  1633. bittok2str(gmpls_link_prot_values, "none", *tptr),
  1634. *(tptr+1)));
  1635. }
  1636. break;
  1637. case ISIS_SUBTLV_SPB_METRIC:
  1638. if (subl >= 6) {
  1639. ND_PRINT((ndo, ", LM: %u", EXTRACT_24BITS(tptr)));
  1640. tptr=tptr+3;
  1641. ND_PRINT((ndo, ", P: %u", *(tptr)));
  1642. tptr++;
  1643. ND_PRINT((ndo, ", P-ID: %u", EXTRACT_16BITS(tptr)));
  1644. }
  1645. break;
  1646. case ISIS_SUBTLV_EXT_IS_REACH_INTF_SW_CAP_DESCR:
  1647. if (subl >= 36) {
  1648. gmpls_switch_cap = *tptr;
  1649. ND_PRINT((ndo, "%s Interface Switching Capability:%s",
  1650. ident,
  1651. tok2str(gmpls_switch_cap_values, "Unknown", gmpls_switch_cap)));
  1652. ND_PRINT((ndo, ", LSP Encoding: %s",
  1653. tok2str(gmpls_encoding_values, "Unknown", *(tptr + 1))));
  1654. tptr+=4;
  1655. ND_PRINT((ndo, "%s Max LSP Bandwidth:", ident));
  1656. for (priority_level = 0; priority_level < 8; priority_level++) {
  1657. bw.i = EXTRACT_32BITS(tptr);
  1658. ND_PRINT((ndo, "%s priority level %d: %.3f Mbps",
  1659. ident,
  1660. priority_level,
  1661. bw.f * 8 / 1000000));
  1662. tptr+=4;
  1663. }
  1664. subl-=36;
  1665. switch (gmpls_switch_cap) {
  1666. case GMPLS_PSC1:
  1667. case GMPLS_PSC2:
  1668. case GMPLS_PSC3:
  1669. case GMPLS_PSC4:
  1670. if (subl < 6)
  1671. break;
  1672. bw.i = EXTRACT_32BITS(tptr);
  1673. ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
  1674. ND_PRINT((ndo, "%s Interface MTU: %u", ident, EXTRACT_16BITS(tptr + 4)));
  1675. break;
  1676. case GMPLS_TSC:
  1677. if (subl < 8)
  1678. break;
  1679. bw.i = EXTRACT_32BITS(tptr);
  1680. ND_PRINT((ndo, "%s Min LSP Bandwidth: %.3f Mbps", ident, bw.f * 8 / 1000000));
  1681. ND_PRINT((ndo, "%s Indication %s", ident,
  1682. tok2str(gmpls_switch_cap_tsc_indication_values, "Unknown (%u)", *(tptr + 4))));
  1683. break;
  1684. default:
  1685. /* there is some optional stuff left to decode but this is as of yet
  1686. not specified so just lets hexdump what is left */
  1687. if(subl>0){
  1688. if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
  1689. return(0);
  1690. }
  1691. }
  1692. }
  1693. break;
  1694. default:
  1695. if (!print_unknown_data(ndo, tptr, "\n\t\t ", subl))
  1696. return(0);
  1697. break;
  1698. }
  1699. return(1);
  1700. trunc:
  1701. return(0);
  1702. }
  1703. /*
  1704. * this is the common IS-REACH decoder it is called
  1705. * from various EXTD-IS REACH style TLVs (22,24,222)
  1706. */
  1707. static int
  1708. isis_print_ext_is_reach(netdissect_options *ndo,
  1709. const uint8_t *tptr, const char *ident, int tlv_type)
  1710. {
  1711. char ident_buffer[20];
  1712. int subtlv_type,subtlv_len,subtlv_sum_len;
  1713. int proc_bytes = 0; /* how many bytes did we process ? */
  1714. if (!ND_TTEST2(*tptr, NODE_ID_LEN))
  1715. return(0);
  1716. ND_PRINT((ndo, "%sIS Neighbor: %s", ident, isis_print_id(tptr, NODE_ID_LEN)));
  1717. tptr+=(NODE_ID_LEN);
  1718. if (tlv_type != ISIS_TLV_IS_ALIAS_ID) { /* the Alias TLV Metric field is implicit 0 */
  1719. if (!ND_TTEST2(*tptr, 3)) /* and is therefore skipped */
  1720. return(0);
  1721. ND_PRINT((ndo, ", Metric: %d", EXTRACT_24BITS(tptr)));
  1722. tptr+=3;
  1723. }
  1724. if (!ND_TTEST2(*tptr, 1))
  1725. return(0);
  1726. subtlv_sum_len=*(tptr++); /* read out subTLV length */
  1727. proc_bytes=NODE_ID_LEN+3+1;
  1728. ND_PRINT((ndo, ", %ssub-TLVs present",subtlv_sum_len ? "" : "no "));
  1729. if (subtlv_sum_len) {
  1730. ND_PRINT((ndo, " (%u)", subtlv_sum_len));
  1731. while (subtlv_sum_len>0) {
  1732. if (!ND_TTEST2(*tptr,2))
  1733. return(0);
  1734. subtlv_type=*(tptr++);
  1735. subtlv_len=*(tptr++);
  1736. /* prepend the indent string */
  1737. snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
  1738. if (!isis_print_is_reach_subtlv(ndo, tptr, subtlv_type, subtlv_len, ident_buffer))
  1739. return(0);
  1740. tptr+=subtlv_len;
  1741. subtlv_sum_len-=(subtlv_len+2);
  1742. proc_bytes+=(subtlv_len+2);
  1743. }
  1744. }
  1745. return(proc_bytes);
  1746. }
  1747. /*
  1748. * this is the common Multi Topology ID decoder
  1749. * it is called from various MT-TLVs (222,229,235,237)
  1750. */
  1751. static int
  1752. isis_print_mtid(netdissect_options *ndo,
  1753. const uint8_t *tptr, const char *ident)
  1754. {
  1755. if (!ND_TTEST2(*tptr, 2))
  1756. return(0);
  1757. ND_PRINT((ndo, "%s%s",
  1758. ident,
  1759. tok2str(isis_mt_values,
  1760. "Reserved for IETF Consensus",
  1761. ISIS_MASK_MTID(EXTRACT_16BITS(tptr)))));
  1762. ND_PRINT((ndo, " Topology (0x%03x), Flags: [%s]",
  1763. ISIS_MASK_MTID(EXTRACT_16BITS(tptr)),
  1764. bittok2str(isis_mt_flag_values, "none",ISIS_MASK_MTFLAGS(EXTRACT_16BITS(tptr)))));
  1765. return(2);
  1766. }
  1767. /*
  1768. * this is the common extended IP reach decoder
  1769. * it is called from TLVs (135,235,236,237)
  1770. * we process the TLV and optional subTLVs and return
  1771. * the amount of processed bytes
  1772. */
  1773. static int
  1774. isis_print_extd_ip_reach(netdissect_options *ndo,
  1775. const uint8_t *tptr, const char *ident, uint16_t afi)
  1776. {
  1777. char ident_buffer[20];
  1778. uint8_t prefix[sizeof(struct in6_addr)]; /* shared copy buffer for IPv4 and IPv6 prefixes */
  1779. u_int metric, status_byte, bit_length, byte_length, sublen, processed, subtlvtype, subtlvlen;
  1780. if (!ND_TTEST2(*tptr, 4))
  1781. return (0);
  1782. metric = EXTRACT_32BITS(tptr);
  1783. processed=4;
  1784. tptr+=4;
  1785. if (afi == AF_INET) {
  1786. if (!ND_TTEST2(*tptr, 1)) /* fetch status byte */
  1787. return (0);
  1788. status_byte=*(tptr++);
  1789. bit_length = status_byte&0x3f;
  1790. if (bit_length > 32) {
  1791. ND_PRINT((ndo, "%sIPv4 prefix: bad bit length %u",
  1792. ident,
  1793. bit_length));
  1794. return (0);
  1795. }
  1796. processed++;
  1797. } else if (afi == AF_INET6) {
  1798. if (!ND_TTEST2(*tptr, 2)) /* fetch status & prefix_len byte */
  1799. return (0);
  1800. status_byte=*(tptr++);
  1801. bit_length=*(tptr++);
  1802. if (bit_length > 128) {
  1803. ND_PRINT((ndo, "%sIPv6 prefix: bad bit length %u",
  1804. ident,
  1805. bit_length));
  1806. return (0);
  1807. }
  1808. processed+=2;
  1809. } else
  1810. return (0); /* somebody is fooling us */
  1811. byte_length = (bit_length + 7) / 8; /* prefix has variable length encoding */
  1812. if (!ND_TTEST2(*tptr, byte_length))
  1813. return (0);
  1814. memset(prefix, 0, sizeof prefix); /* clear the copy buffer */
  1815. memcpy(prefix,tptr,byte_length); /* copy as much as is stored in the TLV */
  1816. tptr+=byte_length;
  1817. processed+=byte_length;
  1818. if (afi == AF_INET)
  1819. ND_PRINT((ndo, "%sIPv4 prefix: %15s/%u",
  1820. ident,
  1821. ipaddr_string(ndo, prefix),
  1822. bit_length));
  1823. else if (afi == AF_INET6)
  1824. ND_PRINT((ndo, "%sIPv6 prefix: %s/%u",
  1825. ident,
  1826. ip6addr_string(ndo, prefix),
  1827. bit_length));
  1828. ND_PRINT((ndo, ", Distribution: %s, Metric: %u",
  1829. ISIS_MASK_TLV_EXTD_IP_UPDOWN(status_byte) ? "down" : "up",
  1830. metric));
  1831. if (afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
  1832. ND_PRINT((ndo, ", sub-TLVs present"));
  1833. else if (afi == AF_INET6)
  1834. ND_PRINT((ndo, ", %s%s",
  1835. ISIS_MASK_TLV_EXTD_IP6_IE(status_byte) ? "External" : "Internal",
  1836. ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte) ? ", sub-TLVs present" : ""));
  1837. if ((afi == AF_INET && ISIS_MASK_TLV_EXTD_IP_SUBTLV(status_byte))
  1838. || (afi == AF_INET6 && ISIS_MASK_TLV_EXTD_IP6_SUBTLV(status_byte))
  1839. ) {
  1840. /* assume that one prefix can hold more
  1841. than one subTLV - therefore the first byte must reflect
  1842. the aggregate bytecount of the subTLVs for this prefix
  1843. */
  1844. if (!ND_TTEST2(*tptr, 1))
  1845. return (0);
  1846. sublen=*(tptr++);
  1847. processed+=sublen+1;
  1848. ND_PRINT((ndo, " (%u)", sublen)); /* print out subTLV length */
  1849. while (sublen>0) {
  1850. if (!ND_TTEST2(*tptr,2))
  1851. return (0);
  1852. subtlvtype=*(tptr++);
  1853. subtlvlen=*(tptr++);
  1854. /* prepend the indent string */
  1855. snprintf(ident_buffer, sizeof(ident_buffer), "%s ",ident);
  1856. if (!isis_print_ip_reach_subtlv(ndo, tptr, subtlvtype, subtlvlen, ident_buffer))
  1857. return(0);
  1858. tptr+=subtlvlen;
  1859. sublen-=(subtlvlen+2);
  1860. }
  1861. }
  1862. return (processed);
  1863. }
  1864. /*
  1865. * Clear checksum and lifetime prior to signature verification.
  1866. */
  1867. static void
  1868. isis_clear_checksum_lifetime(void *header)
  1869. {
  1870. struct isis_lsp_header *header_lsp = (struct isis_lsp_header *) header;
  1871. header_lsp->checksum[0] = 0;
  1872. header_lsp->checksum[1] = 0;
  1873. header_lsp->remaining_lifetime[0] = 0;
  1874. header_lsp->remaining_lifetime[1] = 0;
  1875. }
  1876. /*
  1877. * isis_print
  1878. * Decode IS-IS packets. Return 0 on error.
  1879. */
  1880. static int
  1881. isis_print(netdissect_options *ndo,
  1882. const uint8_t *p, u_int length)
  1883. {
  1884. const struct isis_common_header *isis_header;
  1885. const struct isis_iih_lan_header *header_iih_lan;
  1886. const struct isis_iih_ptp_header *header_iih_ptp;
  1887. const struct isis_lsp_header *header_lsp;
  1888. const struct isis_csnp_header *header_csnp;
  1889. const struct isis_psnp_header *header_psnp;
  1890. const struct isis_tlv_lsp *tlv_lsp;
  1891. const struct isis_tlv_ptp_adj *tlv_ptp_adj;
  1892. const struct isis_tlv_is_reach *tlv_is_reach;
  1893. const struct isis_tlv_es_reach *tlv_es_reach;
  1894. uint8_t pdu_type, max_area, id_length, tlv_type, tlv_len, tmp, alen, lan_alen, prefix_len;
  1895. uint8_t ext_is_len, ext_ip_len, mt_len;
  1896. const uint8_t *optr, *pptr, *tptr;
  1897. u_short packet_len,pdu_len, key_id;
  1898. u_int i,vendor_id;
  1899. int sigcheck;
  1900. packet_len=length;
  1901. optr = p; /* initialize the _o_riginal pointer to the packet start -
  1902. need it for parsing the checksum TLV and authentication
  1903. TLV verification */
  1904. isis_header = (const struct isis_common_header *)p;
  1905. ND_TCHECK(*isis_header);
  1906. if (length < ISIS_COMMON_HEADER_SIZE)
  1907. goto trunc;
  1908. pptr = p+(ISIS_COMMON_HEADER_SIZE);
  1909. header_iih_lan = (const struct isis_iih_lan_header *)pptr;
  1910. header_iih_ptp = (const struct isis_iih_ptp_header *)pptr;
  1911. header_lsp = (const struct isis_lsp_header *)pptr;
  1912. header_csnp = (const struct isis_csnp_header *)pptr;
  1913. header_psnp = (const struct isis_psnp_header *)pptr;
  1914. if (!ndo->ndo_eflag)
  1915. ND_PRINT((ndo, "IS-IS"));
  1916. /*
  1917. * Sanity checking of the header.
  1918. */
  1919. if (isis_header->version != ISIS_VERSION) {
  1920. ND_PRINT((ndo, "version %d packet not supported", isis_header->version));
  1921. return (0);
  1922. }
  1923. if ((isis_header->id_length != SYSTEM_ID_LEN) && (isis_header->id_length != 0)) {
  1924. ND_PRINT((ndo, "system ID length of %d is not supported",
  1925. isis_header->id_length));
  1926. return (0);
  1927. }
  1928. if (isis_header->pdu_version != ISIS_VERSION) {
  1929. ND_PRINT((ndo, "version %d packet not supported", isis_header->pdu_version));
  1930. return (0);
  1931. }
  1932. if (length < isis_header->fixed_len) {
  1933. ND_PRINT((ndo, "fixed header length %u > packet length %u", isis_header->fixed_len, length));
  1934. return (0);
  1935. }
  1936. if (isis_header->fixed_len < ISIS_COMMON_HEADER_SIZE) {
  1937. ND_PRINT((ndo, "fixed header length %u < minimum header size %u", isis_header->fixed_len, (u_int)ISIS_COMMON_HEADER_SIZE));
  1938. return (0);
  1939. }
  1940. max_area = isis_header->max_area;
  1941. switch(max_area) {
  1942. case 0:
  1943. max_area = 3; /* silly shit */
  1944. break;
  1945. case 255:
  1946. ND_PRINT((ndo, "bad packet -- 255 areas"));
  1947. return (0);
  1948. default:
  1949. break;
  1950. }
  1951. id_length = isis_header->id_length;
  1952. switch(id_length) {
  1953. case 0:
  1954. id_length = 6; /* silly shit again */
  1955. break;
  1956. case 1: /* 1-8 are valid sys-ID lenghts */
  1957. case 2:
  1958. case 3:
  1959. case 4:
  1960. case 5:
  1961. case 6:
  1962. case 7:
  1963. case 8:
  1964. break;
  1965. case 255:
  1966. id_length = 0; /* entirely useless */
  1967. break;
  1968. default:
  1969. break;
  1970. }
  1971. /* toss any non 6-byte sys-ID len PDUs */
  1972. if (id_length != 6 ) {
  1973. ND_PRINT((ndo, "bad packet -- illegal sys-ID length (%u)", id_length));
  1974. return (0);
  1975. }
  1976. pdu_type=isis_header->pdu_type;
  1977. /* in non-verbose mode print the basic PDU Type plus PDU specific brief information*/
  1978. if (ndo->ndo_vflag == 0) {
  1979. ND_PRINT((ndo, "%s%s",
  1980. ndo->ndo_eflag ? "" : ", ",
  1981. tok2str(isis_pdu_values, "unknown PDU-Type %u", pdu_type)));
  1982. } else {
  1983. /* ok they seem to want to know everything - lets fully decode it */
  1984. ND_PRINT((ndo, "%slength %u", ndo->ndo_eflag ? "" : ", ", length));
  1985. ND_PRINT((ndo, "\n\t%s, hlen: %u, v: %u, pdu-v: %u, sys-id-len: %u (%u), max-area: %u (%u)",
  1986. tok2str(isis_pdu_values,
  1987. "unknown, type %u",
  1988. pdu_type),
  1989. isis_header->fixed_len,
  1990. isis_header->version,
  1991. isis_header->pdu_version,
  1992. id_length,
  1993. isis_header->id_length,
  1994. max_area,
  1995. isis_header->max_area));
  1996. if (ndo->ndo_vflag > 1) {
  1997. if (!print_unknown_data(ndo, optr, "\n\t", 8)) /* provide the _o_riginal pointer */
  1998. return (0); /* for optionally debugging the common header */
  1999. }
  2000. }
  2001. switch (pdu_type) {
  2002. case ISIS_PDU_L1_LAN_IIH:
  2003. case ISIS_PDU_L2_LAN_IIH:
  2004. if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)) {
  2005. ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
  2006. isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)));
  2007. return (0);
  2008. }
  2009. ND_TCHECK(*header_iih_lan);
  2010. if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE)
  2011. goto trunc;
  2012. if (ndo->ndo_vflag == 0) {
  2013. ND_PRINT((ndo, ", src-id %s",
  2014. isis_print_id(header_iih_lan->source_id, SYSTEM_ID_LEN)));
  2015. ND_PRINT((ndo, ", lan-id %s, prio %u",
  2016. isis_print_id(header_iih_lan->lan_id,NODE_ID_LEN),
  2017. header_iih_lan->priority));
  2018. ND_PRINT((ndo, ", length %u", length));
  2019. return (1);
  2020. }
  2021. pdu_len=EXTRACT_16BITS(header_iih_lan->pdu_len);
  2022. if (packet_len>pdu_len) {
  2023. packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
  2024. length=pdu_len;
  2025. }
  2026. ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
  2027. isis_print_id(header_iih_lan->source_id,SYSTEM_ID_LEN),
  2028. EXTRACT_16BITS(header_iih_lan->holding_time),
  2029. tok2str(isis_iih_circuit_type_values,
  2030. "unknown circuit type 0x%02x",
  2031. header_iih_lan->circuit_type)));
  2032. ND_PRINT((ndo, "\n\t lan-id: %s, Priority: %u, PDU length: %u",
  2033. isis_print_id(header_iih_lan->lan_id, NODE_ID_LEN),
  2034. (header_iih_lan->priority) & ISIS_LAN_PRIORITY_MASK,
  2035. pdu_len));
  2036. if (ndo->ndo_vflag > 1) {
  2037. if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_LAN_HEADER_SIZE))
  2038. return (0);
  2039. }
  2040. packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
  2041. pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_LAN_HEADER_SIZE);
  2042. break;
  2043. case ISIS_PDU_PTP_IIH:
  2044. if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)) {
  2045. ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
  2046. isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)));
  2047. return (0);
  2048. }
  2049. ND_TCHECK(*header_iih_ptp);
  2050. if (length < ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE)
  2051. goto trunc;
  2052. if (ndo->ndo_vflag == 0) {
  2053. ND_PRINT((ndo, ", src-id %s", isis_print_id(header_iih_ptp->source_id, SYSTEM_ID_LEN)));
  2054. ND_PRINT((ndo, ", length %u", length));
  2055. return (1);
  2056. }
  2057. pdu_len=EXTRACT_16BITS(header_iih_ptp->pdu_len);
  2058. if (packet_len>pdu_len) {
  2059. packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
  2060. length=pdu_len;
  2061. }
  2062. ND_PRINT((ndo, "\n\t source-id: %s, holding time: %us, Flags: [%s]",
  2063. isis_print_id(header_iih_ptp->source_id,SYSTEM_ID_LEN),
  2064. EXTRACT_16BITS(header_iih_ptp->holding_time),
  2065. tok2str(isis_iih_circuit_type_values,
  2066. "unknown circuit type 0x%02x",
  2067. header_iih_ptp->circuit_type)));
  2068. ND_PRINT((ndo, "\n\t circuit-id: 0x%02x, PDU length: %u",
  2069. header_iih_ptp->circuit_id,
  2070. pdu_len));
  2071. if (ndo->ndo_vflag > 1) {
  2072. if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_IIH_PTP_HEADER_SIZE))
  2073. return (0);
  2074. }
  2075. packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
  2076. pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_IIH_PTP_HEADER_SIZE);
  2077. break;
  2078. case ISIS_PDU_L1_LSP:
  2079. case ISIS_PDU_L2_LSP:
  2080. if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)) {
  2081. ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
  2082. isis_header->fixed_len, (unsigned long)ISIS_LSP_HEADER_SIZE));
  2083. return (0);
  2084. }
  2085. ND_TCHECK(*header_lsp);
  2086. if (length < ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE)
  2087. goto trunc;
  2088. if (ndo->ndo_vflag == 0) {
  2089. ND_PRINT((ndo, ", lsp-id %s, seq 0x%08x, lifetime %5us",
  2090. isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
  2091. EXTRACT_32BITS(header_lsp->sequence_number),
  2092. EXTRACT_16BITS(header_lsp->remaining_lifetime)));
  2093. ND_PRINT((ndo, ", length %u", length));
  2094. return (1);
  2095. }
  2096. pdu_len=EXTRACT_16BITS(header_lsp->pdu_len);
  2097. if (packet_len>pdu_len) {
  2098. packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
  2099. length=pdu_len;
  2100. }
  2101. ND_PRINT((ndo, "\n\t lsp-id: %s, seq: 0x%08x, lifetime: %5us\n\t chksum: 0x%04x",
  2102. isis_print_id(header_lsp->lsp_id, LSP_ID_LEN),
  2103. EXTRACT_32BITS(header_lsp->sequence_number),
  2104. EXTRACT_16BITS(header_lsp->remaining_lifetime),
  2105. EXTRACT_16BITS(header_lsp->checksum)));
  2106. osi_print_cksum(ndo, (const uint8_t *)header_lsp->lsp_id,
  2107. EXTRACT_16BITS(header_lsp->checksum),
  2108. 12, length-12);
  2109. ND_PRINT((ndo, ", PDU length: %u, Flags: [ %s",
  2110. pdu_len,
  2111. ISIS_MASK_LSP_OL_BIT(header_lsp->typeblock) ? "Overload bit set, " : ""));
  2112. if (ISIS_MASK_LSP_ATT_BITS(header_lsp->typeblock)) {
  2113. ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DEFAULT_BIT(header_lsp->typeblock) ? "default " : ""));
  2114. ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_DELAY_BIT(header_lsp->typeblock) ? "delay " : ""));
  2115. ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_EXPENSE_BIT(header_lsp->typeblock) ? "expense " : ""));
  2116. ND_PRINT((ndo, "%s", ISIS_MASK_LSP_ATT_ERROR_BIT(header_lsp->typeblock) ? "error " : ""));
  2117. ND_PRINT((ndo, "ATT bit set, "));
  2118. }
  2119. ND_PRINT((ndo, "%s", ISIS_MASK_LSP_PARTITION_BIT(header_lsp->typeblock) ? "P bit set, " : ""));
  2120. ND_PRINT((ndo, "%s ]", tok2str(isis_lsp_istype_values, "Unknown(0x%x)",
  2121. ISIS_MASK_LSP_ISTYPE_BITS(header_lsp->typeblock))));
  2122. if (ndo->ndo_vflag > 1) {
  2123. if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_LSP_HEADER_SIZE))
  2124. return (0);
  2125. }
  2126. packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
  2127. pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_LSP_HEADER_SIZE);
  2128. break;
  2129. case ISIS_PDU_L1_CSNP:
  2130. case ISIS_PDU_L2_CSNP:
  2131. if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)) {
  2132. ND_PRINT((ndo, ", bogus fixed header length %u should be %lu",
  2133. isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)));
  2134. return (0);
  2135. }
  2136. ND_TCHECK(*header_csnp);
  2137. if (length < ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE)
  2138. goto trunc;
  2139. if (ndo->ndo_vflag == 0) {
  2140. ND_PRINT((ndo, ", src-id %s", isis_print_id(header_csnp->source_id, NODE_ID_LEN)));
  2141. ND_PRINT((ndo, ", length %u", length));
  2142. return (1);
  2143. }
  2144. pdu_len=EXTRACT_16BITS(header_csnp->pdu_len);
  2145. if (packet_len>pdu_len) {
  2146. packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
  2147. length=pdu_len;
  2148. }
  2149. ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
  2150. isis_print_id(header_csnp->source_id, NODE_ID_LEN),
  2151. pdu_len));
  2152. ND_PRINT((ndo, "\n\t start lsp-id: %s",
  2153. isis_print_id(header_csnp->start_lsp_id, LSP_ID_LEN)));
  2154. ND_PRINT((ndo, "\n\t end lsp-id: %s",
  2155. isis_print_id(header_csnp->end_lsp_id, LSP_ID_LEN)));
  2156. if (ndo->ndo_vflag > 1) {
  2157. if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_CSNP_HEADER_SIZE))
  2158. return (0);
  2159. }
  2160. packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
  2161. pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_CSNP_HEADER_SIZE);
  2162. break;
  2163. case ISIS_PDU_L1_PSNP:
  2164. case ISIS_PDU_L2_PSNP:
  2165. if (isis_header->fixed_len != (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)) {
  2166. ND_PRINT((ndo, "- bogus fixed header length %u should be %lu",
  2167. isis_header->fixed_len, (unsigned long)(ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)));
  2168. return (0);
  2169. }
  2170. ND_TCHECK(*header_psnp);
  2171. if (length < ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE)
  2172. goto trunc;
  2173. if (ndo->ndo_vflag == 0) {
  2174. ND_PRINT((ndo, ", src-id %s", isis_print_id(header_psnp->source_id, NODE_ID_LEN)));
  2175. ND_PRINT((ndo, ", length %u", length));
  2176. return (1);
  2177. }
  2178. pdu_len=EXTRACT_16BITS(header_psnp->pdu_len);
  2179. if (packet_len>pdu_len) {
  2180. packet_len=pdu_len; /* do TLV decoding as long as it makes sense */
  2181. length=pdu_len;
  2182. }
  2183. ND_PRINT((ndo, "\n\t source-id: %s, PDU length: %u",
  2184. isis_print_id(header_psnp->source_id, NODE_ID_LEN),
  2185. pdu_len));
  2186. if (ndo->ndo_vflag > 1) {
  2187. if (!print_unknown_data(ndo, pptr, "\n\t ", ISIS_PSNP_HEADER_SIZE))
  2188. return (0);
  2189. }
  2190. packet_len -= (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
  2191. pptr = p + (ISIS_COMMON_HEADER_SIZE+ISIS_PSNP_HEADER_SIZE);
  2192. break;
  2193. default:
  2194. if (ndo->ndo_vflag == 0) {
  2195. ND_PRINT((ndo, ", length %u", length));
  2196. return (1);
  2197. }
  2198. (void)print_unknown_data(ndo, pptr, "\n\t ", length);
  2199. return (0);
  2200. }
  2201. /*
  2202. * Now print the TLV's.
  2203. */
  2204. while (packet_len > 0) {
  2205. ND_TCHECK2(*pptr, 2);
  2206. if (packet_len < 2)
  2207. goto trunc;
  2208. tlv_type = *pptr++;
  2209. tlv_len = *pptr++;
  2210. tmp =tlv_len; /* copy temporary len & pointer to packet data */
  2211. tptr = pptr;
  2212. packet_len -= 2;
  2213. /* first lets see if we know the TLVs name*/
  2214. ND_PRINT((ndo, "\n\t %s TLV #%u, length: %u",
  2215. tok2str(isis_tlv_values,
  2216. "unknown",
  2217. tlv_type),
  2218. tlv_type,
  2219. tlv_len));
  2220. if (tlv_len == 0) /* something is invalid */
  2221. continue;
  2222. if (packet_len < tlv_len)
  2223. goto trunc;
  2224. /* now check if we have a decoder otherwise do a hexdump at the end*/
  2225. switch (tlv_type) {
  2226. case ISIS_TLV_AREA_ADDR:
  2227. ND_TCHECK2(*tptr, 1);
  2228. alen = *tptr++;
  2229. while (tmp && alen < tmp) {
  2230. ND_TCHECK2(*tptr, alen);
  2231. ND_PRINT((ndo, "\n\t Area address (length: %u): %s",
  2232. alen,
  2233. isonsap_string(ndo, tptr, alen)));
  2234. tptr += alen;
  2235. tmp -= alen + 1;
  2236. if (tmp==0) /* if this is the last area address do not attemt a boundary check */
  2237. break;
  2238. ND_TCHECK2(*tptr, 1);
  2239. alen = *tptr++;
  2240. }
  2241. break;
  2242. case ISIS_TLV_ISNEIGH:
  2243. while (tmp >= ETHER_ADDR_LEN) {
  2244. ND_TCHECK2(*tptr, ETHER_ADDR_LEN);
  2245. ND_PRINT((ndo, "\n\t SNPA: %s", isis_print_id(tptr, ETHER_ADDR_LEN)));
  2246. tmp -= ETHER_ADDR_LEN;
  2247. tptr += ETHER_ADDR_LEN;
  2248. }
  2249. break;
  2250. case ISIS_TLV_ISNEIGH_VARLEN:
  2251. if (!ND_TTEST2(*tptr, 1) || tmp < 3) /* min. TLV length */
  2252. goto trunctlv;
  2253. lan_alen = *tptr++; /* LAN address length */
  2254. if (lan_alen == 0) {
  2255. ND_PRINT((ndo, "\n\t LAN address length 0 bytes (invalid)"));
  2256. break;
  2257. }
  2258. tmp --;
  2259. ND_PRINT((ndo, "\n\t LAN address length %u bytes ", lan_alen));
  2260. while (tmp >= lan_alen) {
  2261. ND_TCHECK2(*tptr, lan_alen);
  2262. ND_PRINT((ndo, "\n\t\tIS Neighbor: %s", isis_print_id(tptr, lan_alen)));
  2263. tmp -= lan_alen;
  2264. tptr +=lan_alen;
  2265. }
  2266. break;
  2267. case ISIS_TLV_PADDING:
  2268. break;
  2269. case ISIS_TLV_MT_IS_REACH:
  2270. mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
  2271. if (mt_len == 0) /* did something go wrong ? */
  2272. goto trunctlv;
  2273. tptr+=mt_len;
  2274. tmp-=mt_len;
  2275. while (tmp >= 2+NODE_ID_LEN+3+1) {
  2276. ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
  2277. if (ext_is_len == 0) /* did something go wrong ? */
  2278. goto trunctlv;
  2279. tmp-=ext_is_len;
  2280. tptr+=ext_is_len;
  2281. }
  2282. break;
  2283. case ISIS_TLV_IS_ALIAS_ID:
  2284. while (tmp >= NODE_ID_LEN+1) { /* is it worth attempting a decode ? */
  2285. ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
  2286. if (ext_is_len == 0) /* did something go wrong ? */
  2287. goto trunctlv;
  2288. tmp-=ext_is_len;
  2289. tptr+=ext_is_len;
  2290. }
  2291. break;
  2292. case ISIS_TLV_EXT_IS_REACH:
  2293. while (tmp >= NODE_ID_LEN+3+1) { /* is it worth attempting a decode ? */
  2294. ext_is_len = isis_print_ext_is_reach(ndo, tptr, "\n\t ", tlv_type);
  2295. if (ext_is_len == 0) /* did something go wrong ? */
  2296. goto trunctlv;
  2297. tmp-=ext_is_len;
  2298. tptr+=ext_is_len;
  2299. }
  2300. break;
  2301. case ISIS_TLV_IS_REACH:
  2302. ND_TCHECK2(*tptr,1); /* check if there is one byte left to read out the virtual flag */
  2303. ND_PRINT((ndo, "\n\t %s",
  2304. tok2str(isis_is_reach_virtual_values,
  2305. "bogus virtual flag 0x%02x",
  2306. *tptr++)));
  2307. tlv_is_reach = (const struct isis_tlv_is_reach *)tptr;
  2308. while (tmp >= sizeof(struct isis_tlv_is_reach)) {
  2309. ND_TCHECK(*tlv_is_reach);
  2310. ND_PRINT((ndo, "\n\t IS Neighbor: %s",
  2311. isis_print_id(tlv_is_reach->neighbor_nodeid, NODE_ID_LEN)));
  2312. isis_print_metric_block(ndo, &tlv_is_reach->isis_metric_block);
  2313. tmp -= sizeof(struct isis_tlv_is_reach);
  2314. tlv_is_reach++;
  2315. }
  2316. break;
  2317. case ISIS_TLV_ESNEIGH:
  2318. tlv_es_reach = (const struct isis_tlv_es_reach *)tptr;
  2319. while (tmp >= sizeof(struct isis_tlv_es_reach)) {
  2320. ND_TCHECK(*tlv_es_reach);
  2321. ND_PRINT((ndo, "\n\t ES Neighbor: %s",
  2322. isis_print_id(tlv_es_reach->neighbor_sysid, SYSTEM_ID_LEN)));
  2323. isis_print_metric_block(ndo, &tlv_es_reach->isis_metric_block);
  2324. tmp -= sizeof(struct isis_tlv_es_reach);
  2325. tlv_es_reach++;
  2326. }
  2327. break;
  2328. /* those two TLVs share the same format */
  2329. case ISIS_TLV_INT_IP_REACH:
  2330. case ISIS_TLV_EXT_IP_REACH:
  2331. if (!isis_print_tlv_ip_reach(ndo, pptr, "\n\t ", tlv_len))
  2332. return (1);
  2333. break;
  2334. case ISIS_TLV_EXTD_IP_REACH:
  2335. while (tmp>0) {
  2336. ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
  2337. if (ext_ip_len == 0) /* did something go wrong ? */
  2338. goto trunctlv;
  2339. tptr+=ext_ip_len;
  2340. tmp-=ext_ip_len;
  2341. }
  2342. break;
  2343. case ISIS_TLV_MT_IP_REACH:
  2344. mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
  2345. if (mt_len == 0) { /* did something go wrong ? */
  2346. goto trunctlv;
  2347. }
  2348. tptr+=mt_len;
  2349. tmp-=mt_len;
  2350. while (tmp>0) {
  2351. ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET);
  2352. if (ext_ip_len == 0) /* did something go wrong ? */
  2353. goto trunctlv;
  2354. tptr+=ext_ip_len;
  2355. tmp-=ext_ip_len;
  2356. }
  2357. break;
  2358. case ISIS_TLV_IP6_REACH:
  2359. while (tmp>0) {
  2360. ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
  2361. if (ext_ip_len == 0) /* did something go wrong ? */
  2362. goto trunctlv;
  2363. tptr+=ext_ip_len;
  2364. tmp-=ext_ip_len;
  2365. }
  2366. break;
  2367. case ISIS_TLV_MT_IP6_REACH:
  2368. mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
  2369. if (mt_len == 0) { /* did something go wrong ? */
  2370. goto trunctlv;
  2371. }
  2372. tptr+=mt_len;
  2373. tmp-=mt_len;
  2374. while (tmp>0) {
  2375. ext_ip_len = isis_print_extd_ip_reach(ndo, tptr, "\n\t ", AF_INET6);
  2376. if (ext_ip_len == 0) /* did something go wrong ? */
  2377. goto trunctlv;
  2378. tptr+=ext_ip_len;
  2379. tmp-=ext_ip_len;
  2380. }
  2381. break;
  2382. case ISIS_TLV_IP6ADDR:
  2383. while (tmp>=sizeof(struct in6_addr)) {
  2384. ND_TCHECK2(*tptr, sizeof(struct in6_addr));
  2385. ND_PRINT((ndo, "\n\t IPv6 interface address: %s",
  2386. ip6addr_string(ndo, tptr)));
  2387. tptr += sizeof(struct in6_addr);
  2388. tmp -= sizeof(struct in6_addr);
  2389. }
  2390. break;
  2391. case ISIS_TLV_AUTH:
  2392. ND_TCHECK2(*tptr, 1);
  2393. ND_PRINT((ndo, "\n\t %s: ",
  2394. tok2str(isis_subtlv_auth_values,
  2395. "unknown Authentication type 0x%02x",
  2396. *tptr)));
  2397. switch (*tptr) {
  2398. case ISIS_SUBTLV_AUTH_SIMPLE:
  2399. if (fn_printzp(ndo, tptr + 1, tlv_len - 1, ndo->ndo_snapend))
  2400. goto trunctlv;
  2401. break;
  2402. case ISIS_SUBTLV_AUTH_MD5:
  2403. for(i=1;i<tlv_len;i++) {
  2404. ND_TCHECK2(*(tptr + i), 1);
  2405. ND_PRINT((ndo, "%02x", *(tptr + i)));
  2406. }
  2407. if (tlv_len != ISIS_SUBTLV_AUTH_MD5_LEN+1)
  2408. ND_PRINT((ndo, ", (invalid subTLV) "));
  2409. sigcheck = signature_verify(ndo, optr, length, tptr + 1,
  2410. isis_clear_checksum_lifetime,
  2411. header_lsp);
  2412. ND_PRINT((ndo, " (%s)", tok2str(signature_check_values, "Unknown", sigcheck)));
  2413. break;
  2414. case ISIS_SUBTLV_AUTH_GENERIC:
  2415. ND_TCHECK2(*(tptr + 1), 2);
  2416. key_id = EXTRACT_16BITS((tptr+1));
  2417. ND_PRINT((ndo, "%u, password: ", key_id));
  2418. for(i=1 + sizeof(uint16_t);i<tlv_len;i++) {
  2419. ND_TCHECK2(*(tptr + i), 1);
  2420. ND_PRINT((ndo, "%02x", *(tptr + i)));
  2421. }
  2422. break;
  2423. case ISIS_SUBTLV_AUTH_PRIVATE:
  2424. default:
  2425. if (!print_unknown_data(ndo, tptr + 1, "\n\t\t ", tlv_len - 1))
  2426. return(0);
  2427. break;
  2428. }
  2429. break;
  2430. case ISIS_TLV_PTP_ADJ:
  2431. tlv_ptp_adj = (const struct isis_tlv_ptp_adj *)tptr;
  2432. if(tmp>=1) {
  2433. ND_TCHECK2(*tptr, 1);
  2434. ND_PRINT((ndo, "\n\t Adjacency State: %s (%u)",
  2435. tok2str(isis_ptp_adjancey_values, "unknown", *tptr),
  2436. *tptr));
  2437. tmp--;
  2438. }
  2439. if(tmp>sizeof(tlv_ptp_adj->extd_local_circuit_id)) {
  2440. ND_TCHECK(tlv_ptp_adj->extd_local_circuit_id);
  2441. ND_PRINT((ndo, "\n\t Extended Local circuit-ID: 0x%08x",
  2442. EXTRACT_32BITS(tlv_ptp_adj->extd_local_circuit_id)));
  2443. tmp-=sizeof(tlv_ptp_adj->extd_local_circuit_id);
  2444. }
  2445. if(tmp>=SYSTEM_ID_LEN) {
  2446. ND_TCHECK2(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN);
  2447. ND_PRINT((ndo, "\n\t Neighbor System-ID: %s",
  2448. isis_print_id(tlv_ptp_adj->neighbor_sysid, SYSTEM_ID_LEN)));
  2449. tmp-=SYSTEM_ID_LEN;
  2450. }
  2451. if(tmp>=sizeof(tlv_ptp_adj->neighbor_extd_local_circuit_id)) {
  2452. ND_TCHECK(tlv_ptp_adj->neighbor_extd_local_circuit_id);
  2453. ND_PRINT((ndo, "\n\t Neighbor Extended Local circuit-ID: 0x%08x",
  2454. EXTRACT_32BITS(tlv_ptp_adj->neighbor_extd_local_circuit_id)));
  2455. }
  2456. break;
  2457. case ISIS_TLV_PROTOCOLS:
  2458. ND_PRINT((ndo, "\n\t NLPID(s): "));
  2459. while (tmp>0) {
  2460. ND_TCHECK2(*(tptr), 1);
  2461. ND_PRINT((ndo, "%s (0x%02x)",
  2462. tok2str(nlpid_values,
  2463. "unknown",
  2464. *tptr),
  2465. *tptr));
  2466. if (tmp>1) /* further NPLIDs ? - put comma */
  2467. ND_PRINT((ndo, ", "));
  2468. tptr++;
  2469. tmp--;
  2470. }
  2471. break;
  2472. case ISIS_TLV_MT_PORT_CAP:
  2473. {
  2474. ND_TCHECK2(*(tptr), 2);
  2475. ND_PRINT((ndo, "\n\t RES: %d, MTID(s): %d",
  2476. (EXTRACT_16BITS (tptr) >> 12),
  2477. (EXTRACT_16BITS (tptr) & 0x0fff)));
  2478. tmp = tmp-2;
  2479. tptr = tptr+2;
  2480. if (tmp)
  2481. isis_print_mt_port_cap_subtlv(ndo, tptr, tmp);
  2482. break;
  2483. }
  2484. case ISIS_TLV_MT_CAPABILITY:
  2485. ND_TCHECK2(*(tptr), 2);
  2486. ND_PRINT((ndo, "\n\t O: %d, RES: %d, MTID(s): %d",
  2487. (EXTRACT_16BITS(tptr) >> 15) & 0x01,
  2488. (EXTRACT_16BITS(tptr) >> 12) & 0x07,
  2489. EXTRACT_16BITS(tptr) & 0x0fff));
  2490. tmp = tmp-2;
  2491. tptr = tptr+2;
  2492. if (tmp)
  2493. isis_print_mt_capability_subtlv(ndo, tptr, tmp);
  2494. break;
  2495. case ISIS_TLV_TE_ROUTER_ID:
  2496. ND_TCHECK2(*pptr, sizeof(struct in_addr));
  2497. ND_PRINT((ndo, "\n\t Traffic Engineering Router ID: %s", ipaddr_string(ndo, pptr)));
  2498. break;
  2499. case ISIS_TLV_IPADDR:
  2500. while (tmp>=sizeof(struct in_addr)) {
  2501. ND_TCHECK2(*tptr, sizeof(struct in_addr));
  2502. ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
  2503. tptr += sizeof(struct in_addr);
  2504. tmp -= sizeof(struct in_addr);
  2505. }
  2506. break;
  2507. case ISIS_TLV_HOSTNAME:
  2508. ND_PRINT((ndo, "\n\t Hostname: "));
  2509. if (fn_printzp(ndo, tptr, tmp, ndo->ndo_snapend))
  2510. goto trunctlv;
  2511. break;
  2512. case ISIS_TLV_SHARED_RISK_GROUP:
  2513. if (tmp < NODE_ID_LEN)
  2514. break;
  2515. ND_TCHECK2(*tptr, NODE_ID_LEN);
  2516. ND_PRINT((ndo, "\n\t IS Neighbor: %s", isis_print_id(tptr, NODE_ID_LEN)));
  2517. tptr+=(NODE_ID_LEN);
  2518. tmp-=(NODE_ID_LEN);
  2519. if (tmp < 1)
  2520. break;
  2521. ND_TCHECK2(*tptr, 1);
  2522. ND_PRINT((ndo, ", Flags: [%s]", ISIS_MASK_TLV_SHARED_RISK_GROUP(*tptr++) ? "numbered" : "unnumbered"));
  2523. tmp--;
  2524. if (tmp < sizeof(struct in_addr))
  2525. break;
  2526. ND_TCHECK2(*tptr, sizeof(struct in_addr));
  2527. ND_PRINT((ndo, "\n\t IPv4 interface address: %s", ipaddr_string(ndo, tptr)));
  2528. tptr+=sizeof(struct in_addr);
  2529. tmp-=sizeof(struct in_addr);
  2530. if (tmp < sizeof(struct in_addr))
  2531. break;
  2532. ND_TCHECK2(*tptr, sizeof(struct in_addr));
  2533. ND_PRINT((ndo, "\n\t IPv4 neighbor address: %s", ipaddr_string(ndo, tptr)));
  2534. tptr+=sizeof(struct in_addr);
  2535. tmp-=sizeof(struct in_addr);
  2536. while (tmp>=4) {
  2537. ND_TCHECK2(*tptr, 4);
  2538. ND_PRINT((ndo, "\n\t Link-ID: 0x%08x", EXTRACT_32BITS(tptr)));
  2539. tptr+=4;
  2540. tmp-=4;
  2541. }
  2542. break;
  2543. case ISIS_TLV_LSP:
  2544. tlv_lsp = (const struct isis_tlv_lsp *)tptr;
  2545. while(tmp>=sizeof(struct isis_tlv_lsp)) {
  2546. ND_TCHECK((tlv_lsp->lsp_id)[LSP_ID_LEN-1]);
  2547. ND_PRINT((ndo, "\n\t lsp-id: %s",
  2548. isis_print_id(tlv_lsp->lsp_id, LSP_ID_LEN)));
  2549. ND_TCHECK2(tlv_lsp->sequence_number, 4);
  2550. ND_PRINT((ndo, ", seq: 0x%08x", EXTRACT_32BITS(tlv_lsp->sequence_number)));
  2551. ND_TCHECK2(tlv_lsp->remaining_lifetime, 2);
  2552. ND_PRINT((ndo, ", lifetime: %5ds", EXTRACT_16BITS(tlv_lsp->remaining_lifetime)));
  2553. ND_TCHECK2(tlv_lsp->checksum, 2);
  2554. ND_PRINT((ndo, ", chksum: 0x%04x", EXTRACT_16BITS(tlv_lsp->checksum)));
  2555. tmp-=sizeof(struct isis_tlv_lsp);
  2556. tlv_lsp++;
  2557. }
  2558. break;
  2559. case ISIS_TLV_CHECKSUM:
  2560. if (tmp < ISIS_TLV_CHECKSUM_MINLEN)
  2561. break;
  2562. ND_TCHECK2(*tptr, ISIS_TLV_CHECKSUM_MINLEN);
  2563. ND_PRINT((ndo, "\n\t checksum: 0x%04x ", EXTRACT_16BITS(tptr)));
  2564. /* do not attempt to verify the checksum if it is zero
  2565. * most likely a HMAC-MD5 TLV is also present and
  2566. * to avoid conflicts the checksum TLV is zeroed.
  2567. * see rfc3358 for details
  2568. */
  2569. osi_print_cksum(ndo, optr, EXTRACT_16BITS(tptr), tptr-optr,
  2570. length);
  2571. break;
  2572. case ISIS_TLV_POI:
  2573. if (tlv_len >= SYSTEM_ID_LEN + 1) {
  2574. ND_TCHECK2(*tptr, SYSTEM_ID_LEN + 1);
  2575. ND_PRINT((ndo, "\n\t Purge Originator System-ID: %s",
  2576. isis_print_id(tptr + 1, SYSTEM_ID_LEN)));
  2577. }
  2578. if (tlv_len == 2 * SYSTEM_ID_LEN + 1) {
  2579. ND_TCHECK2(*tptr, 2 * SYSTEM_ID_LEN + 1);
  2580. ND_PRINT((ndo, "\n\t Received from System-ID: %s",
  2581. isis_print_id(tptr + SYSTEM_ID_LEN + 1, SYSTEM_ID_LEN)));
  2582. }
  2583. break;
  2584. case ISIS_TLV_MT_SUPPORTED:
  2585. if (tmp < ISIS_TLV_MT_SUPPORTED_MINLEN)
  2586. break;
  2587. while (tmp>1) {
  2588. /* length can only be a multiple of 2, otherwise there is
  2589. something broken -> so decode down until length is 1 */
  2590. if (tmp!=1) {
  2591. mt_len = isis_print_mtid(ndo, tptr, "\n\t ");
  2592. if (mt_len == 0) /* did something go wrong ? */
  2593. goto trunctlv;
  2594. tptr+=mt_len;
  2595. tmp-=mt_len;
  2596. } else {
  2597. ND_PRINT((ndo, "\n\t invalid MT-ID"));
  2598. break;
  2599. }
  2600. }
  2601. break;
  2602. case ISIS_TLV_RESTART_SIGNALING:
  2603. /* first attempt to decode the flags */
  2604. if (tmp < ISIS_TLV_RESTART_SIGNALING_FLAGLEN)
  2605. break;
  2606. ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_FLAGLEN);
  2607. ND_PRINT((ndo, "\n\t Flags [%s]",
  2608. bittok2str(isis_restart_flag_values, "none", *tptr)));
  2609. tptr+=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
  2610. tmp-=ISIS_TLV_RESTART_SIGNALING_FLAGLEN;
  2611. /* is there anything other than the flags field? */
  2612. if (tmp == 0)
  2613. break;
  2614. if (tmp < ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN)
  2615. break;
  2616. ND_TCHECK2(*tptr, ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN);
  2617. ND_PRINT((ndo, ", Remaining holding time %us", EXTRACT_16BITS(tptr)));
  2618. tptr+=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
  2619. tmp-=ISIS_TLV_RESTART_SIGNALING_HOLDTIMELEN;
  2620. /* is there an additional sysid field present ?*/
  2621. if (tmp == SYSTEM_ID_LEN) {
  2622. ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
  2623. ND_PRINT((ndo, ", for %s", isis_print_id(tptr,SYSTEM_ID_LEN)));
  2624. }
  2625. break;
  2626. case ISIS_TLV_IDRP_INFO:
  2627. if (tmp < ISIS_TLV_IDRP_INFO_MINLEN)
  2628. break;
  2629. ND_TCHECK2(*tptr, ISIS_TLV_IDRP_INFO_MINLEN);
  2630. ND_PRINT((ndo, "\n\t Inter-Domain Information Type: %s",
  2631. tok2str(isis_subtlv_idrp_values,
  2632. "Unknown (0x%02x)",
  2633. *tptr)));
  2634. switch (*tptr++) {
  2635. case ISIS_SUBTLV_IDRP_ASN:
  2636. ND_TCHECK2(*tptr, 2); /* fetch AS number */
  2637. ND_PRINT((ndo, "AS Number: %u", EXTRACT_16BITS(tptr)));
  2638. break;
  2639. case ISIS_SUBTLV_IDRP_LOCAL:
  2640. case ISIS_SUBTLV_IDRP_RES:
  2641. default:
  2642. if (!print_unknown_data(ndo, tptr, "\n\t ", tlv_len - 1))
  2643. return(0);
  2644. break;
  2645. }
  2646. break;
  2647. case ISIS_TLV_LSP_BUFFERSIZE:
  2648. if (tmp < ISIS_TLV_LSP_BUFFERSIZE_MINLEN)
  2649. break;
  2650. ND_TCHECK2(*tptr, ISIS_TLV_LSP_BUFFERSIZE_MINLEN);
  2651. ND_PRINT((ndo, "\n\t LSP Buffersize: %u", EXTRACT_16BITS(tptr)));
  2652. break;
  2653. case ISIS_TLV_PART_DIS:
  2654. while (tmp >= SYSTEM_ID_LEN) {
  2655. ND_TCHECK2(*tptr, SYSTEM_ID_LEN);
  2656. ND_PRINT((ndo, "\n\t %s", isis_print_id(tptr, SYSTEM_ID_LEN)));
  2657. tptr+=SYSTEM_ID_LEN;
  2658. tmp-=SYSTEM_ID_LEN;
  2659. }
  2660. break;
  2661. case ISIS_TLV_PREFIX_NEIGH:
  2662. if (tmp < sizeof(struct isis_metric_block))
  2663. break;
  2664. ND_TCHECK2(*tptr, sizeof(struct isis_metric_block));
  2665. ND_PRINT((ndo, "\n\t Metric Block"));
  2666. isis_print_metric_block(ndo, (const struct isis_metric_block *)tptr);
  2667. tptr+=sizeof(struct isis_metric_block);
  2668. tmp-=sizeof(struct isis_metric_block);
  2669. while(tmp>0) {
  2670. ND_TCHECK2(*tptr, 1);
  2671. prefix_len=*tptr++; /* read out prefix length in semioctets*/
  2672. if (prefix_len < 2) {
  2673. ND_PRINT((ndo, "\n\t\tAddress: prefix length %u < 2", prefix_len));
  2674. break;
  2675. }
  2676. tmp--;
  2677. if (tmp < prefix_len/2)
  2678. break;
  2679. ND_TCHECK2(*tptr, prefix_len / 2);
  2680. ND_PRINT((ndo, "\n\t\tAddress: %s/%u",
  2681. isonsap_string(ndo, tptr, prefix_len / 2), prefix_len * 4));
  2682. tptr+=prefix_len/2;
  2683. tmp-=prefix_len/2;
  2684. }
  2685. break;
  2686. case ISIS_TLV_IIH_SEQNR:
  2687. if (tmp < ISIS_TLV_IIH_SEQNR_MINLEN)
  2688. break;
  2689. ND_TCHECK2(*tptr, ISIS_TLV_IIH_SEQNR_MINLEN); /* check if four bytes are on the wire */
  2690. ND_PRINT((ndo, "\n\t Sequence number: %u", EXTRACT_32BITS(tptr)));
  2691. break;
  2692. case ISIS_TLV_VENDOR_PRIVATE:
  2693. if (tmp < ISIS_TLV_VENDOR_PRIVATE_MINLEN)
  2694. break;
  2695. ND_TCHECK2(*tptr, ISIS_TLV_VENDOR_PRIVATE_MINLEN); /* check if enough byte for a full oui */
  2696. vendor_id = EXTRACT_24BITS(tptr);
  2697. ND_PRINT((ndo, "\n\t Vendor: %s (%u)",
  2698. tok2str(oui_values, "Unknown", vendor_id),
  2699. vendor_id));
  2700. tptr+=3;
  2701. tmp-=3;
  2702. if (tmp > 0) /* hexdump the rest */
  2703. if (!print_unknown_data(ndo, tptr, "\n\t\t", tmp))
  2704. return(0);
  2705. break;
  2706. /*
  2707. * FIXME those are the defined TLVs that lack a decoder
  2708. * you are welcome to contribute code ;-)
  2709. */
  2710. case ISIS_TLV_DECNET_PHASE4:
  2711. case ISIS_TLV_LUCENT_PRIVATE:
  2712. case ISIS_TLV_IPAUTH:
  2713. case ISIS_TLV_NORTEL_PRIVATE1:
  2714. case ISIS_TLV_NORTEL_PRIVATE2:
  2715. default:
  2716. if (ndo->ndo_vflag <= 1) {
  2717. if (!print_unknown_data(ndo, pptr, "\n\t\t", tlv_len))
  2718. return(0);
  2719. }
  2720. break;
  2721. }
  2722. /* do we want to see an additionally hexdump ? */
  2723. if (ndo->ndo_vflag> 1) {
  2724. if (!print_unknown_data(ndo, pptr, "\n\t ", tlv_len))
  2725. return(0);
  2726. }
  2727. pptr += tlv_len;
  2728. packet_len -= tlv_len;
  2729. }
  2730. if (packet_len != 0) {
  2731. ND_PRINT((ndo, "\n\t %u straggler bytes", packet_len));
  2732. }
  2733. return (1);
  2734. trunc:
  2735. ND_PRINT((ndo, "%s", tstr));
  2736. return (1);
  2737. trunctlv:
  2738. ND_PRINT((ndo, "\n\t\t"));
  2739. ND_PRINT((ndo, "%s", tstr));
  2740. return(1);
  2741. }
  2742. static void
  2743. osi_print_cksum(netdissect_options *ndo, const uint8_t *pptr,
  2744. uint16_t checksum, int checksum_offset, u_int length)
  2745. {
  2746. uint16_t calculated_checksum;
  2747. /* do not attempt to verify the checksum if it is zero,
  2748. * if the offset is nonsense,
  2749. * or the base pointer is not sane
  2750. */
  2751. if (!checksum
  2752. || checksum_offset < 0
  2753. || !ND_TTEST2(*(pptr + checksum_offset), 2)
  2754. || (u_int)checksum_offset > length
  2755. || !ND_TTEST2(*pptr, length)) {
  2756. ND_PRINT((ndo, " (unverified)"));
  2757. } else {
  2758. #if 0
  2759. printf("\nosi_print_cksum: %p %u %u\n", pptr, checksum_offset, length);
  2760. #endif
  2761. calculated_checksum = create_osi_cksum(pptr, checksum_offset, length);
  2762. if (checksum == calculated_checksum) {
  2763. ND_PRINT((ndo, " (correct)"));
  2764. } else {
  2765. ND_PRINT((ndo, " (incorrect should be 0x%04x)", calculated_checksum));
  2766. }
  2767. }
  2768. }
  2769. /*
  2770. * Local Variables:
  2771. * c-style: whitesmith
  2772. * c-basic-offset: 8
  2773. * End:
  2774. */