Message ID | 20210617170013.BlueZ.v1.1.If79c3f0720cc893be1770c6853fe2fbe626f2caa@changeid (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Detailed error code | expand |
This is automated email and please do not reply to this email! Dear submitter, Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series: PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=502869 ---Test result--- Test Summary: CheckPatch FAIL 1.22 seconds GitLint PASS 0.42 seconds Prep - Setup ELL PASS 49.88 seconds Build - Prep PASS 0.17 seconds Build - Configure PASS 9.15 seconds Build - Make FAIL 190.37 seconds Make Check FAIL 0.62 seconds Make Distcheck FAIL 174.13 seconds Build w/ext ELL - Configure PASS 8.79 seconds Build w/ext ELL - Make FAIL 174.89 seconds Details ############################## Test: CheckPatch - FAIL Desc: Run checkpatch.pl script with rule in .checkpatch.conf Output: error: BR/EDR and LE connection failure reasons WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #105: FILE: src/error.c:165: + case EISCONN: // Fall through WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #118: FILE: src/error.c:178: + case EPROTONOSUPPORT: // Fall through WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #151: FILE: src/error.c:211: + case EPROTONOSUPPORT: // Fall through WARNING:PREFER_FALLTHROUGH: Prefer 'fallthrough;' over fallthrough comment #154: FILE: src/error.c:214: + case EISCONN: // Fall through - total: 0 errors, 4 warnings, 349 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. "[PATCH] error: BR/EDR and LE connection failure reasons" has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. ############################## Test: GitLint - PASS Desc: Run gitlint with rule in .gitlint ############################## Test: Prep - Setup ELL - PASS Desc: Clone, build, and install ELL ############################## Test: Build - Prep - PASS Desc: Prepare environment for build ############################## Test: Build - Configure - PASS Desc: Configure the BlueZ source tree ############################## Test: Build - Make - FAIL Desc: Build the BlueZ source tree Output: src/error.c: In function ‘btd_error_bredr_conn_from_errno’: src/error.c:164:7: error: ‘EALREADY’ undeclared (first use in this function) 164 | case EALREADY: | ^~~~~~~~ src/error.c:164:7: note: each undeclared identifier is reported only once for each function it appears in src/error.c:165:7: error: ‘EISCONN’ undeclared (first use in this function) 165 | case EISCONN: // Fall through | ^~~~~~~ src/error.c:167:7: error: ‘EHOSTDOWN’ undeclared (first use in this function) 167 | case EHOSTDOWN: | ^~~~~~~~~ src/error.c:169:7: error: ‘ENOPROTOOPT’ undeclared (first use in this function) 169 | case ENOPROTOOPT: | ^~~~~~~~~~~ src/error.c:171:7: error: ‘EIO’ undeclared (first use in this function) 171 | case EIO: | ^~~ src/error.c:173:7: error: ‘EINVAL’ undeclared (first use in this function) 173 | case EINVAL: | ^~~~~~ src/error.c:175:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 175 | case EHOSTUNREACH: | ^~~~~~~~~~~~ src/error.c:177:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 177 | case EOPNOTSUPP: | ^~~~~~~~~~ src/error.c:178:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 178 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ src/error.c:180:7: error: ‘EBADFD’ undeclared (first use in this function) 180 | case EBADFD: | ^~~~~~ src/error.c:182:7: error: ‘ENOMEM’ undeclared (first use in this function) 182 | case ENOMEM: | ^~~~~~ src/error.c:184:7: error: ‘EBUSY’ undeclared (first use in this function) 184 | case EBUSY: | ^~~~~ src/error.c:186:7: error: ‘EMLINK’ undeclared (first use in this function) 186 | case EMLINK: | ^~~~~~ src/error.c:188:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 188 | case ETIMEDOUT: | ^~~~~~~~~ src/error.c:190:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 190 | case ECONNREFUSED: | ^~~~~~~~~~~~ src/error.c:192:7: error: ‘ECONNRESET’ undeclared (first use in this function) 192 | case ECONNRESET: | ^~~~~~~~~~ src/error.c:194:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 194 | case ECONNABORTED: | ^~~~~~~~~~~~ src/error.c:196:7: error: ‘EPROTO’ undeclared (first use in this function) 196 | case EPROTO: | ^~~~~~ src/error.c: In function ‘btd_error_le_conn_from_errno’: src/error.c:206:7: error: ‘EINVAL’ undeclared (first use in this function) 206 | case EINVAL: | ^~~~~~ src/error.c:208:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 208 | case EHOSTUNREACH: | ^~~~~~~~~~~~ src/error.c:210:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 210 | case EOPNOTSUPP: | ^~~~~~~~~~ src/error.c:211:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 211 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ src/error.c:213:7: error: ‘EALREADY’ undeclared (first use in this function) 213 | case EALREADY: | ^~~~~~~~ src/error.c:214:7: error: ‘EISCONN’ undeclared (first use in this function) 214 | case EISCONN: // Fall through | ^~~~~~~ src/error.c:216:7: error: ‘EBADFD’ undeclared (first use in this function) 216 | case EBADFD: | ^~~~~~ src/error.c:218:7: error: ‘ENOMEM’ undeclared (first use in this function) 218 | case ENOMEM: | ^~~~~~ src/error.c:220:7: error: ‘EBUSY’ undeclared (first use in this function) 220 | case EBUSY: | ^~~~~ src/error.c:222:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 222 | case ECONNREFUSED: | ^~~~~~~~~~~~ src/error.c:224:7: error: ‘EIO’ undeclared (first use in this function) 224 | case EIO: | ^~~ src/error.c:226:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 226 | case ETIMEDOUT: | ^~~~~~~~~ src/error.c:228:7: error: ‘EMLINK’ undeclared (first use in this function) 228 | case EMLINK: | ^~~~~~ src/error.c:230:7: error: ‘ECONNRESET’ undeclared (first use in this function) 230 | case ECONNRESET: | ^~~~~~~~~~ src/error.c:232:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 232 | case ECONNABORTED: | ^~~~~~~~~~~~ src/error.c:234:7: error: ‘EPROTO’ undeclared (first use in this function) 234 | case EPROTO: | ^~~~~~ make[1]: *** [Makefile:9301: src/bluetoothd-error.o] Error 1 make: *** [Makefile:4134: all] Error 2 ############################## Test: Make Check - FAIL Desc: Run 'make check' Output: src/error.c: In function ‘btd_error_bredr_conn_from_errno’: src/error.c:164:7: error: ‘EALREADY’ undeclared (first use in this function) 164 | case EALREADY: | ^~~~~~~~ src/error.c:164:7: note: each undeclared identifier is reported only once for each function it appears in src/error.c:165:7: error: ‘EISCONN’ undeclared (first use in this function) 165 | case EISCONN: // Fall through | ^~~~~~~ src/error.c:167:7: error: ‘EHOSTDOWN’ undeclared (first use in this function) 167 | case EHOSTDOWN: | ^~~~~~~~~ src/error.c:169:7: error: ‘ENOPROTOOPT’ undeclared (first use in this function) 169 | case ENOPROTOOPT: | ^~~~~~~~~~~ src/error.c:171:7: error: ‘EIO’ undeclared (first use in this function) 171 | case EIO: | ^~~ src/error.c:173:7: error: ‘EINVAL’ undeclared (first use in this function) 173 | case EINVAL: | ^~~~~~ src/error.c:175:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 175 | case EHOSTUNREACH: | ^~~~~~~~~~~~ src/error.c:177:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 177 | case EOPNOTSUPP: | ^~~~~~~~~~ src/error.c:178:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 178 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ src/error.c:180:7: error: ‘EBADFD’ undeclared (first use in this function) 180 | case EBADFD: | ^~~~~~ src/error.c:182:7: error: ‘ENOMEM’ undeclared (first use in this function) 182 | case ENOMEM: | ^~~~~~ src/error.c:184:7: error: ‘EBUSY’ undeclared (first use in this function) 184 | case EBUSY: | ^~~~~ src/error.c:186:7: error: ‘EMLINK’ undeclared (first use in this function) 186 | case EMLINK: | ^~~~~~ src/error.c:188:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 188 | case ETIMEDOUT: | ^~~~~~~~~ src/error.c:190:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 190 | case ECONNREFUSED: | ^~~~~~~~~~~~ src/error.c:192:7: error: ‘ECONNRESET’ undeclared (first use in this function) 192 | case ECONNRESET: | ^~~~~~~~~~ src/error.c:194:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 194 | case ECONNABORTED: | ^~~~~~~~~~~~ src/error.c:196:7: error: ‘EPROTO’ undeclared (first use in this function) 196 | case EPROTO: | ^~~~~~ src/error.c: In function ‘btd_error_le_conn_from_errno’: src/error.c:206:7: error: ‘EINVAL’ undeclared (first use in this function) 206 | case EINVAL: | ^~~~~~ src/error.c:208:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 208 | case EHOSTUNREACH: | ^~~~~~~~~~~~ src/error.c:210:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 210 | case EOPNOTSUPP: | ^~~~~~~~~~ src/error.c:211:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 211 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ src/error.c:213:7: error: ‘EALREADY’ undeclared (first use in this function) 213 | case EALREADY: | ^~~~~~~~ src/error.c:214:7: error: ‘EISCONN’ undeclared (first use in this function) 214 | case EISCONN: // Fall through | ^~~~~~~ src/error.c:216:7: error: ‘EBADFD’ undeclared (first use in this function) 216 | case EBADFD: | ^~~~~~ src/error.c:218:7: error: ‘ENOMEM’ undeclared (first use in this function) 218 | case ENOMEM: | ^~~~~~ src/error.c:220:7: error: ‘EBUSY’ undeclared (first use in this function) 220 | case EBUSY: | ^~~~~ src/error.c:222:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 222 | case ECONNREFUSED: | ^~~~~~~~~~~~ src/error.c:224:7: error: ‘EIO’ undeclared (first use in this function) 224 | case EIO: | ^~~ src/error.c:226:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 226 | case ETIMEDOUT: | ^~~~~~~~~ src/error.c:228:7: error: ‘EMLINK’ undeclared (first use in this function) 228 | case EMLINK: | ^~~~~~ src/error.c:230:7: error: ‘ECONNRESET’ undeclared (first use in this function) 230 | case ECONNRESET: | ^~~~~~~~~~ src/error.c:232:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 232 | case ECONNABORTED: | ^~~~~~~~~~~~ src/error.c:234:7: error: ‘EPROTO’ undeclared (first use in this function) 234 | case EPROTO: | ^~~~~~ make[1]: *** [Makefile:9301: src/bluetoothd-error.o] Error 1 make: *** [Makefile:10406: check] Error 2 ############################## Test: Make Distcheck - FAIL Desc: Run distcheck to check the distribution Output: ../../src/error.c: In function ‘btd_error_bredr_conn_from_errno’: ../../src/error.c:164:7: error: ‘EALREADY’ undeclared (first use in this function) 164 | case EALREADY: | ^~~~~~~~ ../../src/error.c:164:7: note: each undeclared identifier is reported only once for each function it appears in ../../src/error.c:165:7: error: ‘EISCONN’ undeclared (first use in this function) 165 | case EISCONN: // Fall through | ^~~~~~~ ../../src/error.c:167:7: error: ‘EHOSTDOWN’ undeclared (first use in this function) 167 | case EHOSTDOWN: | ^~~~~~~~~ ../../src/error.c:169:7: error: ‘ENOPROTOOPT’ undeclared (first use in this function) 169 | case ENOPROTOOPT: | ^~~~~~~~~~~ ../../src/error.c:171:7: error: ‘EIO’ undeclared (first use in this function) 171 | case EIO: | ^~~ ../../src/error.c:173:7: error: ‘EINVAL’ undeclared (first use in this function) 173 | case EINVAL: | ^~~~~~ ../../src/error.c:175:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 175 | case EHOSTUNREACH: | ^~~~~~~~~~~~ ../../src/error.c:177:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 177 | case EOPNOTSUPP: | ^~~~~~~~~~ ../../src/error.c:178:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 178 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ ../../src/error.c:180:7: error: ‘EBADFD’ undeclared (first use in this function) 180 | case EBADFD: | ^~~~~~ ../../src/error.c:182:7: error: ‘ENOMEM’ undeclared (first use in this function) 182 | case ENOMEM: | ^~~~~~ ../../src/error.c:184:7: error: ‘EBUSY’ undeclared (first use in this function) 184 | case EBUSY: | ^~~~~ ../../src/error.c:186:7: error: ‘EMLINK’ undeclared (first use in this function) 186 | case EMLINK: | ^~~~~~ ../../src/error.c:188:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 188 | case ETIMEDOUT: | ^~~~~~~~~ ../../src/error.c:190:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 190 | case ECONNREFUSED: | ^~~~~~~~~~~~ ../../src/error.c:192:7: error: ‘ECONNRESET’ undeclared (first use in this function) 192 | case ECONNRESET: | ^~~~~~~~~~ ../../src/error.c:194:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 194 | case ECONNABORTED: | ^~~~~~~~~~~~ ../../src/error.c:196:7: error: ‘EPROTO’ undeclared (first use in this function) 196 | case EPROTO: | ^~~~~~ ../../src/error.c: In function ‘btd_error_le_conn_from_errno’: ../../src/error.c:206:7: error: ‘EINVAL’ undeclared (first use in this function) 206 | case EINVAL: | ^~~~~~ ../../src/error.c:208:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 208 | case EHOSTUNREACH: | ^~~~~~~~~~~~ ../../src/error.c:210:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 210 | case EOPNOTSUPP: | ^~~~~~~~~~ ../../src/error.c:211:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 211 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ ../../src/error.c:213:7: error: ‘EALREADY’ undeclared (first use in this function) 213 | case EALREADY: | ^~~~~~~~ ../../src/error.c:214:7: error: ‘EISCONN’ undeclared (first use in this function) 214 | case EISCONN: // Fall through | ^~~~~~~ ../../src/error.c:216:7: error: ‘EBADFD’ undeclared (first use in this function) 216 | case EBADFD: | ^~~~~~ ../../src/error.c:218:7: error: ‘ENOMEM’ undeclared (first use in this function) 218 | case ENOMEM: | ^~~~~~ ../../src/error.c:220:7: error: ‘EBUSY’ undeclared (first use in this function) 220 | case EBUSY: | ^~~~~ ../../src/error.c:222:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 222 | case ECONNREFUSED: | ^~~~~~~~~~~~ ../../src/error.c:224:7: error: ‘EIO’ undeclared (first use in this function) 224 | case EIO: | ^~~ ../../src/error.c:226:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 226 | case ETIMEDOUT: | ^~~~~~~~~ ../../src/error.c:228:7: error: ‘EMLINK’ undeclared (first use in this function) 228 | case EMLINK: | ^~~~~~ ../../src/error.c:230:7: error: ‘ECONNRESET’ undeclared (first use in this function) 230 | case ECONNRESET: | ^~~~~~~~~~ ../../src/error.c:232:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 232 | case ECONNABORTED: | ^~~~~~~~~~~~ ../../src/error.c:234:7: error: ‘EPROTO’ undeclared (first use in this function) 234 | case EPROTO: | ^~~~~~ make[2]: *** [Makefile:9301: src/bluetoothd-error.o] Error 1 make[1]: *** [Makefile:4134: all] Error 2 make: *** [Makefile:10327: distcheck] Error 1 ############################## Test: Build w/ext ELL - Configure - PASS Desc: Configure BlueZ source with '--enable-external-ell' configuration ############################## Test: Build w/ext ELL - Make - FAIL Desc: Build BlueZ source with '--enable-external-ell' configuration Output: src/error.c: In function ‘btd_error_bredr_conn_from_errno’: src/error.c:164:7: error: ‘EALREADY’ undeclared (first use in this function) 164 | case EALREADY: | ^~~~~~~~ src/error.c:164:7: note: each undeclared identifier is reported only once for each function it appears in src/error.c:165:7: error: ‘EISCONN’ undeclared (first use in this function) 165 | case EISCONN: // Fall through | ^~~~~~~ src/error.c:167:7: error: ‘EHOSTDOWN’ undeclared (first use in this function) 167 | case EHOSTDOWN: | ^~~~~~~~~ src/error.c:169:7: error: ‘ENOPROTOOPT’ undeclared (first use in this function) 169 | case ENOPROTOOPT: | ^~~~~~~~~~~ src/error.c:171:7: error: ‘EIO’ undeclared (first use in this function) 171 | case EIO: | ^~~ src/error.c:173:7: error: ‘EINVAL’ undeclared (first use in this function) 173 | case EINVAL: | ^~~~~~ src/error.c:175:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 175 | case EHOSTUNREACH: | ^~~~~~~~~~~~ src/error.c:177:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 177 | case EOPNOTSUPP: | ^~~~~~~~~~ src/error.c:178:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 178 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ src/error.c:180:7: error: ‘EBADFD’ undeclared (first use in this function) 180 | case EBADFD: | ^~~~~~ src/error.c:182:7: error: ‘ENOMEM’ undeclared (first use in this function) 182 | case ENOMEM: | ^~~~~~ src/error.c:184:7: error: ‘EBUSY’ undeclared (first use in this function) 184 | case EBUSY: | ^~~~~ src/error.c:186:7: error: ‘EMLINK’ undeclared (first use in this function) 186 | case EMLINK: | ^~~~~~ src/error.c:188:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 188 | case ETIMEDOUT: | ^~~~~~~~~ src/error.c:190:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 190 | case ECONNREFUSED: | ^~~~~~~~~~~~ src/error.c:192:7: error: ‘ECONNRESET’ undeclared (first use in this function) 192 | case ECONNRESET: | ^~~~~~~~~~ src/error.c:194:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 194 | case ECONNABORTED: | ^~~~~~~~~~~~ src/error.c:196:7: error: ‘EPROTO’ undeclared (first use in this function) 196 | case EPROTO: | ^~~~~~ src/error.c: In function ‘btd_error_le_conn_from_errno’: src/error.c:206:7: error: ‘EINVAL’ undeclared (first use in this function) 206 | case EINVAL: | ^~~~~~ src/error.c:208:7: error: ‘EHOSTUNREACH’ undeclared (first use in this function) 208 | case EHOSTUNREACH: | ^~~~~~~~~~~~ src/error.c:210:7: error: ‘EOPNOTSUPP’ undeclared (first use in this function) 210 | case EOPNOTSUPP: | ^~~~~~~~~~ src/error.c:211:7: error: ‘EPROTONOSUPPORT’ undeclared (first use in this function) 211 | case EPROTONOSUPPORT: // Fall through | ^~~~~~~~~~~~~~~ src/error.c:213:7: error: ‘EALREADY’ undeclared (first use in this function) 213 | case EALREADY: | ^~~~~~~~ src/error.c:214:7: error: ‘EISCONN’ undeclared (first use in this function) 214 | case EISCONN: // Fall through | ^~~~~~~ src/error.c:216:7: error: ‘EBADFD’ undeclared (first use in this function) 216 | case EBADFD: | ^~~~~~ src/error.c:218:7: error: ‘ENOMEM’ undeclared (first use in this function) 218 | case ENOMEM: | ^~~~~~ src/error.c:220:7: error: ‘EBUSY’ undeclared (first use in this function) 220 | case EBUSY: | ^~~~~ src/error.c:222:7: error: ‘ECONNREFUSED’ undeclared (first use in this function) 222 | case ECONNREFUSED: | ^~~~~~~~~~~~ src/error.c:224:7: error: ‘EIO’ undeclared (first use in this function) 224 | case EIO: | ^~~ src/error.c:226:7: error: ‘ETIMEDOUT’ undeclared (first use in this function) 226 | case ETIMEDOUT: | ^~~~~~~~~ src/error.c:228:7: error: ‘EMLINK’ undeclared (first use in this function) 228 | case EMLINK: | ^~~~~~ src/error.c:230:7: error: ‘ECONNRESET’ undeclared (first use in this function) 230 | case ECONNRESET: | ^~~~~~~~~~ src/error.c:232:7: error: ‘ECONNABORTED’ undeclared (first use in this function) 232 | case ECONNABORTED: | ^~~~~~~~~~~~ src/error.c:234:7: error: ‘EPROTO’ undeclared (first use in this function) 234 | case EPROTO: | ^~~~~~ make[1]: *** [Makefile:9301: src/bluetoothd-error.o] Error 1 make: *** [Makefile:4134: all] Error 2 --- Regards, Linux Bluetooth
Hi Miao, On Thu, Jun 17, 2021 at 8:08 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > The source of Connect() failures can be divided into the following > three. > - bluetoothd's device interface state transition and profile state > transition > - Kernel's L2CAP layer state transition > - Potential HCI error codes returned by the remote device > > Reviewed-by: Alain Michaud <alainm@chromium.org> > Reviewed-by: Howard Chung <howardchung@google.com> > --- > > src/error.c | 124 +++++++++++++++++++++++++++++++++++++ > src/error.h | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 295 insertions(+) > > diff --git a/src/error.c b/src/error.c > index 89517075e..b72e3d764 100644 > --- a/src/error.c > +++ b/src/error.c > @@ -27,6 +27,7 @@ > #include <config.h> > #endif > > +#include <stdio.h> > #include "gdbus/gdbus.h" > > #include "error.h" > @@ -43,6 +44,15 @@ DBusMessage *btd_error_invalid_args_str(DBusMessage *msg, const char *str) > "%s", str); > } > > +DBusMessage *btd_error_invalid_args_err(DBusMessage *msg, uint16_t err) > +{ > + char str[16]; > + > + sprintf(str, "BtdError:0x%04X", err); > + return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", > + "%s", str); > +} > + > DBusMessage *btd_error_busy(DBusMessage *msg) > { > return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress", > @@ -79,12 +89,30 @@ DBusMessage *btd_error_in_progress(DBusMessage *msg) > "In Progress"); > } > > +DBusMessage *btd_error_in_progress_err(DBusMessage *msg, uint16_t err) > +{ > + char str[16]; > + > + sprintf(str, "BtdError:0x%04X", err); > + return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress", "%s", > + str); Was there a problem that you didn't use g_dbus_create_error to convert the error? I mean instead of using %s use BtdError:0x%04X, actually it might be enough to just have the code portion and skip BtdError as that can be assumed implicitly the our error messages would contain error codes. > +} > + > DBusMessage *btd_error_not_available(DBusMessage *msg) > { > return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", > "Operation currently not available"); > } > > +DBusMessage *btd_error_not_available_err(DBusMessage *msg, uint16_t err) > +{ > + char str[16]; > + > + sprintf(str, "BtdError:0x%04X", err); > + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", "%s", > + str); > +} > + > DBusMessage *btd_error_does_not_exist(DBusMessage *msg) > { > return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist", > @@ -121,8 +149,104 @@ DBusMessage *btd_error_not_ready(DBusMessage *msg) > "Resource Not Ready"); > } > > +DBusMessage *btd_error_not_ready_err(DBusMessage *msg, uint16_t err) > +{ > + char str[16]; > + > + sprintf(str, "BtdError:0x%04X", err); > + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady", "%s", str); > +} > + > DBusMessage *btd_error_failed(DBusMessage *msg, const char *str) > { > return g_dbus_create_error(msg, ERROR_INTERFACE > ".Failed", "%s", str); > } > + > +DBusMessage *btd_error_failed_err(DBusMessage *msg, uint16_t err) > +{ > + char str[16]; > + > + sprintf(str, "BtdError:0x%04X", err); > + return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", str); > +} > + > +uint16_t btd_error_bredr_conn_from_errno(int errno_code) > +{ > + switch (-errno_code) { > + case EALREADY: > + case EISCONN: // Fall through > + return BTD_ERR_BREDR_CONN_ALREADY_CONNECTED; > + case EHOSTDOWN: > + return BTD_ERR_BREDR_CONN_PAGE_TIMEOUT; > + case ENOPROTOOPT: > + return BTD_ERR_BREDR_CONN_PROFILE_UNAVAILABLE; > + case EIO: > + return BTD_ERR_BREDR_CONN_CREATE_SOCKET; > + case EINVAL: > + return BTD_ERR_BREDR_CONN_INVALID_ARGUMENTS; > + case EHOSTUNREACH: > + return BTD_ERR_BREDR_CONN_ADAPTER_NOT_POWERED; > + case EOPNOTSUPP: > + case EPROTONOSUPPORT: // Fall through > + return BTD_ERR_BREDR_CONN_NOT_SUPPORTED; > + case EBADFD: > + return BTD_ERR_BREDR_CONN_BAD_SOCKET; > + case ENOMEM: > + return BTD_ERR_BREDR_CONN_MEMORY_ALLOC; > + case EBUSY: > + return BTD_ERR_BREDR_CONN_BUSY; > + case EMLINK: > + return BTD_ERR_BREDR_CONN_SYNC_CONNECT_LIMIT; > + case ETIMEDOUT: > + return BTD_ERR_BREDR_CONN_TIMEOUT; > + case ECONNREFUSED: > + return BTD_ERR_BREDR_CONN_REFUSED; > + case ECONNRESET: > + return BTD_ERR_BREDR_CONN_TERM_BY_REMOTE; > + case ECONNABORTED: > + return BTD_ERR_BREDR_CONN_TERM_BY_LOCAL; > + case EPROTO: > + return BTD_ERR_BREDR_CONN_PROTO_ERROR; > + default: > + return BTD_ERR_BREDR_CONN_UNKNOWN; > + } > +} > + > +uint16_t btd_error_le_conn_from_errno(int errno_code) > +{ > + switch (-errno_code) { > + case EINVAL: > + return BTD_ERR_LE_CONN_INVALID_ARGUMENTS; > + case EHOSTUNREACH: > + return BTD_ERR_LE_CONN_ADAPTER_NOT_POWERED; > + case EOPNOTSUPP: > + case EPROTONOSUPPORT: // Fall through > + return BTD_ERR_LE_CONN_NOT_SUPPORTED; > + case EALREADY: > + case EISCONN: // Fall through > + return BTD_ERR_LE_CONN_ALREADY_CONNECTED; > + case EBADFD: > + return BTD_ERR_LE_CONN_BAD_SOCKET; > + case ENOMEM: > + return BTD_ERR_LE_CONN_MEMORY_ALLOC; > + case EBUSY: > + return BTD_ERR_LE_CONN_BUSY; > + case ECONNREFUSED: > + return BTD_ERR_LE_CONN_REFUSED; > + case EIO: > + return BTD_ERR_LE_CONN_CREATE_SOCKET; > + case ETIMEDOUT: > + return BTD_ERR_LE_CONN_TIMEOUT; > + case EMLINK: > + return BTD_ERR_LE_CONN_SYNC_CONNECT_LIMIT; > + case ECONNRESET: > + return BTD_ERR_LE_CONN_TERM_BY_REMOTE; > + case ECONNABORTED: > + return BTD_ERR_LE_CONN_TERM_BY_LOCAL; > + case EPROTO: > + return BTD_ERR_LE_CONN_PROTO_ERROR; > + default: > + return BTD_ERR_LE_CONN_UNKNOWN; > + } > +} > diff --git a/src/error.h b/src/error.h > index 7c8cad066..f258cc4e7 100644 > --- a/src/error.h > +++ b/src/error.h > @@ -24,22 +24,193 @@ > */ > > #include <dbus/dbus.h> > +#include <stdint.h> > > #define ERROR_INTERFACE "org.bluez.Error" > > +/* BR/EDR connection failure reasons > + * BT_ERR_* should be used as one of the parameters to btd_error_*_err(). > + */ > + > +/* Either the profile is already connected or ACL connection is in > + * place. > + * errno: EALREADY, EISCONN > + */ > +#define BTD_ERR_BREDR_CONN_ALREADY_CONNECTED 0x0001 > +/* Failed due to page timeout. > + * errno: EHOSTDOWN > + */ > +#define BTD_ERR_BREDR_CONN_PAGE_TIMEOUT 0x0002 > +/* Failed to find connectable services or the target service. > + * errno: ENOPROTOOPT > + */ > +#define BTD_ERR_BREDR_CONN_PROFILE_UNAVAILABLE 0x0003 > +/* Failed to complete the SDP search. > + * errno: none > + */ > +#define BTD_ERR_BREDR_CONN_SDP_SEARCH 0x0004 > +/* Failed to create or connect to BT IO socket. This can also indicate > + * hardware failure in the controller. > + * errno: EIO > + */ > +#define BTD_ERR_BREDR_CONN_CREATE_SOCKET 0x0005 > +/* Failed due to invalid arguments. > + * errno: EINVAL > + */ > +#define BTD_ERR_BREDR_CONN_INVALID_ARGUMENTS 0x0006 > +/* Failed due to adapter not powered. > + * errno: EHOSTUNREACH > + */ > +#define BTD_ERR_BREDR_CONN_ADAPTER_NOT_POWERED 0x0007 > +/* Failed due to unsupported state transition of L2CAP channel or other > + * features either by the local host or the remote. > + * errno: EOPNOTSUPP, EPROTONOSUPPORT > + */ > +#define BTD_ERR_BREDR_CONN_NOT_SUPPORTED 0x0008 > +/* Failed due to the socket is in bad state. > + * errno: EBADFD > + */ > +#define BTD_ERR_BREDR_CONN_BAD_SOCKET 0x0009 > +/* Failed to allocate memory in either host stack or controller. > + * errno: ENOMEM > + */ > +#define BTD_ERR_BREDR_CONN_MEMORY_ALLOC 0x000A > +/* Failed due to other ongoing operations, such as pairing, busy L2CAP > + * channel or the operation disallowed by the controller. > + * errno: EBUSY > + */ > +#define BTD_ERR_BREDR_CONN_BUSY 0x000B > +/* Failed due to reaching the synchronous connection limit to a device. > + * errno: EMLINK > + */ > +#define BTD_ERR_BREDR_CONN_SYNC_CONNECT_LIMIT 0x000C > +/* Failed due to connection timeout > + * errno: ETIMEDOUT > + */ > +#define BTD_ERR_BREDR_CONN_TIMEOUT 0x000D > +/* Refused by the remote device due to limited resource, security reason > + * or unacceptable address type. > + * errno: ECONNREFUSED > + */ > +#define BTD_ERR_BREDR_CONN_REFUSED 0x000E > +/* Terminated by the remote device due to limited resource or power > + * off. > + * errno: ECONNRESET > + */ > +#define BTD_ERR_BREDR_CONN_TERM_BY_REMOTE 0x000F > +/* Terminated by the local host. > + * errno: ECONNABORTED > + */ > +#define BTD_ERR_BREDR_CONN_TERM_BY_LOCAL 0x0010 > +/* Failed due to LMP protocol error. > + * errno: EPROTO > + */ > +#define BTD_ERR_BREDR_CONN_PROTO_ERROR 0x0011 > +/* Failed due to cancellation caused by adapter drop, unexpected device drop, > + * or incoming disconnection request before connection request is completed. > + * errno: none > + */ > +#define BTD_ERR_BREDR_CONN_CANCELED 0x0012 > +/* Failed due to unknown reason. > + * errno: ENOSYS > + */ > +#define BTD_ERR_BREDR_CONN_UNKNOWN 0x0013 > + > +/* LE connection failure reasons > + * BT_ERR_* should be used as one of the parameters to btd_error_*_err(). > + */ > + > +/* Failed due to invalid arguments. > + * errno: EINVAL > + */ > +#define BTD_ERR_LE_CONN_INVALID_ARGUMENTS 0x0101 > +/* Failed due to adapter not powered. > + * errno: EHOSTUNREACH > + */ > +#define BTD_ERR_LE_CONN_ADAPTER_NOT_POWERED 0x0102 > +/* Failed due to unsupported state transition of L2CAP channel or other > + * features (e.g. LE features) either by the local host or the remote. > + * errno: EOPNOTSUPP, EPROTONOSUPPORT > + */ > +#define BTD_ERR_LE_CONN_NOT_SUPPORTED 0x0103 > +/* Either the BT IO is already connected or LE link connection in place. > + * errno: EALREADY, EISCONN > + */ > +#define BTD_ERR_LE_CONN_ALREADY_CONNECTED 0x0104 > +/* Failed due to the socket is in bad state. > + * errno: EBADFD > + */ > +#define BTD_ERR_LE_CONN_BAD_SOCKET 0x0105 > +/* Failed to allocate memory in either host stack or controller. > + * errno: ENOMEM > + */ > +#define BTD_ERR_LE_CONN_MEMORY_ALLOC 0x0106 > +/* Failed due to other ongoing operations, such as pairing, connecting, busy > + * L2CAP channel or the operation disallowed by the controller. > + * errno: EBUSY > + */ > +#define BTD_ERR_LE_CONN_BUSY 0x0107 > +/* Failed due to that LE is not enabled or the attempt is refused by the remote > + * device due to limited resource, security reason or unacceptable address type. > + * errno: ECONNREFUSED > + */ > +#define BTD_ERR_LE_CONN_REFUSED 0x0108 > +/* Failed to create or connect to BT IO socket. This can also indicate > + * hardware failure in the controller. > + * errno: EIO > + */ > +#define BTD_ERR_LE_CONN_CREATE_SOCKET 0x0109 > +/* Failed due to connection timeout > + * errno: ETIMEDOUT > + */ > +#define BTD_ERR_LE_CONN_TIMEOUT 0x010A > +/* Failed due to reaching the synchronous connection limit to a device. > + * errno: EMLINK > + */ > +#define BTD_ERR_LE_CONN_SYNC_CONNECT_LIMIT 0x010B > +/* Terminated by the remote device due to limited resource or power > + * off. > + * errno: ECONNRESET > + */ > +#define BTD_ERR_LE_CONN_TERM_BY_REMOTE 0x010C > +/* Terminated by the local host. > + * errno: ECONNABORTED > + */ > +#define BTD_ERR_LE_CONN_TERM_BY_LOCAL 0x010D > +/* Failed due to LL protocol error. > + * errno: EPROTO > + */ > +#define BTD_ERR_LE_CONN_PROTO_ERROR 0x010E > +/* Failed to complete the GATT browsing. > + * errno: none > + */ > +#define BTD_ERR_LE_CONN_GATT_BROWSE 0x010F > +/* Failed due to unknown reason. > + * errno: ENOSYS > + */ > +#define BTD_ERR_LE_CONN_UNKNOWN 0x0110 > + > DBusMessage *btd_error_invalid_args(DBusMessage *msg); > DBusMessage *btd_error_invalid_args_str(DBusMessage *msg, const char *str); > +DBusMessage *btd_error_invalid_args_err(DBusMessage *msg, uint16_t err); > DBusMessage *btd_error_busy(DBusMessage *msg); > DBusMessage *btd_error_already_exists(DBusMessage *msg); > DBusMessage *btd_error_not_supported(DBusMessage *msg); > DBusMessage *btd_error_not_connected(DBusMessage *msg); > DBusMessage *btd_error_already_connected(DBusMessage *msg); > DBusMessage *btd_error_not_available(DBusMessage *msg); > +DBusMessage *btd_error_not_available_err(DBusMessage *msg, uint16_t err); > DBusMessage *btd_error_in_progress(DBusMessage *msg); > +DBusMessage *btd_error_in_progress_err(DBusMessage *msg, uint16_t err); > DBusMessage *btd_error_does_not_exist(DBusMessage *msg); > DBusMessage *btd_error_not_authorized(DBusMessage *msg); > DBusMessage *btd_error_not_permitted(DBusMessage *msg, const char *str); > DBusMessage *btd_error_no_such_adapter(DBusMessage *msg); > DBusMessage *btd_error_agent_not_available(DBusMessage *msg); > DBusMessage *btd_error_not_ready(DBusMessage *msg); > +DBusMessage *btd_error_not_ready_err(DBusMessage *msg, uint16_t err); > DBusMessage *btd_error_failed(DBusMessage *msg, const char *str); > +DBusMessage *btd_error_failed_err(DBusMessage *msg, uint16_t err); > + > +uint16_t btd_error_bredr_conn_from_errno(int errno_code); > +uint16_t btd_error_le_conn_from_errno(int errno_code); > -- > 2.32.0.288.g62a8d224e6-goog >
Hi Luiz, On Fri, Jun 18, 2021 at 11:18 AM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Miao, > > On Thu, Jun 17, 2021 at 8:08 PM Miao-chen Chou <mcchou@chromium.org> wrote: > > > > The source of Connect() failures can be divided into the following > > three. > > - bluetoothd's device interface state transition and profile state > > transition > > - Kernel's L2CAP layer state transition > > - Potential HCI error codes returned by the remote device > > > > Reviewed-by: Alain Michaud <alainm@chromium.org> > > Reviewed-by: Howard Chung <howardchung@google.com> > > --- > > > > src/error.c | 124 +++++++++++++++++++++++++++++++++++++ > > src/error.h | 171 ++++++++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 295 insertions(+) > > > > diff --git a/src/error.c b/src/error.c > > index 89517075e..b72e3d764 100644 > > --- a/src/error.c > > +++ b/src/error.c > > @@ -27,6 +27,7 @@ > > #include <config.h> > > #endif > > > > +#include <stdio.h> > > #include "gdbus/gdbus.h" > > > > #include "error.h" > > @@ -43,6 +44,15 @@ DBusMessage *btd_error_invalid_args_str(DBusMessage *msg, const char *str) > > "%s", str); > > } > > > > +DBusMessage *btd_error_invalid_args_err(DBusMessage *msg, uint16_t err) > > +{ > > + char str[16]; > > + > > + sprintf(str, "BtdError:0x%04X", err); > > + return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", > > + "%s", str); > > +} > > + > > DBusMessage *btd_error_busy(DBusMessage *msg) > > { > > return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress", > > @@ -79,12 +89,30 @@ DBusMessage *btd_error_in_progress(DBusMessage *msg) > > "In Progress"); > > } > > > > +DBusMessage *btd_error_in_progress_err(DBusMessage *msg, uint16_t err) > > +{ > > + char str[16]; > > + > > + sprintf(str, "BtdError:0x%04X", err); > > + return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress", "%s", > > + str); > > Was there a problem that you didn't use g_dbus_create_error to convert > the error? I mean instead of using %s use BtdError:0x%04X, actually it > might be enough to just have the code portion and skip BtdError as > that can be assumed implicitly the our error messages would contain > error codes. I thought about dropping BtdError from the error message, but I ended up with BtdError to make the meaning more explicit. I am happy to drop it if the implicity is fine. > > > +} > > + > > DBusMessage *btd_error_not_available(DBusMessage *msg) > > { > > return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", > > "Operation currently not available"); > > } > > > > +DBusMessage *btd_error_not_available_err(DBusMessage *msg, uint16_t err) > > +{ > > + char str[16]; > > + > > + sprintf(str, "BtdError:0x%04X", err); > > + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", "%s", > > + str); > > +} > > + > > DBusMessage *btd_error_does_not_exist(DBusMessage *msg) > > { > > return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist", > > @@ -121,8 +149,104 @@ DBusMessage *btd_error_not_ready(DBusMessage *msg) > > "Resource Not Ready"); > > } > > > > +DBusMessage *btd_error_not_ready_err(DBusMessage *msg, uint16_t err) > > +{ > > + char str[16]; > > + > > + sprintf(str, "BtdError:0x%04X", err); > > + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady", "%s", str); > > +} > > + > > DBusMessage *btd_error_failed(DBusMessage *msg, const char *str) > > { > > return g_dbus_create_error(msg, ERROR_INTERFACE > > ".Failed", "%s", str); > > } > > + > > +DBusMessage *btd_error_failed_err(DBusMessage *msg, uint16_t err) > > +{ > > + char str[16]; > > + > > + sprintf(str, "BtdError:0x%04X", err); > > + return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", str); > > +} > > + > > +uint16_t btd_error_bredr_conn_from_errno(int errno_code) > > +{ > > + switch (-errno_code) { > > + case EALREADY: > > + case EISCONN: // Fall through > > + return BTD_ERR_BREDR_CONN_ALREADY_CONNECTED; > > + case EHOSTDOWN: > > + return BTD_ERR_BREDR_CONN_PAGE_TIMEOUT; > > + case ENOPROTOOPT: > > + return BTD_ERR_BREDR_CONN_PROFILE_UNAVAILABLE; > > + case EIO: > > + return BTD_ERR_BREDR_CONN_CREATE_SOCKET; > > + case EINVAL: > > + return BTD_ERR_BREDR_CONN_INVALID_ARGUMENTS; > > + case EHOSTUNREACH: > > + return BTD_ERR_BREDR_CONN_ADAPTER_NOT_POWERED; > > + case EOPNOTSUPP: > > + case EPROTONOSUPPORT: // Fall through > > + return BTD_ERR_BREDR_CONN_NOT_SUPPORTED; > > + case EBADFD: > > + return BTD_ERR_BREDR_CONN_BAD_SOCKET; > > + case ENOMEM: > > + return BTD_ERR_BREDR_CONN_MEMORY_ALLOC; > > + case EBUSY: > > + return BTD_ERR_BREDR_CONN_BUSY; > > + case EMLINK: > > + return BTD_ERR_BREDR_CONN_SYNC_CONNECT_LIMIT; > > + case ETIMEDOUT: > > + return BTD_ERR_BREDR_CONN_TIMEOUT; > > + case ECONNREFUSED: > > + return BTD_ERR_BREDR_CONN_REFUSED; > > + case ECONNRESET: > > + return BTD_ERR_BREDR_CONN_TERM_BY_REMOTE; > > + case ECONNABORTED: > > + return BTD_ERR_BREDR_CONN_TERM_BY_LOCAL; > > + case EPROTO: > > + return BTD_ERR_BREDR_CONN_PROTO_ERROR; > > + default: > > + return BTD_ERR_BREDR_CONN_UNKNOWN; > > + } > > +} > > + > > +uint16_t btd_error_le_conn_from_errno(int errno_code) > > +{ > > + switch (-errno_code) { > > + case EINVAL: > > + return BTD_ERR_LE_CONN_INVALID_ARGUMENTS; > > + case EHOSTUNREACH: > > + return BTD_ERR_LE_CONN_ADAPTER_NOT_POWERED; > > + case EOPNOTSUPP: > > + case EPROTONOSUPPORT: // Fall through > > + return BTD_ERR_LE_CONN_NOT_SUPPORTED; > > + case EALREADY: > > + case EISCONN: // Fall through > > + return BTD_ERR_LE_CONN_ALREADY_CONNECTED; > > + case EBADFD: > > + return BTD_ERR_LE_CONN_BAD_SOCKET; > > + case ENOMEM: > > + return BTD_ERR_LE_CONN_MEMORY_ALLOC; > > + case EBUSY: > > + return BTD_ERR_LE_CONN_BUSY; > > + case ECONNREFUSED: > > + return BTD_ERR_LE_CONN_REFUSED; > > + case EIO: > > + return BTD_ERR_LE_CONN_CREATE_SOCKET; > > + case ETIMEDOUT: > > + return BTD_ERR_LE_CONN_TIMEOUT; > > + case EMLINK: > > + return BTD_ERR_LE_CONN_SYNC_CONNECT_LIMIT; > > + case ECONNRESET: > > + return BTD_ERR_LE_CONN_TERM_BY_REMOTE; > > + case ECONNABORTED: > > + return BTD_ERR_LE_CONN_TERM_BY_LOCAL; > > + case EPROTO: > > + return BTD_ERR_LE_CONN_PROTO_ERROR; > > + default: > > + return BTD_ERR_LE_CONN_UNKNOWN; > > + } > > +} > > diff --git a/src/error.h b/src/error.h > > index 7c8cad066..f258cc4e7 100644 > > --- a/src/error.h > > +++ b/src/error.h > > @@ -24,22 +24,193 @@ > > */ > > > > #include <dbus/dbus.h> > > +#include <stdint.h> > > > > #define ERROR_INTERFACE "org.bluez.Error" > > > > +/* BR/EDR connection failure reasons > > + * BT_ERR_* should be used as one of the parameters to btd_error_*_err(). > > + */ > > + > > +/* Either the profile is already connected or ACL connection is in > > + * place. > > + * errno: EALREADY, EISCONN > > + */ > > +#define BTD_ERR_BREDR_CONN_ALREADY_CONNECTED 0x0001 > > +/* Failed due to page timeout. > > + * errno: EHOSTDOWN > > + */ > > +#define BTD_ERR_BREDR_CONN_PAGE_TIMEOUT 0x0002 > > +/* Failed to find connectable services or the target service. > > + * errno: ENOPROTOOPT > > + */ > > +#define BTD_ERR_BREDR_CONN_PROFILE_UNAVAILABLE 0x0003 > > +/* Failed to complete the SDP search. > > + * errno: none > > + */ > > +#define BTD_ERR_BREDR_CONN_SDP_SEARCH 0x0004 > > +/* Failed to create or connect to BT IO socket. This can also indicate > > + * hardware failure in the controller. > > + * errno: EIO > > + */ > > +#define BTD_ERR_BREDR_CONN_CREATE_SOCKET 0x0005 > > +/* Failed due to invalid arguments. > > + * errno: EINVAL > > + */ > > +#define BTD_ERR_BREDR_CONN_INVALID_ARGUMENTS 0x0006 > > +/* Failed due to adapter not powered. > > + * errno: EHOSTUNREACH > > + */ > > +#define BTD_ERR_BREDR_CONN_ADAPTER_NOT_POWERED 0x0007 > > +/* Failed due to unsupported state transition of L2CAP channel or other > > + * features either by the local host or the remote. > > + * errno: EOPNOTSUPP, EPROTONOSUPPORT > > + */ > > +#define BTD_ERR_BREDR_CONN_NOT_SUPPORTED 0x0008 > > +/* Failed due to the socket is in bad state. > > + * errno: EBADFD > > + */ > > +#define BTD_ERR_BREDR_CONN_BAD_SOCKET 0x0009 > > +/* Failed to allocate memory in either host stack or controller. > > + * errno: ENOMEM > > + */ > > +#define BTD_ERR_BREDR_CONN_MEMORY_ALLOC 0x000A > > +/* Failed due to other ongoing operations, such as pairing, busy L2CAP > > + * channel or the operation disallowed by the controller. > > + * errno: EBUSY > > + */ > > +#define BTD_ERR_BREDR_CONN_BUSY 0x000B > > +/* Failed due to reaching the synchronous connection limit to a device. > > + * errno: EMLINK > > + */ > > +#define BTD_ERR_BREDR_CONN_SYNC_CONNECT_LIMIT 0x000C > > +/* Failed due to connection timeout > > + * errno: ETIMEDOUT > > + */ > > +#define BTD_ERR_BREDR_CONN_TIMEOUT 0x000D > > +/* Refused by the remote device due to limited resource, security reason > > + * or unacceptable address type. > > + * errno: ECONNREFUSED > > + */ > > +#define BTD_ERR_BREDR_CONN_REFUSED 0x000E > > +/* Terminated by the remote device due to limited resource or power > > + * off. > > + * errno: ECONNRESET > > + */ > > +#define BTD_ERR_BREDR_CONN_TERM_BY_REMOTE 0x000F > > +/* Terminated by the local host. > > + * errno: ECONNABORTED > > + */ > > +#define BTD_ERR_BREDR_CONN_TERM_BY_LOCAL 0x0010 > > +/* Failed due to LMP protocol error. > > + * errno: EPROTO > > + */ > > +#define BTD_ERR_BREDR_CONN_PROTO_ERROR 0x0011 > > +/* Failed due to cancellation caused by adapter drop, unexpected device drop, > > + * or incoming disconnection request before connection request is completed. > > + * errno: none > > + */ > > +#define BTD_ERR_BREDR_CONN_CANCELED 0x0012 > > +/* Failed due to unknown reason. > > + * errno: ENOSYS > > + */ > > +#define BTD_ERR_BREDR_CONN_UNKNOWN 0x0013 > > + > > +/* LE connection failure reasons > > + * BT_ERR_* should be used as one of the parameters to btd_error_*_err(). > > + */ > > + > > +/* Failed due to invalid arguments. > > + * errno: EINVAL > > + */ > > +#define BTD_ERR_LE_CONN_INVALID_ARGUMENTS 0x0101 > > +/* Failed due to adapter not powered. > > + * errno: EHOSTUNREACH > > + */ > > +#define BTD_ERR_LE_CONN_ADAPTER_NOT_POWERED 0x0102 > > +/* Failed due to unsupported state transition of L2CAP channel or other > > + * features (e.g. LE features) either by the local host or the remote. > > + * errno: EOPNOTSUPP, EPROTONOSUPPORT > > + */ > > +#define BTD_ERR_LE_CONN_NOT_SUPPORTED 0x0103 > > +/* Either the BT IO is already connected or LE link connection in place. > > + * errno: EALREADY, EISCONN > > + */ > > +#define BTD_ERR_LE_CONN_ALREADY_CONNECTED 0x0104 > > +/* Failed due to the socket is in bad state. > > + * errno: EBADFD > > + */ > > +#define BTD_ERR_LE_CONN_BAD_SOCKET 0x0105 > > +/* Failed to allocate memory in either host stack or controller. > > + * errno: ENOMEM > > + */ > > +#define BTD_ERR_LE_CONN_MEMORY_ALLOC 0x0106 > > +/* Failed due to other ongoing operations, such as pairing, connecting, busy > > + * L2CAP channel or the operation disallowed by the controller. > > + * errno: EBUSY > > + */ > > +#define BTD_ERR_LE_CONN_BUSY 0x0107 > > +/* Failed due to that LE is not enabled or the attempt is refused by the remote > > + * device due to limited resource, security reason or unacceptable address type. > > + * errno: ECONNREFUSED > > + */ > > +#define BTD_ERR_LE_CONN_REFUSED 0x0108 > > +/* Failed to create or connect to BT IO socket. This can also indicate > > + * hardware failure in the controller. > > + * errno: EIO > > + */ > > +#define BTD_ERR_LE_CONN_CREATE_SOCKET 0x0109 > > +/* Failed due to connection timeout > > + * errno: ETIMEDOUT > > + */ > > +#define BTD_ERR_LE_CONN_TIMEOUT 0x010A > > +/* Failed due to reaching the synchronous connection limit to a device. > > + * errno: EMLINK > > + */ > > +#define BTD_ERR_LE_CONN_SYNC_CONNECT_LIMIT 0x010B > > +/* Terminated by the remote device due to limited resource or power > > + * off. > > + * errno: ECONNRESET > > + */ > > +#define BTD_ERR_LE_CONN_TERM_BY_REMOTE 0x010C > > +/* Terminated by the local host. > > + * errno: ECONNABORTED > > + */ > > +#define BTD_ERR_LE_CONN_TERM_BY_LOCAL 0x010D > > +/* Failed due to LL protocol error. > > + * errno: EPROTO > > + */ > > +#define BTD_ERR_LE_CONN_PROTO_ERROR 0x010E > > +/* Failed to complete the GATT browsing. > > + * errno: none > > + */ > > +#define BTD_ERR_LE_CONN_GATT_BROWSE 0x010F > > +/* Failed due to unknown reason. > > + * errno: ENOSYS > > + */ > > +#define BTD_ERR_LE_CONN_UNKNOWN 0x0110 > > + > > DBusMessage *btd_error_invalid_args(DBusMessage *msg); > > DBusMessage *btd_error_invalid_args_str(DBusMessage *msg, const char *str); > > +DBusMessage *btd_error_invalid_args_err(DBusMessage *msg, uint16_t err); > > DBusMessage *btd_error_busy(DBusMessage *msg); > > DBusMessage *btd_error_already_exists(DBusMessage *msg); > > DBusMessage *btd_error_not_supported(DBusMessage *msg); > > DBusMessage *btd_error_not_connected(DBusMessage *msg); > > DBusMessage *btd_error_already_connected(DBusMessage *msg); > > DBusMessage *btd_error_not_available(DBusMessage *msg); > > +DBusMessage *btd_error_not_available_err(DBusMessage *msg, uint16_t err); > > DBusMessage *btd_error_in_progress(DBusMessage *msg); > > +DBusMessage *btd_error_in_progress_err(DBusMessage *msg, uint16_t err); > > DBusMessage *btd_error_does_not_exist(DBusMessage *msg); > > DBusMessage *btd_error_not_authorized(DBusMessage *msg); > > DBusMessage *btd_error_not_permitted(DBusMessage *msg, const char *str); > > DBusMessage *btd_error_no_such_adapter(DBusMessage *msg); > > DBusMessage *btd_error_agent_not_available(DBusMessage *msg); > > DBusMessage *btd_error_not_ready(DBusMessage *msg); > > +DBusMessage *btd_error_not_ready_err(DBusMessage *msg, uint16_t err); > > DBusMessage *btd_error_failed(DBusMessage *msg, const char *str); > > +DBusMessage *btd_error_failed_err(DBusMessage *msg, uint16_t err); > > + > > +uint16_t btd_error_bredr_conn_from_errno(int errno_code); > > +uint16_t btd_error_le_conn_from_errno(int errno_code); > > -- > > 2.32.0.288.g62a8d224e6-goog > > > > > -- > Luiz Augusto von Dentz Thanks, Miao
diff --git a/src/error.c b/src/error.c index 89517075e..b72e3d764 100644 --- a/src/error.c +++ b/src/error.c @@ -27,6 +27,7 @@ #include <config.h> #endif +#include <stdio.h> #include "gdbus/gdbus.h" #include "error.h" @@ -43,6 +44,15 @@ DBusMessage *btd_error_invalid_args_str(DBusMessage *msg, const char *str) "%s", str); } +DBusMessage *btd_error_invalid_args_err(DBusMessage *msg, uint16_t err) +{ + char str[16]; + + sprintf(str, "BtdError:0x%04X", err); + return g_dbus_create_error(msg, ERROR_INTERFACE ".InvalidArguments", + "%s", str); +} + DBusMessage *btd_error_busy(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress", @@ -79,12 +89,30 @@ DBusMessage *btd_error_in_progress(DBusMessage *msg) "In Progress"); } +DBusMessage *btd_error_in_progress_err(DBusMessage *msg, uint16_t err) +{ + char str[16]; + + sprintf(str, "BtdError:0x%04X", err); + return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress", "%s", + str); +} + DBusMessage *btd_error_not_available(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", "Operation currently not available"); } +DBusMessage *btd_error_not_available_err(DBusMessage *msg, uint16_t err) +{ + char str[16]; + + sprintf(str, "BtdError:0x%04X", err); + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotAvailable", "%s", + str); +} + DBusMessage *btd_error_does_not_exist(DBusMessage *msg) { return g_dbus_create_error(msg, ERROR_INTERFACE ".DoesNotExist", @@ -121,8 +149,104 @@ DBusMessage *btd_error_not_ready(DBusMessage *msg) "Resource Not Ready"); } +DBusMessage *btd_error_not_ready_err(DBusMessage *msg, uint16_t err) +{ + char str[16]; + + sprintf(str, "BtdError:0x%04X", err); + return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady", "%s", str); +} + DBusMessage *btd_error_failed(DBusMessage *msg, const char *str) { return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", str); } + +DBusMessage *btd_error_failed_err(DBusMessage *msg, uint16_t err) +{ + char str[16]; + + sprintf(str, "BtdError:0x%04X", err); + return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed", "%s", str); +} + +uint16_t btd_error_bredr_conn_from_errno(int errno_code) +{ + switch (-errno_code) { + case EALREADY: + case EISCONN: // Fall through + return BTD_ERR_BREDR_CONN_ALREADY_CONNECTED; + case EHOSTDOWN: + return BTD_ERR_BREDR_CONN_PAGE_TIMEOUT; + case ENOPROTOOPT: + return BTD_ERR_BREDR_CONN_PROFILE_UNAVAILABLE; + case EIO: + return BTD_ERR_BREDR_CONN_CREATE_SOCKET; + case EINVAL: + return BTD_ERR_BREDR_CONN_INVALID_ARGUMENTS; + case EHOSTUNREACH: + return BTD_ERR_BREDR_CONN_ADAPTER_NOT_POWERED; + case EOPNOTSUPP: + case EPROTONOSUPPORT: // Fall through + return BTD_ERR_BREDR_CONN_NOT_SUPPORTED; + case EBADFD: + return BTD_ERR_BREDR_CONN_BAD_SOCKET; + case ENOMEM: + return BTD_ERR_BREDR_CONN_MEMORY_ALLOC; + case EBUSY: + return BTD_ERR_BREDR_CONN_BUSY; + case EMLINK: + return BTD_ERR_BREDR_CONN_SYNC_CONNECT_LIMIT; + case ETIMEDOUT: + return BTD_ERR_BREDR_CONN_TIMEOUT; + case ECONNREFUSED: + return BTD_ERR_BREDR_CONN_REFUSED; + case ECONNRESET: + return BTD_ERR_BREDR_CONN_TERM_BY_REMOTE; + case ECONNABORTED: + return BTD_ERR_BREDR_CONN_TERM_BY_LOCAL; + case EPROTO: + return BTD_ERR_BREDR_CONN_PROTO_ERROR; + default: + return BTD_ERR_BREDR_CONN_UNKNOWN; + } +} + +uint16_t btd_error_le_conn_from_errno(int errno_code) +{ + switch (-errno_code) { + case EINVAL: + return BTD_ERR_LE_CONN_INVALID_ARGUMENTS; + case EHOSTUNREACH: + return BTD_ERR_LE_CONN_ADAPTER_NOT_POWERED; + case EOPNOTSUPP: + case EPROTONOSUPPORT: // Fall through + return BTD_ERR_LE_CONN_NOT_SUPPORTED; + case EALREADY: + case EISCONN: // Fall through + return BTD_ERR_LE_CONN_ALREADY_CONNECTED; + case EBADFD: + return BTD_ERR_LE_CONN_BAD_SOCKET; + case ENOMEM: + return BTD_ERR_LE_CONN_MEMORY_ALLOC; + case EBUSY: + return BTD_ERR_LE_CONN_BUSY; + case ECONNREFUSED: + return BTD_ERR_LE_CONN_REFUSED; + case EIO: + return BTD_ERR_LE_CONN_CREATE_SOCKET; + case ETIMEDOUT: + return BTD_ERR_LE_CONN_TIMEOUT; + case EMLINK: + return BTD_ERR_LE_CONN_SYNC_CONNECT_LIMIT; + case ECONNRESET: + return BTD_ERR_LE_CONN_TERM_BY_REMOTE; + case ECONNABORTED: + return BTD_ERR_LE_CONN_TERM_BY_LOCAL; + case EPROTO: + return BTD_ERR_LE_CONN_PROTO_ERROR; + default: + return BTD_ERR_LE_CONN_UNKNOWN; + } +} diff --git a/src/error.h b/src/error.h index 7c8cad066..f258cc4e7 100644 --- a/src/error.h +++ b/src/error.h @@ -24,22 +24,193 @@ */ #include <dbus/dbus.h> +#include <stdint.h> #define ERROR_INTERFACE "org.bluez.Error" +/* BR/EDR connection failure reasons + * BT_ERR_* should be used as one of the parameters to btd_error_*_err(). + */ + +/* Either the profile is already connected or ACL connection is in + * place. + * errno: EALREADY, EISCONN + */ +#define BTD_ERR_BREDR_CONN_ALREADY_CONNECTED 0x0001 +/* Failed due to page timeout. + * errno: EHOSTDOWN + */ +#define BTD_ERR_BREDR_CONN_PAGE_TIMEOUT 0x0002 +/* Failed to find connectable services or the target service. + * errno: ENOPROTOOPT + */ +#define BTD_ERR_BREDR_CONN_PROFILE_UNAVAILABLE 0x0003 +/* Failed to complete the SDP search. + * errno: none + */ +#define BTD_ERR_BREDR_CONN_SDP_SEARCH 0x0004 +/* Failed to create or connect to BT IO socket. This can also indicate + * hardware failure in the controller. + * errno: EIO + */ +#define BTD_ERR_BREDR_CONN_CREATE_SOCKET 0x0005 +/* Failed due to invalid arguments. + * errno: EINVAL + */ +#define BTD_ERR_BREDR_CONN_INVALID_ARGUMENTS 0x0006 +/* Failed due to adapter not powered. + * errno: EHOSTUNREACH + */ +#define BTD_ERR_BREDR_CONN_ADAPTER_NOT_POWERED 0x0007 +/* Failed due to unsupported state transition of L2CAP channel or other + * features either by the local host or the remote. + * errno: EOPNOTSUPP, EPROTONOSUPPORT + */ +#define BTD_ERR_BREDR_CONN_NOT_SUPPORTED 0x0008 +/* Failed due to the socket is in bad state. + * errno: EBADFD + */ +#define BTD_ERR_BREDR_CONN_BAD_SOCKET 0x0009 +/* Failed to allocate memory in either host stack or controller. + * errno: ENOMEM + */ +#define BTD_ERR_BREDR_CONN_MEMORY_ALLOC 0x000A +/* Failed due to other ongoing operations, such as pairing, busy L2CAP + * channel or the operation disallowed by the controller. + * errno: EBUSY + */ +#define BTD_ERR_BREDR_CONN_BUSY 0x000B +/* Failed due to reaching the synchronous connection limit to a device. + * errno: EMLINK + */ +#define BTD_ERR_BREDR_CONN_SYNC_CONNECT_LIMIT 0x000C +/* Failed due to connection timeout + * errno: ETIMEDOUT + */ +#define BTD_ERR_BREDR_CONN_TIMEOUT 0x000D +/* Refused by the remote device due to limited resource, security reason + * or unacceptable address type. + * errno: ECONNREFUSED + */ +#define BTD_ERR_BREDR_CONN_REFUSED 0x000E +/* Terminated by the remote device due to limited resource or power + * off. + * errno: ECONNRESET + */ +#define BTD_ERR_BREDR_CONN_TERM_BY_REMOTE 0x000F +/* Terminated by the local host. + * errno: ECONNABORTED + */ +#define BTD_ERR_BREDR_CONN_TERM_BY_LOCAL 0x0010 +/* Failed due to LMP protocol error. + * errno: EPROTO + */ +#define BTD_ERR_BREDR_CONN_PROTO_ERROR 0x0011 +/* Failed due to cancellation caused by adapter drop, unexpected device drop, + * or incoming disconnection request before connection request is completed. + * errno: none + */ +#define BTD_ERR_BREDR_CONN_CANCELED 0x0012 +/* Failed due to unknown reason. + * errno: ENOSYS + */ +#define BTD_ERR_BREDR_CONN_UNKNOWN 0x0013 + +/* LE connection failure reasons + * BT_ERR_* should be used as one of the parameters to btd_error_*_err(). + */ + +/* Failed due to invalid arguments. + * errno: EINVAL + */ +#define BTD_ERR_LE_CONN_INVALID_ARGUMENTS 0x0101 +/* Failed due to adapter not powered. + * errno: EHOSTUNREACH + */ +#define BTD_ERR_LE_CONN_ADAPTER_NOT_POWERED 0x0102 +/* Failed due to unsupported state transition of L2CAP channel or other + * features (e.g. LE features) either by the local host or the remote. + * errno: EOPNOTSUPP, EPROTONOSUPPORT + */ +#define BTD_ERR_LE_CONN_NOT_SUPPORTED 0x0103 +/* Either the BT IO is already connected or LE link connection in place. + * errno: EALREADY, EISCONN + */ +#define BTD_ERR_LE_CONN_ALREADY_CONNECTED 0x0104 +/* Failed due to the socket is in bad state. + * errno: EBADFD + */ +#define BTD_ERR_LE_CONN_BAD_SOCKET 0x0105 +/* Failed to allocate memory in either host stack or controller. + * errno: ENOMEM + */ +#define BTD_ERR_LE_CONN_MEMORY_ALLOC 0x0106 +/* Failed due to other ongoing operations, such as pairing, connecting, busy + * L2CAP channel or the operation disallowed by the controller. + * errno: EBUSY + */ +#define BTD_ERR_LE_CONN_BUSY 0x0107 +/* Failed due to that LE is not enabled or the attempt is refused by the remote + * device due to limited resource, security reason or unacceptable address type. + * errno: ECONNREFUSED + */ +#define BTD_ERR_LE_CONN_REFUSED 0x0108 +/* Failed to create or connect to BT IO socket. This can also indicate + * hardware failure in the controller. + * errno: EIO + */ +#define BTD_ERR_LE_CONN_CREATE_SOCKET 0x0109 +/* Failed due to connection timeout + * errno: ETIMEDOUT + */ +#define BTD_ERR_LE_CONN_TIMEOUT 0x010A +/* Failed due to reaching the synchronous connection limit to a device. + * errno: EMLINK + */ +#define BTD_ERR_LE_CONN_SYNC_CONNECT_LIMIT 0x010B +/* Terminated by the remote device due to limited resource or power + * off. + * errno: ECONNRESET + */ +#define BTD_ERR_LE_CONN_TERM_BY_REMOTE 0x010C +/* Terminated by the local host. + * errno: ECONNABORTED + */ +#define BTD_ERR_LE_CONN_TERM_BY_LOCAL 0x010D +/* Failed due to LL protocol error. + * errno: EPROTO + */ +#define BTD_ERR_LE_CONN_PROTO_ERROR 0x010E +/* Failed to complete the GATT browsing. + * errno: none + */ +#define BTD_ERR_LE_CONN_GATT_BROWSE 0x010F +/* Failed due to unknown reason. + * errno: ENOSYS + */ +#define BTD_ERR_LE_CONN_UNKNOWN 0x0110 + DBusMessage *btd_error_invalid_args(DBusMessage *msg); DBusMessage *btd_error_invalid_args_str(DBusMessage *msg, const char *str); +DBusMessage *btd_error_invalid_args_err(DBusMessage *msg, uint16_t err); DBusMessage *btd_error_busy(DBusMessage *msg); DBusMessage *btd_error_already_exists(DBusMessage *msg); DBusMessage *btd_error_not_supported(DBusMessage *msg); DBusMessage *btd_error_not_connected(DBusMessage *msg); DBusMessage *btd_error_already_connected(DBusMessage *msg); DBusMessage *btd_error_not_available(DBusMessage *msg); +DBusMessage *btd_error_not_available_err(DBusMessage *msg, uint16_t err); DBusMessage *btd_error_in_progress(DBusMessage *msg); +DBusMessage *btd_error_in_progress_err(DBusMessage *msg, uint16_t err); DBusMessage *btd_error_does_not_exist(DBusMessage *msg); DBusMessage *btd_error_not_authorized(DBusMessage *msg); DBusMessage *btd_error_not_permitted(DBusMessage *msg, const char *str); DBusMessage *btd_error_no_such_adapter(DBusMessage *msg); DBusMessage *btd_error_agent_not_available(DBusMessage *msg); DBusMessage *btd_error_not_ready(DBusMessage *msg); +DBusMessage *btd_error_not_ready_err(DBusMessage *msg, uint16_t err); DBusMessage *btd_error_failed(DBusMessage *msg, const char *str); +DBusMessage *btd_error_failed_err(DBusMessage *msg, uint16_t err); + +uint16_t btd_error_bredr_conn_from_errno(int errno_code); +uint16_t btd_error_le_conn_from_errno(int errno_code);