#include<sys/socket.h>
|
#include<sys/types.h>
|
#include<netinet/in.h>
|
#include <netdb.h>
|
#include <stdio.h>
|
#include <string.h>
|
#include <stdlib.h>
|
#include <unistd.h>
|
#include <errno.h>
|
#include <arpa/inet.h>
|
#include <time.h>
|
#include <signal.h>
|
#include <pthread.h>
|
#include <sys/time.h>
|
#include <stdbool.h>
|
#include <fcntl.h>
|
#include "/usr/include/mysql/mysql.h"
|
#include <sys/stat.h>
|
#define _DELETE_FILE
|
#include <dirent.h>
|
#include <limits.h>
|
#include <sys/io.h>
|
#include <signal.h>
|
int RealAlarmEventNum[16];
|
typedef struct{
|
int Year;
|
int Month;
|
int Day;
|
int Hour;
|
int Min;
|
int Sec;
|
}MyTime,*lpMyTime;
|
typedef struct{
|
int m_id;
|
char serverIP[32];
|
char serverport[10];
|
char port[10];
|
char ip[32];
|
char user[64];
|
char pass[64];
|
int reboot;
|
}sockinfo,*lpsockinfo;
|
typedef struct{
|
char channelId[5];
|
char eventId[10];
|
char startTime[30];
|
char soffset[20];
|
char endTime[30];
|
char eoffset[20];
|
char clipUrl[100];
|
char ruleId[10];
|
char ruleName[50];
|
char soiId[10];
|
char soiName[50];
|
char activity[50];
|
char objectType[20];
|
char aborted[15];
|
char acknowledged[15];
|
char debugMessage[512];
|
}AlarmInfo,*lpAlarmInfo;
|
typedef struct EVENT_LOG
|
{
|
bool mp4downed;
|
bool Ack;
|
bool InSearchRange;
|
char Date[15];
|
char Time[15];
|
char Rule[20];
|
char Camera[30];
|
char Region[30];
|
char Duration[20];
|
char Object[20];
|
char Activity[20];
|
unsigned char ActivityNum[5];
|
char clipUrl[200];
|
char DebugMessageS[200];
|
char DebugMessageE[200];
|
}EVENT_LOG;
|
|
int memorycmp(unsigned char* src ,int slen, char* token, int len);
|
void AurhorizationResponseBytes(char* byte_array_out,int * byte_array_length_out,char *Myuri, char *nonce,char *cnonce,char *response);
|
int AnalyXMLUrnEVENT(char* buff,int length,AlarmInfo* RealAlarmEvent);
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///// PHP API function
|
|
int CharToByte(char* chars, char* bytes, unsigned int count,char* ptr1,char* ptr2,char* ptr3,char* ptr4,unsigned char* number);
|
int stringcmp(char* src ,char* token, int len);
|
int DivideTimeToYMDHMS(char* DateTimeStr,int* year,int* month,int* day, int* hour,int* min,int* sec);
|
void RequestMetaFiles(char* AnaylyIP,char* httpUri,char* Tm1,char* Tm2);
|
void RequestZipSerFiles(char* AnaylyIP,char* httpUri);
|
void UrnStringToBytes(char* byte_array_out,int * byte_array_length_out,char* StartTim,char* EndTime);
|
|
void zclock_sleep (int msecs);
|
|
typedef struct{
|
char name[1024];
|
}filenames,*lpfilenames;
|
typedef struct{
|
char ID[5];
|
char IP[32];
|
}SESSION;
|
|
int doesFileExist(const char *filename);
|
void delete_file(const char *path);
|
void delete_folder(const char *path);
|
void AnalySerFile(char* p_save_buf,int res, int SearchStartTm, int SearchEndTm);
|
int GetFileNameInFolder(char* dirname,lpfilenames lpfilename);
|
int net_test(char* serverIP,char* port);
|
void GPIOinit(void);
|
int GPIOoutput(int no);
|
int RestartCommand(char* AnalyserIP,char* user,char* pass);
|
void MakeAuthorizedPacketRestart(char* buff,int length, char* Method,char* uri);
|
void MakeAuthorizedPacketReal(char* buff,int length, char* Method,char* uri);
|
void MakeAuthorizedPacketSimp(char* buff,int length, char* Method,char* uri);
|
void MakeAuthorizedPacketSimp111(char* buff,int length, char* Method,char* uri,char* Tm1,char* Tm2);
|
void AurhorizationResponseBytes(char* byte_array_out,int * byte_array_length_out,char *Myuri, char *nonce,char *cnonce,char *response);
|
void AurhorizationResponseBytesReal(char* byte_array_out,int * byte_array_length_out,char *Myuri, char *nonce,char *cnonce,char *response);
|
void AurhorizationResponseBytesReatart(char* byte_array_out,int * byte_array_length_out,char *Myuri, char *nonce,char *cnonce,char *response);
|
int Read_MysqlData();
|
int UpdateMysqData(int key);
|
int InsertMysqlData(char *AnalyserName,char* AnalyserIP,char* AnalyserPort,char* ServerIP,char* ServerPort,char* username,char* pass,char* resol,char* commType);
|
|
|
|
int GetConnectState(char* AnalyserIP); //1.查看分析器连接状态 参数:分析器IP。返回: 连接状态
|
int RestartAnalyser(char* AnalyserIP,char* user,char* pass,int RestartKind,int no); //2.重启分析器 参数:分析器IP,协议重启或电路重启。返回: 重启成功或失败的状态值。
|
int RealEventStart(char* AnalyserIP,char* user,char* pass);
|
int RealEventStop(char* AnalyserIP);
|
|
char* GetRealEvent(char* AnalyserIP); //3.查看实时监控 参数:分析器IP。返回:信道号及其对应的视频流地址
|
char* GetPHPSearchMetaInfo(char* AnalyserIP,char* user,char* pass,int Channel,int s_year,int s_month,int s_day,int s_hour,int s_minute,int s_sec,int e_year,int e_month,int e_day,int e_hour,int e_minute,int e_sec); //potection function
|
char* GetSearchMetaInfo(char* AnalyserIP,char* user,char* pass,int Channel,lpMyTime StartTm,lpMyTime EndTm); //4.查询记录 参数:分析器IP,开始时间,结束时间,信道号。返回:查询结果。(包括信道号,报警时间,播放地址,等。)
|
char* GetAnalyserNet(void); //5.获取当前转发器的ip 参数:无。返回:当前的ip地址子网掩码和网关
|
int SetAnalyserNet(char* NetInfo);
|
char* GetMp4Info(char* AnalyserIP,char* user,char* pass,int Channel,char* path) ;
|
char* GetAnalyserAll(); //9.查询设备 参数:无 返回:分析器的名称和ip
|
int DeleteAnalyser(char* AnalyserIP); //8.删除设备 参数:设备ip 返回:成功或失败的提示。
|
int InsertAnalyser(char *AnalyserName,char* AnalyserIP,char* AnalyserPort,char* ServerIP,char* ServerPort,char* user,char* pass,char* resol,char* commType);// 7.添加设备 参数:设备属性。返回:成功返回对应的视频流地址,失败返回一个提示。
|
char* GetDeviceInfo(char* AnalyserIP);
|
int Check_MysqlData(char *AnalyserName,char* AnalyserIP,char* AnalyserPort,char* ServerIP,char* ServerPort,char* user,char* pass,char* resol,char* commType);
|
//
|
int GPIO_OPEN(int PortNum);
|
void GPIO_CLOSE(int PortNum);
|
int GPIO_READ(int PortNum);
|
void GPIO_WRITE(int PortNum,unsigned char DATA);
|
//MD5 Function declaration******************************************
|
#define MD 5
|
|
#ifndef PROTOTYPES
|
#define PROTOTYPES 0
|
#endif
|
|
typedef unsigned char *POINTER; /* POINTER defines a generic pointer type */
|
typedef unsigned short int UINT2; /* UINT2 defines a two byte word */
|
typedef unsigned long int UINT4; /* UINT4 defines a four byte word */
|
|
/*
|
PROTO_LIST is defined depending on how PROTOTYPES is defined above.
|
If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
|
returns an empty list.
|
*/
|
//#if PROTOTYPES
|
//#define PROTO_LIST(list) list
|
//#else
|
//#define PROTO_LIST(list) ()
|
//#endif
|
|
/* Length of test block, number of test blocks. */
|
#define TEST_BLOCK_LEN 1000
|
#define TEST_BLOCK_COUNT 1000
|
|
/* Constants for MD5Transform routine. */
|
#define S11 7 /* ¸÷ÂÖ×óÒÆµÄλÊý */
|
#define S12 12
|
#define S13 17
|
#define S14 22
|
#define S21 5
|
#define S22 9
|
#define S23 14
|
#define S24 20
|
#define S31 4
|
#define S32 11
|
#define S33 16
|
#define S34 23
|
#define S41 6
|
#define S42 10
|
#define S43 15
|
#define S44 21
|
|
typedef struct
|
{
|
UINT4 state[4]; /* state (ABCD) */
|
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
|
unsigned char buffer[64]; /* input buffer */
|
}MD5_CTX;
|
|
static unsigned char PADDING[64] =
|
{
|
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
};
|
|
/*
|
F, G, H and I are basic MD5 functions.
|
*/
|
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
|
/*
|
ROTATE_LEFT rotates x left n bits.
|
*/
|
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
|
/*
|
FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
Rotation is separate from addition to prevent recomputation.
|
*/
|
#define FF(a, b, c, d, x, s, ac) { \
|
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
(a) = ROTATE_LEFT ((a), (s)); \
|
(a) += (b); \
|
}
|
#define GG(a, b, c, d, x, s, ac) { \
|
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
(a) = ROTATE_LEFT ((a), (s)); \
|
(a) += (b); \
|
}
|
#define HH(a, b, c, d, x, s, ac) { \
|
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
(a) = ROTATE_LEFT ((a), (s)); \
|
(a) += (b); \
|
}
|
#define II(a, b, c, d, x, s, ac) { \
|
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
(a) = ROTATE_LEFT ((a), (s)); \
|
(a) += (b); \
|
}
|
|
char* MDString (char *string);
|
|
|
void MD5Init (MD5_CTX *context);
|
void MD5Update(MD5_CTX *context, unsigned char *input,unsigned int inputLen);
|
void MD5Final (unsigned char digest[16], MD5_CTX *context);
|
void MD5Transform (UINT4 [4], unsigned char [64]) ;
|
void Encode(unsigned char *, UINT4 *, unsigned int);
|
void Decode (UINT4 *, unsigned char *, unsigned int);
|
void MD5_memcpy(POINTER, POINTER, unsigned int);
|
void MD5_memset(POINTER, int, unsigned int);
|