コード例 #1
0
ファイル: ofp_role.c プロジェクト: D-TOKIOKA/lagopus
static lagopus_result_t
ofp_role_write(struct channel *channel, void *val) {
  struct role_write_vars *v = val;

  if (channel_is_alive(channel) == true) {
    /* packet filtering. */
    if (channel_role_channel_check_mask(channel, v->type, v->reason) == true) {
      v->ret = ofp_write_channel(channel, v->pbuf);
    } else {
      /* Not send packet. */
      v->ret = LAGOPUS_RESULT_OK;
    }
  } else {
    lagopus_msg_debug(1, "Channel is not alive, drop asynchronous message(%s)\n",
                      ofp_type_str(v->type));
    /* Not send packet. */
    v->ret = LAGOPUS_RESULT_OK;
  }

  return LAGOPUS_RESULT_OK;
}
コード例 #2
0
ファイル: ofp_role.c プロジェクト: lagopus/lagopus
lagopus_result_t
ofp_role_channel_write(struct pbuf *pbuf, uint64_t dpid,
                       uint8_t type, uint8_t reason) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  if (pbuf != NULL) {
    struct role_write_vars v;

    v.type = type;
    v.reason = reason;
    v.pbuf = pbuf;
    v.ret = LAGOPUS_RESULT_ANY_FAILURES;

    ret = channel_mgr_dpid_iterate(dpid, ofp_role_write, (void *) &v);

    if (ret != LAGOPUS_RESULT_OK) {
      if (ret == LAGOPUS_RESULT_NOT_OPERATIONAL ||
          ret == LAGOPUS_RESULT_NOT_FOUND) {
        lagopus_msg_info("Channel is not alive, drop asynchronous message(%s)\n",
                         ofp_type_str(v.type));
        /* Not send packet. */
        ret = LAGOPUS_RESULT_OK;
      } else {
        ret = v.ret;
      }
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  if (ret == LAGOPUS_RESULT_OK && pbuf != NULL) {
    /* move getp to putp. */
    pbuf_getp_set(pbuf, pbuf_putp_get(pbuf));
  }

  return ret;
}