blob: 72efa61535d0eddd04ec53c14b206ec636bcde93 [file] [log] [blame]
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -08001/**
Ray Milkey269ffb92014-04-03 14:43:30 -07002 * Copyright 2011, Big Switch Networks, Inc.
3 * Originally created by David Erickson, Stanford University
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may
6 * not use this file except in compliance with the License. You may obtain
7 * a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations
15 * under the License.
16 **/
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080017
18/**
Ray Milkey269ffb92014-04-03 14:43:30 -070019 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080020 */
Jonathan Hartdeda0ba2014-04-03 11:14:12 -070021package net.onrc.onos.core.packet;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080022
23import java.nio.ByteBuffer;
24import java.util.Arrays;
25import java.util.Collection;
26import java.util.HashMap;
27import java.util.Map;
28
29/**
30 * @author David Erickson (daviderickson@cs.stanford.edu)
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080031 */
32public class IPv4 extends BasePacket {
Ray Milkey269ffb92014-04-03 14:43:30 -070033 public static final int ADDRESS_LENGTH = 4;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080034 public static final byte PROTOCOL_ICMP = 0x1;
35 public static final byte PROTOCOL_TCP = 0x6;
36 public static final byte PROTOCOL_UDP = 0x11;
Pavlin Radoslavov608fac32014-04-09 12:40:24 -070037 public static final Map<Byte, Class<? extends IPacket>> PROTOCOL_CLASS_MAP;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080038
39 static {
Pavlin Radoslavov608fac32014-04-09 12:40:24 -070040 PROTOCOL_CLASS_MAP = new HashMap<Byte, Class<? extends IPacket>>();
41 PROTOCOL_CLASS_MAP.put(PROTOCOL_ICMP, ICMP.class);
42 PROTOCOL_CLASS_MAP.put(PROTOCOL_TCP, TCP.class);
43 PROTOCOL_CLASS_MAP.put(PROTOCOL_UDP, UDP.class);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -080044 }
45
46 protected byte version;
47 protected byte headerLength;
48 protected byte diffServ;
49 protected short totalLength;
50 protected short identification;
51 protected byte flags;
52 protected short fragmentOffset;
53 protected byte ttl;
54 protected byte protocol;
55 protected short checksum;
56 protected int sourceAddress;
57 protected int destinationAddress;
58 protected byte[] options;
59
60 protected boolean isTruncated;
61
62 /**
63 * Default constructor that sets the version to 4.
64 */
65 public IPv4() {
66 super();
67 this.version = 4;
68 isTruncated = false;
69 }
70
71 /**
72 * @return the version
73 */
74 public byte getVersion() {
75 return version;
76 }
77
78 /**
79 * @param version the version to set
80 */
81 public IPv4 setVersion(byte version) {
82 this.version = version;
83 return this;
84 }
85
86 /**
87 * @return the headerLength
88 */
89 public byte getHeaderLength() {
90 return headerLength;
91 }
92
93 /**
94 * @return the diffServ
95 */
96 public byte getDiffServ() {
97 return diffServ;
98 }
99
100 /**
101 * @param diffServ the diffServ to set
102 */
103 public IPv4 setDiffServ(byte diffServ) {
104 this.diffServ = diffServ;
105 return this;
106 }
107
108 /**
109 * @return the totalLength
110 */
111 public short getTotalLength() {
112 return totalLength;
113 }
114
115 /**
116 * @return the identification
117 */
118 public short getIdentification() {
119 return identification;
120 }
121
122 public boolean isTruncated() {
123 return isTruncated;
124 }
125
126 public void setTruncated(boolean isTruncated) {
127 this.isTruncated = isTruncated;
128 }
129
130 /**
131 * @param identification the identification to set
132 */
133 public IPv4 setIdentification(short identification) {
134 this.identification = identification;
135 return this;
136 }
137
138 /**
139 * @return the flags
140 */
141 public byte getFlags() {
142 return flags;
143 }
144
145 /**
146 * @param flags the flags to set
147 */
148 public IPv4 setFlags(byte flags) {
149 this.flags = flags;
150 return this;
151 }
152
153 /**
154 * @return the fragmentOffset
155 */
156 public short getFragmentOffset() {
157 return fragmentOffset;
158 }
159
160 /**
161 * @param fragmentOffset the fragmentOffset to set
162 */
163 public IPv4 setFragmentOffset(short fragmentOffset) {
164 this.fragmentOffset = fragmentOffset;
165 return this;
166 }
167
168 /**
169 * @return the ttl
170 */
171 public byte getTtl() {
172 return ttl;
173 }
174
175 /**
176 * @param ttl the ttl to set
177 */
178 public IPv4 setTtl(byte ttl) {
179 this.ttl = ttl;
180 return this;
181 }
182
183 /**
184 * @return the protocol
185 */
186 public byte getProtocol() {
187 return protocol;
188 }
189
190 /**
191 * @param protocol the protocol to set
192 */
193 public IPv4 setProtocol(byte protocol) {
194 this.protocol = protocol;
195 return this;
196 }
197
198 /**
199 * @return the checksum
200 */
201 public short getChecksum() {
202 return checksum;
203 }
204
205 /**
206 * @param checksum the checksum to set
207 */
208 public IPv4 setChecksum(short checksum) {
209 this.checksum = checksum;
210 return this;
211 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700212
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800213 @Override
214 public void resetChecksum() {
215 this.checksum = 0;
216 super.resetChecksum();
217 }
218
219 /**
220 * @return the sourceAddress
221 */
222 public int getSourceAddress() {
223 return sourceAddress;
224 }
225
226 /**
227 * @param sourceAddress the sourceAddress to set
228 */
229 public IPv4 setSourceAddress(int sourceAddress) {
230 this.sourceAddress = sourceAddress;
231 return this;
232 }
233
234 /**
235 * @param sourceAddress the sourceAddress to set
236 */
237 public IPv4 setSourceAddress(String sourceAddress) {
238 this.sourceAddress = IPv4.toIPv4Address(sourceAddress);
239 return this;
240 }
241
242 /**
243 * @return the destinationAddress
244 */
245 public int getDestinationAddress() {
246 return destinationAddress;
247 }
248
249 /**
250 * @param destinationAddress the destinationAddress to set
251 */
252 public IPv4 setDestinationAddress(int destinationAddress) {
253 this.destinationAddress = destinationAddress;
254 return this;
255 }
256
257 /**
258 * @param destinationAddress the destinationAddress to set
259 */
260 public IPv4 setDestinationAddress(String destinationAddress) {
261 this.destinationAddress = IPv4.toIPv4Address(destinationAddress);
262 return this;
263 }
264
265 /**
266 * @return the options
267 */
268 public byte[] getOptions() {
269 return options;
270 }
271
272 /**
273 * @param options the options to set
274 */
275 public IPv4 setOptions(byte[] options) {
Ray Milkeyb29e6262014-04-09 16:02:14 -0700276 if (options != null && (options.length % 4) > 0) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800277 throw new IllegalArgumentException(
278 "Options length must be a multiple of 4");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700279 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800280 this.options = options;
281 return this;
282 }
283
284 /**
285 * Serializes the packet. Will compute and set the following fields if they
286 * are set to specific values at the time serialize is called:
Ray Milkey269ffb92014-04-03 14:43:30 -0700287 * -checksum : 0
288 * -headerLength : 0
289 * -totalLength : 0
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800290 */
291 public byte[] serialize() {
292 byte[] payloadData = null;
293 if (payload != null) {
294 payload.setParent(this);
295 payloadData = payload.serialize();
296 }
297
298 int optionsLength = 0;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700299 if (this.options != null) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800300 optionsLength = this.options.length / 4;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700301 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800302 this.headerLength = (byte) (5 + optionsLength);
303
304 this.totalLength = (short) (this.headerLength * 4 + ((payloadData == null) ? 0
305 : payloadData.length));
306
307 byte[] data = new byte[this.totalLength];
308 ByteBuffer bb = ByteBuffer.wrap(data);
309
310 bb.put((byte) (((this.version & 0xf) << 4) | (this.headerLength & 0xf)));
311 bb.put(this.diffServ);
312 bb.putShort(this.totalLength);
313 bb.putShort(this.identification);
314 bb.putShort((short) (((this.flags & 0x7) << 13) | (this.fragmentOffset & 0x1fff)));
315 bb.put(this.ttl);
316 bb.put(this.protocol);
317 bb.putShort(this.checksum);
318 bb.putInt(this.sourceAddress);
319 bb.putInt(this.destinationAddress);
Ray Milkeyb29e6262014-04-09 16:02:14 -0700320 if (this.options != null) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800321 bb.put(this.options);
Ray Milkeyb29e6262014-04-09 16:02:14 -0700322 }
323 if (payloadData != null) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800324 bb.put(payloadData);
Ray Milkeyb29e6262014-04-09 16:02:14 -0700325 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800326
327 // compute checksum if needed
328 if (this.checksum == 0) {
329 bb.rewind();
330 int accumulation = 0;
331 for (int i = 0; i < this.headerLength * 2; ++i) {
332 accumulation += 0xffff & bb.getShort();
333 }
334 accumulation = ((accumulation >> 16) & 0xffff)
335 + (accumulation & 0xffff);
336 this.checksum = (short) (~accumulation & 0xffff);
337 bb.putShort(10, this.checksum);
338 }
339 return data;
340 }
341
342 @Override
343 public IPacket deserialize(byte[] data, int offset, int length) {
344 ByteBuffer bb = ByteBuffer.wrap(data, offset, length);
345 short sscratch;
346
347 this.version = bb.get();
348 this.headerLength = (byte) (this.version & 0xf);
349 this.version = (byte) ((this.version >> 4) & 0xf);
350 this.diffServ = bb.get();
351 this.totalLength = bb.getShort();
352 this.identification = bb.getShort();
353 sscratch = bb.getShort();
354 this.flags = (byte) ((sscratch >> 13) & 0x7);
355 this.fragmentOffset = (short) (sscratch & 0x1fff);
356 this.ttl = bb.get();
357 this.protocol = bb.get();
358 this.checksum = bb.getShort();
359 this.sourceAddress = bb.getInt();
360 this.destinationAddress = bb.getInt();
361
362 if (this.headerLength > 5) {
363 int optionsLength = (this.headerLength - 5) * 4;
364 this.options = new byte[optionsLength];
365 bb.get(this.options);
366 }
367
368 IPacket payload;
Pavlin Radoslavov608fac32014-04-09 12:40:24 -0700369 if (IPv4.PROTOCOL_CLASS_MAP.containsKey(this.protocol)) {
370 Class<? extends IPacket> clazz = IPv4.PROTOCOL_CLASS_MAP.get(this.protocol);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800371 try {
372 payload = clazz.newInstance();
373 } catch (Exception e) {
374 throw new RuntimeException("Error parsing payload for IPv4 packet", e);
375 }
376 } else {
377 payload = new Data();
378 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700379 this.payload = payload.deserialize(data, bb.position(), bb.limit() - bb.position());
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800380 this.payload.setParent(this);
381
Ray Milkeyb29e6262014-04-09 16:02:14 -0700382 if (this.totalLength != length) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800383 this.isTruncated = true;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700384 } else {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800385 this.isTruncated = false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700386 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800387
388 return this;
389 }
390
391 /**
392 * Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and
393 * returns the corresponding 32 bit integer.
Ray Milkey269ffb92014-04-03 14:43:30 -0700394 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800395 * @param ipAddress
396 * @return
397 */
398 public static int toIPv4Address(String ipAddress) {
Ray Milkeyb29e6262014-04-09 16:02:14 -0700399 if (ipAddress == null) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800400 throw new IllegalArgumentException("Specified IPv4 address must" +
Ray Milkey269ffb92014-04-03 14:43:30 -0700401 "contain 4 sets of numerical digits separated by periods");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700402 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800403 String[] octets = ipAddress.split("\\.");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700404 if (octets.length != 4) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800405 throw new IllegalArgumentException("Specified IPv4 address must" +
Ray Milkey269ffb92014-04-03 14:43:30 -0700406 "contain 4 sets of numerical digits separated by periods");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700407 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800408
409 int result = 0;
410 for (int i = 0; i < 4; ++i) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700411 result |= Integer.valueOf(octets[i]) << ((3 - i) * 8);
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800412 }
413 return result;
414 }
415
416 /**
417 * Accepts an IPv4 address in a byte array and returns the corresponding
418 * 32-bit integer value.
Ray Milkey269ffb92014-04-03 14:43:30 -0700419 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800420 * @param ipAddress
421 * @return
422 */
423 public static int toIPv4Address(byte[] ipAddress) {
424 int ip = 0;
425 for (int i = 0; i < 4; i++) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700426 int t = (ipAddress[i] & 0xff) << ((3 - i) * 8);
427 ip |= t;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800428 }
429 return ip;
430 }
431
432 /**
433 * Accepts an IPv4 address and returns of string of the form xxx.xxx.xxx.xxx
Ray Milkeyb41100a2014-04-10 10:42:15 -0700434 * ie 192.168.0.1.
Ray Milkey269ffb92014-04-03 14:43:30 -0700435 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800436 * @param ipAddress
437 * @return
438 */
439 public static String fromIPv4Address(int ipAddress) {
440 StringBuffer sb = new StringBuffer();
441 int result = 0;
442 for (int i = 0; i < 4; ++i) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700443 result = (ipAddress >> ((3 - i) * 8)) & 0xff;
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800444 sb.append(Integer.valueOf(result).toString());
Ray Milkeyb29e6262014-04-09 16:02:14 -0700445 if (i != 3) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800446 sb.append(".");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700447 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800448 }
449 return sb.toString();
450 }
451
452 /**
453 * Accepts a collection of IPv4 addresses as integers and returns a single
454 * String useful in toString method's containing collections of IP
455 * addresses.
Ray Milkey269ffb92014-04-03 14:43:30 -0700456 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800457 * @param ipAddresses collection
458 * @return
459 */
460 public static String fromIPv4AddressCollection(Collection<Integer> ipAddresses) {
Ray Milkeyb29e6262014-04-09 16:02:14 -0700461 if (ipAddresses == null) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800462 return "null";
Ray Milkeyb29e6262014-04-09 16:02:14 -0700463 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800464 StringBuffer sb = new StringBuffer();
465 sb.append("[");
466 for (Integer ip : ipAddresses) {
467 sb.append(fromIPv4Address(ip));
468 sb.append(",");
469 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700470 sb.replace(sb.length() - 1, sb.length(), "]");
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800471 return sb.toString();
472 }
473
474 /**
475 * Accepts an IPv4 address of the form xxx.xxx.xxx.xxx, ie 192.168.0.1 and
476 * returns the corresponding byte array.
Ray Milkey269ffb92014-04-03 14:43:30 -0700477 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800478 * @param ipAddress The IP address in the form xx.xxx.xxx.xxx.
479 * @return The IP address separated into bytes
480 */
481 public static byte[] toIPv4AddressBytes(String ipAddress) {
482 String[] octets = ipAddress.split("\\.");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700483 if (octets.length != 4) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800484 throw new IllegalArgumentException("Specified IPv4 address must" +
Ray Milkey269ffb92014-04-03 14:43:30 -0700485 "contain 4 sets of numerical digits separated by periods");
Ray Milkeyb29e6262014-04-09 16:02:14 -0700486 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800487
488 byte[] result = new byte[4];
489 for (int i = 0; i < 4; ++i) {
490 result[i] = Integer.valueOf(octets[i]).byteValue();
491 }
492 return result;
493 }
Ray Milkey269ffb92014-04-03 14:43:30 -0700494
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800495 /**
496 * Accepts an IPv4 address in the form of an integer and
497 * returns the corresponding byte array.
Ray Milkey269ffb92014-04-03 14:43:30 -0700498 *
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800499 * @param ipAddress The IP address as an integer.
500 * @return The IP address separated into bytes.
501 */
502 public static byte[] toIPv4AddressBytes(int ipAddress) {
Ray Milkey269ffb92014-04-03 14:43:30 -0700503 return new byte[]{
504 (byte) (ipAddress >>> 24),
505 (byte) (ipAddress >>> 16),
506 (byte) (ipAddress >>> 8),
507 (byte) ipAddress};
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800508 }
509
510 /* (non-Javadoc)
511 * @see java.lang.Object#hashCode()
512 */
513 @Override
514 public int hashCode() {
515 final int prime = 2521;
516 int result = super.hashCode();
517 result = prime * result + checksum;
518 result = prime * result + destinationAddress;
519 result = prime * result + diffServ;
520 result = prime * result + flags;
521 result = prime * result + fragmentOffset;
522 result = prime * result + headerLength;
523 result = prime * result + identification;
524 result = prime * result + Arrays.hashCode(options);
525 result = prime * result + protocol;
526 result = prime * result + sourceAddress;
527 result = prime * result + totalLength;
528 result = prime * result + ttl;
529 result = prime * result + version;
530 return result;
531 }
532
533 /* (non-Javadoc)
534 * @see java.lang.Object#equals(java.lang.Object)
535 */
536 @Override
537 public boolean equals(Object obj) {
Ray Milkeyb29e6262014-04-09 16:02:14 -0700538 if (this == obj) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800539 return true;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700540 }
541 if (!super.equals(obj)) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800542 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700543 }
544 if (!(obj instanceof IPv4)) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800545 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700546 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800547 IPv4 other = (IPv4) obj;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700548 if (checksum != other.checksum) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800549 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700550 }
551 if (destinationAddress != other.destinationAddress) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800552 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700553 }
554 if (diffServ != other.diffServ) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800555 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700556 }
557 if (flags != other.flags) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800558 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700559 }
560 if (fragmentOffset != other.fragmentOffset) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800561 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700562 }
563 if (headerLength != other.headerLength) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800564 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700565 }
566 if (identification != other.identification) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800567 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700568 }
569 if (!Arrays.equals(options, other.options)) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800570 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700571 }
572 if (protocol != other.protocol) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800573 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700574 }
575 if (sourceAddress != other.sourceAddress) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800576 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700577 }
578 if (totalLength != other.totalLength) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800579 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700580 }
581 if (ttl != other.ttl) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800582 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700583 }
584 if (version != other.version) {
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800585 return false;
Ray Milkeyb29e6262014-04-09 16:02:14 -0700586 }
Umesh Krishnaswamy345ee992012-12-13 20:29:48 -0800587 return true;
588 }
589}