Linux kernel practices

Source: Internet
Author: User

This article is just a kernel network protocol practice example, first explain the purpose of adding, the next chapter to start concrete implementation.

Kernel version: 2.6.34; In support of 802.1 hosts, the general format of the message:

There is now a need to support a new protocol [two-tier]–BRCM protocol, unlike IP and other protocols, it is located in the 2 layer, with 6-byte head and 4-byte tail, the added level of the decision to add more than other protocols to be more complex, the new message format is as follows, and our goal is to network protocol stack can normally handle such a message :

In fact, BRCM is an internal protocol for switches that allow the switch management ports to get messages from which port the switch is from, or to specify which port the switch is from, which is not what we care about, and we just need to pick a protocol number for it 0x8744, The rest of the content will be 0. Therefore, the BRCM head will be filled in at the end of 00,BRCM and will be filled into 00 00. The message content of a new protocol is viewed in the form of a wireshark and other catch-bag tool as follows:

[Source/Destination MAC]02 03 04 05 06 07 10 11 12 13 14 15

[BRCM Header]88 74 00 00 00 00

[VLAN Header]81 00 00 01

[Message content] ...

First from the concept of the device to add the BRCM protocol after the hierarchy diagram:

Eth1 represents the actual B4401 physical network card; eth1. X/brcm0.x on behalf of the VLAN created virtual network card, the following number x is the VLAN number, BRCM0 represents the virtual network card created by BRCM, the number 0 represents the test; As you can see from the diagram, the BRCM protocol is added by adding BRCMX Virtual NIC interface.

If the BRCM protocol is added correctly, the final result should be:

When receiving a message, the virtual device BRCM will remove the BRCM 6-byte head and the 4-byte tail, of course, the protocol does much more than that, but this is the core.

When sending a message, the BRCM of the virtual device adds a 6-byte header and a 4-byte tail, and of course, the protocol does much more than that, but it's the core.

The work to be done is roughly the following:

1. Determine the Brcm_dev storage data structure

2. Preparation of struct Ptype_base Brcm_packet_type

3. Add IOCTL calls for user space calls, including at least brcm_dev creation and deletion

4. Add notifier mechanism, netlink mechanism, proc mechanism

5. Add Kconfig, makefile and so on, and modify Menuconfig

The data structure is the core, each step is also the core of a network protocol module. The next article begins the implementation of BRCM protocol additions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.