$Revision: 1.5 $
$Date: 2007/11/15 02:27:07 $

# Functions

## `avp_db_load(source,name)`

Loads from DB into memory the AVPs corresponding to the given source.

Meaning of the parameters is as follows:

- source - what info is used for identifying the AVPs. Parameter syntax:

      source = (sip_uri) [ '/' ( 'username' | 'domain' ) ] ) | (avp_alias) | str_value
      sip_uri = '$from' | '$to' | '$ruri'

- name - which AVPs will be loaded from DB into memory. Parameter syntax is:

  -     name = avp_spec [ '/' ( table_name | '$' db_scheme ) ]
        avp_spec = '' | 's:' | 'i:' | avp_name | avp_alias

### `avp_db_load` usage

    ...
    avp_db_load("$from","i:678");
    avp_db_load("$ruri/domain","i:/domain_preferences");
    avp_db_load("$uid","s:404fwd/fwd_table");
    avp_db_load("$ruri","i:123/$some_scheme");
    ...

## `avp_db_store(source,name)`

Stores to DB the AVPs corresponding to the given source.

The meaning and usage of the parameters are identical as for avp_db_load(source,name) function. Please refer to its description.

### `avp_db_store` usage

    ...
    avp_db_store("$to","i:678");
    avp_db_store("$ruri/username","$email");
    ...

## `avp_db_delete(source,name)`

Deletes from DB the AVPs corresponding to the given source.

The meaning and usage of the parameters are identical as for avp_db_load(source,name) function. Please refer to its description.

### `avp_db_delete` usage

    ...
    avp_db_delete("$to","i:678");
    avp_db_delete("$ruri/username","$email");
    avp_db_delete("$uid","s:404fwd/fwd_table");
    ...

## `avp_write(value,name)`

The function writes some value (given) or some information from the SIP message into a new AVP.

Meaning of the parameters is as follows:

- value - the value to be written into the AVP. Parameter syntax:

      value = (variable) | (fix_value)
      variable = '$src_ip' | '$dst_ip' | '$hdr[name]' | (sip_uri) [ '/' ( 'username' | 'domain' ) ] )
      sip_uri = '$from' | '$to' | '$ruri'
      fix_value = 'i:'integer | 's:'string | string

- name - the name of the new written AVP. Parameter syntax is:

      name = avp_name | avp_alias

### `avp_write` usage

    ...
    avp_write("$to","i:678");
    avp_write("$ruri/username","$email");
    avp_write("$src_ip","s:ip");
    avp_write("$hdr[call-id]","i:11");
    avp_write("i:333","i:6");
    ...

## `avp_delete(name)`

Deletes from memory the AVPs with name or, if empty, all AVPs.

Meaning of the parameters is as follows:

- name - which AVPs will be deleted from memory. Parameter syntax is:

      name = ('' | 's:' | 'i:' | avp_name | avp_alias ) [ '/' flag ]
      flag = 'g' | 'G'

### `avp_delete` usage

    ...
    avp_delete("i:678/g");
    avp_delete("$email");
    avp_delete("i:");
    avp_delete("");
    ...

## `avp_pushto(destination,name)`

Pushes the value of AVP(s) into the SIP message.

Meaning of the parameters is as follows:

- destination - as what will be the AVP value pushed into SIP message. Parameter syntax:

      destination = ruri_dst | hdr_dst
      ruri_dst = '$ruri' [ '/' ( 'username' | 'domain' ) ]
      hdr_dst = '$hdr_name' [ '/' ( 'request' | 'reply' ) ]

- name - which AVP(s) should be pushed into the SIP message. Parameter syntax is:

      name = ( avp_name | avp_alias ) [ '/' flags ]
      flags = 'g'

### `avp_pushto` usage

    ...
    avp_pushto("$ruri","i:678");
    avp_pushto("$ruri/domain","s:backup_domains/g");
    avp_pushto("$Email/reply","s:email");
    avp_pushto("$Foo","$bar/g");
    ...

## `avp_check(name,op_value)`

Checks the value of the AVP(s) against an operator and value.

Meaning of the parameters is as follows:

- name - which AVP(s) should be checked. Parameter syntax is:

      name = ( avp_name | avp_alias )

- op_value - define the operator, the value and flags for checking. Parameter syntax is:

      op_value = operator '/' value [ '/' flags ]
      operator = 'eq' | 'lt' | 'gt' | 're' | 'fm'
      value = variable | fix_value
      variable = '$from' | '$ruri' | '$from' | '$src_ip' | '$dst_ip' | avp_alias
      fix_value = 'i:' integer | 's:' string | string
      flags = 'g' | 'G' | 'i' | 'I'

### `avp_check` usage

    ...
    avp_check("i:678", "lt/i:345/g");
    avp_check("s:person","eq/$from/I");
    avp_check("s:foo","gt/$bar/g");
    avp_check("s:foo","re/sip:.*@bar.net/g");
    avp_check("s:foo","fm/$fm_avp/g");
    ...

## `avp_copy(old_name,new_name)`

Copy / move an AVP under a new name.

Meaning of the parameters is as follows:

- name1 - which AVP(s) should be copied/moved. Parameter syntax is:

      name = ( avp_name | avp_alias )

- name2 - the new name of the copied/moved AVP(s). Parameter syntax is:

      name = ( avp_name | avp_alias ) [ '/' flags ]
      flags = 'g' | 'G' | 'd' | 'D'

### `avp_copy` usage

    ...
    avp_copy("i:678", "s:345/g");
    avp_copy("$old","$new/gd");
    ...

## `is_avp_set()`

Check if any AVP with name is set.

Meaning of the parameters is as follows:

- name - name of AVP to look for. Parameter syntax is:

  - name = ('s:'|'i:'|avp_name|avp_alias)

### `is_avp_set` usage

    ...
    if(is_avp_set("i:678/g"))
        log("AVP with integer id 678 exists\n");
    ...

## `avp_print()`

Prints the list with all the AVPs from memory. This is only a helper/debug function.

### `avp_print` usage

    ...
    avp_print();
    ...