|
From: Anders J. <and...@us...> - 2003-11-05 17:10:45
|
The following file was modified in apps/bluetooth/utils/btconnect:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btcon.c 1.1 1.2=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added bnep for btcon. Pincode shall now work properly. Added usage-page.
The diff of the modified file(s):
--- btcon.c 2003/11/04 10:59:38 1.1
+++ btcon.c 2003/11/05 17:04:33 1.2
@@ -60,21 +60,92 @@
#include "bt_if.h"
#include "bt_misc.h"
=20
-#define DEFAULT_BTDEV "/dev/ttyBT0"
+#define DEFAULT_PROTOCOL "RFCOMM"
+#define DEFAULT_LINE 0 /* /dev/ttyBT0 */
+#define DEFAULT_SRV_CHANNEL 1
+#define DEFAULT_DEST 0x1116 /* NAP */
+#define DEFAULT_SRC 0x1115 /* PANU */
=20
-/*
- * Syntax: btcon [-d <device>] [-p <pincode>] -a <BD> [-S <rfcomm srv ch>]
- * If using 'disable' as pin, authentication is disabled=20
- */
+static int bt_cfd;
+unsigned char *pin =3D "";
+
+static void usage();
+static int connect_rfcomm(unsigned char *bd,=20
+ int srv_channel,=20
+ int line);
+static int connect_bnep(unsigned char *bd,
+ int dest,
+ int src);
+
+static void
+usage()
+{
+ printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM/BNEP>]\n");
+ printf("RFCOMM protocol:\n");
+ printf(" [-s <rfcomm srv channel>]\n");
+ printf(" [-d <device>]\n");
+ printf("BNEP protocol:\n");
+ printf(" [-D <destination service>]\n");
+ printf(" [-S <source service>]\n");
+ printf("Default values:\n");
+ printf(" -P %s\n", DEFAULT_PROTOCOL);
+ printf(" -s %d\n", DEFAULT_SRV_CHANNEL);
+ printf(" -d /dev/ttyBT%d\n", DEFAULT_LINE);
+ printf(" -D 0x%04x\n", DEFAULT_DEST);
+ printf(" -S 0x%04x\n", DEFAULT_SRC);
+}
+
+static int=20
+connect_rfcomm(unsigned char *bd,
+ int srv_channel,
+ int line)
+{=20
+ int con_id;
+=20=20
+ /* Connect RFCOMM session on line */
+ printf("Connecting to %s on line %d\n", bd2str(bd), line);
+
+ /* Some sanity checks */
+ if ((srv_channel <=3D 0) || (srv_channel > 62))=20
+ {
+ fprintf(stderr, "Invalid server channel\n");
+ exit(1);
+ }
+
+ if((line < 0) || (line > 6))
+ {
+ fprintf(stderr, "Invalid device\n");
+ exit(1);
+ }
+
+ con_id =3D CREATE_RFCOMM_ID(line, srv_channel << 1);
+ return bt_connect(bt_cfd, bd, con_id, pin, strlen(pin));
+}
+
+static int
+connect_bnep(unsigned char *bd,
+ int dest,
+ int src)
+{
+ printf("Connecting with BNEP using source UUID 0x%04x and dest UUIS 0x%0=
4x\n",
+ src, dest);
+ return bnep_connect(bt_cfd, bd,=20
+ src, dest,
+ pin, strlen(pin));
+}
=20
int
main(int argc, char **argv)
{
- char *btdev =3D DEFAULT_BTDEV;
char *bd_str =3D NULL;
unsigned char bd[6];
- int con_id, opt, i, result;
- int line, bt_cfd, srvch =3D 1;
+ int opt, i, result =3D 0;
+=20=20
+ int line =3D DEFAULT_LINE;
+ int srvch =3D 1;
+ int dstservice =3D DEFAULT_DEST;
+ int srcservice =3D DEFAULT_SRC;
+ unsigned char *protocol =3D DEFAULT_PROTOCOL;=20
=20
/* Print header if called via http */
if (getenv("REQUEST_METHOD") !=3D NULL)
@@ -83,7 +154,7 @@ main(int argc, char **argv)
}
=20
/* now parse options */
- while ((opt =3D getopt(argc, argv, "a:d:r:S:p:")) !=3D -1)
+ while ((opt =3D getopt(argc, argv, "a:d:r:S:p:D:s:S:P:h")) !=3D -1)
{
switch (opt)
{
@@ -117,12 +188,11 @@ main(int argc, char **argv)
{
bd[i] =3D (unsigned char)tmp[i];=20
}
- printf("Connecting to bd: %2x:%2x:%2x:%2x:%2x:%2x\n",
- bd[0], bd[1], bd[2], bd[3], bd[4], bd[5]);
}
else
{
- printf("Invalid syntax: %s\n", bd_str);
+ fprintf(stderr, "Invalid syntax: %s\n", bd_str);
+ usage();
exit(1);
}
}
@@ -130,19 +200,74 @@ main(int argc, char **argv)
=20=20=20=20=20=20=20
case 'd':
/* BT device */
- btdev =3D optarg;
- printf("btdev %s\n", btdev);
+ if(sscanf(optarg, "/dev/ttyBT%d", &line) !=3D 1)
+ {
+ fprintf(stderr, "Invalid device %s\n", optarg);
+ exit(1);
+ }
break;
=20=20=20=20=20=20=20
- case 'p':
- /* If using 'disable' as pin, authentication is disabled */
- printf("Using pin code: %s\n", optarg);
- set_pin_code(optarg);
+ case 's':
+ srvch =3D atoi(optarg);
break;
=20
case 'S':
- srvch =3D atoi(optarg);
- printf("Using rfcomm server ch: %d\n", srvch);
+ if(sscanf(optarg, "0x%x", &srcservice) =3D=3D 1)
+ {
+ }
+ else if(!strcmp(optarg, "PANU"))
+ {
+ srcservice =3D 0x1115;
+ }
+ else if(!strcmp(optarg, "NAP"))
+ {
+ srcservice =3D 0x1116;
+ }
+ else if(!strcmp(optarg, "GN"))
+ {
+ srcservice =3D 0x1117;
+ }
+ else
+ {
+ fprintf(stderr, "Invalid source service for BNEP\n");
+ exit(1);
+ }
+ break;
+
+ case 'D':
+ if(sscanf(optarg, "0x%x", &dstservice) =3D=3D 1)
+ {
+ }
+ else if(!strcmp(optarg, "PANU"))
+ {
+ dstservice =3D 0x1115;
+ }
+ else if(!strcmp(optarg, "NAP"))
+ {
+ dstservice =3D 0x1116;
+ }
+ else if(!strcmp(optarg, "GN"))
+ {
+ dstservice =3D 0x1117;
+ }
+ else
+ {
+ fprintf(stderr, "Invalid source service for BNEP\n");
+ exit(1);
+ }
+ break;
+=20=20=20=20=20=20
+ case 'p':
+ pin =3D optarg;
+ break;
+
+ case 'h':
+ usage();
+ exit(0);
+ break;
+=20=20=20=20=20=20
+ case 'P':
+ protocol =3D optarg;
break;
=20=20=20=20=20=20=20
default:
@@ -152,8 +277,8 @@ main(int argc, char **argv)
=20
if (optind < argc || !bd_str)
{=20=20=20=20
- printf("Wrong syntax or missing parameters\n");
- printf("Syntax: %s [-d <device>] [-p <pincode>] -a <BD> [-S <rfcomm sr=
v ch>]\n", argv[0]);
+ fprintf(stderr, "Wrong syntax or missing parameters\n");
+ usage();
exit(1);
}
=20
@@ -167,27 +292,23 @@ main(int argc, char **argv)
/* First of all check that stack is running */
if (!bt_isinitiated(bt_cfd))
{
- printf("Stack not initiated, exit\n");
+ fprintf(stderr, "Stack not initiated, exit\n");
exit(1);
}
=20
- line =3D atoi((char*)(btdev+10));
-=20=20
- /* Connect RFCOMM session on line */
-=20
- printf("Connecting to %s on line %d\n", bd2str(bd), line);
-
- /* Some sanity checks */
- if ((srvch <=3D 0) || (srvch > 62) || (line < 0) || (line > 6))
+ if(!strcmp(protocol, "RFCOMM"))
{
- printf("Invalid parameters, srvch [1-62] , line [0-6]\n");
- exit(1);
+ result =3D connect_rfcomm(bd, srvch, line);
+ }
+ else if(!strcmp(protocol, "BNEP"))
+ {
+ result =3D connect_bnep(bd, dstservice, srcservice);
+ }
+ else
+ {
+ fprintf(stderr, "Unknown protocol, exit\n");
+ usage();
}
-
- con_id =3D CREATE_RFCOMM_ID(line, srvch << 1);
-
- result =3D bt_connect(bt_cfd, bd, con_id);
-=20
close(bt_cfd);
exit(result);
}
|
|
From: Anders J. <and...@us...> - 2003-11-05 21:28:55
|
The following file was modified in apps/bluetooth/utils/btconnect:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btcon.c 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Replaced BD parsing with library function.
The diff of the modified file(s):
--- btcon.c 2003/11/05 17:04:33 1.2
+++ btcon.c 2003/11/05 19:05:42 1.3
@@ -139,7 +139,7 @@ main(int argc, char **argv)
{
char *bd_str =3D NULL;
unsigned char bd[6];
- int opt, i, result =3D 0;
+ int opt, result =3D 0;
=20=20=20
int line =3D DEFAULT_LINE;
int srvch =3D 1;
@@ -160,38 +160,10 @@ main(int argc, char **argv)
{
case 'a':
{
- int tmp[6], all_read =3D 0;
bd_str =3D optarg;
- if (sscanf(optarg, "%2x%2x%2x%2x%2x%2x",
- &tmp[0], &tmp[1], &tmp[2],
- &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
- {=20=20
- all_read =3D 1;
- }
- else if (sscanf(optarg, "%x:%x:%x:%x:%x:%x",
- &tmp[0], &tmp[1], &tmp[2],
- &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
- {=20=20
- all_read =3D 1;
- }
- else if (sscanf(optarg, "%x-%x-%x-%x-%x-%x",
- &tmp[0], &tmp[1], &tmp[2],
- &tmp[3], &tmp[4], &tmp[5]) =3D=3D 6)
- {=20
- all_read =3D 1;
- }
-=20=20=20=20=20=20=20=20
- /* now convert to real bd format if syntax was correct */
- if (all_read)
- {
- for (i =3D 0; i < 6; i++)
- {
- bd[i] =3D (unsigned char)tmp[i];=20
- }
- }
- else
+ if(strtobd(optarg, bd) < 0)
{
- fprintf(stderr, "Invalid syntax: %s\n", bd_str);
+ fprintf(stderr, "Invalid syntax: %s\n", optarg);
usage();
exit(1);
}
|
|
From: Anders J. <and...@us...> - 2003-11-06 19:10:16
|
The following file was modified in apps/bluetooth/utils/btconnect:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btcon.c 1.3 1.4=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Typo
The diff of the modified file(s):
--- btcon.c 2003/11/05 19:05:42 1.3
+++ btcon.c 2003/11/06 19:10:13 1.4
@@ -127,7 +127,7 @@ connect_bnep(unsigned char *bd,
int dest,
int src)
{
- printf("Connecting with BNEP using source UUID 0x%04x and dest UUIS 0x%0=
4x\n",
+ printf("Connecting with BNEP using source UUID 0x%04x and dest UUID 0x%0=
4x\n",
src, dest);
return bnep_connect(bt_cfd, bd,=20
src, dest,
|
|
From: Anders J. <and...@us...> - 2004-01-09 15:31:11
|
The following file was modified in apps/bluetooth/utils/btconnect:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btcon.c 1.4 1.5=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added SDP.
The diff of the modified file(s):
--- btcon.c 2003/11/06 19:10:13 1.4
+++ btcon.c 2004/01/09 15:31:10 1.5
@@ -80,13 +80,15 @@ static int connect_bnep(unsigned char *b
static void
usage()
{
- printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM/BNEP>]\n");
+ printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM|BNEP|SDP>]\n");
printf("RFCOMM protocol:\n");
printf(" [-s <rfcomm srv channel>]\n");
printf(" [-d <device>]\n");
printf("BNEP protocol:\n");
printf(" [-D <destination service>]\n");
printf(" [-S <source service>]\n");
+ printf("SDP protocol:\n");
+ printf(" No options needed\n");
printf("Default values:\n");
printf(" -P %s\n", DEFAULT_PROTOCOL);
printf(" -s %d\n", DEFAULT_SRV_CHANNEL);
@@ -134,6 +136,15 @@ connect_bnep(unsigned char *bd,
pin, strlen(pin));
}
=20
+static int=20
+connect_sdp(unsigned char *bd)
+{
+ printf("Connecting with SDP\n");
+ return sdp_connect(bt_cfd, bd,
+ pin, strlen(pin));
+}
+
+
int
main(int argc, char **argv)
{
@@ -275,6 +286,10 @@ main(int argc, char **argv)
else if(!strcmp(protocol, "BNEP"))
{
result =3D connect_bnep(bd, dstservice, srcservice);
+ }
+ else if(!strcmp(protocol, "SDP"))
+ {
+ result =3D connect_sdp(bd);
}
else
{
|
|
From: Anders J. <and...@us...> - 2004-01-31 02:46:44
|
The following file was modified in apps/bluetooth/utils/btconnect:
Name Old version New version Tag Comment
---- ----------- ----------- --- -------
btcon.c 1.5 1.6=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Added option to do authentication/encryption.
Added option BB to connect baseband.
The diff of the modified file(s):
--- btcon.c 2004/01/09 15:31:10 1.5
+++ btcon.c 2004/01/30 12:00:04 1.6
@@ -80,7 +80,7 @@ static int connect_bnep(unsigned char *b
static void
usage()
{
- printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM|BNEP|SDP>]\n");
+ printf("btcon -a <BD> [-p <pincode>] [-P <protocol RFCOMM|BNEP|SDP|BB>] =
[-A]\n");
printf("RFCOMM protocol:\n");
printf(" [-s <rfcomm srv channel>]\n");
printf(" [-d <device>]\n");
@@ -89,6 +89,11 @@ usage()
printf(" [-S <source service>]\n");
printf("SDP protocol:\n");
printf(" No options needed\n");
+ printf("BB (Baseband):\n");
+ printf(" No options needed\n");
+ printf("The -A flag:\n");
+ printf(" Set this flag to authenticate and encrypt a link, shall on=
ly be\n");
+ printf(" used with -a. The pin must have been set with a previous B=
B connect\n");
printf("Default values:\n");
printf(" -P %s\n", DEFAULT_PROTOCOL);
printf(" -s %d\n", DEFAULT_SRV_CHANNEL);
@@ -144,6 +149,13 @@ connect_sdp(unsigned char *bd)
pin, strlen(pin));
}
=20
+static int=20
+connect_bb(unsigned char *bd)
+{
+ printf("Connecting baseband\n");
+ return bb_connect(bt_cfd, bd,
+ pin, strlen(pin));
+}
=20
int
main(int argc, char **argv)
@@ -157,6 +169,7 @@ main(int argc, char **argv)
int dstservice =3D DEFAULT_DEST;
int srcservice =3D DEFAULT_SRC;
unsigned char *protocol =3D DEFAULT_PROTOCOL;=20
+ int doauthentication =3D 0;
=20
/* Print header if called via http */
if (getenv("REQUEST_METHOD") !=3D NULL)
@@ -165,10 +178,16 @@ main(int argc, char **argv)
}
=20
/* now parse options */
- while ((opt =3D getopt(argc, argv, "a:d:r:S:p:D:s:S:P:h")) !=3D -1)
+ while ((opt =3D getopt(argc, argv, "Aa:d:r:S:p:D:s:S:P:h")) !=3D -1)
{
switch (opt)
{
+ case 'A':
+ {
+ doauthentication++;
+ }
+ break;
+=20=20=20=20=20=20
case 'a':
{
bd_str =3D optarg;
@@ -279,6 +298,12 @@ main(int argc, char **argv)
exit(1);
}
=20
+ if(doauthentication)
+ {
+ result =3D bt_authenticate_encrypt(bt_cfd, bd);
+ }
+ else
+ {
if(!strcmp(protocol, "RFCOMM"))
{
result =3D connect_rfcomm(bd, srvch, line);
@@ -291,11 +316,17 @@ main(int argc, char **argv)
{
result =3D connect_sdp(bd);
}
+ else if(!strcmp(protocol, "BB"))
+ {
+ result =3D connect_bb(bd);
+ }
else
{
fprintf(stderr, "Unknown protocol, exit\n");
usage();
}
+ }
+=20=20
close(bt_cfd);
exit(result);
}
|