The Linux Networking Architecture [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

The Linux Networking Architecture [Electronic resources] - نسخه متنی

Klaus Wehrle

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید







Appendix F. Example for a Transport Protocol


/**********************************************************
* Example for a transport protocol
* Compile:
* gcc -I/lib/modules/'uname -r'/build/include -c file.c
**********************************************************/
#ifndef _KERNEL_
#define _KERNEL_
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/skbuff.h>
#include <linux/in.h>
#include <net/protocol.h>
MODULE_AUTHOR("Test Author (fixme@Linux-netzwerkarchitektur.de)");
MODULE_DESCRIPTION("Module with a layer-4 test protocol");
int test_proto_rcv(struct sk_buff *skb);
static struct inet_protocol test_protocol =
{
&test_proto_rcv, /* protocol handler */
NULL, /* error control */
NULL, /* next */
IPPROTO_TCP, /* protocol ID */
0, /* copy */
NULL, /* data */
" Test_Protocol" /* name */
};
int test_proto_rcv(struct sk_buff *skb)
{
printk(KERN_DEBUG "Test protocol: Packet Received with length: %u\n",
skb->len);
return skb->len;
}
int init_module(void)
{
inet_add_protocol(&test_protocol);
return 0;
}
void cleanup_module(void)
{
inet_del_protocol(&test_protocol);
}


/ 187