/*
 * Copyright (c) 2020 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.
 */

option version="0.0.0";
import "vnet/ip/ip_types.api";
import "vnet/interface_types.api";

autoreply define test_prefix {
  vl_api_prefix_t pref;
};

enumflag test_enumflags {
  RED = 0x1,
  BLUE = 0x2,
  GREEN = 0x4,
};

autoreply define test_enum {
  vl_api_test_enumflags_t flags;
};

typedef test_stringtype {
  string str[];
};

autoreply define test_string {
  vl_api_test_stringtype_t str;
};

autoreply define test_string2 {
  string str[];
};

/* Test of toplevel VLA with basetype */
autoreply define test_vla {
  u32 count;
  u32 vla[count];
};

/* Test of toplevel VLA with u8 */
autoreply define test_vla2 {
  u32 count;
  u8 vla[count];
};
/* Test of toplevel VLA with user type */
typedef test_vlatype {
  u32 data;
};
autoreply define test_vla3 {
  u32 count;
  vl_api_test_vlatype_t vla[count];
};
/* Test of typedefed VLA */
typedef test_vlatype2 {
  u32 count;
  u32 vla[count];
};
autoreply define test_vla4 {
  vl_api_test_vlatype2_t data;
};
/* u8 string in typedef */
typedef test_vlatype3 {
  u32 count;
  u8 vla[count];
};
autoreply define test_vla5 {
  vl_api_test_vlatype3_t data;
};

/* Addresses */
autoreply define test_addresses {
  vl_api_address_t a;
};
autoreply define test_addresses2 {
  vl_api_address_t a[2];
};
autoreply define test_addresses3 {
  u32 n;
  vl_api_address_t a[n];
};

/* Empty */
autoreply define test_empty {
  u32 client_index;
  u32 context;
};

/* Interface */
autoreply define test_interface {
  vl_api_interface_index_t sw_if_index;
};
