blob: 3f74a08c7f0b9246869ebe263e5efe900a1031c0 [file] [log] [blame]
Jonathan Hart382623d2014-04-03 09:48:11 -07001package net.onrc.onos.apps.bgproute;
Jonathan Harte963a332013-07-26 15:56:20 +12002
Jonathan Hart31e15f12014-04-10 10:33:00 -07003/**
4 * Represents a route update received from BGPd. An update has an operation
5 * describing whether the update is adding a route or revoking a route. It also
6 * contains the route prefix, and {@link RibEntry} containing next hop and
7 * sequence number information for the update.
8 */
Jonathan Harte963a332013-07-26 15:56:20 +12009public class RibUpdate {
Jonathan Hart738980f2014-04-04 10:11:15 -070010 private final Operation operation;
11 private final Prefix prefix;
12 private final RibEntry ribEntry;
Ray Milkey5d406012014-04-08 14:44:41 -070013
Jonathan Hart31e15f12014-04-10 10:33:00 -070014 /**
15 * Updates can either add new routes or revoke old routes. The
16 * {@link Operation} enum descibes which action is being taken.
17 */
Ray Milkey269ffb92014-04-03 14:43:30 -070018 public enum Operation {
Jonathan Hart31e15f12014-04-10 10:33:00 -070019 /**
20 * Represents a route update. ONOS should update its route information
21 * for this prefix to the new information provided in this
22 * {@link RibUpdate}. This means either add a new prefix, or update
23 * the information for an existing prefix.
24 */
Ray Milkey269ffb92014-04-03 14:43:30 -070025 UPDATE,
Jonathan Hart31e15f12014-04-10 10:33:00 -070026 /**
27 * Represents a route delete. ONOS should remove this prefix and route
28 * information from its route table.
29 */
Ray Milkey269ffb92014-04-03 14:43:30 -070030 DELETE
31 }
Jonathan Harte963a332013-07-26 15:56:20 +120032
Jonathan Hart31e15f12014-04-10 10:33:00 -070033 /**
34 * Class constructor, taking the operation of the update, the route prefix
35 * and the {@link RibEntry} describing the update.
36 *
37 * @param operation the operation of the update
38 * @param prefix the route prefix
39 * @param ribEntry the update entry
40 */
Ray Milkey269ffb92014-04-03 14:43:30 -070041 public RibUpdate(Operation operation, Prefix prefix, RibEntry ribEntry) {
42 this.operation = operation;
43 this.prefix = prefix;
44 this.ribEntry = ribEntry;
45 }
Jonathan Harte963a332013-07-26 15:56:20 +120046
Jonathan Hart31e15f12014-04-10 10:33:00 -070047 /**
48 * Gets the operation of the update.
49 *
50 * @return the operation
51 */
Ray Milkey269ffb92014-04-03 14:43:30 -070052 public Operation getOperation() {
53 return operation;
54 }
55
Jonathan Hart31e15f12014-04-10 10:33:00 -070056 /**
57 * Gets the route prefix of the update.
58 *
59 * @return the prefix
60 */
Ray Milkey269ffb92014-04-03 14:43:30 -070061 public Prefix getPrefix() {
62 return prefix;
63 }
64
Jonathan Hart31e15f12014-04-10 10:33:00 -070065 /**
66 * Gets the {@link RibEntry} of the update.
67 *
68 * @return the entry
69 */
Ray Milkey269ffb92014-04-03 14:43:30 -070070 public RibEntry getRibEntry() {
71 return ribEntry;
72 }
Jonathan Harte963a332013-07-26 15:56:20 +120073}