This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
laforge gerrit-no-reply at lists.osmocom.orglaforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/simtrace2/+/16196 )
Change subject: merge simtrace2-discovery.[ch] to libusb_util.[ch]
......................................................................
merge simtrace2-discovery.[ch] to libusb_util.[ch]
Change-Id: I4defbec70986a90c1f0cfb7587393265b73c0163
---
M host/include/osmocom/simtrace2/libusb_util.h
M host/lib/libusb_util.c
M host/src/Makefile.am
D host/src/simtrace2-discovery.c
D host/src/simtrace2-discovery.h
M host/src/simtrace2-remsim.c
M host/src/simtrace2-sniff.c
M host/src/usb2udp.c
8 files changed, 48 insertions(+), 129 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/simtrace2 refs/changes/96/16196/1
diff --git a/host/include/osmocom/simtrace2/libusb_util.h b/host/include/osmocom/simtrace2/libusb_util.h
index 2b2d92e..3280b27 100644
--- a/host/include/osmocom/simtrace2/libusb_util.h
+++ b/host/include/osmocom/simtrace2/libusb_util.h
@@ -68,3 +68,6 @@
libusb_device_handle *usb_open_claim_interface(libusb_context *ctx,
const struct usb_interface_match *ifm);
+
+int get_usb_ep_addrs(libusb_device_handle *devh, unsigned int if_num,
+ uint8_t *out, uint8_t *in, uint8_t *irq);
diff --git a/host/lib/libusb_util.c b/host/lib/libusb_util.c
index d88b043..50cd087 100644
--- a/host/lib/libusb_util.c
+++ b/host/lib/libusb_util.c
@@ -295,3 +295,44 @@
return usb_devh;
}
+
+/*! \brief obtain the endpoint addresses for a given USB interface */
+int get_usb_ep_addrs(libusb_device_handle *devh, unsigned int if_num,
+ uint8_t *out, uint8_t *in, uint8_t *irq)
+{
+ libusb_device *dev = libusb_get_device(devh);
+ struct libusb_config_descriptor *cdesc;
+ const struct libusb_interface_descriptor *idesc;
+ const struct libusb_interface *iface;
+ int rc, l;
+
+ rc = libusb_get_active_config_descriptor(dev, &cdesc);
+ if (rc < 0)
+ return rc;
+
+ iface = &cdesc->interface[if_num];
+ /* FIXME: we assume there's no altsetting */
+ idesc = &iface->altsetting[0];
+
+ for (l = 0; l < idesc->bNumEndpoints; l++) {
+ const struct libusb_endpoint_descriptor *edesc = &idesc->endpoint[l];
+ switch (edesc->bmAttributes & 3) {
+ case LIBUSB_TRANSFER_TYPE_BULK:
+ if (edesc->bEndpointAddress & 0x80) {
+ if (in)
+ *in = edesc->bEndpointAddress;
+ } else {
+ if (out)
+ *out = edesc->bEndpointAddress;
+ }
+ break;
+ case LIBUSB_TRANSFER_TYPE_INTERRUPT:
+ if (irq)
+ *irq = edesc->bEndpointAddress;
+ break;
+ default:
+ break;
+ }
+ }
+ return 0;
+}
diff --git a/host/src/Makefile.am b/host/src/Makefile.am
index b0f1f91..29f2405 100644
--- a/host/src/Makefile.am
+++ b/host/src/Makefile.am
@@ -5,14 +5,12 @@
LDADD= $(top_builddir)/lib/libosmo-simtrace2.la \
$(LIBOSMOCORE_LIBS) $(LIBOSMOSIM_LIBS) $(LIBUSB_LIBS)
-noinst_HEADERS = simtrace2-discovery.h
-
bin_PROGRAMS = simtrace2-remsim simtrace2-remsim-usb2udp simtrace2-list simtrace2-sniff
-simtrace2_remsim_SOURCES = simtrace2-remsim.c simtrace2-discovery.c
+simtrace2_remsim_SOURCES = simtrace2-remsim.c
-simtrace2_remsim_usb2udp_SOURCES = usb2udp.c simtrace2-discovery.c
+simtrace2_remsim_usb2udp_SOURCES = usb2udp.c
simtrace2_list_SOURCES = simtrace2_usb.c
-simtrace2_sniff_SOURCES = simtrace2-sniff.c simtrace2-discovery.c
+simtrace2_sniff_SOURCES = simtrace2-sniff.c
diff --git a/host/src/simtrace2-discovery.c b/host/src/simtrace2-discovery.c
deleted file mode 100644
index a7306ce..0000000
--- a/host/src/simtrace2-discovery.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* simtrace2-discovery - host PC library to scan for matching USB
- * devices
- *
- * (C) 2016 by Harald Welte <hwelte at hmw-consulting.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#include <stdint.h>
-
-#include <libusb.h>
-
-/*! \brief obtain the endpoint addresses for a given USB interface */
-int get_usb_ep_addrs(libusb_device_handle *devh, unsigned int if_num,
- uint8_t *out, uint8_t *in, uint8_t *irq)
-{
- libusb_device *dev = libusb_get_device(devh);
- struct libusb_config_descriptor *cdesc;
- const struct libusb_interface_descriptor *idesc;
- const struct libusb_interface *iface;
- int rc, l;
-
- rc = libusb_get_active_config_descriptor(dev, &cdesc);
- if (rc < 0)
- return rc;
-
- iface = &cdesc->interface[if_num];
- /* FIXME: we assume there's no altsetting */
- idesc = &iface->altsetting[0];
-
- for (l = 0; l < idesc->bNumEndpoints; l++) {
- const struct libusb_endpoint_descriptor *edesc = &idesc->endpoint[l];
- switch (edesc->bmAttributes & 3) {
- case LIBUSB_TRANSFER_TYPE_BULK:
- if (edesc->bEndpointAddress & 0x80) {
- if (in)
- *in = edesc->bEndpointAddress;
- } else {
- if (out)
- *out = edesc->bEndpointAddress;
- }
- break;
- case LIBUSB_TRANSFER_TYPE_INTERRUPT:
- if (irq)
- *irq = edesc->bEndpointAddress;
- break;
- default:
- break;
- }
- }
- return 0;
-}
-
-#if 0
- struct libusb_device_descriptor ddesc;
- int rc, i, j, k;
-
- rc = libusb_get_device_descriptor(devh, &ddesc);
- if (rc < 0)
- return;
-
- for (i = 0; i < ddesc.bNumConfigurations; i++) {
- struct libusb_config_descriptor *cdesc;
- rc = libusb_get_config_descriptor(devh, i, &cdesc);
- if (rc < 0)
- return;
-
- for (j = 0; j < cdesc->bNumInterfaces; j++) {
- const struct libusb_interface *iface = cdesc->interface[j];
- for (k = 0; k < iface->num_altsetting; k++) {
- const struct libusb_interface_descriptor *idesc = iface->altsetting[k];
- /* make sure this is the interface we're looking for */
- if (idesc->bInterfaceClass != 0xFF ||
- idesc->bInterfaceSubClass != if_class ||
- idsec->bInterfaceProtocol != if_proto)
- continue;
- /* FIXME */
- }
- }
-
- libusb_free_config_descriptor(cdesc);
- }
-#endif
diff --git a/host/src/simtrace2-discovery.h b/host/src/simtrace2-discovery.h
deleted file mode 100644
index cfba956..0000000
--- a/host/src/simtrace2-discovery.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* simtrace2-discovery - host PC library to scan for matching USB
- * devices
- *
- * (C) 2016 by Harald Welte <hwelte at hmw-consulting.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-#pragma once
-
-#include <stdint.h>
-#include <libusb.h>
-
-int get_usb_ep_addrs(libusb_device_handle *devh, unsigned int if_num,
- uint8_t *out, uint8_t *in, uint8_t *irq);
diff --git a/host/src/simtrace2-remsim.c b/host/src/simtrace2-remsim.c
index 5362733..03d11df 100644
--- a/host/src/simtrace2-remsim.c
+++ b/host/src/simtrace2-remsim.c
@@ -44,8 +44,6 @@
#include <osmocom/simtrace2/apdu_dispatch.h>
#include <osmocom/simtrace2/gsmtap.h>
-#include "simtrace2-discovery.h"
-
#include <osmocom/core/utils.h>
#include <osmocom/core/socket.h>
#include <osmocom/core/msgb.h>
diff --git a/host/src/simtrace2-sniff.c b/host/src/simtrace2-sniff.c
index f3c37dc..7e8e5eb 100644
--- a/host/src/simtrace2-sniff.c
+++ b/host/src/simtrace2-sniff.c
@@ -40,7 +40,6 @@
#include <osmocom/simtrace2/libusb_util.h>
#include <osmocom/simtrace2/simtrace_usb.h>
#include <osmocom/simtrace2/simtrace_prot.h>
-#include "simtrace2-discovery.h"
#include <osmocom/simtrace2/gsmtap.h>
diff --git a/host/src/usb2udp.c b/host/src/usb2udp.c
index 9927594..23800fd 100644
--- a/host/src/usb2udp.c
+++ b/host/src/usb2udp.c
@@ -37,7 +37,7 @@
#include <osmocom/simtrace2/simtrace_usb.h>
#include <osmocom/simtrace2/simtrace_prot.h>
-#include "simtrace2-discovery.h"
+#include <osmocom/simtrace2/libusb_util.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/socket.h>
--
To view, visit https://gerrit.osmocom.org/c/simtrace2/+/16196
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: simtrace2
Gerrit-Branch: master
Gerrit-Change-Id: I4defbec70986a90c1f0cfb7587393265b73c0163
Gerrit-Change-Number: 16196
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge at osmocom.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191124/89df4e4b/attachment.htm>