diff options
author | harti <harti@FreeBSD.org> | 2003-08-12 14:20:32 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2003-08-12 14:20:32 +0000 |
commit | 5f9648d8b3cf36898e88a64d4caf5b0ceee76982 (patch) | |
tree | 7a739f01532bf93f710204e6d6adc1bca62e1e1a /sys/netinet | |
parent | a40178b3b1de3071a02ff8b8201c46d8fdb631d0 (diff) | |
download | FreeBSD-src-5f9648d8b3cf36898e88a64d4caf5b0ceee76982.zip FreeBSD-src-5f9648d8b3cf36898e88a64d4caf5b0ceee76982.tar.gz |
Change the code that enables/disables the ATM channel to use the
new ATMIOCOPENVCC/CLOSEVCC. This allows us to not only use UBR channels
for IP over ATM, but also CBR, VBR and ABR. Change the format of the
link layer address to specify the channel characteristics. The old
format is still supported and opens UBR channels.
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/if_atm.c | 115 |
1 files changed, 48 insertions, 67 deletions
diff --git a/sys/netinet/if_atm.c b/sys/netinet/if_atm.c index f328c07..82c95bf 100644 --- a/sys/netinet/if_atm.c +++ b/sys/netinet/if_atm.c @@ -65,6 +65,24 @@ __FBSDID("$FreeBSD$"); #define SDL(s) ((struct sockaddr_dl *)s) +#define GET3BYTE(V, A, L) do { \ + (V) = ((A)[0] << 16) | ((A)[1] << 8) | (A)[2]; \ + (A) += 3; \ + (L) -= 3; \ + } while (0) + +#define GET2BYTE(V, A, L) do { \ + (V) = ((A)[0] << 8) | (A)[1]; \ + (A) += 2; \ + (L) -= 2; \ + } while (0) + +#define GET1BYTE(V, A, L) do { \ + (V) = *(A)++; \ + (L)--; \ + } while (0) + + /* * atm_rtrequest: handle ATM rt request (in support of generic code) * inputs: "req" = request code @@ -136,96 +154,59 @@ atm_rtrequest(int req, struct rtentry *rt, struct rt_addrinfo *info) if (alen == 4) { /* old type address */ - op.param.flags = *addr++; - op.param.vpi = *addr++; - op.param.vci = *addr++ << 8; - op.param.vci |= *addr++; + GET1BYTE(op.param.flags, addr, alen); + GET1BYTE(op.param.vpi, addr, alen); + GET2BYTE(op.param.vci, addr, alen); op.param.traffic = ATMIO_TRAFFIC_UBR; op.param.aal = (op.param.flags & ATM_PH_AAL5) ? ATMIO_AAL_5 : ATMIO_AAL_0; } else { /* new address */ op.param.aal = ATMIO_AAL_5; - /* 1. byte LLC/SNAP flag */ - op.param.flags = *addr++ & ATM_PH_LLCSNAP; - alen--; - /* 2.-4. byte VPI/VCI */ - op.param.vpi = *addr++; - op.param.vci = *addr++ << 8; - op.param.vci |= *addr++; - alen -= 3; - /* 5. byte: traffic */ - op.param.traffic = *addr++; - alen--; + + GET1BYTE(op.param.flags, addr, alen); + op.param.flags &= ATM_PH_LLCSNAP; + + GET1BYTE(op.param.vpi, addr, alen); + GET2BYTE(op.param.vci, addr, alen); + + GET1BYTE(op.param.traffic, addr, alen); + switch (op.param.traffic) { case ATMIO_TRAFFIC_UBR: - if (alen >= 3) { - op.param.tparam.pcr = *addr++ << 16; - op.param.tparam.pcr = *addr++ << 8; - op.param.tparam.pcr = *addr++ << 0; - alen -= 3; - } + if (alen >= 3) + GET3BYTE(op.param.tparam.pcr, + addr, alen); break; case ATMIO_TRAFFIC_CBR: if (alen < 3) goto bad_param; - op.param.tparam.pcr = *addr++ << 16; - op.param.tparam.pcr = *addr++ << 8; - op.param.tparam.pcr = *addr++ << 0; - alen -= 3; + GET3BYTE(op.param.tparam.pcr, addr, alen); break; case ATMIO_TRAFFIC_VBR: if (alen < 3 * 3) goto bad_param; - op.param.tparam.pcr = *addr++ << 16; - op.param.tparam.pcr = *addr++ << 8; - op.param.tparam.pcr = *addr++ << 0; - alen -= 3; - op.param.tparam.scr = *addr++ << 16; - op.param.tparam.scr = *addr++ << 8; - op.param.tparam.scr = *addr++ << 0; - alen -= 3; - op.param.tparam.mbs = *addr++ << 16; - op.param.tparam.mbs = *addr++ << 8; - op.param.tparam.mbs = *addr++ << 0; - alen -= 3; + GET3BYTE(op.param.tparam.pcr, addr, alen); + GET3BYTE(op.param.tparam.scr, addr, alen); + GET3BYTE(op.param.tparam.mbs, addr, alen); break; case ATMIO_TRAFFIC_ABR: - if (alen < 4 * 3 + 1 * 2 + 5 + 1) + if (alen < 4 * 3 + 2 + 1 * 2 + 3) goto bad_param; - op.param.tparam.pcr = *addr++ << 16; - op.param.tparam.pcr = *addr++ << 8; - op.param.tparam.pcr = *addr++ << 0; - alen -= 3; - op.param.tparam.mcr = *addr++ << 16; - op.param.tparam.mcr = *addr++ << 8; - op.param.tparam.mcr = *addr++ << 0; - alen -= 3; - op.param.tparam.icr = *addr++ << 16; - op.param.tparam.icr = *addr++ << 8; - op.param.tparam.icr = *addr++ << 0; - alen -= 3; - op.param.tparam.tbe = *addr++ << 16; - op.param.tparam.tbe = *addr++ << 8; - op.param.tparam.tbe = *addr++ << 0; - alen -= 3; - op.param.tparam.nrm = *addr++; - alen--; - op.param.tparam.trm = *addr++; - alen--; - op.param.tparam.adtf = *addr++ << 8; - op.param.tparam.adtf = *addr++ << 0; - alen -= 2; - op.param.tparam.rif = *addr++; - alen--; - op.param.tparam.rdf = *addr++; - alen--; - op.param.tparam.cdf = *addr++; - alen--; + GET3BYTE(op.param.tparam.pcr, addr, alen); + GET3BYTE(op.param.tparam.mcr, addr, alen); + GET3BYTE(op.param.tparam.icr, addr, alen); + GET3BYTE(op.param.tparam.tbe, addr, alen); + GET1BYTE(op.param.tparam.nrm, addr, alen); + GET1BYTE(op.param.tparam.trm, addr, alen); + GET2BYTE(op.param.tparam.adtf, addr, alen); + GET1BYTE(op.param.tparam.rif, addr, alen); + GET1BYTE(op.param.tparam.rdf, addr, alen); + GET1BYTE(op.param.tparam.cdf, addr, alen); break; default: |