include/linux/kernel.h
#define NIPQUAD(addr) \
((unsigned char *)&addr)[0], \
((unsigned char *)&addr)[1], \
((unsigned char *)&addr)[2], \
((unsigned char *)&addr)[3]
#define NIPQUAD_FMT "%u.%u.%u.%u"
IPv4 주소를 000.000.000.000 형태로 포맷팅한다.
#define NIP6(addr) \
ntohs((addr).s6_addr16[0]), \
ntohs((addr).s6_addr16[1]), \
ntohs((addr).s6_addr16[2]), \
ntohs((addr).s6_addr16[3]), \
ntohs((addr).s6_addr16[4]), \
ntohs((addr).s6_addr16[5]), \
ntohs((addr).s6_addr16[6]), \
ntohs((addr).s6_addr16[7])
#define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x"
#define NIP6_SEQFMT "%04x%04x%04x%04x%04x%04x%04x%04x"
IPv6 주소를 0000:0000:0000:0000:0000:0000:0000:0000 형태로 포맷팅한다.
include/linux/ipv6.h
struct ipv6hdr {
__u8 version:4,
priority:4;
__u8 flow_lbl[3];
__u16 payload_len;
__u8 nexthdr;
__u8 hop_limit;
struct in6_addr saddr;
struct in6_addr daddr;
};
IPv6 헤더 구조.
4|24
16|8|8
32x4
32x4
struct ipv6_opt_hdr {
__u8 nexthdr;
__u8 hdrlen;
/*
* TLV encoded option data follows.
*/
};
IPv6 옵션헤더. hdrlen에 정의된 길이만큼 TLV로 인코딩된 옵션 데이터가 존재한다.
int ipv6_optlen(u8 *nexthdrp)
nexthdrp로 가리키는 옵션헤더의 길이를 알려준다.
int ipv6_skip_exthdr(const struct sk_buff *skb, int start, u8 *nexthdrp)
주어진 skb에서 nexthdrp로 나타내어지는 옵션헤더를 건너뛴다.
static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2)
a1의 주소를 a2로 복사한다.
static inline void ipv6_addr_set(struct in6_addr *addr, __u32 w1, __u32 w2, __u32 w3, __u32 w4)
addr로 표현되는 IPv6 주소 구조체를 w1,w2,w3,w4의 값으로 설정한다.
static inline int ipv6_addr_equal(const struct in6_addr *a1, const struct in6_addr *a2)
a1과 a2의 주소가 일치하는지 확인한다.
include/linux/ip6_checksum.h
static __inline__ unsigned short int csum_ipv6_magic(struct in6_addr *saddr, struct in6_addr *daddr, __u16 len, unsigned short proto, unsigned int csum)
해당 IPv6 패킷의 checksum을 계산한다.
include/linux/skbuff.h
extern void kfree_skb(struct sk_buff *skb);
skb를 위해 할당된 공간을 해제한다.
extern struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int fclone);
새로운 skb를 할당한다.
extern struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t priority);
extern struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t priority);
주어진 skb를 복사한다.
extern struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom);
주어진 skb의 headroom 공간을 주어진 크기로 재조정한다.
static inline struct sk_buff *skb_peek(struct sk_buff_head *list_)
skb 리스트중 첫 아이템을 peek 한다. list에서 삭제하지는 않음.
static inline __u32 skb_queue_len(const struct sk_buff_head *list_)
skb 리스트의 길이를 반환한다.
static inline struct sk_buff *skb_peek_tail(struct sk_buff_head *list_)
skb 리스트중 마지막 아이템을 peek 한다. list에서 삭제하지는 않음.
extern struct sk_buff *skb_dequeue(struct sk_buff_head *list);
skb 리스트중 첫 아이템을 꺼낸다.
extern void skb_insert(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
extern void skb_append(struct sk_buff *old, struct sk_buff *newsk, struct sk_buff_head *list);
list로 주어지는 skb에 새로운 skb를 삽입한다.
static inline void *skb_header_pointer(const struct sk_buff *skb, int offset, int len, void *buffer)
skb에 존재하는 패킷의 헤더 위치를 반환한다.
static inline void skb_get_timestamp(const struct sk_buff *skb, struct timeval *stamp)
static inline void skb_set_timestamp(const struct sk_buff *skb, struct timeval *stamp)
skb에 기록된 timestamp를 반환/설정한다.
static inline unsigned char *skb_put(struct sk_buff *skb, unsigned int len)
static inline unsigned char *skb_push(struct sk_buff *skb, unsigned int len)
skb의 앞/뒤에 len 길이만큼의 공간을 확보한다.
static inline unsigned char *skb_pull(struct sk_buff *skb, unsigned int len)
skb로 부터 len 길이만큼을 읽어온다.
static inline int skb_add_data(struct sk_buff *skb, char __user *from, int copy)
skb에 from으로부터 copy 만큼의 데이터를 복사한다.




댓글을 달아 주세요
정리해두신 내용 우선 허락을 구하지 않고 복사하였습니다.
문제가 있으면 이야기 주세요 ^^