-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCmdProc.c
More file actions
3002 lines (2399 loc) · 77.6 KB
/
CmdProc.c
File metadata and controls
3002 lines (2399 loc) · 77.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
// file description
#include "CmdProc.h"
#include "Cmdcallback.h"
#include "diskmanage.h"
#include "netcommon.h"
#include "biz.h"
//#include "common_geometric.h"
//#include "biz_types.h"
typedef struct
{
int nValue;
char strDisplay[32];
} SValue;
extern void GetDWellSwitchTimeList( SValue* psValueList, int* nRealNum, int nMaxNum);
extern void GetDWellSwitchPictureList( SValue* psValueList, int* nRealNum, int nMaxNum);
//** macro
#define SUPPORT_LANGUAGE_NUM 20
#define CMD_CB_MAX 128
//** typedef
typedef enum //return value from UserCheckLoginPara()
{
EM_MODUSER_LOGIN_ERR_NOTHISUSER = -2,
EM_MODUSER_LOGIN_ERR_WRONGPASSWD = -3,
EM_MODUSER_LOGIN_ERR_NOLOGINTWINCE = -4,
EM_MODUSER_LOGIN_ERR_IP_NOPERMIT = -5,
EM_MODUSER_LOGIN_ERR_MAC_NOPERMIT = -6,
//
} EMMODUSERLOGINERR;
//** local var
static PNetCommCommandDeal2 pCB2;
static u8 nChnMax;
static SCmdCBPair sCmdCBStack[CMD_CB_MAX]={{0,0}};
#define NET_USER_MAX 128
typedef struct
{
u8 nLoginUser;
SNetUser User[NET_USER_MAX];
} SNetUserMgr;
static SNetUserMgr sNetUserMgr;
//** global var
extern SNetCommCtrl sNetCommCtrl;
extern ifly_AlarmUploadCenter_t g_AlarmUploadCenter[MAX_ALARM_UPLOAD_NUM];
//** local functions
//** global functions
s32 remotePlay_Stop(u32 nLnkId);
s32 remotePlay_FastPlay(u32 id);
s32 remotePlay_SlowPlay(u32 id);
s32 remotePlay_SetRate(u32 id, int rate);
s32 remotePlay_Pause(u32 id);
s32 remotePlay_Resume(u32 id);
s32 remotePlay_Step(u32 id);
s32 remotePlay_PrevNext(u32 id, u8 bPrev);
s32 remotePlay_Seek(u32 id, u32 nSeekPos);
s32 remotePlay_Mute(u32 id, u8 bMute);
s32 remoteVoip_Stop(u32 nLinkId);
s32 remotePlay_Progress(u32 id, CPHandle cph, u8 bStatus);
s32 netComm_PPPOE_CmdPreup();
s32 netComm_PPPOE_CmdUp();
s32 netComm_PPPOE_CmdDown();
s32 netComm_PPPOE_CmdDisconnect();
s32 netComm_DHCP_Active( char* pIFName );
extern void net_write_upload_alarm(u32 key);
void cmdPro_Init( PNetCommCommandDeal2 p, u8 nChMax )
{
pCB2 = p;
nChnMax = nChMax;
memset(&sNetUserMgr, 0, sizeof(sNetUserMgr));
}
// find cb
PNetCommCommandDeal cmdProc_GetCmdCB(u32 nCmdID)
{
int i;
SCmdCBPair* pCmdPair = sCmdCBStack;
for(i=0;i<CMD_CB_MAX;i++)
{
if(pCmdPair[i].nCmdID==nCmdID)
{
//NETCOMM_DEBUG_STR("Get callback, add ", (u32)pCmdPair[i].pCB);
return pCmdPair[i].pCB;
}
}
return NULL;
}
// NetCommUnregCmdCB
void NetCommUnregCmdCB(u32 nCmdID)
{
int i;
SCmdCBPair* pCmdPair = sCmdCBStack;
for(i=0;i<CMD_CB_MAX;i++)
{
if(pCmdPair[i].nCmdID==nCmdID)
{
pCmdPair[i].nCmdID = 0;
pCmdPair[i].pCB = NULL;
break;
}
}
}
// NetCommRegCmdCB
s32 NetCommRegCmdCB( u32 nCmdID, PNetCommCommandDeal pCB )
{
int i;
SCmdCBPair* pCmdPair = sCmdCBStack;
for(i=0;i<CMD_CB_MAX;i++)
{
if(pCmdPair[i].nCmdID==0)
{
//NETCOMM_DEBUG_STR("Register on callback, id", nCmdID);
pCmdPair[i].nCmdID = nCmdID;
pCmdPair[i].pCB = pCB;
break;
}
}
if(i==CMD_CB_MAX)
{
NETCOMM_DEBUG_STR("No more position for cmd call back register!!!\n", -1);
return -1;
}
return 0;
}
extern u16 DealPlayProgress(
CPHandle cph,
u16 event,
u8 *pbyMsgBuf,
int msgLen,
u8 *pbyAckBuf,
int *pAckLen,
void* pContext
);
typedef struct
{
char name[12];
char password[12];
char local_privilege[16];
char remote_privilege[16];
char mac_address[18];
u16 startID;
}PACK_NO_PADDING ifly_usermanage_t;
//csp modify 20130423
extern s32 remotePreview_SetMonitorInfo(u32 nLinkId, u32 MonitorInfo);
extern s32 remotePreview_StopPreview(u32 nLinkId, u8 bVideo);
extern s32 remotePlay_Stop(u32 nLnkId);
s32 cmdProc_GetLoginUser(SNetUser* pUser)
{
int i;
if(pUser)
{
for(i=0; i<NET_USER_MAX; i++)
{
if(sNetUserMgr.User[i].bOnline)
{
//printf("ip %lu, sock %d\n", pUser->ip, pUser->sock);
}
#if 1//csp modify
if( sNetUserMgr.User[i].bOnline &&
( sNetUserMgr.User[i].ip == pUser->ip &&
sNetUserMgr.User[i].sock == pUser->sock )
)
#else
if( sNetUserMgr.User[i].bOnline &&
( sNetUserMgr.User[i].ip == pUser->ip ||
sNetUserMgr.User[i].sock == pUser->sock )
)
#endif
{
strcpy(pUser->name, sNetUserMgr.User[i].name);
pUser->id = sNetUserMgr.User[i].id;
printf("get user:(%s,%d), index:%d, net info:(0x%08x, %d)\n", pUser->name, pUser->id, i, pUser->ip, pUser->sock);
break;
}
}
if(i == NET_USER_MAX)
{
return -1;
}
}
return 0;
}
s32 cmdProc_AddNetUser(SNetUser* pUser)
{
int i, iUsrIdx = -1;
if(pUser)
{
for(i=0; i<NET_USER_MAX; i++)
{
if(iUsrIdx < 0 && !sNetUserMgr.User[i].bOnline)
{
iUsrIdx = i;
}
if(sNetUserMgr.User[i].bOnline &&
sNetUserMgr.User[i].ip == pUser->ip &&
sNetUserMgr.User[i].sock == pUser->sock
#if 0
//Modify by Lirl on Dec/29/2011
//登陆时只要为登陆状态,并且再记录下当前用户状态信息
pUser->bOnline
#endif
)
{
printf("add user %s\n", pUser->name);
//IE登陆时记录当前用户的状态信息
strcpy(sNetUserMgr.User[i].name, pUser->name);
sNetUserMgr.User[i].id = pUser->id;
sNetUserMgr.User[i].bOnline = pUser->bOnline;
sNetUserMgr.User[i].ip = pUser->ip;
sNetUserMgr.User[i].sock = pUser->sock;
return 0;
}
}
if((i == NET_USER_MAX) && (iUsrIdx >= 0 && iUsrIdx < NET_USER_MAX))
{
printf("add user:(%s,%d), index:%d, net info:(0x%08x, %d)\n", pUser->name, pUser->id, iUsrIdx, pUser->ip, pUser->sock);
memcpy(&sNetUserMgr.User[iUsrIdx], pUser, sizeof(SNetUser));
}
}
return 0;
}
s32 cmdProc_DelNetUser(SNetUser* pUser)
{
int i;
if(pUser)
{
if(pUser->bUserDel)
{
for(i=0; i<NET_USER_MAX; i++)
{
//用户管理删除该用户则删除在线用户信息
if(strcmp(sNetUserMgr.User[i].name, pUser->name) == 0)
{
memset(&sNetUserMgr.User[i], 0, sizeof(SNetUser));
sNetUserMgr.User[i].bOnline = 0;
sNetUserMgr.User[i].ip = 0;
sNetUserMgr.User[i].sock = 0;
}
}
}
else
{
for(i=0; i<NET_USER_MAX; i++)
{
if(sNetUserMgr.User[i].bOnline &&
strcmp(sNetUserMgr.User[i].name, pUser->name) == 0 &&
sNetUserMgr.User[i].ip == pUser->ip &&
sNetUserMgr.User[i].sock == pUser->sock
)
{
//IE退出时删除当前用户的状态信息
memset(&sNetUserMgr.User[i], 0, sizeof(SNetUser));
sNetUserMgr.User[i].bOnline = 0;
sNetUserMgr.User[i].ip = 0;
sNetUserMgr.User[i].sock = 0;
break;
}
}
}
}
return 0;
}
//xdc
ifly_ipc_info_t sIpcInfo1[100];
static u16 second = 0;
static u16 startid = 0;
static u16 endid = 0;
static u16 ipc_num = 0;
static u16 max_return = 0;
//xdc end
u16 DealCommand(
CPHandle cph,
u16 event,
u8* pbyMsgBuf,
int msgLen,
u8* pbyAckBuf,
int* pAckLen,
void* pContext
)
{
printf("%s event %d\n", __func__, event);
u8 byMute;
u8 byStatus;
int i, k, id, rate, seekPos;
//char temp[2] = {0};
PNetCommCommandDeal pCB;
SNetCommCtrl* pNetCtrl = &sNetCommCtrl;
SNetLog sNLIns;
// set or get paramters to/from uplayer
//
SRemoteCmdReq sReqIns;
SRemoteCmdRslt sRslt;
memset(&sReqIns, 0, sizeof(sReqIns));
memset(&sRslt, 0, sizeof(sRslt));
pCB = cmdProc_GetCmdCB(event);
if(NULL == pCB)
{
NETCOMM_DEBUG_STR("No matched callback function registered!!!\n", -1);
//csp modify 20130527
if(pAckLen)
{
*pAckLen = 0;
}
//csp modify 20130527
return CTRL_FAILED_COMMAND;//return 0;//
}
if(cph)
{
sReqIns.cph = cph;
}
else
{
//csp modify 20130527
if(pAckLen)
{
*pAckLen = 0;
}
//csp modify 20130527
return CTRL_FAILED_CONNECT;//return -1;
}
switch(event)
{
case CTRL_CMD_GETRECSCHPARAMBYTYPE:// CTRL_CMD_BASE+133 //按布防类型获得录像布防参数
{
ifly_RecSchTime_t* pRecordSCH;
pRecordSCH = &sReqIns.sReq.RecSchTime;
memcpy(pRecordSCH, pbyMsgBuf, sizeof(ifly_RecSchTime_t));
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_RecSchTime_t);
}
memcpy(pbyAckBuf, &sRslt.sBasicInfo.RecSchTime, sizeof(ifly_RecSchTime_t));
//printf("acklen %d \n", *pAckLen);
} break;
case CTRL_CMD_SETRECSCHPARAMBYTYPE: // CTRL_CMD_BASE+134 //按布防类型分开设置录像布防参数
{
ifly_RecSchTime_t* pRecordSCH;
pRecordSCH = &sReqIns.sReq.RecSchTime;
memcpy(pRecordSCH, pbyMsgBuf, sizeof(ifly_RecSchTime_t));
pRecordSCH->copy2Chnmask = ntohl(pRecordSCH->copy2Chnmask);
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = 0;
}
} break;
case CTRL_CMD_GETPTZPROTOCOLLIST:
{
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_PTZProtocolList_t);
}
memcpy(pbyAckBuf, &sRslt.sBasicInfo.PTZProtocolList, sizeof(ifly_PTZProtocolList_t));
//printf("CTRL_CMD_GETPTZPROTOCOLLIST acklen %d \n", *pAckLen);
}
break;
case CTRL_CMD_GETMDSENSELIST: // CTRL_CMD_BASE+129 //获取移动侦测灵敏度列表
{
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_MDSenselist_t);
}
memcpy(pbyAckBuf, &sRslt.sBasicInfo.MDSenselist, sizeof(ifly_MDSenselist_t));
} break;
case CTRL_CMD_GETMDALARMDELAYLIST: // CTRL_CMD_BASE+130 //获取移动侦测报警输出延时列表
{
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_MDAlarmDelaylist_t);
}
memcpy(pbyAckBuf, &sRslt.sBasicInfo.MDAlarmDelaylist, sizeof(ifly_MDAlarmDelaylist_t));
} break;
case CTRL_CMD_GETBAUDRATELIST: // CTRL_CMD_BASE+131 //获取波特率列表
{
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_BaudRateList_t);
}
memcpy(pbyAckBuf, &sRslt.sBasicInfo.BaudRateList, sizeof(ifly_BaudRateList_t));
} break;
case CTRL_CMD_STOPVOIP:
{
memcpy(&id,pbyMsgBuf,sizeof(u32));
id = ntohl(id);
*pAckLen = 0;
printf("RECV CMD:STOPVOIP id=%d...\n",id);
return remoteVoip_Stop(id);
}
break;
case CTRL_CMD_LOGIN:// CTRL_CMD_BASE+1 //远程登录命令
{
ifly_link_online links;
ifly_loginpara_t* pLoginInfo;
memset(&links,0,sizeof(links));
pLoginInfo = &sReqIns.sReq.loginpara;
memcpy(pLoginInfo,pbyMsgBuf,sizeof(ifly_loginpara_t));
(*pCB)(&sReqIns, &sRslt); // Get user info from up-layer
if(sRslt.nErrCode != 0)
{
if(pAckLen)
{
*pAckLen = 0;
}
u32 key = (8 << 16) | (0 << 8) | 1;
upload_alarm(key);
switch(sRslt.nErrCode)
{
case EM_MODUSER_LOGIN_ERR_WRONGPASSWD:
{
return CTRL_FAILED_PASSWORD;
} break;
case EM_MODUSER_LOGIN_ERR_MAC_NOPERMIT:
{
return CTRL_FAILED_MACADDR;
} break;
default:
{
return CTRL_FAILED_PARAM;
} break;
}
}
u32 key = (8 << 16) | (0 << 8) | 0;
upload_alarm(key);
SRemoteUserInfo* pUserInfo = &sRslt.sBasicInfo.sUserInfo;
links.link_online = 1;
memcpy(pbyAckBuf,&links,sizeof(links));
ifly_remusr_limit quanxian;
strcpy( quanxian.usrname, pLoginInfo->username );
#if 1
memcpy( quanxian.remote_privilege,
pUserInfo->szPrivilege,
sizeof(quanxian.remote_privilege)/sizeof(quanxian.remote_privilege[0]) );
#else
memset(quanxian.remote_privilege, '1', 16);
#endif
memcpy(pbyAckBuf+sizeof(links),&quanxian,sizeof(ifly_remusr_limit));
if(pAckLen)
{
*pAckLen = sizeof(links)+sizeof(ifly_remusr_limit);
}
}
break;
case CTRL_CMD_LOGOFF:// CTRL_CMD_BASE+2 //注销用户登录
{
printf("CTRL_CMD_LOGOFF\n");
ifly_loginpara_t* pLoginInfo;
pLoginInfo = &sReqIns.sReq.loginpara;
memcpy(pLoginInfo, pbyMsgBuf, sizeof(ifly_loginpara_t));
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = 0;
}
}
break;
case CTRL_CMD_GETDEVICEINFO:// CTRL_CMD_BASE+3 //获得设备信息
{
if(pAckLen)
{
*pAckLen = sizeof(ifly_DeviceInfo_t);
}
(*pCB)(&sReqIns, &sRslt);
memcpy(pbyAckBuf,&sRslt.sBasicInfo.DeviceInfo,sizeof(ifly_DeviceInfo_t));
printf("get device info deviceIP:%x,devicePort:%d,device_name:%s,device_mode:%s,chn=%d,maxAlarmInNum:%d\n",
sRslt.sBasicInfo.DeviceInfo.deviceIP,
ntohs(sRslt.sBasicInfo.DeviceInfo.devicePort),
sRslt.sBasicInfo.DeviceInfo.device_name,
sRslt.sBasicInfo.DeviceInfo.device_mode,
sRslt.sBasicInfo.DeviceInfo.maxChnNum,
sRslt.sBasicInfo.DeviceInfo.maxAlarmInNum);
}
break;
case CTRL_CMD_GETVIDEOPROPERTY:// CTRL_CMD_BASE+4 //视频属性信息
{
SNetCommCtrl* pNetCtrl = &sNetCommCtrl;
ifly_Video_Property_t videoproperty;
videoproperty.videoEncType = 98;
//csp modify
//videoproperty.max_videowidth = htons(704);
//videoproperty.max_videoheight = htons(576);
videoproperty.max_videowidth = htons(pNetCtrl->sCommonCfg.nVideoMaxWidth);
videoproperty.max_videoheight = htons(pNetCtrl->sCommonCfg.nVideoMaxHeight);
if(pAckLen)
{
*pAckLen = sizeof(ifly_Video_Property_t);
}
memcpy(pbyAckBuf,&videoproperty,sizeof(ifly_Video_Property_t));
printf("here,get video property:(%d,%d)\n",ntohs(videoproperty.max_videowidth),ntohs(videoproperty.max_videoheight));
}
break;
case CTRL_CMD_GETAUDIOPROPERTY:// CTRL_CMD_BASE+5 //音频属性信息
{
ifly_Audio_Property_t audioproperty;
audioproperty.audioBitPerSample = 16;
audioproperty.audioSamplePerSec = htons(8000);
#if 0//csp modify
audioproperty.audioFrameSize = htons(640);
#else
audioproperty.audioFrameSize = htons(642);
#endif
audioproperty.audioEnctype = 0;//19;//MEDIA_TYPE_PCMU;
#if 0//csp modify
audioproperty.audioFrameDurTime = htons(40);
#else
audioproperty.audioFrameDurTime = htons(40);
#endif
if(pAckLen)
{
*pAckLen = sizeof(ifly_Audio_Property_t);
}
memcpy(pbyAckBuf,&audioproperty,sizeof(ifly_Audio_Property_t));
printf("get audio property#################\n");
}
break;
case CTRL_CMD_GETVOIPPROPERTY:// CTRL_CMD_BASE+6 //voip属性信息
{
ifly_VOIP_Property_t voipproperty;
voipproperty.VOIPBitPerSample = 16;
#if 0//csp modify
voipproperty.VOIPFrameSize = htons(640);
#else
voipproperty.VOIPFrameSize = htons(642);
#endif
voipproperty.VOIPSamplePerSec = htons(8000);
if(pAckLen)
{
*pAckLen = sizeof(ifly_VOIP_Property_t);
}
memcpy(pbyAckBuf,&voipproperty,sizeof(ifly_VOIP_Property_t));
//printf("get voip property\n");
}
break;
case CTRL_CMD_GETMDPROPERTY:// CTRL_CMD_BASE+7 //移动侦测属性信息
{
ifly_MD_Property_t mdproperty;
mdproperty.MDRow = 18;
mdproperty.MDCol = 22;
if(pAckLen)
{
*pAckLen = sizeof(ifly_MD_Property_t);
}
memcpy(pbyAckBuf,&mdproperty,sizeof(ifly_MD_Property_t));
//printf("get md property\n");
}
break;
//csp modify 20130519
case CTRL_CMD_GETADVPRIVILEGE:
{
ifly_loginpara_t* pLoginInfo = &sReqIns.sReq.loginpara;
memcpy(pLoginInfo,pbyMsgBuf,sizeof(ifly_loginpara_t));
ifly_AdvPrivilege_t *pAdvPrivilege = &sRslt.sBasicInfo.AdvPrivilege;
memset(pAdvPrivilege, 0, sizeof(ifly_AdvPrivilege_t));
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_AdvPrivilege_t);
}
memcpy(pbyAckBuf, pAdvPrivilege, sizeof(ifly_AdvPrivilege_t));
printf("get user[%s] advanced privilege#################\n",pLoginInfo->username);
}
break;
#if 1
case CTRL_CMD_GETUSERINFO:
{
ifly_userNumber_t* pUsernumInfo;
pUsernumInfo = &sRslt.sBasicInfo.userNumber;
memset(pUsernumInfo, 0, sizeof(ifly_userNumber_t));
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_userNumber_t);
}
memcpy(pbyAckBuf, pUsernumInfo, sizeof(ifly_userNumber_t));
//printf("get user info!\n");
}
break;
#else
case CTRL_CMD_GETUSERINFO:
{
ifly_userNumber_t* pUsernumInfo;
pUsernumInfo = &sRslt.sBasicInfo.userNumber;
memset(pUsernumInfo, 0, sizeof(ifly_userNumber_t));
ifly_usermanage_t tem_user;
memset(tem_user.local_privilege, '1', sizeof(tem_user.local_privilege));
memset(tem_user.remote_privilege, '1', sizeof(tem_user.remote_privilege));
for(i=0;i<1;++i)
{
//GetUserInfo(&tem_user, i);
strcpy(pUsernumInfo->userNum[i].name,"admin");//tem_user.name,sizeof(pUsernumInfo->userNum[i].name));
strcpy(pUsernumInfo->userNum[i].passwd,"");//tem_user.password,sizeof(pUsernumInfo->userNum[i].passwd));
strcpy(pUsernumInfo->userNum[i].macaddr,"");//tem_user.mac_address,sizeof(pUsernumInfo->userNum[i].macaddr));
pUsernumInfo->userNum[i].lcamer = tem_user.local_privilege[0] -48;
pUsernumInfo->userNum[i].lrec = tem_user.local_privilege[1] -48;
pUsernumInfo->userNum[i].lplay = tem_user.local_privilege[2] -48;
pUsernumInfo->userNum[i].lsetpara = tem_user.local_privilege[3] -48;
pUsernumInfo->userNum[i].llog = tem_user.local_privilege[4] -48;
pUsernumInfo->userNum[i].ltool = tem_user.local_privilege[5] -48;
pUsernumInfo->userNum[i].rcamer = tem_user.remote_privilege[0] -48;
pUsernumInfo->userNum[i].rrec = tem_user.remote_privilege[1] -48;
pUsernumInfo->userNum[i].rplay = tem_user.remote_privilege[2] -48;
pUsernumInfo->userNum[i].rsetpara = tem_user.remote_privilege[3] -48;
pUsernumInfo->userNum[i].rlog = tem_user.remote_privilege[4] -48;
pUsernumInfo->userNum[i].rtool = tem_user.remote_privilege[5] -48;
pUsernumInfo->userNum[i].rpreview = tem_user.remote_privilege[6] -48;
pUsernumInfo->userNum[i].ralarm = tem_user.remote_privilege[7] -48;
pUsernumInfo->userNum[i].rvoip = tem_user.remote_privilege[8] -48;
//strncpy(pUsernumInfo->userNum[i].local_privilege,tem_user.local_privilege,sizeof(pUsernumInfo->userNum[i].local_privilege));
//strncpy(pUsernumInfo->userNum[i].remote_privilege,tem_user.remote_privilege,sizeof(pUsernumInfo->userNum[i].remote_privilege));
}
//(*pCB)(NULL, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_userNumber_t);
}
memcpy(pbyAckBuf, pUsernumInfo, sizeof(ifly_userNumber_t));
//printf("get user info!\n");
}
break;
#endif
case CTRL_CMD_GETSYSTIME:
{
ifly_sysTime_t* pGetsystemtime;
pGetsystemtime = &sRslt.sBasicInfo.sysTime;
memset(pGetsystemtime, 0, sizeof(ifly_sysTime_t));
(*pCB)(&sReqIns, &sRslt);
if(pAckLen)
{
*pAckLen = sizeof(ifly_sysTime_t);
}
//printf("get systime time:%x!\n", pGetsystemtime->systemtime);
pGetsystemtime->systemtime = htonl(pGetsystemtime->systemtime);
memcpy(pbyAckBuf, pGetsystemtime, sizeof(ifly_sysTime_t));
}
break;
#if 1
case CTRL_CMD_REBOOT:
case CTRL_CMD_SETRESTORE:
case CTRL_CMD_CLEARALARM:
case CTRL_CMD_SHUTDOWN:
{
if(pAckLen) *pAckLen = 0;
//printf("ctrl cmd %d\n", event);
(*pCB)(&sReqIns, &sRslt);
//printf("ctrl cmd %d\n", event);
}
break;
case CTRL_CMD_STOPAUDIOMONITOR:
{
memcpy(&id,pbyMsgBuf,sizeof(u32));
id = ntohl(id);
if(pAckLen) *pAckLen = 0;
printf("RECV CMD:STOPAUDIOMONITOR...\n");
return remotePreview_StopPreview(id, 0);
}
break;
case CTRL_CMD_STOPVIDEOMONITOR:
{
#define CONN_LOST_STOP 1
if(*(pbyMsgBuf+4) != CONN_LOST_STOP)//???
{
memcpy(&id,pbyMsgBuf,sizeof(u32));
id = ntohl(id);
if(pAckLen) *pAckLen = 0;
//printf("RECV CMD:STOPVIDEOMONITOR id=%d...\n",id);
return remotePreview_StopPreview(id, 1);
}
else
{
if(pAckLen) *pAckLen = 0;
}
}
break;
//csp modify 20130423
case CTRL_CMD_SETMONITORINFO:
{
ifly_wndinfo_t wndinfo;
memcpy(&wndinfo,pbyMsgBuf,sizeof(wndinfo));
id = ntohl(wndinfo.id);
u32 MonitorInfo = wndinfo.wnd_num;//wndinfo.wnd_num | (wndinfo.wnd_index << 8);
//printf("RECV CMD:CTRL_CMD_SETMONITORINFO id=%d MonitorInfo=0x%x\n",id,MonitorInfo);
if(pAckLen) *pAckLen = 0;
SNetThirdStreamProperty property;
NetComm_GetThirdStreamProperty(&property);
if(property.support)
{
s32 chn = remotePreview_SetMonitorInfo(id, MonitorInfo);//低8位,视频窗口数;高8位,窗口索引
if(chn == -1)
{
return CTRL_FAILED_LINKLIMIT;
}
}
return CTRL_SUCCESS;
}
break;
#if 1
case CTRL_CMD_RECFILESEARCH:
{
ifly_recsearch_param_t* pRemotesearch;
SCPRecFile* pRecFile;
//sNLIns.nLogId = EM_NETLOG_SEARCH_DATA_BYTIME;
//pNetCtrl->pWriteLogCB(&sNLIns);
pRecFile = &sRslt.sBasicInfo.sRecFile;
pRemotesearch = &sReqIns.sReq.recsearch_param;
memset(pRecFile, 0, sizeof(SCPRecFile));
memcpy(pRemotesearch, pbyMsgBuf, sizeof(ifly_recsearch_param_t));
pRemotesearch->channel_mask = ntohs(pRemotesearch->channel_mask);
pRemotesearch->chn17to32mask= ntohs(pRemotesearch->chn17to32mask);
pRemotesearch->type_mask = ntohs(pRemotesearch->type_mask);
pRemotesearch->start_time = ntohl(pRemotesearch->start_time);
pRemotesearch->end_time = ntohl(pRemotesearch->end_time);
pRemotesearch->startID = ntohs(pRemotesearch->startID);
pRemotesearch->max_return = ntohs(pRemotesearch->max_return);
/*
//printf("pRemotesearch->channel_mask %x\n", pRemotesearch->channel_mask );
//printf("pRemotesearch->type_mask %x\n", pRemotesearch->type_mask );
//printf("pRemotesearch->start_time %d\n", pRemotesearch->start_time );
//printf("pRemotesearch->end_time %d\n", pRemotesearch->end_time );
//printf("pRemotesearch->startID %d\n", pRemotesearch->startID );
//printf("pRemotesearch->max_return %d\n", pRemotesearch->max_return );
*/
ifly_recfileinfo_t sRecFileInfo[pRemotesearch->max_return];//zlb20111117 去掉原先malloc
pRecFile->info = sRecFileInfo;
if(NULL != pRecFile->info)
{
(*pCB)(&sReqIns, &sRslt);
for(i=pRecFile->desc.startID; i<=pRecFile->desc.endID; i++)
{
ifly_recfileinfo_t* pFinfo = &pRecFile->info[i-pRecFile->desc.startID];
/*
//printf("for sending: \n");
//printf("for sending, starttime %d\n", pFinfo->start_time);
//printf("for sending, endtime %d\n", pFinfo->end_time);
//printf("for sending, size %d\n", pFinfo->size);
//printf("for sending, offset %d\n", pFinfo->offset);
*/
pFinfo->start_time = htonl(pFinfo->start_time);
pFinfo->end_time = htonl(pFinfo->end_time);
pFinfo->size = htonl(pFinfo->size);
pFinfo->offset = htonl(pFinfo->offset);
memcpy(pbyAckBuf+sizeof(ifly_recfile_desc_t)+(i-pRecFile->desc.startID)*sizeof(ifly_recfileinfo_t),
pFinfo, sizeof(ifly_recfileinfo_t));
}
/*
//printf("for sending, sum %d\n", pRecFile->desc.sum);
//printf("for sending, endID %d\n", pRecFile->desc.endID);
*/
*pAckLen = (pRecFile->desc.endID-pRecFile->desc.startID+1)*sizeof(ifly_recfileinfo_t)+sizeof(ifly_search_desc_t);
pRecFile->desc.sum = htons(pRecFile->desc.sum);
pRecFile->desc.endID = htons(pRecFile->desc.endID);
pRecFile->desc.startID = htons(pRecFile->desc.startID);
memcpy(pbyAckBuf, &pRecFile->desc, sizeof(ifly_search_desc_t));
//printf("for sending, pAckLen %d\n", *pAckLen);
}
}
break;
#endif
case CTRL_CMD_PPPOE_PREUP:
{
printf("#################CTRL_CMD_PPPOE_PREUP#################\n");
netComm_PPPOE_CmdPreup();
} break;
case CTRL_CMD_PPPOE_UP:
{
printf("#################CTRL_CMD_PPPOE_UP#################\n");
netComm_PPPOE_CmdUp();
} break;
case CTRL_CMD_PPPOE_DOWN:
{
printf("#################CTRL_CMD_PPPOE_DOWN#################\n");
netComm_PPPOE_CmdDown();
} break;
case CTRL_CMD_PPPOE_DISCONNECT:
{
printf("#################CTRL_CMD_PPPOE_DISCONNECT#################\n");
netComm_PPPOE_CmdDisconnect();
} break;
#if 0
{
SCmdPPPOE* pCmd;
pCmd = &sReqIns.sReq.sCmdPoeIns;
pCmd->nCmdType = EM_CMD_PPPOE_PREUP+(event-CTRL_CMD_PPPOE_PREUP);
(*pCB)(&sReqIns, NULL);
}
break;
#endif
//csp modify
case CTRL_CMD_DHCP_DECONFIG:
{
ifly_cp_dhcp_t dhcp;
memcpy(&dhcp,pbyMsgBuf,sizeof(dhcp));
printf("#################CTRL_CMD_DHCP_DECONFIG interface:%s\n",dhcp.ifrname);
}
break;
//csp modify
case CTRL_CMD_DHCP_NAK:
{
printf("#################CTRL_CMD_DHCP_NAK\n");
}
break;
case CTRL_CMD_DHCP_BOUND:
case CTRL_CMD_DHCP_RENEW:
{
memcpy(&sReqIns.sReq.cp_dhcp, pbyMsgBuf, sizeof(ifly_cp_dhcp_t));
(*pCB)(&sReqIns, &sRslt);
netComm_DHCP_Active(sReqIns.sReq.cp_dhcp.ifrname);
}
break;
case CTRL_CMD_STOPDOWNLOAD:
break;
case CTRL_CMD_STOPFILEPLAY:
case CTRL_CMD_STOPTIMEPLAY:
{
sNLIns.nLogId = EM_NETLOG_PB_STOP;
sNLIns.ip=cph->ip;
pNetCtrl->pWriteLogCB(&sNLIns);
memcpy(&id,pbyMsgBuf,sizeof(u32));
id = ntohl(id);
if(pAckLen) *pAckLen = 0;
return remotePlay_Stop(id);
}
break;
case CTRL_CMD_FASTPLAY:
{
memcpy(&id,pbyMsgBuf,sizeof(u32));
id = ntohl(id);
//printf("remote fast play:(id:0x%x)\n",id);
if(pAckLen) *pAckLen = 0;
return remotePlay_FastPlay(id);
}