Download the PHP package ocolin/maclookup without Composer
On this page you can find all versions of the php package ocolin/maclookup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ocolin/maclookup
More information about ocolin/maclookup
Files in ocolin/maclookup
Package maclookup
Short Description MAC address vendor lookup with file, memory, and database drivers
License MIT
Homepage https://github.com/ocolin/MacLookup
Informations about the package maclookup
MacLookup
Table of Contents
- What is it?
- How does it work?
- Note from Author
- Installation
- Instantiation
- Arguments
- File Driver
- Memory Driver
- Database Driver
- Lookups
- Lookup
- BulkLookup
- Special cases
- Invalid MAC
- Private MAC
- Not Found
- Formatting
- Updating
- Benchmarks
What is it?
This is a small tool for looking up MAC vendor information of a give MAC address or group of MAC addresses.
How does it work?
Upon first instantiation it downloads the library of MAC vendors from IEEE from which it can then do local lookups directly rather than connecting to an external server.
Note from Author
This version is not compatible with previous versions. The reason for this is that the previous versions were part of testing and it was not expected that they would get used by anyone. Apologies for the incompatibility but they were done in a hurry and not written for a userbase. Any further versions will be done so in a more compatible way.
Requirements
- PHP ^8.2
- SQLite extension (for some functions)
Installation
Instantiation
MacLookup has 3 static functions for instantiation depending on the intended use. Keep in mind that upon first use, this plugin will download the IEEE database which may take a few seconds. Once downloaded it will read from the local copy.
Arguments
Each instantiation can take two optional arguments. It was designed to not be used with these options, but they exist for special circumstances.
| Name | Type | Default | Description |
|---|---|---|---|
| dataPath | string | System temp files dir or project dir | Allows you so specify a folder to store the Vendor data |
| autoUpdate | boolean | true | If the vendor data is not found on instantiation, aotumatically download new data |
File Driver
This instantiation stores the data in a local file and does lookups by parsing through that file. This is the slowest method, but also the most memory efficient. Use this method if saving memory is your biggest concern.
Basic Example
Advanced Example
Memory Driver
This instantiation stores all the vendor data in memory. This driver is the fastest, but uses the most memory. Use this version if you don't care about memory usage.
Basic Example
Advanced Example
Database Driver
This instantiation stores the vendor data in an SQLite database. It's a compromise between two methods. It gives you the low memory usage of the file driver, and close to the same speed as the memory driver. However, it requires that you have the SQLite extension installed in PHP.
Basic Example
Advanced Example
Lookups
There are two methods of looking up mac addresses. One for looking up an individual mac addres, and another for doing bulk lookups.
Lookup
This function allows you to look up a single mac address.
Example:
BulkLookup
This method allows you to look up an array of MAC addresses. When searching for multiple addresses you can send them in a single request rather than make repeated single requests. This speeds up lookups when you know you have multiple lookups to make.
The output is an array using the MAC address as an array index so you can lookup a particular MAC address by array index name.
Example:
Special cases
Sometimes as MAC address may be invalid, private, or not found in the IEEE database. In these cases the registry value of the returned vendor object will inform you of the status if not something in an IEEE registry.
Invalid MAC
MacLookup will detect any invalid mac addresses and return an invalid address to save time from a long lookup.
Private MAC
MAC addresses in the reserved private space will also be spared a long lookup and returned indicating they are private.
Not Found
Some MAC addresses are valid, public, but not registered with IEEE. These will have a "Not Found" indication for the resigstry.
Formatting
MacLookup will accept MAC addresses that are coma separated or dash separated, dot separated or raw Hex. Leader zeros for will also be automatically added if needed.
Updating
Each driver has an update function for manually updating. This is not intended to be used much, however it is available should anyone want to refresh the vendor list from IEEE. The same can also be done by deleting the existing vendor file.
Benchmarks
There is a benchmark utility that can be used to compare times of lookups if needed. You can provide a MAC address for an argument and it will use all 3 drivers and compare the memory usage and speed.
All versions of maclookup with dependencies
php Version ^8.2
ext-ctype Version *