FreeBSD kernel kern code
kern_uuid.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/endian.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/sbuf.h>
#include <sys/socket.h>
#include <sys/sysproto.h>
#include <sys/systm.h>
#include <sys/jail.h>
#include <sys/uuid.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <net/vnet.h>
Include dependency graph for kern_uuid.c:

Go to the source code of this file.

Data Structures

struct  uuid_private
 
struct  uuid_macaddr
 
struct  uuidgen_args
 

Macros

#define UUID_ETHER_EMPTY   0
 
#define UUID_ETHER_RANDOM   1
 
#define UUID_ETHER_UNIQUE   2
 
#define UUID_NETHER   4
 
#define VUUIDF_PARSEFLAGS   (VUUIDF_EMPTYOK | VUUIDF_CHECKSEMANTICS)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 CTASSERT (sizeof(struct uuid)==16)
 
 CTASSERT (sizeof(struct uuid_private)==16)
 
 MTX_SYSINIT (uuid_lock, &uuid_mutex, "UUID generator mutex lock", MTX_DEF)
 
static void uuid_node (uint16_t *node)
 
static uint64_t uuid_time (void)
 
struct uuid * kern_uuidgen (struct uuid *store, size_t count)
 
int sys_uuidgen (struct thread *td, struct uuidgen_args *uap)
 
int uuid_ether_add (const uint8_t *addr)
 
int uuid_ether_del (const uint8_t *addr)
 
int snprintf_uuid (char *buf, size_t sz, struct uuid *uuid)
 
int printf_uuid (struct uuid *uuid)
 
int sbuf_printf_uuid (struct sbuf *sb, struct uuid *uuid)
 
void le_uuid_enc (void *buf, struct uuid const *uuid)
 
void le_uuid_dec (void const *buf, struct uuid *uuid)
 
void be_uuid_enc (void *buf, struct uuid const *uuid)
 
void be_uuid_dec (void const *buf, struct uuid *uuid)
 
int validate_uuid (const char *str, size_t size, struct uuid *uuid, int flags)
 
int parse_uuid (const char *str, struct uuid *uuid)
 
int uuidcmp (const struct uuid *uuid1, const struct uuid *uuid2)
 

Variables

static struct uuid_private uuid_last
 
static struct uuid_macaddr uuid_ether [UUID_NETHER]
 
static struct mtx uuid_mutex
 

Macro Definition Documentation

◆ UUID_ETHER_EMPTY

#define UUID_ETHER_EMPTY   0

Definition at line 78 of file kern_uuid.c.

◆ UUID_ETHER_RANDOM

#define UUID_ETHER_RANDOM   1

Definition at line 79 of file kern_uuid.c.

◆ UUID_ETHER_UNIQUE

#define UUID_ETHER_UNIQUE   2

Definition at line 80 of file kern_uuid.c.

◆ UUID_NETHER

#define UUID_NETHER   4

Definition at line 86 of file kern_uuid.c.

◆ VUUIDF_PARSEFLAGS

#define VUUIDF_PARSEFLAGS   (VUUIDF_EMPTYOK | VUUIDF_CHECKSEMANTICS)

Definition at line 440 of file kern_uuid.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ be_uuid_dec()

void be_uuid_dec ( void const *  buf,
struct uuid *  uuid 
)

Definition at line 369 of file kern_uuid.c.

References buf.

◆ be_uuid_enc()

void be_uuid_enc ( void *  buf,
struct uuid const *  uuid 
)

Definition at line 353 of file kern_uuid.c.

References buf.

◆ CTASSERT() [1/2]

CTASSERT ( sizeof(struct uuid)  = =16)

◆ CTASSERT() [2/2]

CTASSERT ( sizeof(struct uuid_private = =16)

◆ kern_uuidgen()

struct uuid * kern_uuidgen ( struct uuid *  store,
size_t  count 
)

Definition at line 132 of file kern_uuid.c.

References count, uuid_private::hi, uuid_private::ll, uuid_private::low, uuid_private::mid, uuid_private::node, uuid_private::seq, uuid_private::time, uuid_last, uuid_mutex, uuid_node(), uuid_time(), and uuid_private::x.

Referenced by sys_uuidgen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ le_uuid_dec()

void le_uuid_dec ( void const *  buf,
struct uuid *  uuid 
)

Definition at line 337 of file kern_uuid.c.

References buf.

◆ le_uuid_enc()

void le_uuid_enc ( void *  buf,
struct uuid const *  uuid 
)

Definition at line 321 of file kern_uuid.c.

References buf.

◆ MTX_SYSINIT()

MTX_SYSINIT ( uuid_lock  ,
uuid_mutex,
"UUID generator mutex lock"  ,
MTX_DEF   
)

◆ parse_uuid()

int parse_uuid ( const char *  str,
struct uuid *  uuid 
)

Definition at line 443 of file kern_uuid.c.

References validate_uuid(), and VUUIDF_PARSEFLAGS.

Here is the call graph for this function:

◆ printf_uuid()

int printf_uuid ( struct uuid *  uuid)

Definition at line 286 of file kern_uuid.c.

References buf, printf(), and snprintf_uuid().

Here is the call graph for this function:

◆ sbuf_printf_uuid()

int sbuf_printf_uuid ( struct sbuf *  sb,
struct uuid *  uuid 
)

Definition at line 295 of file kern_uuid.c.

References buf, sbuf_cat(), and snprintf_uuid().

Here is the call graph for this function:

◆ snprintf_uuid()

int snprintf_uuid ( char *  buf,
size_t  sz,
struct uuid *  uuid 
)

Definition at line 273 of file kern_uuid.c.

References buf, uuid_private::hi, uuid_private::low, uuid_private::mid, uuid_private::node, uuid_private::seq, snprintf(), uuid_private::time, and uuid_private::x.

Referenced by printf_uuid(), and sbuf_printf_uuid().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sys_uuidgen()

int sys_uuidgen ( struct thread *  td,
struct uuidgen_args uap 
)

Definition at line 179 of file kern_uuid.c.

References count, uuidgen_args::count, free(), kern_uuidgen(), malloc(), and uuidgen_args::store.

Here is the call graph for this function:

◆ uuid_ether_add()

int uuid_ether_add ( const uint8_t *  addr)

◆ uuid_ether_del()

int uuid_ether_del ( const uint8_t *  addr)

◆ uuid_node()

static void uuid_node ( uint16_t *  node)
static

Definition at line 99 of file kern_uuid.c.

References uuid_macaddr::state, uuid_ether, UUID_ETHER_EMPTY, and UUID_ETHER_RANDOM.

Referenced by kern_uuidgen().

Here is the caller graph for this function:

◆ uuid_time()

static uint64_t uuid_time ( void  )
static

Definition at line 120 of file kern_uuid.c.

References bintime(), and bt.

Referenced by kern_uuidgen().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uuidcmp()

int uuidcmp ( const struct uuid *  uuid1,
const struct uuid *  uuid2 
)

Definition at line 450 of file kern_uuid.c.

◆ validate_uuid()

int validate_uuid ( const char *  str,
size_t  size,
struct uuid *  uuid,
int  flags 
)

Definition at line 385 of file kern_uuid.c.

References flags, and sscanf().

Referenced by parse_uuid(), and prison0_init().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ uuid_ether

struct uuid_macaddr uuid_ether[UUID_NETHER]
static

Definition at line 87 of file kern_uuid.c.

Referenced by uuid_ether_add(), uuid_ether_del(), and uuid_node().

◆ uuid_last

struct uuid_private uuid_last
static

Definition at line 84 of file kern_uuid.c.

Referenced by kern_uuidgen().

◆ uuid_mutex

struct mtx uuid_mutex
static

Definition at line 89 of file kern_uuid.c.

Referenced by kern_uuidgen(), uuid_ether_add(), and uuid_ether_del().