]>
git.ipfire.org Git - thirdparty/squid.git/blob - compat/eui64_aton.c
c4b75de99d7c13c1e6e324d4e747d3d22c66b777
2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
10 * Squid Change History:
12 * 2009-10-16 : import eui64_aton() function from NetBSD eui64.c
15 /* $NetBSD: eui64.c,v 1.1 2005/07/11 15:35:25 kiyohara Exp $ */
17 * Copyright 2004 The Aerospace Corporation. All rights reserved.
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions, and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions, and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * 3. The name of The Aerospace Corporation may not be used to endorse or
29 * promote products derived from this software.
31 * THIS SOFTWARE IS PROVIDED BY THE AEROSPACE CORPORATION "AS IS" AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED. IN NO EVENT SHALL THE AEROSPACE CORPORATION BE LIABLE
35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
46 * Redistribution and use in source and binary forms, with or without
47 * modification, are permitted provided that the following conditions
49 * 1. Redistributions of source code must retain the above copyright
50 * notice, this list of conditions and the following disclaimer.
51 * 2. Redistributions in binary form must reproduce the above copyright
52 * notice, this list of conditions and the following disclaimer in the
53 * documentation and/or other materials provided with the distribution.
54 * 3. All advertising materials mentioning features or use of this software
55 * must display the following acknowledgement:
56 * This product includes software developed by Bill Paul.
57 * 4. Neither the name of the author nor the names of any co-contributors
58 * may be used to endorse or promote products derived from this software
59 * without specific prior written permission.
61 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
62 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
63 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
64 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
65 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
66 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
67 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
68 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
70 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
73 * EUI-64 conversion and lookup routines
76 * Converted from ether_addr.c rev
77 * FreeBSD: src/lib/libc/net/eui64.c,v 1.15 2002/04/08 07:51:10 ru Exp
80 * Written by Bill Paul <wpaul@ctr.columbia.edu>
81 * Center for Telecommunications Research
82 * Columbia University, New York City
86 #include "compat/eui64_aton.h"
91 * Convert an ASCII representation of an EUI-64 to binary form.
94 eui64_aton(const char *a
, struct eui64
*e
)
97 unsigned int o0
, o1
, o2
, o3
, o4
, o5
, o6
, o7
;
100 i
= sscanf(a
, "%x-%x-%x-%x-%x-%x-%x-%x",
101 &o0
, &o1
, &o2
, &o3
, &o4
, &o5
, &o6
, &o7
);
105 i
= sscanf(a
, "%x:%x:%x:%x:%x:%x:%x:%x",
106 &o0
, &o1
, &o2
, &o3
, &o4
, &o5
, &o6
, &o7
);
109 /* classic fwcontrol/dconschat form */
110 i
= sscanf(a
, "0x%2x%2x%2x%2x%2x%2x%2x%2x",
111 &o0
, &o1
, &o2
, &o3
, &o4
, &o5
, &o6
, &o7
);
115 i
= sscanf(a
, "%x-%x-%x-%x-%x-%x",
116 &o0
, &o1
, &o2
, &o5
, &o6
, &o7
);
123 i
= sscanf(a
, "%x:%x:%x:%x:%x:%x",
124 &o0
, &o1
, &o2
, &o5
, &o6
, &o7
);
146 #endif /* !SQUID_EUI64_ATON */