ng_btsocket_rfcomm.c (130480) | ng_btsocket_rfcomm.c (130653) |
---|---|
1/* 2 * ng_btsocket_rfcomm.c 3 * 4 * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $Id: ng_btsocket_rfcomm.c,v 1.28 2003/09/14 23:29:06 max Exp $ | 1/* 2 * ng_btsocket_rfcomm.c 3 * 4 * Copyright (c) 2001-2003 Maksim Yevmenkin <m_evmenkin@yahoo.com> 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 12 unchanged lines hidden (view full) --- 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $Id: ng_btsocket_rfcomm.c,v 1.28 2003/09/14 23:29:06 max Exp $ |
29 * $FreeBSD: head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c 130480 2004-06-14 18:16:22Z rwatson $ | 29 * $FreeBSD: head/sys/netgraph/bluetooth/socket/ng_btsocket_rfcomm.c 130653 2004-06-17 22:48:11Z rwatson $ |
30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/bitstring.h> 35#include <sys/domain.h> 36#include <sys/endian.h> 37#include <sys/errno.h> --- 954 unchanged lines hidden (view full) --- 992 993 NG_BT_MBUFQ_DRAIN(&s->outq); 994 if (!LIST_EMPTY(&s->dlcs)) 995 panic("%s: DLC list is not empty\n", __func__); 996 997 /* Close L2CAP socket */ 998 s->l2so->so_upcallarg = NULL; 999 s->l2so->so_upcall = NULL; | 30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/bitstring.h> 35#include <sys/domain.h> 36#include <sys/endian.h> 37#include <sys/errno.h> --- 954 unchanged lines hidden (view full) --- 992 993 NG_BT_MBUFQ_DRAIN(&s->outq); 994 if (!LIST_EMPTY(&s->dlcs)) 995 panic("%s: DLC list is not empty\n", __func__); 996 997 /* Close L2CAP socket */ 998 s->l2so->so_upcallarg = NULL; 999 s->l2so->so_upcall = NULL; |
1000 SOCKBUF_LOCK(&s->l2so->so_rcv); |
|
1000 s->l2so->so_rcv.sb_flags &= ~SB_UPCALL; | 1001 s->l2so->so_rcv.sb_flags &= ~SB_UPCALL; |
1002 SOCKBUF_UNLOCK(&s->l2so->so_rcv); 1003 SOCKBUF_LOCK(&s->l2so->so_snd); |
|
1001 s->l2so->so_snd.sb_flags &= ~SB_UPCALL; | 1004 s->l2so->so_snd.sb_flags &= ~SB_UPCALL; |
1005 SOCKBUF_UNLOCK(&s->l2so->so_snd); |
|
1002 soclose(s->l2so); 1003 1004 mtx_unlock(&s->session_mtx); 1005 1006 mtx_destroy(&s->session_mtx); 1007 bzero(s, sizeof(*s)); 1008 FREE(s, M_NETGRAPH_BTSOCKET_RFCOMM); 1009 } else --- 222 unchanged lines hidden (view full) --- 1232 mtx_init(&s->session_mtx, "btsocks_rfcomm_session_mtx", NULL, 1233 MTX_DEF|MTX_DUPOK); 1234 1235 LIST_INIT(&s->dlcs); 1236 1237 /* Prepare L2CAP socket */ 1238 l2so->so_upcallarg = NULL; 1239 l2so->so_upcall = ng_btsocket_rfcomm_upcall; | 1006 soclose(s->l2so); 1007 1008 mtx_unlock(&s->session_mtx); 1009 1010 mtx_destroy(&s->session_mtx); 1011 bzero(s, sizeof(*s)); 1012 FREE(s, M_NETGRAPH_BTSOCKET_RFCOMM); 1013 } else --- 222 unchanged lines hidden (view full) --- 1236 mtx_init(&s->session_mtx, "btsocks_rfcomm_session_mtx", NULL, 1237 MTX_DEF|MTX_DUPOK); 1238 1239 LIST_INIT(&s->dlcs); 1240 1241 /* Prepare L2CAP socket */ 1242 l2so->so_upcallarg = NULL; 1243 l2so->so_upcall = ng_btsocket_rfcomm_upcall; |
1244 SOCKBUF_LOCK(&l2so->so_rcv); |
|
1240 l2so->so_rcv.sb_flags |= SB_UPCALL; | 1245 l2so->so_rcv.sb_flags |= SB_UPCALL; |
1246 SOCKBUF_UNLOCK(&l2so->so_rcv); 1247 SOCKBUF_LOCK(&l2so->so_snd); |
|
1241 l2so->so_snd.sb_flags |= SB_UPCALL; | 1248 l2so->so_snd.sb_flags |= SB_UPCALL; |
1249 SOCKBUF_UNLOCK(&l2so->so_snd); |
|
1242 l2so->so_state |= SS_NBIO; 1243 s->l2so = l2so; 1244 1245 mtx_lock(&s->session_mtx); 1246 1247 /* 1248 * "src" == NULL and "dst" == NULL means just create session. 1249 * caller must do the rest --- 62 unchanged lines hidden (view full) --- 1312 return (0); 1313 1314bad: 1315 mtx_unlock(&s->session_mtx); 1316 1317 /* Return L2CAP socket back to its original state */ 1318 l2so->so_upcallarg = NULL; 1319 l2so->so_upcall = NULL; | 1250 l2so->so_state |= SS_NBIO; 1251 s->l2so = l2so; 1252 1253 mtx_lock(&s->session_mtx); 1254 1255 /* 1256 * "src" == NULL and "dst" == NULL means just create session. 1257 * caller must do the rest --- 62 unchanged lines hidden (view full) --- 1320 return (0); 1321 1322bad: 1323 mtx_unlock(&s->session_mtx); 1324 1325 /* Return L2CAP socket back to its original state */ 1326 l2so->so_upcallarg = NULL; 1327 l2so->so_upcall = NULL; |
1328 SOCKBUF_LOCK(&l2so->so_rcv); |
|
1320 l2so->so_rcv.sb_flags &= ~SB_UPCALL; | 1329 l2so->so_rcv.sb_flags &= ~SB_UPCALL; |
1330 SOCKBUF_LOCK(&l2so->so_rcv); 1331 SOCKBUF_LOCK(&l2so->so_snd); |
|
1321 l2so->so_snd.sb_flags &= ~SB_UPCALL; | 1332 l2so->so_snd.sb_flags &= ~SB_UPCALL; |
1333 SOCKBUF_LOCK(&l2so->so_snd); |
|
1322 l2so->so_state &= ~SS_NBIO; 1323 1324 mtx_destroy(&s->session_mtx); 1325 bzero(s, sizeof(*s)); 1326 FREE(s, M_NETGRAPH_BTSOCKET_RFCOMM); 1327 1328 return (error); 1329} /* ng_btsocket_rfcomm_session_create */ --- 2257 unchanged lines hidden --- | 1334 l2so->so_state &= ~SS_NBIO; 1335 1336 mtx_destroy(&s->session_mtx); 1337 bzero(s, sizeof(*s)); 1338 FREE(s, M_NETGRAPH_BTSOCKET_RFCOMM); 1339 1340 return (error); 1341} /* ng_btsocket_rfcomm_session_create */ --- 2257 unchanged lines hidden --- |