libpktlab - The PacketLab Utility Library
Macros | Enumerations | Functions
pktctrl.h File Reference

The pktlab pktctrl module. More...

#include <pktlab.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <poll.h>
#include <sys/select.h>
Include dependency graph for pktctrl.h:

Go to the source code of this file.

Macros

#define PKTCTRL_SNIKEY_LEN_MIN   1
 Minimum pktlab snikey length.
 
#define PKTCTRL_SNIKEY_LEN_MAX   63
 Maximum pktlab snikey length. More...
 

Enumerations

enum  pktctrl_err {
  PKTCTRL_SUCCESS = 0, PKTCTRL_INVAL = 1, PKTCTRL_MAP_ERR = 2, PKTCTRL_KEY_NOT_FOUND = 3,
  PKTCTRL_SSL_FAILURE = 4, PKTCTRL_BAD_CERT = 5, PKTCTRL_BAD_CERTKEY = 6, PKTCTRL_IN_PROGRESS = 7,
  PKTCTRL_UNKNOWN_FAULT = 127
}
 pktctrl module defined error values.
 

Functions

struct pktctrl_objpktctrl_create_obj (void)
 Get initialized pktctrl session object struct. More...
 
struct pktctrl_keycert_storepktctrl_create_keycert_store (void)
 Get initialized pktctrl key certificate storage struct. More...
 
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 struct. More...
 
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 certificate storage struct. More...
 
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 certificate storage struct. More...
 
int pktctrl_set_server_keycert_default (struct pktctrl_keycert_store *store, const char *snikey)
 Set server pktctrl key certificate storage default entry. More...
 
int pktctrl_clear_server_keycert_default (struct pktctrl_keycert_store *store)
 Clear server pktctrl key certificate storage default entry. More...
 
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. More...
 
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 struct. More...
 
int pktctrl_clear_client_keycert (struct pktctrl_keycert_store *store)
 Delete client certificate chain and trusted roots from client pktctrl key certificate storage struct. More...
 
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. More...
 
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. More...
 
int pktctrl_raw_session (int fd, struct pktctrl_obj *ctrlobj)
 Set up pktctrl session object struct to establish barebone TCP pktctrl session. More...
 
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 intention. More...
 
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 performed. More...
 
int pktctrl_prepare_poll (struct pollfd *restrict pfd, bool want_read, bool want_write, struct pktctrl_obj *ctrlobj)
 
int pktctrl_process_poll (const struct pollfd *restrict pfd, struct pktctrl_obj *ctrlobj, bool *readable, bool *writable, bool *err)
 
int pktctrl_read_message (struct pktctrl_obj *ctrlobj, struct pktlab_message **msgptr)
 Read pktctrl message from established pktctrl session. More...
 
int pktctrl_write_message (struct pktctrl_obj *ctrlobj, const struct pktlab_message *msg)
 Write pktctrl message to established pktctrl session. More...
 
int pktctrl_flush_write (struct pktctrl_obj *ctrlobj)
 Flush established pktctrl session internal writer buffer. More...
 
size_t pktctrl_write_unsent (const struct pktctrl_obj *ctrlobj)
 Get established pktctrl session internal writer buffered content length. More...
 
ssize_t pktctrl_read (struct pktctrl_obj *obj, void *buf, size_t nbyte)
 Read bytes from established pktctrl session. More...
 
ssize_t pktctrl_write (struct pktctrl_obj *obj, const void *buf, size_t nbyte)
 Write bytes to established pktctrl session. More...
 
int pktctrl_close (struct pktctrl_obj *obj)
 Close and free an allocated pktctrl session object struct. More...
 
int pktctrl_cleanup_keycert_store (struct pktctrl_keycert_store *store)
 Free an allocated pktctrl key certificate storage struct. More...
 
bool pktctrl_is_established (struct pktctrl_obj *obj)
 Check if a pktctrl session object is established. More...
 
bool pktctrl_is_valid_snikey (const char *snikey)
 Check if '\0'-terminated string is a valid snikey. More...
 
int pktctrl_gen_snikey (char **buf)
 Generate random '\0'-terminated valid snikey of PKTCTRL_SNIKEY_LEN_MAX length. More...
 

Detailed Description

The pktlab pktctrl module.

For pktlab protocol message communication among pktlab entities. Note snikey is the same as SNI in normal TLS context.

Macro Definition Documentation

◆ PKTCTRL_SNIKEY_LEN_MAX

#define PKTCTRL_SNIKEY_LEN_MAX   63

Maximum pktlab snikey length.

Defined to be 63 for TLS library compatibility, as 63 is the maximum domain name label length.

Function Documentation

◆ pktctrl_accept()

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.

Parameters
[in]fdFile descriptor for an established TCP connection.
[in]auth_modeThe certificate chain verification mode to use. One of enum pktlab_auth_mode.
[in]serverkeyPointer to a loaded pktlab private key struct to be used as TLS server key.
[in]storePointer to a loaded server pktctrl key certificate storage struct.
[in,out]ctrlobjPointer to an initialized pktctrl session object struct.
[out]client_snikeyPointer to return the client-supplied snikey.
[out]peer_cert_lsPointer to return client certificate chain.
[out]peer_cert_numThe number of returned client certificates.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success. ctrlobj is an established session object upon return.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_IN_PROGRESS for TLS handshake in progress.
  4. PKTCTRL_SSL_FAILURE for TLS handshake error.
  5. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_cleanup_keycert_store()

int pktctrl_cleanup_keycert_store ( struct pktctrl_keycert_store store)

Free an allocated pktctrl key certificate storage struct.

Parameters
[in,out]storePointer to an allocated pktctrl key certificate storage struct to free.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_clear_client_keycert()

int pktctrl_clear_client_keycert ( struct pktctrl_keycert_store store)

Delete client certificate chain and trusted roots from client pktctrl key certificate storage struct.

Parameters
[in,out]storePointer to a client pktctrl key certificate storage struct.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_clear_server_keycert()

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 certificate storage struct.

Parameters
[in,out]storePointer to a server pktctrl key certificate storage struct.
[in]snikeyPointer to the target '\0'-terminated snikey.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_MAP_ERR for internal map error.
  4. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_clear_server_keycert_default()

int pktctrl_clear_server_keycert_default ( struct pktctrl_keycert_store store)

Clear server pktctrl key certificate storage default entry.

Parameters
[in,out]storePointer to a server pktctrl key certificate storage struct.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_close()

int pktctrl_close ( struct pktctrl_obj obj)

Close and free an allocated pktctrl session object struct.

Parameters
[in,out]objPointer to an allocated pktctrl session object struct to free.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_UNKNOWN_FAULT for other unknown errors.
  • pktctrl_close() also performs TLS shutdown if applicable.
  • Note the underlying file descriptor is NOT closed.
  • Do not call pktctrl_close() again if failed.

◆ pktctrl_connect()

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.

Parameters
[in]fdFile descriptor for an established TCP connection.
[in]auth_modeThe certificate chain verification mode to use. One of enum pktlab_auth_mode.
[in]snikeyPointer to a '\0'-terminated snikey or NULL.
[in]clientkeyPointer to a loaded pktlab private key struct to be used as TLS client key.
[in]storePointer to a loaded client pktctrl key certificate storage struct.
[in,out]ctrlobjPointer to an initialized pktctrl session object struct.
[out]peer_cert_lsPointer to return client certificate chain.
[out]peer_cert_numThe number of returned client certificates.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success. ctrlobj is an established session object upon return.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_BAD_CERT for certificate rejected by underlying TLS implementation.
  4. PKTCTRL_BAD_CERTKEY for private key rejected by underlying TLS implementation.
  5. PKTCTRL_IN_PROGRESS for TLS handshake in progress.
  6. PKTCTRL_SSL_FAILURE for TLS handshake error.
  7. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_create_keycert_store()

struct pktctrl_keycert_store* pktctrl_create_keycert_store ( void  )

Get initialized pktctrl key certificate storage struct.

Returns
An allocated and initialized pktctrl key certificate storage struct, or NULL if failed.

◆ pktctrl_create_obj()

struct pktctrl_obj* pktctrl_create_obj ( void  )

Get initialized pktctrl session object struct.

Returns
An allocated and initialized pktctrl session object struct, or NULL if failed.

◆ pktctrl_flush_write()

int pktctrl_flush_write ( struct pktctrl_obj ctrlobj)

Flush established pktctrl session internal writer buffer.

Parameters
[in,out]ctrlobjPointer to an established pktctrl session object struct.

◆ pktctrl_gen_snikey()

int pktctrl_gen_snikey ( char **  buf)

Generate random '\0'-terminated valid snikey of PKTCTRL_SNIKEY_LEN_MAX length.

Parameters
[in,out]bufPointer to return allocated snikey.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success. *buf points to a valid snikey upon return.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_UNKNOWN_FAULT for other unknown errors.
  • The returned buf should be freed with free() in stdlib.h.

◆ pktctrl_get_client_keycert()

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 struct.

Parameters
[in]storePointer to a client pktctrl key certificate storage struct.
[out]cert_lsPointer to return the loaded client certificate chain.
[out]certnumPointer to return the number of client certificates loaded.
[out]root_lsPointer to return the loaded trusted roots.
[out]rootnumPointer to return the number of trusted roots loaded.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_get_server_keycert()

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 certificate storage struct.

Parameters
[in]storePointer to a server pktctrl key certificate storage struct.
[in]snikeyPointer to the target '\0'-terminated snikey.
[out]cert_lsPointer to return the loaded server certificate chain.
[out]certnumPointer to return the number of server certificates loaded.
[out]root_lsPointer to return the loaded trusted roots.
[out]rootnumPointer to return the number of trusted roots loaded.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_KEY_NOT_FOUND for snikey not present in internal map.
  4. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_is_established()

bool pktctrl_is_established ( struct pktctrl_obj obj)

Check if a pktctrl session object is established.

Parameters
[in]objPointer to a pktctrl session object struct.
Returns
true if obj is established, false otherwise.

◆ pktctrl_is_valid_snikey()

bool pktctrl_is_valid_snikey ( const char *  snikey)

Check if '\0'-terminated string is a valid snikey.

Parameters
[in]snikeyPointer to a '\0'-terminated string.
Returns
true if string is valid snikey, false otherwise.
  • A valid snikey is a string of length in [PKTCTRL_SNIKEY_LEN_MIN,PKTCTRL_SNIKEY_LEN_MAX] consisting only of lowercase letters (a-z) and digits (0-9).

◆ pktctrl_prepare_select()

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 intention.

Parameters
[in,out]nfdsPointer to update the nfds value to select on the ctrlobj fd.
[in,out]rsetRead fdset. May be set for ctrlobj fd.
[in,out]wsetWrite fdset. May be set for ctrlobj fd.
[in]want_readIntention on wanting to read from ctrlobj.
[in]want_writeIntention on wanting to write to ctrlobj.
[in]ctrlobjPointer to an established pktctrl session object struct.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success. rset and wset are set based on the read/write intention passed in. nfds is updated to cover the ctrlobj fd.
  2. PKTCTRL_INVAL for bad argument.

◆ pktctrl_process_select()

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 performed.

Parameters
[in]rsetselect()-set read fdset.
[in]wsetselect()-set write fdset.
[in]ctrlobjPointer to an established pktctrl session object struct.
[out]readablePointer to return if read operation can be performed on ctrlobj.
[out]writablePointer to return if write operation can be performed on ctrlobj.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success. readable and writable are set.
  2. PKTCTRL_INVAL for bad argument.

◆ pktctrl_raw_session()

int pktctrl_raw_session ( int  fd,
struct pktctrl_obj ctrlobj 
)

Set up pktctrl session object struct to establish barebone TCP pktctrl session.

Parameters
[in]fdFile descriptor for an established TCP connection.
[in,out]ctrlobjPointer to an initialized pktctrl session object struct.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success. ctrlobj is an established session object upon return.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_read()

ssize_t pktctrl_read ( struct pktctrl_obj obj,
void *  buf,
size_t  nbyte 
)

Read bytes from established pktctrl session.

Parameters
[in,out]objPointer to an established pktctrl session object struct.
[out]bufPointer to buffer for storing the read bytes.
[in]buflenAttempted read length (must be > 0).
Returns
The number of bytes read, 0 for EOF, or < 0 for error (see errno for more information).

◆ pktctrl_read_message()

int pktctrl_read_message ( struct pktctrl_obj ctrlobj,
struct pktlab_message **  msgptr 
)

Read pktctrl message from established pktctrl session.

Parameters
[in,out]ctrlobjPointer to an established pktctrl session object struct.
[out]msgptrPointer to return an allocated fields-set msg that was read.

◆ pktctrl_set_client_keycert()

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.

Parameters
[in,out]storePointer to an initialized/client pktctrl key certificate storage struct.
[in]cert_lsArray of pointers to loaded pktlab certificate structs to be loaded as the client certificate chain.
[in]certnumThe number of certificates being loaded.
[in]root_lsArray of pointers to loaded pktlab public key structs to be loaded as the remote party certificate chain trusted roots.
[in]rootnumThe number of public keys being loaded.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_UNKNOWN_FAULT for other unknown errors.
  • When an initialized pktctrl key certificate storage struct is called with pktctrl_set_client_keycert() successfully, the key certificate storage is marked as a "client" key certificate storage and can only be used with pktctrl_connect() afterwards for TLS client-side connection establishment.
  • The loaded cert_ls and root_ls are used to perform the TLS handshake. Note no ordering on cert_ls is needed EXCEPT the first certificate should contain the public key corresponding to clientkey in pktctrl_connect(). No ordering on root_ls is needed.
  • It is allowed for cert_ls to be NULL. This will result in not supplying any client certificate during the TLS handshake.
  • It is allowed for root_ls to be NULL as well. This will result in accepting whatever root the server certificate chain contains during the TLS handshake (the certificate chain form is still checked).
  • Certificate struct(s) in cert_ls (and cert_ls itself) and public key struct(s) in root_ls (and root_ls itself) must not go out of scope/freed when store is still being used as they are not copied by this function into store.
  • When cert_ls/root_ls is NULL, certnum/rootnum must be 0 and vice versa.
  • See also pktctrl_create_keycert_store(), pktctrl_get_client_keycert(), pktctrl_clear_client_keycert(), pktctrl_cleanup_keycert_store().

◆ pktctrl_set_server_keycert()

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 struct.

Parameters
[in,out]storePointer to an initialized/server pktctrl key certificate storage struct.
[in]snikeyPointer to the target '\0'-terminated snikey.
[in]cert_lsArray of pointers to loaded pktlab certificate structs to be loaded as the server certificate chain.
[in]certnumThe number of certificates being loaded.
[in]root_lsArray of pointers to loaded pktlab public key structs to be loaded as the remote party certificate chain trusted roots.
[in]rootnumThe number of public keys being loaded.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_MAP_ERR for internal map error.
  4. PKTCTRL_UNKNOWN_FAULT for other unknown errors.
  • store should be freed after pktctrl_set_server_keycert() returned PKTCTRL_MAP_ERR.
  • When an initialized pktctrl key certificate storage struct is called with pktctrl_set_server_keycert() successfully, the key certificate storage is marked as a "server" key certificate storage and can only be used with pktctrl_accept() afterwards for TLS server-side connection establishment.
  • Effectively, each successful non-NULL cert_ls call will result in an insertion/update of an entry (key being the snikey while values being cert_ls and root_ls) in the internal storage map. Afterwards, when supplying the storage to pktctrl_accept() call, the internal map is looked up to see if there is an entry matching the incoming TLS client supplied snikey. If such an entry exists, the corresponding cert_ls and root_ls is used to perform the TLS handshake. Note if no such entry exists, the handshake is failed. No ordering on cert_ls is needed EXCEPT the first certificate should contain the public key corresponding to serverkey in pktctrl_accept(). No ordering on root_ls is needed.
  • OTOH, for successful NULL cert_ls calls (root_ls must be NULL in these kind of calls), the corresponding entry is deleted for the supplied snikey.
  • It is allowed for root_ls to be NULL for the non-NULL cert_ls case. This will result in accepting whatever root the client certificate chain contains during the TLS handshake (the certificate chain form is still checked).
  • Certificate struct(s) in cert_ls (and cert_ls itself) and public key struct(s) in root_ls (and root_ls itself) must not go out of scope/freed when store is still being used as they are not copied by this function into store.
  • When cert_ls/root_ls is NULL, certnum/rootnum must be 0 and vice versa.
  • See also pktctrl_create_keycert_store(), pktctrl_get_server_keycert(), pktctrl_clear_server_keycert(), pktctrl_set_server_keycert_default(), pktctrl_clear_server_keycert_default(), pktctrl_cleanup_keycert_store().

◆ pktctrl_set_server_keycert_default()

int pktctrl_set_server_keycert_default ( struct pktctrl_keycert_store store,
const char *  snikey 
)

Set server pktctrl key certificate storage default entry.

Parameters
[in,out]storePointer to a server pktctrl key certificate storage struct.
[in]snikeyPointer to the target '\0'-terminated snikey.
Returns
An enum pktctrl_err value:
  1. PKTCTRL_SUCCESS for success.
  2. PKTCTRL_INVAL for bad argument.
  3. PKTCTRL_KEY_NOT_FOUND for snikey not present in internal map.
  4. PKTCTRL_UNKNOWN_FAULT for other unknown errors.

◆ pktctrl_write()

ssize_t pktctrl_write ( struct pktctrl_obj obj,
const void *  buf,
size_t  nbyte 
)

Write bytes to established pktctrl session.

Parameters
[in,out]objPointer to an established pktctrl session object struct.
[in]bufTarget write bytes.
[in]buflenAttempted write length (must be > 0).
Returns
The number of bytes written, or < 0 for error (see errno for more information).

◆ pktctrl_write_message()

int pktctrl_write_message ( struct pktctrl_obj ctrlobj,
const struct pktlab_message msg 
)

Write pktctrl message to established pktctrl session.

Parameters
[in,out]ctrlobjPointer to an established pktctrl session object struct.
[in]msgPointer to a fields-set msg struct.

◆ pktctrl_write_unsent()

size_t pktctrl_write_unsent ( const struct pktctrl_obj ctrlobj)

Get established pktctrl session internal writer buffered content length.

Parameters
[in]ctrlobjPointer to an established pktctrl session object struct.