Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_network_ws_limits.c File Reference
#include "nilorea/n_log.h"
#include "nilorea/n_network.h"
#include "nilorea/n_str.h"
#include <string.h>
Include dependency graph for ex_network_ws_limits.c:

Go to the source code of this file.

Macros

#define WS_LIMITS_PORT   "27431"
 Port the local listener binds for this test.

Functions

static int check_refused (const char *label, uint64_t len)
 Drive one hostile length through n_ws_recv and report the outcome.
int main (void)
static int send_hostile_header (NETWORK *peer, uint64_t len)
 Send a raw WebSocket frame header naming a payload length of len.

Macro Definition Documentation

◆ WS_LIMITS_PORT

#define WS_LIMITS_PORT   "27431"

Port the local listener binds for this test.

Examples
ex_network_ws_limits.c.

Definition at line 44 of file ex_network_ws_limits.c.

Referenced by check_refused().

Function Documentation

◆ check_refused()

int check_refused ( const char * label,
uint64_t len )
static

Drive one hostile length through n_ws_recv and report the outcome.

Parameters
labelHuman-readable name of the case.
lenPayload length the peer declares.
Returns
0 when n_ws_recv refused the frame, 1 when it did not.
Examples
ex_network_ws_limits.c.

Definition at line 70 of file ex_network_ws_limits.c.

References N_WS_CONN::connected, free_nstr, LOG_ERR, LOG_INFO, n_log, n_ws_recv(), N_WS_CONN::netw, netw_accept_from(), netw_close(), netw_connect_to(), netw_make_listening(), NETWORK_IPV4, N_WS_MESSAGE::payload, send_hostile_header(), server, and WS_LIMITS_PORT.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( void )

Definition at line 123 of file ex_network_ws_limits.c.

References check_refused(), LOG_ERR, LOG_INFO, n_log, N_WS_MAX_PAYLOAD, and set_log_level().

Here is the call graph for this function:

◆ send_hostile_header()

int send_hostile_header ( NETWORK * peer,
uint64_t len )
static

Send a raw WebSocket frame header naming a payload length of len.

Parameters
peerConnected socket to write to.
lenPayload length to declare in the header.
Returns
0 on success, -1 on a short write.
Examples
ex_network_ws_limits.c.

Definition at line 52 of file ex_network_ws_limits.c.

References send_data().

Referenced by check_refused().

Here is the call graph for this function:
Here is the caller graph for this function: