mpls.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2014 Nicira, Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of version 2 of the GNU General Public
  6. * License as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. */
  13. #ifndef _NET_MPLS_H
  14. #define _NET_MPLS_H 1
  15. #include <linux/if_ether.h>
  16. #include <linux/netdevice.h>
  17. #define MPLS_HLEN 4
  18. static inline bool eth_p_mpls(__be16 eth_type)
  19. {
  20. return eth_type == htons(ETH_P_MPLS_UC) ||
  21. eth_type == htons(ETH_P_MPLS_MC);
  22. }
  23. /*
  24. * For non-MPLS skbs this will correspond to the network header.
  25. * For MPLS skbs it will be before the network_header as the MPLS
  26. * label stack lies between the end of the mac header and the network
  27. * header. That is, for MPLS skbs the end of the mac header
  28. * is the top of the MPLS label stack.
  29. */
  30. static inline unsigned char *skb_mpls_header(struct sk_buff *skb)
  31. {
  32. return skb_mac_header(skb) + skb->mac_len;
  33. }
  34. #endif