/*
 * Pthreads support functions
 *
 * 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 _DCTPSUPPORT_H_
#define _DCTPSUPPORT_H_

void dctpoSocketLockInit(dctpSocket *sock);
void dctpoSocketLock(dctpSocket *sock);
void dctpoSocketUnlock(dctpSocket *sock);
void dctpoSocketWait(dctpSocket *sock);
void dctpoSocketSignal(dctpSocket *sock);
void dctpoMemcpy(void *dest, void *src, int len);
void *dctpoMalloc(int size);
void dctpoFree(void *ptr);
void dctpoMemset(void *dst, int val, int len);
dctpPacket *dctpoPacketMalloc(int size);
void dctpoPacketFree(dctpPacket *pkt);
void dctpoStartTimer(dctpTimer *t, uint32_t timeout,
		     dctpTimerAction action, void *arg);
void dctpoStopTimer(dctpTimer *t);
void dctpoTimerFuncExit(void);
void dctpoInit(void);
uint64_t dctpoRandomSeqno(void);
void dctpoLog(int pri, char *form, ...);
uint16_t dctpoNtohs(uint16_t ns);
uint32_t dctpoNtohl(uint32_t nl);
uint64_t dctpoNow(void);
uint_t dctpoStrlen(char *s);
dctpPacket *dctpoPacketCopyTo(dctpPacket *pkt, uint_t offset, uint8_t *src, uint_t len);
dctpPacket *dctpoPacketExtendDccpHdr(dctpPacket *pkt, uint_t len);
int dctpoMemcmp(void *s1, void *s2, uint_t len);
void dctpoPacketCopyFrom(dctpPacket *pkt, uint_t offset, uint8_t *dst, uint_t len);
uint16_t dctpoHtons(uint16_t h);
uint32_t dctpoHtonl(uint32_t h);
void dctpoNatV4Xmt(dctpSocket *sock, dctpPacket *pkt);
void dctpoObjectLock(dctpSupportMutex_t *lock);
void dctpoObjectUnlock(dctpSupportMutex_t *lock);
void dctpiAddConnectedSocket(dctpSocket *sock);
void bpoint(char *);
void dctpoPacketCopyData(dctpPacket *dpkt, dctpPacket *spkt);
void *dctpoRealloc(void *ptr, int size);
void dctpiDelayedFree(dctpTimer *t, void *arg, uint32_t delay);

extern dctpSupportMutex_t readThreadLock;

#endif  /* _DCTPSUPPORT_H_ */

