Esempio n. 1
0
lagopus_result_t
ofp_header_packet_set(struct channel *channel,
                      struct pbuf *pbuf) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  uint16_t cur_length;
  pbuf_info_t cur_pbuf_info;
  pbuf_info_t update_pbuf_info;
  struct ofp_header header;

  if (channel != NULL && pbuf != NULL) {
    /* Store current pbuf info. */
    pbuf_info_store(pbuf, &cur_pbuf_info);
    ret = pbuf_length_get(pbuf, &cur_length);

    if (ret == LAGOPUS_RESULT_OK) {
      /* Update pbuf info for ofp_header_decode_sneak. */
      pbuf_getp_set(&update_pbuf_info, pbuf_data_get(pbuf));
      pbuf_putp_set(&update_pbuf_info,
                    pbuf_data_get(pbuf) + sizeof(struct ofp_header));
      pbuf_plen_set(&update_pbuf_info, sizeof(struct ofp_header));
      pbuf_info_load(pbuf, &update_pbuf_info);

      ret = ofp_header_decode_sneak(pbuf, &header);
      if (ret == LAGOPUS_RESULT_OK) {
        /* Update pbuf info for ofp_header_create. */
        pbuf_reset(pbuf);
        pbuf_plen_set(pbuf, (size_t) cur_length);

        ret = ofp_header_create(channel, header.type, NULL,
                                &header, pbuf);
        if (ret == LAGOPUS_RESULT_OK) {
          /* Load pbuf info. */
          pbuf_info_load(pbuf, &cur_pbuf_info);
        } else {
          lagopus_msg_warning("FAILED (%s).\n",
                              lagopus_error_get_string(ret));
        }
      } else {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("FAILED (%s).\n",
                          lagopus_error_get_string(ret));
    }
  } else {
    return LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
Esempio n. 2
0
lagopus_result_t
ofp_header_length_set(struct pbuf *pbuf,
                      uint16_t length) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  pbuf_info_t cur_pbuf_info;
  pbuf_info_t update_pbuf_info;
  struct ofp_header header;

  if (pbuf != NULL) {
    /* Store current pbuf info. */
    pbuf_info_store(pbuf, &cur_pbuf_info);

    /* Update pbuf info for ofp_header_decode_sneak. */
    pbuf_getp_set(&update_pbuf_info, pbuf_data_get(pbuf));
    pbuf_putp_set(&update_pbuf_info,
                  pbuf_data_get(pbuf) + sizeof(struct ofp_header));
    pbuf_plen_set(&update_pbuf_info, sizeof(struct ofp_header));
    pbuf_info_load(pbuf, &update_pbuf_info);

    ret = ofp_header_decode_sneak(pbuf, &header);
    if (ret == LAGOPUS_RESULT_OK) {
      /* Set length.*/
      header.length = length;
      /* Update pbuf info for ofp_header_encode. */
      pbuf_reset(pbuf);
      pbuf_plen_set(pbuf, sizeof(struct ofp_header));

      ret = ofp_header_encode(pbuf, &header);
      if (ret == LAGOPUS_RESULT_OK) {
        /* Load pbuf info. */
        pbuf_info_load(pbuf, &cur_pbuf_info);
      } else {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("FAILED (%s).\n",
                          lagopus_error_get_string(ret));
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
STATIC lagopus_result_t
ofp_role_reply_create(struct channel *channel,
                      struct pbuf **pbuf,
                      struct ofp_header *xid_header,
                      struct ofp_role_request *role_request) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  /* reply is ofp_role_request structure. */
  struct ofp_role_request role_reply;

  /* check params */
  if (channel != NULL && pbuf != NULL &&
      xid_header != NULL && role_request != NULL) {
    /* alloc */
    *pbuf = channel_pbuf_list_get(channel,
                                  sizeof(struct ofp_role_request));
    if (*pbuf != NULL) {
      pbuf_plen_set(*pbuf, sizeof(struct ofp_role_request));

      /* Fill in header. */
      ofp_header_set(&role_reply.header,
                     channel_version_get(channel),
                     OFPT_ROLE_REPLY,
                     (uint16_t) pbuf_plen_get(*pbuf),
                     xid_header->xid);

      role_reply.role = role_request->role;
      memset(role_reply.pad, 0, sizeof(role_request->pad));
      role_reply.generation_id = role_request->generation_id;

      /* Encode message. */
      ret = ofp_role_request_encode(*pbuf, &role_reply);
      if (ret != LAGOPUS_RESULT_OK) {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }

      if (ret != LAGOPUS_RESULT_OK && *pbuf != NULL) {
        channel_pbuf_list_unget(channel, *pbuf);
        *pbuf = NULL;
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
Esempio n. 4
0
STATIC lagopus_result_t
ofp_get_async_reply_create(struct channel *channel,
                           struct pbuf **pbuf,
                           struct ofp_header *xid_header) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  struct ofp_async_config async_config;

  /* check params */
  if (channel != NULL && pbuf != NULL &&
      xid_header != NULL) {
    /* alloc */
    *pbuf = channel_pbuf_list_get(channel,
                                  sizeof(struct ofp_async_config));
    if (*pbuf != NULL) {
      pbuf_plen_set(*pbuf, sizeof(struct ofp_async_config));

      /* Copy packet_in_mask, port_status_mask, flow_removed_mask. */
      channel_role_mask_get(channel, &async_config);

      /* Fill in header. */
      ofp_header_set(&async_config.header,
                     channel_version_get(channel),
                     OFPT_GET_ASYNC_REPLY,
                     (uint16_t) pbuf_plen_get(*pbuf),
                     xid_header->xid);

      /* Encode message. */
      ret = ofp_async_config_encode(*pbuf, &async_config);

      if (ret != LAGOPUS_RESULT_OK) {
        lagopus_msg_warning("FAILED : ofp_async_config_encode (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }

    if (ret != LAGOPUS_RESULT_OK &&  *pbuf != NULL) {
      channel_pbuf_list_unget(channel, *pbuf);
      *pbuf = NULL;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
Esempio n. 5
0
/* Send switch features reply. */
STATIC lagopus_result_t
ofp_features_reply_create(struct channel *channel,
                          struct pbuf **pbuf,
                          struct ofp_header *xid_header) {
  struct ofp_switch_features features;
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  if (channel != NULL && pbuf != NULL && xid_header != NULL) {
    /* alloc */
    *pbuf = channel_pbuf_list_get(channel,
                                  sizeof(struct ofp_switch_features));
    if (*pbuf != NULL) {
      pbuf_plen_set(*pbuf, sizeof(struct ofp_switch_features));

      ret = features_reply_features_get(channel, &features);
      if (ret == LAGOPUS_RESULT_OK) {
        /* Fill in header. */
        ofp_header_set(&features.header, channel_version_get(channel),
                       OFPT_FEATURES_REPLY, (uint16_t) pbuf_plen_get(*pbuf),
                       xid_header->xid);

        /* Encode message. */
        ret = ofp_switch_features_encode(*pbuf, &features);
        if (ret != LAGOPUS_RESULT_OK) {
          lagopus_msg_warning("FAILED (%s).\n",
                              lagopus_error_get_string(ret));
        }
      } else {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }

    if (ret != LAGOPUS_RESULT_OK && *pbuf != NULL) {
      channel_pbuf_list_unget(channel, *pbuf);
      *pbuf = NULL;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
/* Send experimenter reply. */
STATIC lagopus_result_t
ofp_experimenter_reply_create(struct channel *channel,
                              struct pbuf **pbuf,
                              struct ofp_header *xid_header,
                              struct ofp_experimenter_header *exper_req) {
  struct ofp_experimenter_header exper_reply;
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  if (channel != NULL && pbuf != NULL &&
      xid_header != NULL && exper_req != NULL) {
    *pbuf = NULL;
    /* alloc */
    *pbuf = channel_pbuf_list_get(channel,
                                  sizeof(struct ofp_experimenter_header));
    if (*pbuf != NULL) {
      pbuf_plen_set(*pbuf, sizeof(struct ofp_experimenter_header));

      exper_reply.experimenter = exper_req->experimenter;
      exper_reply.exp_type = exper_req->exp_type;

      /* Fill in header. */
      ofp_header_set(&exper_reply.header, channel_version_get(channel),
                     OFPT_EXPERIMENTER, (uint16_t) pbuf_plen_get(*pbuf),
                     xid_header->xid);

      /* Encode message. */
      ret = ofp_experimenter_header_encode(*pbuf, &exper_reply);
      if (ret != LAGOPUS_RESULT_OK) {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }

    if (ret != LAGOPUS_RESULT_OK && *pbuf != NULL) {
      channel_pbuf_list_unget(channel, *pbuf);
      *pbuf = NULL;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
Esempio n. 7
0
STATIC lagopus_result_t
ofp_port_status_create(struct port_status *port_status,
                       struct pbuf **pbuf) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  uint8_t tmp_version = 0x00;
  uint32_t tmp_xid = 0;

  if (port_status != NULL && pbuf != NULL) {
    /* alloc */
    *pbuf = pbuf_alloc(sizeof(struct ofp_port_status));
    if (pbuf != NULL) {
      pbuf_plen_set(*pbuf, sizeof(struct ofp_port_status));

      /* Fill in header. */
      /* tmp_* is replaced later. */
      ofp_header_set(&port_status->ofp_port_status.header,
                     tmp_version,
                     OFPT_PORT_STATUS,
                     sizeof(struct ofp_port_status),
                     tmp_xid);

      ret = ofp_port_status_encode(*pbuf, &port_status->ofp_port_status);
      if (ret != LAGOPUS_RESULT_OK) {
        lagopus_msg_warning("FAILED : ofp_port_status_encode (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }

    /* free. */
    if (ret != LAGOPUS_RESULT_OK && *pbuf != NULL) {
      pbuf_free(*pbuf);
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
/* SEND */
STATIC lagopus_result_t
ofp_packet_in_create(struct packet_in *packet_in,
                     struct pbuf **pbuf) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  uint16_t miss_send_len;
  uint16_t length = 0;
  uint16_t remain_length = 0;
  uint16_t match_total_len = 0;
  uint8_t tmp_version = 0x00;
  uint32_t tmp_xid = 0x00;
  uint16_t tmp_length = 0;

  if (packet_in != NULL && packet_in->data != NULL &&
      pbuf != NULL) {

    /* alloc */
    *pbuf = pbuf_alloc(OFP_PACKET_MAX_SIZE);

    if (*pbuf != NULL) {
      pbuf_plen_set(*pbuf, OFP_PACKET_MAX_SIZE);

      /* set total_len. */
      ret = pbuf_length_get(packet_in->data, &length);
      if (ret == LAGOPUS_RESULT_OK) {
        packet_in->ofp_packet_in.total_len = length;

        /* Fill in header. */
        /* tmp_* is replaced later. */
        ofp_header_set(&packet_in->ofp_packet_in.header, tmp_version,
                       OFPT_PACKET_IN, tmp_length, tmp_xid);

        ret = ofp_packet_in_encode(*pbuf, &packet_in->ofp_packet_in);

        if (ret == LAGOPUS_RESULT_OK) {
          ret = ofp_match_list_encode(NULL, *pbuf, &packet_in->match_list,
                                      &match_total_len);

          if (ret == LAGOPUS_RESULT_OK) {
            /* Cut packet. */
            remain_length = (uint16_t) pbuf_plen_get(*pbuf);
            if (packet_in->ofp_packet_in.buffer_id == OFP_NO_BUFFER) {
              miss_send_len = remain_length;
            } else {
              miss_send_len = packet_in->miss_send_len;
            }
            if (length < miss_send_len) {
              miss_send_len = length;
            }

            /* exist data */
            if (miss_send_len != 0) {
              /* add padding */
              ret = ofp_padding_add(*pbuf, OFP_PACKET_IN_PAD);

              if (ret == LAGOPUS_RESULT_OK) {
                /* Cut packet. (remain_length) */
                if (miss_send_len + OFP_PACKET_IN_PAD > remain_length) {
                  miss_send_len = remain_length;
                }

                if (pbuf_plen_check(*pbuf, miss_send_len) !=
                    LAGOPUS_RESULT_OK) {
                  lagopus_msg_warning("FAILED : over data length.\n");
                  ret = LAGOPUS_RESULT_OUT_OF_RANGE;
                } else {
                  /* copy data. */
                  ret = pbuf_copy_with_length(*pbuf, packet_in->data,
                                              miss_send_len);
                  if (ret == LAGOPUS_RESULT_OK) {
                    pbuf_plen_reset(*pbuf);
                  } else {
                    lagopus_msg_warning("FAILED (%s).\n",
                                        lagopus_error_get_string(ret));
                  }
                }
              } else {
                lagopus_msg_warning("FAILED : over padding length.\n");
              }
            } else {
              ret = LAGOPUS_RESULT_OK;
            }
          } else {
            lagopus_msg_warning("FAILED (%s).\n",
                                lagopus_error_get_string(ret));
          }
        } else {
          lagopus_msg_warning("FAILED (%s).\n",
                              lagopus_error_get_string(ret));
        }
      } else {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }

    /* free. */
    if (ret != LAGOPUS_RESULT_OK && *pbuf != NULL) {
      pbuf_free(*pbuf);
      *pbuf = NULL;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
Esempio n. 9
0
lagopus_result_t
ofp_header_mp_copy(struct pbuf *dst_pbuf,
                   struct pbuf *src_pbuf) {
  struct ofp_multipart_reply mp_reply;
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  pbuf_info_t cur_src_pbuf_info;
  pbuf_info_t cur_dst_pbuf_info;
  pbuf_info_t update_pbuf_info;
  uint16_t cur_src_length = 0;

  if (dst_pbuf != NULL && src_pbuf != NULL) {
    /* Store current dst/src_pbuf info. */
    pbuf_info_store(dst_pbuf, &cur_dst_pbuf_info);
    pbuf_info_store(src_pbuf, &cur_src_pbuf_info);
    ret = pbuf_length_get(src_pbuf, &cur_src_length);

    if (ret == LAGOPUS_RESULT_OK) {
      /* Update src_pbuf info for ofp_multipart_reply_decode. */
      pbuf_getp_set(&update_pbuf_info, pbuf_data_get(src_pbuf));
      pbuf_putp_set(&update_pbuf_info,
                    pbuf_data_get(src_pbuf) + sizeof(struct ofp_multipart_reply));
      pbuf_plen_set(&update_pbuf_info, sizeof(struct ofp_multipart_reply));
      pbuf_info_load(src_pbuf, &update_pbuf_info);

      ret = ofp_multipart_reply_decode(src_pbuf, &mp_reply);

      if (ret == LAGOPUS_RESULT_OK) {
        /* Set length/flag in src_pbuf. */
        mp_reply.header.length = cur_src_length;
        mp_reply.flags = OFPMPF_REPLY_MORE;
        /* Update src_pbuf info for ofp_multipart_reply_encode. */
        pbuf_reset(src_pbuf);
        pbuf_plen_set(src_pbuf, sizeof(struct ofp_multipart_reply));

        ret = ofp_multipart_reply_encode(src_pbuf, &mp_reply);

        if (ret == LAGOPUS_RESULT_OK) {
          /* Set length/flag in dst_pbuf. */
          mp_reply.header.length = sizeof(struct ofp_multipart_reply);
          mp_reply.flags = 0;
          /* Update dst_pbuf info for ofp_multipart_reply_encode. */
          pbuf_reset(dst_pbuf);
          pbuf_plen_set(dst_pbuf, pbuf_plen_get(&cur_dst_pbuf_info));

          ret = ofp_multipart_reply_encode(dst_pbuf, &mp_reply);
          if (ret == LAGOPUS_RESULT_OK) {
            /* Load pbuf info. */
            pbuf_info_load(src_pbuf, &cur_src_pbuf_info);
          } else {
            lagopus_msg_warning("FAILED (%s).\n",
                                lagopus_error_get_string(ret));
          }
        } else {
          lagopus_msg_warning("FAILED (%s).\n",
                              lagopus_error_get_string(ret));
        }
      } else {
        lagopus_msg_warning("FAILED (%s).\n",
                            lagopus_error_get_string(ret));
      }
    } else {
      lagopus_msg_warning("FAILED (%s).\n",
                          lagopus_error_get_string(ret));
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
/* Send experimenter multipart reply. */
STATIC lagopus_result_t
ofp_experimenter_mp_reply_create(
  struct channel *channel,
  struct pbuf_list **pbuf_list,
  struct ofp_header *xid_header,
  struct ofp_experimenter_multipart_header *exper_req) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  uint16_t tmp_length = 0;
  uint16_t length = 0;
  struct ofp_multipart_reply mp_reply;
  struct pbuf *pbuf = NULL;
  struct ofp_experimenter_multipart_header exper_reply;

  if (channel != NULL && pbuf_list != NULL &&
      xid_header != NULL && exper_req != NULL) {

    /* alloc */
    *pbuf_list = pbuf_list_alloc();

    if (*pbuf_list != NULL) {
      pbuf = pbuf_list_last_get(*pbuf_list);

      if (pbuf != NULL) {
        pbuf_plen_set(pbuf, pbuf_size_get(pbuf));

        /* Fill in header. */
        memset(&mp_reply, 0, sizeof(mp_reply));
        ofp_header_set(&mp_reply.header, channel_version_get(channel),
                       OFPT_MULTIPART_REPLY, tmp_length, xid_header->xid);

        mp_reply.type = OFPMP_EXPERIMENTER;
        mp_reply.flags = 0;

        /* Encode multipart reply. */
        ret = ofp_multipart_reply_encode(pbuf, &mp_reply);

        if (ret == LAGOPUS_RESULT_OK) {
          exper_reply.experimenter = exper_req->experimenter;
          exper_reply.exp_type = exper_req->exp_type;

          /* Encode message. */
          ret = ofp_experimenter_multipart_header_encode(
                  pbuf,
                  &exper_reply);

          if (ret == LAGOPUS_RESULT_OK) {
            /* set length for last pbuf. */
            ret = pbuf_length_get(pbuf, &length);
            if (ret == LAGOPUS_RESULT_OK) {
              ret = ofp_header_length_set(pbuf, length);
              if (ret == LAGOPUS_RESULT_OK) {
                pbuf_plen_reset(pbuf);
                ret = LAGOPUS_RESULT_OK;
              } else {
                lagopus_msg_warning("FAILED (%s).\n",
                                    lagopus_error_get_string(ret));
              }
            } else {
              lagopus_msg_warning("FAILED (%s).\n",
                                  lagopus_error_get_string(ret));
            }
          } else {
            lagopus_msg_warning("FAILED (%s).\n",
                                lagopus_error_get_string(ret));
          }
        } else {
          lagopus_msg_warning("FAILED (%s).\n",
                              lagopus_error_get_string(ret));
        }
      } else {
        lagopus_msg_warning("Can't allocate pbuf.\n");
        ret = LAGOPUS_RESULT_NO_MEMORY;
      }
    } else {
      lagopus_msg_warning("Can't allocate pbuf_list.\n");
      ret = LAGOPUS_RESULT_NO_MEMORY;
    }

    if (ret != LAGOPUS_RESULT_OK && *pbuf_list != NULL) {
      pbuf_list_free(*pbuf_list);
      *pbuf_list = NULL;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
STATIC lagopus_result_t
ofp_meter_features_reply_create(struct channel *channel,
                                struct pbuf_list **pbuf_list,
                                struct ofp_meter_features *ofp_meter_features,
                                struct ofp_header *xid_header) {
  lagopus_result_t res = LAGOPUS_RESULT_ANY_FAILURES;
  uint16_t length = 0;
  struct pbuf *pbuf = NULL;
  struct ofp_multipart_reply ofpmp_reply;

  /* check params */
  if (channel              != NULL &&
      pbuf_list            != NULL &&
      ofp_meter_features   != NULL &&
      xid_header           != NULL) {
    /* alloc */
    *pbuf_list = NULL;
    *pbuf_list = pbuf_list_alloc();
    if (*pbuf_list != NULL) {
      /* alloc&get tail of pbuf_list */
      pbuf = pbuf_list_last_get(*pbuf_list);
      if (pbuf != NULL) {
        /* set data. */
        memset(&ofpmp_reply, 0, sizeof(ofpmp_reply));
        ofp_header_set(&ofpmp_reply.header,
                       channel_version_get(channel),
                       OFPT_MULTIPART_REPLY,
                       0, /* length set in ofp_header_length_set()  */
                       xid_header->xid);
        ofpmp_reply.type = OFPMP_METER_FEATURES;

        /* encode message. */
        pbuf_plen_set(pbuf, pbuf_size_get(pbuf));
        res = ofp_multipart_reply_encode_list(*pbuf_list, &pbuf, &ofpmp_reply);
        if (res == LAGOPUS_RESULT_OK) {
          res = ofp_meter_features_encode_list(*pbuf_list, &pbuf, ofp_meter_features);
          if (res == LAGOPUS_RESULT_OK) {
            /* set packet length */
            res = pbuf_length_get(pbuf, &length);
            if (res == LAGOPUS_RESULT_OK) {
              res = ofp_header_length_set(pbuf, length);
              if (res == LAGOPUS_RESULT_OK) {
                pbuf_plen_reset(pbuf);
              } else {
                lagopus_msg_warning("FAILED (%s).\n",
                                    lagopus_error_get_string(res));
              }
            } else {
              lagopus_msg_warning("FAILED (%s).\n",
                                  lagopus_error_get_string(res));
            }
          } else {
            lagopus_msg_warning("FAILED (%s).\n",
                                lagopus_error_get_string(res));
          }
        } else {
          lagopus_msg_warning("FAILED (%s).\n",
                              lagopus_error_get_string(res));
        }
      } else {
        res = LAGOPUS_RESULT_NO_MEMORY;
      }
    } else {
      res = LAGOPUS_RESULT_NO_MEMORY;
    }
  } else {
    res = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return res;
}