0001
0002 #ifndef __LINUX_PIM_H
0003 #define __LINUX_PIM_H
0004
0005 #include <linux/skbuff.h>
0006 #include <asm/byteorder.h>
0007
0008
0009 #define PIM_V1_VERSION cpu_to_be32(0x10000000)
0010 #define PIM_V1_REGISTER 1
0011
0012
0013 #define PIM_VERSION 2
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 enum {
0034 PIM_TYPE_HELLO,
0035 PIM_TYPE_REGISTER,
0036 PIM_TYPE_REGISTER_STOP,
0037 PIM_TYPE_JOIN_PRUNE,
0038 PIM_TYPE_BOOTSTRAP,
0039 PIM_TYPE_ASSERT,
0040 PIM_TYPE_GRAFT,
0041 PIM_TYPE_GRAFT_ACK,
0042 PIM_TYPE_CANDIDATE_RP_ADV
0043 };
0044
0045 #define PIM_NULL_REGISTER cpu_to_be32(0x40000000)
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055 struct pimhdr {
0056 __u8 type;
0057 __u8 reserved;
0058 __be16 csum;
0059 };
0060
0061
0062 struct pimreghdr {
0063 __u8 type;
0064 __u8 reserved;
0065 __be16 csum;
0066 __be32 flags;
0067 };
0068
0069 int pim_rcv_v1(struct sk_buff *skb);
0070
0071 static inline bool ipmr_pimsm_enabled(void)
0072 {
0073 return IS_BUILTIN(CONFIG_IP_PIMSM_V1) || IS_BUILTIN(CONFIG_IP_PIMSM_V2);
0074 }
0075
0076 static inline struct pimhdr *pim_hdr(const struct sk_buff *skb)
0077 {
0078 return (struct pimhdr *)skb_transport_header(skb);
0079 }
0080
0081 static inline u8 pim_hdr_version(const struct pimhdr *pimhdr)
0082 {
0083 return pimhdr->type >> 4;
0084 }
0085
0086 static inline u8 pim_hdr_type(const struct pimhdr *pimhdr)
0087 {
0088 return pimhdr->type & 0xf;
0089 }
0090
0091
0092 static inline bool pim_ipv4_all_pim_routers(__be32 addr)
0093 {
0094 return addr == htonl(0xE000000D);
0095 }
0096 #endif