---
title: llarp::dns::PacketSource_Wrapper
summary: a packet source which will override the sendto function of an wrapped packet source to construct a raw ip packet as a reply 

---

# llarp::dns::PacketSource_Wrapper



a packet source which will override the sendto function of an wrapped packet source to construct a raw ip packet as a reply 


`#include <server.hpp>`

Inherits from [llarp::dns::PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md)

## Public Functions

|                | Name           |
| -------------- | -------------- |
| | **[PacketSource_Wrapper](Classes/classllarp_1_1dns_1_1PacketSource__Wrapper.md#function-packetsource-wrapper)**(std::weak_ptr< [PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md) > wrapped, std::function< void([net::IPPacket](Classes/structllarp_1_1net_1_1IPPacket.md))> write_packet) |
| virtual bool | **[WouldLoop](Classes/classllarp_1_1dns_1_1PacketSource__Wrapper.md#function-wouldloop)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & to, const [SockAddr](Classes/structllarp_1_1SockAddr.md) & from) const override<br>return true if traffic with source and dest addresses would cause a loop in resolution and thus should not be sent to query handlers  |
| virtual void | **[SendTo](Classes/classllarp_1_1dns_1_1PacketSource__Wrapper.md#function-sendto)**(const [SockAddr](Classes/structllarp_1_1SockAddr.md) & to, const [SockAddr](Classes/structllarp_1_1SockAddr.md) & from, [OwnedBuffer](Classes/structllarp_1_1OwnedBuffer.md) buf) const override<br>send packet with src and dst address containing buf on this packet source  |
| virtual void | **[Stop](Classes/classllarp_1_1dns_1_1PacketSource__Wrapper.md#function-stop)**() override<br>stop reading packets and end operation  |
| virtual std::optional< [SockAddr](Classes/structllarp_1_1SockAddr.md) > | **[BoundOn](Classes/classllarp_1_1dns_1_1PacketSource__Wrapper.md#function-boundon)**() const override<br>returns the sockaddr we are bound on if applicable  |

## Additional inherited members

**Public Functions inherited from [llarp::dns::PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md)**

|                | Name           |
| -------------- | -------------- |
| virtual | **[~PacketSource_Base](Classes/classllarp_1_1dns_1_1PacketSource__Base.md#function-~packetsource-base)**() =default |


## Public Functions Documentation

### function PacketSource_Wrapper

```cpp
inline explicit PacketSource_Wrapper(
    std::weak_ptr< PacketSource_Base > wrapped,
    std::function< void(net::IPPacket)> write_packet
)
```


### function WouldLoop

```cpp
inline virtual bool WouldLoop(
    const SockAddr & to,
    const SockAddr & from
) const override
```

return true if traffic with source and dest addresses would cause a loop in resolution and thus should not be sent to query handlers 

**Reimplements**: [llarp::dns::PacketSource_Base::WouldLoop](Classes/classllarp_1_1dns_1_1PacketSource__Base.md#function-wouldloop)


### function SendTo

```cpp
inline virtual void SendTo(
    const SockAddr & to,
    const SockAddr & from,
    OwnedBuffer buf
) const override
```

send packet with src and dst address containing buf on this packet source 

**Reimplements**: [llarp::dns::PacketSource_Base::SendTo](Classes/classllarp_1_1dns_1_1PacketSource__Base.md#function-sendto)


### function Stop

```cpp
inline virtual void Stop() override
```

stop reading packets and end operation 

**Reimplements**: [llarp::dns::PacketSource_Base::Stop](Classes/classllarp_1_1dns_1_1PacketSource__Base.md#function-stop)


### function BoundOn

```cpp
inline virtual std::optional< SockAddr > BoundOn() const override
```

returns the sockaddr we are bound on if applicable 

**Reimplements**: [llarp::dns::PacketSource_Base::BoundOn](Classes/classllarp_1_1dns_1_1PacketSource__Base.md#function-boundon)


-------------------------------

Updated on 2022-10-25 at 00:38:16 +0000