summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-08 16:56:51 -0300
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2008-09-08 17:12:02 -0300
commit75b61c0a4f415fdb6518b9cf99f9b5d4b8072c5f (patch)
tree7b08b513bac9934ee8b3d0c8dde28b12493179f8
parent2cea206bb38dbb573b00b0bf28650b9ccac57578 (diff)
Add -i option to avinfo.
-rw-r--r--tools/avinfo.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/tools/avinfo.c b/tools/avinfo.c
index 76d29c0c..dccf4e7d 100644
--- a/tools/avinfo.c
+++ b/tools/avinfo.c
@@ -607,11 +607,15 @@ static void usage()
{
printf("avinfo - Audio/Video Info Tool ver %s\n", VERSION);
printf("Usage:\n"
- "\tavinfo <remote address>\n");
+ "\tavinfo [options] <remote address>\n");
+ printf("Options:\n"
+ "\t-h\t\tDisplay help\n"
+ "\t-i\t\tSpecify source interface\n");
}
static struct option main_options[] = {
{ "help", 0, 0, 'h' },
+ { "device", 1, 0, 'i' },
{ 0, 0, 0, 0 }
};
@@ -625,8 +629,22 @@ int main(int argc, char *argv[])
exit(0);
}
- while ((opt = getopt_long(argc, argv, "h", main_options, NULL)) != -1) {
+ bacpy(&src, BDADDR_ANY);
+ dev_id = hci_get_route(&src);
+ if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) {
+ printf("Cannot find any local adapter\n");
+ exit(-1);
+ }
+
+ while ((opt = getopt_long(argc, argv, "+i:h", main_options, NULL)) != -1) {
switch (opt) {
+ case 'i':
+ if (!strncmp(optarg, "hci", 3))
+ hci_devba(atoi(optarg + 3), &src);
+ else
+ str2ba(optarg, &src);
+ break;
+
case 'h':
default:
usage();
@@ -634,21 +652,14 @@ int main(int argc, char *argv[])
}
}
- bacpy(&src, BDADDR_ANY);
- dev_id = hci_get_route(&src);
- if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) {
- printf("Cannot find any local adapter\n");
- exit(-1);
- }
-
printf("Connecting ... \n");
- if (bachk(argv[1]) < 0) {
+ if (bachk(argv[optind]) < 0) {
printf("Invalid argument\n");
exit(1);
}
- str2ba(argv[1], &dst);
+ str2ba(argv[optind], &dst);
sk = l2cap_connect(&src, &dst);
if (sk < 0)
exit(1);