Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | |
| 16 | #include <vnet/dpo/dpo.h> |
| 17 | #include <vnet/lisp-gpe/lisp_gpe.h> |
| 18 | #include <vnet/lisp-cp/control.h> |
| 19 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 20 | /** |
| 21 | * The static array of LISP punt DPOs |
| 22 | */ |
| 23 | static dpo_id_t lisp_cp_dpos[DPO_PROTO_NUM]; |
| 24 | |
| 25 | const dpo_id_t * |
| 26 | lisp_cp_dpo_get (dpo_proto_t proto) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 27 | { |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 28 | /* |
| 29 | * there are only two instances of this DPO type. |
| 30 | * we can use the protocol as the index |
| 31 | */ |
| 32 | return (&lisp_cp_dpos[proto]); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 33 | } |
| 34 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 35 | static u8 * |
| 36 | format_lisp_cp_dpo (u8 * s, va_list * args) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 37 | { |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 38 | index_t index = va_arg (*args, index_t); |
| 39 | CLIB_UNUSED (u32 indent) = va_arg (*args, u32); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 40 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 41 | return (format (s, "lisp-cp-punt-%U", format_dpo_proto, index)); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | static void |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 45 | lisp_cp_dpo_lock (dpo_id_t * dpo) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | |
| 49 | static void |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 50 | lisp_cp_dpo_unlock (dpo_id_t * dpo) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 51 | { |
| 52 | } |
| 53 | |
| 54 | const static dpo_vft_t lisp_cp_vft = { |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 55 | .dv_lock = lisp_cp_dpo_lock, |
| 56 | .dv_unlock = lisp_cp_dpo_unlock, |
| 57 | .dv_format = format_lisp_cp_dpo, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | /** |
| 61 | * @brief The per-protocol VLIB graph nodes that are assigned to a LISP-CP |
| 62 | * object. |
| 63 | * |
| 64 | * this means that these graph nodes are ones from which a LISP-CP is the |
| 65 | * parent object in the DPO-graph. |
| 66 | */ |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 67 | const static char *const lisp_cp_ip4_nodes[] = { |
| 68 | "lisp-cp-lookup-ip4", |
| 69 | NULL, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 72 | const static char *const lisp_cp_ip6_nodes[] = { |
| 73 | "lisp-cp-lookup-ip6", |
| 74 | NULL, |
| 75 | }; |
| 76 | |
| 77 | const static char *const lisp_cp_ethernet_nodes[] = { |
| 78 | "lisp-cp-lookup-l2", |
| 79 | NULL, |
| 80 | }; |
| 81 | |
| 82 | |
| 83 | const static char *const *const lisp_cp_nodes[DPO_PROTO_NUM] = { |
| 84 | [DPO_PROTO_IP4] = lisp_cp_ip4_nodes, |
| 85 | [DPO_PROTO_IP6] = lisp_cp_ip6_nodes, |
| 86 | [DPO_PROTO_ETHERNET] = lisp_cp_ethernet_nodes, |
| 87 | [DPO_PROTO_MPLS] = NULL, |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | clib_error_t * |
| 91 | lisp_cp_dpo_module_init (vlib_main_t * vm) |
| 92 | { |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 93 | dpo_proto_t dproto; |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 94 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 95 | /* |
| 96 | * there are no exit arcs from the LIS-CP VLIB node, so we |
| 97 | * pass NULL as said node array. |
| 98 | */ |
| 99 | dpo_register (DPO_LISP_CP, &lisp_cp_vft, lisp_cp_nodes); |
| 100 | |
| 101 | FOR_EACH_DPO_PROTO (dproto) |
| 102 | { |
| 103 | dpo_set (&lisp_cp_dpos[dproto], DPO_LISP_CP, dproto, dproto); |
| 104 | } |
| 105 | |
| 106 | return (NULL); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 107 | } |
| 108 | |
Neale Ranns | 5e575b1 | 2016-10-03 09:40:25 +0100 | [diff] [blame] | 109 | VLIB_INIT_FUNCTION (lisp_cp_dpo_module_init); |
| 110 | |
| 111 | /* |
| 112 | * fd.io coding-style-patch-verification: ON |
| 113 | * |
| 114 | * Local Variables: |
| 115 | * eval: (c-set-style "gnu") |
| 116 | * End: |
| 117 | */ |