INITIALIZATION
void skb_queue_head_init(struct sk_buff_head *list)
Initializes the sk_bufff_head structure. Normally, the sk_buff_head is declared as a local variable, which is then initialized to an empty queue by the this function
sk_buff_head 구조체를 초기화 한다. 일반적으로 sk_buff_head 구조체는 지역변수로 선언되며 이 함수에 의해 비어있는 큐로 초기화 된다.
CREATION
struct sk_buff *alloc_skb(unsigned int size, int priority)
Allocates kernel memmory to store data of at least the specified size. Note that kernel memory is allocate in powers of two, and so you might get alot more space than you need. The priority indicates whether the memory has to be available right now, or can be paged in. In most cases, it should be GFP_ATOMIC, which means no paging.
적어도 명시된 크기 만큼의 데이터를 저장할 수 있는 커널 메모리를 할당한다. 커널 메모리는 2의 배수로 할당되므로 필요로 하는 것보다 많은 공간이 할당될 것이다. priority는 메모리 영역이 지금 바로 필요한지 페이징 되어도 되는지를 나타낸다. 대부분의 경우에 GFP_ATOMIC으로 설정하며 이는 페이징하지 않음을 뜻한다.
struct sk_buff *dev_alloc_skb(unsigned int size);
struct sk_buff *skb_clone(struct sk_buff *skb, int priority)
Make a fake copy of the the specified SKB. The new skb is not owned by a socket, or locked, and will be freed on deletion.
명시한 skb의 복사본을 만든다. 새로운 skb는 어떤 socket에 소유되지 않으며 잠겨있다. 삭제 될 때 잠김이 풀릴 것이다.
struct sk_buff *skb_copy(struct sk_buff *skb, int priority)
Make a real (independent) copy of the the specified SKB and the data it points to.
명시한 skb와 그것이 가르키는 데이터의 복사본을 만든다.
SIMPLE MANIPULATION
void skb_queue_head(struct sk_buff_head *list,struct sk_buff *buf)
Adds the given SKB to the head of the queue. It will then be the next SKB dequeue.
주어진 skb를 큐의 head에 추가한다. 추가된 skb는 다음번에 dequeue 된다.
void skb_queue_tail(struct sk_buff_head *list,struct sk_buff *buf)
Adds the given SKB to the tail (end) of the queue. It will then be the last SKB dequeued.
주어진 skb를 큐의 tail에 추가한다. 추가된 skb는 마지막에 dequeue 된다.
struct sk_buff * skb_dequeue(struct sk_buff_head *list)
Removes an SKB from the head of a given queue, if one is available. If not, NULL is returned.
큐의 head에서 skb 하나를 제거한다. 큐에 skb가 존재하지 않을 경우 NULL을 리턴함.
INFORMATIVE
__u32 skb_queue_len(struct sk_buff_head *list);
Determines the number of SKBs in a given queue.
큐에 존재하는 skb의 갯수를 알려준다.
struct sk_buff *skb_peek_copy(struct sk_buff_head *list);
Takes a peek at the next SKB to be dequeued, BUT DOES NOT REMOVE IT FROM THE LIST. This means that it is possible for another process to run off with it while your back is turned.
다음번 dequeue될 skb를 peek 한다. 이 때 큐에서 skb를 제거하지는 않는다. 다른 프로세스에서 해당 skb를 가지고 작업 할 수도 있음을 뜻한다.
int skb_headroom(struct sk_buff *skb)
Determines how many free bytes are available before the actual data starts in the buffer. Often used to see if a header can simplely be prepended to the valid data area, or if a copy into a new buffer is necessary. Usually used as a check right before skb_push() is called.
버퍼에 실제 data가 나타나기 까지 얼마나 많은 빈 공간(headroom)이 있는지 알려준다. 헤더를 단순히 확장할 수 있는지 새로운 버퍼로 복사해야 하는지를 알아보는데 사용된다.
int skb_tailroom(struct sk_buff *skb)
Determines how many free bytes are available after the actual data ends in the buffer. Often used to see if a trailer can simplely be appended to the valid data area, or if a copy into a new buffer is necessary. Ussually used as a check right before a call to skb_put().
버퍼에 실제 data가 끝난 이후로 얼마나 많은 빈 공간(tailroom)이 있는지 알려준다. trailer가 단순히 덧붙을 수 있는지 새로운 버퍼로 복사해야 하는지 알아보는데 사용된다. 일반적으로 skb_put()을 호출하기 전에 크기를 체크하기 위해 사용된다.
int skb_device_locked(struct sk_buff *skb)
Check to see if the given SKB is locked.
주어진 skb가 잠김 상태인지를 확인한다.
COMPLEX SKB MANIPULATION
void skb_insert(struct sk_buff *old,struct sk_buff *newsk)
Inserts the new SKB in front of the old SKB in the list.
새로운 skb를 old의 앞에 삽입한다.
void skb_append(struct sk_buff *old,struct sk_buff *newsk)
Inserts the new SKB in back of the old SKB in the list.
새로운 skb를 old의 뒤에 삽입한다.
void skb_unlink(struct sk_buff *buf)
Removes the SKB from its list, no matter where it is in that list.
리스트에서 skb를 제거한다. skb의 위치는 상관없음.
void skb_device_lock(struct sk_buff *skb)
Places a lock on the given SKB.
주어진 skb를 잠근다.
void skb_device_unlock(struct sk_buff *skb)
Removes a lock on a given SKB
주어진 skb의 잠금을 해제한다.
DATA MANIPULATION
unsigned char * skb_put(struct sk_buff *skb, int len)
Adds len garbage characters to the end of the PDU, and then returns a pointer to the start of the garbage characters so you can overwrite them. Note that there is no range checking to ensure that space actually exists, so be careful of memory overruns.
len 길이 만큼의 garbage 문자들을 PDU의 끝에 덧붙이고 garbage character의 시작 위치를 리턴해서 해당 부분을 rewrite할수 있게 한다. 실제로 충분한 공간이 존재하는지를 체크하지 않으므로 메모리 overrun에 주의해야 한다.
unsigned char * skb_push(struct sk_buff *skb, int len)
"Pushes" len garbage bytes onto the front of the PDU, and returns a pointer to the start of the garbage bytes. Note that there is no range checking to ensure that space actually exists so be careful of memory underruns.
PDU의 앞쪽에 len 길이 만큼의 garbage 문자들을 삽입하고 garbage 문자의 시작 위치를 리턴한다. 실제로 충분한 공간이 존재하는지를 체크하지 않으므로 메모리 overrun에 주의해야 한다.
unsigned char * skb_pull(struct sk_buff *skb, int len)
If there are len bytes available, then they are removed from the buffer and a pointer to the start of the removed bytes is returned. Otherwise, a NULL pointer is returned.
len 길이 만큼의 byte가 사용가능하다면 버퍼에서 그만큼 지우고 지워진 byte의 시작 포인터를 리턴한다. 아니면 NULL 리턴.
void skb_reserve(struct sk_buff *skb, int len)
Pre-allocates some space for a header that will be added by later protocols. This can save some unnessary copies in lower protocol layers. normally, these headers are then written with skb_push()
향후 프로토콜들에서 추가될 헤더를 위한 공간을 미리 할당해둠. 하위 프로토콜에서의 불필요한 복사를 줄일 수 있다. 보통 이러한 헤더들은 skb_push() 함수로 skb에 추가된다.
void skb_trim(struct sk_buff *skb, int len)
Shortens the stored data in the SKB to the desired length. Often used to remove trailiers from PDUs
skb에 저장된 데이터를 원하는 길이로 짧게 한다. 보통 PDU에서 trailer를 제거하는데 사용됨.
DESTRUCTION
void kfree_skb(struct sk_buff *skb, int rw)
Frees an SKB for either Reading, Writing, or both.
skb를 읽기,쓰기 또는 모두 못하도록 해제한다.
void kfree_skbmem(struct sk_buff *skb)
Frees the memory allocated to an SKB to store data. Not used by newer code
데이터를 저장하기 위해 할당하였던 메모리를 해제한다. 새로운 코드에서는 사용되지 않음.
void dev_kfree_skb(struct sk_buff *skb, int mode)
Frees the memory that the SKB structure occupies
skb 구조체가 점유하는 메모리를 해제함.
원문 출처
---------------------------------
http://www.ittc.ku.edu/Projects/Wireless_ATM/linux/sk-funct.html
댓글을 달아 주세요