Extensible Connection-oriented Messaging (XCM)
Loading...
Searching...
No Matches
xcm_addr.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * Copyright(c) 2020 Ericsson AB
4 */
5
6#ifndef XCM_ADDR_H
7#define XCM_ADDR_H
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <errno.h>
13#include <inttypes.h>
14#include <netinet/in.h>
15#include <stdbool.h>
16#include <sys/socket.h>
17#include <sys/types.h>
18
26#define XCM_UTLS_PROTO "utls"
29#define XCM_TLS_PROTO "tls"
31#define XCM_TCP_PROTO "tcp"
33#define XCM_SCTP_PROTO "sctp"
36#define XCM_UX_PROTO "ux"
39#define XCM_UXF_PROTO "uxf"
40
43#define XCM_BTLS_PROTO "btls"
45#define XCM_BTCP_PROTO "btcp"
46
47enum xcm_addr_type {
48 xcm_addr_type_name,
49 xcm_addr_type_ip
50};
51
54{
56 sa_family_t family;
57
59 union {
62 in_addr_t ip4;
65 uint8_t ip6[16];
67};
68
71{
73 enum xcm_addr_type type;
74
76 union {
77 struct xcm_addr_ip ip;
78 /* Max DNS name length is 253 characters */
79 char name[254];
80 };
81};
82
96bool xcm_addr_is_valid(const char *xcm_addr_s);
97
107bool xcm_addr_is_supported(const char *xcm_addr_s);
108
122int xcm_addr_parse_proto(const char *addr_s, char *proto, size_t capacity);
123
137int xcm_addr_parse_utls(const char *utls_addr_s, struct xcm_addr_host *host,
138 uint16_t *port);
139
153int xcm_addr_parse_tls(const char *tls_addr_s, struct xcm_addr_host *host,
154 uint16_t *port);
155
170int xcm_addr_parse_tcp(const char *tcp_addr_s, struct xcm_addr_host *host,
171 uint16_t *port);
172
187int xcm_addr_parse_sctp(const char *sctp_addr_s, struct xcm_addr_host *host,
188 uint16_t *port);
189
203int xcm_addr_parse_ux(const char *ux_addr_s, char *ux_path, size_t capacity);
204
218int xcm_addr_parse_uxf(const char *uxf_addr_s, char *uxf_path,
219 size_t capacity);
220
234int xcm_addr_parse_btcp(const char *btcp_addr_s, struct xcm_addr_host *host,
235 uint16_t *port);
236
250int xcm_addr_parse_btls(const char *btls_addr_s, struct xcm_addr_host *host,
251 uint16_t *port);
252
268int xcm_addr_make_utls(const struct xcm_addr_host *host, unsigned short port,
269 char *utls_addr_s, size_t capacity);
270
286int xcm_addr_make_tls(const struct xcm_addr_host *host, unsigned short port,
287 char *tls_addr_s, size_t capacity);
288
304int xcm_addr_make_tcp(const struct xcm_addr_host *host, unsigned short port,
305 char *tcp_addr_s, size_t capacity);
306
322int xcm_addr_make_sctp(const struct xcm_addr_host *host, unsigned short port,
323 char *sctp_addr_s, size_t capacity);
324
339int xcm_addr_make_ux(const char *ux_name, char *ux_addr_s, size_t capacity);
340
355int xcm_addr_make_uxf(const char *uxf_name, char *uxf_addr_s, size_t capacity);
356
372int xcm_addr_make_btcp(const struct xcm_addr_host *host, unsigned short port,
373 char *btcp_addr_s, size_t capacity);
374
390int xcm_addr_make_btls(const struct xcm_addr_host *host, unsigned short port,
391 char *btls_addr_s, size_t capacity);
392
393#include <xcm_addr_compat.h>
394
395#ifdef __cplusplus
396}
397#endif
398#endif
Definition xcm_addr.h:71
enum xcm_addr_type type
Definition xcm_addr.h:73
Definition xcm_addr.h:54
union xcm_addr_ip::@0 addr
sa_family_t family
Definition xcm_addr.h:56
uint8_t ip6[16]
Definition xcm_addr.h:65
in_addr_t ip4
Definition xcm_addr.h:62
int xcm_addr_parse_uxf(const char *uxf_addr_s, char *uxf_path, size_t capacity)
int xcm_addr_make_btls(const struct xcm_addr_host *host, unsigned short port, char *btls_addr_s, size_t capacity)
int xcm_addr_make_utls(const struct xcm_addr_host *host, unsigned short port, char *utls_addr_s, size_t capacity)
int xcm_addr_parse_sctp(const char *sctp_addr_s, struct xcm_addr_host *host, uint16_t *port)
int xcm_addr_make_ux(const char *ux_name, char *ux_addr_s, size_t capacity)
int xcm_addr_parse_utls(const char *utls_addr_s, struct xcm_addr_host *host, uint16_t *port)
bool xcm_addr_is_supported(const char *xcm_addr_s)
int xcm_addr_parse_btls(const char *btls_addr_s, struct xcm_addr_host *host, uint16_t *port)
int xcm_addr_make_tcp(const struct xcm_addr_host *host, unsigned short port, char *tcp_addr_s, size_t capacity)
int xcm_addr_make_tls(const struct xcm_addr_host *host, unsigned short port, char *tls_addr_s, size_t capacity)
int xcm_addr_parse_ux(const char *ux_addr_s, char *ux_path, size_t capacity)
int xcm_addr_parse_btcp(const char *btcp_addr_s, struct xcm_addr_host *host, uint16_t *port)
int xcm_addr_make_uxf(const char *uxf_name, char *uxf_addr_s, size_t capacity)
int xcm_addr_parse_proto(const char *addr_s, char *proto, size_t capacity)
bool xcm_addr_is_valid(const char *xcm_addr_s)
int xcm_addr_parse_tls(const char *tls_addr_s, struct xcm_addr_host *host, uint16_t *port)
int xcm_addr_parse_tcp(const char *tcp_addr_s, struct xcm_addr_host *host, uint16_t *port)
int xcm_addr_make_btcp(const struct xcm_addr_host *host, unsigned short port, char *btcp_addr_s, size_t capacity)
int xcm_addr_make_sctp(const struct xcm_addr_host *host, unsigned short port, char *sctp_addr_s, size_t capacity)