#ifndef _KEY_SWITCHING_H
#define _KEY_SWITCHING_H

#include <linux/ioctl.h>

#define WIDTH_LIMIT 256
#define LENGTH_LIMIT 8
#define L_LIMIT 32

typedef struct {
  unsigned char op_type;
  unsigned char width;
  unsigned char length;
  unsigned char ell;
  int input;
} key_switching_loading_t;

typedef struct {
  unsigned char reset;
  unsigned char done;
  unsigned char all_loaded;
} key_switching_status_t;

typedef struct {
  int output;
  char output_length;
  char output_width;
  char done;
} key_switching_output_t;

typedef struct {
  key_switching_loading_t load_info;
  key_switching_status_t status_info;
  key_switching_output_t output_info;
} key_switching_arg_t;

#define KEY_SWITCHING_MAGIC 'q'

/* ioctls and their arguments */
#define KEY_SWITCHING_WRITE _IOW(KEY_SWITCHING_MAGIC, 1, key_switching_arg_t *)
#define KEY_SWITCHING_WRITE_OP_TYPE _IOW(KEY_SWITCHING_MAGIC, 2, key_switching_arg_t *)
#define KEY_SWITCHING_WRITE_WIDTH _IOW(KEY_SWITCHING_MAGIC, 3, key_switching_arg_t *)
#define KEY_SWITCHING_WRITE_LENGTH _IOW(KEY_SWITCHING_MAGIC, 4, key_switching_arg_t *)
#define KEY_SWITCHING_WRITE_ELL _IOW(KEY_SWITCHING_MAGIC, 5, key_switching_arg_t *)
#define KEY_SWITCHING_READ  _IOR(KEY_SWITCHING_MAGIC, 6, key_switching_arg_t *)
#define KEY_SWITCHING_READ_WIDTH _IOR(ENCRYPTED_DOMAIN_MAGIC, 7, encrypted_domain_arg_t *)
#define KEY_SWITCHING_READ_LENGTH _IOR(ENCRYPTED_DOMAIN_MAGIC, 8, encrypted_domain_arg_t *)
#define KEY_SWITCHING_READ_DONE _IOR(ENCRYPTED_DOMAIN_MAGIC, 9, encrypted_domain_arg_t *)
#define KEY_SWITCHING_WRITE_RESET _IOW(ENCRYPTED_DOMAIN_MAGIC, 10, encrypted_domain_arg_t *)
#define KEY_SWITCHING_WRITE_LOADED _IOW(ENCRYPTED_DOMAIN_MAGIC, 11, encrypted_domain_arg_t *)

#endif
