su  1.12.11devel
su_uniqueid.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Sofia-SIP package
3  *
4  * Copyright (C) 2005 Nokia Corporation.
5  *
6  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; either version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24 
25 #ifndef SU_UNIQUEID_H
26 
27 #define SU_UNIQUEID_H
28 
29 
41 #ifndef SU_TYPES_H
42 #include <sofia-sip/su_types.h>
43 #endif
44 
45 SOFIA_BEGIN_DECLS
46 
48 typedef union GloballyUniqueIdentifier {
49  unsigned char id[16];
50  struct {
51  uint32_t time_low;
52  uint16_t time_mid;
53  uint16_t time_high_and_version;
54  uint8_t clock_seq_hi_and_reserved;
55  uint8_t clock_seq_low;
56  uint8_t node[6];
57  } s;
58 } su_guid_t;
59 
61 SOFIAPUBFUN size_t su_node_identifier(void *address, size_t addrlen);
62 
73 
90 SOFIAPUBFUN isize_t su_guid_sprintf(char* buf, size_t len, su_guid_t const *guid);
91 
92 enum {
94  su_guid_strlen = 8 + 5 + 5 + 5 + 13
95 };
96 
108 SOFIAPUBFUN int su_randint(int lb, int ub);
109 
117 SOFIAPUBFUN void *su_randmem(void *mem, size_t siz);
118 
120 
122 
123 SOFIA_END_DECLS
124 
125 #endif
void * su_randmem(void *mem, size_t siz)
Fill memory with random values.
Definition: su_uniqueid.c:372
Basic integer types for su library.
uint64_t su_random64(void)
Generate a random 64-bit unsigned integer.
Definition: su_uniqueid.c:357
SU_U64_T uint64_t
64-bit unsigned integer
Definition: su_types.h:83
SU_U16_T uint16_t
16-bit unsigned integer
Definition: su_types.h:91
isize_t su_guid_sprintf(char *buf, size_t len, su_guid_t const *guid)
Print guid.
Definition: su_uniqueid.c:341
uint32_t su_random(void)
Generate a random 32-bit unsigned integer.
Definition: su_uniqueid.c:421
#define SOFIAPUBFUN
SOFIAPUBFUN declares an exported function.
Definition: su_config.h:66
void su_guid_generate(su_guid_t *guid)
Generate a GUID.
Definition: su_uniqueid.c:274
union GloballyUniqueIdentifier su_guid_t
Globally unique identifier type.
Length of guid in hex format.
Definition: su_uniqueid.h:94
size_t su_node_identifier(void *address, size_t addrlen)
Return node identifier.
Definition: su_uniqueid.c:263
SU_U32_T uint32_t
32-bit unsigned integer
Definition: su_types.h:87
Globally unique identifier type.
Definition: su_uniqueid.h:48
int su_randint(int lb, int ub)
Random integer in range [lb, ub] (inclusive).
Definition: su_uniqueid.c:401
SU_U8_T uint8_t
8-bit unsigned integer
Definition: su_types.h:95

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.