A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.

Dependents:   oldheating gps motorhome heating

tcp/tcb.h

Committer:
andrewboyson
Date:
2019-05-12
Revision:
144:6bd5c54efc7d
Parent:
131:774f7f367031
Child:
147:a6093b52e654

File content as of revision 144:6bd5c54efc7d:

#ifndef TCB_H
#define TCB_H

#include <stdint.h>
#include <stdbool.h>

#define TCB_EMPTY          0
#define TCB_SYN_RECEIVED   1
#define TCB_ESTABLISHED    2
#define TCB_CLOSE_FIN_WAIT 3

#define TCB_APP_STATE_BYTES 16

struct tcb
{
    int      state;
    uint32_t timeSendsBeingAcked; //Used for RTO
    int      countSendsNotAcked;  //Used for RTO
    uint32_t timeLastRcvd;        //Used for detect idle links
    int      ipType;
    int      remArIndex;          //Unique per remote ip when taken with the ipType
    int      locIpScope;          //Unique per local ip
    uint16_t remPort;
    uint16_t locPort;
    uint32_t remMss;
    uint32_t window;
    
    uint32_t remIsn;
    uint32_t bytesRcvdFromRem;
    uint32_t bytesAckdToRem;
    bool     rcvdFin;
    
    uint32_t locIsn;
    uint32_t bytesSentToRem;
    uint32_t bytesAckdByRem;
    bool     sentFin;
    
    bool     appStarted;                   //Set when data has been sent to the app.
    char     appData[TCB_APP_STATE_BYTES]; //This is just a place for the app to hold state information - it has no function in TCP.
};

extern uint32_t    TcbGetIsn(void);
extern struct tcb* TcbGetExisting(int ipType, int remArIndex, int locIpScope, uint16_t remPort, uint16_t locPort);
extern struct tcb* TcbGetEmpty(void);
extern struct tcb* TcbGetNext(struct tcb* pTcb);
extern void        TcbInit(void);

#endif