/*
 * Copyright (C) 2017 ~ 2017 Deepin Technology Co., Ltd.
 *
 * Author:     Iceyer <me@iceyer.net>
 *
 * Maintainer: Iceyer <me@iceyer.net>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _DEEPIN_LICENSE_PRIVATE_DEVICE_H_
#define _DEEPIN_LICENSE_PRIVATE_DEVICE_H_

#include <linux/ioctl.h>

#define MAJOR_NUM 200

/*
 * _IOR means that we're creating an ioctl command
 * number for passing information from a user process
 * to the kernel module.
 *
 * The first arguments, MAJOR_NUM, is the major device
 * number we're using.
 *
 * The second argument is the number of the command
 * (there could be several with different meanings).
 *
 * The third argument is the type we want to get from
 * the process to the kernel.

 * This IOCTL is used for output, to get the message
 * of the device driver. However, we still need the
 * buffer to place the message in to be input,
 * as it is allocated by the process.

 * The IOCTL is used for both input and output. It
 * receives from the user a number, n, and returns
 * Message[n].
*/

#define IOCTL_GET_LICENSE_TYPE             _IOR(MAJOR_NUM, 1 , char *)
/*
 * Get the license user info
 */
#define IOCTL_GET_LICENSE_USERNAME         _IOR(MAJOR_NUM, 2, char *)

/*
 * Get the license product info
 */
#define IOCTL_GET_LICENSE_PRODUCT           _IOR(MAJOR_NUM, 3, char *)

#define IOCTL_GET_LICENSE_COPYRIGHT         _IOR(MAJOR_NUM, 4, char *)

#define IOCTL_GET_LICENSE_EDITION           _IOR(MAJOR_NUM, 5, char *)

/*
 * Get the license authorize code
 */
#define IOCTL_GET_LICENSE_AUTHORIZE_CODE    _IOR(MAJOR_NUM, 6, char *)

#define IOCTL_GET_LICENSE_SIGNATURE_RSA     _IOR(MAJOR_NUM, 7, char *)

#define IOCTL_GET_LICENSE_SIGNATURE_AHS     _IOR(MAJOR_NUM, 8, char *)

#define IOCTL_GET_LICENSE_INFO              _IOR(MAJOR_NUM, 9, char *)

#define IOCTL_GET_LICENSE_MACHINE_CODE      _IOR(MAJOR_NUM, 10, char *)

#define IOCTL_GET_LICENSE_VALIDED           _IOR(MAJOR_NUM, 11 , char *)

#define IOCTL_GET_LICENSE_FILE_SIZE         _IOR(MAJOR_NUM, 12 , char *)

/*
 * reload license file
 * third parameter is the file name
 */
#define IOCTL_RELOAD_LICENSE                _IOW(MAJOR_NUM, 100, char *)

#define IOCTL_DEACTIVATE                    _IOW(MAJOR_NUM, 101, char *)

#define IOCTL_VERIFY_LICENSE                _IOWR(MAJOR_NUM, 200, char *)

#define IOCTL_VERIFY_SERIALKEY              _IOWR(MAJOR_NUM, 201, char *)

// #define IOCTL_VERIFY_ENCRYPT_KEY            _IOWR(MAJOR_NUM, 202, char *)

#define IOCTL_SWAP_SERIALKEY_LICENSE        _IOWR(MAJOR_NUM, 203, char *)

#define IOCTL_SET_MACHINE_CODE              _IOW(MAJOR_NUM, 300, char *)

#define IOCTL_SET_SYSTEM_COPYRIGHT          _IOW(MAJOR_NUM, 301, char *)

#define IOCTL_SET_SYSTEM_EDITION            _IOW(MAJOR_NUM, 302, char *)

#define IOCTL_SET_SYSTEM_VERSION            _IOW(MAJOR_NUM, 303, char *)

/*
 * The name of the device file
 */
#define DEVICE_FILE_NAME "license"

extern int init_device(void);
extern void cleanup_device(void);

#endif //_DEEPIN_LICENSE_PRIVATE_DEVICE_H_
