void
test_ofp_meter_stats_reply_create_band_stats_list_empty(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  const char *data[1] = {"04 13 00 60 00 00 00 10"
                         "00 09 00 00 00 00 00 00"

                         "00 00 00 01 00 28 00 00"
                         "00 00 00 00 00 00 00 02"
                         "00 00 00 00 00 00 00 03"
                         "00 00 00 00 00 00 00 04"
                         "00 00 00 05 00 00 00 06"

                         "00 00 00 02 00 28 00 00"
                         "00 00 00 00 00 00 00 03"
                         "00 00 00 00 00 00 00 04"
                         "00 00 00 00 00 00 00 05"
                         "00 00 00 06 00 00 00 07"
                        };

  meter_stats_length = 0x28;
  meter_stats_num = 2;
  band_stats_num = 0;

  ret = check_pbuf_list_packet_create(ofp_meter_stats_reply_create_wrap,
                                      data, 1);

  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "ofp_meter_stats_reply_create(normal) error.");
}
Example #2
0
void
test_ofp_group_stats_reply_create_len_error(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  const char *data[1] = {"04 13 00 a0 00 00 00 10"
                         "00 06 00 00 00 00 00 00"
                         "00 48 00 00 00 00 00 01"
                         "00 00 00 02 00 00 00 00"
                         "00 00 00 00 00 00 00 03"
                         "00 00 00 00 00 00 00 04"
                         "00 00 00 05 00 00 00 06"
                         "00 00 00 00 00 00 00 07"
                         "00 00 00 00 00 00 00 09"
                         "00 00 00 00 00 00 00 08"
                         "00 00 00 00 00 00 00 0a"
                         "00 48 00 00 00 00 00 02"
                         "00 00 00 03 00 00 00 00"
                         "00 00 00 00 00 00 00 04"
                         "00 00 00 00 00 00 00 05"
                         "00 00 00 06 00 00 00 07"
                         "00 00 00 00 00 00 00 08"
                         "00 00 00 00 00 00 00 0a"
                         "00 00 00 00 00 00 00 09"
                         "00 00 00 00 00 00 00 0b"
                        };

  group_stats_num = 2;
  bucket_counter_num = OFP_PACKET_MAX_SIZE;
  ret = check_pbuf_list_packet_create(ofp_group_stats_reply_create_wrap,
                                      data, 1);

  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OUT_OF_RANGE, ret,
                            "ofp_group_stats_reply_create(len error) error.");
}
void
test_ofp_meter_stats_reply_create_null(void) {
  const char *data[1] = {"04 13 00 a0 00 00 00 10"};

  /* Not check return value. */
  (void ) check_pbuf_list_packet_create(ofp_meter_stats_reply_create_null_wrap,
                                        data, 1);
}
void
test_ofp_port_stats_reply_create(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  struct port_stats *port_stats = NULL;
  const char *require[1] = {
    "04 13 00 80 00 00 00 10 "
    "00 04 00 00 00 00 00 00 "
    // body
    "00 00 00 01 "             //  uint32_t port_no;
    "00 00 00 00 "             //  uint8_t pad[4];
    "00 00 00 00 00 00 00 02 " //  uint64_t rx_packets;
    "00 00 00 00 00 00 00 03 " //  uint64_t tx_packets;
    "00 00 00 00 00 00 00 04 " //  uint64_t rx_bytes;
    "00 00 00 00 00 00 00 05 " //  uint64_t tx_bytes;
    "00 00 00 00 00 00 00 06 " //  uint64_t rx_dropped;
    "00 00 00 00 00 00 00 07 " //  uint64_t tx_dropped;
    "00 00 00 00 00 00 00 08 " //  uint64_t rx_errors;
    "00 00 00 00 00 00 00 09 " //  uint64_t tx_errors;
    "00 00 00 00 00 00 00 0a " //  uint64_t rx_frame_err;
    "00 00 00 00 00 00 00 0b " //  uint64_t rx_over_err;
    "00 00 00 00 00 00 00 0c " //  uint64_t rx_crc_err;
    "00 00 00 00 00 00 00 0d " //  uint64_t collisions;
    "00 00 00 0e"              // uint32_t duration_sec;
    "00 00 00 0f"              // uint32_t duration_nsec;
  };

  TAILQ_INIT(&s_port_stats_list);
  if ((port_stats = s_port_stats_alloc()) != NULL) {
    port_stats->ofp.port_no       = 0x01;
    port_stats->ofp.rx_packets    = 0x02;
    port_stats->ofp.tx_packets    = 0x03;
    port_stats->ofp.rx_bytes      = 0x04;
    port_stats->ofp.tx_bytes      = 0x05;
    port_stats->ofp.rx_dropped    = 0x06;
    port_stats->ofp.tx_dropped    = 0x07;
    port_stats->ofp.rx_errors     = 0x08;
    port_stats->ofp.tx_errors     = 0x09;
    port_stats->ofp.rx_frame_err  = 0x0a;
    port_stats->ofp.rx_over_err   = 0x0b;
    port_stats->ofp.rx_crc_err    = 0x0c;
    port_stats->ofp.collisions    = 0x0d;
    port_stats->ofp.duration_sec  = 0x0e;
    port_stats->ofp.duration_nsec = 0x0f;
    TAILQ_INSERT_TAIL(&s_port_stats_list, port_stats, entry);
  } else {
    TEST_FAIL_MESSAGE("allocation error.");
  }

  /* port 0 */
  ret = check_pbuf_list_packet_create(s_ofp_port_reply_create_wrap, require, 1);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "create port 0 error.");

  /* free */
  while ((port_stats = TAILQ_FIRST(&s_port_stats_list)) != NULL) {
    TAILQ_REMOVE(&s_port_stats_list, port_stats, entry);
    free(port_stats);
  }
}
Example #5
0
void
test_ofp_flow_reply_create_01(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  struct flow_stats *flow_stats = NULL;
  struct instruction *instruction = NULL;
  struct match *match = NULL;
  const char *require[1] = {
    "04 13 00 58 00 00 00 10 00 01 00 00 00 00 00 00 "
    "00 48 01 00 00 00 00 02 00 00 00 03 00 04 00 05 "
    "00 06 00 07 00 00 00 00 00 00 00 00 00 00 00 08 "
    "00 00 00 00 00 00 00 09 00 00 00 00 00 00 00 0a "
    "00 01 00 10 00 00 01 08 00 00 00 00 00 00 00 00 "
    "00 01 00 08 00 00 00 00"
  };

  TAILQ_INIT(&s_flow_stats_list);
  if ((flow_stats = s_flow_stats_alloc()) != NULL) {
    /* flow_stats = 48, match = 16, instruction = 8, sum = 72 */
    flow_stats->ofp.length = 48 + 16 + 8;
    flow_stats->ofp.table_id = 0x01;
    flow_stats->ofp.duration_sec = 0x02;
    flow_stats->ofp.duration_nsec = 0x03;
    flow_stats->ofp.priority = 0x04;
    flow_stats->ofp.idle_timeout = 0x05;
    flow_stats->ofp.hard_timeout = 0x06;
    flow_stats->ofp.flags = 0x07;
    flow_stats->ofp.cookie = 0x08;
    flow_stats->ofp.packet_count = 0x09;
    flow_stats->ofp.byte_count = 0x0a;
    if ((match = match_alloc(8)) != NULL) {
      match->oxm_class = 0x00;
      match->oxm_field = 0x01;
      match->oxm_length = 0x08;
      TAILQ_INSERT_TAIL(&(flow_stats->match_list), match, entry);
    }
    if ((instruction = instruction_alloc()) != NULL) {
      instruction->ofpit_goto_table.type = OFPIT_GOTO_TABLE;
      instruction->ofpit_goto_table.len = 0x08; /* action_list empty */
      instruction->ofpit_goto_table.table_id = 0x00;
      TAILQ_INSERT_TAIL(&(flow_stats->instruction_list), instruction, entry);
    }
    TAILQ_INSERT_TAIL(&s_flow_stats_list, flow_stats, entry);
  } else {
    TEST_FAIL_MESSAGE("allocation error.");
  }

  /* port 0 */
  ret = check_pbuf_list_packet_create(s_ofp_flow_reply_create_wrap, require, 1);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "create port 0 error.");

  /* free */
  while ((flow_stats = TAILQ_FIRST(&s_flow_stats_list)) != NULL) {
    TAILQ_REMOVE(&s_flow_stats_list, flow_stats, entry);
    ofp_match_list_elem_free(&flow_stats->match_list);
    ofp_instruction_list_elem_free(&flow_stats->instruction_list);
    free(flow_stats);
  }
}
void
test_ofp_queue_stats_reply_create_null(void) {
  const char *data[1] = {"04 13 00 38 00 00 00 10"
                         "00 05 00 00 00 00 00 00"
                         "00 00 00 01 00 00 00 02"
                         "00 00 00 00 00 00 00 03"
                         "00 00 00 00 00 00 00 04"
                         "00 00 00 00 00 00 00 05"
                         "00 00 00 06 00 00 00 07"
                        };

  /* Uncheck return value. */
  (void) check_pbuf_list_packet_create(ofp_queue_stats_reply_create_null_wrap,
                                       data, 1);
}
Example #7
0
void
test_ofp_table_stats_reply_create_01(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  const char *data[1] = {"04 13 00 28 00 00 00 10 "
                         "00 03 00 00 00 00 00 00 "
                         // body
                         "01 "
                         "00 00 00 "
                         "00 00 00 02 "
                         "00 00 00 00 00 00 00 03 "
                         "00 00 00 00 00 00 00 04 "
                        };

  ret = check_pbuf_list_packet_create(s_ofp_table_stats_reply_create_wrap,
                                      data, 1);
  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret, "create port 0 error.");
}
void
test_ofp_queue_stats_reply_create(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  const char *data[1] = {"04 13 00 38 00 00 00 10"
                         "00 05 00 00 00 00 00 00"
                         "00 00 00 01 00 00 00 02"
                         "00 00 00 00 00 00 00 03"
                         "00 00 00 00 00 00 00 04"
                         "00 00 00 00 00 00 00 05"
                         "00 00 00 06 00 00 00 07"
                        };

  ret = check_pbuf_list_packet_create(ofp_queue_stats_reply_create_wrap,
                                      data, 1);

  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "ofp_queue_stats_reply_create(normal) error.");
}
void
test_ofp_group_desc_reply_create(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  const char *data[1] = {"04 13 00 e0 00 00 00 10"
                         "00 07 00 00 00 00 00 00"

                         "00 68 01 00 00 00 00 01"
                         "00 30 00 02 00 00 00 03"
                         "00 00 00 04 00 00 00 00"
                         "00 00 00 10 00 00 00 05"
                         "00 06 00 00 00 00 00 00"
                         "00 00 00 10 00 00 00 06"
                         "00 07 00 00 00 00 00 00"
                         "00 30 00 03 00 00 00 04"
                         "00 00 00 05 00 00 00 00"
                         "00 00 00 10 00 00 00 05"
                         "00 06 00 00 00 00 00 00"
                         "00 00 00 10 00 00 00 06"
                         "00 07 00 00 00 00 00 00"

                         "00 68 01 00 00 00 00 02"
                         "00 30 00 02 00 00 00 03"
                         "00 00 00 04 00 00 00 00"
                         "00 00 00 10 00 00 00 05"
                         "00 06 00 00 00 00 00 00"
                         "00 00 00 10 00 00 00 06"
                         "00 07 00 00 00 00 00 00"
                         "00 30 00 03 00 00 00 04"
                         "00 00 00 05 00 00 00 00"
                         "00 00 00 10 00 00 00 05"
                         "00 06 00 00 00 00 00 00"
                         "00 00 00 10 00 00 00 06"
                         "00 07 00 00 00 00 00 00"
                        };

  group_desc_num = 2;
  bucket_num = 2;
  action_num = 2;
  ret = check_pbuf_list_packet_create(ofp_group_desc_reply_create_wrap,
                                      data, 1);

  TEST_ASSERT_EQUAL_MESSAGE(LAGOPUS_RESULT_OK, ret,
                            "ofp_group_desc_reply_create(normal) error.");
}