1
- From 337d268fa4701e10cec14bedb9732d049ff3e387 Mon Sep 17 00:00:00 2001
1
+ From 3dd5f871c118cdbc98c6068165a7eeef4ac5d245 Mon Sep 17 00:00:00 2001
2
2
From: =?UTF-8?q?Fredrik=20M=C3=B6ller?= <
[email protected] >
3
3
Date: Tue, 15 Sep 2020 18:22:53 +0200
4
4
Subject: [PATCH] rtkernel for Profinet
@@ -12,6 +12,12 @@ stack:
12
12
- Fix SNMP ifDescr in ifTable.
13
13
- Discard invalid UDP packets.
14
14
- VLAN tag support.
15
+ - Lock mutex while handling received frame
16
+ instead of passing message to lwip thread
17
+ (LWIP_TCPIP_CORE_LOCKING_INPUT).
18
+ - Add hook function to be called when frame of
19
+ unknown EtherType is received, such as LLDP
20
+ and Profinet (LWIP_HOOK_UNKNOWN_ETH_PROTOCOL).
15
21
- bsp/xmc48relax:
16
22
- Static IP addressing.
17
23
- Increase stack size for main task.
@@ -26,12 +32,16 @@ stack:
26
32
lwip/src/apps/snmp/Makefile | 16 ++
27
33
lwip/src/apps/snmp/snmp_mib2_interfaces.c | 6 +-
28
34
lwip/src/apps/snmp/snmp_mib2_system.c | 309 ++--------------------
35
+ lwip/src/core/lwip_hooks.c | 23 ++
29
36
lwip/src/core/udp.c | 12 +
30
37
lwip/src/include/lwip/apps/snmp_mib2.h | 24 +-
31
- lwip/src/include/lwip/lwipopts.h | 23 +-
32
- 11 files changed, 133 insertions(+), 309 deletions(-)
38
+ lwip/src/include/lwip/lwip_hooks.h | 41 +++
39
+ lwip/src/include/lwip/lwipopts.h | 39 ++-
40
+ 13 files changed, 213 insertions(+), 309 deletions(-)
33
41
create mode 100644 lwip/src/apps/Makefile
34
42
create mode 100644 lwip/src/apps/snmp/Makefile
43
+ create mode 100644 lwip/src/core/lwip_hooks.c
44
+ create mode 100644 lwip/src/include/lwip/lwip_hooks.h
35
45
36
46
diff --git a/bsp/xmc48relax/include/config.h b/bsp/xmc48relax/include/config.h
37
47
index 850ce674..07d80b1e 100644
@@ -567,6 +577,35 @@ index 90e57805..0242ce5c 100644
567
577
}
568
578
569
579
static const struct snmp_scalar_array_node_def system_nodes[] = {
580
+ diff --git a/lwip/src/core/lwip_hooks.c b/lwip/src/core/lwip_hooks.c
581
+ new file mode 100644
582
+ index 00000000..ad6229f8
583
+ --- /dev/null
584
+ +++ b/lwip/src/core/lwip_hooks.c
585
+ @@ -0,0 +1,23 @@
586
+ + #include "lwip/lwip_hooks.h"
587
+ +
588
+ + #ifdef LWIP_HOOK_UNKNOWN_ETH_PROTOCOL
589
+ + static netif_input_fn lwip_hook_for_unknown_eth_protocol;
590
+ +
591
+ + err_enum_t lwip_hook_unknown_eth_protocol(struct pbuf *pbuf, struct netif *netif)
592
+ + {
593
+ + if(lwip_hook_for_unknown_eth_protocol == NULL)
594
+ + {
595
+ + /* Not handled. User needs to free pbuf */
596
+ + return ERR_IF;
597
+ + }
598
+ + else
599
+ + {
600
+ + return lwip_hook_for_unknown_eth_protocol(pbuf, netif);
601
+ + }
602
+ + }
603
+ +
604
+ + void lwip_set_hook_for_unknown_eth_protocol(struct netif *netif, netif_input_fn hook)
605
+ + {
606
+ + lwip_hook_for_unknown_eth_protocol = hook;
607
+ + }
608
+ + #endif /* LWIP_HOOK_UNKNOWN_ETH_PROTOCOL */
570
609
diff --git a/lwip/src/core/udp.c b/lwip/src/core/udp.c
571
610
index ce2e3d29..7946cb05 100644
572
611
--- a/lwip/src/core/udp.c
@@ -625,11 +664,62 @@ index 2f4a6893..1df6bb0d 100644
625
664
626
665
#endif /* SNMP_LWIP_MIB2 */
627
666
#endif /* LWIP_SNMP */
667
+ diff --git a/lwip/src/include/lwip/lwip_hooks.h b/lwip/src/include/lwip/lwip_hooks.h
668
+ new file mode 100644
669
+ index 00000000..c48f1c57
670
+ --- /dev/null
671
+ +++ b/lwip/src/include/lwip/lwip_hooks.h
672
+ @@ -0,0 +1,41 @@
673
+ + /**
674
+ + * Hook functions
675
+ + *
676
+ + * Declares hook functions called by lwip.
677
+ + * Also declared API for configuring hook functions.
678
+ + *
679
+ + * The name of this file is specified as LWIP_HOOK_FILENAME in lwipopts.h.
680
+ + */
681
+ +
682
+ + #ifndef LWIP_HOOKS_H
683
+ + #define LWIP_HOOKS_H
684
+ +
685
+ + #include "lwip/netif.h"
686
+ +
687
+ + /**
688
+ + * LWIP_HOOK_UNKNOWN_ETH_PROTOCOL
689
+ + *
690
+ + * Called from ethernet_input() when an unknown eth type is encountered.
691
+ + *
692
+ + * By default, this will do nothing and return ERR_IF.
693
+ + * If a hook function has been set in lwip_set_hook_for_unknown_eth_protocol(),
694
+ + * then that function will be called.
695
+ + *
696
+ + * \param pbuf Payload points to ethernet header!
697
+ + * \param netif Network interface.
698
+ + * \return ERR_OK if packet is accepted and freed,
699
+ + * ERR_IF otherwise.
700
+ + */
701
+ + err_enum_t lwip_hook_unknown_eth_protocol(struct pbuf *pbuf, struct netif *netif);
702
+ +
703
+ + /**
704
+ + * Configure function to be called by lwip_hook_unknown_eth_protocol()
705
+ + *
706
+ + *\param netif Network interface.
707
+ + *\param hook Hook function to be called when frame with unknown eth type
708
+ + * is encountered. Should return ERR_OK for accepted and freed
709
+ + * frames, ERR_IF otherwise.
710
+ + */
711
+ + void lwip_set_hook_for_unknown_eth_protocol(struct netif *netif, netif_input_fn hook);
712
+ +
713
+ + #endif /* LWIP_HOOKS_H */
628
714
diff --git a/lwip/src/include/lwip/lwipopts.h b/lwip/src/include/lwip/lwipopts.h
629
- index c48a69b7..941e6f9c 100644
715
+ index c48a69b7..c3fdf058 100644
630
716
--- a/lwip/src/include/lwip/lwipopts.h
631
717
+++ b/lwip/src/include/lwip/lwipopts.h
632
- @@ -49,7 +49,12 @@
718
+ @@ -46,10 +46,31 @@
719
+ #define LWIP_NETIF_LINK_CALLBACK 1
720
+ #define LWIP_NETIF_STATUS_CALLBACK 1
721
+ #define LWIP_NETIF_LOOPBACK 1
722
+ + #define LWIP_TCPIP_CORE_LOCKING_INPUT 1
633
723
#define LWIP_SOCKET 1
634
724
#define LWIP_IGMP 1
635
725
#define LWIP_TCP_KEEPALIVE 1
@@ -639,10 +729,25 @@ index c48a69b7..941e6f9c 100644
639
729
+ #define MIB2_STATS 1
640
730
#define SO_REUSE 1
641
731
+ #define ETHARP_SUPPORT_VLAN 1
732
+ +
733
+ + /**
734
+ + * LWIP_HOOK_FILENAME: Custom filename to #include in files that provide hooks.
735
+ + * Declare your hook function prototypes in there, you may also #include all headers
736
+ + * providing data types that are need in this file.
737
+ + */
738
+ + #define LWIP_HOOK_FILENAME "lwip/lwip_hooks.h"
739
+ +
740
+ + /**
741
+ + * LWIP_HOOK_UNKNOWN_ETH_PROTOCOL(pbuf, netif):
742
+ + * Called from ethernet_input() when an unknown eth type is encountered.
743
+ + * Return ERR_OK if packet is accepted, any error code otherwise.
744
+ + * Payload points to ethernet header!
745
+ + */
746
+ + #define LWIP_HOOK_UNKNOWN_ETH_PROTOCOL lwip_hook_unknown_eth_protocol
642
747
643
748
/**
644
749
* LWIP_DHCP_AUTOIP_COOP_TRIES: Set to the number of DHCP DISCOVER probes
645
- @@ -60,20 +65 ,33 @@
750
+ @@ -60,20 +81 ,33 @@
646
751
*/
647
752
#define LWIP_DHCP_AUTOIP_COOP_TRIES 2
648
753
@@ -677,15 +782,15 @@ index c48a69b7..941e6f9c 100644
677
782
/* Mailbox sizes */
678
783
#define TCPIP_MBOX_SIZE 128
679
784
#define DEFAULT_RAW_RECVMBOX_SIZE 5
680
- @@ -106,6 +124 ,7 @@
785
+ @@ -106,6 +140 ,7 @@
681
786
* LWIP_DBG_OFF
682
787
* LWIP_DBG_ON
683
788
*/
684
789
+ #define PBUF_DEBUG LWIP_DBG_OFF
685
790
#define IP_DEBUG LWIP_DBG_OFF
686
791
#define IGMP_DEBUG LWIP_DBG_OFF
687
792
#define TCPIP_DEBUG LWIP_DBG_OFF
688
- @@ -120,5 +139 ,7 @@
793
+ @@ -120,5 +155 ,7 @@
689
794
#define TCP_FR_DEBUG LWIP_DBG_OFF
690
795
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
691
796
#define TCP_RST_DEBUG LWIP_DBG_OFF
0 commit comments