---
title: llarp::net::IPPacket
summary: an Packet 

---

# llarp::net::IPPacket



an Packet 


`#include <ip_packet.hpp>`

## Public Classes

|                | Name           |
| -------------- | -------------- |
| struct | **[CompareOrder](Classes/structllarp_1_1net_1_1IPPacket_1_1CompareOrder.md)**  |
| struct | **[CompareSize](Classes/structllarp_1_1net_1_1IPPacket_1_1CompareSize.md)**  |

## Public Functions

|                | Name           |
| -------------- | -------------- |
| [IPPacket](Classes/structllarp_1_1net_1_1IPPacket.md) | **[UDP](Classes/structllarp_1_1net_1_1IPPacket.md#function-udp)**(nuint32_t srcaddr, nuint16_t srcport, nuint32_t dstaddr, nuint16_t dstport, const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & data) |
| [ManagedBuffer](Classes/structManagedBuffer.md) | **[Buffer](Classes/structllarp_1_1net_1_1IPPacket.md#function-buffer)**() |
| [ManagedBuffer](Classes/structManagedBuffer.md) | **[ConstBuffer](Classes/structllarp_1_1net_1_1IPPacket.md#function-constbuffer)**() const |
| bool | **[Load](Classes/structllarp_1_1net_1_1IPPacket.md#function-load)**(const [llarp_buffer_t](Classes/structllarp__buffer__t.md) & buf) |
| [ip_header](Classes/structllarp_1_1net_1_1ip__header__le.md) * | **[Header](Classes/structllarp_1_1net_1_1IPPacket.md#function-header)**() |
| const [ip_header](Classes/structllarp_1_1net_1_1ip__header__le.md) * | **[Header](Classes/structllarp_1_1net_1_1IPPacket.md#function-header)**() const |
| [ipv6_header](Classes/structllarp_1_1net_1_1ipv6__header.md) * | **[HeaderV6](Classes/structllarp_1_1net_1_1IPPacket.md#function-headerv6)**() |
| const [ipv6_header](Classes/structllarp_1_1net_1_1ipv6__header.md) * | **[HeaderV6](Classes/structllarp_1_1net_1_1IPPacket.md#function-headerv6)**() const |
| int | **[Version](Classes/structllarp_1_1net_1_1IPPacket.md#function-version)**() const |
| bool | **[IsV4](Classes/structllarp_1_1net_1_1IPPacket.md#function-isv4)**() const |
| bool | **[IsV6](Classes/structllarp_1_1net_1_1IPPacket.md#function-isv6)**() const |
| service::ProtocolType | **[ServiceProtocol](Classes/structllarp_1_1net_1_1IPPacket.md#function-serviceprotocol)**() const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[srcv6](Classes/structllarp_1_1net_1_1IPPacket.md#function-srcv6)**() const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[dstv6](Classes/structllarp_1_1net_1_1IPPacket.md#function-dstv6)**() const |
| [huint32_t](Classes/structllarp_1_1huint__t.md) | **[srcv4](Classes/structllarp_1_1net_1_1IPPacket.md#function-srcv4)**() const |
| [huint32_t](Classes/structllarp_1_1huint__t.md) | **[dstv4](Classes/structllarp_1_1net_1_1IPPacket.md#function-dstv4)**() const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[src4to6](Classes/structllarp_1_1net_1_1IPPacket.md#function-src4to6)**() const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[dst4to6](Classes/structllarp_1_1net_1_1IPPacket.md#function-dst4to6)**() const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[src4to6Lan](Classes/structllarp_1_1net_1_1IPPacket.md#function-src4to6lan)**() const |
| [huint128_t](Classes/structllarp_1_1huint__t.md) | **[dst4to6Lan](Classes/structllarp_1_1net_1_1IPPacket.md#function-dst4to6lan)**() const |
| std::optional< nuint16_t > | **[DstPort](Classes/structllarp_1_1net_1_1IPPacket.md#function-dstport)**() const<br>get destination port if applicable  |
| std::optional< nuint16_t > | **[SrcPort](Classes/structllarp_1_1net_1_1IPPacket.md#function-srcport)**() const<br>get source port if applicable  |
| std::optional< std::pair< const char *, size_t > > | **[L4Data](Classes/structllarp_1_1net_1_1IPPacket.md#function-l4data)**() const<br>get pointer and size of layer 4 data  |
| void | **[UpdateIPv4Address](Classes/structllarp_1_1net_1_1IPPacket.md#function-updateipv4address)**(nuint32_t src, nuint32_t dst) |
| void | **[UpdateIPv6Address](Classes/structllarp_1_1net_1_1IPPacket.md#function-updateipv6address)**([huint128_t](Classes/structllarp_1_1huint__t.md) src, [huint128_t](Classes/structllarp_1_1huint__t.md) dst, std::optional< nuint32_t > flowlabel =std::nullopt) |
| void | **[ZeroAddresses](Classes/structllarp_1_1net_1_1IPPacket.md#function-zeroaddresses)**(std::optional< nuint32_t > flowlabel =std::nullopt)<br>set addresses to zero and recacluate checksums  |
| void | **[ZeroSourceAddress](Classes/structllarp_1_1net_1_1IPPacket.md#function-zerosourceaddress)**(std::optional< nuint32_t > flowlabel =std::nullopt)<br>zero out source address  |
| std::optional< [IPPacket](Classes/structllarp_1_1net_1_1IPPacket.md) > | **[MakeICMPUnreachable](Classes/structllarp_1_1net_1_1IPPacket.md#function-makeicmpunreachable)**() const<br>make an icmp unreachable reply packet based of this ip packet  |

## Public Attributes

|                | Name           |
| -------------- | -------------- |
| constexpr size_t | **[MaxSize](Classes/structllarp_1_1net_1_1IPPacket.md#variable-maxsize)**  |
| llarp_time_t | **[timestamp](Classes/structllarp_1_1net_1_1IPPacket.md#variable-timestamp)**  |
| size_t | **[sz](Classes/structllarp_1_1net_1_1IPPacket.md#variable-sz)**  |
| byte_t[MaxSize] | **[buf](Classes/structllarp_1_1net_1_1IPPacket.md#variable-buf)**  |

## Public Functions Documentation

### function UDP

```cpp
static IPPacket UDP(
    nuint32_t srcaddr,
    nuint16_t srcport,
    nuint32_t dstaddr,
    nuint16_t dstport,
    const llarp_buffer_t & data
)
```


### function Buffer

```cpp
ManagedBuffer Buffer()
```


### function ConstBuffer

```cpp
ManagedBuffer ConstBuffer() const
```


### function Load

```cpp
bool Load(
    const llarp_buffer_t & buf
)
```


### function Header

```cpp
inline ip_header * Header()
```


### function Header

```cpp
inline const ip_header * Header() const
```


### function HeaderV6

```cpp
inline ipv6_header * HeaderV6()
```


### function HeaderV6

```cpp
inline const ipv6_header * HeaderV6() const
```


### function Version

```cpp
inline int Version() const
```


### function IsV4

```cpp
inline bool IsV4() const
```


### function IsV6

```cpp
inline bool IsV6() const
```


### function ServiceProtocol

```cpp
inline service::ProtocolType ServiceProtocol() const
```


### function srcv6

```cpp
huint128_t srcv6() const
```


### function dstv6

```cpp
huint128_t dstv6() const
```


### function srcv4

```cpp
huint32_t srcv4() const
```


### function dstv4

```cpp
huint32_t dstv4() const
```


### function src4to6

```cpp
huint128_t src4to6() const
```


### function dst4to6

```cpp
huint128_t dst4to6() const
```


### function src4to6Lan

```cpp
huint128_t src4to6Lan() const
```


### function dst4to6Lan

```cpp
huint128_t dst4to6Lan() const
```


### function DstPort

```cpp
std::optional< nuint16_t > DstPort() const
```

get destination port if applicable 

### function SrcPort

```cpp
std::optional< nuint16_t > SrcPort() const
```

get source port if applicable 

### function L4Data

```cpp
std::optional< std::pair< const char *, size_t > > L4Data() const
```

get pointer and size of layer 4 data 

### function UpdateIPv4Address

```cpp
void UpdateIPv4Address(
    nuint32_t src,
    nuint32_t dst
)
```


### function UpdateIPv6Address

```cpp
void UpdateIPv6Address(
    huint128_t src,
    huint128_t dst,
    std::optional< nuint32_t > flowlabel =std::nullopt
)
```


### function ZeroAddresses

```cpp
void ZeroAddresses(
    std::optional< nuint32_t > flowlabel =std::nullopt
)
```

set addresses to zero and recacluate checksums 

### function ZeroSourceAddress

```cpp
void ZeroSourceAddress(
    std::optional< nuint32_t > flowlabel =std::nullopt
)
```

zero out source address 

### function MakeICMPUnreachable

```cpp
std::optional< IPPacket > MakeICMPUnreachable() const
```

make an icmp unreachable reply packet based of this ip packet 

## Public Attributes Documentation

### variable MaxSize

```cpp
static constexpr size_t MaxSize = 1500;
```


### variable timestamp

```cpp
llarp_time_t timestamp;
```


### variable sz

```cpp
size_t sz;
```


### variable buf

```cpp
byte_t[MaxSize] buf;
```


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

Updated on 2022-08-30 at 18:09:27 +0000