Skip to contentSkip to conversation

PAND Network

Bluez-users Delgado, Monica (ERZIA) 1 participant 1 message Oct 23, 2006 1 message not in the archive Bluetooth drivers

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Marcel,

Quoted 19 lines
Quoted 7 lines

I have tried to find where the error "file exists" arises debugging the source code, and I have found it in this function of bnep.c when trying to
send the ioctl command "bnepconnadd":

static int bnep_connadd(int sk, uint16_t role, char *dev)

Quoted 11 lines
{
	struct bnep_connadd_req req;

	strcpy(req.device, dev);
	req.sock = sk;
	req.role = role;
	if (ioctl(ctl, bnepconnadd, &req))
		return -1;
	strcpy(dev, req.device);
	return 0;
} 
Quoted 2 lines

please check the getsockname() and getpeername() output for sk in that call.

I have checked the local address and the remote address of the socket "sk"
in the bnep_connadd function with getsockname() and getpeername() and they are correct in both bnep connections. The local address is in the first connection is 00:10:60:B3:5A:C9 and 00:07:80:80:4B:04 in the second one, and the remote address is in both connections 00:80:5A:20:EA:13.

I have been looking for the error "file exists" more deeply and I think I have finally found it in the file ../linux-2.6.11/net/bluetooth/bnep/core.c , in the function bnep_add_connection, which is used to create the bnep module:

int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)

{
	struct net_device *dev;
	struct bnep_session *s, *ss;
	u8 dst[ETH_ALEN], src[ETH_ALEN];
	int err;

	BT_DBG("");

	baswap((void *) dst, &bt_sk(sock->sk)->dst);
	baswap((void *) src, &bt_sk(sock->sk)->src);

	/* session struct allocated as private part of net_device */
	dev = alloc_netdev(sizeof(struct bnep_session),
			   (*req->device) ? req->device : "bnep%d",
			   bnep_net_setup);
	if (!dev) 
		return ENOMEM;


	down_write(&bnep_session_sem);

	ss = __bnep_get_session(dst);
	if (ss && ss->state == BT_CONNECTED) {
		err = -EEXIST;
		goto failed;
	}

(............more source code...)

	failed:
	up_write(&bnep_session_sem);
	free_netdev(dev);
	return err;
}

As I can see, when trying to create a bnep connection, in this function the destination address of the socket is used to discover if there is another bnep session established with that destination address, and if that session is in the state BT_CONNECTED, it exits with the error EEXIST ("file exists"). I don't know if this is the way it should work or this is a bug in the source code, but according to this, it's not possible to establish two bnep connections from the same PC to the same destination address. Please Marcel, could you confirm me if I'm right?

Thank you and best regards,

Monica

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users