Ankit was new to kernel programming. Even I have not mastered this beast well. Neverthless, I got Ankit started with it.
1. Zaptel discussion
It is not necessary to define a span in case of an FXS/FXO. Just need to define a channel.
However, for registering fxs/fxo also, we pass a span argument to zaptel. I asked Ankit to look at span as an abstraction for a device (E1 card, FXS etc) which 'n' channels. (n = 1, for FXS)
I showed him how to define a fxo channel.
loadzone = us
defaultzone = us
zapata.conf (Additions only)
callerid="Green Phone"<(256) 428-6121>
channel => 1
exten => 1000,1,Dial(Zap/1)
2. Kernel module programming
To program kernel modules, you need to have kernel source for your current kernel.
I asked him to first download LDD3.
Then, we copied the code from second chapter and compiled the module.
This had to be done on my laptop, as he did not have kernel sources installed on his system.
static int hello_init(void)
printk(KERN_ALERT "Hello, world\n");
static void hello_exit(void)
printk(KERN_ALERT "Goodbye, cruel world\n");
Then we created the makefile
obj-m += tzap.o
EXTRA_CFLAGS += -I/root/zaptel/kernel
make -C /lib/modules/$(shell uname -r)/build M=`pwd` modules
With the make file in place, we compiled the module and inserted it.
- obj-m is a variable understood by kernel build system
- obj-m = tzap.o indicates that the name of your module source file is tzap.c
- EXTRA_CFLAGS defines the extra compile time flags specific for your module
- In this case that extra flag is not really necessary. But as we do more work with this driver, we will need it.
- Make command arguments: -C
Tells the make to change to before actually running
- Make command arguments: M=`pwd`defines M, which will be used by kernel build system to determine the directory in which module source is present
- Make command arguments: modules is the target to build