Deleted Added
full compact
kern_uuid.c (102263) kern_uuid.c (108172)
1/*
2 * Copyright (c) 2002 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*
2 * Copyright (c) 2002 Marcel Moolenaar
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 9 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/kern_uuid.c 102263 2002-08-22 12:47:22Z bde $
26 * $FreeBSD: head/sys/kern/kern_uuid.c 108172 2002-12-22 05:35:03Z hsu $
27 */
28
29#include <sys/param.h>
30#include <sys/endian.h>
31#include <sys/kernel.h>
32#include <sys/lock.h>
33#include <sys/mutex.h>
34#include <sys/sbuf.h>

--- 51 unchanged lines hidden (view full) ---

86static void
87uuid_node(uint16_t *node)
88{
89 struct ifnet *ifp;
90 struct ifaddr *ifa;
91 struct sockaddr_dl *sdl;
92 int i;
93
27 */
28
29#include <sys/param.h>
30#include <sys/endian.h>
31#include <sys/kernel.h>
32#include <sys/lock.h>
33#include <sys/mutex.h>
34#include <sys/sbuf.h>

--- 51 unchanged lines hidden (view full) ---

86static void
87uuid_node(uint16_t *node)
88{
89 struct ifnet *ifp;
90 struct ifaddr *ifa;
91 struct sockaddr_dl *sdl;
92 int i;
93
94 /* XXX: lock ifnet. */
94 IFNET_RLOCK();
95 TAILQ_FOREACH(ifp, &ifnet, if_link) {
96 /* Walk the address list */
97 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
98 sdl = (struct sockaddr_dl*)ifa->ifa_addr;
99 if (sdl != NULL && sdl->sdl_family == AF_LINK &&
100 sdl->sdl_type == IFT_ETHER) {
101 /* Got a MAC address. */
102 bcopy(LLADDR(sdl), node, UUID_NODE_LEN);
95 TAILQ_FOREACH(ifp, &ifnet, if_link) {
96 /* Walk the address list */
97 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
98 sdl = (struct sockaddr_dl*)ifa->ifa_addr;
99 if (sdl != NULL && sdl->sdl_family == AF_LINK &&
100 sdl->sdl_type == IFT_ETHER) {
101 /* Got a MAC address. */
102 bcopy(LLADDR(sdl), node, UUID_NODE_LEN);
103 /* XXX: unlock ifnet. */
103 IFNET_RUNLOCK();
104 return;
105 }
106 }
107 }
104 return;
105 }
106 }
107 }
108 /* XXX: unlock ifnet. */
108 IFNET_RUNLOCK();
109
110 for (i = 0; i < (UUID_NODE_LEN>>1); i++)
111 node[i] = (uint16_t)arc4random();
112 *((uint8_t*)node) |= 0x80;
113}
114
115/*
116 * Get the current time as a 60 bit count of 100-nanosecond intervals

--- 108 unchanged lines hidden ---
109
110 for (i = 0; i < (UUID_NODE_LEN>>1); i++)
111 node[i] = (uint16_t)arc4random();
112 *((uint8_t*)node) |= 0x80;
113}
114
115/*
116 * Get the current time as a 60 bit count of 100-nanosecond intervals

--- 108 unchanged lines hidden ---