/* LICENSE: */

#ifndef BareNet_h
#define BareNet_h

#include <OPENR/OObject.h>
#include <Types.h>
#include <entry.h>
#include <ant.h>
#include <antTypes.h>
#include <EndpointTypes.h>
#include <UDPEndpointMsg.h>
#include <IPAddress.h>
#include <map>

#include "entry.h"

enum ConnectionState {
  CONNECTION_CLOSED,
  CONNECTION_CONNECTING,
  CONNECTION_CONNECTED,
  CONNECTION_SENDING,
  CONNECTION_RECEIVING,
  CONNECTION_CLOSING
};

struct UDPConnection {
  antModuleRef     endpoint;
  ConnectionState  state;
  
  // send buffer
  antSharedBuffer  sendBuffer;
  byte*            sendData;
  int              sendSize;
  IPAddress        sendAddress;
  Port             sendPort;
  Port             recvPort;
 
  // receive buffer
  antSharedBuffer  recvBuffer;
  byte*            recvData;
  int              recvSize;
  int              recvErrSinceData;
  int              sendErrSinceData;
};

const int buffer_size = 16384;

#endif
