1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // tcpseq.h - TCP sequence numbers
15 // This module defines a TCP sequence number with mod32 arithmetic.
32 /** TCP sequence number with mod-32 arithmetic.
39 inline TTcpSeqNum() { iSeq = 0; }
40 inline TTcpSeqNum(TUint32 aSeq) { iSeq = aSeq; }
41 inline TTcpSeqNum(const TTcpSeqNum& aSeq) { iSeq = aSeq.iSeq; }
43 inline TTcpSeqNum& operator=(TUint32 aSeq) { iSeq = aSeq; return *this; }
44 inline TTcpSeqNum& operator=(const TTcpSeqNum& aSeq) { iSeq = aSeq.iSeq; return *this; }
45 inline TTcpSeqNum& operator+=(TInt aOff) { iSeq += aOff; return *this; }
46 inline TTcpSeqNum& operator-=(TInt aOff) { iSeq -= aOff; return *this; }
48 inline TTcpSeqNum& operator++() { ++iSeq; return *this; }
49 inline TTcpSeqNum operator++(TInt) { return iSeq++; }
50 inline TTcpSeqNum& operator--() { --iSeq; return *this; }
51 inline TTcpSeqNum operator--(TInt) { return iSeq--; }
53 inline TBool operator==(const TTcpSeqNum& aSeq) const { return iSeq == aSeq.iSeq; }
54 inline TBool operator!=(const TTcpSeqNum& aSeq) const { return iSeq != aSeq.iSeq; }
55 inline TBool operator<(const TTcpSeqNum& aSeq) const { return (TInt32)(iSeq - aSeq.iSeq) < 0; }
56 inline TBool operator<=(const TTcpSeqNum& aSeq) const { return (TInt32)(iSeq - aSeq.iSeq) <= 0; }
57 inline TBool operator>(const TTcpSeqNum& aSeq) const { return (TInt32)(iSeq - aSeq.iSeq) > 0; }
58 inline TBool operator>=(const TTcpSeqNum& aSeq) const { return (TInt32)(iSeq - aSeq.iSeq) >= 0; }
59 inline TTcpSeqNum operator+(TInt aOff) const { return iSeq + aOff; }
60 inline TTcpSeqNum operator-(TInt aOff) const { return iSeq - aOff; }
61 inline TInt32 operator-(const TTcpSeqNum& aSeq) const { return iSeq - aSeq.iSeq; }
64 // Automatic typecast can lead to ambiguous expressions and
65 // in the worst case to some very hard-to-track errors.
66 // We use the following explicit typecast instead. -ML
68 inline TUint32 Uint32() const { return iSeq; }
69 //inline operator TUint32() const { return iSeq; }
71 // Methods for checking whether a sequence number is inside or outside a given window.
72 inline TBool Inside(TTcpSeqNum aSeqLo, TTcpSeqNum aSeqHi)
73 { return (iSeq - aSeqLo.iSeq) <= (aSeqHi.iSeq - aSeqLo.iSeq); }
75 inline TBool Outside(TTcpSeqNum aSeqLo, TTcpSeqNum aSeqHi)
76 { return (iSeq - aSeqLo.iSeq) > (aSeqHi.iSeq - aSeqLo.iSeq); }