@@ -14,7 +14,6 @@ import {
1414 getICMPCode ,
1515 getICMPDocUrl ,
1616 getICMPType ,
17- icmpAllCodesValues ,
1817 icmpAllTypesValues ,
1918 isValidICMPProto
2019} from '../../../utils/icmp' ;
@@ -369,41 +368,40 @@ export const RecordField: React.FC<RecordFieldProps> = ({
369368 }
370369 case ColumnsId . icmptype : {
371370 let child = emptyText ( ) ;
372- if ( Array . isArray ( value ) && value . length ) {
373- if ( isValidICMPProto ( Number ( value [ 0 ] ) ) ) {
374- const type = getICMPType ( Number ( value [ 0 ] ) , Number ( value [ 1 ] ) as icmpAllTypesValues ) ;
371+ if ( typeof value === 'number' && ! isNaN ( value ) ) {
372+ const proto = Number ( flow . fields . Proto ) ;
373+ if ( isValidICMPProto ( proto ) ) {
374+ const type = getICMPType ( proto , value as icmpAllTypesValues ) ;
375375 if ( type && detailed ) {
376- child = clickableContent ( type . name , type . description || '' , getICMPDocUrl ( Number ( value [ 0 ] ) ) ) ;
376+ child = clickableContent ( type . name , type . description || '' , getICMPDocUrl ( proto ) ) ;
377377 } else {
378- child = simpleTextWithTooltip ( type ?. name || String ( value [ 1 ] ) ) ! ;
378+ child = simpleTextWithTooltip ( type ?. name || String ( value ) ) ! ;
379379 }
380380 } else {
381381 child = errorTextValue (
382- String ( value [ 1 ] ) ,
383- t ( 'ICMP type provided but protocol is {{proto}}' , { proto : formatProtocol ( value [ 0 ] as number , t ) } )
382+ String ( value ) ,
383+ t ( 'ICMP type provided but protocol is {{proto}}' , { proto : formatProtocol ( proto , t ) } )
384384 ) ;
385385 }
386386 }
387387 return singleContainer ( child ) ;
388388 }
389389 case ColumnsId . icmpcode : {
390390 let child = emptyText ( ) ;
391- if ( Array . isArray ( value ) && value . length ) {
392- if ( isValidICMPProto ( Number ( value [ 0 ] ) ) ) {
393- const code = getICMPCode (
394- Number ( value [ 0 ] ) ,
395- Number ( value [ 1 ] ) as icmpAllTypesValues ,
396- Number ( value [ 2 ] ) as icmpAllCodesValues
397- ) ;
391+ if ( typeof value === 'number' && ! isNaN ( value ) ) {
392+ const proto = Number ( flow . fields . Proto ) ;
393+ const typez = Number ( flow . fields . IcmpType ) as icmpAllTypesValues ;
394+ if ( isValidICMPProto ( proto ) ) {
395+ const code = getICMPCode ( proto , typez , value ) ;
398396 if ( code && detailed ) {
399- child = clickableContent ( code . name , code . description || '' , getICMPDocUrl ( Number ( value [ 0 ] ) ) ) ;
397+ child = clickableContent ( code . name , code . description || '' , getICMPDocUrl ( proto ) ) ;
400398 } else {
401- child = simpleTextWithTooltip ( code ?. name || String ( value [ 2 ] ) ) ! ;
399+ child = simpleTextWithTooltip ( code ?. name || String ( value ) ) ! ;
402400 }
403401 } else {
404402 child = errorTextValue (
405- String ( value [ 1 ] ) ,
406- t ( 'ICMP code provided but protocol is {{proto}}' , { proto : formatProtocol ( value [ 0 ] as number , t ) } )
403+ String ( value ) ,
404+ t ( 'ICMP code provided but protocol is {{proto}}' , { proto : formatProtocol ( proto , t ) } )
407405 ) ;
408406 }
409407 }
0 commit comments