|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // tcpseq.h - TCP sequence numbers |
|
15 // This module defines a TCP sequence number with mod32 arithmetic. |
|
16 // |
|
17 |
|
18 |
|
19 |
|
20 /** |
|
21 @file tcpseq.h |
|
22 @publishedAll |
|
23 @released |
|
24 */ |
|
25 |
|
26 #ifndef __TCPSEQ_H__ |
|
27 #define __TCPSEQ_H__ |
|
28 |
|
29 #include <e32std.h> |
|
30 |
|
31 |
|
32 /** TCP sequence number with mod-32 arithmetic. |
|
33 @publishedAll |
|
34 @released |
|
35 */ |
|
36 class TTcpSeqNum |
|
37 { |
|
38 public: |
|
39 inline TTcpSeqNum() { iSeq = 0; } |
|
40 inline TTcpSeqNum(TUint32 aSeq) { iSeq = aSeq; } |
|
41 inline TTcpSeqNum(const TTcpSeqNum& aSeq) { iSeq = aSeq.iSeq; } |
|
42 |
|
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; } |
|
47 |
|
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--; } |
|
52 |
|
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; } |
|
62 |
|
63 // |
|
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 |
|
67 // |
|
68 inline TUint32 Uint32() const { return iSeq; } |
|
69 //inline operator TUint32() const { return iSeq; } |
|
70 |
|
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); } |
|
74 |
|
75 inline TBool Outside(TTcpSeqNum aSeqLo, TTcpSeqNum aSeqHi) |
|
76 { return (iSeq - aSeqLo.iSeq) > (aSeqHi.iSeq - aSeqLo.iSeq); } |
|
77 |
|
78 private: |
|
79 TUint32 iSeq; |
|
80 }; |
|
81 |
|
82 #endif |