10 #define INTERRUPT_IN 0x83
13 struct uip_eth_addr default_uip_ethaddr = {{0x02,0x00,0x00,0x00,0x00,0x02}};
16 handle_cdc_eth_requests()
21 static const struct USBRequestHandler cdc_eth_request_handler =
25 handle_cdc_eth_requests
28 static struct USBRequestHandlerHook cdc_eth_request_hook =
31 &cdc_eth_request_handler
34 static USBBuffer recv_buffer;
37 static USBBuffer xmit_buffer[3];
43 recv_buffer.next =
NULL;
44 recv_buffer.data = recv_data;
46 recv_buffer.flags = USB_BUFFER_SHORT_END | USB_BUFFER_NOTIFY;
52 if ((xmit_buffer[0].flags & USB_BUFFER_SUBMITTED))
return UIP_FW_DROPPED;
54 memcpy(xmit_data, uip_buf,
uip_len);
55 xmit_buffer[0].next =
NULL;
57 xmit_buffer[0].flags = USB_BUFFER_NOTIFY | USB_BUFFER_SHORT_END;
58 xmit_buffer[0].data = xmit_data;
61 usb_submit_xmit_buffer(DATA_IN, &xmit_buffer[0]);
66 {
UIP_FW_NETIF(172,16,0,1, 255,255,255,255, usbeth_send)};
68 #define BUF ((struct uip_eth_hdr *)&uip_buf[0])
70 PROCESS(usb_eth_process,
"USB ethernet");
75 usb_register_request_handler(&cdc_eth_request_hook);
77 usb_set_ep_event_process(DATA_OUT, process_current);
78 usb_set_global_event_process(process_current);
85 if (ev == PROCESS_EVENT_EXIT)
break;
86 if (ev == PROCESS_EVENT_POLL) {
87 unsigned int events = usb_get_global_events();
89 if (events & USB_EVENT_CONFIG) {
90 if (usb_get_current_configuration() != 0) {
91 printf(
"Configured\n");
92 usb_setup_bulk_endpoint(DATA_IN);
93 usb_setup_bulk_endpoint(DATA_OUT);
94 usb_setup_interrupt_endpoint(INTERRUPT_IN);
96 usb_submit_recv_buffer(DATA_OUT, &recv_buffer);
99 static const uint8_t foo[4] = {0x12,0x34,0x56,0x78};
100 xmit_buffer[0].next =
NULL;
101 xmit_buffer[0].left =
sizeof(foo);
102 xmit_buffer[0].flags = USB_BUFFER_SHORT_END;
103 xmit_buffer[0].data = &foo;
105 usb_submit_xmit_buffer(DATA_IN, &xmit_buffer[0]);
109 usb_disable_endpoint(DATA_IN);
110 usb_disable_endpoint(DATA_OUT);
111 usb_disable_endpoint(INTERRUPT_IN);
115 events = usb_get_ep_events(DATA_OUT);
116 if (events & USB_EP_EVENT_NOTIFICATION) {
117 uip_len =
sizeof(recv_data) - recv_buffer.left;
119 memcpy(uip_buf, recv_data,
uip_len);
121 if(BUF->type ==
uip_htons(UIP_ETHTYPE_IPV6)) {
122 uip_neighbor_add(&IPBUF->srcipaddr, &BUF->src);
126 if(BUF->type ==
uip_htons(UIP_ETHTYPE_IP)) {
129 }
else if(BUF->type ==
uip_htons(UIP_ETHTYPE_ARP)) {
135 memcpy(xmit_data, uip_buf,
uip_len);
136 xmit_buffer[0].next =
NULL;
137 xmit_buffer[0].data = xmit_data;
139 xmit_buffer[0].flags = USB_BUFFER_SHORT_END;
141 usb_submit_xmit_buffer(DATA_IN, &xmit_buffer[0]);
147 usb_submit_recv_buffer(DATA_OUT, &recv_buffer);
161 usb_cdc_eth_set_ifaddr(uip_ipaddr_t *addr)
167 dummy(uip_ipaddr_t *addr1, uip_ipaddr_t *addr2)
void uip_arp_out(void)
Prepend Ethernet header to an outbound IP packet and see if we need to send out an ARP request...
#define UIP_FW_DROPPED
An error message that indicates that a packet that should be forwarded or output was dropped...
uip_len
The length of the packet in the uip_buf buffer.
uIP packet forwarding header file.
#define uip_setethaddr(eaddr)
Specifiy the Ethernet MAC address.
#define UIP_FW_NETIF(ip1, ip2, ip3, ip4, nm1, nm2, nm3, nm4, outputfunc)
Instantiating macro for a uIP network interface.
void tcpip_input(void)
Deliver an incoming packet to the TCP/IP stack.
Representation of a uIP network interface.
#define PROCESS_BEGIN()
Define the beginning of a process.
uip_ipaddr_t ipaddr
The IP address of this interface.
#define NULL
The null pointer.
#define UIP_BUFSIZE
The size of the uIP packet buffer.
void uip_arp_init(void)
Initialize the ARP module.
#define PROCESS_THREAD(name, ev, data)
Define the body of a process.
#define PROCESS_END()
Define the end of a process.
Macros and definitions for the ARP module.
CCIF uint16_t uip_htons(uint16_t val)
Convert a 16-bit quantity from host byte order to network byte order.
#define PROCESS_WAIT_EVENT()
Wait for an event to be posted to the process.
void uip_fw_default(struct uip_fw_netif *netif)
Register a default network interface.
#define PROCESS(name, strname)
Declare a process.
void process_start(struct process *p, process_data_t data)
Start a process.
#define UIP_FW_OK
A non-error message that indicates that something went OK.
void uip_arp_arpin(void)
ARP processing for incoming IP packets.