📄 ipv4.h
字号:
#define RTCF_FAST 0x00200000#define RTCF_MASQ 0x00400000#define RTCF_SNAT 0x00800000#define RTCF_DOREDIRECT 0x01000000#define RTCF_DIRECTSRC 0x04000000#define RTCF_DNAT 0x08000000#define RTCF_BROADCAST 0x10000000#define RTCF_MULTICAST 0x20000000#define RTCF_REJECT 0x40000000#define RTCF_LOCAL 0x80000000#define RTCF_NAT (RTCF_DNAT|RTCF_SNAT)#define RT_TOS(tos) ((tos)&IPTOS_TOS_MASK)/* flow */struct flowi { int oif; int iif; union { struct { __u32 daddr; __u32 saddr; __u32 fwmark; __u8 tos; __u8 scope; } ip4_u;#if 0 struct { struct in6_addr daddr; struct in6_addr saddr; __u32 flowlabel; } ip6_u;#endif struct { __u16 daddr; __u16 saddr; __u32 fwmark; __u8 scope; } dn_u; } nl_u;#define fld_dst nl_u.dn_u.daddr#define fld_src nl_u.dn_u.saddr#define fld_fwmark nl_u.dn_u.fwmark#define fld_scope nl_u.dn_u.scope#define fl6_dst nl_u.ip6_u.daddr#define fl6_src nl_u.ip6_u.saddr#define fl6_flowlabel nl_u.ip6_u.flowlabel#define fl4_dst nl_u.ip4_u.daddr#define fl4_src nl_u.ip4_u.saddr#define fl4_fwmark nl_u.ip4_u.fwmark#define fl4_tos nl_u.ip4_u.tos#define fl4_scope nl_u.ip4_u.scope __u8 proto; __u8 flags; union { struct { __u16 sport; __u16 dport; } ports; struct { __u8 type; __u8 code; } icmpt; struct { __u16 sport; __u16 dport; __u8 objnum; __u8 objnamel; /* Not 16 bits since max val is 16 */ __u8 objname[16]; /* Not zero terminated */ } dnports; __u32 spi; } uli_u;#define fl_ip_sport uli_u.ports.sport#define fl_ip_dport uli_u.ports.dport#define fl_icmp_type uli_u.icmpt.type#define fl_icmp_code uli_u.icmpt.code#define fl_ipsec_spi uli_u.spi} __attribute__((__aligned__(BITS_PER_LONG/8)));#define FLOW_DIR_IN 0#define FLOW_DIR_OUT 1#define FLOW_DIR_FWD 2/* rtable.h */struct rtable{ union { struct dst_entry dst; struct rtable *rt_next; } u; unsigned rt_flags; unsigned rt_type; __u32 rt_dst; /* Path destination */ __u32 rt_src; /* Path source */ int rt_iif; /* Info on neighbour */ __u32 rt_gateway; /* Cache lookup keys */ struct flowi fl;#ifdef CONFIG_IP_ROUTE_NAT __u32 rt_src_map; __u32 rt_dst_map;#endif};void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk);/* fib */enum{ RTN_UNSPEC, RTN_UNICAST, /* Gateway or direct route */ RTN_LOCAL, /* Accept locally */ RTN_BROADCAST, /* Accept locally as broadcast, send as broadcast */ RTN_ANYCAST, /* Accept locally as broadcast, but send as unicast */ RTN_MULTICAST, /* Multicast route */ RTN_BLACKHOLE, /* Drop */ RTN_UNREACHABLE, /* Destination is unreachable */ RTN_PROHIBIT, /* Administratively prohibited */ RTN_THROW, /* Not in this table */ RTN_NAT, /* Translate this address */ RTN_XRESOLVE, /* Use external resolver */};unsigned inet_addr_type(u32 addr);/** * entry in a routing table * TODO: gateway. */struct ipv4_route{ struct list_head entry; u32 network; u32 netmask; struct net_device *interface; u32 gateway;};/* the routing table */extern struct list_head routes;/* routing cache - dst_entries for each skb */extern struct rtable *rcache;/* address data attached to a device */struct in_ifaddr { struct in_ifaddr *ifa_next; struct in_device *ifa_dev; u32 ifa_local; u32 ifa_address; u32 ifa_mask; u32 ifa_broadcast;};/* ipv4-specific extension for an interface *//* struct ipv4_if_ext { */struct in_device { struct net_device *dev; struct in_ifaddr *ifa_list; /* struct in_addr addr; unsigned char netmask; struct in_addr broadcast; */};static inline unsigned int netmask_bits(uint32_t netmask){ int maskbits = 32; int bit = 0; while (!((netmask << (bit++)) & 0x80000000)) { maskbits--; } return maskbits;}extern const char *inet_ntoa(struct in_addr);extern int inet_aton(const char *cp, struct in_addr *inp);static inline int inet_atou32(const char *cp, uint32_t *addr){ return inet_aton(cp, (struct in_addr *)addr);}static inline const char *inet_u32toa(uint32_t addr){ struct in_addr inaddr; inaddr.s_addr = addr; return inet_ntoa(inaddr);} int register_inetaddr_notifier(struct notifier_block *nb);int unregister_inetaddr_notifier(struct notifier_block *nb);int __call_inetaddr_notifier(unsigned long, struct in_ifaddr *ifa);static inline int register_netdevice_notifier(struct notifier_block *nb){ return 0;}#define unregister_netdevice_notifier(notifier)u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope);int ip_route_me_harder(struct sk_buff **pskb);int ip_route(struct sk_buff *skb);int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*));enum ip_defrag_users{ IP_DEFRAG_LOCAL_DELIVER, IP_DEFRAG_CALL_RA_CHAIN, IP_DEFRAG_CONNTRACK_IN, IP_DEFRAG_CONNTRACK_OUT, IP_DEFRAG_NAT_OUT, IP_DEFRAG_VS_IN, IP_DEFRAG_VS_OUT, IP_DEFRAG_VS_FWD};#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)struct sk_buff *ip_defrag(struct sk_buff *skb);#elsestruct sk_buff *ip_defrag(struct sk_buff *skb, u32 user);#endifvoid ipfrag_flush(void);void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info);int ip_finish_output(struct sk_buff *skb);void ip_send_check(struct iphdr *iph);unsigned short ip_fast_csum(void * iph, unsigned int ihl);/* unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl); */unsigned int csum_fold(unsigned int sum);unsigned int csum_partial(const void * buff, int len, unsigned int sum);/* unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum); */unsigned short csum_tcpudp_magic(unsigned long saddr, unsigned long daddr, unsigned short len, unsigned short proto, unsigned int sum);u32 csum_tcpudp_nofold(unsigned long saddr, unsigned long daddr, unsigned short len, unsigned short proto, unsigned int sum);uint16_t tcp_v4_check(struct tcphdr *th, int len, unsigned long saddr, unsigned long daddr, unsigned long base);static inline int xrlim_allow(struct dst_entry *dst, int timeout){ return 1;}/* routing */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)struct rt_key { __u32 src, dst; __u8 tos; __u32 oif;};int ip_route_output_key(struct rtable **rp, struct rt_key *key);/* Deprecated: use ip_route_output_key directly */static inline int ip_route_output(struct rtable **rp, u32 daddr, u32 saddr, u32 tos, int oif){ struct rt_key key = { dst:daddr, src:saddr, oif:oif, tos:tos }; return ip_route_output_key(rp, &key);}#elseint ip_route_output_key(struct rtable **rp, struct flowi *flp);#endifint xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, struct sock *sk, int flags);int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr, u8 tos, struct net_device *dev);char *ipv4_describe_packet(struct sk_buff *skb);void add_route_for_device(struct in_device *indev);inline unsigned short ip_compute_csum(unsigned char * buff, int len);#define IPT_DSCP_MASK 0xfc#define IPT_DSCP_SHIFT 2#define IPT_DSCP_MAX 0x3f#endif /* __HAVE_IPV4_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -