ng_btsocket_hci_raw.c (108107) | ng_btsocket_hci_raw.c (109623) |
---|---|
1/* 2 * ng_btsocket_hci_raw.c 3 * 4 * Copyright (c) 2001-2002 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_hci_raw.c,v 1.3 2002/11/12 22:31:39 max Exp $ | 1/* 2 * ng_btsocket_hci_raw.c 3 * 4 * Copyright (c) 2001-2002 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_hci_raw.c,v 1.3 2002/11/12 22:31:39 max Exp $ |
29 * $FreeBSD: head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c 108107 2002-12-19 22:58:27Z bmilekic $ | 29 * $FreeBSD: head/sys/netgraph/bluetooth/socket/ng_btsocket_hci_raw.c 109623 2003-01-21 08:56:16Z alfred $ |
30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/domain.h> 35#include <sys/errno.h> 36#include <sys/filedesc.h> 37#include <sys/ioccom.h> --- 232 unchanged lines hidden (view full) --- 270 */ 271 272static int 273ng_btsocket_hci_raw_node_rcvdata(hook_p hook, item_p item) 274{ 275 struct mbuf *nam = NULL; 276 int error; 277 | 30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/domain.h> 35#include <sys/errno.h> 36#include <sys/filedesc.h> 37#include <sys/ioccom.h> --- 232 unchanged lines hidden (view full) --- 270 */ 271 272static int 273ng_btsocket_hci_raw_node_rcvdata(hook_p hook, item_p item) 274{ 275 struct mbuf *nam = NULL; 276 int error; 277 |
278 MGET(nam, M_DONTWAIT, MT_SONAME); | 278 MGET(nam, M_NOWAIT, MT_SONAME); |
279 if (nam != NULL) { 280 struct sockaddr_hci *sa = mtod(nam, struct sockaddr_hci *); 281 282 nam->m_len = sizeof(struct sockaddr_hci); 283 284 sa->hci_len = sizeof(*sa); 285 sa->hci_family = AF_BLUETOOTH; 286 strncpy(sa->hci_node, NG_PEER_NODE_NAME(hook), --- 56 unchanged lines hidden (view full) --- 343 */ 344 345static int 346ng_btsocket_raw_send_ngmsg(char *path, int cmd, void *arg, int arglen) 347{ 348 struct ng_mesg *msg = NULL; 349 int error = 0; 350 | 279 if (nam != NULL) { 280 struct sockaddr_hci *sa = mtod(nam, struct sockaddr_hci *); 281 282 nam->m_len = sizeof(struct sockaddr_hci); 283 284 sa->hci_len = sizeof(*sa); 285 sa->hci_family = AF_BLUETOOTH; 286 strncpy(sa->hci_node, NG_PEER_NODE_NAME(hook), --- 56 unchanged lines hidden (view full) --- 343 */ 344 345static int 346ng_btsocket_raw_send_ngmsg(char *path, int cmd, void *arg, int arglen) 347{ 348 struct ng_mesg *msg = NULL; 349 int error = 0; 350 |
351 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, cmd, arglen, M_WAITOK); | 351 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, cmd, arglen, 0); |
352 if (msg == NULL) 353 return (ENOMEM); 354 355 if (arg != NULL && arglen > 0) 356 bcopy(arg, msg->data, arglen); 357 358 NG_SEND_MSG_PATH(error, ng_btsocket_hci_raw_node, msg, path, NULL); 359 --- 9 unchanged lines hidden (view full) --- 369 int cmd, void *rsp, int rsplen) 370{ 371 struct ng_mesg *msg = NULL; 372 int error = 0; 373 374 ng_btsocket_hci_raw_get_token(&pcb->token); 375 pcb->msg = NULL; 376 | 352 if (msg == NULL) 353 return (ENOMEM); 354 355 if (arg != NULL && arglen > 0) 356 bcopy(arg, msg->data, arglen); 357 358 NG_SEND_MSG_PATH(error, ng_btsocket_hci_raw_node, msg, path, NULL); 359 --- 9 unchanged lines hidden (view full) --- 369 int cmd, void *rsp, int rsplen) 370{ 371 struct ng_mesg *msg = NULL; 372 int error = 0; 373 374 ng_btsocket_hci_raw_get_token(&pcb->token); 375 pcb->msg = NULL; 376 |
377 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, cmd, 0, M_WAITOK); | 377 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, cmd, 0, 0); |
378 if (msg == NULL) { 379 pcb->token = 0; 380 return (ENOMEM); 381 } 382 msg->header.token = pcb->token; 383 384 NG_SEND_MSG_PATH(error, ng_btsocket_hci_raw_node, msg, path, NULL); 385 if (error != 0) { --- 113 unchanged lines hidden (view full) --- 499 continue; 500 501 /* 502 * Make a copy of the packet, append to the socket's 503 * receive queue and wakeup socket. sbappendaddr() 504 * will check if socket has enough buffer space. 505 */ 506 | 378 if (msg == NULL) { 379 pcb->token = 0; 380 return (ENOMEM); 381 } 382 msg->header.token = pcb->token; 383 384 NG_SEND_MSG_PATH(error, ng_btsocket_hci_raw_node, msg, path, NULL); 385 if (error != 0) { --- 113 unchanged lines hidden (view full) --- 499 continue; 500 501 /* 502 * Make a copy of the packet, append to the socket's 503 * receive queue and wakeup socket. sbappendaddr() 504 * will check if socket has enough buffer space. 505 */ 506 |
507 m = m_dup(m0, M_DONTWAIT); | 507 m = m_dup(m0, M_NOWAIT); |
508 if (m != NULL) { 509 struct mbuf *ctl = NULL; 510 511 ng_btsocket_hci_raw_savctl(pcb, &ctl, m); 512 513 if (sbappendaddr(&pcb->so->so_rcv, 514 (struct sockaddr *) sa, m, ctl)) 515 sorwakeup(pcb->so); --- 222 unchanged lines hidden (view full) --- 738 return (error); 739 740 error = soreserve(so, NG_BTSOCKET_HCI_RAW_SENDSPACE, 741 NG_BTSOCKET_HCI_RAW_RECVSPACE); 742 if (error != 0) 743 return (error); 744 745 MALLOC(pcb, ng_btsocket_hci_raw_pcb_p, sizeof(*pcb), | 508 if (m != NULL) { 509 struct mbuf *ctl = NULL; 510 511 ng_btsocket_hci_raw_savctl(pcb, &ctl, m); 512 513 if (sbappendaddr(&pcb->so->so_rcv, 514 (struct sockaddr *) sa, m, ctl)) 515 sorwakeup(pcb->so); --- 222 unchanged lines hidden (view full) --- 738 return (error); 739 740 error = soreserve(so, NG_BTSOCKET_HCI_RAW_SENDSPACE, 741 NG_BTSOCKET_HCI_RAW_RECVSPACE); 742 if (error != 0) 743 return (error); 744 745 MALLOC(pcb, ng_btsocket_hci_raw_pcb_p, sizeof(*pcb), |
746 M_NETGRAPH_BTSOCKET_HCI_RAW, M_WAITOK | M_ZERO); | 746 M_NETGRAPH_BTSOCKET_HCI_RAW, M_ZERO); |
747 if (pcb == NULL) 748 return (ENOMEM); 749 750 so->so_pcb = (caddr_t) pcb; 751 pcb->so = so; 752 753 /* 754 * Set default socket filter. By default socket only accepts HCI --- 196 unchanged lines hidden (view full) --- 951 error = EINVAL; 952 break; 953 } 954 955 ng_btsocket_hci_raw_get_token(&pcb->token); 956 pcb->msg = NULL; 957 958 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, | 747 if (pcb == NULL) 748 return (ENOMEM); 749 750 so->so_pcb = (caddr_t) pcb; 751 pcb->so = so; 752 753 /* 754 * Set default socket filter. By default socket only accepts HCI --- 196 unchanged lines hidden (view full) --- 951 error = EINVAL; 952 break; 953 } 954 955 ng_btsocket_hci_raw_get_token(&pcb->token); 956 pcb->msg = NULL; 957 958 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, |
959 NGM_HCI_NODE_GET_NEIGHBOR_CACHE, 0, M_WAITOK); | 959 NGM_HCI_NODE_GET_NEIGHBOR_CACHE, 0, 0); |
960 if (msg == NULL) { 961 pcb->token = 0; 962 error = ENOMEM; 963 break; 964 } 965 msg->header.token = pcb->token; 966 967 NG_SEND_MSG_PATH(error,ng_btsocket_hci_raw_node,msg,path,NULL); --- 41 unchanged lines hidden (view full) --- 1009 error = EINVAL; 1010 break; 1011 } 1012 1013 ng_btsocket_hci_raw_get_token(&pcb->token); 1014 pcb->msg = NULL; 1015 1016 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, NGM_HCI_NODE_GET_CON_LIST, | 960 if (msg == NULL) { 961 pcb->token = 0; 962 error = ENOMEM; 963 break; 964 } 965 msg->header.token = pcb->token; 966 967 NG_SEND_MSG_PATH(error,ng_btsocket_hci_raw_node,msg,path,NULL); --- 41 unchanged lines hidden (view full) --- 1009 error = EINVAL; 1010 break; 1011 } 1012 1013 ng_btsocket_hci_raw_get_token(&pcb->token); 1014 pcb->msg = NULL; 1015 1016 NG_MKMESSAGE(msg, NGM_HCI_COOKIE, NGM_HCI_NODE_GET_CON_LIST, |
1017 0, M_WAITOK); | 1017 0, 0); |
1018 if (msg == NULL) { 1019 pcb->token = 0; 1020 error = ENOMEM; 1021 break; 1022 } 1023 msg->header.token = pcb->token; 1024 1025 NG_SEND_MSG_PATH(error,ng_btsocket_hci_raw_node,msg,path,NULL); --- 240 unchanged lines hidden (view full) --- 1266 if (pcb->addr.hci_node[0] == 0) { 1267 error = EDESTADDRREQ; 1268 goto drop; 1269 } 1270 1271 sa = (struct sockaddr *) &pcb->addr; 1272 } 1273 | 1018 if (msg == NULL) { 1019 pcb->token = 0; 1020 error = ENOMEM; 1021 break; 1022 } 1023 msg->header.token = pcb->token; 1024 1025 NG_SEND_MSG_PATH(error,ng_btsocket_hci_raw_node,msg,path,NULL); --- 240 unchanged lines hidden (view full) --- 1266 if (pcb->addr.hci_node[0] == 0) { 1267 error = EDESTADDRREQ; 1268 goto drop; 1269 } 1270 1271 sa = (struct sockaddr *) &pcb->addr; 1272 } 1273 |
1274 MGET(nam, M_TRYWAIT, MT_SONAME); | 1274 MGET(nam, 0, MT_SONAME); |
1275 if (nam == NULL) { 1276 error = ENOBUFS; 1277 goto drop; 1278 } 1279 1280 nam->m_len = sizeof(struct sockaddr_hci); 1281 bcopy(sa,mtod(nam, struct sockaddr_hci *),sizeof(struct sockaddr_hci)); 1282 --- 38 unchanged lines hidden --- | 1275 if (nam == NULL) { 1276 error = ENOBUFS; 1277 goto drop; 1278 } 1279 1280 nam->m_len = sizeof(struct sockaddr_hci); 1281 bcopy(sa,mtod(nam, struct sockaddr_hci *),sizeof(struct sockaddr_hci)); 1282 --- 38 unchanged lines hidden --- |