#include <sys/ioccom.h>
sys/ioccom.h
macroIOCPARM_MASK
Ioctl's have the command encoded in the lower word, and the size of
any in or out parameters in the upper word. The high 3 bits of the
upper word are used to encode the in/out status of the parameter.
#define IOCPARM_MASK 0x1fff
parameter length, at most 13 bits
macroIOCPARM_LEN
#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK)
macroIOCBASECMD
#define IOCBASECMD(x) ((x) & ~(IOCPARM_MASK << 16))
macroIOCGROUP
#define IOCGROUP(x) (((x) >> 8) & 0xff)
macro_IOC
#define _IOC(inout, group, num, len) (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))