summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Lawrence <[email protected]>2020-03-03 10:31:46 -0600
committerPeter Lawrence <[email protected]>2020-03-03 10:31:46 -0600
commit4a4682a80a2bd3d6d607d5a960443656de32955d (patch)
treeef0fa610bdeb7e7509b73302962446520d283429
parentfee79d746604f671483f5872337ea366f2d2c1a2 (diff)
update net class to follow API naming convention
-rw-r--r--examples/device/lwip_webserver/src/main.c20
-rw-r--r--examples/device/lwip_webserver/src/usb_descriptors.c6
-rw-r--r--lib/networking/rndis_reports.c4
-rw-r--r--src/class/net/net_device.c16
-rw-r--r--src/class/net/net_device.h14
5 files changed, 30 insertions, 30 deletions
diff --git a/examples/device/lwip_webserver/src/main.c b/examples/device/lwip_webserver/src/main.c
index 364a26788..c193aeb0f 100644
--- a/examples/device/lwip_webserver/src/main.c
+++ b/examples/device/lwip_webserver/src/main.c
@@ -48,12 +48,12 @@ The MCU appears to the host as IP address 192.168.7.1, and provides a DHCP serve
/* lwip context */
static struct netif netif_data;
-/* shared between network_recv_callback() and service_traffic() */
+/* shared between tud_network_recv_cb() and service_traffic() */
static struct pbuf *received_frame;
/* this is used by this code, ./class/net/net_driver.c, and usb_descriptors.c */
/* ideally speaking, this should be generated from the hardware's unique ID (if available) */
-const uint8_t network_mac_address[6] = {0x20,0x89,0x84,0x6A,0x96,0x00};
+const uint8_t tud_network_mac_address[6] = {0x20,0x89,0x84,0x6A,0x96,0x00};
/* network parameters of this MCU */
static const ip_addr_t ipaddr = IPADDR4_INIT_BYTES(192, 168, 7, 1);
@@ -90,9 +90,9 @@ static err_t linkoutput_fn(struct netif *netif, struct pbuf *p)
return ERR_USE;
/* if the network driver can accept another packet, we make it happen */
- if (network_can_xmit())
+ if (tud_network_can_xmit())
{
- network_xmit(p);
+ tud_network_xmit(p);
return ERR_OK;
}
@@ -124,8 +124,8 @@ static void init_lwip(void)
struct netif *netif = &netif_data;
lwip_init();
- netif->hwaddr_len = sizeof(network_mac_address);
- memcpy(netif->hwaddr, network_mac_address, sizeof(network_mac_address));
+ netif->hwaddr_len = sizeof(tud_network_mac_address);
+ memcpy(netif->hwaddr, tud_network_mac_address, sizeof(tud_network_mac_address));
netif = netif_add(netif, &ipaddr, &netmask, &gateway, NULL, netif_init_cb, ip_input);
netif_set_default(netif);
@@ -142,7 +142,7 @@ bool dns_query_proc(const char *name, ip_addr_t *addr)
return false;
}
-bool network_recv_callback(struct pbuf *p)
+bool tud_network_recv_cb(struct pbuf *p)
{
/* this shouldn't happen, but if we get another packet before
parsing the previous, we must signal our inability to accept it */
@@ -155,17 +155,17 @@ bool network_recv_callback(struct pbuf *p)
static void service_traffic(void)
{
- /* handle any packet received by network_recv_callback() */
+ /* handle any packet received by tud_network_recv_cb() */
if (received_frame)
{
ethernet_input(received_frame, &netif_data);
pbuf_free(received_frame);
received_frame = NULL;
- network_recv_renew();
+ tud_network_recv_renew();
}
}
-void network_init_callback(void)
+void tud_network_init_cb(void)
{
/* if the network is re-initializing and we have a leftover packet, we must do a cleanup */
if (received_frame)
diff --git a/examples/device/lwip_webserver/src/usb_descriptors.c b/examples/device/lwip_webserver/src/usb_descriptors.c
index 803c99c02..26f8aeba6 100644
--- a/examples/device/lwip_webserver/src/usb_descriptors.c
+++ b/examples/device/lwip_webserver/src/usb_descriptors.c
@@ -168,10 +168,10 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index, uint16_t langid)
{
// Convert MAC address into UTF-16
- for (unsigned i=0; i<sizeof(network_mac_address); i++)
+ for (unsigned i=0; i<sizeof(tud_network_mac_address); i++)
{
- _desc_str[1+chr_count++] = "0123456789ABCDEF"[(network_mac_address[i] >> 4) & 0xf];
- _desc_str[1+chr_count++] = "0123456789ABCDEF"[(network_mac_address[i] >> 0) & 0xf];
+ _desc_str[1+chr_count++] = "0123456789ABCDEF"[(tud_network_mac_address[i] >> 4) & 0xf];
+ _desc_str[1+chr_count++] = "0123456789ABCDEF"[(tud_network_mac_address[i] >> 0) & 0xf];
}
}
else
diff --git a/lib/networking/rndis_reports.c b/lib/networking/rndis_reports.c
index 535bdf851..9c470b621 100644
--- a/lib/networking/rndis_reports.c
+++ b/lib/networking/rndis_reports.c
@@ -36,8 +36,8 @@
#define RNDIS_LINK_SPEED 12000000 /* Link baudrate (12Mbit/s for USB-FS) */
#define RNDIS_VENDOR "TinyUSB" /* NIC vendor name */
-static const uint8_t *const station_hwaddr = network_mac_address;
-static const uint8_t *const permanent_hwaddr = network_mac_address;
+static const uint8_t *const station_hwaddr = tud_network_mac_address;
+static const uint8_t *const permanent_hwaddr = tud_network_mac_address;
static usb_eth_stat_t usb_eth_stat = { 0, 0, 0, 0 };
static uint32_t oid_packet_filter = 0x0000000;
diff --git a/src/class/net/net_device.c b/src/class/net/net_device.c
index 422d435c6..c918e5874 100644
--- a/src/class/net/net_device.c
+++ b/src/class/net/net_device.c
@@ -74,7 +74,7 @@ CFG_TUSB_MEM_SECTION static netd_interface_t _netd_itf;
static bool can_xmit;
-void network_recv_renew(void)
+void tud_network_recv_renew(void)
{
usbd_edpt_xfer(TUD_OPT_RHPORT, _netd_itf.ep_out, received, sizeof(received));
}
@@ -156,13 +156,13 @@ bool netd_open(uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t
(*p_length) += 2*sizeof(tusb_desc_endpoint_t);
}
- network_init_callback();
+ tud_network_init_cb();
// we are ready to transmit a packet
can_xmit = true;
// prepare for incoming packets
- network_recv_renew();
+ tud_network_recv_renew();
return true;
}
@@ -237,7 +237,7 @@ static void handle_incoming_packet(uint32_t len)
if (hdr->bmType)
{
/* EEM Control Packet: discard it */
- network_recv_renew();
+ tud_network_recv_renew();
}
else
{
@@ -256,13 +256,13 @@ static void handle_incoming_packet(uint32_t len)
{
memcpy(p->payload, pnt, size);
p->len = size;
- accepted = network_recv_callback(p);
+ accepted = tud_network_recv_cb(p);
}
if (!p || !accepted)
{
/* if a buffer couldn't be allocated or accepted by the callback, we must discard this packet */
- network_recv_renew();
+ tud_network_recv_renew();
}
}
}
@@ -297,12 +297,12 @@ bool netd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
return true;
}
-bool network_can_xmit(void)
+bool tud_network_can_xmit(void)
{
return can_xmit;
}
-void network_xmit(struct pbuf *p)
+void tud_network_xmit(struct pbuf *p)
{
struct pbuf *q;
uint8_t *data;
diff --git a/src/class/net/net_device.h b/src/class/net/net_device.h
index c61efc86c..fee54163f 100644
--- a/src/class/net/net_device.h
+++ b/src/class/net/net_device.h
@@ -49,22 +49,22 @@
//--------------------------------------------------------------------+
// client must provide this: initialize any network state back to the beginning
-void network_init_callback(void);
+void tud_network_init_cb(void);
// client must provide this: return false if the packet buffer was not accepted
-bool network_recv_callback(struct pbuf *p);
+bool tud_network_recv_cb(struct pbuf *p);
// client must provide this: 48-bit MAC address
-extern const uint8_t network_mac_address[6];
+extern const uint8_t tud_network_mac_address[6];
-// indicate to network driver that client has finished with the packet provided to network_recv_callback()
-void network_recv_renew(void);
+// indicate to network driver that client has finished with the packet provided to network_recv_cb()
+void tud_network_recv_renew(void);
// poll network driver for its ability to accept another packet to transmit
-bool network_can_xmit(void);
+bool tud_network_can_xmit(void);
// if network_can_xmit() returns true, network_xmit() can be called once
-void network_xmit(struct pbuf *p);
+void tud_network_xmit(struct pbuf *p);
//--------------------------------------------------------------------+
// INTERNAL USBD-CLASS DRIVER API