# OpenSIPS Lua API

## Available functions

This module provides access to a limited number of OpenSIPS core functions.

### xdbg(message)

An alias for xlog(DBG, message)

### xlog([level],message)

Logs the message with OpenSIPS's logging facility. The logging level is one of the following:

- ALERT

- CRIT

- ERR

- WARN

- NOTICE

- INFO

- DBG

### setUserDebug

Enable or disable the xlog feature. Disabled, the xlog function has no effect.

### WarnMissingFreeFixup

Dynamically change the variable warn_missing_free_fixup.

### getpid

Returns the current pid.

### getmem

Returns a table with the size of allocated memory and the fragmentation.

### getmeminfo

Returns a table with memory infos.

### gethostname

Returns the value of the current hostname.

### getType(msg)

Returns "SIP_REQUEST" or "SIP_REPLY".

### getURI_User(msg)

Returns the user of the To URI.

### getExpires(msg)

Returns the expires header of the current message.

### getHeader(header)

Returns the value of the specified header.

### getContact(msg)

Returns a table with the contact header.

### moduleFunc(msg, function, args1, args2)

You can pass arguments to this function.

### getStatus(msg)

Returns the current status if the SIP message is a SIP_REPLY.

### getMethod(msg)

Returns the current method.

### getSrcIp(msg)

Returns the IP address of the source.

### getDstIp(msg)

Returns the IP address of the destination.

### AVP_get(msg, name)

Returns an AVP variable.

### AVP_set(msg, name, value)

Defines an AVP variable.

### AVP_destroy(msg, name)

Destroys an AVP variable.

### pseudoVar(msg, variable)

Returns a pseudoVar.

### add_lump_rpl

Add header to the reply.