Esempio n. 1
0
static void
htlc_read (int fd)
{
   ssize_t r;
   struct htlc_conn *htlc = hxd_files[fd].conn.htlc;
   struct qbuf *in = &htlc->read_in;

   if (!in->len) {
      qbuf_set(in, in->pos, READ_BUFSIZE);
      in->len = 0;
   }
   r = read(fd, &in->buf[in->pos], READ_BUFSIZE-in->len);
   if (r == 0 || (r < 0 && errno != EWOULDBLOCK && errno != EINTR)) {
      /*hxd_log("htlc_read; %d %s", r, strerror(errno));*/
      htlc_close(htlc);
   } else {
      in->len += r;
      while (decode(htlc)) {
#ifdef CONFIG_NETWORK
         struct htlc_conn *server_htlc = htlc->server_htlc;
#endif
         if (htlc->rcv) {
            int is_rcv_hdr = htlc->rcv == rcv_hdr;
            htlc->rcv(htlc);
            if (!hxd_files[fd].conn.htlc) {
#ifdef CONFIG_NETWORK
#if 0
               if (server_htlc)
                  server_reset(fd, htlc, server_htlc);
#endif
#endif
               return;
            }
            if (!is_rcv_hdr)
               goto reset;
         } else {
reset:
            if (htlc->flags.is_hlcomm_client && htlc->rcv != rcv_user_getlist)
               test_away(htlc);
            else if (htlc->flags.is_frogblast && htlc->rcv != rcv_user_getinfo)
               test_away(htlc);
            else if (!htlc->flags.is_hlcomm_client && \
                     !htlc->flags.is_frogblast)
               test_away(htlc);
            htlc->rcv = rcv_hdr;
            qbuf_set(&htlc->in, 0, SIZEOF_HL_HDR);
#ifdef CONFIG_NETWORK
            if (server_htlc)
               server_reset(fd, htlc, server_htlc);
#endif
         }
      }
   }
}
Esempio n. 2
0
/**
 * RESET
 */
int handleRESET(sessionid_t sessionid, bus_t bus, char *device,
                char *parameter, char *reply)
{
    struct timeval time;
    int rc = SRCP_UNSUPPORTEDOPERATION;
    *reply = 0x00;

    if (bus_has_devicegroup(bus, DG_SERVER)
             && strncasecmp(device, "SERVER", 6) == 0) {
        rc = SRCP_OK;
        server_reset();
    }

    gettimeofday(&time, NULL);
    srcp_fmt_msg(rc, reply, time);
    return rc;
}