Skip to content

Commit c3e2077

Browse files
committed
LWAPP: Modernize packet parsing style.
The first revision of print-lwapp.c supposedly implemented draft-ohara-capwap-lwapp-04, all subsequent revisions made various code clean-ups only and the differences between the I-D and RFC 5412 seem to be purely editorial. However, the current implementation has substantial discrepancies with the specification. Moreover, several aspects of the specification are plainly not implementable due to various technical issues. The matter is, RFC 5412 was published for posterity rather than implementation: CAPWAP superseded LWAPP before the latter was complete. Before time is good for a more substantial reorganization of tcpdump decoders, clean the LWAPP decoder up once more and make it follow the specification better where practicable. Improve various comments. Define ND_LONGJMP_FROM_TCHECK. In lwapp_transport_header rename version to ver_rid_cfl and rearrange the associated macros for clarity. lwapp_control_print() and lwapp_data_print() each parse an LWAPP transport header in a slightly different way. Move the common code to a new function, lwapp_print(), and make it the only function exported from the decoder. To print the value of "length", the old common code used UDP payload length for ndo_vflag == 0 and LWAPP transport header payload length otherwise; in the new function make it the latter in both cases. Ibid., add diagnostics to flag unexpected fragmentation in the transport header. Ibid., use the transport header C bit instead of UDP ports to tell control and data frames apart. Rename lwapp_message_header to lwapp_msgelem_header to match the data it represents. Add a registry of message elements and specify the minimum length where possible. Implement a new function, permitted_msg_elem(), to tell whether a message element is valid for a message type. Fix lwapp_control_print() to iterate over message elements rather than messages and use the new props to validate and to print control messages a bit better. In lwapp_data_print() remove the mention of AP identity field because the function does not actually implement it. Ibid., do not require the transport payload length to be greater or equal to the transport header length and do not subtract the latter from the former for the hex dump because the former does not include the latter (this recovers the overlooked last 6 bytes of the payload in the output); require the transport payload end and the UDP payload end to be the same. With these changes made lwapp_data_print() becomes equivalent to just print_unknown_data(), so remove the former function. Since these clean-ups affect most of the code, in the same go reindent the entire file in a more sensible way. Update the tests.
1 parent d0f3be9 commit c3e2077

File tree

5 files changed

+747
-316
lines changed

5 files changed

+747
-316
lines changed

netdissect.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,7 @@ extern void lldp_print(netdissect_options *, const u_char *, u_int);
710710
extern void lmp_print(netdissect_options *, const u_char *, u_int);
711711
extern void loopback_print(netdissect_options *, const u_char *, u_int);
712712
extern void lspping_print(netdissect_options *, const u_char *, u_int);
713-
extern void lwapp_control_print(netdissect_options *, const u_char *, u_int, int);
714-
extern void lwapp_data_print(netdissect_options *, const u_char *, u_int);
713+
extern void lwapp_print(netdissect_options *, const u_char *, const u_int, const u_char);
715714
extern void lwres_print(netdissect_options *, const u_char *, u_int);
716715
extern void m3ua_print(netdissect_options *, const u_char *, const u_int);
717716
extern int macsec_print(netdissect_options *, const u_char **, u_int *, u_int *, u_int *, const struct lladdr_info *, const struct lladdr_info *);

0 commit comments

Comments
 (0)