Hi,
ich hab auf einem Mikrocontroller den Lwip-Stack am laufen.
Es handelt sich dabei um eine Beispielapplikation mit einer
Webserveranwendung. Mit dem Wireshark Tool kann ich den Netzwerkverkeher
mitprotokollieren. Ich möchte nun zum Beispiel den Inhalt vom ARP
Telegramm auf dem Mikrocontroller debuggen. Ich weiss allerdings nicht
wo die Daten genau ankommen. In der ethermacif_input Funktion kann ich
zwar die Mac Adresse auslesen, aber Daten sehe ich da nicht.
Ich möchte den Hardware type, Protocol type, Hardware size, Protocol
size, Opcode usw. auslesen können.
1 | static void
|
2 | ethermacif_input(struct netif *netif)
|
3 | {
|
4 | struct pbuf *p = (struct pbuf *)0;
|
5 | u16_t idx;
|
6 | static u16_t recv_len;
|
7 | u8_t* recv_buf;
|
8 |
|
9 | /* Read Packet */
|
10 | while( (recv_len=ether_get_recv_len()) > 0 ) {
|
11 | p = pbuf_alloc(PBUF_LINK, (u16_t)recv_len , PBUF_POOL);
|
12 | if (p == (struct pbuf *)0) {
|
13 | /* Error */
|
14 | // not support
|
15 | DBG_PRINT(("PBUF ERROR\n"));
|
16 | }
|
17 | recv_buf = (u8_t*)ether_recv();
|
18 | eth_memcpy( p->payload , recv_buf , recv_len );
|
19 |
|
20 | /* points to packet payload, which starts with an Ethernet header */
|
21 | idx = htons(((struct eth_hdr *)p->payload)->type);
|
22 | if (idx == ETHTYPE_IP) {
|
23 | /* IP packet */
|
24 | /* update ARP table */
|
25 | etharp_ip_input(netif, p);
|
26 | /* skip Ethernet header */
|
27 | pbuf_header(p, -14);
|
28 | /* pass to network layer */
|
29 | netif->input(p, netif);
|
30 | } else if (idx == ETHTYPE_ARP) {
|
31 | /* ARP packet */
|
32 | /* pass p to ARP module */
|
33 | etharp_arp_input(netif, (struct eth_addr *)netif->hwaddr, p);
|
34 | } else {
|
35 | /* unsupported Ethernet packet type */
|
36 | /* free pbuf */
|
37 | pbuf_free(p);
|
38 | p = (struct pbuf *)0;
|
39 | }
|
40 | }
|
41 | }
|