Shadow Network Framework  0.0.2-alpha
C Server Library for Shadow Network Framework
Loading...
Searching...
No Matches
request.h File Reference

This file Defines everything related to handling Requests. More...

Go to the source code of this file.

Data Structures

struct  SNF_Request_t
 The Structure for saving Requests. More...
 
struct  SNF_Request_args_t
 

Macros

#define NULLREQUEST   "000000000000000"
 Requests's Default Request ID.
 
#define SNF_REQUEST_MAXSIZE   4096
 Defines the Requests' maximum length.
 

Typedefs

typedef struct SNF_Request_t SNF_RQST
 Shortened definition of struct SNF_Request_t .
 
typedef struct SNF_Request_args_t SNF_RQST_ARG
 Shortened definition of struct SNF_Request_args_t .
 

Functions

void snf_request_free (SNF_RQST *Request)
 Frees a SNF_RQST *.
 
SNF_RQSTsnf_request_gen ()
 Generates a new empty request.
 
SNF_RQSTsnf_request_gen_wUID (const char UID[16])
 Generates a new empty request that has an UID.
 
SNF_RQSTsnf_request_gen_response (SNF_RQST *Original, SNF_opcode *OPCODE, SNF_RQST_ARG *Args)
 Generates a new response request.
 
SNF_RQSTsnf_request_gen_server_OPCODE (SNF_opcode *OPCODE)
 Generates a server request.
 
SNF_RQSTsnf_request_gen_base (SNF_RQST *Original, SNF_opcode_mmbr_t Command, SNF_opcode_mmbr_t Detail)
 Generates a response request using base OPCode.
 
SNF_RQSTsnf_request_genu_base (SNF_RQST *Original, SNF_opcode_mmbr_t Command)
 Generates a response request using undetailed base OPCode.
 
int snf_request_get_nargs (SNF_RQST *args)
 Gets the amount of arguments a request has.
 
SNF_RQST_ARGsnf_request_arg_gen (const char *arg)
 Generates a new Argumment.
 
void snf_request_arg_free (SNF_RQST_ARG *arg)
 Frees an instance of SNF_RQST_ARG.
 
void snf_request_args_free (SNF_RQST_ARG *arg)
 Frees all instance of SNF_RQST_ARG that were linked together using SNF_RQST_ARG::next.
 
void snf_request_arg_insert (SNF_RQST *Request, SNF_RQST_ARG *arg)
 Inserts an arguments to the end of Request's SNF_RQST_ARG List.
 
SNF_RQSTsnf_request_fetch (SNF_CLT *Client)
 Fetches the request from the incoming Client.
 
void snf_request_send (SNF_CLT *Client, SNF_RQST *Request)
 Send a request to a Client.
 
void snf_request_send_confirm (SNF_CLT *Client, SNF_RQST *Original)
 Sends a confirmation Response request to the client.
 
void snf_request_send_reject (SNF_CLT *Client, SNF_RQST *Original)
 Sends a rejection Response request to the client.
 
void snf_request_send_invalid (SNF_CLT *Client, SNF_RQST *Original)
 Sends a invalidation Response request to the client.
 

Detailed Description

This file Defines everything related to handling Requests.

Macro Definition Documentation

◆ NULLREQUEST

#define NULLREQUEST   "000000000000000"

Requests's Default Request ID.

Note
Server Requests to client always must have this as their ID

◆ SNF_REQUEST_MAXSIZE

#define SNF_REQUEST_MAXSIZE   4096

Defines the Requests' maximum length.

Typedef Documentation

◆ SNF_RQST

typedef struct SNF_Request_t SNF_RQST

Shortened definition of struct SNF_Request_t .

◆ SNF_RQST_ARG

Shortened definition of struct SNF_Request_args_t .

Function Documentation

◆ snf_request_free()

void snf_request_free ( SNF_RQST * Request)
extern

Frees a SNF_RQST *.

Parameters
RequestPointer to be free'd

◆ snf_request_gen()

SNF_RQST * snf_request_gen ( )
extern

Generates a new empty request.

Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance

◆ snf_request_gen_wUID()

SNF_RQST * snf_request_gen_wUID ( const char UID[16])
extern

Generates a new empty request that has an UID.

Parameters
UIDThe new Request's UID
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance

◆ snf_request_gen_response()

SNF_RQST * snf_request_gen_response ( SNF_RQST * Original,
SNF_opcode * OPCODE,
SNF_RQST_ARG * Args )
extern

Generates a new response request.

Parameters
OriginalThe request to reply to
OPCODEThre response's OPCODE
ArgsThe response's arguments
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance
Note
The response Request's UID will match the Original's UID, See SNF_RQST::UID

◆ snf_request_gen_server_OPCODE()

SNF_RQST * snf_request_gen_server_OPCODE ( SNF_opcode * OPCODE)
extern

Generates a server request.

Parameters
OPCODEserver request's OPCODE
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance

◆ snf_request_gen_base()

SNF_RQST * snf_request_gen_base ( SNF_RQST * Original,
SNF_opcode_mmbr_t Command,
SNF_opcode_mmbr_t Detail )
extern

Generates a response request using base OPCode.

Parameters
OriginalThe request to respond to
CommandBase Command
DetailBase Command's Detail
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance

◆ snf_request_genu_base()

SNF_RQST * snf_request_genu_base ( SNF_RQST * Original,
SNF_opcode_mmbr_t Command )
extern

Generates a response request using undetailed base OPCode.

Parameters
OriginalThe request to respond to
CommandBase Command
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance

◆ snf_request_get_nargs()

int snf_request_get_nargs ( SNF_RQST * args)
extern

Gets the amount of arguments a request has.

Parameters
argsThe request to get it's arguments
Returns
The possible results :
  • 0 if any of the args were empty
  • int Amount of SNF_RQST_ARG

◆ snf_request_arg_gen()

SNF_RQST_ARG * snf_request_arg_gen ( const char * arg)
extern

Generates a new Argumment.

Parameters
argArgument's Content
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST_ARG instance

◆ snf_request_arg_free()

void snf_request_arg_free ( SNF_RQST_ARG * arg)
extern

Frees an instance of SNF_RQST_ARG.

Parameters
argInstance to be free'd
Warning
Do not free an argumment if SNF_RQST_ARG::next contains a pointer, and it could cause a memoery leak
  • If you wish to free all arguments then use snf_request_args_free
  • If you wish to free just that one argument then save the SNF_RQST_ARG::next in a variable, replace the arg instance with the the latter variable, and then free arg

◆ snf_request_args_free()

void snf_request_args_free ( SNF_RQST_ARG * arg)
extern

Frees all instance of SNF_RQST_ARG that were linked together using SNF_RQST_ARG::next.

Parameters
argarg Instances to be free'd

◆ snf_request_arg_insert()

void snf_request_arg_insert ( SNF_RQST * Request,
SNF_RQST_ARG * arg )
extern

Inserts an arguments to the end of Request's SNF_RQST_ARG List.

Parameters
RequestRequest to be operated on
argArgument to be added
Note
If you want to Insert a bunch of instances of SNF_RQST_ARG then preferably avoid calling this function but instead crteate the first instance in head variable( SNF_RQST_ARG ) and also put it in a pointer( SNF_RQST_ARG ) variable ( at first it's value Must be the same as the head variable ) variable then everytime you create a new argument you save it in the SNF_RQST_ARG::next member of the pointer variable, and then assign the SNF_RQST_ARG::next 's new value as the pointer variable, at the end, use this function only the head variable

◆ snf_request_fetch()

SNF_RQST * snf_request_fetch ( SNF_CLT * Client)
extern

Fetches the request from the incoming Client.

Parameters
ClientClient to receive request from.
Returns
The possible results :
  • NULL if there was an error with calloc ( See errno and calloc's errcodes )
  • Pointer to the SNF_RQST instance

◆ snf_request_send()

void snf_request_send ( SNF_CLT * Client,
SNF_RQST * Request )
extern

Send a request to a Client.

Parameters
ClientReceiving Client
RequestRequest to Send

◆ snf_request_send_confirm()

void snf_request_send_confirm ( SNF_CLT * Client,
SNF_RQST * Original )
extern

Sends a confirmation Response request to the client.

Parameters
ClientReceiving Client
OriginalClient's Original Request

◆ snf_request_send_reject()

void snf_request_send_reject ( SNF_CLT * Client,
SNF_RQST * Original )
extern

Sends a rejection Response request to the client.

Parameters
ClientReceiving Client
OriginalClient's Original Request

◆ snf_request_send_invalid()

void snf_request_send_invalid ( SNF_CLT * Client,
SNF_RQST * Original )
extern

Sends a invalidation Response request to the client.

Parameters
ClientReceiving Client
OriginalClient's Original Request