Updated Mac2vendor

I have just updated mac2vendor to a new version. The previous version used Google Fusion Tables for data storage, but I found this easy to maintain. I have now changed it to static data on my webserver, that can easily be updated through a cron job.

Also this version fixes a nasty bug that could make the page reload on entering data, deleting your input in the proces.

The new version uses a Perl script that imports the IEEE oui.txt file and generates a directory structure using the first and second octets of the oui, like so:

oui
  |
   - 00
  |   |
  |    - 01
  |   |
  |    - 02
  |   |
  |    ...
  |
   - 01
  |   |
  |    ...
  |
   ...

The leaves are text files containing the last octet of the OUI, and the vendor description as tab separated values. This makes all files at most 255 rows long, which I believe should be light enough to send to the browser to sort out.

A sample file, oui/CC/E7 for example, contains:

98  My Social Stuff
DF  American Magnetics, Inc.

The browser handles this as follows:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
   function fetch(octets) {

      var ouibase = document.location.origin + '/oui';
      var result = document.getElementById("res");

      $.get( [ouibase, octets[0], octets[1]].join('/'),
          function (data) {
              var lines = data.split("\n");
              for (var i = 0; i < lines.length; i++) {
                  var fields = lines[i].split("\t");
                  if (fields[0] == octets[2])
                      result.value = fields[1];
              };
              if ( result.value.length <= 0 )
                  result.value = "No results";
          }
      ).error( function () {
          document.getElementById("res").value = "No results";
      });
  };

A bit dirty code, but it works and seems to be pretty snappy in response times too. At least much better than using Fusion Tables. The data files are only a few kB in size, so I think they’ll be also pretty cachable. In my tests I see some nice 304’s appearing in my access logs, anyway. :)

Oh, and no JSON or XML needed…yay. :)

Comments