libschc
Classes | Macros | Typedefs | Enumerations | Functions
fragmenter.h File Reference
#include "schc.h"
#include "schc_config.h"

Go to the source code of this file.

Classes

struct  schc_mbuf_t
 
struct  schc_fragmentation_ack_t
 
struct  schc_fragmentation_t
 

Macros

#define SCHC_FRAG_INPUT   2
 Return code: Indicator. More...
 
#define SCHC_ACK_INPUT   1
 Return code: Indicator. More...
 
#define SCHC_SUCCESS   0
 Return code: No error. More...
 
#define SCHC_END   3
 Return code: End of fragmentation cycle. More...
 
#define SCHC_FAILURE   -1
 Return code: Error. More...
 
#define SCHC_NO_FRAGMENTATION   -2
 Return code: Error. More...
 

Typedefs

typedef struct schc_mbuf_t schc_mbuf_t
 
typedef struct schc_fragmentation_ack_t schc_fragmentation_ack_t
 
typedef struct schc_fragmentation_t schc_fragmentation_t
 

Enumerations

enum  tx_state {
  INIT_TX = 0, SEND = 1, RESEND = 2, WAIT_BITMAP = 3,
  END_TX = 4, ERR = 5
}
 
enum  rx_state {
  RECV_WINDOW = 0, WAIT_NEXT_WINDOW = 1, WAIT_MISSING_FRAG = 2, WAIT_END = 3,
  END_RX = 4, ABORT = 5
}
 

Functions

int8_t schc_fragmenter_init (schc_fragmentation_t *tx_conn, uint8_t(*send)(uint8_t *data, uint16_t length, uint32_t device_id), void(*end_rx)(schc_fragmentation_t *conn), void(*remove_timer_entry)(uint32_t device_id))
 Initializes the SCHC fragmenter. More...
 
int8_t schc_fragment (schc_fragmentation_t *tx_conn)
 the sender state machine More...
 
int8_t schc_reassemble (schc_fragmentation_t *rx_conn)
 the receiver state machine More...
 
void schc_reset (schc_fragmentation_t *conn)
 reset a connection More...
 
schc_fragmentation_tschc_input (uint8_t *data, uint16_t len, schc_fragmentation_t *rx_conn, uint32_t device_id)
 This function should be called whenever a packet is received. More...
 
void schc_ack_input (uint8_t *data, uint16_t len, schc_fragmentation_t *tx_conn, uint32_t device_id)
 This function should be called whenever an ack is received. More...
 
schc_fragmentation_tschc_fragment_input (uint8_t *data, uint16_t len, uint32_t device_id)
 This function should be called whenever a fragment is received an open connection is picked for the device out of a pool of connections to keep track of the packet. More...
 
schc_fragmentation_tschc_get_connection (uint32_t device_id)
 find a connection based on a device id or open a new connection if there was no connection for this device yet More...
 
uint16_t get_mbuf_len (schc_mbuf_t *head)
 returns the total length of the mbuf More...
 
void mbuf_copy (schc_mbuf_t *head, uint8_t *ptr)
 copy the byte alligned contents of the mbuf chain to the passed pointer More...
 

Macro Definition Documentation

◆ SCHC_ACK_INPUT

#define SCHC_ACK_INPUT   1

Return code: Indicator.

Generic indication that an acknowledgment was received

◆ SCHC_END

#define SCHC_END   3

Return code: End of fragmentation cycle.

Indicates successful completion of an SCHC fragmentation cycle.

◆ SCHC_FAILURE

#define SCHC_FAILURE   -1

Return code: Error.

Generic indication that an SCHC operation went wrong

◆ SCHC_FRAG_INPUT

#define SCHC_FRAG_INPUT   2

Return code: Indicator.

Generic indication that a fragment was received

◆ SCHC_NO_FRAGMENTATION

#define SCHC_NO_FRAGMENTATION   -2

Return code: Error.

Generic indication that no fragmentation was needed

◆ SCHC_SUCCESS

#define SCHC_SUCCESS   0

Return code: No error.

Indicates successful completion of an SCHC operation.

Typedef Documentation

◆ schc_fragmentation_ack_t

◆ schc_fragmentation_t

◆ schc_mbuf_t

typedef struct schc_mbuf_t schc_mbuf_t

Enumeration Type Documentation

◆ rx_state

enum rx_state
Enumerator
RECV_WINDOW 
WAIT_NEXT_WINDOW 
WAIT_MISSING_FRAG 
WAIT_END 
END_RX 
ABORT 

◆ tx_state

enum tx_state
Enumerator
INIT_TX 
SEND 
RESEND 
WAIT_BITMAP 
END_TX 
ERR 

Function Documentation

◆ get_mbuf_len()

uint16_t get_mbuf_len ( schc_mbuf_t head)

returns the total length of the mbuf

Parameters
headthe head of the list
Returns
len the total length of the fragment

◆ mbuf_copy()

void mbuf_copy ( schc_mbuf_t head,
uint8_t *  ptr 
)

copy the byte alligned contents of the mbuf chain to the passed pointer

Parameters
headthe head of the list
ptrthe pointer to copy the contents to

◆ schc_ack_input()

void schc_ack_input ( uint8_t *  data,
uint16_t  len,
schc_fragmentation_t tx_conn,
uint32_t  device_id 
)

This function should be called whenever an ack is received.

Parameters
dataa pointer to the received data
lenthe length of the received packet
tx_conna pointer to the tx initialization structure
device_idthe device id from the rx source

◆ schc_fragment()

int8_t schc_fragment ( schc_fragmentation_t tx_conn)

the sender state machine

Parameters
tx_conna pointer to the tx connection structure
Returns
0 TBD -1 failed to initialize the connection -2 no fragmentation was needed for this packet

◆ schc_fragment_input()

schc_fragmentation_t* schc_fragment_input ( uint8_t *  data,
uint16_t  len,
uint32_t  device_id 
)

This function should be called whenever a fragment is received an open connection is picked for the device out of a pool of connections to keep track of the packet.

Parameters
dataa pointer to the data packet
lenthe length of the received packet
device_idthe device id from the rx source
Returns
conn the connection

◆ schc_fragmenter_init()

int8_t schc_fragmenter_init ( schc_fragmentation_t tx_conn,
uint8_t(*)(uint8_t *data, uint16_t length, uint32_t device_id)  send,
void(*)(schc_fragmentation_t *conn)  end_rx,
void(*)(uint32_t device_id)  remove_timer_entry 
)

Initializes the SCHC fragmenter.

Parameters
tx_conna pointer to the tx initialization structure
senda pointer to the send callback
end_rxthis function is called to indicate that the last rx timer has expired
remove_timer_entrysome scheduler implementations need a callback to remove a timer entry for a certain device
Returns
error codes on error

◆ schc_get_connection()

schc_fragmentation_t* schc_get_connection ( uint32_t  device_id)

find a connection based on a device id or open a new connection if there was no connection for this device yet

Parameters
device_idthe id of the device to open a connection for
Returns
conn a pointer to the selected connection 0 if no free connections are available

◆ schc_input()

schc_fragmentation_t* schc_input ( uint8_t *  data,
uint16_t  len,
schc_fragmentation_t tx_conn,
uint32_t  device_id 
)

This function should be called whenever a packet is received.

Parameters
dataa pointer to the received data
lenthe length of the received packet
tx_conna pointer to the tx initialization structure
device_idthe device id from the rx source

◆ schc_reassemble()

int8_t schc_reassemble ( schc_fragmentation_t rx_conn)

the receiver state machine

Parameters
conna pointer to the connection
Returns
0 TBD

◆ schc_reset()

void schc_reset ( schc_fragmentation_t conn)

reset a connection

Parameters
conna pointer to the connection to reset