Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
stream.h File Reference
#include <stdint.h>
#include <stdio.h>
#include <pbl.h>
#include <ev.h>
#include "modules/cque.h"

Go to the source code of this file.

Data Structures

struct  ksnStreamMapData
 File: stream.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
struct  ksnStreamData
 Stream map data structure. More...
 
struct  stream_packet
 Stream packet data structure. More...
 
struct  ksnStreamClass
 Stream module class structure. More...
 

Typedefs

typedef struct ksnStreamMapData ksnStreamMapData
 File: stream.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
typedef struct ksnStreamData ksnStreamData
 Stream map data structure. More...
 
typedef struct ksnStreamClass ksnStreamClass
 Stream module class structure. More...
 

Enumerations

enum  stream_cmd {
  CMD_ST_NONE, CMD_ST_CREATE, CMD_ST_CREATE_GOT, CMD_ST_CREATED,
  CMD_ST_DATA, CMD_ST_CLOSE, CMD_ST_CLOSE_GOT, CMD_ST_CLOSE_NOTREMOVE
}
 Stream subcommands. More...
 

Functions

ksnStreamClassksnStreamInit (void *ke)
 Initialize Stream module. More...
 
void ksnStreamDestroy (ksnStreamClass *ks)
 Stream module destroy. More...
 
int ksnStreamCreate (ksnStreamClass *ks, char *to_peer, char *stream_name, int send_f)
 Create new named stream with selected peer. More...
 
int ksnStreamClose (ksnStreamClass *ks, char *to_peer, char *stream_name, int send_f)
 Close named stream with selected peer. More...
 
int ksnStreamClosePeer (ksnStreamClass *ks, const char *peer_name)
 Close all streams connected to selected peer. More...
 
ksnStreamDataksnStreamGetDataFromMap (ksnStreamData *sd, ksnStreamMapData *smd)
 Get stream data. More...
 
ksnStreamMapDataksnStreamGetMapData (ksnStreamClass *ks, void *key, size_t key_len)
 Get stream map data by key. More...
 

Typedef Documentation

Stream module class structure.

typedef struct ksnStreamData ksnStreamData

Stream map data structure.

File: stream.h Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Teonet stream module

Created on October 3, 2015, 3:02 PM Stream map data structure

Enumeration Type Documentation

enum stream_cmd

Stream subcommands.

Enumerator
CMD_ST_NONE 
CMD_ST_CREATE 

Create stream command.

CMD_ST_CREATE_GOT 

Got create request.

CMD_ST_CREATED 

Stream created (answer to create) command.

CMD_ST_DATA 

Send data command.

CMD_ST_CLOSE 

Close stream command.

CMD_ST_CLOSE_GOT 

Got close request from stream.

CMD_ST_CLOSE_NOTREMOVE 

Close stream but not remove from stream map.

Function Documentation

int ksnStreamClose ( ksnStreamClass ks,
char *  to_peer,
char *  stream_name,
int  send_f 
)
int ksnStreamClosePeer ( ksnStreamClass ks,
const char *  peer_name 
)

Close all streams connected to selected peer.

Parameters
ks
peer_name
Returns

References CMD_ST_CLOSE_GOT, ksnStreamClose(), ksnStreamClosePeer(), and ksnStreamClass::map.

Referenced by ksnetArpRemove(), and ksnStreamClosePeer().

int ksnStreamCreate ( ksnStreamClass ks,
char *  to_peer,
char *  stream_name,
int  send_f 
)

Create new named stream with selected peer.

Parameters
ks
to_peer
stream_name
send_fCMD_ST_CREATE - create pipes and send CREATE request to peer; CMD_ST_CREATE_GOT - CREATE command received, create pipes and send CREATED response CMD_ST_CREATED - CREATED command received
Returns

References CMD_ST_CREATE, CMD_ST_CREATE_GOT, CMD_ST_CREATED, connect_watchers(), ksnStreamMapData::cq, ksnStreamMapData::created, data, DEBUG_VV, ksnCQueData::id, ksnStreamMapData::ke, kev, ksnStreamMapData::key, ksnStreamMapData::key_len, kq_connect_cb(), ksn_printf, KSN_STREAM_CONNECT_TIMEOUT, ksnCQueAdd(), ksnCQueExec(), ksnStreamSendTo(), malloc(), ksnStreamClass::map, MODULE, ksnStreamMapData::pipe_in, ksnStreamMapData::pipe_out, and stream_packet::stream_name_len.

Referenced by cmd_stream_cb(), and event_cb().

void ksnStreamDestroy ( ksnStreamClass ks)

Stream module destroy.

Parameters
ksPointer to ksnStreamClass

References free(), ksnStreamCloseAll(), and ksnStreamClass::map.

Referenced by modules_destroy().

ksnStreamMapData* ksnStreamGetMapData ( ksnStreamClass ks,
void *  key,
size_t  key_len 
)

Get stream map data by key.

Parameters
ks
key
key_len
Returns
Pointer to ksnStreamMapData or NULL if not found

References data, and ksnStreamClass::map.

Referenced by event_cb().

ksnStreamClass* ksnStreamInit ( void *  ke)

Initialize Stream module.

Parameters
kePointer to
Returns

References ke, ksnStreamClass::ke, malloc(), and ksnStreamClass::map.

Referenced by modules_init().