# STUN module (rfc5389)

<a id="stunmodulerfc5389"></a>

# STUN module (rfc5389)

The `stun` module contains a STUN (rfc5389) implementation.

## Namespaces

| Name | Description |
|------|-------------|
| [`stun`](https://auscaster.com/icey/docs/api-reference/icy-stun.md#stun) | STUN messages, attributes, and transaction helpers defined by RFC 5389. |

## Macros

| Name | Description |
|------|-------------|
| [`STUN_API`](#stun_api)  |  |
| [`DECLARE_FIXLEN_STUN_ATTRIBUTE`](#declare_fixlen_stun_attribute)  | Attribute macros. |
| [`DECLARE_STUN_ATTRIBUTE`](#declare_stun_attribute)  |  |

---

<a id="stun_api"></a>

### STUN_API

```cpp
#define STUN_API ICY_IMPORT
```

[Defined in src/stun/include/icy/stun/stun.h:27](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/stun.h#L27)

---

<a id="declare_fixlen_stun_attribute"></a>

### DECLARE_FIXLEN_STUN_ATTRIBUTE

```cpp
#define DECLARE_FIXLEN_STUN_ATTRIBUTE(Name, Type, Derives) \
    class Name : public Derives                            \
    {                                                      \
    public:                                                \
        static constexpr uint16_t TypeID = Type;           \
        Name()                                             \
            : Derives(TypeID) {};                          \
        std::unique_ptr<Attribute> clone() override        \
        {                                                  \
            return std::make_unique<Name>(*this);          \
        }                                                  \
        virtual ~Name() {};                                \
    };
```

[Defined in src/stun/include/icy/stun/attributes.h:570](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L570)

Attribute macros.

---

<a id="declare_stun_attribute"></a>

### DECLARE_STUN_ATTRIBUTE

```cpp
#define DECLARE_STUN_ATTRIBUTE(Name, Type, Derives, Length) \
    class Name : public Derives                             \
    {                                                       \
    public:                                                 \
        static constexpr uint16_t TypeID = Type;            \
        Name(uint16_t size = Length)                        \
            : Derives(TypeID, size) {};                     \
        std::unique_ptr<Attribute> clone() override         \
        {                                                   \
            return std::make_unique<Name>(*this);           \
        }                                                   \
        virtual ~Name() {};                                 \
    };
```

[Defined in src/stun/include/icy/stun/attributes.h:585](https://github.com/auscaster/icey/blob/main/src/stun/include/icy/stun/attributes.h#L585)
