summaryrefslogtreecommitdiffstats
path: root/lib/network/connection/wireless.pm
blob: e036f6c4fa51dcc7c57a9dbdb4e6bd5c9bf520e5 (plain)
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
     3 => "Philips|(SECAM+PAL_BG) (FI1216MF, FM1216MF, FR1216MF)",
     4 => "NoTuner",
     5 => "Philips|PAL_BG (FI1216 and compatibles)",
     6 => "Temic|NTSC (4032 FY5)",
     7 => "Temic|PAL_I (4062 FY5)",
     8 => "Temic|NTSC (4036 FY5)",
     9 => "Alps|HSBH1",
     10 => "Alps|TSBE1",
     11 => "Alps|TSBB5",
     12 => "Alps|TSBE5",
     13 => "Alps|TSBC5",
     14 => "Temic|PAL_BG (4006FH5)",
     15 => "Alps|TSCH6",
     16 => "Temic|PAL_DK (4016 FY5)",
     17 => "Philips|NTSC_M (MK2)",
     18 => "Temic|PAL_I (4066 FY5)",
     19 => "Temic|PAL* auto (4006 FN5)",
     20 => "Temic|PAL_BG (4009 FR5) or PAL_I (4069 FR5)",
     21 => "Temic|NTSC (4039 FR5)",
     22 => "Temic|PAL/SECAM multi (4046 FM5)",
     23 => "Philips|PAL_DK (FI1256 and compatibles)",
     24 => "Philips|PAL/SECAM multi (FQ1216ME)",
     25 => "LG|PAL_I+FM (TAPC-I001D)",
     26 => "LG|PAL_I (TAPC-I701D)",
     27 => "LG|NTSC+FM (TPI8NSR01F)",
     28 => "LG|PAL_BG+FM (TPI8PSB01D)",
     29 => "LG|PAL_BG (TPI8PSB11D)",
     30 => "Temic|PAL* auto + FM (4009 FN5)",
     31 => "SHARP NTSC_JP (2U5JF5540)",
     32 => "Samsung|PAL TCPM9091PD27",
     33 => "MT20xx universal",
     34 => "Temic|PAL_BG (4106 FH5)",
     35 => "Temic|PAL_DK/SECAM_L (4012 FY5)",
     36 => "Temic|NTSC (4136 FY5)",
     37 => "LG|PAL (newer TAPC series)",
     38 => "Philips|PAL/SECAM multi (FM1216ME)",
     39 => "LG|NTSC (newer TAPC series)",
     40 => "HITACHI V7-J180AT",
     41 => "Philips|PAL_MK (FI1216 MK)",
     42 => "Philips|1236D ATSC/NTSC daul in",
     43 => "Philips|NTSC MK3 (FM1236MK3 or FM1236/F)",
     44 => "Philips|4 in 1 (ATI TV Wonder Pro/Conexant)",
     45 => "Microtune|4049 FM5",
     46 => "Panasonic VP27s/ENGE4324D",
     47 => "LG|NTSC (TAPE series)",
     48 => "Tena|TNF 8831 BGFF",
     49 => "Microtune|4042 FI5 ATSC/NTSC dual in",
     50 => "TCL 2002N",
     51 => "Philips|PAL/SECAM_D (FM 1256 I-H3)",
     52 => "Thomson|DDT 7610 (ATSC/NTSC)",
     53 => "Philips|FQ1286",
     54 => "tda8290+75",
     55 => "LG|PAL (TAPE series)",
     56 => "Philips|PAL/SECAM multi (FQ1216AME MK4)",
     57 => "Philips|FQ1236A MK4",
     58 => "Ymec|TVision|TVF-8531MF",
     59 => "Ymec|TVision|TVF-5533MF",
     60 => "Thomson|DDT 7611 (ATSC/NTSC)",
     61 => "Tena|TNF9533-D/IF/TNF9533-B/DF",
     62 => "Philips|TEA5767HN FM Radio",
     63 => "Philips|FMD1216ME MK3 Hybrid Tuner",
     64 => "LG|TDVS-H062F/TUA6034",
     65 => "Ymec|TVF66T5-B/DFF",
     66 => "LG|NTSC (TALN mini series)",
     67 => "Philips|TD1316 Hybrid Tuner",
     68 => "Philips|TUV1236D ATSC/NTSC dual in",
     69 => "Tena|TNF 5335 MF",
     70 => "Samsung|TCPN 2121P30A",
     71 => "Xceive xc3028",


     );

# Tweaked from Cardlist
my $cards_lst = {
    'bttv' => {
        $default => -1,
        N("Unknown|Generic") => 0,
        "M|Miro|PCTV" => 1,
        "H|Hauppauge|bt848" => 2,
        "S|STB|Hauppauge 878" => 3,
        "I|Intel|Create and Share PCI (bttv type 4)" => 4,
        "I|Intel|Smart Video Recorder III (bttv type 4)" => 4,
        "D|Diamond DTV2000" => 5,
        "A|AVerMedia|TVPhone" => 6,
        "M|MATRIX Vision|MV-Delta" => 7,
        "L|Lifeview|FlyVideo II (Bt848) LR26" => 8,
        "G|Guillemot|MAXI TV Video PCI2 LR26" => 27,
        "G|Genius/Kye Video Wonder Pro II (848 or 878)" => 8,
        "I|IMS/IXmicro TurboTV" => 9,
        "H|Hauppauge|bt878" => 10,
        "M|Miro|PCTV pro" => 11,
        "A|ADS Technologies|Channel Surfer TV (bt848)" => 12,
        "A|AVerMedia|TVCapture 98" => 13,
        "A|Aimslab|Video Highway Xtreme (VHX)" => 14,
        "Zoltrix|TV-Max" => 15,
        "P|Prolink|Pixelview PlayTV (bt878)" => 16,
        "L|Leadtek|WinView 601" => 17,
        "A|AVEC|Intercapture" => 18,
        "L|Lifeview|FlyKit LR38 Bt848 (capture only)" => 19,
        "L|Lifeview|FlyVideo II EZ" => 19,
        "C|CEI Raffles Card" => 20,
        "L|Lifeview|FlyVideo 98" => 21,
        "L|Lucky Star Image World ConferenceTV LR50" => 21,
        "A|Askey|CPH050" => 22,
        "P|Phoebe Micro|Tv Master + FM" => 22,
        "M|Modular|Technology MM205 PCTV (bt878)" => 23,
        "A|Askey|CPH06X (bt878)" => 24,
        "G|Guillemot|Maxi TV Video 3" => 24,
        "A|Askey|CPH05X (bt878)" => 24,
        N("Unknown|CPH05X (bt878) [many vendors]") => 24,
        N("Unknown|CPH06X (bt878) [many vendors]") => 24,
        "T|Terratec|Terra TV+ Version 1.0 (Bt848)" => 25,
        "V|Vobis TV-Boostar" => 25,
        "T|Terratec|TV-Boostar" => 25,
        "H|Hauppauge|WinCam newer (bt878)" => 26,
        "L|Lifeview|FlyVideo 98" => 27,
        "G|Guillemot|MAXI TV Video PCI2 LR50" => 27,
        "T|Terratec|TerraTV+" => 28,
        "I|Imagenation PXC200" => 29,
        "L|Lifeview|FlyVideo 98 LR50" => 30,
        "Formac|iProTV" => 31,
        "Formac|iProTV I (bt848)" => 31,
        "I|Intel|Create and Share PCI (bttv type 32)" => 32,
        "I|Intel|Smart Video Recorder III (bttv type 32)" => 32,
        "T|Terratec|TerraTValue" => 33,
        "L|Leadtek|WinFast TV 2000" => 34,
        "L|Leadtek|WinFast VC 100" => 35,
        "L|Lifeview|FlyVideo 98 LR50" => 35,
        "C|Chronos Video Shuttle II" => 35,
        "L|Lifeview|FlyVideo 98FM LR50" => 36,
        "T|Typhoon|TView TV/FM Tuner" => 36,
        "P|Prolink|PixelView PlayTV pro" => 37,
        "P|Prolink|PixelView PlayTV Theater" => 37,
        "A|Askey|CPH06X TView99" => 38,
        "P|Pinnacle|PCTV Studio/Rave" => 39,
        "S|STB|STB2 TV PCI FM, P/N 6000704" => 40,
        "A|AVerMedia|TVPhone 98" => 41,
        "P|ProVideo|PV951" => 42,
        "L|Little OnAir TV" => 43,
        "S|Sigma TVII-FM" => 44,
        "M|MATRIX Vision|MV-Delta 2" => 45,
        "Zoltrix|Genie TV/FM" => 46,
        "T|Terratec|TV/Radio+" => 47,
        "A|Askey|CPH03x" => 48,
        "D|Dynalink Magic TView" => 48,
        "I|IODATA|GV-BCTV3/PCI" => 49,
        "P|Prolink|PixelView PlayTV PAK" => 50,
        "L|Lenco|MXTV-9578 CP" => 50,
        "P|Prolink|PV-BT878P+4E" => 50,
        "L|Lenco|MXTV-9578CP (Bt878)" => 50,
        "E|Eagle Wireless Capricorn2 (bt878A)" => 51,
        "P|Pinnacle|PCTV Studio Pro" => 52,
        "T|Typhoon|KNC1 TV Station RDS" => 53,
        "T|Typhoon|TV Tuner RDS (black package)" => 53,
        "T|Typhoon|TView RDS + FM Stereo" => 53,
        "L|Lifeview|FlyVideo 2000" => 54,
        "L|Lifeview|FlyVideo A2" => 54,
        "L|Lifetec|LT 9415 TV [LR90]" => 54,
        "A|Askey|CPH031" => 55,
        "L|Lenco|MXR-9571 (Bt848)" => 55,
        "Bestbuy|Easy TV" => 55,
        "L|Lifeview|FlyVideo 98FM LR50" => 56,
        "G|GrandTec|Grand Video Capture (Bt848)" => 57,
        "A|Askey|CPH060" => 58,
        "P|Phoebe Micro|TV Master Only (No FM)" => 58,
        "A|Askey|CPH03x TV Capturer" => 59,
        "M|Modular|Technology MM100 PCTV" => 60,
        "A|AG|Electronics GMV1" => 61,
        "A|Askey|CPH061" => 62,
        "Bestbuy|Easy TV (bt878)" => 62,
        "L|Lifetec|LT9306" => 62,
        "M|Medion MD9306" => 62,
        "A|ATI|TV-Wonder" => 63,
        "A|ATI|TV-Wonder VE" => 64,
        "L|Lifeview|FlyVideo 2000S LR90" => 65,
        "T|Terratec|TValueRadio" => 66,
        "I|IODATA|GV-BCTV4/PCI" => 67,
        "3Dfx|VoodooTV FM (Euro)" => 68,
        "3Dfx|VoodooTV 200 (USA)" => 68,
        "A|Active|Imaging AIMMS" => 69,
        "P|Prolink|Pixelview PV-BT878P+ (Rev.4C)" => 70,
        "L|Lifeview|FlyVideo 98EZ (capture only) LR51" => 71,
#    "G|Genius/Kye|Video Wonder/Genius Internet Video Kit" => 71,
        "P|Prolink|Pixelview PV-BT878P+ (Rev.9B) (PlayTV Pro rev.9B FM+NICAM)" => 72,
        "T|Typhoon|TV Tuner Pal BG (blue package)" => 72,
        "S|Sensoray 311" => 73,
        "RemoteVision|MX (RV605)" => 74,
        "P|Powercolor|MTV878" => 75,
        "P|Powercolor|MTV878R" => 75,
        "P|Powercolor|MTV878F" => 75,
        "C|Canopus WinDVR PCI (COMPAQ Presario 3524JP, 5112JP)" => 76,
        "G|GrandTec|Multi Capture Card (Bt878)" => 77,
        "Jetway TV/Capture JW-TV878-FBK" => 78,
        "K|Kworld KW-TV878RF" => 78,
        "D|DSP Design TCVIDEO" => 79,
        "H|Hauppauge|WinTV PVR" => 80,
        "G|GV-BCTV5/PCI" => 81,
        "Osprey|100/150 (878)" => 82,
        "Osprey|100/150 (848)" => 83,
        "Osprey|101 (848)" => 84,
        "Osprey|101/151" => 85,
        "Osprey|101/151 w/ svid" => 86,
        "Osprey|200/201/250/251" => 87,
        "Osprey|200/250" => 88,
        "Osprey|210/220" => 89,
        "Osprey|500" => 90,
        "Osprey|540" => 91,
        "Osprey|2000" => 92,
        "I|IDS Eagle" => 93,
        "P|Pinnacle|PCTV Sat" => 94,
        "Formac|ProTV II (bt878)" => 95,
        "M|MachTV" => 96,
        "E|Euresys|Picolo" => 97,
        "P|ProVideo|PV150" => 98,
        "A|AD-TVK503" => 99,
        "H|Hercules Smart TV Stereo" => 100,
        "P|Pace TV & Radio Card" => 101,
        "I|IVC|200" => 102,
        "G|GrandTec|Grand X-Guard / Trust 814PCI" => 103,
        "N|Nebula Electronics DigiTV" => 104,
        "P|ProVideo|PV143" => 105,
        "P|PHYTEC|VD-009-X1 MiniDIN (bt878)" => 106,
        "P|PHYTEC|VD-009-X1 Combi (bt878)" => 107,
        "P|PHYTEC|VD-009 MiniDIN (bt878)" => 108,
        "P|PHYTEC|VD-009 Combi (bt878)" => 109,
        "I|IVC|100" => 110,
        "I|IVC|120G" => 111,
        "P|pcHDTV HD-2000 TV" => 112,
        "T|Twinhan DST + clones" => 113,
        "L|Leadtek|Winfast VC100" => 114,
        "T|Teppro TEV-560/InterVision IV-560" => 115,
        "S|SIMUS GVC1100" => 116,
        "N|NGS NGSTV+" => 117,
        "L|LMLBT4" => 118,
        "T|Tekram M205 PRO" => 119,
        "C|Conceptronic|CONTVFMi" => 120,
        "E|Euresys|Picolo Tetra" => 121,
        "S|Spirit TV Tuner" => 122,
        "A|AverMedia|AVerTV DVB-T 771" => 123,
        "A|AverMedia|AverTV DVB-T 761" => 124,
        "M|MATRIX Vision|Sigma-SQ" => 125,
        "M|MATRIX Vision|Sigma-SLC" => 126,
        "A|APAC Viewcomp 878(AMAX)" => 127,
        "D|DViCO|FusionHDTV DVB-T Lite" => 128,
        "V|V-Gear MyVCD" => 129,
        "S|Super TV Tuner" => 130,
        "T|Tibet Systems 'Progress DVR' CS16" => 131,
        "K|Kodicom|4400R (master)" => 132,
        "K|Kodicom|4400R (slave)" => 133,
        "A|Adlink|RTV24" => 134,
        "D|DViCO|FusionHDTV 5 Lite" => 135,
        "A|Acorp|Y878F" => 136,
        "C|Conceptronic|CTVFMi v2" => 137,
        "P|Prolink|Pixelview PV-BT878P+ (Rev.2E)" => 138,
        "P|Prolink|PixelView PlayTV MPEG2 PV-M4900" => 139,
        "Osprey|440" => 140,
        "A|Asound|Skyeye PCTV" => 141,
        "S|Sabrent TV-FM (bttv version)" => 142,
        "H|Hauppauge|ImpactVCB (bt878)" => 143,
        "M|MagicTV" => 144,

    },
    
    'cx88' => {
        N("Unknown|Generic") => 0,
        "Hauppauge|WinTV 34xxx models" => 1,
        "GDI Black Gold" => 2,
        "PixelView|???" => 3,
        "ATI|TV Wonder Pro" => 4,
        "Leadtek|Winfast 2000XP Expert" => 5,
        "AVerTV|Studio 303 (M126)               " => 6,
        'MSI|TV-@nywhere Master' => 7,
        "Leadtek|Winfast DV2000" => 8,
        "Leadtek|PVR 2000" => 9,
        "IODATA|GV-VCP3/PCI" => 10,
        "Prolink PlayTV PVR" => 11,
        "ASUS PVR-416" => 12,
        'MSI|TV-@nywhere' => 13,
        "VStream|XPert DVB-T" => 14,
        "KWorld|XPert DVB-T" => 14,
        "DViCO|FusionHDTV DVB-T1" => 15,
        "KWorld|LTV883RF" => 16,
        "DViCO|FusionHDTV 3 Gold" => 17,
        "Hauppauge|Nova-T DVB-T" => 18,
        "Conexant DVB-T reference design" => 19,
        "Provideo PV259" => 20,
        "DViCO|FusionHDTV DVB-T Plus" => 21,
        "digitalnow|DNTV Live! DVB-T" => 22,
        "pcHDTV HD3000 HDTV" => 23,
        "Hauppauge|WinTV 28xxx (Roslyn) models" => 24,
        "Digital-Logic MICROSPACE Entertainment Center (MEC)" => 25,
        "IODATA|GV/BCTV7E" => 26,
        "PixelView|PlayTV Ultra Pro (Stereo)" => 27,
        "DViCO|FusionHDTV 3 Gold-T" => 28,
        "ADS Tech Instant TV DVB-T PCI" => 29,
        "TerraTec Cinergy 1400 DVB-T" => 30,
        "DViCO|FusionHDTV 5 Gold" => 31,
        "AverMedia UltraTV Media Center PCI 550" => 32,
        "KWorld|V-Stream Xpert DVD" => 33,
        "ATI|HDTV Wonder" => 34,
        "WinFast DTV1000-T" => 35,
        "AVerTV|303 (M126)" => 36,
        "Hauppauge|Nova-S-Plus DVB-S" => 37,
        "Hauppauge|Nova-SE2 DVB-S" => 38,
        "KWorld|VB-S 100" => 39,
        "Hauppauge|WinTV-HVR1100 DVB-T/Hybrid" => 40,
        "Hauppauge|WinTV-HVR1100 DVB-T/Hybrid (Low Profile)  [0070:9800,0070:9802]" => 41,
        "digitalnow|DNTV Live! DVB-T Pro" => 42,
        "VStream|XPert DVB-T with cx22702" => 43,
        "KWorld|XPert DVB-T with cx22702" => 43,
        "DViCO|FusionHDTV DVB-T Dual Digital" => 44,
        "KWorld|HardwareMpegTV XPert" => 45,

    },

    'saa7134' => {
        N("Unknown|Generic") => 0,
        "Proteus Pro [philips reference design]" => 1,
        "LifeView|FlyVIDEO3000" => 2,
        "LifeView|FlyVIDEO2000" => 3,
        "EMPRESS" => 4,
        "SKNet|Monster TV" => 5,
        "Tevion|MD 9717" => 6,
        "KNC|One TV-Station RDS" => 7,
        "Typhoon|TV Tuner RDS" => 7,
        "Terratec|Cinergy 400 TV" => 8,
        "Medion|5044" => 9,
        "Kworld|SAA7130-TVPCI" => 10,
        "KuroutoShikou SAA7130-TVPCI" => 10,
        "Terratec|Cinergy 600 TV" => 11,
        "Medion|7134" => 12,
        "Typhoon|TV+Radio 90031" => 13,
        "ELSA|EX-VISION 300TV" => 14,
        "ELSA|EX-VISION 500TV" => 15,
        "ASUS|TV-FM 7134" => 16,
        "AOPEN VA1000 POWER" => 17,
        "BMK|MPEX No Tuner" => 18,
        "Compro|VideoMate TV" => 19,
        "Matrox CronosPlus" => 20,
        "10MOONS PCI TV CAPTURE CARD" => 21,
        "Medion|2819" => 22,
        "AverMedia|M156" => 22,
        "BMK|MPEX Tuner" => 23,
        "KNC|One TV-Station DVR" => 24,
        "ASUS|TV-FM 7133" => 25,
        "Pinnacle|PCTV Stereo (saa7134)" => 26,
        "Manli|MuchTV M-TV002/Behold TV 403 FM" => 27,
        "Manli|MuchTV M-TV001/Behold TV 401" => 28,
        "Nagase Sangyo TransGear 3000TV" => 29,
        "Elitegroup|ECS TVP3XP FM1216 Tuner Card(PAL-BG,FM)" => 30,
        "Elitegroup|ECS TVP3XP FM1236 Tuner Card (NTSC,FM)" => 31,
        "AVACS SmartTV" => 32,
        "AverMedia|DVD EZMaker" => 33,
        "Noval Prime TV 7133" => 34,
        "AverMedia|AverTV Studio 305" => 35,
        "UPMOST PURPLE TV" => 36,
        "Items MuchTV Plus / IT-005" => 37,
        "Terratec|Cinergy 200 TV" => 38,
        "LifeView|FlyTV Platinum Mini" => 39,
        "Compro|VideoMate TV PVR/FM" => 40,
        "Compro|VideoMate TV Gold+" => 41,
        "Sabrent SBT-TVFM (saa7130)" => 42,
        "Zolid Xpert TV7134" => 43,
        "Empire PCI TV-Radio LE" => 44,
        "AverMedia|AVerTV Studio 307" => 45,
        "AverMedia|Cardbus TV/Radio" => 46,
        "Terratec|Cinergy 400 mobile" => 47,
        "Terratec|Cinergy 600 TV MK3" => 48,
        "Compro|VideoMate Gold+ Pal" => 49,
        "Pinnacle|PCTV 300i DVB-T + PAL" => 50,
        "ProVideo PV952" => 51,
        "AverMedia|AverTV/305" => 52,
        "ASUS|TV-FM 7135" => 53,
        "LifeView|FlyTV Platinum FM" => 54,
        "LifeView|FlyDVB-T DUO" => 55,
        "AverMedia|AVerTV 307" => 56,
        "AverMedia|AVerTV GO 007 FM" => 57,
        "ADS Tech Instant TV (saa7135)" => 58,
        "Kworld|V-Stream Xpert TV PVR7134" => 59,
        "Tevion|V-Stream Xpert TV PVR7134" => 59,
        "Typhoon|DVB-T Duo Digital/Analog Cardbus" => 60,
        "Philips|TOUGH DVB-T reference design" => 61,
        "Compro|VideoMate TV Gold+II" => 62,
        "Kworld|Xpert TV PVR7134" => 63,
        "FlyTV mini Asus Digimatrix" => 64,
        "Kworld|V-Stream Studio TV Terminator" => 65,
        "Yuan TUN-900 (saa7135)" => 66,
        "Beholder BeholdTV 409 FM" => 67,
        "GoTView 7135 PCI" => 68,
        "Philips|EUROPA V3 reference design" => 69,
        "Compro|Videomate DVB-T300" => 70,
        "Compro|Videomate DVB-T200" => 71,
        "RTD|Embedded Technologies VFG7350" => 72,
        "RTD|Embedded Technologies VFG7330" => 73,
        "LifeView|FlyTV Platinum Mini2" => 74,
        "AverMedia|AVerTVHD MCE A180" => 75,
        "SKNet|MonsterTV Mobile" => 76,
        "Pinnacle|PCTV 40i/50i/110i (saa7133)" => 77,
        "ASUSTeK P7131 Dual" => 78,
        "Sedna/MuchTV PC TV Cardbus TV/Radio (ITO25 Rev:2B)" => 79,
        "ASUS|Digimatrix TV" => 80,
        "Philips|Tiger reference design" => 81,
        'MSI TV@Anywhere plus' => 82,
        "Terratec|Cinergy 250 PCI TV" => 83,
        "LifeView|FlyDVB Trio" => 84,
        "AverTV DVB-T 777" => 85,
        "LifeView|FlyDVB-T" => 86,
        "ADS Instant TV Duo Cardbus PTV331" => 87,
        "Tevion|DVB-T 220RF" => 88,
        "ELSA|EX-VISION 700TV" => 89,
        "Kworld|ATSC110" => 90,

    }
};

my %pll_lst = 
    (
     -1 => N("Default"),
     0 => "do not use pll",
     1 => "28 Mhz Crystal (X)",
     2 => "35 Mhz Crystal"
     );

sub config {
    my ($in, $modules_conf, $driver) = @_;

    my $min_gbuffers = 2;
    my $max_gbuffers = 32;

    my %conf = (gbuffers => 4, card => $default, tuner => -1, radio => 0, pll => -1);

    my %cards_list = %{$cards_lst->{$driver}};
    my %rvs_cards_list = reverse %cards_list;

    # get the existing options (if there are any)
    my $current = $modules_conf->get_options($driver);

    foreach (split(/\s+/,$current)) {
        $conf{$1} = $2 if /^(gbuffers|tuner|radio|pll)=(.+)/;
        $conf{$1} = $rvs_cards_list{$2} if /^(card)=(.+)/;
    }
    
    #Sanity checks on defaults
    $conf{gbuffers} = max($min_gbuffers, $conf{gbuffers});
    $conf{gbuffers} = min($max_gbuffers, $conf{gbuffers});
    $conf{card}  = $default if !defined $cards_list{$conf{card}};
    $conf{tuner} = -1 if !defined $tuners_lst{$conf{tuner}};
    if ($driver eq 'bttv') {
        $conf{pll}   = -1 if !defined $pll_lst{$conf{tuner}};
        $conf{radio} =  0 if $conf{radio} !~ /(0|1)/;
    }


    if ($in->ask_from("BTTV configuration", N("For most modern TV cards, the bttv module of the GNU/Linux kernel just auto-detect the rights parameters.
If your card is misdetected, you can force the right tuner and card types here. Just select your tv card parameters if needed."),
                      [
                       { label => N("Card model:"), val => \$conf{card}, list => [ keys %cards_list ], default => -1, sort =>1, separator => '|' },
                       { label => N("Tuner type:"), val => \$conf{tuner}, list => [keys %tuners_lst], format => sub { $tuners_lst{$_[0]} }, sort => 1, separator => '|' },
                       { label => N("Number of capture buffers:"), val => \$conf{gbuffers}, min => $min_gbuffers, max => $max_gbuffers, sort => 1, default => 0, type => 'range', advanced => 1, help => N("number of capture buffers for mmap'ed capture") },                    
                       if_($driver eq 'bttv',
                           { label => N("PLL setting:"), val => \$conf{pll}, list => [keys %pll_lst], format => sub { $pll_lst{$_[0]} }, sort => 1, default => 0, advanced =>1 },
                           { label => N("Radio support:"), val => \$conf{radio}, type => "bool", text => N("enable radio support") }),
                       ]
                      ))
    {
        $conf{card} = $cards_list{$conf{card}};
        if (my $options = join(' ', if_($driver eq 'bttv', 'radio=' . ($conf{radio} ? 1 : 0)), map { if_($conf{$_} ne -1, "$_=$conf{$_}") } qw(card pll tuner gbuffers))) {
            log::l(qq([harddrake::v4l] set "$options" options for $driver));
#             log::explanations("modified file /etc/modules.conf ($options)") if $::isStandalone;
              $modules_conf->set_options($driver, $options);
          }
        return 1;
    }
    return 0;
}



1;
___ RELATED ADDITIONAL INFORMATION: In the Advanced Page, you can select which EAP mode is used for authentication. For the eap mode setting Auto Detect: implies all possible modes are tried. If Auto Detect fails, try the PEAP TTLS combo bofore others Note: The settings MD5, MSCHAPV2, OTP and GTC imply automatically PEAP and TTLS modes. TLS mode is completely certificate based and may ignore the username and password values specified here.") }, { label => N("EAP client certificate"), val => \$self->{access}{network}{eap_client_cert}, disabled => sub { $self->{access}{network}{encryption} ne 'wpa-eap' }, help => N("The complete path and filename of client certificate. This is only used for EAP certificate based authentication. It could be considered as the alternative to username/password combo. Note: other related settings are shown on the Advanced page.") }, { label => N("Network ID"), val => \$self->{ifcfg}{WIRELESS_NWID}, advanced => 1 }, { label => N("Operating frequency"), val => \$self->{ifcfg}{WIRELESS_FREQ}, advanced => 1 }, { label => N("Sensitivity threshold"), val => \$self->{ifcfg}{WIRELESS_SENS}, advanced => 1 }, { label => N("Bitrate (in b/s)"), val => \$self->{ifcfg}{WIRELESS_RATE}, advanced => 1 }, { label => N("RTS/CTS"), val => \$self->{ifcfg}{WIRELESS_RTS}, advanced => 1, help => N("RTS/CTS adds a handshake before each packet transmission to make sure that the channel is clear. This adds overhead, but increase performance in case of hidden nodes or large number of active nodes. This parameter sets the size of the smallest packet for which the node sends RTS, a value equal to the maximum packet size disable the scheme. You may also set this parameter to auto, fixed or off.") }, { label => N("Fragmentation"), val => \$self->{ifcfg}{WIRELESS_FRAG}, advanced => 1 }, { label => N("iwconfig command extra arguments"), val => \$self->{ifcfg}{WIRELESS_IWCONFIG}, advanced => 1, help => N("Here, one can configure some extra wireless parameters such as: ap, channel, commit, enc, power, retry, sens, txpower (nick is already set as the hostname). See iwconfig(8) man page for further information."), }, { label => #-PO: split the "xyz command extra argument" translated string into two lines if it's bigger than the english one N("iwspy command extra arguments"), val => \$self->{ifcfg}{WIRELESS_IWSPY}, advanced => 1, help => N("iwspy is used to set a list of addresses in a wireless network interface and to read back quality of link information for each of those. This information is the same as the one available in /proc/net/wireless : quality of the link, signal strength and noise level. See iwpspy(8) man page for further information."), }, { label => N("iwpriv command extra arguments"), val => \$self->{ifcfg}{WIRELESS_IWPRIV}, advanced => 1, disabled => sub { $self->need_rt2x00_iwpriv }, help => N("iwpriv enable to set up optionals (private) parameters of a wireless network interface. iwpriv deals with parameters and setting specific to each driver (as opposed to iwconfig which deals with generic ones). In theory, the documentation of each device driver should indicate how to use those interface specific commands and their effect. See iwpriv(8) man page for further information."), }, { label => N("EAP Protocol"), val => \$self->{access}{network}{forceeap}, list => [ N_("Auto Detect"), N_("WPA2"), N_("WPA") ], sort => 1, format => \&translate, advanced => 1, help => N("Auto Detect is recommended as it first tries WPA version 2 with a fallback to WPA version 1") }, { label => N("EAP Mode"), val => \$self->{access}{network}{eap_eap}, list => [ N_("Auto Detect"), N_("PEAP"), N_("TTLS"), N_("TLS"), N_("MSCHAPV2"), N_("MD5"), N_("OTP"), N_("GTC"), N_("LEAP") , N_("PEAP TTLS"), N_("TTLS TLS") ], sort => 1, format => \&translate, advanced => 1, }, { label => N("EAP key_mgmt"), val => \$self->{access}{network}{eap_key_mgmt}, advanced => 1, disabled => sub { $self->{access}{network}{encryption} ne 'wpa-eap' }, help => N("list of accepted authenticated key management protocols. possible values are WPA-EAP, IEEE8021X, NONE") }, { label => N("EAP outer identity"), val => \$self->{access}{network}{eap_anonymous_identity}, advanced => 1, disabled => sub { $self->{access}{network}{encryption} ne 'wpa-eap' }, help => N("Anonymous identity string for EAP: to be used as the unencrypted identity with EAP types that support different tunnelled identity, e.g., TTLS") }, { label => N("EAP phase2"), val => \$self->{access}{network}{eap_phase2}, advanced => 1, disabled => sub { $self->{access}{network}{encryption} ne 'wpa-eap' } , help => N("Inner authentication with TLS tunnel parameters. input is string with field-value pairs, Examples: auth=MSCHAPV2 for PEAP or autheap=MSCHAPV2 autheap=MD5 for TTLS") }, { label => N("EAP CA certificate"), val => \$self->{access}{network}{eap_ca_cert}, advanced => 1, disabled => sub { $self->{access}{network}{encryption} ne 'wpa-eap' }, help => N("Full file path to CA certificate file (PEM/DER). This file can have one or more trusted CA certificates. If ca_cert are not included, server certificate will not be verified. If possible, a trusted CA certificate should always be configured when using TLS or TTLS or PEAP.") }, { label => N("EAP certificate subject match"), val => \$self->{access}{network}{eap_subject_match}, advanced => 1, disabled => sub { $self->{access}{network}{encryption} ne 'wpa-eap' }, help => N(" Substring to be matched against the subject of the authentication server certificate. If this string is set, the server certificate is only accepted if it contains this string in the subject. The subject string is in following format: /C=US/ST=CA/L=San Francisco/CN=Test AS/emailAddress=as\@example.com") }, { label => N("Extra directives"), val => \$self->{access}{network}{extra}, advanced => 1, help => N("Here one can pass extra settings to wpa_supplicant The expected format is a string field=value pair. Multiple values maybe specified, separating each value with the # character. Note: directives are passed unchecked and may cause the wpa negotiation to fail silently. Supported directives are preserved across editing. Supported directives are : disabled, id_str, bssid, priority, auth_alg, eapol_flags, proactive_key_caching, peerkey, ca_path, private_key, private_key_passwd, dh_file, altsubject_match, phase1, fragment_size and eap_workaround, pairwise, group Others such as key_mgmt, eap maybe used to force special settings different from the U.I settings.") }, ]; } sub check_network_access_settings { my ($self) = @_; if (!member($self->{access}{network}{encryption}, qw(none wpa-eap)) && !$self->{access}{network}{key}) { $self->{network_access}{error}{message} = N("An encryption key is required."); $self->{network_access}{error}{field} = \$self->{access}{network}{key}; return 0; } if ($self->{access}{network}{encryption} eq 'wpa-psk' && !convert_psk_key_for_wpa_supplicant($self->{access}{network}{key})) { $self->{network_access}{error}{message} = N("The pre-shared key should have between 8 and 63 ASCII characters, or 64 hexadecimal characters."); $self->{network_access}{error}{field} = \$self->{access}{network}{key}; return 0; } if (member($self->{access}{network}{encryption}, qw(open restricted)) && !convert_wep_key_for_wpa_supplicant($self->{access}{network}{key}, $self->{access}{network}{force_ascii_key})) { $self->{network_access}{error}{message} = N("The WEP key should have at most %d ASCII characters or %d hexadecimal characters.", $wpa_supplicant_max_wep_key_len, $wpa_supplicant_max_wep_key_len * 2); $self->{network_access}{error}{field} = \$self->{access}{network}{key}; return 0; } if ($self->{ifcfg}{WIRELESS_FREQ} && $self->{ifcfg}{WIRELESS_FREQ} !~ /[0-9.]*[kGM]/) { $self->{network_access}{error}{message} = N("Freq should have the suffix k, M or G (for example, \"2.46G\" for 2.46 GHz frequency), or add enough '0' (zeroes)."); $self->{network_access}{error}{field} = \$self->{ifcfg}{WIRELESS_FREQ}; return 0; } if ($self->{ifcfg}{WIRELESS_RATE} && $self->{ifcfg}{WIRELESS_RATE} !~ /[0-9.]*[kGM]/) { $self->{network_access}{error}{message} = N("Rate should have the suffix k, M or G (for example, \"11M\" for 11M), or add enough '0' (zeroes)."); $self->{network_access}{error}{field} = \$self->{ifcfg}{WIRELESS_RATE}; return 0; } return 1; } sub get_control_settings { my ($self) = @_; [ @{$self->SUPER::get_control_settings}, { text => N("Allow access point roaming"), val => \$self->{control}{roaming}, type => "bool", disabled => sub { is_wpa_supplicant_blacklisted($self->get_driver) } }, ]; } sub need_wpa_supplicant { my ($self) = @_; ($self->{control}{roaming} || $self->{access}{network}{encryption} =~ /^wpa-/) && !is_old_rt2x00($self->get_driver); } sub install_packages { my ($self, $in) = @_; if ($self->need_wpa_supplicant) { $in->do_pkgs->ensure_is_installed('wpa_supplicant', '/usr/sbin/wpa_supplicant') or return; $in->do_pkgs->ensure_is_installed('mandi', '/usr/sbin/mandi'); } $self->SUPER::install_packages($in); } sub build_ifcfg_settings { my ($self) = @_; # if we are not using WEP, the key is always ASCII (#52128) $self->{access}{network}{force_ascii_key} = 1 unless member($self->{access}{network}{encryption}, qw(open restricted)); my $settings = { WIRELESS_MODE => $self->{access}{network}{mode}, if_($self->need_wpa_supplicant, WIRELESS_WPA_DRIVER => wpa_supplicant_get_driver($self->get_driver), WIRELESS_WPA_REASSOCIATE => bool2yesno($self->need_wpa_supplicant_reassociate), MII_NOT_SUPPORTED => 'no', ), WIRELESS_ESSID => $self->{access}{network}{essid}, if_($self->{access}{network}{encryption} ne 'none', WIRELESS_ENC_KEY => convert_wep_key_for_iwconfig($self->{access}{network}{key}, $self->{access}{network}{force_ascii_key})), if_(member($self->{access}{network}{encryption}, qw(open restricted)), WIRELESS_ENC_MODE => $self->{access}{network}{encryption}), if_($self->need_rt2x00_iwpriv, #- use iwpriv for WPA with rt2400/rt2500 drivers, they don't plan to support wpa_supplicant WIRELESS_IWPRIV => qq(set AuthMode=WPAPSK set EncrypType=TKIP set SSID=$self->{access}{network}{essid} set WPAPSK="$self->{access}{network}{key}" set TxRate=0)), (map { $_ => $self->{ifcfg}{$_} } qw(WIRELESS_NWID WIRELESS_FREQ WIRELESS_SENS WIRELESS_RATE WIRELESS_RTS WIRELESS_FRAG WIRELESS_IWCONFIG WIRELESS_IWSPY), if_(!$self->need_rt2x00_iwpriv, 'WIRELESS_IWPRIV')), }; $self->SUPER::build_ifcfg_settings($settings); } sub add_network_to_wpa_supplicant { my ($self) = @_; if ($self->{access}{network}{encryption} eq 'wpa-eap') { wpa_supplicant_add_eap_network($self->{access}{network}); } else { wpa_supplicant_add_network($self->{access}{network}); } #- this should be handled by the monitoring daemon instead run_program::run('/usr/sbin/wpa_cli', 'reconfigure'); } sub write_settings { my ($self, $o_net, $o_modules_conf) = @_; my $network = $self->get_selected_network; network::network::write_wireless_conf($_, $self->build_ifcfg_settings) foreach grep { $_ } ($network ? $network->{ap} : ()), $self->{access}{network}{essid}; $self->add_network_to_wpa_supplicant if $self->need_wpa_supplicant; wlan_ng_configure($self->{access}{network}{essid}, $self->{access}{network}{key}, $self->get_interface, $self->get_driver) if $self->{thirdparty}{name} eq 'prism2'; $self->SUPER::write_settings($o_net, $o_modules_conf); } sub apply_network_selection { my ($self) = @_; require network::network; my $file = network::network::get_ifcfg_file($self->get_interface); network::network::write_interface_settings($self->build_ifcfg_settings, $file); $self->add_network_to_wpa_supplicant if $self->need_wpa_supplicant; } sub network_is_configured { my ($self, $network) = @_; if ($self->{control}{roaming}) { return defined $network->{id}; } else { my $wireless_ifcfg = get_network_ifcfg($network->{ap}) || defined $network->{essid} && get_network_ifcfg($network->{essid}); return $wireless_ifcfg; } } sub connect { my ($self, $_in, $net) = @_; $self->SUPER::connect; if ($self->{control}{roaming}) { my $network_id; foreach (0 .. 1) { $self->refresh_roaming_ids if $_; my $network = $self->get_selected_network; $network_id = $network->{id} if $network && defined $network->{id}; } if (defined $network_id) { if ($net->{monitor}) { log::explanations("selecting wpa_supplicant network $network_id through network monitor"); eval { $net->{monitor}->select_network($network_id) }; return !$@; } else { run_program::run('/usr/sbin/wpa_cli', 'select_network', $network_id); } } } } sub get_status_message { my ($self, $status) = @_; my $interface = $self->get_interface; my ($current_essid, $current_ap) = get_access_point($interface); my $network = $current_essid || $current_ap && "[$current_ap]"; { link_up => N("Associated to wireless network \"%s\" on interface %s", $network, $interface), link_down => N("Lost association to wireless network on interface %s", $interface), }->{$status} || $self->SUPER::get_status_message($status); } my $wpa_supplicant_conf = "/etc/wpa_supplicant.conf"; sub get_access_point { my ($intf) = @_; (chomp_(`/sbin/iwgetid -r $intf 2>/dev/null`), lc(chomp_(`/sbin/iwgetid -r -a $intf 2>/dev/null`))); } sub is_old_rt2x00 { my ($module) = @_; member($module, qw(rt2400 rt2500 rt2570 rt61 rt73)); } sub is_wpa_supplicant_blacklisted { my ($module) = @_; is_old_rt2x00($module); } sub need_wpa_supplicant_reassociate { my ($self) = @_; $self->get_driver eq 'rt61pci'; } sub need_rt2x00_iwpriv { my ($self) = @_; is_old_rt2x00($self->get_driver) && $self->{access}{network}{encryption} eq 'wpa-psk'; } sub get_hex_key { my ($key) = @_; #- odd number or non-hexa characters, consider the key as ASCII and prepend "s:" if ($key =~ /^([[:xdigit:]]{4}[\:-]?)+[[:xdigit:]]{2,}$/) { $key =~ s/[\:-]//g; return lc($key); } } sub convert_wep_key_for_iwconfig { my ($real_key, $force_ascii) = @_; !$force_ascii && get_hex_key($real_key) || "s:$real_key"; } sub convert_wep_key_for_wpa_supplicant { my ($key, $force_ascii) = @_; if (my $hex_key = !$force_ascii && get_hex_key($key)) { return length($hex_key) <= $wpa_supplicant_max_wep_key_len * 2 && $hex_key; } else { return length($key) <= $wpa_supplicant_max_wep_key_len && qq("$key"); } } sub get_wep_key_from_iwconfig { my ($key) = @_; my ($mode, $real_key) = $key =~ /^(?:(open|restricted)\s+)?(.*)$/; my $is_ascii = $real_key =~ s/^s://; my $force_ascii = to_bool($is_ascii && get_hex_key($real_key)); ($real_key, $mode eq 'restricted', $force_ascii); } sub convert_psk_key_for_wpa_supplicant { my ($key) = @_; my $l = length($key); $l == 64 ? get_hex_key($key) : $l >= 8 && $l <= 63 ? qq("$key") : undef; } #- FIXME: to be improved (quotes, comments) sub wlan_ng_update_vars { my ($file, $vars) = @_; substInFile { while (my ($key, $value) = each(%$vars)) { s/^#?\Q$key\E=(?:"[^#]*"|[^#\s]*)(\s*#.*)?/$key=$value$1/ and delete $vars->{$key}; } $_ .= join('', map { "$_=$vars->{$_}\n" } keys %$vars) if eof; } $file; } sub wlan_ng_configure { my ($essid, $key, $device, $module) = @_; my $wlan_conf_file = "$::prefix/etc/wlan/wlan.conf"; my @wlan_devices = split(/ /, (cat_($wlan_conf_file) =~ /^WLAN_DEVICES="(.*)"/m)[0]); push @wlan_devices, $device unless member($device, @wlan_devices); #- enable device and make it use the choosen ESSID wlan_ng_update_vars($wlan_conf_file, { WLAN_DEVICES => qq("@wlan_devices"), "SSID_$device" => qq("$essid"), "ENABLE_$device" => "y" }); my $wlan_ssid_file = "$::prefix/etc/wlan/wlancfg-$essid"; #- copy default settings for this ESSID if config file does not exist -f $wlan_ssid_file or cp_f("$::prefix/etc/wlan/wlancfg-DEFAULT", $wlan_ssid_file); #- enable/disable encryption wlan_ng_update_vars($wlan_ssid_file, { (map { $_ => $key ? "true" : "false" } qw(lnxreq_hostWEPEncrypt lnxreq_hostWEPDecrypt dot11PrivacyInvoked dot11ExcludeUnencrypted)), AuthType => $key ? qq("sharedkey") : qq("opensystem"), if_($key, dot11WEPDefaultKeyID => 0, dot11WEPDefaultKey0 => qq("$key") ) }); #- hide settings for non-root users chmod 0600, $wlan_conf_file; chmod 0600, $wlan_ssid_file; #- apply settings on wlan interface require services; services::restart($module eq 'prism2_cs' ? 'pcmcia' : 'wlan'); } sub wpa_supplicant_get_driver { my ($module) = @_; $module =~ /^hostap_/ ? "hostap" : $module eq "prism54" ? "prism54" : $module =~ /^ath_/ ? "madwifi" : $module =~ /^at76c50|atmel_/ ? "atmel" : "wext"; } sub wpa_supplicant_add_network { my ($ui_input) = @_; my $conf = wpa_supplicant_read_conf(); # use shorter variables my $essid = $ui_input->{essid}; my $bssid = $ui_input->{bssid}; my $enc_mode = $ui_input->{encryption}; my $key = $ui_input->{key}; my $force_ascii = $ui_input->{force_ascii_key}; my $mode = $ui_input->{mode}; my $network = { ssid => qq("$essid"), scan_ssid => to_bool($bssid), #- hidden or non-broadcasted SSIDs if_($bssid, bssid => $bssid), if_($enc_mode ne 'none', priority => 1), }; if ($enc_mode eq 'wpa-psk') { $network->{psk} = convert_psk_key_for_wpa_supplicant($key); } else { $network->{key_mgmt} = 'NONE'; $network->{mode} = to_bool($mode eq 'Ad-hoc'); if (member($enc_mode, qw(open restricted))) { put_in_hash($network, { wep_key0 => convert_wep_key_for_wpa_supplicant($key, $force_ascii), wep_tx_keyidx => 0, auth_alg => $enc_mode eq 'restricted' ? 'SHARED' : 'OPEN', }); } } #- handle extra variables as final overides handle_extra_params($network, $ui_input->{extra}); @$conf = difference2($conf, [ wpa_supplicant_find_similar($conf, $network) ]); push @$conf, $network; wpa_supplicant_write_conf($conf); } sub wpa_supplicant_find_similar { my ($conf, $network) = @_; grep { my $current = $_; any { exists $network->{$_} && $network->{$_} eq $current->{$_} } qw(ssid bssid); } @$conf; } sub wpa_supplicant_read_conf() { my @conf; my $network; foreach (cat_($::prefix . $wpa_supplicant_conf)) { if ($network) { #- in a "network = {}" block # value is either the string with "quotes" - or a full-length string if (/^\s*(\w+)=\s*(?|([^"].*)|("[^"]*")).*$/) { $network->{$1} = $2; } elsif (/^\}/) { #- end of network block push @conf, $network; undef $network; } } elsif (/^\s*network={/) { #- beginning of a new network block $network = {}; } } \@conf; } sub wpa_supplicant_write_conf { my ($conf) = @_; my $buf; my @conf = @$conf; my $network; foreach (cat_($::prefix . $wpa_supplicant_conf)) { if ($network) { #- in a "network = {}" block if (/^\s*(\w+)=(.*)$/) { push @{$network->{entries}}, { key => $1, value => $2 }; member($1, qw(ssid bssid)) and $network->{$1} = $2; } elsif (/^\}/) { #- end of network block, write it $buf .= "network={$network->{comment}\n"; my $new_network = first(wpa_supplicant_find_similar(\@conf, $network)); foreach (@{$network->{entries}}) { my $key = $_->{key}; if ($new_network) { #- do not write entry if not provided in the new network exists $new_network->{$key} or next; #- update value from the new network $_->{value} = delete $new_network->{$key}; } $buf .= " "; $buf .= "$key=$_->{value}" if $key; $buf .= "$_->{comment}\n"; } if ($new_network) { #- write new keys while (my ($key, $value) = each(%$new_network)) { $buf .= " $key=$value\n"; } } $buf .= "}\n"; $new_network and @conf = grep { $_ != $new_network } @conf; undef $network; } else { #- unrecognized, keep it anyway push @{$network->{entries}}, { comment => $_ }; } } else { if (/^\s*network={/) { #- beginning of a new network block $network = {}; } else { #- keep other options, comments $buf .= $_; } } } #- write remaining networks foreach (@conf) { $buf .= "\nnetwork={\n"; while (my ($key, $value) = each(%$_)) { $buf .= " $key=$value\n"; } $buf .= "}\n"; } output($::prefix . $wpa_supplicant_conf, $buf); #- hide keys for non-root users chmod 0600, $::prefix . $wpa_supplicant_conf; } sub wpa_supplicant_load_eap_settings { my ($network) = @_; my $quoted_essid = qq("$network->{essid}"); my $conf = wpa_supplicant_read_conf(); foreach my $old_net (@$conf) { if ($old_net->{ssid} eq $network->{essid} || $old_net->{ssid} eq $quoted_essid) { $network->{extra} = ''; foreach my $eap_var (keys %eap_vars) { next if $eap_var eq 'ssid'; my $ui_var = join('_', "eap", $eap_var); if (defined $old_net->{$eap_var}) { if ($eap_vars{$eap_var} == 0) { if ($network->{extra} eq "") { $network->{extra} = "$eap_var=$old_net->{$eap_var}"; } else { $network->{extra} = join('#', $network->{extra}, "$eap_var=$old_net->{$eap_var}"); } } else { $network->{$ui_var} = $old_net->{$eap_var}; #- remove quotes on selected variables $network->{$ui_var} = $1 if $eap_vars{$eap_var} == 2 && $network->{$ui_var} =~ /^"(.*)"$/; if ($eap_var eq "proto") { $network->{forceeap} = 'WPA2' if $old_net->{$eap_var} eq "RSN"; $network->{forceeap} = 'WPA' if $old_net->{$eap_var} eq "WPA"; } } } } last; } } } sub handle_extra_params { my ($network, $extra) = @_; #- handle extra variables as final overides if (defined $extra && $extra ne "") { #- FIXME: should split it on what the # sign? foreach my $extra_var (split('#', $extra)) { my ($key, $val) = split('=', $extra_var, 2); $network->{$key} = $val; } } } sub wpa_supplicant_add_eap_network { my ($ui_input) = @_; #- expect all variables for us to be prefixed with eap_ my $conf = wpa_supplicant_read_conf(); my $default_eap_cfg = { pairwise => 'CCMP TKIP', group => 'CCMP TKIP', proto => 'RSN WPA', key_mgmt => 'WPA-EAP IEEE8021X NONE', scan_ssid => 1, }; if ($ui_input->{forceeap} eq 'WPA') { #- WPA only $default_eap_cfg->{pairwise} = 'TKIP'; $default_eap_cfg->{group} = 'TKIP'; $default_eap_cfg->{proto} = 'WPA'; } elsif ($ui_input->{forceeap} eq 'WPA2') { #- WPA2 only $default_eap_cfg->{pairwise} = 'CCMP TKIP'; $default_eap_cfg->{group} = 'CCMP TKIP'; $default_eap_cfg->{proto} = 'RSN'; } my $network = { ssid => qq("$ui_input->{essid}") }; #- set the values foreach my $eap_var (keys %eap_vars) { my $key = join('_', "eap", $eap_var); if (!defined $ui_input->{$key} || $ui_input->{$key} =~ /auto detect/i) { $network->{$eap_var} = $default_eap_cfg->{$eap_var} if $default_eap_cfg->{$eap_var}; } else { #- do not define if blank, the save routine will delete entry from file next if !$ui_input->{$key}; $network->{$eap_var} = $eap_vars{$eap_var} == 2 ? qq("$ui_input->{$key}") : $ui_input->{$key}; } } #- handle extra variables as final overides handle_extra_params($network, $ui_input->{extra}); $network->{mode} = to_bool($ui_input->{mode} eq 'Ad-hoc'); @$conf = difference2($conf, [ wpa_supplicant_find_similar($conf, $network) ]); push @$conf, $network; wpa_supplicant_write_conf($conf); } 1;