// SCTP Conformance Test Suite Implementation
// (C) Copyright Fujitsu Ltd. 2008, 2009
//
// This file is part of the SCTP Conformance Test Suite implementation.
//
// The SCTP Conformance Test Suite implementation is free software;
// you can redistribute it and/or modify it under the terms of
// the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// The SCTP Conformance Test Suite implementation 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with GNU CC; see the file COPYING.  If not, write to
// the Free Software Foundation, 59 Temple Place - Suite 330,
// Boston, MA 02111-1307, USA.
//
// Please send any bug reports or fixes you make to the
// email address(es):
//    networktest sctp <networktest-sctp@lists.sourceforge.net>
//
// Or submit a bug report through the following website:
//    http://networktest.sourceforge.net/
//
// Written or modified by:
//    Hiroaki Kago <linuxsctp-kg@ml.css.fujitsu.com>
//    Wei Yongjun <yjwei@cn.fujitsu.com>
//
// Any bugs reported given to us we will try to fix... any fixes shared will
// be incorporated into the next SCTP release.
//

#ifndef __SCTP_COMMON_DEF_
#define __SCTP_COMMON_DEF_	1

#include "sctpconf.def"
#include "IP_COMMON.def"

#if (ENABLE_IPV6 == 0)

#define PKG_SCTP_NORM_SEND		PKG_SCTP_NORM_SEND4
#define PKG_SCTP_NORM_RECV		PKG_SCTP_NORM_RECV4
#define PKG_SCTP_EXTH_SEND		PKG_SCTP_EXTH_SEND4
#define PKG_SCTP_EXTH_RECV		PKG_SCTP_EXTH_RECV4
#define PKG_SCTP_SHORT_SEND		PKG_SCTP_SHORT_SEND4
#define PKG_SCTP_SHORT_RECV		PKG_SCTP_SHORT_RECV4
#define PKG_SCTP_FULL_SEND		PKG_SCTP_FULL_SEND4
#define PKG_SCTP_FULL_RECV		PKG_SCTP_FULL_RECV4
#define _ECN				_ECN4

#else 

#define PKG_SCTP_NORM_SEND		PKG_SCTP_NORM_SEND6
#define PKG_SCTP_NORM_RECV		PKG_SCTP_NORM_RECV6
#define PKG_SCTP_EXTH_SEND		PKG_SCTP_EXTH_SEND6
#define PKG_SCTP_EXTH_RECV		PKG_SCTP_EXTH_RECV6
#define PKG_SCTP_SHORT_SEND		PKG_SCTP_SHORT_SEND6
#define PKG_SCTP_SHORT_RECV		PKG_SCTP_SHORT_RECV6
#define PKG_SCTP_FULL_SEND		PKG_SCTP_FULL_SEND6
#define PKG_SCTP_FULL_RECV		PKG_SCTP_FULL_RECV6
#define _ECN				_ECN6

#endif /* #if (ENABLE_IPV6 == 0) */

#define _ECN4(_pValue)		TypeOfService = _pValue
#define _ECN6(_pValue)		TrafficClass = _pValue

#ifndef VERFTAG
#define VERFTAG	0xFFFFFFFF
#endif

#define PKG_SCTP_NORM_SEND4(_pNAME, _oHDR_IPV4, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	_oHDR_IPV4, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_TN0_PORT; \
		DestinationPort = SCTP_NUT0_PORT;	\
		VerificationTag = VERFTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_NORM_RECV4(_pNAME, _oHDR_IPV4, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	_oHDR_IPV4, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_NUT0_PORT; \
		DestinationPort = SCTP_TN0_PORT;	\
		VerificationTag = INITTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_EXTH_SEND4(_pNAME, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	{ \
		_SRC(v4(SCTP4_TN_NET0_ADDR)); \
		_DST(v4(SCTP4_NUT_NET0_ADDR)); \
	}, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_EXTH_RECV4(_pNAME, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	{ \
		_SRC(v4(SCTP4_NUT_NET0_ADDR)); \
		_DST(v4(SCTP4_TN_NET0_ADDR)); \
	}, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_SHORT_SEND4(_pNAME, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	{ \
		_SRC(v4(SCTP4_TN_NET0_ADDR)); \
		_DST(v4(SCTP4_NUT_NET0_ADDR)); \
	}, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_TN0_PORT; \
		DestinationPort = SCTP_NUT0_PORT;	\
		VerificationTag = VERFTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_SHORT_RECV4(_pNAME, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	{ \
		_SRC(v4(SCTP4_NUT_NET0_ADDR)); \
		_DST(v4(SCTP4_TN_NET0_ADDR)); \
	}, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_NUT0_PORT; \
		DestinationPort = SCTP_TN0_PORT;	\
		VerificationTag = INITTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_FULL_SEND4(_pNAME, _oHDR_IPV4, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	_oHDR_IPV4, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_FULL_RECV4(_pNAME, _oHDR_IPV4, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp4_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	_oHDR_IPV4, \
	{ \
		header = _HDR_IPV4_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_NORM_SEND6(_pNAME, _oHDR_IPV6, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	_oHDR_IPV6, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_TN0_PORT; \
		DestinationPort = SCTP_NUT0_PORT;	\
		VerificationTag = VERFTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_NORM_RECV6(_pNAME, _oHDR_IPV6, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	_oHDR_IPV6, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_NUT0_PORT; \
		DestinationPort = SCTP_TN0_PORT;	\
		VerificationTag = INITTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_EXTH_SEND6(_pNAME, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	{ \
		_SRC(SCTP6_TN_NET0_ADDR); \
		_DST(SCTP6_NUT_NET0_ADDR); \
	}, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_EXTH_RECV6(_pNAME, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	{ \
		_SRC(SCTP6_NUT_NET0_ADDR); \
		_DST(SCTP6_TN_NET0_ADDR); \
	}, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_SHORT_SEND6(_pNAME, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	{ \
		_SRC(SCTP6_TN_NET0_ADDR); \
		_DST(SCTP6_NUT_NET0_ADDR); \
	}, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_TN0_PORT; \
		DestinationPort = SCTP_NUT0_PORT;	\
		VerificationTag = VERFTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_SHORT_RECV6(_pNAME, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	{ \
		_SRC(SCTP6_NUT_NET0_ADDR); \
		_DST(SCTP6_TN_NET0_ADDR); \
	}, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	{ \
		SourcePort = SCTP_NUT0_PORT; \
		DestinationPort = SCTP_TN0_PORT;	\
		VerificationTag = INITTAG; \
	}, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_FULL_SEND6(_pNAME, _oHDR_IPV6, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_tn2nut, \
	_oHDR_IPV6, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define PKG_SCTP_FULL_RECV6(_pNAME, _oHDR_IPV6, _oHDR_SCTP, _oUPP_SCTP) \
FEM_sctp6_exth( \
	_pNAME, \
	_HETHER_nut2tn, \
	_oHDR_IPV6, \
	{ \
		header = _HDR_IPV6_NAME(_pNAME); \
		upper = _UPP_SCTP_NAME(_pNAME); \
	}, \
	_oHDR_SCTP, \
	{ \
		header = _HDR_SCTP_NAME(_pNAME); \
		_oUPP_SCTP \
	} \
)

#define TP_CHUNK_DATA			0
#define TP_CHUNK_INIT			1
#define TP_CHUNK_INIT_ACK		2
#define TP_CHUNK_SACK			3
#define TP_CHUNK_HEARTBEAT		4
#define TP_CHUNK_HEARTBEAT_ACK		5
#define TP_CHUNK_ABORT			6
#define TP_CHUNK_SHUTDOWN		7
#define TP_CHUNK_SHUTDOWN_ACK		8
#define TP_CHUNK_ERROR			9
#define TP_CHUNK_COOKIE_ECHO		10
#define TP_CHUNK_COOKIE_ACK		11
#define TP_CHUNK_SHUTDOWN_COMPLETE	14
#define TP_CHUNK_FORWARD_TSN		192
#define TP_CHUNK_ASCONF 		0xC1
#define TP_CHUNK_ASCONF_ACK 		0x80
#define TP_CHUNK_AUTH 			0x0F

#endif /* #ifndef __SCTP_COMMON_DEF_ */
