from Jon Smirl
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 26 Mar 2007 07:58:17 +0000 (07:58 +0000)
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 26 Mar 2007 07:58:17 +0000 (07:58 +0000)
add defines for data direction (which direction in/out is data being transferred for this particylar request/response pair)
and a mask for which bits of the byte contains the type.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@21207 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-usb.c

index 6170c84975903d3998f5f56d25f742150b9b9e1e..4fc7c8f77c0ab59427d22c79f3d033a30649f2af 100644 (file)
@@ -852,17 +852,15 @@ static const value_string setup_request_names_vals[] = {
 };  
 
 
-
-
-
-
-
+#define USB_DIR_OUT                     0               /* to device */
+#define USB_DIR_IN                      0x80            /* to host */
 
 static const true_false_string tfs_bmrequesttype_direction = {
        "Device-to-host",
        "Host-to-device"
 };
 
+#define USB_TYPE_MASK                   (0x03 << 5)
 #define RQT_SETUP_TYPE_STANDARD        0
 #define RQT_SETUP_TYPE_CLASS   1
 #define RQT_SETUP_TYPE_VENDOR  2
@@ -895,7 +893,7 @@ dissect_usb_bmrequesttype(proto_tree *parent_tree, tvbuff_t *tvb, int offset,
        }
 
        bmRequestType = tvb_get_guint8(tvb, offset);
-       *type = (bmRequestType >> 5) & 0x03;
+       *type = (bmRequestType & USB_TYPE_MASK) >>5;
        proto_tree_add_item(tree, hf_usb_bmRequestType_direction, tvb, offset, 1, TRUE);
        proto_tree_add_item(tree, hf_usb_bmRequestType_type, tvb, offset, 1, TRUE);
        proto_tree_add_item(tree, hf_usb_bmRequestType_recipient, tvb, offset, 1, TRUE);
@@ -1352,11 +1350,11 @@ proto_register_usb(void)
     
         { &hf_usb_bmRequestType_direction,
         { "Direction", "usb.bmRequestType.direction", FT_BOOLEAN, 8, 
-          TFS(&tfs_bmrequesttype_direction), 0x80, "", HFILL }},
+          TFS(&tfs_bmrequesttype_direction), USB_DIR_IN, "", HFILL }},
 
         { &hf_usb_bmRequestType_type,
         { "Type", "usb.bmRequestType.type", FT_UINT8, BASE_HEX, 
-          VALS(bmrequesttype_type_vals), 0x60, "", HFILL }},
+          VALS(bmrequesttype_type_vals), USB_TYPE_MASK, "", HFILL }},
 
         { &hf_usb_bmRequestType_recipient,
         { "Recipient", "usb.bmRequestType.recipient", FT_UINT8, BASE_HEX,