⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 采用非对称密钥加密方式的应用系统认证系统
💻 H
字号:
/**********************************************************************/
/*      安 全 验 证 服 务                                             */
/*                                                                    */
/*           作  者 :罗小江                                          */ 
/*           2001年10月 于 南京                                       */
/*                                                                    */
/**********************************************************************/

/*包含的各种头文件*/
#include <pthread.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/un.h>
#include <time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netdb.h>
#include <signal.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <strings.h>
#include <semaphore.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/ipc.h>
#include <sys/dir.h>
#include <sys/ioctl.h>
#include "rsaeuro.h" 

/*定义全局常量*/
#define LISTEN_PORT 10028
#define MAX_REQUEST 10   /* 最大同时连接请求数 */ 
#define MSGLEN_BYTES 4    /*读入MsgLen字段长度*/
#define MAX_BUFFER_SIZE  2048
#define PUBLICKEY_LENGTH       (sizeof(R_RSA_PUBLIC_KEY)) /*存储所需字节数*/
#define KEY_BITS  512

#define TIME_OUT    10

typedef enum {UM_QUIT=0,UM_QUITNOTIFY,UM_QUITQUERY,UM_PACKAGEARRIVE,UM_PACKAGERETURN, \
              UM_ISSUE,UM_UNISSUE,UM_FREENOTIFY,UM_INITSUCNOTIFY,UM_LISTENORQUITNOTIFY, \
              UM_PACKAGEARRIVEAGAIN,UM_TASKCOMPLETE} a;


/*控制各种DEBUG*/
#define DEBUG_CTL      /*各种调度、控制信息*/
#define DEBUG_LISTENOR /*侦听进程各种信息*/
#define DEBUG_SHM      /*共享内存各种信息*/ 
#define DEBUG_DATA     /*各种包请求信息*/
#define DEBUG_AUTHEN   /*各种验证成功、失败信息*/

/*定义各种结构体*/
typedef struct Operator_Info
{
    char Operator[7];
    char Password[7];
    char ClientIP[16];
    char AppName[21];
    char ProcessId[11];
} OperatorInfo;
typedef struct Reply_Info
{
    char Operator[7];
    char Password[26];
    char Depart[8];
    char Areacode[2];
    char GsmUserName[21];
    char GsmPassword[21];
    char CdrUserName[21];
    char CdrPassword[21];
} ReplyInfo;

/*定义各种公共函数*/

/*将十进制转化为十六进制*/
int  IntToHex(char *bufback, int iValue);
/*将十六进制转化为十进制, len为十六进制数的长度,返回转化后的十进制值*/
int  HexToInt(char *buf, int len); 
/*显示信息ShowMessage,perror,printf()*/
void  CommonShow(char*);        
/*mcm加密方式的解密函数*/              
void decodekey(char *source,char *dest);
/*设置非阻塞方式*/
int SetNonblock(int fd);
/*设置非阻塞方式*/
int SetBlock(int fd);
/*从套接字读入n个字节,返回已读到的字节数,为0:已到文件尾或socket已断开,小于0:发生错误*/
int Readn(int Fd,char *Buf,int n);
/**/
void SysTime(int *year,int *mon,int *day,int *hour,int *min,int *sec);
void GetSysTime(char *t);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -