File: UniversalReader.cs

package info (click to toggle)
aircrack-ng 1%3A1.7%2Bgit20230807.4bf83f1a-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 21,812 kB
  • sloc: ansic: 69,601; cs: 5,392; sh: 3,924; python: 2,647; pascal: 1,242; makefile: 257; cpp: 43
file content (107 lines) | stat: -rw-r--r-- 2,960 bytes parent folder | download | duplicates (4)
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
// License: BSD/LGPL
// Copyright (C) 2011-2018 Thomas d'Otreppe
using System;
using System.Data;

namespace WirelessPanda.Readers
{
    public class UniversalReader : Reader
    {
        /// <summary>
        /// Reader
        /// </summary>
        private Reader _reader = null;

        /// <summary>
        /// File type
        /// </summary>
        /// <remarks>So that we have to check it only once</remarks>
        private string _fileType = string.Empty;

        #region Properties
        /// <summary>
        /// DataSet containing 2 tables: "Access Points" and "Stations"
        /// </summary>
        public override DataSet Dataset
        {
            get
            {
                return this._reader.Dataset;
            }
        }

        /// <summary>
        /// Array of access points
        /// </summary>
        public override AccessPoint[] AccessPoints
        {
            get
            {
                return this._reader.AccessPoints;
            }
        }

        /// <summary>
        /// Array of stations
        /// </summary>
        public override Station[] Stations
        {
            get
            {
                return this._reader.Stations;
            }
        }

        /// <summary>
        /// Reader type
        /// </summary>
        public override string ReaderType
        {
            get
            {
                return "Universal: Airodump-ng CSV, Kismet CSV, Kismet NetXML";
            }
        }
        #endregion

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="filename">Filename (doesn't need to exist now but MUST when using Read() )</param>
        public UniversalReader(string filename) : base(filename) { }

        /// <summary>
        /// Read/Update the content of the file
        /// </summary>
        /// <returns>true if successful</returns>
        public override bool Read()
        {
            this.ParseSuccess = false;

            if (string.IsNullOrEmpty(this._fileType))
            {
                this._fileType = Reader.getFileType(this.Filename);
            }

            switch (this._fileType)
            {
                case "Airodump-ng CSV":
                    this._reader = new CsvReader(this.Filename);
                    break;
                case "Kismet CSV":
                    this._reader = new KismetCsvReader(this.Filename);
                    break;
                case "Kismet NetXML":
                    this._reader = new NetXMLReader(this.Filename);
                    break;
                default:
                    throw new FormatException("Unknown file format, can't parse");
                    break;
            }

            this.ParseSuccess = this._reader.Read();

            return this.ParseSuccess;
        }
    }
}