vfs: check userland buffers before reading them.
[haiku.git] / src / servers / bluetooth / HCITransportAccessor.cpp
blob2353d4e346c4adc29ffd98fd52e55df3185c6018
1 /*
2 * Copyright 2007-2008 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
7 #include <String.h>
9 #include "BluetoothServer.h"
10 #include "HCITransportAccessor.h"
13 HCITransportAccessor::HCITransportAccessor(BPath* path) : HCIDelegate(path)
15 status_t status;
17 fDescriptor = open (path->Path(), O_RDWR);
18 if (fDescriptor > 0) {
19 // find out which ID was assigned
20 status = ioctl(fDescriptor, GET_HCI_ID, &fIdentifier, 0);
21 printf("%s: hid retrieved %" B_PRIx32 " status=%" B_PRId32 "\n",
22 __FUNCTION__, fIdentifier, status);
23 } else {
24 printf("%s: Device driver %s could not be opened %" B_PRId32 "\n",
25 __FUNCTION__, path->Path(), fIdentifier);
26 fIdentifier = B_ERROR;
32 HCITransportAccessor::~HCITransportAccessor()
34 if (fDescriptor > 0)
36 close(fDescriptor);
37 fDescriptor = -1;
38 fIdentifier = B_ERROR;
43 status_t
44 HCITransportAccessor::IssueCommand(raw_command rc, size_t size)
46 if (Id() < 0 || fDescriptor < 0)
47 return B_ERROR;
49 printf("### Command going: len = %ld\n", size);
50 for (uint16 index = 0 ; index < size; index++ ) {
51 printf("%x:",((uint8*)rc)[index]);
53 printf("### \n");
56 return ioctl(fDescriptor, ISSUE_BT_COMMAND, rc, size);
60 status_t
61 HCITransportAccessor::Launch() {
63 uint32 dummy;
64 return ioctl(fDescriptor, BT_UP, &dummy, sizeof(uint32));