sk_buff에 관해서 궁금한게 있습니다.
글쓴이: satanjr / 작성시간: 화, 2003/12/30 - 12:24오후
다름이 아니라 리눅스 네트워크 쪽으로 공부를 하고 있는 학생입니다.
지금 막히는 부분이 skbuff.h 파일에 있는 pskb_may_pull 함수 부분입니다.
static inline int pskb_may_pull(struct sk_buff *skb, unsigned int len)
{
if (len <= skb_headlen(skb))
return 1;
if (len > skb->len)
return 0;
return (__pskb_pull_tail(skb, len-skb_headlen(skb)) != NULL);
}
여기서 받아들이는 len 은 (ip헤더 + (tcp 헤더 or udp 헤더))의 길이입니다.
이럴때 skb_headlen(skb)는 다음과 같구요..
static inline unsigned int skb_headlen(const struct sk_buff *skb)
{
return skb->len - skb->data_len;
}
여기서 "skb->len - skb->data_len" 부분이 위의 len (ip헤더 + (tcp 헤더 or udp 헤더)) 하고 다른점이 무엇인지요?
한마디로 쉽게^^ 이야기 하면 sk_buff구조체의 len과 data_len 인자가 뜻하는 것이 무엇인지 알고 싶습니다.[/code]
Forums:


sk 구조체를 보여주시오~~~그전엔 답변 구경하시기 힘들듯...
sk 구조체를 보여주시오~~~
그전엔 답변 구경하시기 힘들듯... 한데...-_-ㅋ
<어떠한 역경에도 굴하지 않는 '하양 지훈'>
#include <com.h> <C2H5OH.h> <woman.h>
do { if (com) hacking(); if (money) drinking(); if (women) loving(); } while (1);
sk_buff 구조체는 다음과 같습니다.
struct sk_buff { /* These two members must be first. */ struct sk_buff * next; /* Next buffer in list */ struct sk_buff * prev; /* Previous buffer in list */ struct sk_buff_head * list; /* List we are on */ struct sock *sk; /* Socket we are owned by */ struct timeval stamp; /* Time we arrived */ struct net_device *dev; /* Device we arrived on/are leaving by */ struct net_device *real_dev; /* For support of point to point protocols (e.g. 802.3ad) over bonding, we must save the physical device that got the packet before replacing skb->dev with the virtual device. */ /* Transport layer header */ union { struct tcphdr *th; struct udphdr *uh; struct icmphdr *icmph; struct igmphdr *igmph; struct iphdr *ipiph; struct spxhdr *spxh; unsigned char *raw; } h; /* Network layer header */ union { struct iphdr *iph; struct ipv6hdr *ipv6h; struct arphdr *arph; struct ipxhdr *ipxh; unsigned char *raw; } nh; /* Link layer header */ union { struct ethhdr *ethernet; unsigned char *raw; } mac; struct dst_entry *dst; /* * This is the control buffer. It is free to use for every * layer. Please put your private variables there. If you * want to keep them across layers you have to do a skb_clone() * first. This is owned by whoever has the skb queued ATM. */ char cb[48]; unsigned int len; /* Length of actual data */ unsigned int data_len; unsigned int csum; /* Checksum */ unsigned char __unused, /* Dead field, may be reused */ cloned, /* head may be cloned (check refcnt to be sure). */ pkt_type, /* Packet class */ ip_summed; /* Driver fed us an IP checksum */ __u32 priority; /* Packet queueing priority */ atomic_t users; /* User count - see datagram.c,tcp.c */ unsigned short protocol; /* Packet protocol from driver. */ unsigned short security; /* Security level of packet */ unsigned int truesize; /* Buffer size */ unsigned char *head; /* Head of buffer */ unsigned char *data; /* Data head pointer */ unsigned char *tail; /* Tail pointer */ unsigned char *end; /* End pointer */ void (*destructor)(struct sk_buff *); /* Destruct function */ #ifdef CONFIG_NETFILTER /* Can be used for communication between hooks. */ unsigned long nfmark; /* Cache info */ __u32 nfcache; /* Associated connection, if any */ struct nf_ct_info *nfct; #ifdef CONFIG_NETFILTER_DEBUG unsigned int nf_debug; #endif #endif /*CONFIG_NETFILTER*/ #if defined(CONFIG_HIPPI) union{ __u32 ifield; } private; #endif #ifdef CONFIG_NET_SCHED __u32 tc_index; /* traffic control index */ #endif };[/code]날짜가 오래된 질문이긴 해도 저처럼 검색해서 보시는 분들 계실까 몇자 적
날짜가 오래된 질문이긴 해도 저처럼 검색해서 보시는 분들 계실까 몇자 적어봅니다.
초 간단히 말씀드리면...
skb->len는 말 그대로 패킷의 길이이고,
skb->data_len는 패킷이 fragment되었을 경우 fragment된 패킷의 길이입니다. fragment되지 않은 패킷의 data_len의 값은 0으로 들어가게 됩니다.
예를 들어 2000byte짜리 패킷이 두개로 쪼개져서 1500, 500짜리 skb로 되어있다면
첫번째 skb : len=2000, data_len=1500
두번째 skb : len=2000, data_len=500
이렇게 들어갑니다.
감사합니다.
감사합니다.
==================================
루비 개발자.
==================================
당신은 당신의 꿈을 위해 무엇을 희생하였나요?
댓글 달기