Xreferat.com » Топики по английскому языку » Алгоритми маршрутизації в мережах

Алгоритми маршрутизації в мережах

            t1->tv_sec++;

               t1->tv_usec -= 1000000;

   }

}

/* t1 = t2 - t3

*/

static void

timevalsub(struct timeval *t1,

    struct timeval *t2,

    struct timeval *t3)

{

   t1->tv_sec = t2->tv_sec - t3->tv_sec;

   if ((t1->tv_usec = t2->tv_usec - t3->tv_usec) < 0) {

               t1->tv_sec--;

               t1->tv_usec += 1000000;

   }

}

/* put a message into the system log

*/

void

msglog(char *p, ...)

{

   va_list args;

   trace_flush();

   va_start(args, p);

   vsyslog(LOG_ERR, p, args);

   if (ftrace != 0) {

               if (ftrace == stdout)

                           (void)fputs("routed: ", ftrace);

               (void)vfprintf(ftrace, p, args);

               (void)fputc('n', ftrace);

   }

}

/* Put a message about a bad system into the system log if

* we have not complained about it recently.

*

* It is desirable to complain about all bad systems, but not too often.

* In the worst case, it is not practical to keep track of all bad systems.

* For example, there can be many systems with the wrong password.

*/

void

msglim(struct msg_limit *lim, naddr addr, char *p, ...)

{

   va_list args;

   int i;

   struct msg_sub *ms1, *ms;

   char *p1;

   va_start(args, p);

   /* look for the oldest slot in the table

    * or the slot for the bad router.

    */

   ms = ms1 = lim->subs;

   for (i = MSG_SUBJECT_N; ; i--, ms1++) {

               if (i == 0) {

                           /* Reuse a slot at most once every 10 minutes.

                            */

                           if (lim->reuse > now.tv_sec) {

                                       ms = 0;

                           } else {

                                       ms = ms1;

                                       lim->reuse = now.tv_sec + 10*60;

                           }

                           break;

               }

               if (ms->addr == addr) {

                           /* Repeat a complaint about a given system at

                            * most once an hour.

                            */

                           if (ms->until > now.tv_sec)

                                       ms = 0;

                           break;

               }

               if (ms->until < ms1->until)

                           ms = ms1;

   }

   if (ms != 0) {

               ms->addr = addr;

               ms->until = now.tv_sec + 60*60; /* 60 minutes */

               trace_flush();

               for (p1 = p; *p1 == ' '; p1++)

                           continue;

               vsyslog(LOG_ERR, p1, args);

   }

   /* always display the message if tracing */

   if (ftrace != 0) {

               (void)vfprintf(ftrace, p, args);

               (void)fputc('n', ftrace);

   }

}

void

logbad(int dump, char *p, ...)

{

   va_list args;

   trace_flush();

   va_start(args, p);

   vsyslog(LOG_ERR, p, args);

   (void)fputs("routed: ", stderr);

   (void)vfprintf(stderr, p, args);

   (void)fputs("; giving upn",stderr);

   (void)fflush(stderr);

   if (dump)

               abort();

   exit(1);

}

Список литературы

Если Вам нужна помощь с академической работой (курсовая, контрольная, диплом, реферат и т.д.), обратитесь к нашим специалистам. Более 90000 специалистов готовы Вам помочь.
Бесплатные корректировки и доработки. Бесплатная оценка стоимости работы.

Поможем написать работу на аналогичную тему

Получить выполненную работу или консультацию специалиста по вашему учебному проекту
Нужна помощь в написании работы?
Мы - биржа профессиональных авторов (преподавателей и доцентов вузов). Пишем статьи РИНЦ, ВАК, Scopus. Помогаем в публикации. Правки вносим бесплатно.

Похожие рефераты: