1 | # oui
|
2 | [![](https://img.shields.io/npm/v/oui.svg?style=flat)](https://www.npmjs.org/package/oui) [![](https://img.shields.io/npm/dm/oui.svg)](https://www.npmjs.org/package/oui)
|
3 | > Look up MAC addresses for their vendor in the IEEE OUI database
|
4 |
|
5 | The data used in this module comes from the [IEEE OUI Data](https://standards-oui.ieee.org/oui/oui.txt) which is updated once a week on Sunday. The module is also able self-update on demand.
|
6 |
|
7 | ## Installation
|
8 | ```console
|
9 | $ npm i oui
|
10 | ```
|
11 | ## Example
|
12 | ```js
|
13 | var oui = require('oui');
|
14 |
|
15 | console.log(oui('20:37:06:12:34:56'));
|
16 | //=> Cisco Systems, Inc
|
17 | //=> 80 West Tasman Drive
|
18 | //=> San Jose CA 94568
|
19 | //=> United States
|
20 |
|
21 | console.log(oui.search('*Juniper Systems*'))
|
22 | //=> [
|
23 | //=> {
|
24 | //=> oui: '0C0535',
|
25 | //=> organization: 'Juniper Systems\n1132 W. 1700 N.\nLogan UT 84321\nUnited States'
|
26 | //=> }
|
27 | //=> ]
|
28 | ```
|
29 |
|
30 | ## Installation (CLI)
|
31 | ```console
|
32 | $ npm install -g oui
|
33 | ```
|
34 | ## Examples (CLI)
|
35 | ```console
|
36 | $ oui 20:37:06:12:34:56
|
37 | Cisco Systems, Inc
|
38 | 80 West Tasman Drive
|
39 | San Jose CA 94568
|
40 | United States
|
41 | ```
|
42 | ```console
|
43 | $ oui --search cisco theory
|
44 | OUI ORGANZATION ADDRESS COUNTRY
|
45 | 000C41 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
|
46 | 000F66 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
|
47 | 001217 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
|
48 | 001310 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
|
49 | ```
|
50 | To update the local OUI database:
|
51 | ```console
|
52 | $ oui --update
|
53 | ```
|
54 | Or from the original IEEE source (slow):
|
55 | ```console
|
56 | $ oui --update http://standards.ieee.org/develop/regauth/oui/oui.txt
|
57 | ```
|
58 |
|
59 | ## API
|
60 | ### oui(input, [options])
|
61 | - `input` *string*: The input string. Non-hexadecimal characters and characters after 6 hex characters are found are ignored unless `options.strict` is set.
|
62 | - `options` *Object*: A optional options object.
|
63 | - `strict` *boolean*: When `true`, only [strict input formats will be accepted](#strictformats). Will throw an error when an invalid format is supplied.
|
64 | - `file` *string*: A absolute file path to `oui.json`, which contains the parsed oui data. Defaults to the `oui.json` in the module directory.
|
65 |
|
66 | Returns: Either a string, or `null` if no matches are found. Throws if input is not a string.
|
67 |
|
68 | ### oui.update([options])
|
69 | - `options` *Object*: A optional options object.
|
70 | - `url` *string*: The URL from where to retrieve `oui.txt`. Default `"https://standards-oui.ieee.org/oui/oui.txt"`.
|
71 | - `file` *string*: A absolute file path for `oui.json`, which is used to store the parsed oui data. Defaults to the `oui.json` in the module directory.
|
72 |
|
73 | Returns: A Promise that indicates when the internal database has been updated. Rejects on error.
|
74 |
|
75 | ### oui.search(patterns [, options])
|
76 | - `patterns` *string/Array*: One or more wildcard patterns to search the vendor data, as supported by [minimatch](https://github.com/isaacs/minimatch).
|
77 | - `options` *Object*: A optional options object.
|
78 | - `file` *String*: A absolute file path for `oui.json`, which is used to store the parsed oui data. Defaults to the `oui.json` in the module directory.
|
79 | - All [minimatch options](https://github.com/isaacs/minimatch#options) are supported as well.
|
80 |
|
81 | Returns a array of objects in the format {oui, organization}.
|
82 | <a name="strictformats" />
|
83 | #### strict formats
|
84 | - `000000`
|
85 | - `00:00:00`
|
86 | - `00-00-00`
|
87 | - `000000000000`
|
88 | - `0000.0000.0000`
|
89 | - `00:00:00:00:00:00`
|
90 | - `00-00-00-00-00-00`
|
91 |
|
92 | © [silverwind](https://github.com/silverwind), distributed under BSD licence
|