diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/dev.c | 4 | ||||
| -rw-r--r-- | src/lib/frct.c | 9 | ||||
| -rw-r--r-- | src/lib/qos.c | 27 | ||||
| -rw-r--r-- | src/lib/qoscube.c | 6 | 
4 files changed, 34 insertions, 12 deletions
| diff --git a/src/lib/dev.c b/src/lib/dev.c index ee82bbaa..8417d63b 100644 --- a/src/lib/dev.c +++ b/src/lib/dev.c @@ -536,7 +536,7 @@ int flow_accept(qosspec_t *             qs,          assert(ai.flows[fd].frcti == NULL);          if (qc != QOS_CUBE_RAW) { -                ai.flows[fd].frcti = frcti_create(fd); +                ai.flows[fd].frcti = frcti_create(fd, qc);                  if (ai.flows[fd].frcti == NULL) {                          flow_fini(fd);                          pthread_rwlock_unlock(&ai.lock); @@ -611,7 +611,7 @@ int flow_alloc(const char *            dst,          assert(ai.flows[fd].frcti == NULL);          if (qc != QOS_CUBE_RAW) { -                ai.flows[fd].frcti = frcti_create(fd); +                ai.flows[fd].frcti = frcti_create(fd, qc);                  if (ai.flows[fd].frcti == NULL) {                          flow_fini(fd);                          pthread_rwlock_unlock(&ai.lock); diff --git a/src/lib/frct.c b/src/lib/frct.c index bcb031c3..00261272 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -105,7 +105,8 @@ static void frct_fini(void)          timerwheel_destroy(frct.tw);  } -static struct frcti * frcti_create(int fd) +static struct frcti * frcti_create(int       fd, +                                   qoscube_t qc)  {          struct frcti *  frcti;          time_t          delta_t; @@ -133,6 +134,9 @@ static struct frcti * frcti_create(int fd)          delta_t = (frcti->mpl + frcti->a + frcti->r) / 1000; +        if (qc == QOS_CUBE_DATA) +                frcti->snd_cr.cflags |= FRCTFRTX; +          frcti->snd_cr.conf   = true;          frcti->snd_cr.inact  = 3 * delta_t + 1;          frcti->snd_cr.act    = now.tv_sec - (frcti->snd_cr.inact + 1); @@ -317,6 +321,9 @@ static int __frcti_snd(struct frcti *       frcti,          pci->seqno = hton32(snd_cr->seqno++);          if (!(snd_cr->cflags & FRCTFRTX))                  snd_cr->lwe++; +        else +                /* TODO: update on ACK */ +                snd_cr->lwe++;          snd_cr->act  = now.tv_sec;          snd_cr->conf = false; diff --git a/src/lib/qos.c b/src/lib/qos.c index f5fbf1fb..bee6ed71 100644 --- a/src/lib/qos.c +++ b/src/lib/qos.c @@ -25,19 +25,22 @@  #include <stdint.h>  #include <stddef.h> +#include <string.h>  qosspec_t qos_raw = {          .delay                = UINT32_MAX, -        .bandwidth            = UINT64_MAX, +        .bandwidth            = 0,          .availability         = 0, +        .loss                 = 1,          .in_order             = 0,          .maximum_interruption = UINT32_MAX  };  qosspec_t qos_best_effort = {          .delay                = UINT32_MAX, -        .bandwidth            = UINT64_MAX, +        .bandwidth            = 0,          .availability         = 0, +        .loss                 = 1,          .in_order             = 1,          .maximum_interruption = UINT32_MAX  }; @@ -46,27 +49,35 @@ qosspec_t qos_video = {          .delay                = 100,          .bandwidth            = UINT64_MAX,          .availability         = 3, +        .loss                 = 1,          .in_order             = 1,          .maximum_interruption = 100  };  qosspec_t qos_voice = { -        .delay                = 10, +        .delay                = 50,          .bandwidth            = 100000,          .availability         = 5, +        .loss                 = 1,          .in_order             = 1,          .maximum_interruption = 50  }; +qosspec_t qos_data = { +        .delay                = 1000, +        .bandwidth            = 0, +        .availability         = 0, +        .in_order             = 1, +        .loss                 = 0, +        .maximum_interruption = 2000 +}; +  int qosspec_init(qosspec_t * qs)  {          if (qs == NULL)                  return -EINVAL; -        qs->delay = UINT32_MAX; -        qs->bandwidth = UINT64_MAX; -        qs->availability = 0; -        qs->maximum_interruption = UINT32_MAX; +        *qs = qos_best_effort;          return 0;  } @@ -76,7 +87,7 @@ int qosspec_fini(qosspec_t * qs)          if (qs == NULL)                  return -EINVAL; -        qs = NULL; +        memset(qs, 0, sizeof(*qs));          return 0;  } diff --git a/src/lib/qoscube.c b/src/lib/qoscube.c index 12f7c277..5dfa35ad 100644 --- a/src/lib/qoscube.c +++ b/src/lib/qoscube.c @@ -27,7 +27,9 @@  qoscube_t qos_spec_to_cube(qosspec_t qs)  { -        if (qs.delay <= qos_voice.delay && +        if (qs.loss == 0) +                return QOS_CUBE_DATA; +        else if (qs.delay <= qos_voice.delay &&              qs.bandwidth <= qos_voice.bandwidth &&              qs.availability >= qos_voice.availability &&              qs.maximum_interruption <= qos_voice.maximum_interruption) @@ -52,6 +54,8 @@ qosspec_t qos_cube_to_spec(qoscube_t qc)                  return qos_video;          case QOS_CUBE_BE:                  return qos_best_effort; +        case QOS_CUBE_DATA: +                return qos_data;          default:                  return qos_raw;          } | 
