UniSaSA  1.0
C Gateway
Data Structures | Typedefs | Functions
gateway.h File Reference
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "unisasa_types.h"
#include "connector.h"
#include "configuration.h"

Go to the source code of this file.

Data Structures

union  messageInt_t
 

Typedefs

typedef union messageInt_t messageInt_t
 

Functions

void init_gateway ()
 
void load_table (char *path)
 
device_tgetDevices ()
 
unsigned int getNumDevices ()
 
void addConnector (connectorInterface_t newConnector)
 
void discoveryAndCreateTable ()
 
void verifyDevices ()
 
void verifyTable ()
 
void createNewTable ()
 
void create_tcp_server (unsigned int port)
 
void close_gateway ()
 
int wait_client ()
 
void client_communication (int client_sock)
 

Detailed Description

Gateway Implementation.

This gateway reads a request from a TCP socket, forwards it to a different network and sends the answer to the requestor.

Definition in file gateway.h.

Typedef Documentation

◆ messageInt_t

typedef union messageInt_t messageInt_t

Union to convert int/bytes.

Internal use only.

Function Documentation

◆ addConnector()

void addConnector ( connectorInterface_t  newConnector)

Add a new connector.

Parameters
connectora connectorInterface_t implementation.

Definition at line 105 of file gateway.c.

◆ client_communication()

void client_communication ( int  client_sock)

Receive requests and send answers from/to client

Parameters
socket
See also
wait_client()

Definition at line 374 of file gateway.c.

◆ close_gateway()

void close_gateway ( )

Close the TCP socket

Definition at line 356 of file gateway.c.

◆ create_tcp_server()

void create_tcp_server ( unsigned int  port)

Create a TCP Server

Parameters
port(11003 is unisasa default port

Definition at line 330 of file gateway.c.

◆ createNewTable()

void createNewTable ( )

Create a new table.

Destroy old Table and init a new table

Definition at line 318 of file gateway.c.

◆ discoveryAndCreateTable()

void discoveryAndCreateTable ( )

Discovery new devices and create a new Table.

All connectors added are used.

Definition at line 111 of file gateway.c.

◆ getDevices()

device_t* getDevices ( )

Return devices

Returns
devices

Definition at line 292 of file gateway.c.

◆ getNumDevices()

unsigned int getNumDevices ( )

Return devices number

Returns
numDevices

Definition at line 297 of file gateway.c.

◆ init_gateway()

void init_gateway ( )

Init the gateway.

This function is mandatory.

Definition at line 67 of file gateway.c.

◆ load_table()

void load_table ( char *  path)

Load a table from a file

The file has the form: ID ; Address ; TypeConnector ; SizeIODevice ; SizeIDSen ; SizeIDAct ; SYMBOL_[SEN|ACT] ;* ID S/A ; Type S/A ; Size I/O ; Type I/O

Parameters
path

Definition at line 167 of file gateway.c.

◆ verifyDevices()

void verifyDevices ( )

Send a 'verify message' to all connected devices and update current table

Definition at line 303 of file gateway.c.

◆ verifyTable()

void verifyTable ( )

verifyTable alias veifyDevices()

Definition at line 313 of file gateway.c.

◆ wait_client()

int wait_client ( )

Wait a new client/library

Returns
client (socket)

Definition at line 363 of file gateway.c.