* Send Cisco keepalive packet. */
| 591 | * Send Cisco keepalive packet. |
| 592 | */ |
| 593 | static int |
| 594 | cisco_send(sc_p sc, int type, long par1, long par2) |
| 595 | { |
| 596 | struct cisco_header *h; |
| 597 | struct cisco_packet *ch; |
| 598 | struct mbuf *m; |
| 599 | struct timeval time; |
| 600 | uint32_t t; |
| 601 | int error = 0; |
| 602 | |
| 603 | getmicrouptime(&time); |
| 604 | |
| 605 | MGETHDR(m, M_NOWAIT, MT_DATA); |
| 606 | if (!m) |
| 607 | return (ENOBUFS); |
| 608 | |
| 609 | t = time.tv_sec * 1000 + time.tv_usec / 1000; |
| 610 | m->m_pkthdr.len = m->m_len = CISCO_HEADER_LEN + CISCO_PACKET_LEN; |
| 611 | m->m_pkthdr.rcvif = 0; |
| 612 | |
| 613 | h = mtod(m, struct cisco_header *); |
| 614 | h->address = CISCO_MULTICAST; |
| 615 | h->control = 0; |
| 616 | h->protocol = htons(CISCO_KEEPALIVE); |
| 617 | |
| 618 | ch = (struct cisco_packet *) (h + 1); |
| 619 | ch->type = htonl(type); |
| 620 | ch->par1 = htonl(par1); |
| 621 | ch->par2 = htonl(par2); |
| 622 | ch->rel = -1; |
| 623 | ch->time0 = htons((uint16_t) (t >> 16)); |
| 624 | ch->time1 = htons((uint16_t) t); |
| 625 | |
| 626 | NG_SEND_DATA_ONLY(error, sc->downstream.hook, m); |
| 627 | return (error); |
| 628 | } |
| 629 | |
| 630 | /* |
| 631 | * Send linkstate to upstream node. |
no test coverage detected