---
title: "UUID Module"
description: "This module provides a way to generate universally unique identifiers (UUID) as specified in RFC 4122. The UUID is provided as a string representation by reading the [uuid](#pv_uuid) pseudo-variable or calling the [uuid](#func_uuid) script function."
---

## Admin Guide


### Overview


This module provides a way to generate universally unique identifiers
		(UUID) as specified in RFC 4122. The UUID is provided as a string
		representation by reading the [uuid](#pv_uuid)
		pseudo-variable or calling the [uuid](#func_uuid)
		script function.


### Dependencies


#### OpenSIPS Modules


This module does not depend on other modules.


#### External Libraries or Applications


- *libuuid* - part of the util-linux
					package, can be downloaded from:
					ftp://ftp.kernel.org/pub/linux/utils/util-linux/


### Exported Parameters


The module does not export any parameters.


### Exported Pseudo-Variables


#### $uuid


The *$uuid* variable returns a newly generated
			version 4 UUID based on high-quality randomness from /dev/urandom,
			if available. Otherwise, a version 1 UUID (based on
			current time and the local ethernet MAC address) will be generated.


```c title="$uuid usage"
xlog("generated uuid: $uuid\n");
				
```


### Exported Functions


#### uuid(out_var, [version], [namespace], [name])


Generates a new UUID.


- *out_var* (var) - an output variable
						to return the generated UUID.
- *version* (string, optional) - UUID version
						number. The supported values are:
						
							
							*0* - a RFC version 4 or
							version 1 UUID will be generated, depending on the
							availability of high-quality randomness from
							/dev/urandom. This is the default behavior, if the
							*version* parameter is missing.
							
							
							*1* - version 1 UUID
							based on current time and the local ethernet MAC
							address
							
							
							*3* - version 3 UUID
							generated by hashing a namespace identifier and name
							via MD5.
							
							
							*4* - version 4 UUID
							based on a high-quality random number generator. If
							not available, a pseudo-random generator will be
							substituted.
							
							
							*5* - version 5 UUID
							generated by hashing a namespace identifier and name
							via SHA-1.
							
							
								*7* - version 7 UUID
									generated by timestamp and randomness.
- *namespace* (string, optional) - the namespace
						identifier used with UUID version 3 and 5. This must be a valid
						UUID, see RFC 4122 Appendix C for some predefined values.
- *name* (string, optional) - the name used with
						UUID version 3 and 5.


If UUID version 1 is used, the function will return the value
				*2* if the UUID was generated in an unsafe
				manner. This refers to the posibility of two concurrently
				running processes generating the same UUID, in cases where
				synchronization mechanisms are not available (more details
				can be found in the *uuid_generate* man pages
				of *libuuid*).


This function can be used from any route.
<!-- CONTRIBUTORS -->

### License

All documentation files (i.e. .md extension) are licensed under the Creative Common License 4.0
