zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
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
package tbDataModel_Dell;
import java.util.Vector;
import java.util.regex.Pattern;
import BaoWen.Udp_Receive;
import Frame.S2Manage;
import Method.GetNowTime;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import tbDataModel.S2data;
 
/**´¦ÀíÍøÂçÄ£¿é·µ»ØµÄÐÅÏ¢*/
public class DellS2 {
 
    static String ip="255.255.255.255";
    static String port="1500";    
    static Vector<S2data> row=new Vector<>();
    static String mac="";
 
 
    /**ËÑË÷ÃüÁî*/
    public static void serch(String ip2) {
        String data="FF010102";
        ip=ip2;
        byte[] byt=Tools.hexStrToBinaryStr(data);
        Udp_Receive.udp_serch(byt, byt.length,ip,port);    
 
    }
 
    /**´¦ÀíËÑË÷ÃüÁî·µ»ØµÄ½á¹û*/    
    public static void serch_fanhui(String hex) {
        String[] hexs=gethex(hex);    
        String s2_ip=gi(hexs[5])+"."+gi(hexs[6])+"."+gi(hexs[7])+"."+gi(hexs[8]);;
        String s2_mac=hexs[9]+hexs[10]+hexs[11]+hexs[12]+hexs[13]+hexs[14];
 
        String s2_version1=hexs[18]+hexs[17]+hexs[16]+hexs[15];
        String s2_version=gi(s2_version1)+"";
 
        StringBuffer name=new StringBuffer();
        for(int i=19;i<35;i++) {
            name.append(hexs[i]);
        }
 
        String s2_name=toStringHex2(name.toString());
 
        if(gets2(s2_mac) ==null) {
            Vector<String> rowData=new Vector<>();
            S2data s2=new S2data();
            s2.setIp(s2_ip);
            s2.setName(s2_name);
            s2.setMac(s2_mac);
            s2.setVersion(s2_version);
            row.add(s2);
            rowData.add(s2_ip);
            rowData.add(s2_name);
            rowData.add(s2_mac);
            rowData.add(s2_version);
            if(S2Manage.getTableModel() !=null) {
                S2Manage.getTableModel().addRow(rowData);
            }
            
        }else {
            gets2(s2_mac).setIp(s2_ip);
            gets2(s2_mac).setName(s2_name);
            gets2(s2_mac).setVersion(s2_version);
        }
 
        name=null;
        hexs=null;
 
    }
 
    /**ͨ¹ýMACµØÖ·ÕÒµ½S2*/
    public static S2data gets2(String mac) {
        S2data s2=null;
        if(row.size() !=0) {
            for(int i=0;i<row.size();i++) {
                S2data news2=row.get(i);
                if(news2.getMac().equals(mac)) {
                    s2=news2;
                    break;
                }
            }
        }
        return s2;        
    }
 
 
    public static String[] gethex(String hex) {
        int lenth=hex.length()/2;
        String[] hexs=new String[lenth];
        for(int i=0;i<lenth;i++) {
            hexs[i]=hex.substring(i*2, 2+i*2);
        }
        return hexs;
    }
 
 
    /**ת»¯Ê®Áù½øÖƱàÂëΪ×Ö·û´®*/ 
    public static String toStringHex2(String s) {
        byte[] baKeyword = new byte[s.length() / 2];
        for (int i = 0; i < baKeyword.length; i++) {
            try {
                baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(
                        i * 2, i * 2 + 2), 16));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        try {
            s = new String(baKeyword, "gb2312");// UTF-16le:Not
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return s;
    }
 
    public static Vector<S2data> getRow() {
        return row;
    }
 
 
 
    /**¶ÁÈ¡ÅäÖÃÐÅÏ¢
     * @param typeÃüÁîÀàÐÍ
     * @param lenth³¤¶È
     * ·¢ËÍ(22 ×Ö½Ú FF 13 03 D8 B0 4C 46 35 CA 61 64 6D 69 6E 00 61 64 6D 69 6E 00 41 £¬
     * ºÍУÑé 41 =13 + 03 + ... + 6E + 00 £¬µÚ 4 Î»µ½µÚ 9 Î»ÊÇ S2 µÄ MAC µØÖ·£¬
     * Ð£ÑéλǰµÄ×îºóµÄ 12 ¸ö×Ö½ÚΪ S2 µÄÓû§ÃûÓëÃÜÂ룬¾ùΪ 6 ×Ö½Ú£¬²»×㣬²¹ 0 ¡£*/
    public static void reads2peizhi(byte type,String mac) {
        byte[] buf =new byte[22];
        byte[] buf1 =new byte[20];
        //°üÍ·
        buf[0]=(byte) 0xFF;
        //Êý¾Ý³¤¶È
        buf1[0]=(byte) 0x13;
 
        //ÃüÁîÀàÐÍ1×Ö½Ú
        buf1[1]=type;
 
        //macµØÖ·6×Ö½Ú
        byte[] bytmac=Tools.hexStrToBinaryStr(mac);
        for(int i=0;i<6;i++) {
            buf1[i+2]=bytmac[i];
        }
 
        //Óû§ÃûºÍÃÜÂë12×Ö½Úadmin,admin
        byte[] bytnp=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
        for(int i=0;i<12;i++) {
            buf1[i+8]=bytnp[i];
        }
 
 
        for(int i=0;i<buf1.length;i++) {
            buf[i+1]=buf1[i];
        }
 
        //УÑéÂë        
        buf[21]=Jiaoyan.checkqiuhe(buf1)[0];
        Udp_Receive.udp_serch(buf, buf.length,ip,port);
        S2Manage.get_text_area().append(GetNowTime.now()+" ·¢: "+Tools.Bytes2HexString(buf)+"\n"); 
    }
 
 
 
    /**´¦Àí·µ»ØµÄ²ÎÊý£¬Ò»¹²ÊÇ576×Ö½Ú£¬·ÖΪ4¸ö°ü·µ»Ø£¬130×Ö½Ú»ù´¡²ÎÊý±í
     * 50×Ö½Ú£¬85×Ö½Ú£¬302×Ö½Ú
     * ·µ»ØµÄÊÇ´®¿Ú·þÎñÆ÷µÄËùÓвÎÊý£¬Ò»¹²ÊÇ576 ×Ö½Ú£¬²»´øÐ£Ñ飬ûÓÐЭÒ飬ֱ½Ó·µ»Ø²ÎÊý¡£
     * ¶ÁÈ¡·½Ê½²Î¿¼¡°»ù´¡²ÎÊý±í¡±ºÍ¡°´®¿Ú²ÎÊý±í¡±ÒÔ¼°Í¸´«Ôƹ¦ÄÜ£¬ÐÄÌø×¢²á°ü¹¦Äܺ͠Httpd Client °üÍ· ÉèÖà¡£
     * ·ÖΪËĸö°ü·µ»Ø£¬·Ö±ðΪ 130 ×ֽں͠50 ×Ö½Ú£¬ 85 ×Ö½Ú£¬ 302 ×Ö½Ú ¡£
     * »ØÓ¦¾ÙÀý£º95 63 03 00 00 00 50 00 00 07 00 A8 C0 01 00 A8 C0 00 FF FF FF 55 
     * 53 52 2D 54 43 50 32 33 322D 33 31 30 00 00 61 64 6D 69 6E 00 61 64 6D 69 
     * 6E 00 00 01 00 A4 AC CF 23 20 FE 10 00 00 00 00 00 0000 00 80 25 00 00 08 
     * ÃÜÂë´íÎó»ØÓ¦£ºFF 01 03 50 £¬·µ»ØµÄÊý¾ÝÊDz»´øÐ£ÑéµÄ¡£*/
    public static void dell_readpeiz(String hex) {
        int lenth=hex.length()/2;
        String[] hexs=gethex(hex);        
        if(lenth==130) {
            //IPµØÖ·
            String s2_ip=gi(hexs[12])+"."+gi(hexs[11])+"."+gi(hexs[10])+"."+gi(hexs[9]);
 
            //Íø¹Ø
            String wangguan=gi(hexs[16])+"."+gi(hexs[15])+"."+gi(hexs[14])+"."+gi(hexs[13]);
 
            //×ÓÍøÑÚÂë
            String ziwang=gi(hexs[20])+"."+gi(hexs[19])+"."+gi(hexs[18])+"."+gi(hexs[17]);
 
            //Ä£¿éÃû³Æ                    
            String s2_name1=getname(21,35,hexs);
 
            //Óû§Ãû
            String s2_name2=getname(37,43,hexs);
 
            //ÃÜÂë
            String s2_name3=getname(43,49,hexs);
 
            //²¨ÌØÂÊ
            String botelv=gi(hexs[70]+hexs[69]+hexs[68]+hexs[67])+"";
 
            //macµØÖ·
            mac=hexs[53]+hexs[54]+hexs[55]+hexs[56]+hexs[57]+hexs[58];
 
            //±¾µØ¶Ë¿Ú
            String bendiport=gi(hexs[80]+hexs[79])+"";
 
            //Ô¶³Ì¶Ë¿Ú
            String port=gi(hexs[82]+hexs[81])+"";
 
            //·þÎñÆ÷ipµØÖ·
            String adress=getname(83,113,hexs);
 
            //¹¤×÷·½Ê½
            String type="TCP Client";
            if(hexs[118].equals("00")) {
                type="UDP-Client";
            }else if(hexs[118].equals("01")) {
                type="TCP-Client";
            }else if(hexs[118].equals("02")) {
                type="UDP-Server";
            }else if(hexs[118].equals("03")) {
                type="TCP-Server";
            }else if(hexs[118].equals("04")) {
                type="HTTPD Client";
            }
 
            S2data s2=gets2(mac);
 
            if( s2!=null) {
                s2.setIp(s2_ip);
                s2.setWangguan(wangguan);
                s2.setZiwang(ziwang);
                s2.setShebeiid(s2_name1);
                s2.setName(s2_name2);
                s2.setPass(s2_name3);
                s2.setAdress(adress);
                s2.setPort(port);
                s2.setModel(type);
                s2.setBendiport(bendiport);
                s2.setBotelv(botelv);
 
                if(!S2Manage.isAlertall()) {
                    String udpoutport=s2.getBendiport();
                    String fuwuip=Pattern.compile("[^0-9]").matcher(adress).replaceAll("").trim();//·þÎñÆ÷ipµØÖ·
                    String fuwuip2=Pattern.compile("[^0-9]").matcher(Systems.sys().getUdpAdress()).replaceAll("").trim();//ϵͳÉèÖÃÖеķþÎñÆ÷IPµØÖ·
                    S2Manage.getJt_name().setText(s2.getName());
                    S2Manage.getJt_pass().setText(s2.getPass());
                    S2Manage.getJt_shebeiname().setText(s2.getShebeiid());
                    S2Manage.getJt_ip().setText(s2.getIp());
                    S2Manage.getJt_wangguan().setText(s2.getWangguan());
                    S2Manage.getJt_ziwang().setText(s2.getZiwang());            
                    S2Manage.getJt_MAC().setText(mac);
                    S2Manage.getJt_bendiport().setText(s2.getBendiport());
                    S2Manage.getJt_botelv().setText(s2.getBotelv());
 
                    //Èç¹û±¾µØ¶Ë¿ÚºÍϵͳÉèÖõķ¢ËͶ˿ڲ»Ò»ÑùÔòÐèÒªÌáʾ
                    if(!udpoutport.equals(Systems.sys().getUdp_out())) {
                        ShowMessage.zidingyi_24("±¾µØ¶Ë¿Ú:"+udpoutport+"£¬ºÍϵͳÉèÖõÄUDP·¢ËͶ˿ڣº"+Systems.sys().getUdp_out()+
                                "²»Ò»Ö£¬ÇëÐ޸ģ¡");
                    }
 
                    S2Manage.getJt_port().setText(s2.getPort());            
                    S2Manage.getJb_xieyi().setSelectedItem(s2.getModel());
                    S2Manage.getJt_fuwuip().setText(s2.getAdress());
 
                    //Èç¹û·þÎñÆ÷ipµØÖ·ºÍϵͳÉèÖõķþÎñÆ÷ipµØÖ·²»Ò»Ñù
                    if(!fuwuip.equals(fuwuip2) ){
                        ShowMessage.zidingyi_24("Ä¿±êip:"+adress+"£¬ºÍϵͳÉèÖ÷þÎñÆ÷µØÖ·£º"+Systems.sys().getUdpAdress()+
                                "²»Ò»Ö£¬ÇëÐ޸ģ¡");
                    }
                }
            }
        }
 
    }
 
 
    /**½«16½øÖÆ×ªÎª10½øÖÆ*/
    public static int gi(String hex){
        int a1=Integer.parseInt(hex, 16);
        return a1;
    }
 
    /**½«hexתΪASCLL*/
    public static String getname(int start,int stop,String[] hexs) {
        StringBuffer name=new StringBuffer();
        for(int i=start;i<stop;i++) {
            name.append(hexs[i]);
        }            
        String s2_name=toStringHex2(name.toString());
        return s2_name;
    }
 
    /**ÅäÖûù´¡²ÎÊýÍøÂçÉèÖÃ
     * »ù´¡²ÎÊýÅäÖÃÖ¸Á
     * »ù´¡ÉèÖÃÖ¸Áî¹²°üÀ¨67 ¸ö»ù´¡²ÎÊý¡£Îª¸üºÃÉèÖÃʹÓã¬
     * ÌؾÙÀýÈçÏ£º
     * ·¢ËÍ£º FF 56 05 D8 B0 4C 46 35 CA61 64 6D 69 6E 00 61 64 6D 6 9 6E 00 95 63 
     * 03 00 00 00 50 00 00 07 00 A8 C0 01 00 A8 C0 00 FF FF FF55 53 52 2D 4B 32 
     * 00 00 00 00 00 00 00 00 00 00 61 64 6D 69 6E 00 61 64 6D 69 6E 00 00 01 00 
     * E0 D8B0 4C 46 35 CA 00 00 00 00 03 00 00 00 59 £¬
     * Ð£Ñé×Ö½ÚÈÔΪºÍУÑéËã·¨ 59 = 56 + 05 + D8 + ... + 03µÚ 4 Î»µ½ µÚ 9 Î»ÊÇ S2 µÄ MAC µØÖ·£¬ 
     * 10 Î»µ½ 22 Î»ÊÇÓû§Ãû + ÃÜÂ룬ºóÃæµÄ×Ö½Ú¾ÍÊǹ̶¨³¤¶ÈµÄ»ù´¡ÅäÖòÎÊý£¬×îºóÒ»¸ö×Ö½ÚΪºÍУÑé×Ö½Ú¡£*/
    public static void alert_s2(String ips,String wangguan,String ziwang,String mokuaiid,String macid) {
        byte[] buf =new byte[89];
        byte[] buf1 =new byte[87];
        //°üÍ·
        buf[0]=(byte) 0xFF;
        //Êý¾Ý³¤¶È
        buf1[0]=(byte) 0x56;
 
        //ÃüÁîÀàÐÍ1×Ö½Ú
        buf1[1]=(byte) 0x05;
 
        //macµØÖ·6×Ö½Ú£¬µÚ4µ½µÚ9λ
        byte[] bytmac=Tools.hexStrToBinaryStr(mac);
        if(S2Manage.isAlertall()) {
            bytmac=Tools.hexStrToBinaryStr(macid);
        }
 
        for(int i=0;i<6;i++) {
            buf1[i+2]=bytmac[i];
        }
 
        //Óû§ÃûºÍÃÜÂë12×Ö½Úadmin,admin£¬µÚ10µ½22λ
        byte[] bytnp=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
        for(int i=0;i<12;i++) {
            buf1[i+8]=bytnp[i];
        }
 
        //Ô¤Áô°üÍ·
        buf1[20]=(byte) 0x95;
 
        //Ô¤Áô°üÍ·2
        buf1[21]=(byte) 0x63;
 
        //Ô¤Áô°üÍ·3
        buf1[22]=(byte) 0x03;
 
        //ucFlags
        buf1[23]=(byte) 0x90;
 
        //usLocationURLport
        buf1[24]=(byte) 0x00;
        buf1[25]=(byte) 0x00;
 
        //HTTP·þÎñ¶Ë¿ÚusHTTPServerPort
        buf1[26]=(byte) 0x50;
        buf1[27]=(byte) 0x00;
 
        //ucUserFlag²»ÆðÓÃÔ¤ÁôЭÒé
        buf1[28]=(byte) 0x00;
 
        //¾²Ì¬IPµØÖ·4¸ö×Ö½Ú
        for(int i=0;i<4;i++) {
            buf1[29+i]=getip(ips)[i];
        }
 
        //Íø¹Ø4¸ö×Ö½Ú
        for(int i=0;i<4;i++) {
            buf1[33+i]=getip(wangguan)[i];
        }        
 
        //×ÓÍøÑÚÂë4¸ö×Ö½Ú
        for(int i=0;i<4;i++) {
            buf1[37+i]=getip(ziwang)[i];
        }
 
        //Ä£¿éÃû³Æ14¸ö×Ö½Ú        
        for(int i=0;i<14;i++) {
            buf1[41+i]=idname(mokuaiid)[i];
        }
 
        //Ô¤Áô2×Ö½Ú
        buf1[55]=(byte) 0x00;
        buf1[56]=(byte) 0x00;
 
        //Óû§Ãû£¬ÃÜÂë
        byte[] namepass=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
        for(int i=0;i<12;i++) {
            buf1[i+57]=namepass[i];
        }
 
        //Ô¤ÁôucNetSendTime
        buf1[69]=(byte) 0x00;
 
        //uiId
        buf1[70]=(byte) 0x01;
        buf1[71]=(byte) 0x00;
 
        //UCTIYPE
        buf1[72]=(byte) 0x80;
 
        //macµØÖ·
        byte[] mac1=Tools.hexStrToBinaryStr(macid);
        for(int i=0;i<6;i++) {
            buf1[i+73]=mac1[i];
        }
 
        //DNS·þÎñÆ÷µØÖ·
        byte[] data1=Tools.hexStrToBinaryStr("DE DE 43 D0 03 00 00 00");
        for(int i=0;i<8;i++) {
            buf1[i+79]=data1[i];
        }
 
 
        for(int i=0;i<buf1.length;i++) {
            buf[i+1]=buf1[i];
        }
 
        //УÑéÂë        
        buf[88]=Jiaoyan.checkqiuhe(buf1)[0];
 
        Udp_Receive.udp_serch(buf, buf.length,ip,port);         
 
    }
 
    /**´®¿Ú²ÎÊýÅäÖÃ
     * ÓÃÀ´ÅäÖÃÍø¿Ú¼°´®¿ÚµÄÖÚ¶à²ÎÊý£¬¹²ÓÐ63 ¸ö×Ö½Ú£¬Òò´ËÕâÌõÃüÁîµÄÖØÒªÐÔ²»ÑÔ¶øÓ÷¡£
     * ÏÂÃæ¾ÙÀý˵Ã÷¸ÃÃüÁîµÄʹÓ㺷¢ËÍ£¨ 63 ×Ö½Ú£©£º
     *FF 52 06 D8 B0 4C 46 35 CA 61 64 6D 69 6E 00 61 64 6D 69 6 E 00 00 C2 01 00     
     *08 01 01 01 00 00 00 00 8C 4E 2A 20 31 39 32 2E 31 36 38 2E 31 2E 31 33 33
     *00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 85 01 A8 C0 01 03 00 04 
     *10 0E 00 00 00 00 00 00 00 16 £¬Ð£Ñé×Ö½ÚËã·¨16 = 52 + 06 + ... + 00 £»
     *µÚ 4 Î»µ½µÚ 9 Î»ÊÇ S2 µÄ MAC µØÖ·£¬ 10 Î»µ½ 22 Î»ÊÇÓû§Ãû + ÃÜÂë£¬ËæºóµÄÊǶ˿ڲÎÊý + 1 ×Ö½ÚºÍУÑéλ¡£*/
    public static void alert_s2_chuankou(String adress,String macid,String model,String mbport,String botelv) {
        byte[] buf =new byte[85];
        byte[] buf1 =new byte[83];
        //°üÍ·
        buf[0]=(byte) 0xFF;
        //Êý¾Ý³¤¶È
        buf1[0]=(byte) 0x52;
 
        //ÃüÁîÀàÐÍ1×Ö½Ú
        buf1[1]=(byte) 0x06;
 
        //macµØÖ·6×Ö½Ú£¬µÚ4µ½µÚ9λ
        byte[] bytmac=Tools.hexStrToBinaryStr(macid);
        for(int i=0;i<6;i++) {
            buf1[i+2]=bytmac[i];
        }
 
        //Óû§ÃûºÍÃÜÂë12×Ö½Úadmin,admin£¬µÚ10µ½22λ
        byte[] bytnp=Tools.hexStrToBinaryStr("61 64 6D 69 6E 00 61 64 6D 69 6E 00");
        for(int i=0;i<12;i++) {
            buf1[i+8]=bytnp[i];
        }
 
 
        //Ô¶³Ì¶Ë¿Ú֮ǰµÄ²ÎÊý0-13×Ö½Ú
        String b0="00 C2 01 00";
        if(botelv.equals("921600")) {
            b0="00 10 0E 00";
        }
        String a1=b0+" 08 01 01 01 00 00 00 00 29 20";
        byte[] data1=Tools.hexStrToBinaryStr(a1);
        for(int i=0;i<14;i++) {
            buf1[i+20]=data1[i];
        }
 
        //Ô¶³Ì¶Ë¿Ú
        int pot=Integer.parseInt(mbport);
        buf1[34]=intToRegisters(pot)[3];  
        buf1[35]=intToRegisters(pot)[2];
 
        //·þÎñÆ÷IPµØÖ·ÉèÖÃ
        for(int i=0;i<30;i++) {
            buf1[36+i]=adress(adress)[i];
        }
 
        //·þÎñÆ÷ºóµÄ×Ö½Ú17
 
        String a="64 01 A8 C0 20 "+model+" 00 04 10 0E 00 00 00 00 00 00 00";
 
        byte[] data2=Tools.hexStrToBinaryStr(a);
        for(int i=0;i<17;i++) {
            buf1[i+66]=data2[i];
        }
 
 
 
        for(int i=0;i<buf1.length;i++) {
            buf[i+1]=buf1[i];
        }
 
        //УÑéÂë        
        buf[84]=Jiaoyan.checkqiuhe(buf1)[0];
        Udp_Receive.udp_serch(buf, buf.length,ip,port);
 
    }
 
 
    /**½«IPµØÖ·×ªÎª×Ö½ÚÊý×é*/
    public static byte[] getip(String ipss) {
        byte[] byt=null;        
        if(ipss !=null) {        
            byt=new byte[4];
            String[] ips=ipss.split("\\.");
            String hex3= Integer.toHexString(Integer.parseInt(ips[3]));
            if(hex3.length()<2) {
                hex3="0"+hex3;
            }
            String hex2= Integer.toHexString(Integer.parseInt(ips[2]));
            if(hex2.length()<2) {
                hex2="0"+hex2;
            }
            String hex1= Integer.toHexString(Integer.parseInt(ips[1]));
            if(hex1.length()<2) {
                hex1="0"+hex1;
            }
            String hex0= Integer.toHexString(Integer.parseInt(ips[0]));
            if(hex0.length()<2) {
                hex0="0"+hex0;
            }
            String hex=hex3+hex2+hex1+hex0;
            byt=Tools.hexStrToBinaryStr(hex);
 
        }
        return byt;
    }
 
    /**ASCLLתΪHEX*/
    private static String asciiToHex(String asciiStr) {
        char[] chars = asciiStr.toCharArray();
        StringBuilder hex = new StringBuilder();
        for (char ch : chars) {
            hex.append(Integer.toHexString((int) ch));
        }
        return hex.toString();
    }
 
    /**Ä£¿éÃû³Æ×ªÎª×Ö½ÚÊý×é*/
    public static byte[] idname(String name) {
        StringBuffer hexstr=new StringBuffer(asciiToHex(name));
        int size=hexstr.length();
        if(size<28) {
            for(int i=0;i<(28-size);i++) {
                hexstr.append("0");
            }
        }
        byte[] byt=Tools.hexStrToBinaryStr(hexstr.toString());    
 
        return byt;        
    }
 
    /**·þÎñÆ÷µØÖ·Ãû³Æ×ªÎª×Ö½ÚÊý×é*/
    public static byte[] adress(String name) {
        StringBuffer hexstr=new StringBuffer(asciiToHex(name));
        int size=hexstr.length();
        if(size<60) {
            for(int i=0;i<(60-size);i++) {
                hexstr.append("0");
            }
        }
        byte[] byt=Tools.hexStrToBinaryStr(hexstr.toString());    
 
        return byt;        
    }
 
    /**ÐÞ¸ÄËùÓÐS2µÄÐÅÏ¢
     * @param ip S2µÄ¾²Ì¬IPµØÖ·
     * @param wangguanÍø¹ØµØÖ·
     * @param adress·þÎñÆ÷µÄµØÖ·*/
    public static void alertall_S2(String ipd,String wangguan,String adress,String port,String botelv) {        
 
        for(int i=0;i<row.size();i++) {
            S2data s2=row.get(i);
            String macid=s2.getMac();
            String ip1=s2.getIp();
            String ziwang=s2.getZiwang();
            String mokuaiid=s2.getShebeiid();
            String adress1=s2.getAdress();
            String model="00";
            if(s2.getModel().equals("TCP-Client")) {
                model="01";                
            }
 
 
            if(ip1==null) {
                ShowMessage.zidingyi(macid+"ûÓÐÐ޸ijɹ¦£¡");
                return;
            }
 
            //Èç¹ûÐÞ¸ÄÄ¿±êipµØÖ·±»Ñ¡ÖÐÖ»ÐÞ¸ÄÄ¿±êip
            if(!adress.equals("1") &&  wangguan.equals("1") && ipd.equals("1")) {
                if(!adress1.equals(adress) ){
                    DellS2.alert_s2_chuankou(adress,macid,model,port,botelv);
                }
 
                //¶¼ÐÞ¸Ä
            }else if(!adress.equals("1") && !wangguan.equals("1") && !ipd.equals("1")) {
 
                String[] ips=ipd.split("\\.");
                String[] ip1s=ip1.split("\\.");
                ip1=ip1s[0]+"."+ip1s[1]+"."+ips[2]+"."+ip1s[3];    
                DellS2.alert_s2(ip1, wangguan, ziwang, mokuaiid, macid);
 
                if(!adress1.equals(adress) ){
                    DellS2.alert_s2_chuankou(adress,macid,model,port,botelv);
                }
 
                ips=null;
                ip1s=null;
 
                //Ö»ÐÞ¸ÄÍø¹ØºÍÄ¿±êip
            }else if(!adress.equals("1") && !wangguan.equals("1") && ipd.equals("1")) {
                DellS2.alert_s2(ip1, wangguan, ziwang, mokuaiid, macid);
                DellS2.alert_s2_chuankou(adress,macid,model,port,botelv);
            }
 
        }
 
    }
 
    /**»ñÈ¡ËùÓÐS2µÄÐÅÏ¢*/
    public static void getalls2() {        
        if(row.size() !=0) {
            for(int i=0;i<row.size();i++) {
                S2data s2=row.get(i);
                reads2peizhi((byte)0x03,s2.getMac());                
            }
        }
    }
 
    public static  byte[] intToRegisters(int v) {
        byte[] registers = new byte[4];
        registers[0] = (byte) (0xff & (v >> 24));
        registers[1] = (byte) (0xff & (v >> 16));
        registers[2] = (byte) (0xff & (v >> 8));
        registers[3] = (byte) (0xff & v);
        return registers;
    }
}