summaryrefslogtreecommitdiffstats
path: root/src/vnet/mcast/mcast_test.c
blob: be80c9fc982d20e3a89216e4a4ba62da4b59ac81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include <vnet/mcast/mcast.h>

#include <vlib/vlib.h>
#include <vnet/vnet.h>
#include <vnet/pg/pg.h>
#include <vppinfra/error.h>
#include <vnet/ip/lookup.h>
#include <vnet/ip/ip4_packet.h>
#include <vnet/ip/icmp46_packet.h>
#include <vnet/ip/ip4.h>
#include <vnet/mcast/mcast.h>

typedef struct {
  /* convenience */
  vlib_main_t * vlib_main;
  vnet_main_t * vnet_main;
  mcast_main_t * mcast_main;
} mcast_test_main_t;

mcast_test_main_t mcast_test_main;
vlib_node_registration_t mcast_prep_node;
vlib_node_registration_t mcast_recycle_node;

static clib_error_t *
mcast_test_command_fn (vlib_main_t * vm,
		 unformat_input_t * input,
		 vlib_cli_command_t * cmd)
{
  /* u8 *rewrite_data; */
  /* mcast_test_main_t * mtm = &mcast_test_main; */
  /* mcast_main_t * mcm = mtm->mcast_main; */
  /* ip_adjacency_t adj; */
  /* u32 adj_index; */
  /* mcast_group_t * g; */
  /* mcast_group_member_t * member; */
  /* unformat_input_t _line_input, * line_input = &_line_input; */
  /* ip4_address_t dst_addr, zero; */
  /* ip4_main_t * im = &ip4_main; */
  /* ip_lookup_main_t * lm = &im->lookup_main; */

  /* /\* Get a line of input. *\/ */
  /* if (! unformat_user (input, unformat_line_input, line_input)) */
  /*   return 0; */

  /* pool_get (mcm->groups, g); */
  /* memset (g, 0, sizeof (*g)); */

  /* while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) */
  /*   { */
  /*     vnet_hw_interface_t *hw; */
  /*     u32 next, sw_if_index; */

  /*     if (unformat (line_input, "%U", unformat_vnet_sw_interface,  */
  /*                   mtm->vnet_main, &sw_if_index))  */
  /*       { */
  /*         vec_add2 (g->members, member, 1); */
  /*         member->tx_sw_if_index = sw_if_index; */
          
  /*         hw = vnet_get_sup_hw_interface (mtm->vnet_main,  */
  /*                                         sw_if_index); */
          
  /*         next = vlib_node_add_next (mtm->vlib_main,  */
  /*                                    mcast_prep_node.index, */
  /*                                    hw->output_node_index); */
          
  /*         /\* Required to be the same next index... *\/ */
  /*         vlib_node_add_next_with_slot (mtm->vlib_main, */
  /*                                       mcast_recycle_node.index, */
  /*                                       hw->output_node_index, next); */
  /*         member->prep_and_recycle_node_next_index = next; */
  /*       } */
  /*     else */
  /*       { */
  /*         return unformat_parse_error (line_input); */
  /*       } */
  /*   } */

  /* if (vec_len (g->members) == 0) */
  /*   { */
  /*     pool_put (mcm->groups, g); */
  /*     vlib_cli_output (vm, "no group members specified"); */
  /*     return 0; */
  /*   } */


  /* adj.lookup_next_index = IP_LOOKUP_NEXT_REWRITE; */
  /* adj.mcast_group_index = g - mcm->groups; */
  /* rewrite_data = format (0, "abcdefg"); */

  /* vnet_rewrite_for_tunnel */
  /*   (mtm->vnet_main, */
  /*    (u32)~0, /\* tx_sw_if_index, we dont know yet *\/ */
  /*    ip4_rewrite_node.index, */
  /*    mcast_prep_node.index, */
  /*    &adj.rewrite_header, */
  /*    rewrite_data, vec_len(rewrite_data)); */

  /* ip_add_adjacency (lm, &adj, 1 /\* one adj *\/, */
  /*                   &adj_index); */
  
  /* dst_addr.as_u32 = clib_host_to_net_u32 (0x0a000002); */
  /* zero.as_u32 = 0; */

  /* ip4_add_del_route_next_hop (im, */
  /*                             IP4_ROUTE_FLAG_ADD, */
  /*                             &dst_addr, */
  /*                             24 /\* mask width *\/, */
  /*                             &zero /\* no next hop *\/, */
                          
  /*                             0, // next hop sw if index */
  /*                             1, // weight */
  /*                             adj_index, */
  /*                             0 /\* explicit fib 0 *\/); */

  return 0;
}

static VLIB_CLI_COMMAND (mcast_test_command) = {
  .path = "test mc",
  .short_help = "test mc",
  .function = mcast_test_command_fn,
};

clib_error_t *mcast_test_init (vlib_main_t *vm)
{
  mcast_test_main_t * mtm = &mcast_test_main;
    
  mtm->vlib_main = vm;
  mtm->vnet_main = vnet_get_main();
  mtm->mcast_main = &mcast_main;

  return 0;
}

VLIB_INIT_FUNCTION (mcast_test_init);