libusbg-0.1.0
Data Structures | Defines | Enumerations | Functions | Variables
include/usbg/usbg.h File Reference
#include <dirent.h>
#include <sys/queue.h>
#include <netinet/ether.h>

Go to the source code of this file.

Data Structures

struct  state
 State of the gadget devices in the system. More...
struct  gadget
 USB gadget device attributes. More...
struct  config
 USB gadget configuration attributes. More...
struct  serial_attrs
 Attributes for Serial, ACM, and OBEX USB functions. More...
struct  net_attrs
 Attributes for ECM, ECM subset, NCM, EEM, and RNDIS USB functions. More...
struct  phonet_attrs
 Attributes for the phonet USB function. More...
union  attrs
 Attributes for a given function type. More...
struct  function
 USB gadget function attributes. More...
struct  binding
 Describes a binding between a USB gadget configuration and a USB gadget function. More...

Defines

#define DEFAULT_UDC   NULL
#define LANG_US_ENG   0x0409
#define usbg_for_each_gadget(g, s)   TAILQ_FOREACH(g, &s->gadgets, gnode)
#define usbg_for_each_function(f, g)   TAILQ_FOREACH(f, &g->functions, fnode)
#define usbg_for_each_config(c, g)   TAILQ_FOREACH(c, &g->configs, cnode)
#define usbg_for_each_binding(b, c)   TAILQ_FOREACH(b, &c->bindings, bnode)

Enumerations

enum  function_type {
  F_SERIAL, F_ACM, F_OBEX, F_ECM,
  F_SUBSET, F_NCM, F_EEM, F_RNDIS,
  F_PHONET
}
 Supported USB function types.

Functions

struct stateusbg_init (char *configfs_path)
 Initialize the libusbg library state.
void usbg_cleanup (struct state *s)
 Clean up the libusbg library state.
struct gadgetusbg_get_gadget (struct state *s, const char *name)
 Get a gadget device by name.
struct functionusbg_get_function (struct gadget *g, const char *name)
 Get a function by name.
struct configusbg_get_config (struct gadget *g, const char *name)
 Get a configuration by name.
struct gadgetusbg_create_gadget (struct state *s, char *name, int vendor, int product)
 Create a new USB gadget device.
void usbg_set_gadget_device_class (struct gadget *g, int dclass)
 Set the USB gadget device class code.
void usbg_set_gadget_device_protocol (struct gadget *g, int dproto)
 Set the USB gadget protocol code.
void usbg_set_gadget_device_subclass (struct gadget *g, int dsubclass)
 Set the USB gadget device subclass code.
void usbg_set_gadget_device_max_packet (struct gadget *g, int maxpacket)
 Set the maximum packet size for a gadget.
void usbg_set_gadget_device_bcd_device (struct gadget *g, int bcddevice)
 Set the gadget device BCD release number.
void usbg_set_gadget_device_bcd_usb (struct gadget *g, int bcdusb)
 Set the gadget device BCD USB version.
void usbg_set_gadget_serial_number (struct gadget *g, int lang, char *ser)
 Set the serial number for a gadget.
void usbg_set_gadget_manufacturer (struct gadget *g, int lang, char *mnf)
 Set the manufacturer name for a gadget.
void usbg_set_gadget_product (struct gadget *g, int lang, char *prd)
 Set the product name for a gadget.
struct functionusbg_create_function (struct gadget *g, enum function_type type, char *instance)
 Create a new USB gadget function.
struct configusbg_create_config (struct gadget *g, char *name)
 Create a new USB gadget configuration.
void usbg_set_config_max_power (struct config *c, int maxpower)
 Set the configuration maximum power.
void usbg_set_config_bm_attrs (struct config *c, int bmattrs)
 Set the configuration bitmap attributes.
void usbg_set_config_string (struct config *c, int lang, char *string)
 Set the configuration string.
int usbg_add_config_function (struct config *c, char *name, struct function *f)
 Add a function to a configuration.
int usbg_get_udcs (struct dirent ***udc_list)
 Get a list of UDC devices on the system.
void usbg_enable_gadget (struct gadget *g, char *udc)
 Enable a USB gadget device.
void usbg_disable_gadget (struct gadget *g)
 Disable a USB gadget device.
void usbg_set_net_dev_addr (struct function *f, struct ether_addr *addr)
 Set USB function network device address.
void usbg_set_net_host_addr (struct function *f, struct ether_addr *addr)
 Set USB function network host address.
void usbg_set_net_qmult (struct function *f, int qmult)
 Set USB function network qmult.

Variables

const char * function_names []
 Name strings for supported USB function types.

Detailed Description

Todo:

Add usbg_remove_[gadget|config|function|binding] APIs

Clean up static buffers in structures

 All Data Structures Files Functions Variables Enumerations Defines