This repository has been archived by the owner on Mar 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
// To run, execute: go run opendb.go | ||
|
||
import ( | ||
"github.com/klauspost/oui" | ||
) | ||
|
||
// Example of opening a database | ||
func main() { | ||
// Load the content from "sampledb.txt" into a static database | ||
db, err := oui.OpenStaticFile("sampledb.txt") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
oui.PrintDb(db) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
// To run, execute: go run query.go | ||
|
||
import ( | ||
"fmt" | ||
"github.com/klauspost/oui" | ||
) | ||
|
||
// Example of querying a database | ||
func main() { | ||
// Load the content from "sampledb.txt" into a static database | ||
db, err := oui.OpenStaticFile("sampledb.txt") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Query on text string | ||
entry, err := db.Query("00-60-93-98-02-01") | ||
if err == oui.ErrNotFound { | ||
fmt.Println("Not found") | ||
} else if err != nil { | ||
panic(err) | ||
} else { | ||
fmt.Println(entry.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
// To run, execute: go run querybytes.go | ||
|
||
import ( | ||
"fmt" | ||
"github.com/klauspost/oui" | ||
) | ||
|
||
// Example of looking up with byte values | ||
func main() { | ||
// Load the content from "sampledb.txt" into a static database | ||
db, err := oui.OpenStaticFile("sampledb.txt") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// We create a hardware address with the values we would like to look up: | ||
hw := oui.HardwareAddr{0x00, 0x60, 0x92} | ||
|
||
// Now we look up | ||
entry, err := db.LookUp(hw) | ||
if err == oui.ErrNotFound { | ||
fmt.Println("Not found") | ||
} else if err != nil { | ||
panic(err) | ||
} else { | ||
fmt.Println(entry.String()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Generated: Thu, 29 Jan 2015 00:39:43 -0500 | ||
|
||
OUI/MA-L Organization | ||
company_id Organization | ||
Address | ||
|
||
00-60-92 (hex) MICRO/SYS, INC. | ||
006092 (base 16) MICRO/SYS, INC. | ||
3447 OCEAN VIEW BLVD. | ||
GLENDALE CA 91208 | ||
UNITED STATES | ||
|
||
00-60-93 (hex) VARIAN | ||
006093 (base 16) VARIAN | ||
2700 MITCHELL DR. | ||
WALNUT GREEK CA 94598 | ||
UNITED STATES | ||
|
||
00-60-94 (hex) IBM Corp - UPDATED | ||
006094 (base 16) IBM Corp | ||
3039 E Cornwallis Road | ||
PO BOX 12195 | ||
Research Triangle Park NC 27709-2195 | ||
UNITED STATES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// +build ignore | ||
|
||
package main | ||
|
||
// To run, execute: go run updatedb.go | ||
|
||
import ( | ||
"fmt" | ||
"github.com/klauspost/oui" | ||
) | ||
|
||
// Example of opening a database and updating it with new content. | ||
func main() { | ||
// Load the content from "sampledb.txt" into a dynamic database | ||
db, err := oui.OpenFile("sampledb.txt") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Get an entry | ||
entry, err := db.Query("00-60-94") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println("\n*** First Lookup:\n" + entry.String()) | ||
|
||
// Update the database | ||
err = oui.UpdateFile(db, "sampledb2.txt") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
// Get an entry | ||
entry, err = db.Query("00-60-94") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println("\n*** Second Lookup:\n" + entry.String()) | ||
} |