]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
ETHARP_SUPPORT_VLAN: add support for an external VLAN filter function instead of...
authorSimon Goldschmidt <goldsimon@gmx.de>
Tue, 26 Jul 2011 19:03:27 +0000 (21:03 +0200)
committerSimon Goldschmidt <goldsimon@gmx.de>
Tue, 26 Jul 2011 19:03:27 +0000 (21:03 +0200)
CHANGELOG
src/include/lwip/opt.h
src/netif/etharp.c

index 42cf341a37a2626a1dc49c883aec22f07750766b..e31b298587a0ecb65b9f081601a1e748b78eeffe 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,10 @@ HISTORY
 
  ++ New features:
 
+  2011-08-26: Simon Goldschmidt
+  * etharp.c: ETHARP_SUPPORT_VLAN: add support for an external VLAN filter
+    function instead of only checking for one VLAN (define ETHARP_VLAN_CHECK_FN)
+
   2011-07-21: Simon Goldschmidt (patch by hanhui)
   * ip4.c, etharp.c, pbuf.h: bug #33634 ip_forward() have a faulty behaviour:
     Added pbuf flags to mark incoming packets as link-layer broadcast/multicast.
index f4647b64f62bda09b08ecaed3ab1757b86356777..8ae6ba4d58df5489a0cb411c64daa5fda4f03f53 100644 (file)
  * Additionally, you can define ETHARP_VLAN_CHECK to an u16_t VLAN ID to check.
  * If ETHARP_VLAN_CHECK is defined, only VLAN-traffic for this VLAN is accepted.
  * If ETHARP_VLAN_CHECK is not defined, all traffic is accepted.
+ * Alternatively, define a function/define ETHARP_VLAN_CHECK_FN(eth_hdr, vlan)
+ * that returns 1 to accept a packet or 0 to drop a packet.
  */
 #ifndef ETHARP_SUPPORT_VLAN
 #define ETHARP_SUPPORT_VLAN             0
index f2b87e27254202167a845581d83c123f02c85108..8b333dd90e7a07ae0f3f4cc4421b340613f76d6f 100644 (file)
@@ -1297,13 +1297,17 @@ ethernet_input(struct pbuf *p, struct netif *netif)
       ETHARP_STATS_INC(etharp.drop);
       goto free_and_return;
     }
-#ifdef ETHARP_VLAN_CHECK /* if not, allow all VLANs */
+#if defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) /* if not, allow all VLANs */
+#ifdef ETHARP_VLAN_CHECK_FN
+    if (!ETHARP_VLAN_CHECK_FN(ethhdr, vlan)) {
+#elif defined(ETHARP_VLAN_CHECK)
     if (VLAN_ID(vlan) != ETHARP_VLAN_CHECK) {
+#endif
       /* silently ignore this packet: not for our VLAN */
       pbuf_free(p);
       return ERR_OK;
     }
-#endif /* ETHARP_VLAN_CHECK */
+#endif /* defined(ETHARP_VLAN_CHECK) || defined(ETHARP_VLAN_CHECK_FN) */
     type = vlan->tpid;
     ip_hdr_offset = SIZEOF_ETH_HDR + SIZEOF_VLAN_HDR;
   }