UNPKG

3.75 kBMarkdownView Raw
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
5The data used in this module comes from the [Sanitized IEEE OUI Data](http://linuxnet.ca/ieee/oui/) 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
13var oui = require('oui');
14
15console.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
21console.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
30There's also a browser version available as `oui.web.min.js` which uses a reduced dataset that only contains the vendor name.
31
32## Installation (CLI)
33```console
34$ npm install -g oui
35```
36## Examples (CLI)
37```console
38$ oui 20:37:06:12:34:56
39Cisco Systems, Inc
4080 West Tasman Drive
41San Jose CA 94568
42United States
43```
44```console
45$ oui --search cisco theory
46OUI ORGANZATION ADDRESS COUNTRY
47000C41 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
48000F66 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
49001217 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
50001310 Cisco-Linksys LLC 121 Theory Dr. Irvine CA 92612
51```
52To update the local OUI database:
53```console
54$ oui --update
55```
56Or from the original IEEE source (slow):
57```console
58$ oui --update http://standards.ieee.org/develop/regauth/oui/oui.txt
59```
60
61## API
62### oui(input, [options])
63- `input` *string*: The input string. Non-hexadecimal characters and characters after 6 hex characters are found are ignored unless `options.strict` is set.
64- `options` *Object*: A optional options object.
65 - `strict` *boolean*: When `true`, only [strict input formats will be accepted](#strictformats). Will throw an error when an invalid format is supplied.
66 - `file` *string*: A absolute file path to `oui.json`, which contains the parsed oui data. Defaults to the `oui.json` in the module directory.
67
68Returns: Either a string, or `null` if no matches are found. Throws if input is not a string.
69
70### oui.update([options])
71- `options` *Object*: A optional options object.
72 - `url` *string*: The URL from where to retrieve `oui.txt`. Defaults to `'http://linuxnet.ca/ieee/oui.txt'`. To use the more frequently updated but inconsistent and slower to download original file from IEEE, use `'http://standards.ieee.org/develop/regauth/oui/oui.txt'`.
73 - `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.
74
75Returns: A Promise that indicates when the internal database has been updated. Rejects on error.
76
77### oui.search(patterns [, options])
78- `patterns` *string/Array*: One or more wildcard patterns to search the vendor data, as supported by [minimatch](https://github.com/isaacs/minimatch).
79- `options` *Object*: A optional options object.
80 - `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.
81 - All [minimatch options](https://github.com/isaacs/minimatch#options) are supported as well.
82
83Returns a array of objects in the format {oui, organization}.
84<a name="strictformats" />
85#### strict formats
86- `000000`
87- `00:00:00`
88- `00-00-00`
89- `000000000000`
90- `0000.0000.0000`
91- `00:00:00:00:00:00`
92- `00-00-00-00-00-00`
93
94© [silverwind](https://github.com/silverwind), distributed under BSD licence