Skip to content

Commit b5eb8f8

Browse files
committed
Add EUI{48,64} RRType support
1 parent 5a374cf commit b5eb8f8

File tree

7 files changed

+144
-3
lines changed

7 files changed

+144
-3
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ validns: main.o carp.o mempool.o textparse.o base64.o base32hex.o \
2727
dname.o tlsa.o nid.o l32.o l64.o lp.o \
2828
ipseckey.o cbtree.o mb.o mg.o mr.o minfo.o \
2929
afsdb.o x25.o isdn.o rt.o px.o kx.o \
30-
dlv.o dhcid.o nsap.o
30+
dlv.o dhcid.o nsap.o eui48.o eui64.o
3131
$(CC) $(CFLAGS) $(OPTIMIZE) -o validns \
3232
main.o carp.o mempool.o textparse.o base64.o base32hex.o \
3333
rr.o soa.o a.o cname.o mx.o ns.o \
@@ -38,7 +38,7 @@ validns: main.o carp.o mempool.o textparse.o base64.o base32hex.o \
3838
dname.o tlsa.o nid.o l32.o l64.o lp.o \
3939
ipseckey.o cbtree.o mb.o mg.o mr.o minfo.o \
4040
afsdb.o x25.o isdn.o rt.o px.o kx.o \
41-
dlv.o dhcid.o nsap.o \
41+
dlv.o dhcid.o nsap.o eui48.o eui64.o \
4242
-L/usr/local/lib -L/opt/local/lib $(EXTRALPATH) \
4343
-lJudy -lcrypto $(EXTRALIBS) $(EXTRALINKING)
4444

@@ -53,7 +53,7 @@ clean:
5353
-rm -f nid.o l32.o l64.o lp.o ipseckey.o
5454
-rm -f cbtree.o mb.o mg.o mr.o minfo.o
5555
-rm -f afsdb.o x25.o isdn.o rt.o px.o kx.o
56-
-rm -f dlv.o dhcid.o nsap.o
56+
-rm -f dlv.o dhcid.o nsap.o eui48.o eui64.o
5757
-rm -f validns.core core
5858
@echo ':-)'
5959

@@ -141,6 +141,12 @@ nsec.o: nsec.c common.h textparse.h mempool.h carp.h rr.h
141141
dnskey.o: dnskey.c common.h textparse.h mempool.h carp.h rr.h
142142
$(CC) $(CFLAGS) $(OPTIMIZE) -c -o dnskey.o dnskey.c $(INCPATH)
143143

144+
eui48.o: eui48.c textparse.h mempool.h carp.h rr.h
145+
$(CC) $(CFLAGS) $(OPTIMIZE) -c -o eui48.o eui48.c $(INCPATH)
146+
147+
eui64.o: eui64.c textparse.h mempool.h carp.h rr.h
148+
$(CC) $(CFLAGS) $(OPTIMIZE) -c -o eui64.o eui64.c $(INCPATH)
149+
144150
txt.o: txt.c common.h textparse.h mempool.h carp.h rr.h
145151
$(CC) $(CFLAGS) $(OPTIMIZE) -c -o txt.o txt.c $(INCPATH)
146152

eui48.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Part of DNS zone file validator `validns`.
3+
*
4+
* Copyright 2016 Pieter Lexis <pieter.lexis@powerdns.com>
5+
* Modified BSD license.
6+
* (See LICENSE file in the distribution.)
7+
*
8+
*/
9+
#include <sys/types.h>
10+
#include <stdio.h>
11+
#include <string.h>
12+
#include <netinet/in.h>
13+
#include <arpa/inet.h>
14+
15+
#include "common.h"
16+
#include "textparse.h"
17+
#include "mempool.h"
18+
#include "carp.h"
19+
#include "rr.h"
20+
21+
static struct rr* eui48_parse(char *name, long ttl, int type, char *s)
22+
{
23+
struct rr_eui48 *rr = getmem(sizeof(*rr));
24+
uint8_t r[6];
25+
26+
if (sscanf(s, "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx",
27+
r, r+1, r+2, r+3, r+4, r+5) != 6) {
28+
return bitch("%s: in wrong format", name);
29+
}
30+
31+
memmove(rr->address, r, 6);
32+
33+
return store_record(type, name, ttl, rr);
34+
}
35+
36+
static struct binary_data eui48_wirerdata(struct rr *rrv)
37+
{
38+
RRCAST(eui48);
39+
struct binary_data r;
40+
41+
r.length = sizeof(rr->address);
42+
r.data = (void *)&rr->address;
43+
44+
return r;
45+
}
46+
47+
static char* eui48_human(struct rr *rrv)
48+
{
49+
return "...";
50+
}
51+
52+
struct rr_methods eui48_methods = { eui48_parse, eui48_human, eui48_wirerdata, NULL, NULL };

eui64.c

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Part of DNS zone file validator `validns`.
3+
*
4+
* Copyright 2016 Pieter Lexis <pieter.lexis@powerdns.com>
5+
* Modified BSD license.
6+
* (See LICENSE file in the distribution.)
7+
*
8+
*/
9+
#include <sys/types.h>
10+
#include <stdio.h>
11+
#include <string.h>
12+
#include <netinet/in.h>
13+
#include <arpa/inet.h>
14+
15+
#include "common.h"
16+
#include "textparse.h"
17+
#include "mempool.h"
18+
#include "carp.h"
19+
#include "rr.h"
20+
21+
static struct rr* eui64_parse(char *name, long ttl, int type, char *s)
22+
{
23+
struct rr_eui64 *rr = getmem(sizeof(*rr));
24+
uint8_t r[8];
25+
26+
if (sscanf(s, "%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx-%2hhx",
27+
r+0, r+1, r+2, r+3, r+4, r+5, r+6, r+7) != 8) {
28+
return bitch("%s: in wrong format", name);
29+
}
30+
31+
memmove(rr->address, r, 8);
32+
33+
return store_record(type, name, ttl, rr);
34+
}
35+
36+
static struct binary_data eui64_wirerdata(struct rr *rrv)
37+
{
38+
RRCAST(eui64);
39+
struct binary_data r;
40+
41+
r.length = sizeof(rr->address);
42+
r.data = (void *)&rr->address;
43+
44+
return r;
45+
}
46+
47+
static char* eui64_human(struct rr *rrv)
48+
{
49+
return "...";
50+
}
51+
52+
struct rr_methods eui64_methods = { eui64_parse, eui64_human, eui64_wirerdata, NULL, NULL };
53+

main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,8 @@ static void initialize_globals(void)
482482
rr_methods[T_DNAME] = dname_methods;
483483
rr_methods[T_DNSKEY] = dnskey_methods;
484484
rr_methods[T_DS] = ds_methods;
485+
rr_methods[T_EUI48] = eui48_methods;
486+
rr_methods[T_EUI64] = eui64_methods;
485487
rr_methods[T_HINFO] = hinfo_methods;
486488
rr_methods[T_IPSECKEY] = ipseckey_methods;
487489
rr_methods[T_ISDN] = isdn_methods;

rr.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ static char* rdtype2str_map[T_MAX+1] = {
8585
"L32",
8686
"L64",
8787
"LP",
88+
"EUI48",
89+
"EUI64",
8890
};
8991
struct cbtree zone_data = {NULL};
9092
char *zone_apex = NULL;
@@ -500,6 +502,13 @@ int str2rdtype(char *rdtype, int *is_generic)
500502
return T_DHCID;
501503
}
502504
break;
505+
case 'e':
506+
if (strcmp(rdtype, "eui48") == 0) {
507+
return T_EUI48;
508+
} else if (strcmp(rdtype, "eui64") == 0) {
509+
return T_EUI64;
510+
}
511+
break;
503512
case 'h':
504513
if (strcmp(rdtype, "hinfo") == 0) {
505514
return T_HINFO;

rr.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#define T_L32 105
5151
#define T_L64 106
5252
#define T_LP 107
53+
#define T_EUI48 108
54+
#define T_EUI64 109
5355
#define T_DLV 32769
5456
#define T_MAX 32769
5557

@@ -495,6 +497,20 @@ struct rr_dlv
495497
};
496498
extern struct rr_methods dlv_methods;
497499

500+
struct rr_eui48
501+
{
502+
struct rr rr;
503+
uint8_t address[6];
504+
};
505+
extern struct rr_methods eui48_methods;
506+
507+
struct rr_eui64
508+
{
509+
struct rr rr;
510+
uint8_t address[8];
511+
};
512+
extern struct rr_methods eui64_methods;
513+
498514
struct rr_nsap
499515
{
500516
struct rr rr;

t/zones/example.sec

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ sec-32 IPSECKEY ( 10 3 2 some.name. AQO/C76MVA5WN743YYeE537SLNffRZvQ9yxoQqJP943g
102102
sec-mixed-30 IPSECKEY ( 10 3 0 sOme.naMe. )
103103
sec-mixed-31 IPSECKEY ( 10 3 1 Some.namE. AQO/C76MVA5WN743YYeE537SLNffRZvQ9yxoQqJP943gqs4QATtnJWHQ 1SDWiRE2aXl7SJoyJAu7jaUTGKWXzStD2wpkBIJ1IZ+avxf8zxRt3y6x ImvMjRqcobreI351nbop04aBtP7o+r0zrNQmy6FqkPiI657FMEdF1cWJ 2Q4lA0Pymgq/BadXymj/LZXpmCtnTNU6laUUGuxxaf0Fj+vcL17OvU1k sLs9/9hhAbYYedmbAAGmAqfICiLBdOPCbhsCUyq8dTa0FaEinyHCJSHJ WVZ8dBpbbr2pQnZ5ul5NCgkhhcr26IPPiZm2eww6ougsogj6kPdSSQYZ YayHzVnl8NFQ9uCwbRTryepPzZP5Vd2t )
104104
sec-mixed-32 IPSECKEY ( 10 3 2 soMe.NAme. AQO/C76MVA5WN743YYeE537SLNffRZvQ9yxoQqJP943gqs4QATtnJWHQ 1SDWiRE2aXl7SJoyJAu7jaUTGKWXzStD2wpkBIJ1IZ+avxf8zxRt3y6x ImvMjRqcobreI351nbop04aBtP7o+r0zrNQmy6FqkPiI657FMEdF1cWJ 2Q4lA0Pymgq/BadXymj/LZXpmCtnTNU6laUUGuxxaf0Fj+vcL17OvU1k sLs9/9hhAbYYedmbAAGmAqfICiLBdOPCbhsCUyq8dTa0FaEinyHCJSHJ WVZ8dBpbbr2pQnZ5ul5NCgkhhcr26IPPiZm2eww6ougsogj6kPdSSQYZ YayHzVnl8NFQ9uCwbRTryepPzZP5Vd2t )
105+
106+
sec-eui48 EUI48 00-50-56-9b-00-e7
107+
sec-eui64 EUI64 00-50-56-9b-00-e7-7e-57

0 commit comments

Comments
 (0)