📄 kernelenv.h
字号:
#define NETDEV_CHANGEMTU 0x0007#define NETDEV_CHANGEADDR 0x0008#define NETDEV_GOING_DOWN 0x0009#define NETDEV_CHANGENAME 0x000A/* ip.h */struct ip_options { __u32 faddr; /* Saved first hop address */ unsigned char optlen; unsigned char srr; unsigned char rr; unsigned char ts; unsigned char is_setbyuser:1, /* Set by setsockopt? */ is_data:1, /* Options in __data, rather than skb */ is_strictroute:1, /* Strict source route */ srr_is_hit:1, /* Packet destination addr was our one */ is_changed:1, /* IP checksum more not valid */ rr_needaddr:1, /* Need to record addr of outgoing dev */ ts_needtime:1, /* Need to record timestamp */ ts_needaddr:1; /* Need to record addr of outgoing dev */ unsigned char router_alert; unsigned char __pad1; unsigned char __pad2; unsigned char __data[0];};struct inet_skb_parm{ struct ip_options opt; /* Compiled IP options */ unsigned char flags;#define IPSKB_MASQUERADED 1#define IPSKB_TRANSLATED 2#define IPSKB_FORWARDED 4#define IPSKB_XFRM_TUNNEL_SIZE 8};struct ipcm_cookie{ u32 addr; int oif; struct ip_options *opt;};#define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb))struct inet_sock { /* sk has to be the first two members of inet_sock */ struct sock sk; /* Socket demultiplex comparisons on incoming packets. */ __u32 daddr; /* Foreign IPv4 addr */ __u32 rcv_saddr; /* Bound local IPv4 addr */ __u16 dport; /* Destination port */ __u16 num; /* Local port */ __u32 saddr; /* Sending source */ int uc_ttl; /* Unicast TTL */ int tos; /* TOS */ unsigned cmsg_flags; struct ip_options *opt; __u16 sport; /* Source port */ unsigned char hdrincl; /* Include headers ? */ __u8 mc_ttl; /* Multicasting TTL */ __u8 mc_loop; /* Loopback */ __u8 pmtudisc; __u16 id; /* ID counter for DF pkts */ unsigned recverr : 1, freebind : 1; int mc_index; /* Multicast device index */ __u32 mc_addr;};#define inet_opt inet_sock#define inet_sk(__sk) ((struct inet_sock *)__sk)/* udp.h */#define UDP_ENCAP 100 /* Set the socket to accept encapsulated packets *//* UDP encapsulation types */#define UDP_ENCAP_ESPINUDP_NON_IKE 1 /* draft-ietf-ipsec-nat-t-ike-00/01 */#define UDP_ENCAP_ESPINUDP 2 /* draft-ietf-ipsec-udp-encaps-06 *//* rtnetlink.h */enum{ RTAX_UNSPEC,#define RTAX_UNSPEC RTAX_UNSPEC RTAX_LOCK,#define RTAX_LOCK RTAX_LOCK RTAX_MTU,#define RTAX_MTU RTAX_MTU RTAX_WINDOW,#define RTAX_WINDOW RTAX_WINDOW RTAX_RTT,#define RTAX_RTT RTAX_RTT RTAX_RTTVAR,#define RTAX_RTTVAR RTAX_RTTVAR RTAX_SSTHRESH,#define RTAX_SSTHRESH RTAX_SSTHRESH RTAX_CWND,#define RTAX_CWND RTAX_CWND RTAX_ADVMSS,#define RTAX_ADVMSS RTAX_ADVMSS RTAX_REORDERING,#define RTAX_REORDERING RTAX_REORDERING RTAX_HOPLIMIT,#define RTAX_HOPLIMIT RTAX_HOPLIMIT RTAX_INITCWND,#define RTAX_INITCWND RTAX_INITCWND RTAX_FEATURES,#define RTAX_FEATURES RTAX_FEATURES};enum rt_scope_t{ RT_SCOPE_UNIVERSE=0,};#define RTAX_MAX RTAX_FEATURES/* dst.h */struct dst_entry{ struct dst_entry *next; struct net_device *dev; unsigned long lastuse; unsigned long expires; u32 metrics[RTAX_MAX]; int error; int (*input)(struct sk_buff*); int (*output)(struct sk_buff*);#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) int pmtu;#endif#ifdef CONFIG_NET_CLS_ROUTE __u32 tclassid;#endif};u32 dst_path_metric(struct dst_entry *dst, int metric);u32 dst_pmtu(struct dst_entry *dst);#define dst_release(x)#define dst_hold(x)int dst_output(struct sk_buff *skb);int dst_input(struct sk_buff *skb);/* semaphore.h *//* We don't support generic semaphores: we use a simple talloc to track use */struct semaphore { unsigned int count; unsigned int limit;};#define DECLARE_MUTEX(name) struct semaphore name = { 1, 1 }#define down(x) __down((x),__location__)#define down_interruptible(x) __down_interruptible((x),__location__)#define up(x) __up((x),__location__)#define down_trylock(x) __down_trylock((x),__location__)void __down(struct semaphore *sem, const char *location);int __down_interruptible(struct semaphore *sem, const char *location);void __up(struct semaphore *sem, const char *location);int __down_trylock(struct semaphore *sem, const char *location);void sema_init(struct semaphore *sem, int val);/* sched.h */#define capable(x) 1#define TASK_RUNNING 0#define TASK_INTERRUPTIBLE 1#define TASK_UNINTERRUPTIBLE 2#define TASK_STOPPED 4#define TASK_ZOMBIE 8#define TASK_DEAD 16#define set_current_state(x)#define wake_up_process(x)#define current 0/* prefetch.h */static inline void prefetch(const void *x) {;}static inline void smp_read_barrier_depends(void) {;}/* timer.h *//* not used at the moment */#define TIMER_MAGIC 0x4b87ad6estruct timer_list { struct list_head entry; unsigned long expires; spinlock_t lock; unsigned long magic; void (*function)(unsigned long); unsigned long data; struct module *owner; const char *ownerfunction; char *use;};/* for internal timer management: * Increments the current system time, and calls any timers that * are have been scheduled within this period */void increment_time(unsigned int inc);#define init_timer(t) __init_timer(t,THIS_MODULE,__FUNCTION__)void __init_timer(struct timer_list * timer, struct module *owner, const char *function);int timer_pending(const struct timer_list * timer);void check_timer(struct timer_list *timer);#define del_timer(timer) __del_timer((timer), __location__)int __del_timer(struct timer_list *timer, const char *location);void check_timer_failed(struct timer_list *timer);#define add_timer(timer) __add_timer((timer), __location__)void __add_timer(struct timer_list *timer, const char *location);int __mod_timer(struct timer_list *timer, unsigned long expires);/* asm/bitops.h */int test_bit(int nr, const long * addr);int set_bit(int nr,long * addr);#define __set_bit set_bitint clear_bit(int nr, long * addr);/* random */void get_random_bytes(void *buf, int nbytes);/* cache. simple. */#define GFP_ATOMIC 0x01#define GFP_KERNEL 0x02typedef struct kmem_cache_s kmem_cache_t;struct kmem_cache_obj { struct list_head entry; char *ptr;};struct kmem_cache_s { size_t objsize; const char *name; /* list of allocated objects */ struct list_head objs; void (*ctor)(void *, kmem_cache_t *, unsigned long); void (*dtor)(void *, kmem_cache_t *, unsigned long);};kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned long, void (*)(void *, kmem_cache_t *, unsigned long), void (*)(void *, kmem_cache_t *, unsigned long));int kmem_cache_destroy(kmem_cache_t *);void *kmem_cache_alloc(kmem_cache_t *, int);void kmem_cache_free(kmem_cache_t *, void *);unsigned long __get_free_pages(unsigned int gfp_mask, unsigned int order);void free_pages(unsigned long addr, unsigned int order);int get_order(unsigned long size);/* wait.h */struct __wait_queue_head { spinlock_t lock; struct list_head task_list;};typedef struct __wait_queue_head wait_queue_head_t;/* netlink.h */#define NLMSG_ALIGNTO 4#define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )#define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(sizeof(struct nlmsghdr)))#define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))#define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))#define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len <= (len))#define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))#define NLMSG_NOOP 0x1 /* Nothing. */#define NLMSG_ERROR 0x2 /* Error */#define NLMSG_DONE 0x3 /* End of a dump */#define NLMSG_OVERRUN 0x4 /* Data lost */struct nlmsghdr{ __u32 nlmsg_len; /* Length of message including header */ __u16 nlmsg_type; /* Message content */ __u16 nlmsg_flags; /* Additional flags */ __u32 nlmsg_seq; /* Sequence number */ __u32 nlmsg_pid; /* Sending process PID */};/* module things */#define MODULE_LICENSE(x) #define MODULE_AUTHOR(x) #define MODULE_DESCRIPTION(x) #define MODULE_PARM(x,n) #define MODULE_PARM_DESC(x,n) #define module_param(name, type, perm)#define module_param_array(name, type, num, perm)#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28)#define EXPORT_NO_SYMBOLS#endif#define EXPORT_SYMBOL(x)#define EXPORT_SYMBOL_GPL(x)void module_put(struct module *module);int try_module_get(struct module *module);#define try_then_request_module(x, mod...) ((x) ?: (request_module(mod), (x)))extern int request_module(const char * name, ...) __attribute__ ((format (printf, 1, 2)));struct __module_init { int (*initcall)(void); const char *name;};struct __module_exit { void (*exitcall)(void); const char *name;};#define __init#define __initdata#define __exit#define MODULE_NAME_LEN (256 - sizeof(unsigned long) * 5)/* Large alignment ensures it's not padded in section. */struct module { struct list_head list; int (*init)(void); void (*exit)(void); long state; unsigned int use; char name[MODULE_NAME_LEN];} __attribute__((aligned(64)));#ifdef KBUILD_MODNAMEstatic struct module __this __attribute__((section("__modules"), unused)) = { .name = __stringify(KBUILD_MODNAME) };#define THIS_MODULE &__this#define module_init(fn) \ static struct __module_init __initcall_##fn \ __attribute__((__unused__)) \ __attribute__((__section__("module_init"))) = { &fn, __stringify(KBUILD_MODNAME) }#define module_exit(fn) \ static struct __module_exit __exitcall_##fn \ __attribute__((__unused__)) \ __attribute__((__section__("module_exit"))) = { &fn, __stringify(KBUILD_MODNAME) }#else#define THIS_MODULE 0#endif /* KBUILD_MODNAME */#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)#define MOD_INC_USE_COUNT#define MOD_DEC_USE_COUNT#define __MOD_DEC_USE_COUNT(mod)#define __MOD_INC_USE_COUNT(mod)#define smp_num_cpus NR_CPUS#endif#include <core.h>#include <message.h>#include <proc_stuff.h>/* percpu.h */#define DEFINE_PER_CPU(type, name) __typeof__(type) per_cpu__##name#define per_cpu(var, cpu) (*((void)cpu, &per_cpu__##var))#define __get_cpu_var(var) per_cpu__##var#define DECLARE_PER_CPU(type, name) extern __typeof__(type) per_cpu__##name#define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)#define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)/* if_ether.h */struct ethhdr *eth_hdr(const struct sk_buff *skb);/* jhash.h */u32 jhash(void *key, u32 length, u32 initval);u32 jhash2(u32 *k, u32 length, u32 initval);u32 jhash_3words(u32 a, u32 b, u32 c, u32 initval);u32 jhash_2words(u32 a, u32 b, u32 initval);u32 jhash_1word(u32 a, u32 initval);#endif /* __HAVE_SIMULATOR_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -