pan_bindings 1.0.2

FFI bindings for the SCION PAN Path Aware Networking library
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
/* Code generated by cmd/cgo; DO NOT EDIT. */

/* package command-line-arguments */


#line 1 "cgo-builtin-export-prolog"

#include <stddef.h>

#ifndef GO_CGO_EXPORT_PROLOGUE_H
#define GO_CGO_EXPORT_PROLOGUE_H

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
#endif

#endif

/* Start of preamble from import "C" comments.  */


#line 17 "pan_wrapper.go"

 #ifdef BINDGEN
 #include "pan_cdefs.h"
 #else
 #include "pan/pan_cdefs.h"
 #endif
 #define PAN_STREAM_HDR_SIZE 4
 #define PAN_ADDR_HDR_SIZE 32
 /** \file
	* PAN C Wrapper
  * \defgroup handle Go Handles
  * \defgroup addresses Addresses
  * Functions for working with IP and SCION addresses.
  * \defgroup path Path
  * SCION path related functions.
  * \defgroup path_fingerprint Path Fingerprint
  * \defgroup policy Path Policy
  * \defgroup selector Path Selector
  * \defgroup reply_selector Reply Selector
  * \defgroup listen_conn ListenConn
  * PAN ListenConn methods.
  * \defgroup conn Conn
  * PAN Conn methods.
  * \defgroup adapter Socket Adapter
  * UNIX domain socket adapter.
  */

#line 1 "cgo-generated-wrapper"


/* End of preamble from import "C" comments.  */


/* Start of boilerplate cgo prologue.  */
#line 1 "cgo-gcc-export-header-prolog"

#ifndef GO_CGO_PROLOGUE_H
#define GO_CGO_PROLOGUE_H

typedef signed char GoInt8;
typedef unsigned char GoUint8;
typedef short GoInt16;
typedef unsigned short GoUint16;
typedef int GoInt32;
typedef unsigned int GoUint32;
typedef long long GoInt64;
typedef unsigned long long GoUint64;
typedef GoInt64 GoInt;
typedef GoUint64 GoUint;
typedef size_t GoUintptr;
typedef float GoFloat32;
typedef double GoFloat64;
#ifdef _MSC_VER
#include <complex.h>
typedef _Fcomplex GoComplex64;
typedef _Dcomplex GoComplex128;
#else
typedef float _Complex GoComplex64;
typedef double _Complex GoComplex128;
#endif

/*
  static assertion to make sure the file is being used on architecture
  at least with matching size of GoInt.
*/
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];

#ifndef GO_CGO_GOSTRING_TYPEDEF
typedef _GoString_ GoString;
#endif
typedef void *GoMap;
typedef void *GoChan;
typedef struct { void *t; void *v; } GoInterface;
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;

#endif

/* End of boilerplate cgo prologue.  */

#ifdef __cplusplus
extern "C" {
#endif


/**
\brief Duplicate a cgo handle.
\ingroup handle
*/
extern uintptr_t PanDuplicateHandle(uintptr_t handle);

/**
\brief Delete a handle obtained from cgo.
\ingroup handle
*/
extern void PanDeleteHandle(uintptr_t handle);

/**
\brief Wrapper for `pan.ResolveUDPAddr`
	A handle to the resolved address is returned in `resolved`.
\attention deprecated in favour of PanResolveUDPAddrN
		Reason:	conversion of C to Go string with func C.GoString(p *_Ctype_char) string
		has been repeatedly found to be unreliable and cause bugs.
\ingroup addresses
*/
extern PanError PanResolveUDPAddr(cchar_t* address, PanUDPAddr* resolved);
extern PanError PanResolveUDPAddrN(cchar_t* address, int len, PanUDPAddr* resolved);

/**
\brief Create a PanUDPAddr from ISD, ASN, IP and UDP port.
\param[in] ia Pointer to the ISD and AS number packed as 8 bytes in big-endian
	byte order. Must not be NULL.
\param[in] ip Pointer to the IP address in big-endian byte order. Must not be
	NULL.
\param[in] ip_len Length of the IP address in bytes. Must be 4 or 16.
\param[in] port UDP port number
\return UDPAddr handle. A null handle is returned if \p ip_len is not 4 or 16.
\ingroup addresses
*/
extern PanUDPAddr PanUDPAddrNew(cuint64_t* ia, cuint8_t* ip, int ip_len, uint16_t port);

/**
\brief Get the ISD (2 bytes) and ASN (6 bytes) of the address.
\param[out] Pointer to 8 bytes that will receive the ISD and AS number in
	big-endian byte order. Function is a no-op if this is `NULL`.
\ingroup addresses
*/
extern void PanUDPAddrGetIA(PanUDPAddr addr, uint64_t* ia);

/**
\brief Returns whether the IP-part of the address is IPv6 (including mapped IPv4
	addresses).
\return `0` for IPv4 addresses, non-zero otherwise.
\ingroup addresses
*/
extern int PanUDPAddrIsIPv6(PanUDPAddr addr);

/**
\brief Get the IP part of the address. Fails if the address is not an IPv4
	or IPv4-in-IPv6 address.
\param[out] ipv4 Pointer to a 4-byte array that will receive the IP address.
	Function is a no-op if this is `NULL`.
\return `PAN_ERR_OK` if no error occurred.
	`PAN_ERR_FAILED` if the address cannot be represented in 4 bytes.
\ingroup addresses
*/
extern PanError PanUDPAddrGetIPv4(PanUDPAddr addr, uint8_t* ip4);

/**
\brief Get the IP part of the address. IPv4 addresses are returned in
	IPv6-mapped form.
\param[out] ipv6 Pointer to a 16-byte array that will receive the IP address.
	Function is a no-op if this is `NULL`.
\return `PAN_ERR_OK` if no error occurred.
\ingroup addresses
*/
extern PanError PanUDPAddrGetIPv6(PanUDPAddr addr, uint8_t* ip6);

/**
\brief Get the UDP port as integer in host byte order.
\ingroup addresses
*/
extern uint16_t PanUDPAddrGetPort(PanUDPAddr addr);

/**
\brief Returns a string representation of the given SCION address.
The returned string must be freed with free().
\ingroup addresses
*/
extern char* PanUDPAddrToString(PanUDPAddr addr);

/**
\brief Return a string representing the path.
The returned string must be freed with free().
\ingroup path
*/
extern char* PanPathToString(PanPath path);

/**
\brief Get the fingerprint of the path.
\ingroup path
*/
extern PanPathFingerprint PanPathGetFingerprint(PanPath path);

/**
\brief Check whether a path contains a certain AS interface.
\ingroup path
*/
extern int PanPathContainsInterface(PanPath path, PanPathInterface iface);

/**
\brief Check whether two path fingerprints compare equal.
\ingroup path_fingerprint
*/
extern int PanPathFingerprintAreEqual(PanPathFingerprint fp_a, PanPathFingerprint fp_b);

/**
\brief Create a new path policy from a filter function.
\param[in] filter Filter callback.
\param[in] user User data that will be passed to the callback.
\ingroup policy
*/
extern PanPolicy PanNewCPolicy(PanPolicyFilterFn filter, uintptr_t user);
extern void PanCPolicyTest(PanPolicy policy);

/**
\brief Create a new path selector.
\param[in] callbacks Callbacks for the methods of the path selector.
\param[in] user User data that will be passed to the callback.
\ingroup selector
*/
extern PanSelector PanNewCSelector(struct PanSelectorCallbacks* callbacks, uintptr_t user);

/**
\brief Create a new reply selector.
\param[in] callbacks Callbacks for the methods of the reply selector.
\param[in] user User data that will be passed to the callback.
\ingroup reply_selector
*/
extern PanReplySelector PanNewCReplySelector(struct PanReplySelCallbacks* callbacks, uintptr_t user);
extern PanScionSocket PanNewScionSocket(cchar_t* listen, int n);
extern PanScionSocket PanNewScionSocket2();
extern PanError PanScionSocketBind(PanScionSocket socket, cchar_t* listen);
extern char* PanScionSocketGetLocalAddr(PanScionSocket socket);
extern PanError PanScionSocketReadFromAsync(PanScionSocket conn, void* buffer, int len, PanUDPAddr* from, int* n, int timeout_duration, OnCompletionWaker waker, void* arc_conn);
extern PanError PanScionSocketWriteToAsync(PanScionSocket conn, cvoid_t* buffer, int len, PanUDPAddr to, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);
extern PanError PanScionSocketWriteToViaAsync(PanScionSocket conn, cvoid_t* buffer, int len, PanUDPAddr to, PanPath path, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);
extern PanError PanScionSocketReadFromAsyncVia(PanScionSocket conn, void* buffer, int len, PanUDPAddr* from, PanPath* path, int* n, int timeout_duration, OnCompletionWaker waker, void* arc_conn);
extern PanError PanScionSocketClose(PanScionSocket conn);

/**
\brief Wrapper for `(pan.ListenConn).SetDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup listen_conn
*/
extern PanError PanScionSocketSetDeadline(PanScionSocket conn, uint32_t t);

/**
\brief Wrapper for `(pan.ListenConn).SetReadDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup listen_conn
*/
extern PanError PanScionSocketSetReadDeadline(PanScionSocket conn, uint32_t t);

/**
\brief Wrapper for `(pan.ListenConn).SetWriteDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup listen_conn
*/
extern PanError PanScionSocketSetWriteDeadline(PanScionSocket conn, uint32_t t);

/**
\brief Open a UDP socket and listen for connections.
\param[in] listen is the local IP and port to listen on as a null-terminated
	string (e.g., "127.0.0.1:8000").
\param[in] selector Reply path selector. May be a PAN_INVALID_HANDLE to use the
	default selector.
\param[out] conn The value pointed to by \p conn receives the listening
	connection handle if the call is successful.
	\ingroup listen_conn
\return `PAN_ERR_OK` on success.
	`PAN_ERR_ADDR_SYNTAX` is the listen address has an invalid format.
	`PAN_ERR_FAILED` if binding and listening on the socket failed.
*/
extern PanError PanListenUDP(cchar_t* listen, PanReplySelector selector, PanListenConn* conn);

/**
\brief Wrapper for `(pan.ListenConn).ReadFrom`
\param[in] conn Listening connection.
\param[in] buffer Pointer to a buffer that will receive the packet.
\param[in] len Size of \p buffer in bytes.
\param[out] from Host from which data was received. Can be NULL to ignore.
\param[out] n Number of bytes read. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup listen_conn
*/
extern PanError PanListenConnReadFrom(PanListenConn conn, void* buffer, int len, PanUDPAddr* from, int* n);

/**
\brief Wrapper for `(pan.ListenConn).ReadFrom`
\param[in] conn Listening connection.
\param[in] buffer Pointer to a buffer that will receive the packet.
\param[in] len Size of \p buffer in bytes.
\param[out] from Host from which data was received. Can be NULL to ignore.
\param[out] n Number of bytes read. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup listen_conn
*/
extern PanError PanListenConnReadFromAsync(PanListenConn conn, void* buffer, int len, PanUDPAddr* from, int* n, int timeout_duration, OnCompletionWaker waker, void* arc_conn);
extern PanError PanListenConnReadFromAsyncVia(PanListenConn conn, void* buffer, int len, PanUDPAddr* from, PanPath* path, int* n, int timeout_duration, OnCompletionWaker waker, void* arc_conn);

/**
\brief Wrapper for `(pan.ListenConn).ReadFromVia`
\param[in] conn Listening connection.
\param[in] buffer Pointer to a buffer that will receive the packet.
\param[in] len Size of \p buffer in bytes.
\param[out] from Host from which data was received. Can be NULL to ignore.
\param[out] path Path of the received packet. Can be NULL to ignore.
\param[out] n Number of bytes read. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup listen_conn
*/
extern PanError PanListenConnReadFromVia(PanListenConn conn, void* buffer, int len, PanUDPAddr* from, PanPath* path, int* n);

/**
\briefWrapper for `(pan.ListenConn).WriteTo`
\param[in] conn Listening connection.
\param[in] buffer Pointer to a buffer containing the message.
\param[in] len Length of the message in \p buffer in bytes.
\param[in] to Destination address.
\param[out] n Number of bytes written. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_NO_PATH` if no path to the destination is known.
	`PAN_ERR_FAILED` if the operation failed in some other way.
\ingroup listen_conn
*/
extern PanError PanListenConnWriteTo(PanListenConn conn, cvoid_t* buffer, int len, PanUDPAddr to, int* n);
extern PanError PanListenConnWriteToAsync(PanListenConn conn, cvoid_t* buffer, int len, PanUDPAddr to, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);
extern PanError PanListenConnWriteToViaAsync(PanListenConn conn, cvoid_t* buffer, int len, PanUDPAddr to, PanPath path, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);

/**
\brief Wrapper for `(pan.ListenConn).WriteToVia`
\param[in] conn Listening connection.
\param[in] buffer Pointer to a buffer containing the message.
\param[in] len Length of the message in \p buffer in bytes.
\param[in] to Destination address.
\param[in] path Path to take to the destination.
\param[out] n Number of bytes written. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup listen_conn
*/
extern PanError PanListenConnWriteToVia(PanListenConn conn, cvoid_t* buffer, int len, PanUDPAddr to, PanPath path, int* n);

/**
\brief Wrapper for `(pan.ListenConn).LocalAddr`
\ingroup listen_conn
*/
extern PanUDPAddr PanListenConnLocalAddr(PanListenConn conn);

/**
\brief Wrapper for `(pan.ListenConn).SetDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup listen_conn
*/
extern PanError PanListenConnSetDeadline(PanListenConn conn, uint32_t t);

/**
\brief Wrapper for `(pan.ListenConn).SetReadDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup listen_conn
*/
extern PanError PanListenConnSetReadDeadline(PanListenConn conn, uint32_t t);

/**
\brief Wrapper for `(pan.ListenConn).SetWriteDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup listen_conn
*/
extern PanError PanListenConnSetWriteDeadline(PanListenConn conn, uint32_t t);

/**
\brief Close a listening socket. The handle must still be deleted with
PanDeleteHandle().
\ingroup listen_conn
*/
extern PanError PanListenConnClose(PanListenConn conn);

/**
\brief Wrapper for `pan.DialUDP`
\param[in] local is the local IP and port as string. Can be NULL to automatically
	choose.
\param[in] remote is the SCION address of the remote host.
\param[in] policy Path policy. May be a PAN_INVALID_HANDLE to use the default
	policy.
\param[in] selector Path selector. May be a PAN_INVALID_HANDLE to use the
	default selector.
\param[out] conn The value pointed to by \p conn receives the connection handle
	if the call is successful.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_ADDR_SYNTAX` is the local address has an invalid format.
	`PAN_ERR_FAILED` if dialing failed.
\ingroup conn
*/
extern PanError PanDialUDP(cchar_t* local, PanUDPAddr remote, PanPolicy policy, PanSelector selector, PanConn* conn);

/**
\brief Wrapper for `(pan.Conn).Read`
\param[in] conn Connection
\param[in] buffer Pointer to a buffer that will receive the packet.
\param[in] len Size of \p buffer in bytes.
\param[out] n Number of bytes read. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup conn
*/
extern PanError PanConnRead(PanConn conn, void* buffer, int len, int* n);

/**
\brief Wrapper for `(pan.Conn).ReadVia`
\param[in] conn Connection
\param[in] buffer Pointer to a buffer that will receive the packet.
\param[in] len Size of \p buffer in bytes.
\param[out] path Path of the received packet. Can be NULL to ignore.
\param[out] n Number of bytes read. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup conn
*/
extern PanError PanConnReadVia(PanConn conn, void* buffer, int len, PanPath* path, int* n);
extern PanError PanConnReadViaAsync(PanConn conn, void* buffer, int len, PanPath* path, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);

/**
\brief Wrapper for `(pan.Conn).Write`
\param[in] conn Connection
\param[in] buffer Pointer to a buffer containing the message.
\param[in] len Length of the message in \p buffer in bytes.
\param[out] n Number of bytes written. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_NO_PATH` if no path to the destination is known.
	`PAN_ERR_FAILED` if the operation failed in some other way.
\ingroup conn
*/
extern PanError PanConnWrite(PanListenConn conn, cvoid_t* buffer, int len, int* n);
extern PanError PanConnWriteAsync(PanListenConn conn, cvoid_t* buffer, int len, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);
extern GoUint64 GetLocalIA();

/**
\brief Wrapper for `(pan.Conn).WriteVia`
\param[in] conn Connection
\param[in] buffer Pointer to a buffer containing the message.
\param[in] len Length of the message in \p buffer in bytes.
\param[in] path Path to take to the destination.
\param[out] n Number of bytes written. Can be NULL to ignore.
\return `PAN_ERR_OK` on success.
	`PAN_ERR_DEADLINE` if the deadline was exceeded.
	`PAN_ERR_FAILED` if the operation failed.
\ingroup conn
*/
extern PanError PanConnWriteVia(PanListenConn conn, cvoid_t* buffer, int len, PanPath path, int* n);
extern PanError PanConnWriteViaAsync(PanListenConn conn, cvoid_t* buffer, int len, PanPath path, int* n, int timeout, OnCompletionWaker waker, void* arc_conn);

/**
\brief Wrapper for (pan.Conn).LocalAddr
\ingroup conn
*/
extern PanUDPAddr PanConnLocalAddr(PanConn conn);

/**
\brief Wrapper for `(pan.Conn).RemoteAddr`
\ingroup conn
*/
extern PanUDPAddr PanConnRemoteAddr(PanConn conn);

/**
\brief Wrapper for `(pan.Conn).SetDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup conn
*/
extern PanError PanConnSetDeadline(PanConn conn, uint32_t t);

/**
\brief Wrapper for `(pan.Conn).SetReadDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup conn
*/
extern PanError PanConnSetReadDeadline(PanConn conn, uint32_t t);

/**
\brief Wrapper for `(pan.Conn).SetWriteDeadline`
\param[in] conn Connection to set the deadline on.
\param[in] t is the number milliseconds the deadline is set in the future.
\ingroup conn
*/
extern PanError PanConnSetWriteDeadline(PanConn conn, uint32_t t);

/**
\brief Close a connection. The handle must still be deleted with
PanDeleteHandle().
\ingroup conn
*/
extern PanError PanConnClose(PanConn conn);

/**
\brief Open a Unix datagram socket at `listen_addr` as proxy for `pan_conn` or scion_socket (any SocketLike type).
\attention deprecated in favour of PanNewListenSockAdapter2
		Reason:	conversion of C to Go string with func C.GoString(p *_Ctype_char) string has been repeatedly found to be unreliable and cause bugs.
All packets received by `pan_conn` are forwarded from `listen_addr` to `client_addr`.
All packets received from the Unix socket are forwarded to `pan_conn`.
The SCION address of the source or destination is prepended to the payload in a
32 byte header:
\verbatim
byte 0       1       2       3       4       5       6       7
     +-------+-------+-------+-------+-------+-------+-------+-------+
   0 |    ISD (BE)   |                     ASN (BE)                  |
     +-------+-------+-------+-------+-------+-------+-------+-------+
   8 |    Host Addr. Length (LE)     |                               |
     +-------+-------+-------+-------+                               |
  16 |                         Host Address (BE)                     |
     +                               +-------+-------+-------+-------+
  24 |                               | UDP Port (LE) |       0       |
     +-------+-------+-------+-------+-------+-------+-------+-------+
BE = big-endian
LE = little-endian
\endverbatim

\param[in] pan_conn Listening PAN connection or ScionSocket (any type that implements SocketLike).
\param[in] listen_addr Local address of the socket in the file system.
			On the 'FFI caller' side a unix domain socket must have been constructed an bound to this address
			before the adapter is constructed.
\param[in] client_addr Address of the other end of the connection in the C part
	of the program.
\param[out] adapter Socket adapter object.
\ingroup adapter
*/
extern PanError PanNewListenSockAdapter(PanListenConn pan_conn, cchar_t* listen_addr, cchar_t* client_addr, PanListenSockAdapter* adapter);
extern PanError PanNewListenSockAdapter2(PanListenConn pan_conn, cchar_t* listen_addr, int len1, cchar_t* client_addr, int len2, PanListenSockAdapter* adapter);

/**
\brief Close the Unix domain socket **and the PAN connection**.
\ingroup adapter
*/
extern PanError PanListenSockAdapterClose(PanListenSockAdapter adapter);

/**
\brief Open a Unix datagram socket at `listen_addr` as proxy for `pan_conn`.

All packets received by pan_conn are forwarded from `listen_addr` to `client_addr`.
All packets received from the unix socket are forwarded to `pan_conn`.

\param[in] pan_conn Connected PAN connection.
\param[in] listen_addr Local address of the unix socket in the file system.
\param[in] client_addr Address of the other end of the connection in the C part
	of the program.
\param[out] adapter Socket adapter object.
\ingroup adapter
*/
extern PanError PanNewConnSockAdapter(PanConn pan_conn, cchar_t* listen_addr, cchar_t* client_addr, PanConnSockAdapter* adapter);

/**
\brief Close the Unix domain socket **and the PAN connection**.
\ingroup adapter
*/
extern PanError PanConnSockAdapterClose(PanConnSockAdapter adapter);

/**
\brief Open a Unix stream socket at `listen_addr` as proxy for `pan_conn` or 'scion_socket'(any SocketLike).

Behaves identical to `PanNewListenSockAdapter` except that a stream socket is
used instead of a datagram socket. Packet borders in the stream are determined
by prepending a four byte message length (little endian) in front of every
packet sent or received on the Unix socket.

When initially created, the socket will listens for and accept exactly one
connection.

The stream variants of the socket adapters are intended for systems lacking
support for Unix datagram sockets, e.g., Windows. A more native solution on
Windows might be named pipes, however they have a very different API from
sockets.

\param[in] pan_conn Listening PAN connection.
\param[in] listen_addr Local address of the socket in the file system.
\param[out] adapter Socket adapter object.
\ingroup adapter
*/
extern PanError PanNewListenSSockAdapter(PanListenConn pan_conn, cchar_t* listen_addr, PanListenSSockAdapter* adapter);

/**
\brief Close the Unix domain socket **and the PAN connection**.
\ingroup adapter
*/
extern PanError PanListenSSockAdapterClose(PanListenSSockAdapter adapter);

/**
\brief Open a Unix stream socket at `listen_addr` as proxy for `pan_conn`.

Behaves identical to `PanNewConnSockAdapter` except that a stream socket is
used instead of a datagram socket. Packet borders in the stream are determined
by prepending a four byte message length (little endian) in front of every
packet sent or received on the Unix socket.

When initially created, the socket will listens for and accept exactly one
connection.

The stream variants of the socket adapters are intended for systems lacking
support for Unix datagram sockets, e.g., Windows. A more native solution on
Windows might be named pipes, however they have a very different API from
sockets.

\param[in] pan_conn Connected PAN connection.
\param[in] listen_addr Local address of the Unix socket in the file system.
\param[out] adapter Socket adapter object.
\ingroup adapter
*/
extern PanError PanNewConnSSockAdapter(PanConn pan_conn, cchar_t* listen_addr, PanConnSSockAdapter* adapter);

/**
\brief Close the Unix domain socket **and the PAN connection**.
\ingroup adapter
*/
extern PanError PanConnSSockAdapterClose(PanConnSSockAdapter adapter);

#ifdef __cplusplus
}
#endif