1 /** @file libradsec-base.h
2 @brief Low level API for libradsec. */
4 /* FIXME: License blurb goes here. */
8 #include <sys/socket.h>
11 /* Function prototypes. */
13 /** Establish a connection.
15 @param type Connection type.
16 @param addr Network address to connect to.
17 @param cred Credentials, or NULL.
19 @return A file descriptor or -1 if an error occurred, in which
20 case errno is set appropriately. */
21 int rs_connect(const struct rs_config *conf,
22 const struct sockaddr *addr,
27 @param fd File descriptor to close.
29 @return 0 on success or -1 if an error occurred, in which case
30 errno is set appropriately. */
31 int rs_disconnect(const struct rs_config *conf,
34 /** Allocate and initialize a packet from a buffer containing a packet
35 as seen on the wire. Free the packet using @a rs_packet_free().
37 FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
39 @param buf Buffer with on-the-wire data with packet.
40 @param buflen Number of octets in @a buf.
42 @param count Number of octets used in buffer, in case of
43 successful construction of a packet (return !NULL) or number of
44 octets needed for a complete packet (return NULL).
46 FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
48 @return Packet or NULL on error or not enough data in @a buf. If
49 return value is NULL and @a count is < 0, an error has occurred
50 and errno is set appropriately. If return value is NULL and @a
51 count is > 0 it shows the number of bytes needed to complete the
53 struct rs_packet *rs_packet_new(const struct rs_config *ctx,
54 const uint8_t buf[RS_HEADER_LEN],
57 /* FIXME: if return NULL, @a packet is freed and the pointer is no longer valid! */
58 struct rs_packet *rs_packet_parse(const struct rs_config *ctx,
59 struct rs_packet **packet,
63 /** Free a packet that has been allocated by @a rs_packet_new().
65 @param packet Packet to free.
68 void rs_packet_free(const struct rs_config *ctx,
69 struct rs_packet **packet);
71 /** Serialize a packet.
73 @param packet Packet to serialize.
74 @param buf Buffer to store the serialized packet in.
75 @param buflen Length of buffer.
77 @return Number of bytes written to buf or 0 if the buffer wasn't
78 large enough to hold the packet or < 0 in case the packet couldn't
79 be serialized for some other eason (FIXME: elaborate) */
81 ssize_t rs_packet_serialize(const struct rs_packet *packet,