kdp_return_t kdp_connect
(kdp_connection *c)
{
    kdp_return_t ret;

    CHECK_FATAL (kdp_is_bound (c));
    CHECK_FATAL (! kdp_is_connected (c));

    /* Do a connect transaction. */

    c->request->connect_req.hdr.request = KDP_CONNECT;
    c->request->connect_req.req_reply_port = c->reqport;
    c->request->connect_req.exc_note_port  = c->excport;
    strncpy (c->request->connect_req.greeting, "", 64);
    c->request->connect_req.greeting[63] = '\0';

    ret = kdp_transaction (c, c->request, c->response, "remote_connect");
    if (ret != RR_SUCCESS) {
        return ret;
    }

    if (c->response->writemem_reply.error) {
        c->logger (KDP_LOG_ERROR, "kdp_connect: %s\n",
                   kdp_return_string (c->response->connect_reply.error));
        return RR_CONNECT;
    }

    c->session_key = c->response->hdr.key;
    c->connected = 1;

    return RR_SUCCESS;
}
kdp_return_t kdp_disconnect (kdp_connection *c)
{
    kdp_return_t ret;

    CHECK_FATAL (kdp_is_connected (c));

    c->request->disconnect_req.hdr.request = KDP_DISCONNECT;
    ret = kdp_transaction (c, c->request, c->response, "kdp_disconnect");

    if (ret != RR_SUCCESS) {
        return ret;
    }
    c->connected = 0;

    return RR_SUCCESS;
}
Beispiel #3
0
kdp_return_t
kdp_hostreboot (kdp_connection *c)
{
  kdp_return_t ret;

  CHECK_FATAL (kdp_is_connected (c));

  c->request->hostreboot_req.hdr.request = KDP_HOSTREBOOT;
  c->retries = 1;
  ret = kdp_transaction (c, c->request, c->response, "kdp_hostreboot");

  c->connected = 0;

  if (ret != RR_SUCCESS)
    {
      return ret;
    }

  return RR_SUCCESS;
}
Beispiel #4
0
kdp_return_t
kdp_reattach (kdp_connection *c)
{
  kdp_return_t ret;

  CHECK_FATAL (!kdp_is_connected (c));

  c->request->reattach_req.hdr.request = KDP_REATTACH;
  c->request->reattach_req.req_reply_port = c->reqport;

  ret = kdp_transaction (c, c->request, c->response, "kdp_reattach");

  if (ret != RR_SUCCESS)
    {
      return ret;
    }

  c->connected = 1;
  return RR_SUCCESS;
}
static kdp_return_t kdp_exception_reply
(kdp_connection *c, kdp_pkt_t *response)
{
    kdp_return_t kdpret;
    kdp_exception_ack_t ack;

    CHECK_FATAL (kdp_is_connected (c));
    CHECK_FATAL (kdp_is_bound (c));

    ack.hdr.request = KDP_EXCEPTION;
    ack.hdr.is_reply = 1;
    ack.hdr.seq = response->exception.hdr.seq;
    ack.hdr.key = response->exception.hdr.key;

    kdpret = kdp_transmit_exception (c, (kdp_pkt_t *) &ack);
    if (kdpret != RR_SUCCESS) {
        c->logger (KDP_LOG_ERROR, "kdp_exception_reply: unable to acknowledge exception: %s\n",
                   kdp_return_string (kdpret));
    }

    return kdpret;
}