mirror of
https://github.com/opnsense/src.git
synced 2026-06-14 19:20:18 -04:00
Re-arrange the arp code so that fddi arps work properly.
This commit is contained in:
parent
22ec1a0d38
commit
f9083fdb2a
1 changed files with 46 additions and 29 deletions
|
|
@ -294,22 +294,12 @@ arprequest(ac, sip, tip, enaddr)
|
|||
return;
|
||||
m->m_pkthdr.rcvif = (struct ifnet *)0;
|
||||
switch (ac->ac_if.if_type) {
|
||||
case IFT_ETHER:
|
||||
m->m_len = sizeof(*ea);
|
||||
m->m_pkthdr.len = sizeof(*ea);
|
||||
MH_ALIGN(m, sizeof(*ea));
|
||||
ea = mtod(m, struct ether_arp *);
|
||||
eh = (struct ether_header *)sa.sa_data;
|
||||
bzero((caddr_t)ea, sizeof (*ea));
|
||||
eh->ether_type = htons(ETHERTYPE_ARP); /* if_output will not swap */
|
||||
(void)memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost));
|
||||
ea->arp_hrd = htons(ARPHRD_ETHER);
|
||||
break;
|
||||
case IFT_ISO88025:
|
||||
m->m_len = sizeof(*ea) + 10;
|
||||
m->m_pkthdr.len = sizeof(*ea) + 10;
|
||||
MH_ALIGN(m, sizeof(*ea) + 10);
|
||||
(void)memcpy(mtod(m, caddr_t), "\x82\x40\xaa\xaa\x03\x00\x00\x00\x08\x06", 10);
|
||||
(void)memcpy(mtod(m, caddr_t),
|
||||
"\x82\x40\xaa\xaa\x03\x00\x00\x00\x08\x06", 10);
|
||||
(void)memcpy(sa.sa_data, etherbroadcastaddr, 6);
|
||||
(void)memcpy(sa.sa_data + 6, enaddr, 6);
|
||||
sa.sa_data[6] |= 0x80;
|
||||
|
|
@ -319,9 +309,25 @@ arprequest(ac, sip, tip, enaddr)
|
|||
bzero((caddr_t)ea, sizeof (*ea));
|
||||
ea->arp_hrd = htons(ARPHRD_IEEE802);
|
||||
break;
|
||||
case IFT_FDDI:
|
||||
case IFT_ETHER:
|
||||
/*
|
||||
* This may not be correct for types not explicitly
|
||||
* listed, but this is our best guess
|
||||
*/
|
||||
default:
|
||||
m_freem(m);
|
||||
return;
|
||||
m->m_len = sizeof(*ea);
|
||||
m->m_pkthdr.len = sizeof(*ea);
|
||||
MH_ALIGN(m, sizeof(*ea));
|
||||
ea = mtod(m, struct ether_arp *);
|
||||
eh = (struct ether_header *)sa.sa_data;
|
||||
bzero((caddr_t)ea, sizeof (*ea));
|
||||
/* if_output will not swap */
|
||||
eh->ether_type = htons(ETHERTYPE_ARP);
|
||||
(void)memcpy(eh->ether_dhost, etherbroadcastaddr,
|
||||
sizeof(eh->ether_dhost));
|
||||
ea->arp_hrd = htons(ARPHRD_ETHER);
|
||||
break;
|
||||
}
|
||||
ea->arp_pro = htons(ETHERTYPE_IP);
|
||||
ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
|
||||
|
|
@ -435,7 +441,7 @@ arpintr()
|
|||
panic("arpintr");
|
||||
if (m->m_len >= sizeof(struct arphdr) &&
|
||||
(ar = mtod(m, struct arphdr *)) &&
|
||||
(ntohs(ar->ar_hrd) == ARPHRD_ETHER ||
|
||||
(ntohs(ar->ar_hrd) == ARPHRD_ETHER ||
|
||||
ntohs(ar->ar_hrd) == ARPHRD_IEEE802) &&
|
||||
m->m_len >=
|
||||
sizeof(struct arphdr) + 2 * ar->ar_hln + 2 * ar->ar_pln)
|
||||
|
|
@ -568,15 +574,20 @@ in_arpinput(m)
|
|||
*/
|
||||
if (ac->ac_if.if_type == IFT_ISO88025) {
|
||||
th = (struct iso88025_header *)m->m_pkthdr.header;
|
||||
if ((th->iso88025_shost[0] & 0x80) &&
|
||||
if ((th->iso88025_shost[0] & 0x80) &&
|
||||
((th->rcf & 0x001f) > 2)) {
|
||||
sdl->sdl_rcf = (th->rcf & 0x8000) ? (th->rcf & 0x7fff) :
|
||||
sdl->sdl_rcf = (th->rcf & 0x8000) ?
|
||||
(th->rcf & 0x7fff) :
|
||||
(th->rcf | 0x8000);
|
||||
memcpy(sdl->sdl_route, th->rseg, (th->rcf & 0x001f) - 2);
|
||||
memcpy(sdl->sdl_route, th->rseg,
|
||||
(th->rcf & 0x001f) - 2);
|
||||
sdl->sdl_rcf = sdl->sdl_rcf & 0xff1f;
|
||||
/* Set up source routing information for reply packet (XXX)*/
|
||||
m->m_data -= (th->rcf & 0x001f);
|
||||
m->m_len += (th->rcf & 0x001f);
|
||||
/*
|
||||
* Set up source routing information for
|
||||
* reply packet (XXX)
|
||||
*/
|
||||
m->m_data -= (th->rcf & 0x001f);
|
||||
m->m_len += (th->rcf & 0x001f);
|
||||
m->m_pkthdr.len += (th->rcf & 0x001f);
|
||||
} else {
|
||||
th->iso88025_shost[0] &= 0x7f;
|
||||
|
|
@ -585,7 +596,6 @@ in_arpinput(m)
|
|||
m->m_len += 8;
|
||||
m->m_pkthdr.len += 8;
|
||||
th->rcf = sdl->sdl_rcf;
|
||||
|
||||
} else {
|
||||
sdl->sdl_rcf = NULL;
|
||||
}
|
||||
|
|
@ -660,8 +670,10 @@ reply:
|
|||
switch (ac->ac_if.if_type) {
|
||||
case IFT_ISO88025:
|
||||
/* Re-arrange the source/dest address */
|
||||
memcpy(th->iso88025_dhost, th->iso88025_shost, sizeof(th->iso88025_dhost));
|
||||
memcpy(th->iso88025_shost, ac->ac_enaddr, sizeof(th->iso88025_shost));
|
||||
memcpy(th->iso88025_dhost, th->iso88025_shost,
|
||||
sizeof(th->iso88025_dhost));
|
||||
memcpy(th->iso88025_shost, ac->ac_enaddr,
|
||||
sizeof(th->iso88025_shost));
|
||||
/* Set the source routing bit if neccesary */
|
||||
if (th->iso88025_dhost[0] & 0x80) {
|
||||
th->iso88025_dhost[0] &= 0x7f;
|
||||
|
|
@ -669,18 +681,23 @@ reply:
|
|||
th->iso88025_shost[0] |= 0x80;
|
||||
}
|
||||
/* Copy the addresses, ac and fc into sa_data */
|
||||
memcpy(sa.sa_data, th->iso88025_dhost, sizeof(th->iso88025_dhost) * 2);
|
||||
memcpy(sa.sa_data, th->iso88025_dhost,
|
||||
sizeof(th->iso88025_dhost) * 2);
|
||||
sa.sa_data[(sizeof(th->iso88025_dhost) * 2)] = 0x10;
|
||||
sa.sa_data[(sizeof(th->iso88025_dhost) * 2) + 1] = 0x40;
|
||||
break;
|
||||
case IFT_ETHER:
|
||||
case IFT_FDDI:
|
||||
/*
|
||||
* May not be correct for types not explictly
|
||||
* listed, but it is our best guess.
|
||||
*/
|
||||
default:
|
||||
eh = (struct ether_header *)sa.sa_data;
|
||||
(void)memcpy(eh->ether_dhost, ea->arp_tha, sizeof(eh->ether_dhost));
|
||||
(void)memcpy(eh->ether_dhost, ea->arp_tha,
|
||||
sizeof(eh->ether_dhost));
|
||||
eh->ether_type = htons(ETHERTYPE_ARP);
|
||||
break;
|
||||
default:
|
||||
m_free(m);
|
||||
return;
|
||||
}
|
||||
sa.sa_family = AF_UNSPEC;
|
||||
sa.sa_len = sizeof(sa);
|
||||
|
|
|
|||
Loading…
Reference in a new issue