aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-usb.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-08-08 14:51:38 +0200
committerAnders Broman <a.broman58@gmail.com>2017-06-12 06:34:16 +0000
commit6b09377285919333910810bcb0480f9413c5f452 (patch)
tree3b086ec093042db1b1de0a6918dd065c3683c027 /epan/dissectors/packet-usb.c
parente815bbb2e6946e210cd15b1d9c2d280332352c4e (diff)
Extract errno value_strings from usb code
The convention of returning negative errno codes from the Linux kernel is not just limited to usb/usbip, it is also needed by netlink. Now netlink error codes are properly dissected. Also add ERFKILL and EHWPOISON (since 2009 and 2011) and change ESTALE and ENOSYS to match the current description as of Linux 4.7. Fixed header paths in comments too. Used this command to generate the table (with fixups for gaps): cpp -dM -CC include/uapi/asm-generic/errno.h | perl -ne '/^#define (E[A-Z0-9]+) ([0-9]+) \/\* (.+) \*\// && printf " { -%-4s \"%s (-%s)\" },\n", "$2,", $3, $1' | sort -k2 Change-Id: I16fa41a42bd4201a8383ea8e70a0aa8a597b311d Reviewed-on: https://code.wireshark.org/review/16952 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-usb.c')
-rw-r--r--epan/dissectors/packet-usb.c149
1 files changed, 5 insertions, 144 deletions
diff --git a/epan/dissectors/packet-usb.c b/epan/dissectors/packet-usb.c
index 942a3528d3..b3498c0fc4 100644
--- a/epan/dissectors/packet-usb.c
+++ b/epan/dissectors/packet-usb.c
@@ -772,6 +772,7 @@ static const value_string usb_endpoint_direction_vals[] = {
extern value_string_ext ext_usb_vendors_vals;
extern value_string_ext ext_usb_products_vals;
extern value_string_ext ext_usb_com_subclass_vals;
+extern value_string_ext linux_negative_errno_vals_ext;
/*
* Standard descriptor types.
@@ -903,146 +904,6 @@ static const value_string usb_wMaxPacketSize_slots_vals[] = {
{0, NULL}
};
-/* Note: sorted in (unsigned) ascending order */
-static const value_string usb_urb_status_vals[] = {
- /* from linux/include/asm-generic/errno.h*/
- { -131, "State not recoverable (-ENOTRECOVERABLE)" },
- { -130, "Owner died (-EOWNERDEAD)" },
- { -129, "Key was rejected by service (-EKEYREJECTED)" },
- { -128, "Key has been revoked (-EKEYREVOKED)" },
- { -127, "Key has expired (-EKEYEXPIRED)" },
- { -126, "Required key not available (-ENOKEY)" },
- { -125, "Operation Canceled (-ECANCELED)" },
- { -124, "Wrong medium type (-EMEDIUMTYPE)" },
- { -123, "No medium found (-ENOMEDIUM)" },
- { -122, "Quota exceeded (-EDQUOT)" },
- { -121, "Remote I/O error (-EREMOTEIO)" },
- { -120, "Is a named type file (-EISNAM)" },
- { -119, "No XENIX semaphores available (-ENAVAIL)" },
- { -118, "Not a XENIX named type file (-ENOTNAM)" },
- { -117, "Structure needs cleaning (-EUCLEAN)" },
- { -116, "Stale NFS file handle (-ESTALE)" },
- { -115, "Operation now in progress (-EINPROGRESS)" },
- { -114, "Operation already in progress (-EALREADY)" },
- { -113, "No route to host (-EHOSTUNREACH)" },
- { -112, "Host is down (-EHOSTDOWN)" },
- { -111, "Connection refused (-ECONNREFUSED)" },
- { -110, "Connection timed out (-ETIMEDOUT)" },
- { -109, "Too many references: cannot splice (-ETOOMANYREFS)" },
- { -108, "Cannot send after transport endpoint shutdown (-ESHUTDOWN)" },
- { -107, "Transport endpoint is not connected (-ENOTCONN)" },
- { -106, "Transport endpoint is already connected (-EISCONN)" },
- { -105, "No buffer space available (-ENOBUFS)" },
- { -104, "Connection reset by peer (-ECONNRESET)" },
- { -103, "Software caused connection abort (-ECONNABORTED)" },
- { -102, "Network dropped connection because of reset (-ENETRESET)" },
- { -101, "Network is unreachable (-ENETUNREACH)" },
- { -100, "Network is down (-ENETDOWN)" },
- { -99, "Cannot assign requested address (-EADDRNOTAVAIL)" },
- { -98, "Address already in use (-EADDRINUSE)" },
- { -97, "Address family not supported by protocol (-EAFNOSUPPORT)" },
- { -96, "Protocol family not supported (-EPFNOSUPPORT)" },
- { -95, "Operation not supported on transport endpoint (-EOPNOTSUPP)" },
- { -94, "Socket type not supported (-ESOCKTNOSUPPORT)" },
- { -93, "Protocol not supported (-EPROTONOSUPPORT)" },
- { -92, "Protocol not available (-ENOPROTOOPT)" },
- { -91, "Protocol wrong type for socket (-EPROTOTYPE)" },
- { -90, "Message too long (-EMSGSIZE)" },
- { -89, "Destination address required (-EDESTADDRREQ)" },
- { -88, "Socket operation on non-socket (-ENOTSOCK)" },
- { -87, "Too many users (-EUSERS)" },
- { -86, "Streams pipe error (-ESTRPIPE)" },
- { -85, "Interrupted system call should be restarted (-ERESTART)" },
- { -84, "Illegal byte sequence (-EILSEQ)" },
- { -83, "Cannot exec a shared library directly (-ELIBEXEC)" },
- { -82, "Attempting to link in too many shared libraries (-ELIBMAX)" },
- { -81, ".lib section in a.out corrupted (-ELIBSCN)" },
- { -80, "Accessing a corrupted shared library (-ELIBBAD)" },
- { -79, "Can not access a needed shared library (-ELIBACC)" },
- { -78, "Remote address changed (-EREMCHG)" },
- { -77, "File descriptor in bad state (-EBADFD)" },
- { -76, "Name not unique on network (-ENOTUNIQ)" },
- { -75, "Value too large for defined data type (-EOVERFLOW)" },
- { -74, "Not a data message (-EBADMSG)" },
- { -73, "RFS specific error (-EDOTDOT)" },
- { -72, "Multihop attempted (-EMULTIHOP)" },
- { -71, "Protocol error (-EPROTO)" },
- { -70, "Communication error on send (-ECOMM)" },
- { -69, "Srmount error (-ESRMNT)" },
- { -68, "Advertise error (-EADV)" },
- { -67, "Link has been severed (-ENOLINK)" },
- { -66, "Object is remote (-EREMOTE)" },
- { -65, "Package not installed (-ENOPKG)" },
- { -64, "Machine is not on the network (-ENONET)" },
- { -63, "Out of streams resources (-ENOSR)" },
- { -62, "Timer expired (-ETIME)" },
- { -61, "No data available (-ENODATA)" },
- { -60, "Device not a stream (-ENOSTR)" },
- { -59, "Bad font file format (-EBFONT)" },
- { -58, "(-58 \?\?\?)" }, /* dummy so that there are no "gaps" */
- { -57, "Invalid slot (-EBADSLT)" },
- { -56, "Invalid request code (-EBADRQC)" },
- { -55, "No anode (-ENOANO)" },
- { -54, "Exchange full (-EXFULL)" },
- { -53, "Invalid request descriptor (-EBADR)" },
- { -52, "Invalid exchange (-EBADE)" },
- { -51, "Level 2 halted (-EL2HLT)" },
- { -50, "No CSI structure available (-ENOCSI)" },
- { -49, "Protocol driver not attached (-EUNATCH)" },
- { -48, "Link number out of range (-ELNRNG)" },
- { -47, "Level 3 reset (-EL3RST)" },
- { -46, "Level 3 halted (-EL3HLT)" },
- { -45, "Level 2 not synchronized (-EL2NSYNC)" },
- { -44, "Channel number out of range (-ECHRNG)" },
- { -43, "Identifier removed (-EIDRM)" },
- { -42, "No message of desired type (-ENOMSG)" },
- { -41, "(-41 \?\?\?)" }, /* dummy so that there are no "gaps" */
- { -40, "Too many symbolic links encountered (-ELOOP)" },
- { -39, "Directory not empty (-ENOTEMPTY)" },
- { -38, "Function not implemented (-ENOSYS)" },
- { -37, "No record locks available (-ENOLCK)" },
- { -36, "File name too long (-ENAMETOOLONG)" },
- { -35, "Resource deadlock would occur (-EDEADLK)" },
- /* from linux/include/asm-generic/errno.h */
- { -34, "Math result not representable (-ERANGE)" },
- { -33, "Math argument out of domain of func (-EDOM)" },
- { -32, "Broken pipe (-EPIPE)" },
- { -31, "Too many links (-EMLINK)" },
- { -30, "Read-only file system (-EROFS)" },
- { -29, "Illegal seek (-ESPIPE)" },
- { -28, "No space left on device (-ENOSPC)" },
- { -27, "File too large (-EFBIG)" },
- { -26, "Text file busy (-ETXTBSY)" },
- { -25, "Not a typewriter (-ENOTTY)" },
- { -24, "Too many open files (-EMFILE)" },
- { -23, "File table overflow (-ENFILE)" },
- { -22, "Invalid argument (-EINVAL)" },
- { -21, "Is a directory (-EISDIR)" },
- { -20, "Not a directory (-ENOTDIR)" },
- { -19, "No such device (-ENODEV)" },
- { -18, "Cross-device link (-EXDEV)" },
- { -17, "File exists (-EEXIST)" },
- { -16, "Device or resource busy (-EBUSY)" },
- { -15, "Block device required (-ENOTBLK)" },
- { -14, "Bad address (-EFAULT)" },
- { -13, "Permission denied (-EACCES)" },
- { -12, "Out of memory (-ENOMEM)" },
- { -11, "Try again (-EAGAIN)" },
- { -10, "No child processes (-ECHILD)" },
- { -9, "Bad file number (-EBADF)" },
- { -8, "Exec format error (-ENOEXEC)" },
- { -7, "Argument list too long (-E2BIG)" },
- { -6, "No such device or address (-ENXIO)" },
- { -5, "I/O error (-EIO)" },
- { -4, "Interrupted system call (-EINTR)" },
- { -3, "No such process (-ESRCH)" },
- { -2, "No such file or directory (-ENOENT)" },
- { -1, "Operation not permitted (-EPERM)" },
- { 0, "Success"},
- { 0, NULL }
-};
-value_string_ext usb_urb_status_vals_ext = VALUE_STRING_EXT_INIT(usb_urb_status_vals);
-
#define USB_CONTROL_STAGE_SETUP 0x00
#define USB_CONTROL_STAGE_DATA 0x01
#define USB_CONTROL_STAGE_STATUS 0x02
@@ -3980,7 +3841,7 @@ dissect_linux_usb_iso_transfer(packet_info *pinfo _U_, proto_tree *urb_tree,
tvb_memcpy(tvb, (guint8 *)&iso_len, offset+8, 4);
iso_desc_ti = proto_tree_add_protocol_format(urb_tree, proto_usb, tvb, offset,
- 16, "USB isodesc %u [%s]", i, val_to_str_ext(iso_status, &usb_urb_status_vals_ext, "Error %d"));
+ 16, "USB isodesc %u [%s]", i, val_to_str_ext(iso_status, &linux_negative_errno_vals_ext, "Error %d"));
if (iso_len > 0)
proto_item_append_text(iso_desc_ti, " (%u bytes)", iso_len);
iso_desc_tree = proto_item_add_subtree(iso_desc_ti, ett_usb_isodesc);
@@ -4048,7 +3909,7 @@ dissect_usbip_iso_transfer(packet_info *pinfo _U_, proto_tree *urb_tree,
iso_status = tvb_get_ntohl(tvb, desc_offset + 12);
iso_desc_ti = proto_tree_add_protocol_format(urb_tree, proto_usb, tvb, desc_offset,
- 16, "USB isodesc %u [%s]", i, val_to_str_ext(iso_status, &usb_urb_status_vals_ext, "Error %d"));
+ 16, "USB isodesc %u [%s]", i, val_to_str_ext(iso_status, &linux_negative_errno_vals_ext, "Error %d"));
iso_desc_tree = proto_item_add_subtree(iso_desc_ti, ett_usb_isodesc);
proto_tree_add_item_ret_uint(iso_desc_tree, hf_usb_iso_off, tvb, desc_offset, 4, ENC_BIG_ENDIAN, &iso_off);
@@ -4929,7 +4790,7 @@ proto_register_usb(void)
{ &hf_usb_urb_status,
{ "URB status", "usb.urb_status",
- FT_INT32, BASE_DEC|BASE_EXT_STRING, &usb_urb_status_vals_ext, 0x0,
+ FT_INT32, BASE_DEC|BASE_EXT_STRING, &linux_negative_errno_vals_ext, 0x0,
NULL, HFILL }},
{ &hf_usb_urb_len,
@@ -5205,7 +5066,7 @@ proto_register_usb(void)
/* fields of struct mon_bin_isodesc from linux/drivers/usb/mon/mon_bin.c */
{ &hf_usb_iso_status, /* host endian byte order */
{ "Status", "usb.iso.iso_status",
- FT_INT32, BASE_DEC|BASE_EXT_STRING, &usb_urb_status_vals_ext, 0x0,
+ FT_INT32, BASE_DEC|BASE_EXT_STRING, &linux_negative_errno_vals_ext, 0x0,
"ISO descriptor status", HFILL }},
{ &hf_usb_iso_off, /* host endian byte order */