/*
 * DCCP-TP internal definitions
 *
 * Copyright (C) 2008 Tom Phelan
 *
 * This file is part of dccp-tp.
 *
 * Dccp-tp is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * Dccp-tp is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with dccp-tp.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Documentation and source code for dccp-tp is available at
 * http://www.phelan-4.com/dccp-tp/.
 */

#ifndef _DCTPINTERNAL_H_
#define _DCTPINTERNAL_H_

/*
 * Function prototypes
 */
dctpSocket *dctpiGetListenSock(dctpSocket *sock);
void dctpiAddListenSock(dctpSocket *sock);
dctpSocket *dctpiGetWaitingSock(dctpSocket *sock);
dctpPacket *dctpiGetNextRcvPacket(dctpSocket *sock);
int dctpiAddRcvPacket(dctpSocket *sock, dctpPacket *pkt);
dctpPacket *dctpiGetNextPacket(dctpSocket *sock);
void dctpiSendResponse(dctpSocket *sock, dctpPacket *data);
void dctpiSendRequest(dctpSocket *sock, dctpPacket *data);
void dctpiSendAck(dctpSocket *sock);
int dctpiXmtPacket(dctpSocket *sock);
void dctpiSendReset(dctpSocket *sock, dctpPacket *ipkt, uint_t code,
		    uint_t data1, uint_t data2, uint_t data3, uint_t encap);
dctpSocket *dctpiGetNatV4IncomingSocket(dctpPacket *pkt);
dctpSocket *dctpiCloneSocket(dctpSocket *sock, dctpPacket *pkt);
uint64_t dctpiSeqNoAdd(uint64_t n1, uint64_t n2);
uint64_t dctpiSeqNoSub(uint64_t n1, uint64_t n2);
void dctpiSendSync(dctpSocket *sock, uint64_t ackno);
void dctpiDestroySock(dctpSocket *sock);
void dctpiSendClose(dctpSocket *sock);
void dctpiSendClosereq(dctpSocket *sock);
void dctpiSendSyncAck(dctpSocket *sock, uint64_t ackno);
void dctpiRequestTimeout(void *arg);
int dctpiCmpSeqNo(uint64_t n1, uint64_t n2);
void dctpiAddWaitingSocket(dctpSocket *sock);
int dctpiFreePort(uint_t encap, uint16_t port);
void dctpiCloseReqTimeout(void *arg);
void dctpiAddFeatures(dctpSocket *sock, dctpPacket *pkt,
		      uint8_t *options, uint_t *oplen);
int dctpiRcvdFeatureOption(dctpSocket *sock, dctpPacket *pkt, uint_t op,
			   uint8_t *ops, uint_t oplen, uint_t mandatory);
int dctpiCloseConnection(dctpSocket *sock, int *cerrno);
int dctpiOpenCcids(dctpSocket *sock);

#endif  /* _DCTPINTERNAL_H_ */

