1 / 11

proc & ppstream

proc & ppstream. 指導教授 : 李正帆 學生 : 黃健瑋. Content. Save module message to /proc Get ppstream channel ID IP refresh bug. Proc(1). struct proc_dir_entry *create_proc_entry ( const char *name, // 檔案名稱 mode_t mode, // 權限 struct proc_dir_entry *parent // 在 /proc 中的位置 );

zeheb
Télécharger la présentation

proc & ppstream

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. proc & ppstream 指導教授:李正帆 學生:黃健瑋

  2. Content • Save module message to /proc • Get ppstream channel ID • IP refresh bug

  3. Proc(1) struct proc_dir_entry *create_proc_entry ( const char *name, // 檔案名稱 mode_t mode,//權限 struct proc_dir_entry *parent //在/proc中的位置 ); void remove_proc_entry ( const char *name, struct proc_dir_entry *parent );

  4. Proc(2) int init_module(void){ if((proc_mtd = create_proc_entry("wireless", 0, 0))){ proc_mtd->read_proc = procfile_read; …… } // create file named “wireless” // procfile_read->function // when every time read the file, execute the function

  5. Proc(3) void cleanup_module(void){ … if(proc_mtd) remove_proc_entry("wireless", 0); … } // remove the file

  6. Proc(4) static int procfile_read(char *buffer, char **buffer_location, off_t offset, int buffer_length, int zero) { … *buffer_location = procBuffer; … } // we should save the string in procBuffer

  7. Ppstream static void my_check_ci(struct sk_buff *skb) { tcp = (struct tcphdr *)(skb->data + (skb->nh.iph->ihl * 4)); data = (char *)((int)tcp + (int)(tcp->doff * 4)); if (strncmp(data, "GET ", 4) == 0) { do something } }

  8. IP refresh bug • Skb->nh is network layer header • skb->h.raw=skb->nh.raw=skb->data means refresh the transport & network layer data • Still a question: • before the line, where does the raw point to & who use the pointer?

  9. Reference • http://doubao.javaeye.com/blog/278081 • http://www.lslnet.com/linux/f/docs1/i19/big5191723.htm • http://vger.kernel.org/~davem/skb_redundancy.html • http://linux.chinaunix.net/bbs/viewthread.php?action=printable&tid=1131776 • http://zkheartboy.blogspot.com/2007/10/skbuff3.html • 輕輕鬆鬆學會Linux Kernel module及TCP/IP程式設計

More Related