libusbg-0.1.0
Defines | Functions
src/usbg.c File Reference
#include <dirent.h>
#include <errno.h>
#include <usbg/usbg.h>
#include <netinet/ether.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

Defines

#define ERROR(msg,...)
#define ERRORNO(msg,...)
#define usbg_read_dec(p, n, f)   usbg_read_int(p, n, f, 10)
#define usbg_read_hex(p, n, f)   usbg_read_int(p, n, f, 16)
#define usbg_write_dec(p, n, f, v)   usbg_write_int(p, n, f, v, "%d\n")
#define usbg_write_hex16(p, n, f, v)   usbg_write_int(p, n, f, v, "0x%04x\n")
#define usbg_write_hex8(p, n, f, v)   usbg_write_int(p, n, f, v, "0x%02x\n")

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 bindingusbg_get_binding (struct config *c, const char *name)
struct bindingusbg_get_link_binding (struct config *c, struct function *f)
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 *serno)
 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 *str)
 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 *dev_addr)
 Set USB function network device address.
void usbg_set_net_host_addr (struct function *f, struct ether_addr *host_addr)
 Set USB function network host address.
void usbg_set_net_qmult (struct function *f, int qmult)
 Set USB function network qmult.

Detailed Description

Todo:

Handle buffer overflows

Error checking and return code propagation


Define Documentation

#define ERROR (   msg,
  ... 
)
Value:
do {\
                        char *str;\
                        fprintf(stderr, "%s()  "msg" \n", \
                                __func__, ##__VA_ARGS__);\
                    } while (0)
#define ERRORNO (   msg,
  ... 
)
Value:
do {\
                        char *str;\
                        fprintf(stderr, "%s()  %s: "msg" \n", \
                                __func__, strerror(errno), ##__VA_ARGS__);\
                    } while (0)
 All Data Structures Files Functions Variables Enumerations Defines