6e53e46db2b0d59606c6573ecd1a688acf41046c
[cascardo/ovs.git] / datapath-windows / ovsext / Mpls.h
1 /*
2  * Copyright (c) 2015 Cloudbase Solutions Srl
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __MPLS_H_
18 #define __MPLS_H_ 1
19
20 #include "precomp.h"
21 #include "Ethernet.h"
22
23 /*
24  * MPLS definitions
25  */
26 #define FLOW_MAX_MPLS_LABELS    3
27
28 #define MPLS_HLEN               4
29 #define MPLS_BOS_MASK           0x00000100
30
31 /* Reference: RFC 5462, RFC 3032
32  *
33  *  0                   1                   2                   3
34  *  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
35  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36  * |                Label                  | TC  |S|       TTL     |
37  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38  *
39  *      Label:  Label Value, 20 bits
40  *      TC:     Traffic Class field, 3 bits
41  *      S:      Bottom of Stack, 1 bit
42  *      TTL:    Time to Live, 8 bits
43  */
44
45 typedef struct MPLSHdr {
46     ovs_be32 lse;
47 } MPLSHdr;
48
49 __inline BOOLEAN
50 OvsEthertypeIsMpls(ovs_be16 ethertype)
51 {
52     return ethertype == htons(ETH_TYPE_MPLS) ||
53            ethertype == htons(ETH_TYPE_MPLS_MCAST);
54 }
55
56 #endif /* __MPLS_H_ */