libpktlab - The PacketLab Utility Library
|
Go to the documentation of this file.
23 #include <sys/select.h>
39 #define PKTCTRL_SNIKEY_LEN_MIN 1
40 #define PKTCTRL_SNIKEY_LEN_MAX 63 // i.e. the maximum domain name label length
50 PKTCTRL_KEY_NOT_FOUND = 3,
51 PKTCTRL_SSL_FAILURE = 4,
53 PKTCTRL_BAD_CERTKEY = 6,
54 PKTCTRL_IN_PROGRESS = 7,
55 PKTCTRL_UNKNOWN_FAULT = 127,
271 int fd,
int auth_mode,
274 struct pktctrl_obj * ctrlobj,
char ** client_snikey,
276 uint_fast32_t * peer_cert_num);
304 int fd,
int auth_mode,
const char * snikey,
346 int * nfds, fd_set * restrict rset, fd_set * restrict wset,
347 bool want_read,
bool want_write,
struct pktctrl_obj * ctrlobj);
364 const fd_set * restrict rset,
const fd_set * restrict wset,
365 struct pktctrl_obj * ctrlobj,
bool * readable,
bool * writable);
367 extern int pktctrl_prepare_poll (
368 struct pollfd * restrict pfd,
369 bool want_read,
bool want_write,
371 extern int pktctrl_process_poll (
372 const struct pollfd * restrict pfd,
374 bool * readable,
bool * writable,
bool * err);
429 void * buf,
size_t nbyte);
442 const void * buf,
size_t nbyte);
ssize_t pktctrl_read(struct pktctrl_obj *obj, void *buf, size_t nbyte)
Read bytes from established pktctrl session.
pktctrl key certificate storage opaque struct.
Definition: pktctrl.h:66
int pktctrl_clear_server_keycert_default(struct pktctrl_keycert_store *store)
Clear server pktctrl key certificate storage default entry.
pktlab public key opaque struct.
pktctrl session object opaque struct.
pktctrl_err
pktctrl module defined error values.
Definition: pktctrl.h:46
int pktctrl_connect(int fd, int auth_mode, const char *snikey, struct pktlab_privatekey *clientkey, struct pktctrl_keycert_store *store, struct pktctrl_obj *ctrlobj, struct pktlab_certificate ***peer_cert_ls, uint_fast32_t *peer_cert_num)
Perform TLS client-side handshake to establish TLS pktctrl session.
int pktctrl_set_server_keycert_default(struct pktctrl_keycert_store *store, const char *snikey)
Set server pktctrl key certificate storage default entry.
size_t pktctrl_write_unsent(const struct pktctrl_obj *ctrlobj)
Get established pktctrl session internal writer buffered content length.
bool pktctrl_is_valid_snikey(const char *snikey)
Check if '\0'-terminated string is a valid snikey.
int pktctrl_get_client_keycert(struct pktctrl_keycert_store *store, struct pktlab_certificate ***cert_ls, uint_fast32_t *certnum, struct pktlab_publickey ***root_ls, uint_fast32_t *rootnum)
Get loaded client certificate chain and trusted roots from client pktctrl key certificate storage str...
struct pktctrl_obj * pktctrl_create_obj(void)
Get initialized pktctrl session object struct.
int pktctrl_clear_client_keycert(struct pktctrl_keycert_store *store)
Delete client certificate chain and trusted roots from client pktctrl key certificate storage struct.
int pktctrl_cleanup_keycert_store(struct pktctrl_keycert_store *store)
Free an allocated pktctrl key certificate storage struct.
int pktctrl_read_message(struct pktctrl_obj *ctrlobj, struct pktlab_message **msgptr)
Read pktctrl message from established pktctrl session.
General utilities for pktlab.
int pktctrl_gen_snikey(char **buf)
Generate random '\0'-terminated valid snikey of PKTCTRL_SNIKEY_LEN_MAX length.
pktlab private key opaque struct.
int pktctrl_set_server_keycert(struct pktctrl_keycert_store *store, const char *snikey, struct pktlab_certificate **cert_ls, uint_fast32_t certnum, struct pktlab_publickey **root_ls, uint_fast32_t rootnum)
Load server certificate chain and trusted roots for some snikey into pktctrl key certificate storage ...
ssize_t pktctrl_write(struct pktctrl_obj *obj, const void *buf, size_t nbyte)
Write bytes to established pktctrl session.
bool pktctrl_is_established(struct pktctrl_obj *obj)
Check if a pktctrl session object is established.
Structure for storing the decoded form of pktlab messages.
Definition: pktlab.h:930
struct pktctrl_keycert_store * pktctrl_create_keycert_store(void)
Get initialized pktctrl key certificate storage struct.
pktlab certificate opaque struct.
int pktctrl_set_client_keycert(struct pktctrl_keycert_store *store, struct pktlab_certificate **cert_ls, uint_fast32_t certnum, struct pktlab_publickey **root_ls, uint_fast32_t rootnum)
Load client certificate chain and trusted roots into pktctrl key certificate storage struct.
int pktctrl_close(struct pktctrl_obj *obj)
Close and free an allocated pktctrl session object struct.
int pktctrl_write_message(struct pktctrl_obj *ctrlobj, const struct pktlab_message *msg)
Write pktctrl message to established pktctrl session.
int pktctrl_flush_write(struct pktctrl_obj *ctrlobj)
Flush established pktctrl session internal writer buffer.
int pktctrl_prepare_select(int *nfds, fd_set *restrict rset, fd_set *restrict wset, bool want_read, bool want_write, struct pktctrl_obj *ctrlobj)
Set up arguments to select() for read/write operation on established pktctrl session based on intenti...
int pktctrl_process_select(const fd_set *restrict rset, const fd_set *restrict wset, struct pktctrl_obj *ctrlobj, bool *readable, bool *writable)
Process select() results to identify if read/write operation on established pktctrl session can be pe...
int pktctrl_accept(int fd, int auth_mode, struct pktlab_privatekey *serverkey, struct pktctrl_keycert_store *store, struct pktctrl_obj *ctrlobj, char **client_snikey, struct pktlab_certificate ***peer_cert_ls, uint_fast32_t *peer_cert_num)
Perform TLS server-side handshake to establish TLS pktctrl session.
int pktctrl_raw_session(int fd, struct pktctrl_obj *ctrlobj)
Set up pktctrl session object struct to establish barebone TCP pktctrl session.
int pktctrl_get_server_keycert(struct pktctrl_keycert_store *store, const char *snikey, struct pktlab_certificate ***cert_ls, uint_fast32_t *certnum, struct pktlab_publickey ***root_ls, uint_fast32_t *rootnum)
Get loaded server certificate chain and trusted roots for some snikey from server pktctrl key certifi...
int pktctrl_clear_server_keycert(struct pktctrl_keycert_store *store, const char *snikey)
Delete server certificate chain and trusted roots entry for some snikey from server pktctrl key certi...