/*
 * 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.
 */

import "vnet/ip/ip_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;
};
