Create a file that contain all macros, that is used by by user as a command this file called ioctl.h
After creating ioctl.h ,you create a file ioctl.c that file work for kernel space, that file contain all command specific work.
in application level you give a call to function ioctl() and give the command, this command goto the driver and do the work as your command.