hcsecd.c (121054) | hcsecd.c (128079) |
---|---|
1/* 2 * hcsecd.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: hcsecd.c,v 1.6 2003/08/18 19:19:55 max Exp $ | 1/* 2 * hcsecd.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: hcsecd.c,v 1.6 2003/08/18 19:19:55 max Exp $ |
29 * $FreeBSD: head/usr.sbin/bluetooth/hcsecd/hcsecd.c 121054 2003-10-12 22:04:24Z emax $ | 29 * $FreeBSD: head/usr.sbin/bluetooth/hcsecd/hcsecd.c 128079 2004-04-09 23:58:53Z emax $ |
30 */ 31 32#include <sys/queue.h> 33#include <bluetooth.h> 34#include <err.h> 35#include <errno.h> 36#include <signal.h> 37#include <stdarg.h> --- 8 unchanged lines hidden (view full) --- 46 47static int process_pin_code_request_event 48 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr); 49static int process_link_key_request_event 50 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr); 51static int send_pin_code_reply 52 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, char const *pin); 53static int send_link_key_reply | 30 */ 31 32#include <sys/queue.h> 33#include <bluetooth.h> 34#include <err.h> 35#include <errno.h> 36#include <signal.h> 37#include <stdarg.h> --- 8 unchanged lines hidden (view full) --- 46 47static int process_pin_code_request_event 48 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr); 49static int process_link_key_request_event 50 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr); 51static int send_pin_code_reply 52 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, char const *pin); 53static int send_link_key_reply |
54 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, u_int8_t *key); | 54 (int sock, struct sockaddr_hci *addr, bdaddr_p bdaddr, uint8_t *key); |
55static int process_link_key_notification_event 56 (int sock, struct sockaddr_hci *addr, ng_hci_link_key_notification_ep *ep); 57static void sighup 58 (int s); 59static void sigint 60 (int s); 61static void usage 62 (void); --- 196 unchanged lines hidden (view full) --- 259 return (send_link_key_reply(sock, addr, bdaddr, NULL)); 260} 261 262/* Send PIN_Code_[Negative]_Reply */ 263static int 264send_pin_code_reply(int sock, struct sockaddr_hci *addr, 265 bdaddr_p bdaddr, char const *pin) 266{ | 55static int process_link_key_notification_event 56 (int sock, struct sockaddr_hci *addr, ng_hci_link_key_notification_ep *ep); 57static void sighup 58 (int s); 59static void sigint 60 (int s); 61static void usage 62 (void); --- 196 unchanged lines hidden (view full) --- 259 return (send_link_key_reply(sock, addr, bdaddr, NULL)); 260} 261 262/* Send PIN_Code_[Negative]_Reply */ 263static int 264send_pin_code_reply(int sock, struct sockaddr_hci *addr, 265 bdaddr_p bdaddr, char const *pin) 266{ |
267 u_int8_t buffer[HCSECD_BUFFER_SIZE]; | 267 uint8_t buffer[HCSECD_BUFFER_SIZE]; |
268 ng_hci_cmd_pkt_t *cmd = NULL; 269 270 memset(buffer, 0, sizeof(buffer)); 271 272 cmd = (ng_hci_cmd_pkt_t *) buffer; 273 cmd->type = NG_HCI_CMD_PKT; 274 275 if (pin != NULL) { --- 40 unchanged lines hidden (view full) --- 316 } 317 318 return (0); 319} 320 321/* Send Link_Key_[Negative]_Reply */ 322static int 323send_link_key_reply(int sock, struct sockaddr_hci *addr, | 268 ng_hci_cmd_pkt_t *cmd = NULL; 269 270 memset(buffer, 0, sizeof(buffer)); 271 272 cmd = (ng_hci_cmd_pkt_t *) buffer; 273 cmd->type = NG_HCI_CMD_PKT; 274 275 if (pin != NULL) { --- 40 unchanged lines hidden (view full) --- 316 } 317 318 return (0); 319} 320 321/* Send Link_Key_[Negative]_Reply */ 322static int 323send_link_key_reply(int sock, struct sockaddr_hci *addr, |
324 bdaddr_p bdaddr, u_int8_t *key) | 324 bdaddr_p bdaddr, uint8_t *key) |
325{ | 325{ |
326 u_int8_t buffer[HCSECD_BUFFER_SIZE]; | 326 uint8_t buffer[HCSECD_BUFFER_SIZE]; |
327 ng_hci_cmd_pkt_t *cmd = NULL; 328 329 memset(buffer, 0, sizeof(buffer)); 330 331 cmd = (ng_hci_cmd_pkt_t *) buffer; 332 cmd->type = NG_HCI_CMD_PKT; 333 334 if (key != NULL) { --- 60 unchanged lines hidden (view full) --- 395 396 syslog(LOG_DEBUG, "Updating link key for the entry, " \ 397 "remote bdaddr %s, name '%s', link key %s", 398 bt_ntoa(&key->bdaddr, NULL), 399 (key->name != NULL)? key->name : "No name", 400 (key->key != NULL)? "exists" : "doesn't exist"); 401 402 if (key->key == NULL) { | 327 ng_hci_cmd_pkt_t *cmd = NULL; 328 329 memset(buffer, 0, sizeof(buffer)); 330 331 cmd = (ng_hci_cmd_pkt_t *) buffer; 332 cmd->type = NG_HCI_CMD_PKT; 333 334 if (key != NULL) { --- 60 unchanged lines hidden (view full) --- 395 396 syslog(LOG_DEBUG, "Updating link key for the entry, " \ 397 "remote bdaddr %s, name '%s', link key %s", 398 bt_ntoa(&key->bdaddr, NULL), 399 (key->name != NULL)? key->name : "No name", 400 (key->key != NULL)? "exists" : "doesn't exist"); 401 402 if (key->key == NULL) { |
403 key->key = (u_int8_t *) malloc(NG_HCI_KEY_SIZE); | 403 key->key = (uint8_t *) malloc(NG_HCI_KEY_SIZE); |
404 if (key->key == NULL) { 405 syslog(LOG_ERR, "Could not allocate link key"); 406 exit(1); 407 } 408 } 409 410 memcpy(key->key, &ep->key, NG_HCI_KEY_SIZE); 411 --- 35 unchanged lines hidden --- | 404 if (key->key == NULL) { 405 syslog(LOG_ERR, "Could not allocate link key"); 406 exit(1); 407 } 408 } 409 410 memcpy(key->key, &ep->key, NG_HCI_KEY_SIZE); 411 --- 35 unchanged lines hidden --- |