1129759Sbrooks/*
2129759Sbrooks * Copyright 2004 The Aerospace Corporation.  All rights reserved.
3129759Sbrooks *
4129759Sbrooks * Redistribution and use in source and binary forms, with or without
5129759Sbrooks * modification, are permitted provided that the following conditions
6129759Sbrooks * are met:
7129759Sbrooks *
8129759Sbrooks * 1.  Redistributions of source code must retain the above copyright
9129759Sbrooks *     notice, this list of conditions, and the following disclaimer.
10129759Sbrooks * 2.  Redistributions in binary form must reproduce the above copyright
11129759Sbrooks *     notice, this list of conditions, and the following disclaimer in the
12129759Sbrooks *     documentation and/or other materials provided with the distribution.
13129759Sbrooks * 3.  The name of The Aerospace Corporation may not be used to endorse or
14129759Sbrooks *     promote products derived from this software.
15129759Sbrooks *
16129759Sbrooks * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
17129759Sbrooks * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18129759Sbrooks * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19129759Sbrooks * ARE DISCLAIMED.  IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
20129759Sbrooks * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21129759Sbrooks * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22129759Sbrooks * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23129759Sbrooks * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24129759Sbrooks * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25129759Sbrooks * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26129759Sbrooks * SUCH DAMAGE.
27129759Sbrooks *
28129759Sbrooks * $FreeBSD$
29129759Sbrooks */
30129759Sbrooks
31129759Sbrooks#include <sys/types.h>
32129759Sbrooks#include <sys/eui64.h>
33129759Sbrooks#include <stdio.h>
34129759Sbrooks#include <string.h>
35129759Sbrooks
36129759Sbrooks#include "test-eui64.h"
37129759Sbrooks
38129759Sbrooksstatic int
39129759Sbrookstest_line(const char *line, const struct eui64 *eui, const char *host)
40129759Sbrooks{
41129759Sbrooks	struct eui64	e;
42129759Sbrooks	char		buf[256];
43137587Snik	static int	test = 0;
44129759Sbrooks
45137587Snik	test++;
46137587Snik
47129759Sbrooks	if (eui64_line(line, &e, buf, sizeof(buf)) != 0 ||
48129759Sbrooks	    memcmp(&e, eui, sizeof(struct eui64)) != 0 ||
49129759Sbrooks	    strcmp(buf, host) != 0) {
50137587Snik		printf("not ok %d - eui64_line(\"%s\")\n", test, line);
51137587Snik		printf("# host = %s\n", buf);
52129759Sbrooks		eui64_ntoa(&e, buf, sizeof(buf));
53137587Snik		printf("# e = %s\n", buf);
54129759Sbrooks		return (0);
55129759Sbrooks	} else {
56137587Snik		printf("ok %d - eui64_line(\"%s\")\n", test, line);
57129759Sbrooks		return (1);
58129759Sbrooks	}
59129759Sbrooks}
60129759Sbrooks
61129759Sbrooksint
62129759Sbrooksmain(int argc, char **argv)
63129759Sbrooks{
64129759Sbrooks
65137587Snik	printf("1..6\n");
66137587Snik
67129759Sbrooks	test_line(test_eui64_line_id, &test_eui64_id,
68129759Sbrooks	    test_eui64_id_host);
69129759Sbrooks	test_line(test_eui64_line_id_colon, &test_eui64_id,
70129759Sbrooks	    test_eui64_id_host);
71129759Sbrooks	test_line(test_eui64_line_eui48, &test_eui64_eui48,
72129759Sbrooks	    test_eui64_eui48_host);
73129759Sbrooks	test_line(test_eui64_line_mac48, &test_eui64_mac48,
74129759Sbrooks	    test_eui64_mac48_host);
75129759Sbrooks	test_line(test_eui64_line_eui48_6byte, &test_eui64_eui48,
76129759Sbrooks	    test_eui64_eui48_host);
77129759Sbrooks	test_line(test_eui64_line_eui48_6byte_c, &test_eui64_eui48,
78129759Sbrooks	    test_eui64_eui48_host);
79129759Sbrooks
80129759Sbrooks	return (0);
81129759Sbrooks}
82