Пример #1
0
        public int creat_multi_udp_pack2(byte[] ip, int dest_port, byte[] buff, int len,
                                         int sendtime, int inittime, int delaytime,
                                         string magic, Func Func)
        {
            int i;

            lock (multi_udp.udplock)
            {
                if ((i = get_free_buff()) < 0)
                {
                    Console.WriteLine("multi udp buff is full!");
                    //release_nest_lock(multi_udp.lock );
                    return(i);
                }
                if (magic != null)
                {
                    multi_udp.send_buff[i].Magic = magic;
                }

                multi_udp.send_buff[i].DestIP     = ip;
                multi_udp.send_buff[i].DestPort   = dest_port;
                multi_udp.send_buff[i].MaxSendNum = sendtime;
                multi_udp.send_buff[i].SendNum    = 0;
                multi_udp.send_buff[i].DelayTime  = inittime;
                multi_udp.send_buff[i].TimeMap    = delaytime;
                multi_udp.send_buff[i].Time_Count = 0;
                multi_udp.send_buff[i].timeout    = 0;
                ArrayDeal.memcpy(multi_udp.send_buff[i].Buff, buff, len);
                multi_udp.send_buff[i].nlength = len;
                multi_udp.send_buff[i].Func    = Func;
                multi_udp.send_buff[i].isValid = 1;
            }
            return(i);
        }
Пример #2
0
        static public int Remoter_Remove(byte[] IP)
        {
            int i;

            lock (remoterManageLock)
            {
                for (i = 0; i < REMOTEMAX; i++)
                {
                    if (remoter[i].isValid == 1)
                    {
                        if (ArrayDeal.vs_strstr(remoter[i].IP, IP, 4) > 0)
                        {
                            remoter[i].isValid = 0;
                            count--;
                            if (remoter[i].Audioflag > 0)
                            {
                                audio_count--;
                            }
                            if (remoter[i].Videoflag > 0)
                            {
                                video_count--;
                            }
                            Console.WriteLine("Remove:i =%d, Remotenum = " + count);
                            return(i);
                        }
                    }
                }
            }
            return(-1);
        }
Пример #3
0
 static public int Remoter_get_addr(int i, byte[] addr)
 {
     lock (remoterManageLock)
     {
         if (remoter[i].isValid > 0)
         {
             ArrayDeal.memcpy(addr, remoter[i].Addr, 6);
         }
         else
         {
             return(-1);
         }
         return(i);
     }
 }
Пример #4
0
 static public int Remoter_get_ip(int i, byte[] ip)
 {
     lock (remoterManageLock)
     {
         if (remoter[i].isValid > 0)
         {
             ArrayDeal.memcpy(ip, remoter[i].IP, 4);
         }
         else
         {
             return(-1);
         }
         return(i);
     }
 }
Пример #5
0
        static public int Remoter_Search(byte[] IP)
        {
            int i;

            lock (remoterManageLock)
            {
                for (i = 0; i < REMOTEMAX; i++)
                {
                    if (remoter[i].isValid == 1)
                    {
                        if (ArrayDeal.vs_strstr(remoter[i].IP, IP, 4) > 0)
                        {
                            //printf("Remoter_Search:%d\n",i);
                            return(i);
                        }
                    }
                }
            }
            return(-1);
        }
Пример #6
0
        static public int Remoter_Add(byte[] Addr, byte[] IP, int Audio_Flag, int Video_Flag)
        {
            int i;

            lock (remoterManageLock)
            {
                i = Remoter_Search(IP);
                if (i != -1)
                {
                    Console.WriteLine("Remoter_Add: In RemoterList\n" + i);
                    return(i);
                }

                for (i = 0; i < REMOTEMAX; i++)
                {
                    if (remoter[i].isValid == 0)
                    {
                        ArrayDeal.memcpy(remoter[i].Addr, Addr, 6);
                        ArrayDeal.memcpy(remoter[i].IP, IP, 4);
                        remoter[i].Audioflag = Audio_Flag;
                        remoter[i].Videoflag = Video_Flag;
                        remoter[i].isValid   = 1;
                        count++;
                        if (Audio_Flag == 1)
                        {
                            audio_count++;
                        }
                        if (Video_Flag == 1)
                        {
                            video_count++;
                        }
                        Console.WriteLine("Add:Remotenum =  \n" + count);
                        return(i);
                    }
                }
            }
            return(-1);
        }
Пример #7
0
        static public void udp_deal(byte[] ip, int source_port, byte[] buff, int len)
        {
            VsProtocol.Pack pack = new VsProtocol.Pack(buff);
            if (ArrayDeal.vs_strstr(CallTabPage.PublicHead, pack.PublicHead, 10) == 0)//&&
            //    ArrayDeal.vs_strstr(onvif_manage.PublicHead, pack.PublicHead, 10) == 0)
            {
                //printf("public head no match\r\n");
                return;
            }

            if (udp_filter(pack.DestAddr) == false)
            {
                //vs_printf2("udp_filter: ",addr, 0, 6);
                return;
            }
            switch (pack.FunCode) //第28位为功能码,区分是哪个功能模块的指令
            {
            case 0x01:            //生产测试指令
                break;

            case 0x02:          //系统配置指令
                break;

            case 0x03:          //呼叫对讲相关指令
                // if(Call_Record_Common_Deal(buff, ip, source_port, len) == AK_SUCCESS)
                // {
                //     break;
                // }
                stat_fun[(int)talkback.get_talkback_state()](buff, ip, source_port, len);
                break;

            case 0x04:          //门禁功能相关指令
                //DoorFunc_Deal(ip, source_port, buff, len);
                break;

            case 0x05:
                //AlarmUdpDeal(ip, source_port, buff, len);
                break;

            case 0x06:          //信息交互功能相关指令
                //Information_Deal(ip, source_port, buff, len);
                break;

            case 0x07:          //管理应用功能相关指令
                //Manage_Common_Deal(ip, source_port, buff, len);
                break;

            case 0x08:          //电梯联动相关指令
                break;

            case 0x10:          //户内相关功能指令
                /*
                 *  if(Indoor_Func_Deal(ip, source_port, buff, len) == -1)
                 *  {
                 *  MiniOS_Common_Deal(ip, source_port, buff, len);
                 * }*/
                break;

            case 0x0a:                  //网络摄像头监控相关指令
                //Onvif_ComPort_Deal(buff, ip, source_port, len);
                break;

            case 0x20:
                //File_Transfer_Common_Deal(buff, ip, source_port, len);
                break;

            default:
                break;
            }
        }