@@ -54,81 +54,76 @@ static const struct tok fcode_str[] = {
54
54
55
55
static void
56
56
loopback_message_print (netdissect_options * ndo ,
57
- const u_char * cp , u_int len )
57
+ const u_char * cp , u_int length )
58
58
{
59
59
uint16_t function ;
60
60
61
- if (len < 2 )
62
- goto invalid ;
61
+ ND_ICHECK_U (length , < , 2 );
63
62
/* function */
64
63
function = GET_LE_U_2 (cp );
65
64
cp += 2 ;
66
- len -= 2 ;
65
+ length -= 2 ;
67
66
ND_PRINT (", %s" , tok2str (fcode_str , " invalid (%u)" , function ));
68
67
69
68
switch (function ) {
70
69
case LOOPBACK_REPLY :
71
- if (len < 2 )
72
- goto invalid ;
70
+ ND_ICHECK_U (length , < , 2 );
73
71
/* receipt number */
74
72
ND_PRINT (", receipt number %u" , GET_LE_U_2 (cp ));
75
73
cp += 2 ;
76
- len -= 2 ;
74
+ length -= 2 ;
77
75
/* data */
78
- ND_PRINT (", data (%u octets)" , len );
79
- ND_TCHECK_LEN (cp , len );
76
+ ND_PRINT (", data (%u octets)" , length );
77
+ ND_TCHECK_LEN (cp , length );
80
78
break ;
81
79
case LOOPBACK_FWDDATA :
82
- if (len < MAC48_LEN )
83
- goto invalid ;
80
+ ND_ICHECK_U (length , < , MAC48_LEN );
84
81
/* forwarding address */
85
82
ND_PRINT (", forwarding address %s" , GET_MAC48_STRING (cp ));
86
83
cp += MAC48_LEN ;
87
- len -= MAC48_LEN ;
84
+ length -= MAC48_LEN ;
88
85
/* data */
89
- ND_PRINT (", data (%u octets)" , len );
90
- ND_TCHECK_LEN (cp , len );
86
+ ND_PRINT (", data (%u octets)" , length );
87
+ ND_TCHECK_LEN (cp , length );
91
88
break ;
92
89
default :
93
- ND_TCHECK_LEN (cp , len );
90
+ ND_TCHECK_LEN (cp , length );
94
91
break ;
95
92
}
96
93
return ;
97
94
98
95
invalid :
99
96
nd_print_invalid (ndo );
100
- ND_TCHECK_LEN (cp , len );
97
+ ND_TCHECK_LEN (cp , length );
101
98
}
102
99
103
100
void
104
101
loopback_print (netdissect_options * ndo ,
105
- const u_char * cp , u_int len )
102
+ const u_char * cp , u_int length )
106
103
{
107
104
uint16_t skipCount ;
108
105
109
106
ndo -> ndo_protocol = "loopback" ;
110
107
ND_PRINT ("Loopback" );
111
- if (len < 2 )
112
- goto invalid ;
108
+ ND_ICHECK_U (length , < , 2 );
113
109
/* skipCount */
114
110
skipCount = GET_LE_U_2 (cp );
115
111
cp += 2 ;
116
- len -= 2 ;
112
+ length -= 2 ;
117
113
ND_PRINT (", skipCount %u" , skipCount );
118
114
if (skipCount % 8 )
119
115
ND_PRINT (" (bogus)" );
120
- if (skipCount > len )
121
- goto invalid ;
116
+ ND_ICHECK_U (length , < , skipCount );
122
117
/* the octets to skip */
123
118
ND_TCHECK_LEN (cp , skipCount );
124
119
cp += skipCount ;
125
- len -= skipCount ;
120
+ length -= skipCount ;
126
121
/* the first message to decode */
127
- loopback_message_print (ndo , cp , len );
122
+ loopback_message_print (ndo , cp , length );
128
123
return ;
129
124
130
125
invalid :
131
126
nd_print_invalid (ndo );
132
- ND_TCHECK_LEN (cp , len );
127
+ ND_TCHECK_LEN (cp , length );
133
128
}
134
129
0 commit comments