Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
net_split.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "net_split.h"
#include "utils/rlutil.h"
#include "utils/teo_memory.h"

Macros

#define MODULE   _ANSI_BLUE "net_split" _ANSI_NONE
 File: net_split.c Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
#define kev   ((ksnetEvMgrClass*)(((ksnCoreClass*)(ks->kco->kc))->ke))
 
#define create_key(subpacket_num)
 

Functions

ksnSplitClassksnSplitInit (ksnCommandClass *kco)
 Initialize split module. More...
 
void ksnSplitDestroy (ksnSplitClass *ks)
 Destroy split module. More...
 
void ** ksnSplitPacket (ksnSplitClass *ks, uint8_t cmd, void *packet, size_t packet_len, int *num_subpackets)
 Split large packet to array of small. More...
 
ksnCorePacketDataksnSplitCombine (ksnSplitClass *ks, ksnCorePacketData *rd)
 Combine packets to one large packet. More...
 
void ksnSplitFreeRds (ksnSplitClass *ks, ksnCorePacketData *rd)
 Free ksnCorePacketData created in ksnSplitCombine function. More...
 

Macro Definition Documentation

#define create_key (   subpacket_num)
Value:
size_t key_len = sizeof(uint8_t) + rd->from_len + sizeof(uint16_t)*2; \
void *key = teo_malloc(key_len); \
size_t ptr = 0; \
*(uint8_t*)key = rd->from_len; ptr += sizeof(uint8_t); \
memcpy(key + ptr, rd->from, rd->from_len); ptr += rd->from_len; \
*(uint16_t*)(key + ptr) = packet_num ; ptr += sizeof(packet_num); \
*(uint16_t*)(key + ptr) = subpacket_num ; ptr += sizeof(subpacket_num)
void * teo_malloc(size_t size)
Definition: teo_memory.c:22
#define rd

Referenced by ksnSplitCombine().

#define kev   ((ksnetEvMgrClass*)(((ksnCoreClass*)(ks->kco->kc))->ke))

Referenced by ksnSplitCombine(), and ksnSplitPacket().

#define MODULE   _ANSI_BLUE "net_split" _ANSI_NONE

File: net_split.c Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Created on July 17, 2015, 10:20 AM

Referenced by ksnSplitCombine(), and ksnSplitPacket().

Function Documentation

void ksnSplitDestroy ( ksnSplitClass ks)

Destroy split module.

Parameters
ks

References free(), and ksnSplitClass::map.

Referenced by ksnCommandDestroy().

void ksnSplitFreeRds ( ksnSplitClass ks,
ksnCorePacketData rd 
)

Free ksnCorePacketData created in ksnSplitCombine function.

Parameters
ks
rd

References ksnSplitClass::data_save, and free().

ksnSplitClass* ksnSplitInit ( ksnCommandClass kco)

Initialize split module.

Parameters
kco
Returns

References ksnSplitClass::kco, ksnSplitClass::last_added, ksnSplitClass::map, ksnSplitClass::packet_number, and teo_malloc().

Referenced by ksnCommandInit().

void** ksnSplitPacket ( ksnSplitClass ks,
uint8_t  cmd,
void *  packet,
size_t  packet_len,
int *  num_subpackets 
)

Split large packet to array of small.

Parameters
ks
cmd
packet
packet_len
num_subpackets
Returns

References DEBUG_VV, kev, ksn_printf, malloc(), MAX_DATA_LEN, MODULE, and ksnSplitClass::packet_number.

Referenced by ksnCoreSendto().