5656#define MPTCP_SUB_PRIO 0x5
5757#define MPTCP_SUB_FAIL 0x6
5858#define MPTCP_SUB_FCLOSE 0x7
59+ #define MPTCP_SUB_TCPRST 0x8
5960
6061struct mptcp_option {
6162 nd_uint8_t kind ;
@@ -182,6 +183,32 @@ struct mp_prio {
182183
183184#define MP_PRIO_B 0x01
184185
186+ static const struct tok mp_tcprst_flags [] = {
187+ { 0x08 , "U" },
188+ { 0x04 , "V" },
189+ { 0x02 , "W" },
190+ { 0x01 , "T" },
191+ { 0 , NULL }
192+ };
193+
194+ static const struct tok mp_tcprst_reasons [] = {
195+ { 0x06 , "Middlebox interference" },
196+ { 0x05 , "Unacceptable performance" },
197+ { 0x04 , "Too much outstanding data" },
198+ { 0x03 , "Administratively prohibited" },
199+ { 0x02 , "Lack of resources" },
200+ { 0x01 , "MPTCP-specific error" },
201+ { 0x00 , "Unspecified error" },
202+ { 0 , NULL }
203+ };
204+
205+ struct mp_tcprst {
206+ nd_uint8_t kind ;
207+ nd_uint8_t len ;
208+ nd_uint8_t sub_b ;
209+ nd_uint8_t reason ;
210+ };
211+
185212static int
186213dummy_print (netdissect_options * ndo _U_ ,
187214 const u_char * opt _U_ , u_int opt_len _U_ , u_char flags _U_ )
@@ -454,6 +481,23 @@ mp_fast_close_print(netdissect_options *ndo,
454481 return 1 ;
455482}
456483
484+ static int
485+ mp_tcprst_print (netdissect_options * ndo ,
486+ const u_char * opt , u_int opt_len , u_char flags _U_ )
487+ {
488+ const struct mp_tcprst * mpr = (const struct mp_tcprst * )opt ;
489+
490+ if (opt_len != 4 )
491+ return 0 ;
492+
493+ ND_PRINT (" flags [%s]" , bittok2str_nosep (mp_tcprst_flags , "none" ,
494+ GET_U_1 (mpr -> sub_b )));
495+
496+ ND_PRINT (" reason %s" , tok2str (mp_tcprst_reasons , "unknown (0x%02x)" ,
497+ GET_U_1 (mpr -> reason )));
498+ return 1 ;
499+ }
500+
457501static const struct {
458502 const char * name ;
459503 int (* print )(netdissect_options * , const u_char * , u_int , u_char );
@@ -466,6 +510,7 @@ static const struct {
466510 { "prio" , mp_prio_print },
467511 { "fail" , mp_fail_print },
468512 { "fast-close" , mp_fast_close_print },
513+ { "tcprst" , mp_tcprst_print },
469514 { "unknown" , dummy_print },
470515};
471516
@@ -482,7 +527,7 @@ mptcp_print(netdissect_options *ndo,
482527
483528 opt = (const struct mptcp_option * ) cp ;
484529 subtype = MPTCP_OPT_SUBTYPE (GET_U_1 (opt -> sub_etc ));
485- subtype = ND_MIN (subtype , MPTCP_SUB_FCLOSE + 1 );
530+ subtype = ND_MIN (subtype , MPTCP_SUB_TCPRST + 1 );
486531
487532 ND_PRINT (" %u" , len );
488533
0 commit comments