Skip to content

Commit

Permalink
Initial addition of version number for host tools (issue #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominicgs committed Nov 11, 2014
1 parent 77bda32 commit 00b38e6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
29 changes: 28 additions & 1 deletion host/libubertooth/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ include_directories(${LIBUSB_INCLUDE_DIR} ${LIBBTBB_INCLUDE_DIR})
LIST(APPEND LIBUBERTOOTH_LIBS ${LIBUSB_LIBRARIES} ${LIBBTBB_LIBRARIES})

# Conditional libpcap support
find_package(PCAP)
#find_package(PCAP)
if( ${PCAP_FOUND} )
include_directories(${PCAP_INCLUDE_DIRS})
LIST(APPEND LIBUBERTOOTH_LIBS ${PCAP_LIBRARIES})
Expand Down Expand Up @@ -85,3 +85,30 @@ if( ${WIN32} )
COMPONENT headers
)
endif( ${WIN32} )

# Update version.h
# automatic git version when working out of git
execute_process(COMMAND git log --pretty=format:%h -n 1
OUTPUT_VARIABLE GIT_VERSION)

MESSAGE(STATUS "Git version set to ${GIT_VERSION}")

execute_process(COMMAND git status -s --untracked-files=no | grep modified
RESULT_VARIABLE DIRTY)

if( ${DIRTY} EQUAL "0" )
MESSAGE(STATUS "Modifications found since last commit")
set(DIRTY_FLAG "*")
endif( ${DIRTY} EQUAL "0" )


set(VERSION_STRING ${MAJOR_VERSION}.${MINOR_VERSION})
set(RELEASE git-${GIT_VERSION}${DIRTY_FLAG})

CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/version/version.h
@ONLY)


include_directories(${CMAKE_CURRENT_BINARY_DIR}/version/)
4 changes: 4 additions & 0 deletions host/libubertooth/src/ubertooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "ubertooth.h"
#include "ubertooth_control.h"
#include "version.h"

/* this stuff should probably be in a struct managed by the calling program */
static usb_pkt_rx usb_packets[NUM_BANKS];
Expand Down Expand Up @@ -57,6 +58,9 @@ lell_pcap_handle * h_pcap_le = NULL;
btbb_pcapng_handle * h_pcapng_bredr = NULL;
lell_pcapng_handle * h_pcapng_le = NULL;

void print_version() {
printf("libUbertooth version: %s, release: %s\n", VERSION, RELEASE);
}
void stop_transfers(int sig) {
sig = sig; // Unused parameter
stop_ubertooth = 1;
Expand Down
1 change: 1 addition & 0 deletions host/libubertooth/src/ubertooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ typedef struct {
unsigned allowed_access_address_errors;
} btle_options;

void print_version();
struct libusb_device_handle* ubertooth_start(int ubertooth_device);
void ubertooth_stop(struct libusb_device_handle *devh);
int specan(struct libusb_device_handle* devh, int xfer_size, u16 num_blocks,
Expand Down
28 changes: 28 additions & 0 deletions host/libubertooth/src/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2014 Dominic Spill
*
* This file is part of Project Ubertooth.
*
* 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, 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; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/

#ifndef __UBERTOOTH_VERSION_H__
#define __UBERTOOTH_VERSION_H__

#define RELEASE "@RELEASE@"
#define VERSION "@VERSION_STRING@"

#endif /* __UBERTOOTH_VERSION_H__ */
6 changes: 5 additions & 1 deletion host/ubertooth-tools/src/ubertooth-rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ static void usage()
printf("ubertooth-rx - passive Bluetooth discovery/decode\n");
printf("Usage:\n");
printf("\t-h this help\n");
printf("\t-V print version information\n");
printf("\t-i filename\n");
printf("\t-l <LAP> to decode (6 hex), otherwise sniff all LAPs\n");
printf("\t-u <UAP> to decode (2 hex), otherwise try to calculate (requires LAP)\n");
Expand Down Expand Up @@ -69,7 +70,7 @@ int main(int argc, char *argv[])
uint32_t lap = 0;
uint8_t uap = 0;

while ((opt=getopt(argc,argv,"hi:l:u:U:d:e:r:sq:")) != EOF) {
while ((opt=getopt(argc,argv,"hVi:l:u:U:d:e:r:sq:")) != EOF) {
switch(opt) {
case 'i':
infile = fopen(optarg, "r");
Expand Down Expand Up @@ -125,6 +126,9 @@ int main(int argc, char *argv[])
case 's':
++reset_scan;
break;
case 'V':
print_version();
return 0;
case 'h':
default:
usage();
Expand Down

0 comments on commit 00b38e6

Please sign in to comment.