mirror of
https://github.com/linux-usb-gadgets/libusbgx.git
synced 2025-07-24 20:45:06 +03:00
net: adds class, subclass and protocol attributes
This commit allows the library user to change class, subclass and protocol values inside net derivated functions. This is needed by Windows 10 users using RNDIS function with the native driver.
This commit is contained in:
parent
b1c8586648
commit
4ca4a7699b
2 changed files with 84 additions and 0 deletions
|
@ -29,6 +29,9 @@ struct usbg_f_net_attrs {
|
|||
struct ether_addr host_addr;
|
||||
const char *ifname;
|
||||
int qmult;
|
||||
unsigned int class;
|
||||
unsigned int subclass;
|
||||
unsigned int protocol;
|
||||
};
|
||||
|
||||
enum usbg_f_net_attr {
|
||||
|
@ -37,6 +40,9 @@ enum usbg_f_net_attr {
|
|||
USBG_F_NET_HOST_ADDR,
|
||||
USBG_F_NET_IFNAME,
|
||||
USBG_F_NET_QMULT,
|
||||
USBG_F_NET_CLASS,
|
||||
USBG_F_NET_SUBCLASS,
|
||||
USBG_F_NET_PROTOCOL,
|
||||
USBG_F_NET_ATTR_MAX
|
||||
};
|
||||
|
||||
|
@ -45,6 +51,9 @@ union usbg_f_net_attr_val {
|
|||
struct ether_addr host_addr;
|
||||
const char *ifname;
|
||||
int qmult;
|
||||
unsigned int class;
|
||||
unsigned int subclass;
|
||||
unsigned int protocol;
|
||||
};
|
||||
|
||||
#define USBG_F_NET_ETHER_ADDR_TO_ATTR_VAL(WHAT) \
|
||||
|
@ -221,6 +230,78 @@ static inline int usbg_f_net_set_qmult(usbg_f_net *nf, int qmult)
|
|||
USBG_F_NET_INT_TO_ATTR_VAL(qmult));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value of usb function class
|
||||
* @param[in] nf Pointer to net function
|
||||
* @param[out] class Current class identification
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_get_class(usbg_f_net *nf, unsigned int *class)
|
||||
{
|
||||
return usbg_f_net_get_attr_val(nf, USBG_F_NET_CLASS,
|
||||
(union usbg_f_net_attr_val *)class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the value of usb function class
|
||||
* @param[in] nf Pointer to net function
|
||||
* @param[in] class Class identification
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_set_class(usbg_f_net *nf, unsigned int class)
|
||||
{
|
||||
return usbg_f_net_set_attr_val(nf, USBG_F_NET_CLASS,
|
||||
USBG_F_NET_INT_TO_ATTR_VAL(class));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value of usb function subclass
|
||||
* @param[in] nf Pointer to net function
|
||||
* @param[out] subclass Current subclass identification
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_get_subclass(usbg_f_net *nf, int *subclass)
|
||||
{
|
||||
return usbg_f_net_get_attr_val(nf, USBG_F_NET_SUBCLASS,
|
||||
(union usbg_f_net_attr_val *)subclass);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the value of usb function subclass
|
||||
* @param[in] nf Pointer to net function
|
||||
* @param[in] subclass Subclass identification
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_set_subclass(usbg_f_net *nf, unsigned int subclass)
|
||||
{
|
||||
return usbg_f_net_set_attr_val(nf, USBG_F_NET_SUBCLASS,
|
||||
USBG_F_NET_INT_TO_ATTR_VAL(subclass));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the value of usb function protocol
|
||||
* @param[in] nf Pointer to net function
|
||||
* @param[out] protocol Current protocol identification
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_get_protocol(usbg_f_net *nf, int *protocol)
|
||||
{
|
||||
return usbg_f_net_get_attr_val(nf, USBG_F_NET_PROTOCOL,
|
||||
(union usbg_f_net_attr_val *)protocol);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the value of usb function protocol
|
||||
* @param[in] nf Pointer to net function
|
||||
* @param[in] protocol protocol identification
|
||||
* @return 0 on success usbg_error if error occurred.
|
||||
*/
|
||||
static inline int usbg_f_net_set_protocol(usbg_f_net *nf, unsigned int protocol)
|
||||
{
|
||||
return usbg_f_net_set_attr_val(nf, USBG_F_NET_PROTOCOL,
|
||||
USBG_F_NET_INT_TO_ATTR_VAL(protocol));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -67,6 +67,9 @@ static struct {
|
|||
[USBG_F_NET_HOST_ADDR] = NET_ETHER_ADDR_ATTR(host_addr),
|
||||
[USBG_F_NET_IFNAME] = NET_RO_STRING_ATTR(ifname),
|
||||
[USBG_F_NET_QMULT] = NET_DEC_ATTR(qmult),
|
||||
[USBG_F_NET_CLASS] = NET_DEC_ATTR(class),
|
||||
[USBG_F_NET_SUBCLASS] = NET_DEC_ATTR(subclass),
|
||||
[USBG_F_NET_PROTOCOL] = NET_DEC_ATTR(protocol)
|
||||
};
|
||||
|
||||
#undef NET_DEC_ATTR
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue