Patch #874083: Bluetooth support for socket module.
This commit is contained in:
parent
4d205e366c
commit
12af0485f8
|
@ -177,6 +177,7 @@ Sebastian Fernandez
|
|||
Vincent Fiack
|
||||
Russell Finn
|
||||
Nils Fischbeck
|
||||
Frederik Fix
|
||||
Hernán Martínez Foffani
|
||||
Doug Fort
|
||||
Martin Franklin
|
||||
|
|
|
@ -121,6 +121,9 @@ Core and builtins
|
|||
Extension modules
|
||||
-----------------
|
||||
|
||||
- The socket module now supports Bluetooth sockets, if the
|
||||
system has <bluetooth/bluetooth.h>
|
||||
|
||||
- Added a collections module containing a new datatype, deque(),
|
||||
offering high-performance, thread-safe, memory friendly appends
|
||||
and pops on either side of the deque.
|
||||
|
|
|
@ -1012,6 +1012,68 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args,
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
case AF_BLUETOOTH:
|
||||
{
|
||||
switch( s->sock_proto )
|
||||
{
|
||||
case BTPROTO_L2CAP:
|
||||
{
|
||||
struct sockaddr_l2* addr = (struct sockaddr_l2*) &(s->sock_addr).bt_l2;
|
||||
bdaddr_t* bdaddr = &(addr->l2_bdaddr);
|
||||
|
||||
addr->l2_family = AF_BLUETOOTH;
|
||||
if( !PyArg_ParseTuple(args, "(iiiiii)i", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5], &addr->l2_psm) )
|
||||
{
|
||||
PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addr_ret = (struct sockaddr *) addr;
|
||||
*len_ret = sizeof *addr;
|
||||
return 1;
|
||||
}
|
||||
case BTPROTO_RFCOMM:
|
||||
{
|
||||
struct sockaddr_rc* addr = (struct sockaddr_rc*) &(s->sock_addr).bt_rc;
|
||||
bdaddr_t* bdaddr = &(addr->rc_bdaddr);
|
||||
|
||||
addr->rc_family = AF_BLUETOOTH;
|
||||
if( !PyArg_ParseTuple(args, "(iiiiii)i", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5], &addr->rc_channel) )
|
||||
{
|
||||
PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addr_ret = (struct sockaddr *) addr;
|
||||
*len_ret = sizeof *addr;
|
||||
return 1;
|
||||
}
|
||||
case BTPROTO_SCO:
|
||||
{
|
||||
struct sockaddr_sco* addr = (struct sockaddr_sco*) &(s->sock_addr).bt_sco;
|
||||
bdaddr_t* bdaddr = &(addr->sco_bdaddr);
|
||||
|
||||
addr->sco_family = AF_BLUETOOTH;
|
||||
if( !PyArg_ParseTuple(args, "iiiiii", &bdaddr->b[0], &bdaddr->b[1], &bdaddr->b[2], &bdaddr->b[3], &bdaddr->b[4], &bdaddr->b[5]) )
|
||||
{
|
||||
PyErr_SetString(socket_error, "getsockaddrarg: wrong format");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*addr_ret = (struct sockaddr *) addr;
|
||||
*len_ret = sizeof *addr;
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
PyErr_SetString(socket_error, "getsockaddrarg: unknown Bluetooth protocol");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPACKET_PACKET_H
|
||||
case AF_PACKET:
|
||||
{
|
||||
|
@ -1085,6 +1147,35 @@ getsockaddrlen(PySocketSockObject *s, socklen_t *len_ret)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
case AF_BLUETOOTH:
|
||||
{
|
||||
switch(s->sock_proto)
|
||||
{
|
||||
case BTPROTO_L2CAP:
|
||||
{
|
||||
*len_ret = sizeof (struct sockaddr_l2);
|
||||
return 1;
|
||||
}
|
||||
case BTPROTO_RFCOMM:
|
||||
{
|
||||
*len_ret = sizeof (struct sockaddr_rc);
|
||||
return 1;
|
||||
}
|
||||
case BTPROTO_SCO:
|
||||
{
|
||||
*len_ret = sizeof (struct sockaddr_sco);
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
{
|
||||
PyErr_SetString(socket_error, "getsockaddrlen: unknown BT protocol");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPACKET_PACKET_H
|
||||
case AF_PACKET:
|
||||
{
|
||||
|
@ -3573,6 +3664,16 @@ init_socket(void)
|
|||
/* Amateur Radio X.25 PLP */
|
||||
PyModule_AddIntConstant(m, "AF_ROSE", AF_ROSE);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
PyModule_AddIntConstant(m, "AF_BLUETOOTH", AF_BLUETOOTH);
|
||||
PyModule_AddIntConstant(m, "BTPROTO_L2CAP", BTPROTO_L2CAP);
|
||||
PyModule_AddIntConstant(m, "BTPROTO_SCO", BTPROTO_SCO);
|
||||
PyModule_AddIntConstant(m, "BTPROTO_RFCOMM", BTPROTO_RFCOMM);
|
||||
PyModule_AddObject(m, "BDADDR_ANY", Py_BuildValue( "iiiiii", 0,0,0,0,0,0 ) );
|
||||
PyModule_AddObject(m, "BDADDR_LOCAL", Py_BuildValue( "iiiiii", 0,0,0,0xff,0xff,0xff ) );
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPACKET_PACKET_H
|
||||
PyModule_AddIntConstant(m, "AF_PACKET", AF_PACKET);
|
||||
PyModule_AddIntConstant(m, "PF_PACKET", PF_PACKET);
|
||||
|
|
|
@ -32,6 +32,13 @@
|
|||
# undef AF_UNIX
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/rfcomm.h>
|
||||
#include <bluetooth/l2cap.h>
|
||||
#include <bluetooth/sco.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPACKET_PACKET_H
|
||||
# include <sys/ioctl.h>
|
||||
# include <net/if.h>
|
||||
|
@ -80,6 +87,11 @@ typedef struct {
|
|||
struct sockaddr_in6 in6;
|
||||
struct sockaddr_storage storage;
|
||||
#endif
|
||||
#ifdef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
struct sockaddr_l2 bt_l2;
|
||||
struct sockaddr_rc bt_rc;
|
||||
struct sockaddr_sco bt_sco;
|
||||
#endif
|
||||
#ifdef HAVE_NETPACKET_PACKET_H
|
||||
struct sockaddr_ll ll;
|
||||
#endif
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#! /bin/sh
|
||||
# From configure.in Revision: 1.445 .
|
||||
# From configure.in Revision: 1.447 .
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.57 for python 2.4.
|
||||
#
|
||||
|
@ -3008,7 +3008,7 @@ rm -f conftest*
|
|||
|
||||
# Check for unsupported systems
|
||||
case $ac_sys_system/$ac_sys_release in
|
||||
SunOS/4*|Linux*/1*)
|
||||
Linux*/1*)
|
||||
echo This system \($ac_sys_system/$ac_sys_release\) is no longer supported.
|
||||
echo See README for details.
|
||||
exit 1;;
|
||||
|
@ -4347,6 +4347,7 @@ done
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for ac_header in dlfcn.h fcntl.h grp.h limits.h langinfo.h \
|
||||
|
@ -4356,7 +4357,7 @@ unistd.h utime.h \
|
|||
sys/audioio.h sys/bsdtty.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
|
||||
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
|
||||
sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
|
||||
sys/resource.h netpacket/packet.h sysexits.h
|
||||
sys/resource.h netpacket/packet.h sysexits.h bluetooth/bluetooth.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
|
@ -9362,7 +9363,7 @@ fi
|
|||
echo "$as_me:$LINENO: result: $SO" >&5
|
||||
echo "${ECHO_T}$SO" >&6
|
||||
# LDSHARED is the ld *command* used to create shared library
|
||||
# -- "ld" on SunOS 4.x.x, "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
|
||||
# -- "cc -G" on SunOS 5.x, "ld -shared" on IRIX 5
|
||||
# (Shared libraries in this instance are shared modules to be loaded into
|
||||
# Python, as opposed to building Python itself as a shared library.)
|
||||
echo "$as_me:$LINENO: checking LDSHARED" >&5
|
||||
|
@ -9380,7 +9381,6 @@ then
|
|||
;;
|
||||
IRIX/5*) LDSHARED="ld -shared";;
|
||||
IRIX*/6*) LDSHARED="ld ${SGI_ABI} -shared -all";;
|
||||
SunOS/4*) LDSHARED="ld";;
|
||||
SunOS/5*)
|
||||
if test "$GCC" = "yes"
|
||||
then LDSHARED='$(CC) -shared'
|
||||
|
@ -15518,56 +15518,6 @@ rm -f conftest.$ac_objext conftest.$ac_ext
|
|||
echo "$as_me:$LINENO: result: $works" >&5
|
||||
echo "${ECHO_T}$works" >&6
|
||||
|
||||
if test "$have_prototypes" = yes; then
|
||||
bad_prototypes=no
|
||||
echo "$as_me:$LINENO: checking for bad exec* prototypes" >&5
|
||||
echo $ECHO_N "checking for bad exec* prototypes... $ECHO_C" >&6
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line $LINENO "configure"
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <unistd.h>
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char **t;execve("@",t,t);
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
:
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
|
||||
cat >>confdefs.h <<\_ACEOF
|
||||
#define BAD_EXEC_PROTOTYPES 1
|
||||
_ACEOF
|
||||
|
||||
bad_prototypes=yes
|
||||
|
||||
fi
|
||||
rm -f conftest.$ac_objext conftest.$ac_ext
|
||||
echo "$as_me:$LINENO: result: $bad_prototypes" >&5
|
||||
echo "${ECHO_T}$bad_prototypes" >&6
|
||||
fi
|
||||
|
||||
# check if sockaddr has sa_len member
|
||||
echo "$as_me:$LINENO: checking if sockaddr has sa_len member" >&5
|
||||
echo $ECHO_N "checking if sockaddr has sa_len member... $ECHO_C" >&6
|
||||
|
|
|
@ -918,7 +918,7 @@ unistd.h utime.h \
|
|||
sys/audioio.h sys/bsdtty.h sys/file.h sys/lock.h sys/mkdev.h sys/modem.h \
|
||||
sys/param.h sys/poll.h sys/select.h sys/socket.h sys/time.h sys/times.h \
|
||||
sys/un.h sys/utsname.h sys/wait.h pty.h term.h libutil.h \
|
||||
sys/resource.h netpacket/packet.h sysexits.h)
|
||||
sys/resource.h netpacket/packet.h sysexits.h bluetooth/bluetooth.h)
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_MAJOR
|
||||
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
/* Define this if your time.h defines altzone. */
|
||||
#undef HAVE_ALTZONE
|
||||
|
||||
/* Define to 1 if you have the <bluetooth/bluetooth.h> header file. */
|
||||
#undef HAVE_BLUETOOTH_BLUETOOTH_H
|
||||
|
||||
/* Define if nice() returns success/failure instead of the new priority. */
|
||||
#undef HAVE_BROKEN_NICE
|
||||
|
||||
|
@ -818,16 +821,9 @@
|
|||
/* Define _OSF_SOURCE to get the makedev macro. */
|
||||
#undef _OSF_SOURCE
|
||||
|
||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
||||
this defined. */
|
||||
#undef _POSIX_1_SOURCE
|
||||
|
||||
/* Define to activate features from IEEE Stds 1003.1-2001 */
|
||||
#undef _POSIX_C_SOURCE
|
||||
|
||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
||||
#undef _POSIX_SOURCE
|
||||
|
||||
/* Define if you have POSIX threads, and your system does not define that. */
|
||||
#undef _POSIX_THREADS
|
||||
|
||||
|
|
Loading…
Reference in New Issue