Re: mac.c

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Larry Rosenman <ler(at)lerctr(dot)org>
Cc: pgsql-hackers(at)hub(dot)org
Subject: Re: mac.c
Date: 2000-08-20 19:34:27
Message-ID: 39A032C3.24AEF14F@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Does anyone want to do the coding we've talked about?

OK, here is what I have so far, based on the work of Larry, Alex, and
others:

o Two new functions, trunc(macaddr) and text(macaddr), where the former
returns the mac address with the low (non-manufacturer) fields zeroed
out, and the latter converts to a text string. The text conversion is
nice because capabilities such as LIKE can be used transparently :) Will
need to add macaddr(text) for symmetry.

o Two utilities for contrib/mac, createoui and updateoui. The former
creates a table "macoui" with the fields oui and manufacturer. The
latter populates it with the contents of the file oui.txt, fetched from
the IEEE web site and processed by a slightly modified version of
Larry's awk script.

o An sql definition file, manuf.sql, which defines a function
manuf(macaddr) along the lines Alex had suggested. It returns a text
string of the manufacturer's name, or NULL if none is matched. You can
use COALESCE() to return something other than NULL if you want.

Should we have updateoui use wget to fetch oui.txt from the IEEE web
site? Or perhaps better we could have that in a separate utility?

Comments?

- Thomas

Some examples are

myst> ./createoui
myst> ./updateoui

lockhart=# select trunc(macaddr '00:01:a0:aa:bb:cc');
trunc
-------------------
00:01:a0:00:00:00
(1 row)

lockhart=# select manuf('01:02:03:00:00:00');
manuf
-------

(1 row)

lockhart=# select manuf('00:01:a0:00:00:00');
manuf
------------------------
Infinilink Corporation
(1 row)

lockhart=# select manuf('00:01:A0:00:00:00');
manuf
------------------------
Infinilink Corporation
(1 row)

lockhart=# select manuf('00:01:A0:00:00:01');
manuf
------------------------
Infinilink Corporation
(1 row)

lockhart=# select coalesce(manuf('01:02:03:00:00:00'), 'nada');
case
------
nada
(1 row)

lockhart=# select * from macoui where oui like '00:aa%';
oui | manufacturer
-------------------+-------------------------------
00:aa:00:00:00:00 | INTEL CORPORATION
00:aa:01:00:00:00 | INTEL CORPORATION
00:aa:02:00:00:00 | INTEL CORPORATION
00:aa:3c:00:00:00 | OLIVETTI TELECOM SPA (OLTECO)
(4 rows)

lockhart=# select * from macoui where oui like '00:AA%';
oui | manufacturer
-----+--------------
(0 rows)

lockhart=# select * from macoui where oui ilike '00:AA%';
oui | manufacturer
-------------------+-------------------------------
00:aa:00:00:00:00 | INTEL CORPORATION
00:aa:01:00:00:00 | INTEL CORPORATION
00:aa:02:00:00:00 | INTEL CORPORATION
00:aa:3c:00:00:00 | OLIVETTI TELECOM SPA (OLTECO)
(4 rows)

In response to

  • mac.c at 2000-08-20 13:47:28 from Larry Rosenman

Responses

  • Re: mac.c at 2000-08-20 22:50:58 from Larry Rosenman

Browse pgsql-hackers by date

  From Date Subject
Next Message David Lloyd-Jones 2000-08-20 20:37:30 How Do You Pronounce "PostgreSQL"?
Previous Message Tom Lane 2000-08-20 18:57:01 Re: CREATE/DROP SCHEMA considered harmful