void ccnl_face_CTS(struct ccnl_relay_s *ccnl, struct ccnl_face_s *f) { struct ccnl_buf_s *buf; DEBUGMSG_CORE(TRACE, "CTS face=%p sched=%p\n", (void*)f, (void*)f->sched); if (!f->frag || f->frag->protocol == CCNL_FRAG_NONE) { buf = ccnl_face_dequeue(ccnl, f); if (buf) ccnl_interface_enqueue(ccnl_face_CTS_done, f, ccnl, ccnl->ifs + f->ifndx, buf, &f->peer); } #ifdef USE_FRAG else { sockunion dst; int ifndx = f->ifndx; buf = ccnl_frag_getnext(f->frag, &ifndx, &dst); if (!buf) { buf = ccnl_face_dequeue(ccnl, f); ccnl_frag_reset(f->frag, buf, f->ifndx, &f->peer); buf = ccnl_frag_getnext(f->frag, &ifndx, &dst); } if (buf) { ccnl_interface_enqueue(ccnl_face_CTS_done, f, ccnl, ccnl->ifs + ifndx, buf, &dst); #ifndef USE_SCHEDULER ccnl_face_CTS(ccnl, f); // loop to push more fragments #endif } } #endif }
int ccnl_face_enqueue(struct ccnl_relay_s *ccnl, struct ccnl_face_s *to, struct ccnl_buf_s *buf) { struct ccnl_buf_s *msg; DEBUGMSG(20, "ccnl_face_enqueue face=%p (id=%d.%d) buf=%p len=%d\n", (void *) to, ccnl->id, to->faceid, (void *) buf, buf->datalen); for (msg = to->outq; msg; msg = msg->next) // already in the queue? if (buf_equal(msg, buf)) { DEBUGMSG(31, " not enqueued because already there\n"); ccnl_free(buf); return -1; } buf->next = NULL; if (to->outqend) { to->outqend->next = buf; } else { to->outq = buf; } to->outqend = buf; ccnl_face_CTS(ccnl, to); return 0; }
int ccnl_face_enqueue(struct ccnl_relay_s *ccnl, struct ccnl_face_s *to, struct ccnl_buf_s *buf) { struct ccnl_buf_s *msg; if (buf == NULL) { DEBUGMSG_CORE(ERROR, "enqueue face: buf most not be NULL\n"); return -1; } DEBUGMSG_CORE(TRACE, "enqueue face=%p (id=%d.%d) buf=%p len=%zd\n", (void*) to, ccnl->id, to->faceid, (void*) buf, buf ? buf->datalen : -1); for (msg = to->outq; msg; msg = msg->next) // already in the queue? if (buf_equal(msg, buf)) { DEBUGMSG_CORE(VERBOSE, " not enqueued because already there\n"); ccnl_free(buf); return -1; } buf->next = NULL; if (to->outqend) to->outqend->next = buf; else to->outq = buf; to->outqend = buf; #ifdef USE_SCHEDULER if (to->sched) { #ifdef USE_FRAG int len, cnt = ccnl_frag_getfragcount(to->frag, buf->datalen, &len); #else int len = buf->datalen, cnt = 1; #endif ccnl_sched_RTS(to->sched, cnt, len, ccnl, to); } else ccnl_face_CTS(ccnl, to); #else ccnl_face_CTS(ccnl, to); #endif return 0; }