Code Monkey home page Code Monkey logo

hello-netlink's Introduction

Hello via netlink

A basic communication between kernel and user via netlink

Get and build the software

Download the source code

$ cd $HOME
$ mkdir devel
$ cd devel
$ git clone https://github.com/ichergui/hello-netlink.git

Build

kernel side
$ cd $HOME/devel/hello-netlink/kernel
$ make all
User side
$ cd $HOME/devel/hello-netlink/user
$ gcc -o nl_user nl_user.c $(pkg-config --cflags --libs libnl-3.0)

Test

Insert it into the Linux kernel

$ cd $HOME/devel/hello-netlink/kernel
$ sudo insmod nl_kernel.ko
  • verification
$ lsmod | grep -i "nl_kernel"
nl_kernel              16384  0
$

Launch the application

$ cd $HOME/devel/hello-netlink/user
$ ./nl_user -m "Hello from Ilies"
User send the following message to the kernel:
Hello from Ilies
User receive a message from kernel: Hello from kernel
$

Try with the following command line to see what's happened.

$ $ tail -f /var/log/kern.log

Sep 20 22:44:48 dev-machine kernel: [13466.108923] Entering: init_module
Sep 20 22:45:42 dev-machine kernel: [13520.057427] Entering: nl_recv_msg_cb
Sep 20 22:45:42 dev-machine kernel: [13520.057430] Kernel receive a message from user:Hello from Ilies

Remove it from Linux kernel

$ sudo rmmod nl_kernel

hello-netlink's People

Contributors

ichergui avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.