summaryrefslogtreecommitdiff
path: root/cesar/common/defs
diff options
context:
space:
mode:
authorThierry Carré2012-02-14 16:32:05 +0100
committerThierry Carré2012-03-02 13:42:48 +0100
commit18817dacd0549423789aa4dc6ad04a98a2e700e4 (patch)
tree84bbdf457cd6b04e0099e220a191625cb08a10dc /cesar/common/defs
parent0b664733c01c6c1cc23fde6730612951b21cc9a4 (diff)
cesar: redefine many size about ethernet packet, closes #2900
- Add the difference between a packet tagged or not (simple vlan). - Check the length of the last mme of vs_get_pb_stats.cnf (#2900). - Split in 2 fields the vlan_tag in cp_mme_peer, useful for new macro. - Write the HPAV_MTYPE_MME in little endian, and so remove many swap16. This commit prepare the work to do for #2894 (strongly linked)
Diffstat (limited to 'cesar/common/defs')
-rw-r--r--cesar/common/defs/ethernet.h63
-rw-r--r--cesar/common/defs/homeplugAV.h63
2 files changed, 93 insertions, 33 deletions
diff --git a/cesar/common/defs/ethernet.h b/cesar/common/defs/ethernet.h
index 2ca1fe8cbc..1defcbb61f 100644
--- a/cesar/common/defs/ethernet.h
+++ b/cesar/common/defs/ethernet.h
@@ -13,21 +13,70 @@
* \ingroup common_defs
*
* Based on the norme 802.3
+ * Information: chapter 12.3.2.1.1 in homeplugav specification.
*/
/** Ethernet Mac Address size. */
#define ETH_MAC_ADDRESS_SIZE 6
-/** Ethernet packet minimum size. */
-#define ETH_PACKET_MIN_SIZE 60
+/** Define the Ethernet type for one VLAN, in little endian */
+#define ETH_TYPE_VLAN 0x0081
-/** Ethernet packet maximum size. */
-#define ETH_PACKET_MAX_SIZE 1518
+/** Define the MTYPE size. */
+#define ETH_TYPE_SIZE 2
/** Ethernet VLAN Tag complete size. */
-#define ETH_VLAN_TAG_SIZE 4
+#define ETH_VLANTAG_SIZE 4
-/** Ethernet Minimum size allowed. */
-#define ETH_PACKET_MIN_SIZE_ALLOWED 14
+/** Vlan size returned depend of the eth_type.
+ * eth_type must be in little endian (no swap16 so). */
+#define ETH_GET_VLANTAG_SIZE(a) \
+ ((a) == (ETH_TYPE_VLAN) ? ETH_VLANTAG_SIZE : 0)
+
+/** Macro which return true, if a simple vlan is detected. */
+#define ETH_IS_VLANTAG(a) \
+ ((a) == (ETH_TYPE_VLAN) ? true : false)
+
+/** Ethernet packet minimum payload size. */
+#define ETH_PACKET_MIN_PAYLOAD_SIZE 46
+
+/** Ethernet packet maximum payload size. */
+#define ETH_PACKET_MAX_PAYLOAD_SIZE 1500
+
+/** Define the ethernet type offset (=12). */
+#define ETH_TYPE_OFFSET ((ETH_MAC_ADDRESS_SIZE)*2)
+
+/** Ethernet minimum size allowed (=14). */
+#define ETH_PACKET_MIN_SIZE_ALLOWED (ETH_TYPE_OFFSET + ETH_TYPE_SIZE)
+
+/** Ethernet packet minimum size without vlan (=60). */
+#define ETH_PACKET_MIN_NOVLAN_SIZE (ETH_PACKET_MIN_SIZE_ALLOWED \
+ + ETH_PACKET_MIN_PAYLOAD_SIZE)
+
+/** Ethernet packet minimum size with one vlan (=64). */
+#define ETH_PACKET_MIN_VLAN_SIZE (ETH_PACKET_MIN_NOVLAN_SIZE \
+ + ETH_VLANTAG_SIZE)
+
+/** Ethernet packet minimum of minimum size. */
+#define ETH_PACKET_MIN_SIZE (ETH_PACKET_MIN_NOVLAN_SIZE)
+
+/** Ethernet packet maximum size without vlan (=1514). */
+#define ETH_PACKET_MAX_NOVLAN_SIZE (ETH_PACKET_MIN_SIZE_ALLOWED \
+ + ETH_PACKET_MAX_PAYLOAD_SIZE)
+
+/** Ethernet packet maximum size with one vlan (=1518). */
+#define ETH_PACKET_MAX_VLAN_SIZE (ETH_PACKET_MAX_NOVLAN_SIZE \
+ + ETH_VLANTAG_SIZE)
+
+/** Ethernet packet maximum size. Useful for buffer. */
+#define ETH_PACKET_MAX_SIZE (ETH_PACKET_MAX_VLAN_SIZE)
+
+/** Return ethernet packet min size. */
+#define ETH_PACKET_GET_MIN_SIZE(eth_type) \
+ (ETH_PACKET_MIN_NOVLAN_SIZE + ETH_GET_VLANTAG_SIZE(eth_type))
+
+/** Return ethernet packet max size. */
+#define ETH_PACKET_GET_MAX_SIZE(eth_type) \
+ (ETH_PACKET_MAX_NOVLAN_SIZE + ETH_GET_VLANTAG_SIZE(eth_type))
#endif /* common_defs_ethernet_h */
diff --git a/cesar/common/defs/homeplugAV.h b/cesar/common/defs/homeplugAV.h
index a81d9d4cb4..10e2960864 100644
--- a/cesar/common/defs/homeplugAV.h
+++ b/cesar/common/defs/homeplugAV.h
@@ -16,48 +16,59 @@
*/
#include "common/defs/ethernet.h"
-/** Define the MTYPE for MME. */
-#define HPAV_MTYPE_MME 0x88E1
-/** Define the MTYPE size. */
-#define HPAV_MTYPE_SIZE 2
-/** Define the mtype offset where it is if the vlan is not present. */
-#define HPAV_MTYPE_OFFSET 12
-/** The vlan tag size in bytes. */
-#define HPAV_VLANTAG_SIZE 4
-/** Define the offset of the MMTYPE when the vlan is not present. */
-#define HPAV_MMTYPE_OFFSET 15
+/** Define the MTYPE for MME, in little endian.*/
+#define HPAV_MTYPE_MME 0xE188
+
+/** Define the MTYPE size for MME.
+ * Chapter 11.1.4 in homeplugav specification. */
+#define HPAV_MTYPE_SIZE (ETH_TYPE_SIZE)
+
+/** Define MMV Size. */
+#define HPAV_MMV_SIZE 1
+
+/** Define MMTYPE size. */
+#define HPAV_MMTYPE_SIZE 2
+
+/** Define FMI Size. */
+#define HPAV_FMI_SIZE 2
+
+/** Define the MTYPE offset for MME. */
+#define HPAV_GET_MTYPE_OFFSET(eth_type) \
+ (ETH_TYPE_OFFSET + ETH_GET_VLANTAG_SIZE(eth_type))
+
+/** Define the offset of the MMTYPE. */
+#define HPAV_GET_MMTYPE_OFFSET(eth_type) \
+ (ETH_PACKET_MIN_SIZE_ALLOWED + HPAV_MMV_SIZE + \
+ ETH_GET_VLANTAG_SIZE(eth_type))
/** Define the amount max of fragmented message. value coded on 4 bits */
#define HPAV_MME_FRAG_MAX 16
-/** Max payload size in bytes without vlan (= 1499). */
-#define HPAV_MME_PAYLOAD_MAX_SIZE_WITHOUT_VLAN \
- (ETH_PACKET_MAX_SIZE - HPAV_MME_HEADER)
-
/** MMV version for the MME HomePlug 1.0 see section 11.1.5 */
#define HPAV_MMV0 0x0
/** MMV version for the MME HomePlug 1.1 see section 11.1.5 */
#define HPAV_MMV1 0x1
/** MMV version max for MME HomePlug. */
#define HPAV_MMV_MAX HPAV_MMV1
-
/** Define the MMV default type for HPAV. */
#define HPAV_MMV HPAV_MMV1
-/** Define MMV Size. */
-#define HPAV_MMV_SIZE 1
-
-/** Define length of the MME HEADER with Vlan tag. */
-#define HPAV_MME_HEADER_LEN_WITH_VLAN 23
+/** Define length of the MME HEADER without Vlan tag (=19). */
+#define HPAV_MME_HEADER (ETH_PACKET_MIN_SIZE_ALLOWED \
+ + HPAV_MMV_SIZE \
+ + HPAV_MMTYPE_SIZE \
+ + HPAV_FMI_SIZE )
-/** Define length of the MME HEADER without Vlan tag. */
-#define HPAV_MME_HEADER 19
+/** Max MME payload size in bytes, with or without vlan (= 1495). */
+#define HPAV_MME_PAYLOAD_MAX_SIZE (ETH_PACKET_MAX_NOVLAN_SIZE \
+ - HPAV_MME_HEADER)
-/** Define MMTYPE size. */
-#define HPAV_MMTYPE_SIZE 2
+/** Return TRUE if the mmtype is a Vendor Specific (VS). */
+#define HPAV_MMTYPE_IS_VS(mmtype) \
+ ((mmtype) >= VS_MIN && (mmtype) <= VS_MAX)
-/** Define FMI Size. */
-#define HPAV_FMI_SIZE 2
+/** Max VS MME payload size in bytes, with or without vlan (= 1492). */
+#define HPAV_VS_MME_PAYLOAD_MAX (HPAV_MME_PAYLOAD_MAX_SIZE - OUI_SIZE)
/** CRC Data. */
#define HPAV_CRC32_GENERATOR 0x04c11db7