FreeBSD Bugzilla – Attachment 213610 Details for
Bug 245769
[PATCH] Bring hccontrol le commands more into line with the other commands
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch to bring le.c more into line with the rest.
hccontrol_le_c_cleanup.diff (text/plain), 8.91 KB, created by
Marc Veldman
on 2020-04-20 17:51:55 UTC
(
hide
)
Description:
Patch to bring le.c more into line with the rest.
Filename:
MIME Type:
Creator:
Marc Veldman
Created:
2020-04-20 17:51:55 UTC
Size:
8.91 KB
patch
obsolete
>Index: sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c >=================================================================== >--- sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c (revision 360121) >+++ sys/netgraph/bluetooth/socket/ng_btsocket_l2cap.c (working copy) >@@ -2911,6 +2911,7 @@ > case 0x24: /* LMP PSU not allowed */ > case 0x25: /* Encryption mode not acceptable */ > case 0x26: /* Unit key used */ >+ case 0x2f: /* Insufficient security */ > return (EACCES); > > case 0x07: /* Memory full */ >@@ -2919,6 +2920,7 @@ > case 0x08: /* Connection timeout */ > case 0x10: /* Host timeout */ > case 0x22: /* LMP response timeout */ >+ case 0x3c: /* Advertising Timeout */ > case 0xee: /* HCI timeout */ > case 0xeeee: /* L2CAP timeout */ > return (ETIMEDOUT); >@@ -2931,6 +2933,9 @@ > return (EEXIST); > > case 0x0c: /* Command disallowed */ >+ case 0x32: /* Role switch pending */ >+ case 0x38: /* Host Busy - Pairing */ >+ case 0x3a: /* Controller Busy */ > return (EBUSY); > > case 0x0d: /* Host rejected due to limited resources */ >@@ -2939,6 +2944,7 @@ > case 0x1b: /* SCO offset rejected */ > case 0x1c: /* SCO interval rejected */ > case 0x1d: /* SCO air mode rejected */ >+ case 0x39: /* Connection Rejected due to No Suitable Channel Found */ > return (ECONNREFUSED); > > case 0x11: /* Unsupported feature or parameter value */ >@@ -2947,10 +2953,17 @@ > case 0x20: /* Unsupported LMP parameter value */ > case 0x27: /* QoS is not supported */ > case 0x29: /* Paring with unit key not supported */ >+ case 0x2e: /* Channel assessment not supported */ >+ case 0x37: /* Secure Simple Pairing Not Supported By Host */ > return (EOPNOTSUPP); > > case 0x12: /* Invalid HCI command parameter */ > case 0x1e: /* Invalid LMP parameters */ >+ case 0x2c: /* QoS unacceptable parameter */ >+ case 0x2d: /* QoS rejected */ >+ case 0x30: /* Parameter out of mandatory range */ >+ case 0x3b: /* Unacceptable Connection Parameters */ >+ case 0x45: /* Packet Too Long */ > return (EINVAL); > > case 0x13: /* Other end terminated connection: User ended connection */ >@@ -2959,6 +2972,7 @@ > return (ECONNRESET); > > case 0x16: /* Connection terminated by local host */ >+ case 0x3d: /* Connection Terminated due to MIC Failure */ > return (ECONNABORTED); > > #if 0 /* XXX not yet */ >@@ -2966,6 +2980,20 @@ > case 0x1f: /* Unspecified error */ > case 0x23: /* LMP error transaction collision */ > case 0x28: /* Instant passed */ >+ case 0x2a: /* Different transaction collision */ >+ case 0x2b: /* Reserved for future use */ >+ case 0x31: /* Reserved for future use */ >+ case 0x33: /* Reserved for future use */ >+ case 0x34: /* Reserved Slot Violation */ >+ case 0x35: /* Role Switch Failed */ >+ case 0x36: /* Extended Inquiry Response Too Large */ >+ case 0x3e: /* Connection Failed to be Established / Synchronization Timeout */ >+ case 0x3f: /* MAC Connection Failed */ >+ case 0x40: /* Coarse Clock Adjustment Rejected but Will Try to Adjust Using Clock Dragging */ >+ case 0x41: /* Type0 Submap Not Defined */ >+ case 0x42: /* Unknown Advertising Identifier */ >+ case 0x43: /* Limit Reached */ >+ case 0x44: /* Operation Cancelled by Host */ > #endif > } > >Index: usr.sbin/bluetooth/hccontrol/le.c >=================================================================== >--- usr.sbin/bluetooth/hccontrol/le.c (revision 360121) >+++ usr.sbin/bluetooth/hccontrol/le.c (working copy) >@@ -66,13 +66,13 @@ > int window; > int adrtype; > int policy; >- int e, n; >+ int n; > > ng_hci_le_set_scan_parameters_cp cp; > ng_hci_le_set_scan_parameters_rp rp; > > if (argc != 5) >- return USAGE; >+ return (USAGE); > > if (strcmp(argv[0], "active") == 0) > type = 1; >@@ -79,7 +79,7 @@ > else if (strcmp(argv[0], "passive") == 0) > type = 0; > else >- return USAGE; >+ return (USAGE); > > interval = (int)(atof(argv[1])/0.625); > interval = (interval < 4)? 4: interval; >@@ -91,7 +91,7 @@ > else if (strcmp(argv[3], "random") == 0) > adrtype = 1; > else >- return USAGE; >+ return (USAGE); > > if (strcmp(argv[4], "all") == 0) > policy = 0; >@@ -98,7 +98,7 @@ > else if (strcmp(argv[4], "whitelist") == 0) > policy = 1; > else >- return USAGE; >+ return (USAGE); > > cp.le_scan_type = type; > cp.le_scan_interval = interval; >@@ -106,11 +106,19 @@ > cp.le_scan_window = window; > cp.scanning_filter_policy = policy; > n = sizeof(rp); >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_SCAN_PARAMETERS), >- (void *)&cp, sizeof(cp), (void *)&rp, &n); >+ (void *)&cp, sizeof(cp), (void *)&rp, &n) == ERROR) >+ return (ERROR); > >- return 0; >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } >+ >+ return (OK); > } > > static int >@@ -118,27 +126,35 @@ > { > ng_hci_le_set_scan_enable_cp cp; > ng_hci_le_set_scan_enable_rp rp; >- int e, n, enable = 0; >+ int n, enable = 0; > > if (argc != 1) >- return USAGE; >+ return (USAGE); > > if (strcmp(argv[0], "enable") == 0) > enable = 1; > else if (strcmp(argv[0], "disable") != 0) >- return USAGE; >+ return (USAGE); > > n = sizeof(rp); > cp.le_scan_enable = enable; > cp.filter_duplicates = 0; >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_SCAN_ENABLE), >- (void *)&cp, sizeof(cp), (void *)&rp, &n); >+ (void *)&cp, sizeof(cp), >+ (void *)&rp, &n) == ERROR) >+ return (ERROR); > >- if (e != 0 || rp.status != 0) >- return ERROR; >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return OK; >+ fprintf(stdout, "LE Scan: %s\n", >+ enable? "Enabled" : "Disabled"); >+ >+ return (OK); > } > > static int >@@ -193,7 +209,7 @@ > done: > *len = curbuf - buf; > >- return OK; >+ return (OK); > } > > static int >@@ -202,7 +218,6 @@ > ng_hci_le_set_scan_response_data_cp cp; > ng_hci_le_set_scan_response_data_rp rp; > int n; >- int e; > int len; > char buf[NG_HCI_ADVERTISING_DATA_SIZE]; > >@@ -212,13 +227,19 @@ > cp.scan_response_data_length = len; > memcpy(cp.scan_response_data, buf, len); > n = sizeof(rp); >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_SCAN_RESPONSE_DATA), >- (void *)&cp, sizeof(cp), (void *)&rp, &n); >+ (void *)&cp, sizeof(cp), >+ (void *)&rp, &n) == ERROR) >+ return (ERROR); > >- printf("SET SCAN RESPONSE %d %d %d\n", e, rp.status, n); >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return OK; >+ return (OK); > } > > static int >@@ -255,7 +276,7 @@ > buffer, sizeof(buffer))); > fprintf(stdout, "\n"); > >- return OK; >+ return (OK); > } > > static int >@@ -286,7 +307,7 @@ > { > ng_hci_le_set_event_mask_cp semc; > ng_hci_le_set_event_mask_rp rp; >- int i, n ,e; >+ int i, n; > > n = sizeof(rp); > >@@ -294,11 +315,18 @@ > semc.event_mask[i] = mask&0xff; > mask >>= 8; > } >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, >+ if(hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, > NG_HCI_OCF_LE_SET_EVENT_MASK), >- (void *)&semc, sizeof(semc), (void *)&rp, &n); >+ (void *)&semc, sizeof(semc), (void *)&rp, &n) == ERROR) >+ return (ERROR); >+ >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return 0; >+ return (OK); > } > > static int >@@ -306,7 +334,7 @@ > { > ng_hci_set_event_mask_cp semc; > ng_hci_set_event_mask_rp rp; >- int i, n, e; >+ int i, n; > > n = sizeof(rp); > >@@ -314,29 +342,48 @@ > semc.event_mask[i] = mask&0xff; > mask >>= 8; > } >- e = hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, >+ if (hci_request(s, NG_HCI_OPCODE(NG_HCI_OGF_HC_BASEBAND, > NG_HCI_OCF_SET_EVENT_MASK), >- (void *)&semc, sizeof(semc), (void *)&rp, &n); >+ (void *)&semc, sizeof(semc), (void *)&rp, &n) == ERROR) >+ return (ERROR); >+ >+ if (rp.status != 0x00) { >+ fprintf(stdout, "Status: %s [%#02x]\n", >+ hci_status2str(rp.status), rp.status); >+ return (FAILED); >+ } > >- return 0; >+ return (OK); > } > > static > int le_enable(int s, int argc, char *argv[]) > { >+ int result; >+ > if (argc != 1) >- return USAGE; >+ return (USAGE); > > if (strcasecmp(argv[0], "enable") == 0) { >- set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT | >+ result = set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT | > NG_HCI_EVENT_MASK_LE); >- set_le_event_mask(s, NG_HCI_LE_EVENT_MASK_ALL); >- } else if (strcasecmp(argv[0], "disable") == 0) >- set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT); >- else >- return USAGE; >- >- return OK; >+ if (result != OK) >+ return result; >+ result = set_le_event_mask(s, NG_HCI_LE_EVENT_MASK_ALL); >+ if (result == OK) { >+ fprintf(stdout, "LE enabled\n"); >+ return (OK); >+ } else >+ return result; >+ } else if (strcasecmp(argv[0], "disable") == 0) { >+ result = set_event_mask(s, NG_HCI_EVENT_MASK_DEFAULT); >+ if (result == OK) { >+ fprintf(stdout, "LE disabled\n"); >+ return (OK); >+ } else >+ return result; >+ } else >+ return (USAGE); > } > > struct hci_command le_commands[] = {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 245769
:
213610
|
213611
|
213800