5 # make-usb - Creates a file containing vendor and product ids.
6 # It use the databases at
7 # http://www.linux-usb.org/usb.ids
8 # to create our file epan/dissectors/usb.c
10 # It also uses the values culled out of libgphoto2 using usb-ptp-extract-models.pl
16 MODE_VENDOR_PRODUCT = 1
21 # Grab from linux-usb.org
22 response = urllib.urlopen('http://www.linux-usb.org/usb.ids')
23 lines = response.read().splitlines()
27 vendors_str="static const value_string usb_vendors_vals[] = {\n"
28 products_str="static const value_string usb_products_vals[] = {\n"
34 if line == "# Vendors, devices and interfaces. Please keep sorted.":
35 mode = MODE_VENDOR_PRODUCT
37 elif line == "# List of known device classes, subclasses and protocols":
41 if mode == MODE_VENDOR_PRODUCT:
42 if re.match("^[0-9a-f]{4}", line):
44 vendors[last_vendor] = re.sub("\"", "\\\"", re.sub("\?+", "?", repr(line[4:].strip())[1:-1].replace("\\", "\\\\")))
45 elif re.match("^\t[0-9a-f]{4}", line):
47 product = "%s%s"%(last_vendor, line[:4])
48 products[product] = re.sub("\"", "\\\"", re.sub("\?+", "?", repr(line[4:].strip())[1:-1].replace("\\", "\\\\")))
51 # Grab from libgphoto (indirectly through tools/usb-ptp-extract-models.pl)
52 u = open('tools/usb-ptp-extract-models.txt','r')
53 for line in u.readlines():
55 products[fields[0]]= ' '.join(fields[1:])
58 for v in sorted(vendors):
59 vendors_str += " { 0x%s, \"%s\" },\n"%(v,vendors[v])
61 vendors_str += """ { 0, NULL }\n};
62 value_string_ext ext_usb_vendors_vals = VALUE_STRING_EXT_INIT(usb_vendors_vals);
65 for p in sorted(products):
66 products_str += " { 0x%s, \"%s\" },\n"%(p,products[p])
68 products_str += """ { 0, NULL }\n};
69 value_string_ext ext_usb_products_vals = VALUE_STRING_EXT_INIT(usb_products_vals);
73 * USB vendor id and product ids
74 * This file was generated by running python ./tools/make-usb.py
75 * Don't change it directly.
77 * Copyright 2012, Michal Labedzki for Tieto Corporation
79 * Other values imported from libghoto2/camlibs/ptp2/library.c, music-players.h
81 * Copyright (C) 2001-2005 Mariusz Woloszyn <emsi@ipartners.pl>
82 * Copyright (C) 2003-2013 Marcus Meissner <marcus@jet.franken.de>
83 * Copyright (C) 2005 Hubert Figuiere <hfiguiere@teaser.fr>
84 * Copyright (C) 2009 Axel Waggershauser <awagger@web.de>
85 * Copyright (C) 2005-2007 Richard A. Low <richard@wentnet.com>
86 * Copyright (C) 2005-2012 Linus Walleij <triad@df.lth.se>
87 * Copyright (C) 2007 Ted Bullock
88 * Copyright (C) 2012 Sony Mobile Communications AB
92 * Wireshark - Network traffic analyzer
93 * By Gerald Combs <gerald@wireshark.org>
94 * Copyright 1998 Gerald Combs
96 * This program is free software; you can redistribute it and/or
97 * modify it under the terms of the GNU General Public License
98 * as published by the Free Software Foundation; either version 2
99 * of the License, or (at your option) any later version.
101 * This program is distributed in the hope that it will be useful,
102 * but WITHOUT ANY WARRANTY; without even the implied warranty of
103 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
104 * GNU General Public License for more details.
106 * You should have received a copy of the GNU General Public License
107 * along with this program; if not, write to the Free Software
108 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
112 #include <epan/packet.h>
115 f = open('epan/dissectors/usb.c', 'w')
120 f.write(products_str)