goto out2;
}
- usbg_ret = usbg_create_function(g, F_ACM, "usb0", NULL, &f_acm0);
+ usbg_ret = usbg_create_function(g, USBG_F_ACM, "usb0", NULL, &f_acm0);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating acm0 function\n");
fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret),
goto out2;
}
- usbg_ret = usbg_create_function(g, F_ACM, "usb1", NULL, &f_acm1);
+ usbg_ret = usbg_create_function(g, USBG_F_ACM, "usb1", NULL, &f_acm1);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating acm1 function\n");
fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret),
goto out2;
}
- usbg_ret = usbg_create_function(g, F_ECM, "usb0", NULL, &f_ecm);
+ usbg_ret = usbg_create_function(g, USBG_F_ECM, "usb0", NULL, &f_ecm);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating ecm function\n");
fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret),
goto out2;
}
- usbg_ret = usbg_create_function(g, F_FFS, "my_dev_name", NULL, &f_ffs1);
+ usbg_ret = usbg_create_function(g, USBG_F_FFS, "my_dev_name", NULL, &f_ffs1);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating ffs1 function\n");
fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret),
goto out2;
}
- usbg_ret = usbg_create_function(g, F_FFS, "my_other_dev_name",
+ usbg_ret = usbg_create_function(g, USBG_F_FFS, "my_other_dev_name",
NULL, &f_ffs2);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating ffs2 function\n");
usbg_strerror(usbg_ret));
goto out2;
}
- usbg_ret = usbg_create_function(g, F_MIDI, "usb0", &f_attrs, &f_midi);
+ usbg_ret = usbg_create_function(g, USBG_F_MIDI, "usb0", &f_attrs, &f_midi);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating function\n");
fprintf(stderr, "Error: %s : %s\n", usbg_error_name(usbg_ret),
goto out2;
}
- usbg_ret = usbg_create_function(g, F_MASS_STORAGE, "my_reader",
+ usbg_ret = usbg_create_function(g, USBG_F_MASS_STORAGE, "my_reader",
&f_attrs, &f_ms);
if (usbg_ret != USBG_SUCCESS) {
fprintf(stderr, "Error creating mass storage function\n");
usbg_get_function_type_str(type), instance);
switch (type) {
- case F_ACM:
- case F_OBEX:
- case F_SERIAL:
+ case USBG_F_ACM:
+ case USBG_F_OBEX:
+ case USBG_F_SERIAL:
fprintf(stdout, " port_num\t\t%d\n",
f_attrs.serial_port_num);
break;
- case F_ECM:
- case F_SUBSET:
- case F_NCM:
- case F_EEM:
- case F_RNDIS:
+ case USBG_F_ECM:
+ case USBG_F_SUBSET:
+ case USBG_F_NCM:
+ case USBG_F_EEM:
+ case USBG_F_RNDIS:
{
struct usbg_f_net_attrs *f_net_attrs = &f_attrs.net;
break;
}
- case F_PHONET:
+ case USBG_F_PHONET:
fprintf(stdout, " ifname\t\t%s\n", f_attrs.phonet_ifname);
break;
- case F_FFS:
+ case USBG_F_FFS:
fprintf(stdout, " dev_name\t\t%s\n", f_attrs.ffs_dev_name);
break;
- case F_MASS_STORAGE:
+ case USBG_F_MASS_STORAGE:
{
struct usbg_f_ms_attrs *attrs = &f_attrs.ms;
int i;
break;
}
- case F_MIDI:
+ case USBG_F_MIDI:
{
struct usbg_f_midi_attrs *attrs = &f_attrs.midi;
typedef enum
{
USBG_FUNCTION_TYPE_MIN = 0,
- F_SERIAL = USBG_FUNCTION_TYPE_MIN,
- F_ACM,
- F_OBEX,
- F_ECM,
- F_SUBSET,
- F_NCM,
- F_EEM,
- F_RNDIS,
- F_PHONET,
- F_FFS,
- F_MASS_STORAGE,
- F_MIDI,
- F_LOOPBACK,
+ USBG_F_SERIAL = USBG_FUNCTION_TYPE_MIN,
+ USBG_F_ACM,
+ USBG_F_OBEX,
+ USBG_F_ECM,
+ USBG_F_SUBSET,
+ USBG_F_NCM,
+ USBG_F_EEM,
+ USBG_F_RNDIS,
+ USBG_F_PHONET,
+ USBG_F_FFS,
+ USBG_F_MASS_STORAGE,
+ USBG_F_MIDI,
+ USBG_F_LOOPBACK,
USBG_FUNCTION_TYPE_MAX,
} usbg_function_type;
* @brief Types of functions supported by library
*/
struct usbg_function_type* function_types[] = {
- [F_ACM] = &usbg_f_type_acm,
- [F_SERIAL] = &usbg_f_type_serial,
- [F_OBEX] = &usbg_f_type_obex,
- [F_ECM] = &usbg_f_type_ecm,
- [F_SUBSET] = &usbg_f_type_subset,
- [F_NCM] = &usbg_f_type_ncm,
- [F_EEM] = &usbg_f_type_eem,
- [F_RNDIS] = &usbg_f_type_rndis,
- [F_FFS] = &usbg_f_type_ffs,
- [F_MIDI] = &usbg_f_type_midi,
- [F_MASS_STORAGE] = &usbg_f_type_ms,
- [F_PHONET] = &usbg_f_type_phonet,
- [F_LOOPBACK] = &usbg_f_type_loopback,
+ [USBG_F_ACM] = &usbg_f_type_acm,
+ [USBG_F_SERIAL] = &usbg_f_type_serial,
+ [USBG_F_OBEX] = &usbg_f_type_obex,
+ [USBG_F_ECM] = &usbg_f_type_ecm,
+ [USBG_F_SUBSET] = &usbg_f_type_subset,
+ [USBG_F_NCM] = &usbg_f_type_ncm,
+ [USBG_F_EEM] = &usbg_f_type_eem,
+ [USBG_F_RNDIS] = &usbg_f_type_rndis,
+ [USBG_F_FFS] = &usbg_f_type_ffs,
+ [USBG_F_MIDI] = &usbg_f_type_midi,
+ [USBG_F_MASS_STORAGE] = &usbg_f_type_ms,
+ [USBG_F_PHONET] = &usbg_f_type_phonet,
+ [USBG_F_LOOPBACK] = &usbg_f_type_loopback,
};
ARRAY_SIZE_SENTINEL(function_types, USBG_FUNCTION_TYPE_MAX);
* @details Used to go through init when testing other things
*/
static struct test_function simple_funcs[] = {
- FUNC_FROM_TYPE(F_ECM),
- FUNC_FROM_TYPE(F_ACM),
+ FUNC_FROM_TYPE(USBG_F_ECM),
+ FUNC_FROM_TYPE(USBG_F_ACM),
TEST_FUNCTION_LIST_END
};
* processed correctly
*/
static struct test_function all_funcs[] = {
- FUNC_FROM_TYPE(F_SERIAL),
- FUNC_FROM_TYPE(F_ACM),
- FUNC_FROM_TYPE(F_OBEX),
- FUNC_FROM_TYPE(F_ECM),
- FUNC_FROM_TYPE(F_SUBSET),
- FUNC_FROM_TYPE(F_NCM),
- FUNC_FROM_TYPE(F_EEM),
- FUNC_FROM_TYPE(F_RNDIS),
- FUNC_FROM_TYPE(F_PHONET),
- FUNC_FROM_TYPE(F_FFS),
+ FUNC_FROM_TYPE(USBG_F_SERIAL),
+ FUNC_FROM_TYPE(USBG_F_ACM),
+ FUNC_FROM_TYPE(USBG_F_OBEX),
+ FUNC_FROM_TYPE(USBG_F_ECM),
+ FUNC_FROM_TYPE(USBG_F_SUBSET),
+ FUNC_FROM_TYPE(USBG_F_NCM),
+ FUNC_FROM_TYPE(USBG_F_EEM),
+ FUNC_FROM_TYPE(USBG_F_RNDIS),
+ FUNC_FROM_TYPE(USBG_F_PHONET),
+ FUNC_FROM_TYPE(USBG_F_FFS),
TEST_FUNCTION_LIST_END
};
static struct test_function same_type_funcs[] = {
- FUNC_FROM_TYPE(F_SERIAL),
- FUNC_FROM_TYPE(F_SERIAL),
- FUNC_FROM_TYPE(F_SERIAL),
+ FUNC_FROM_TYPE(USBG_F_SERIAL),
+ FUNC_FROM_TYPE(USBG_F_SERIAL),
+ FUNC_FROM_TYPE(USBG_F_SERIAL),
TEST_FUNCTION_LIST_END
};
static int setup_f_serial_attrs(void **state)
{
- *state = setup_f_attrs(F_SERIAL, &simple_serial_attrs);
+ *state = setup_f_attrs(USBG_F_SERIAL, &simple_serial_attrs);
return 0;
}
static int setup_f_serial_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_SERIAL, &writable_serial_attrs);
+ *state = setup_f_attrs(USBG_F_SERIAL, &writable_serial_attrs);
return 0;
}
static int setup_f_acm_attrs(void **state)
{
- *state = setup_f_attrs(F_ACM, &simple_serial_attrs);
+ *state = setup_f_attrs(USBG_F_ACM, &simple_serial_attrs);
return 0;
}
static int setup_f_acm_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_ACM, &writable_serial_attrs);
+ *state = setup_f_attrs(USBG_F_ACM, &writable_serial_attrs);
return 0;
}
static int setup_f_obex_attrs(void **state)
{
- *state = setup_f_attrs(F_OBEX, &simple_serial_attrs);
+ *state = setup_f_attrs(USBG_F_OBEX, &simple_serial_attrs);
return 0;
}
static int setup_f_obex_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_OBEX, &writable_serial_attrs);
+ *state = setup_f_attrs(USBG_F_OBEX, &writable_serial_attrs);
return 0;
}
static int setup_f_ecm_attrs(void **state)
{
- *state = setup_f_attrs(F_ECM, &simple_net_attrs);
+ *state = setup_f_attrs(USBG_F_ECM, &simple_net_attrs);
return 0;
}
static int setup_f_ecm_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_ECM, &writable_net_attrs);
+ *state = setup_f_attrs(USBG_F_ECM, &writable_net_attrs);
return 0;
}
static int setup_f_subset_attrs(void **state)
{
- *state = setup_f_attrs(F_SUBSET, &simple_net_attrs);
+ *state = setup_f_attrs(USBG_F_SUBSET, &simple_net_attrs);
return 0;
}
static int setup_f_subset_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_SUBSET, &writable_net_attrs);
+ *state = setup_f_attrs(USBG_F_SUBSET, &writable_net_attrs);
return 0;
}
static int setup_f_ncm_attrs(void **state)
{
- *state = setup_f_attrs(F_NCM, &simple_net_attrs);
+ *state = setup_f_attrs(USBG_F_NCM, &simple_net_attrs);
return 0;
}
static int setup_f_ncm_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_NCM, &writable_net_attrs);
+ *state = setup_f_attrs(USBG_F_NCM, &writable_net_attrs);
return 0;
}
static int setup_f_eem_attrs(void **state)
{
- *state = setup_f_attrs(F_EEM, &simple_net_attrs);
+ *state = setup_f_attrs(USBG_F_EEM, &simple_net_attrs);
return 0;
}
static int setup_f_eem_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_EEM, &writable_net_attrs);
+ *state = setup_f_attrs(USBG_F_EEM, &writable_net_attrs);
return 0;
}
static int setup_f_rndis_attrs(void **state)
{
- *state = setup_f_attrs(F_RNDIS, &simple_net_attrs);
+ *state = setup_f_attrs(USBG_F_RNDIS, &simple_net_attrs);
return 0;
}
static int setup_f_rndis_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_RNDIS, &writable_net_attrs);
+ *state = setup_f_attrs(USBG_F_RNDIS, &writable_net_attrs);
return 0;
}
static int setup_f_phonet_attrs(void **state)
{
- *state = setup_f_attrs(F_PHONET, &simple_phonet_attrs);
+ *state = setup_f_attrs(USBG_F_PHONET, &simple_phonet_attrs);
return 0;
}
static int setup_f_phonet_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_PHONET, &writable_phonet_attrs);
+ *state = setup_f_attrs(USBG_F_PHONET, &writable_phonet_attrs);
return 0;
}
static int setup_f_ffs_attrs(void **state)
{
- *state = setup_f_attrs(F_FFS, &simple_ffs_attrs);
+ *state = setup_f_attrs(USBG_F_FFS, &simple_ffs_attrs);
return 0;
}
static int setup_f_ffs_writable_attrs(void **state)
{
- *state = setup_f_attrs(F_FFS, &writable_ffs_attrs);
+ *state = setup_f_attrs(USBG_F_FFS, &writable_ffs_attrs);
return 0;
}
g = usbg_get_first_gadget(s);
assert_non_null(g);
- f = usbg_get_function(g, F_ACM, "non-existing-instance");
+ f = usbg_get_function(g, USBG_F_ACM, "non-existing-instance");
assert_null(f);
f = usbg_get_function(g, 9001, "0");
usbg_function_type type;
const char *str;
} types[] = {
- {F_SERIAL, "gser"},
- {F_ACM, "acm"},
- {F_OBEX, "obex"},
- {F_ECM, "ecm"},
- {F_SUBSET, "geth"},
- {F_NCM, "ncm"},
- {F_EEM, "eem"},
- {F_RNDIS, "rndis"},
- {F_PHONET, "phonet"},
- {F_FFS, "ffs"},
+ {USBG_F_SERIAL, "gser"},
+ {USBG_F_ACM, "acm"},
+ {USBG_F_OBEX, "obex"},
+ {USBG_F_ECM, "ecm"},
+ {USBG_F_SUBSET, "geth"},
+ {USBG_F_NCM, "ncm"},
+ {USBG_F_EEM, "eem"},
+ {USBG_F_RNDIS, "rndis"},
+ {USBG_F_PHONET, "phonet"},
+ {USBG_F_FFS, "ffs"},
};
const char *str;
void push_function_attrs(struct test_function *func, void *function_attrs)
{
switch (func->type) {
- case F_ACM:
- case F_OBEX:
- case F_SERIAL:
+ case USBG_F_ACM:
+ case USBG_F_OBEX:
+ case USBG_F_SERIAL:
push_serial_attrs(func, function_attrs);
break;
- case F_ECM:
- case F_SUBSET:
- case F_NCM:
- case F_EEM:
- case F_RNDIS:
+ case USBG_F_ECM:
+ case USBG_F_SUBSET:
+ case USBG_F_NCM:
+ case USBG_F_EEM:
+ case USBG_F_RNDIS:
push_net_attrs(func, function_attrs);
break;
- case F_PHONET:
+ case USBG_F_PHONET:
push_phonet_attrs(func, function_attrs);
break;
- case F_FFS:
+ case USBG_F_FFS:
// ffs does not exist in filesystem
default:
break;
void pull_function_attrs(struct test_function *func, void *attrs)
{
switch (func->type) {
- case F_ECM:
- case F_SUBSET:
- case F_NCM:
- case F_EEM:
- case F_RNDIS:
+ case USBG_F_ECM:
+ case USBG_F_SUBSET:
+ case USBG_F_NCM:
+ case USBG_F_EEM:
+ case USBG_F_RNDIS:
pull_function_net_attrs(func, attrs);
break;
default:
usbg_function_type type)
{
switch (type) {
- case F_ACM:
- case F_OBEX:
- case F_SERIAL:
+ case USBG_F_ACM:
+ case USBG_F_OBEX:
+ case USBG_F_SERIAL:
assert_f_serial_attrs_equal(actual, expected);
break;
- case F_ECM:
- case F_SUBSET:
- case F_NCM:
- case F_EEM:
- case F_RNDIS:
+ case USBG_F_ECM:
+ case USBG_F_SUBSET:
+ case USBG_F_NCM:
+ case USBG_F_EEM:
+ case USBG_F_RNDIS:
assert_f_net_attrs_equal(actual, expected);
break;
- case F_PHONET:
+ case USBG_F_PHONET:
assert_f_phonet_attrs_equal(actual, expected);
break;
- case F_FFS:
+ case USBG_F_FFS:
assert_f_ffs_attrs_equal(actual, expected);
break;
default: