ip addr helpers

This commit is contained in:
pantonshire committed 2026-09-06 09:33:02 +01:00
1 parent e298e1950b
commit ecdbef8b45
3 files changed
+77 -2

No files matched your search

+33
View File
@@ -0,0 +1,33 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
#pragma once
#include <stdint.h>
#include "str.h"
enum {
TLSL_L3PROTO_IPV4,
TLSL_L3PROTO_IPV6,
};
struct tlsl_ipv4_addr {
uint32_t addr;
};
struct tlsl_ipv6_addr {
uint8_t addr[16];
};
struct tlsl_ip_addr {
union {
struct tlsl_ipv4_addr v4;
struct tlsl_ipv6_addr v6;
};
uint8_t l3proto;
};
int tlsl_ip_addr_parse(const char *s, struct tlsl_ip_addr *out);
str_buf_t tlsl_ip_addr_fmt(const struct tlsl_ip_addr *a);