dd_xmit.c,v
来自「TCP-IP红宝书源代码」· C,V 代码 · 共 170 行
C,V
170 行
head 1.4;
access;
symbols;
locks
dls:1.4; strict;
comment @ * @;
1.4
date 97.09.21.19.28.38; author dls; state Dist;
branches;
next 1.3;
1.3
date 94.02.20.18.59.56; author dls; state Works;
branches;
next 1.2;
1.2
date 94.02.13.19.38.53; author dls; state Works;
branches;
next 1.1;
1.1
date 94.02.06.18.20.12; author dls; state Ok;
branches;
next ;
desc
@@
1.4
log
@pre-3e code
@
text
@/* dd_xmit.c - dd_xmit */
#include <conf.h>
#include <kernel.h>
#include <network.h>
#include <ospf.h>
/*------------------------------------------------------------------------
* dd_xmit - transmit pending Database Description packets
*------------------------------------------------------------------------
*/
int dd_xmit(pif, pnb)
struct ospf_if *pif;
struct ospf_nb *pnb;
{
struct ep *pephead, *pep, *ospfddtmpl();
struct ip *pip;
struct ospf *po;
struct ospf_dd *pdd;
int len;
if (pephead = (struct ep *)headq(pnb->nb_dsl)) {
kprintf("dd_xmit: queue not empty\n");
pep = (struct ep *)getbuf(Net.netpool);
if ((int)pep == SYSERR)
return SYSERR;
/* make a copy */
pip = (struct ip *)pephead->ep_data;
po = (struct ospf *)pip->ip_data;
len = EP_HLEN + IPMHLEN + po->ospf_len;
blkcopy(pep, pephead, len);
pip = (struct ip *)pep->ep_data;
po = (struct ospf *)pip->ip_data;
pdd = (struct ospf_dd *)po->ospf_data;
} else {
kprintf("dd_xmit: queue empty\n");
/* no DD's to send; create an ACK-only */
pep = ospfddtmpl(pif);
pip = (struct ip *)pep->ep_data;
po = (struct ospf *)pip->ip_data;
pdd = (struct ospf_dd *)po->ospf_data;
if (pnb->nb_master)
pdd->dd_control = DDC_MSTR;
else
pdd->dd_control = 0;
}
pdd->dd_seq = hl2net(pnb->nb_seq);
po->ospf_authtype = net2hs(pif->if_area->ar_authtype);
len = po->ospf_len;
po->ospf_len = net2hs(po->ospf_len);
pep->ep_order &= ~EPO_OSPF;
bzero(po->ospf_auth, AUTHLEN);
po->ospf_cksum = 0;
po->ospf_cksum = cksum(po, len);
blkcopy(po->ospf_auth, pif->if_area->ar_auth, AUTHLEN);
pip->ip_src = ip_anyaddr;
ipsend(pnb->nb_ipa, pep, len, IPT_OSPF, IPP_INCTL, IP_TTL);
}
@
1.3
log
@*** empty log message ***
@
text
@d16 1
a16 1
struct ep *pephead, *pep;
a21 2
kprintf("dd_xmit\n");
d23 1
d36 1
d47 5
a51 2
pdd->dd_seq = pnb->nb_seq;
po->ospf_authtype = pif->if_area->ar_authtype;
d54 1
a54 1
po->ospf_cksum = cksum(po, po->ospf_len>>1);
d56 2
a57 4
blkcopy(pip->ip_src, ip_anyaddr, IP_ALEN);
kprintf("dd_xmit calling ipsend:\n");
ipsend(pnb->nb_ipa, pep, po->ospf_len, IPT_OSPF, IPP_INCTL,
IP_TTL);
@
1.2
log
@*** empty log message ***
@
text
@a23 3
pep = (struct ep *)getbuf(Net.netpool);
if ((int)pep == SYSERR)
return SYSERR;
d25 3
d38 1
a38 1
ospfddtmpl(pif, pep);
@
1.1
log
@Initial revision
@
text
@a23 5
pephead = (struct ep *)deq(pnb->nb_dsl);
if (pephead == 0) {
/* generate an event here? */
return;
}
d27 21
a47 10
/* make a copy */
pip = (struct ip *)pephead->ep_data;
po = (struct ospf *)pip->ip_data;
len = EP_HLEN + IPMHLEN + po->ospf_len;
blkcopy(pep, pephead, len);
pip = (struct ip *)pep->ep_data;
po = (struct ospf *)pip->ip_data;
if (enq(pnb->nb_dsl, pephead, -pdd->dd_seq) < 0)
freebuf(pephead);
d54 1
@
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?