Update to 4.4-Lite networking code, with a few local changes.

This commit is contained in:
mycroft 1994-05-13 06:10:16 +00:00
parent 13a6ea2dd4
commit c191ecd14e
48 changed files with 549 additions and 322 deletions

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile 5.16 (Berkeley) 4/26/91
# $Id: Makefile,v 1.3 1993/07/31 15:26:00 mycroft Exp $
# @(#)Makefile 5.16 (Berkeley) 4/26/91
# $Id: Makefile,v 1.4 1994/05/13 06:10:16 mycroft Exp $
PROG= xebec
SRCS= llparse.c llscan.c main.c malloc.c procs.c putdriver.c sets.c xebec.c

View File

@ -1,4 +1,4 @@
/* $Id: debug.h,v 1.2 1993/05/20 05:28:20 cgd Exp $ */
/* $Id: debug.h,v 1.3 1994/05/13 06:10:17 mycroft Exp $ */
#define OUT stdout

View File

@ -1,3 +1,5 @@
/* $Id: llparse.c,v 1.3 1994/05/13 06:10:18 mycroft Exp $ */
/*
* ************************* NOTICE *******************************
* This code is in the public domain. It cannot be copyrighted.
@ -8,8 +10,6 @@
* It was subsequently modified very slightly by Nancy Hall at the
* University of Wisconsin for the Crystal project.
* ****************************************************************
*
* $Id: llparse.c,v 1.2 1993/05/20 05:28:21 cgd Exp $
*/
#include "xebec.h"
#include "llparse.h"

View File

@ -1,4 +1,4 @@
/* $Id: llparse.h,v 1.2 1993/05/20 05:28:22 cgd Exp $ */
/* $Id: llparse.h,v 1.3 1994/05/13 06:10:20 mycroft Exp $ */
/************************************************************
attributes stack garbage

View File

@ -1,3 +1,5 @@
/* $Id: llscan.c,v 1.4 1994/05/13 06:10:21 mycroft Exp $ */
/*
* ************************* NOTICE *******************************
* This code is in the public domain. It cannot be copyrighted.
@ -6,8 +8,6 @@
* It was subsequently modified significantly by Nancy Hall at the
* University of Wisconsin for the ARGO project.
* ****************************************************************
*
* $Id: llscan.c,v 1.3 1994/03/29 04:30:26 glass Exp $
*/
#include "xebec.h"
#include "llparse.h"

View File

@ -1,4 +1,5 @@
/* $Id: main.c,v 1.3 1994/03/29 10:16:52 glass Exp $ */
/* $Id: main.c,v 1.4 1994/05/13 06:10:23 mycroft Exp $ */
/*
* TODO:
* rewrite the command line stuff altogether - it's kludged beyond
@ -87,7 +88,8 @@ register char *proto;
X = fopen(X/**/_name, "w");\
if((X)==(FILE *)0)\
{ fprintf(stderr,"Open failed: %s\n", "X"); Exit(-1); }\
fprintf(X, "/* %cId%c */\n",'$', '$' );
fprintf(X, "/* %cHeader%c */\n",'$', '$' );\
fprintf(X, "/* %cSource%c */\n",'$', '$' );
DOIT(eventfile_h);
@ -314,7 +316,6 @@ char *argv[];
(void) llparse();
/* {{ */
if( !FirstEventAttribute )
fprintf(eventfile_h, "\t}ev_union;\n");

View File

@ -1,4 +1,4 @@
/* $Id: main.h,v 1.2 1993/05/20 05:28:26 cgd Exp $ */
/* $Id: main.h,v 1.3 1994/05/13 06:10:25 mycroft Exp $ */
#define TRUE 1
#define FALSE 0

View File

@ -1,4 +1,5 @@
/* $Id: malloc.c,v 1.2 1993/05/20 05:28:27 cgd Exp $ */
/* $Id: malloc.c,v 1.3 1994/05/13 06:10:26 mycroft Exp $ */
/*
* This code is such a kludge that I don't want to put my name on it.
* It was a ridiculously fast hack and needs rewriting.

View File

@ -1,3 +1,3 @@
/* $Id: malloc.h,v 1.2 1993/05/20 05:28:28 cgd Exp $ */
/* $Id: malloc.h,v 1.3 1994/05/13 06:10:28 mycroft Exp $ */
char *Malloc();

View File

@ -1,4 +1,5 @@
/* $Id: procs.c,v 1.2 1993/05/20 05:28:29 cgd Exp $ */
/* $Id: procs.c,v 1.3 1994/05/13 06:10:30 mycroft Exp $ */
/*
* This code is such a kludge that I don't want to put my name on it.
* It was a ridiculously fast hack and needs rewriting.

View File

@ -1,4 +1,4 @@
/* $Id: procs.h,v 1.2 1993/05/20 05:28:30 cgd Exp $ */
/* $Id: procs.h,v 1.3 1994/05/13 06:10:32 mycroft Exp $ */
extern char *stash();
extern struct Object *SameState;

View File

@ -1,4 +1,4 @@
/* $Id: putdriver.c,v 1.2 1993/05/20 05:28:31 cgd Exp $ */
/* $Id: putdriver.c,v 1.3 1994/05/13 06:10:34 mycroft Exp $ */
/*
* This code is such a kludge that I don't want to put my name on it.

View File

@ -1,4 +1,5 @@
/* $Id: sets.c,v 1.2 1993/05/20 05:28:32 cgd Exp $ */
/* $Id: sets.c,v 1.3 1994/05/13 06:10:36 mycroft Exp $ */
/*
* This code is such a kludge that I don't want to put my name on it.
* It was a ridiculously fast hack and needs rewriting.

View File

@ -1,4 +1,4 @@
/* $Id: sets.h,v 1.2 1993/05/20 05:28:35 cgd Exp $ */
/* $Id: sets.h,v 1.3 1994/05/13 06:10:40 mycroft Exp $ */
#define MAXEVENTS 200
#define MAXSTATES 200

View File

@ -1,5 +1,5 @@
/* $Id: test.trans,v 1.2 1993/05/20 05:28:36 cgd Exp $ */
*/
/* $Id: test.trans,v 1.3 1994/05/13 06:10:41 mycroft Exp $ */
*PROTOCOL test
*INCLUDE

View File

@ -1,4 +1,4 @@
/* $Id: test_def.h,v 1.2 1993/05/20 05:28:37 cgd Exp $ */
/* $Id: test_def.h,v 1.3 1994/05/13 06:10:42 mycroft Exp $ */
struct blah {
unsigned int blahfield;

View File

@ -1,6 +1,5 @@
/* $Id: xebec.bnf,v 1.2 1993/05/20 05:28:38 cgd Exp $ */
/* $Id: xebec.bnf,v 1.3 1994/05/13 06:10:44 mycroft Exp $ */
{
#include "main.h"
#include "sets.h"
#include <stdio.h>

View File

@ -1,4 +1,4 @@
/* $Id: xebec.c,v 1.2 1993/05/20 05:28:39 cgd Exp $ */
/* $Id: xebec.c,v 1.3 1994/05/13 06:10:46 mycroft Exp $ */
#include "xebec.h"
#include "llparse.h"

View File

@ -1,4 +1,4 @@
/* $Id: xebec.h,v 1.2 1993/05/20 05:28:40 cgd Exp $ */
/* $Id: xebec.h,v 1.3 1994/05/13 06:10:47 mycroft Exp $ */
union llattrib {
struct {

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)idp.h 7.4 (Berkeley) 6/28/90
* $Id: idp.h,v 1.3 1993/05/20 04:35:46 cgd Exp $
* from: @(#)idp.h 8.1 (Berkeley) 6/10/93
* $Id: idp.h,v 1.4 1994/05/13 06:11:02 mycroft Exp $
*/
#ifndef _NETNS_IDP_H_
#define _NETNS_IDP_H_
/*
* Definitions for NS(tm) Internet Datagram Protocol
*/
@ -48,5 +45,3 @@ struct idp {
struct ns_addr idp_dna; /* Destination Network Address */
struct ns_addr idp_sna; /* Source Network Address */
};
#endif /* !_NETNS_IDP_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)idp_usrreq.c 7.11 (Berkeley) 6/27/91
* $Id: idp_usrreq.c,v 1.3 1993/12/18 00:44:15 mycroft Exp $
* from: @(#)idp_usrreq.c 8.1 (Berkeley) 6/10/93
* $Id: idp_usrreq.c,v 1.4 1994/05/13 06:11:05 mycroft Exp $
*/
#include <sys/param.h>
@ -254,7 +254,7 @@ idp_output(nsp, m0)
}
}
nsp->nsp_lastdst = idp->idp_dna;
#endif ancient_history
#endif /* ancient_history */
if (noIdpRoute) ro = 0;
return (ns_output(m, ro, so->so_options & SO_BROADCAST));
}
@ -358,7 +358,7 @@ idp_ctloutput(req, so, level, name, value)
case SO_NSIP_ROUTE:
error = nsip_route(*value);
break;
#endif NSIP
#endif /* NSIP */
default:
error = EINVAL;
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)idp_var.h 7.4 (Berkeley) 6/28/90
* $Id: idp_var.h,v 1.3 1993/05/20 04:35:49 cgd Exp $
* from: @(#)idp_var.h 8.1 (Berkeley) 6/10/93
* $Id: idp_var.h,v 1.4 1994/05/13 06:11:07 mycroft Exp $
*/
#ifndef _NETNS_IDP_VAR_H_
#define _NETNS_IDP_VAR_H_
/*
* IDP Kernel Structures and Variables
*/
@ -51,5 +48,3 @@ struct idpstat {
#ifdef KERNEL
struct idpstat idpstat;
#endif
#endif /* !_NETNS_IDP_VAR_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns.c 7.8 (Berkeley) 6/27/91
* $Id: ns.c,v 1.4 1994/02/10 17:25:24 mycroft Exp $
* from: @(#)ns.c 8.2 (Berkeley) 11/15/93
* $Id: ns.c,v 1.5 1994/05/13 06:11:09 mycroft Exp $
*/
#include <sys/param.h>
@ -69,7 +69,6 @@ ns_control(so, cmd, data, ifp)
register struct ns_ifaddr *ia;
struct ifaddr *ifa;
struct ns_ifaddr *oia;
struct mbuf *m;
int error, dstIsNew, hostIsNew;
/*
@ -127,16 +126,18 @@ ns_control(so, cmd, data, ifp)
case SIOCSIFADDR:
case SIOCSIFDSTADDR:
if (ia == (struct ns_ifaddr *)0) {
m = m_getclr(M_WAIT, MT_IFADDR);
if (m == (struct mbuf *)NULL)
oia = (struct ns_ifaddr *)
malloc(sizeof *ia, M_IFADDR, M_WAITOK);
if (oia == (struct ns_ifaddr *)NULL)
return (ENOBUFS);
bzero((caddr_t)oia, sizeof(*oia));
if (ia = ns_ifaddr) {
for ( ; ia->ia_next; ia = ia->ia_next)
;
ia->ia_next = mtod(m, struct ns_ifaddr *);
ia->ia_next = oia;
} else
ns_ifaddr = mtod(m, struct ns_ifaddr *);
ia = mtod(m, struct ns_ifaddr *);
ns_ifaddr = oia;
ia = oia;
if (ifa = ifp->if_addrlist) {
for ( ; ifa->ifa_next; ifa = ifa->ifa_next)
;
@ -171,7 +172,8 @@ ns_control(so, cmd, data, ifp)
ia->ia_flags &= ~IFA_ROUTE;
}
if (ifp->if_ioctl) {
error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR, ia);
error = (*ifp->if_ioctl)(ifp, SIOCSIFDSTADDR,
(caddr_t)ia);
if (error)
return (error);
}
@ -207,7 +209,7 @@ ns_control(so, cmd, data, ifp)
else
printf("Didn't unlink nsifadr from list\n");
}
(void) m_free(dtom(oia));
IFAFREE((&oia->ia_ifa));
if (0 == --ns_interfaces) {
/*
* We reset to virginity and start all over again
@ -292,7 +294,8 @@ ns_ifinit(ifp, ia, sns, scrub)
*/
if (ns_hosteqnh(ns_thishost, ns_zerohost)) {
if (ifp->if_ioctl &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ia))) {
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR,
(caddr_t)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
@ -302,7 +305,8 @@ ns_ifinit(ifp, ia, sns, scrub)
|| ns_hosteqnh(sns->sns_addr.x_host, ns_thishost)) {
*h = ns_thishost;
if (ifp->if_ioctl &&
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR, ia))) {
(error = (*ifp->if_ioctl)(ifp, SIOCSIFADDR,
(caddr_t)ia))) {
ia->ia_addr = oldaddr;
splx(s);
return (error);
@ -317,6 +321,7 @@ ns_ifinit(ifp, ia, sns, scrub)
splx(s);
return (EINVAL);
}
ia->ia_ifa.ifa_metric = ifp->if_metric;
/*
* Add route for the network.
*/
@ -328,7 +333,7 @@ ns_ifinit(ifp, ia, sns, scrub)
if (ifp->if_flags & IFF_POINTOPOINT)
rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_HOST|RTF_UP);
else {
ia->ia_broadaddr.sns_addr.x_net = ia->ia_net;
ia->ia_broadaddr.sns_addr.x_net = ia->ia_addr.sns_addr.x_net;
rtinit(&(ia->ia_ifa), (int)RTM_ADD, RTF_UP);
}
ia->ia_flags |= IFA_ROUTE;
@ -354,10 +359,10 @@ ns_iaonnetof(dst)
compare = &satons_addr(ia->ia_dstaddr);
if (ns_hosteq(*dst, *compare))
return (ia);
if (ns_neteqnn(net, ia->ia_net))
if (ns_neteqnn(net, ia->ia_addr.sns_addr.x_net))
ia_maybe = ia;
} else {
if (ns_neteqnn(net, ia->ia_net))
if (ns_neteqnn(net, ia->ia_addr.sns_addr.x_net))
return (ia);
}
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns.h 7.8 (Berkeley) 2/22/91
* $Id: ns.h,v 1.3 1993/05/20 04:35:51 cgd Exp $
* from: @(#)ns.h 8.1 (Berkeley) 6/10/93
* $Id: ns.h,v 1.4 1994/05/13 06:11:11 mycroft Exp $
*/
#ifndef _NETNS_NS_H_
#define _NETNS_NS_H_
/*
* Constants and Structures defined by the Xerox Network Software
* per "Internet Transport Protocols", XSIS 028112, December 1981
@ -153,5 +150,3 @@ extern char *ns_ntoa __P((struct ns_addr));
__END_DECLS
#endif
#endif /* !_NETNS_NS_H_ */

205
sys/netns/ns_cksum.c Normal file
View File

@ -0,0 +1,205 @@
/*
* Copyright (c) 1982, 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_cksum.c 8.1 (Berkeley) 6/10/93
* $Id: ns_cksum.c,v 1.1 1994/05/13 06:11:12 mycroft Exp $
*/
#include <sys/param.h>
#include <sys/mbuf.h>
/*
* Checksum routine for Network Systems Protocol Packets (Big-Endian).
*
* This routine is very heavily used in the network
* code and should be modified for each CPU to be as fast as possible.
*/
#define ADDCARRY(x) { if ((x) > 65535) (x) -= 65535; }
#define FOLD(x) {l_util.l = (x); (x) = l_util.s[0] + l_util.s[1]; ADDCARRY(x);}
u_short
ns_cksum(m, len)
register struct mbuf *m;
register int len;
{
register u_short *w;
register int sum = 0;
register int mlen = 0;
register int sum2;
union {
u_short s[2];
long l;
} l_util;
for (;m && len; m = m->m_next) {
if (m->m_len == 0)
continue;
/*
* Each trip around loop adds in
* word from one mbuf segment.
*/
w = mtod(m, u_short *);
if (mlen == -1) {
/*
* There is a byte left from the last segment;
* ones-complement add it into the checksum.
*/
#if BYTE_ORDER == BIG_ENDIAN
sum += *(u_char *)w;
#else
sum += *(u_char *)w << 8;
#endif
sum += sum;
w = (u_short *)(1 + (char *)w);
mlen = m->m_len - 1;
len--;
FOLD(sum);
} else
mlen = m->m_len;
if (len < mlen)
mlen = len;
len -= mlen;
/*
* We can do a 16 bit ones complement sum using
* 32 bit arithmetic registers for adding,
* with carries from the low added
* into the high (by normal carry-chaining)
* so long as we fold back before 16 carries have occured.
*/
if (1 & (int) w)
goto uuuuglyy;
#ifndef TINY
/* -DTINY reduces the size from 1250 to 550, but slows it down by 22% */
while ((mlen -= 32) >= 0) {
sum += w[0]; sum += sum; sum += w[1]; sum += sum;
sum += w[2]; sum += sum; sum += w[3]; sum += sum;
sum += w[4]; sum += sum; sum += w[5]; sum += sum;
sum += w[6]; sum += sum; sum += w[7]; sum += sum;
FOLD(sum);
sum += w[8]; sum += sum; sum += w[9]; sum += sum;
sum += w[10]; sum += sum; sum += w[11]; sum += sum;
sum += w[12]; sum += sum; sum += w[13]; sum += sum;
sum += w[14]; sum += sum; sum += w[15]; sum += sum;
FOLD(sum);
w += 16;
}
mlen += 32;
#endif
while ((mlen -= 8) >= 0) {
sum += w[0]; sum += sum; sum += w[1]; sum += sum;
sum += w[2]; sum += sum; sum += w[3]; sum += sum;
FOLD(sum);
w += 4;
}
mlen += 8;
while ((mlen -= 2) >= 0) {
sum += *w++; sum += sum;
}
goto commoncase;
uuuuglyy:
#if BYTE_ORDER == BIG_ENDIAN
#define ww(n) (((u_char *)w)[n + n + 1])
#define vv(n) (((u_char *)w)[n + n])
#else
#if BYTE_ORDER == LITTLE_ENDIAN
#define vv(n) (((u_char *)w)[n + n + 1])
#define ww(n) (((u_char *)w)[n + n])
#endif
#endif
sum2 = 0;
#ifndef TINY
while ((mlen -= 32) >= 0) {
sum += ww(0); sum += sum; sum += ww(1); sum += sum;
sum += ww(2); sum += sum; sum += ww(3); sum += sum;
sum += ww(4); sum += sum; sum += ww(5); sum += sum;
sum += ww(6); sum += sum; sum += ww(7); sum += sum;
FOLD(sum);
sum += ww(8); sum += sum; sum += ww(9); sum += sum;
sum += ww(10); sum += sum; sum += ww(11); sum += sum;
sum += ww(12); sum += sum; sum += ww(13); sum += sum;
sum += ww(14); sum += sum; sum += ww(15); sum += sum;
FOLD(sum);
sum2 += vv(0); sum2 += sum2; sum2 += vv(1); sum2 += sum2;
sum2 += vv(2); sum2 += sum2; sum2 += vv(3); sum2 += sum2;
sum2 += vv(4); sum2 += sum2; sum2 += vv(5); sum2 += sum2;
sum2 += vv(6); sum2 += sum2; sum2 += vv(7); sum2 += sum2;
FOLD(sum2);
sum2 += vv(8); sum2 += sum2; sum2 += vv(9); sum2 += sum2;
sum2 += vv(10); sum2 += sum2; sum2 += vv(11); sum2 += sum2;
sum2 += vv(12); sum2 += sum2; sum2 += vv(13); sum2 += sum2;
sum2 += vv(14); sum2 += sum2; sum2 += vv(15); sum2 += sum2;
FOLD(sum2);
w += 16;
}
mlen += 32;
#endif
while ((mlen -= 8) >= 0) {
sum += ww(0); sum += sum; sum += ww(1); sum += sum;
sum += ww(2); sum += sum; sum += ww(3); sum += sum;
FOLD(sum);
sum2 += vv(0); sum2 += sum2; sum2 += vv(1); sum2 += sum2;
sum2 += vv(2); sum2 += sum2; sum2 += vv(3); sum2 += sum2;
FOLD(sum2);
w += 4;
}
mlen += 8;
while ((mlen -= 2) >= 0) {
sum += ww(0); sum += sum;
sum2 += vv(0); sum2 += sum2;
w++;
}
sum += (sum2 << 8);
commoncase:
if (mlen == -1) {
#if BYTE_ORDER == BIG_ENDIAN
sum += *(u_char *)w << 8;
#else
sum += *(u_char *)w;
#endif
}
FOLD(sum);
}
if (mlen == -1) {
/* We had an odd number of bytes to sum; assume a garbage
byte of zero and clean up */
sum += sum;
FOLD(sum);
}
/*
* sum has already been kept to low sixteen bits.
* just examine result and exit.
*/
if(sum==0xffff) sum = 0;
return (sum);
}

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_error.c 7.8 (Berkeley) 6/28/90
* $Id: ns_error.c,v 1.3 1993/12/18 00:44:26 mycroft Exp $
* from: @(#)ns_error.c 8.1 (Berkeley) 6/10/93
* $Id: ns_error.c,v 1.4 1994/05/13 06:11:14 mycroft Exp $
*/
#include <sys/param.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_error.h 7.5 (Berkeley) 6/28/90
* $Id: ns_error.h,v 1.3 1993/05/20 04:35:53 cgd Exp $
* from: @(#)ns_error.h 8.1 (Berkeley) 6/10/93
* $Id: ns_error.h,v 1.4 1994/05/13 06:11:15 mycroft Exp $
*/
#ifndef _NETNS_NS_ERROR_H_
#define _NETNS_NS_ERROR_H_
/*
* Xerox NS error messages
*/
@ -92,5 +89,3 @@ struct ns_errstat {
#ifdef KERNEL
struct ns_errstat ns_errstat;
#endif
#endif /* !_NETNS_NS_ERROR_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_if.h 7.6 (Berkeley) 6/28/90
* $Id: ns_if.h,v 1.3 1993/05/20 04:35:54 cgd Exp $
* from: @(#)ns_if.h 8.1 (Berkeley) 6/10/93
* $Id: ns_if.h,v 1.4 1994/05/13 06:11:16 mycroft Exp $
*/
#ifndef _NETNS_NS_IF_H_
#define _NETNS_NS_IF_H_
/*
* Interface address, xerox version. One of these structures
* is allocated for each interface with an internet address.
@ -48,8 +45,6 @@ struct ns_ifaddr {
struct ifaddr ia_ifa; /* protocol-independent info */
#define ia_ifp ia_ifa.ifa_ifp
#define ia_flags ia_ifa.ifa_flags
/* union ns_net ia_net; /* network number of interface */
#define ia_net ia_addr.sns_addr.x_net
struct ns_ifaddr *ia_next; /* next in list of xerox addresses */
struct sockaddr_ns ia_addr; /* reserve space for my address */
struct sockaddr_ns ia_dstaddr; /* space for my broadcast address */
@ -86,5 +81,3 @@ struct ns_ifaddr *ns_ifaddr;
struct ns_ifaddr *ns_iaonnetof();
struct ifqueue nsintrq; /* XNS input packet queue */
#endif
#endif /* !_NETNS_NS_IF_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_input.c 7.8 (Berkeley) 6/27/91
* $Id: ns_input.c,v 1.3 1993/12/18 00:44:29 mycroft Exp $
* from: @(#)ns_input.c 8.1 (Berkeley) 6/10/93
* $Id: ns_input.c,v 1.4 1994/05/13 06:11:18 mycroft Exp $
*/
#include <sys/param.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_ip.c 7.6 (Berkeley) 6/28/90
* $Id: ns_ip.c,v 1.7 1994/02/20 03:19:45 mycroft Exp $
* from: @(#)ns_ip.c 8.1 (Berkeley) 6/10/93
* $Id: ns_ip.c,v 1.8 1994/05/13 06:11:20 mycroft Exp $
*/
/*
@ -63,8 +63,6 @@
#include <netns/ns_if.h>
#include <netns/idp.h>
#include <machine/cpu.h>
struct ifnet_en {
struct ifnet ifen_ifnet;
struct route ifen_route;
@ -182,7 +180,7 @@ idpip_input(m, ifp)
}
ip = mtod(m, struct ip *);
if (ip->ip_hl > (sizeof (struct ip) >> 2)) {
ip_stripoptions(ip, (struct mbuf *)0);
ip_stripoptions(m, (struct mbuf *)0);
if (m->m_len < s) {
if ((m = m_pullup(m, s)) == 0) {
nsipif.if_ierrors++;
@ -290,7 +288,7 @@ nsipoutput(ifn, m, dst)
/*
* Output final datagram.
*/
error = ip_output(m, NULL, ro, SO_BROADCAST, NULL); /* XXX */
error = (ip_output(m, (struct mbuf *)0, ro, SO_BROADCAST, NULL));
if (error) {
ifn->ifen_ifnet.if_oerrors++;
ifn->ifen_ifnet.if_ierrors = error;

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_output.c 7.8 (Berkeley) 12/16/90
* $Id: ns_output.c,v 1.4 1994/01/20 18:17:02 deraadt Exp $
* from: @(#)ns_output.c 8.1 (Berkeley) 6/10/93
* $Id: ns_output.c,v 1.5 1994/05/13 06:11:21 mycroft Exp $
*/
#include <sys/param.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_pcb.c 7.11 (Berkeley) 6/27/91
* $Id: ns_pcb.c,v 1.3 1993/12/18 00:44:34 mycroft Exp $
* from: @(#)ns_pcb.c 8.1 (Berkeley) 6/10/93
* $Id: ns_pcb.c,v 1.4 1994/05/13 06:11:24 mycroft Exp $
*/
#include <sys/param.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_pcb.h 7.4 (Berkeley) 6/28/90
* $Id: ns_pcb.h,v 1.3 1993/05/20 04:36:00 cgd Exp $
* from: @(#)ns_pcb.h 8.1 (Berkeley) 6/10/93
* $Id: ns_pcb.h,v 1.4 1994/05/13 06:11:26 mycroft Exp $
*/
#ifndef _NETNS_NS_PCB_H_
#define _NETNS_NS_PCB_H_
/*
* Ns protocol interface control block.
*/
@ -82,5 +79,3 @@ struct nspcb {
struct nspcb nspcb; /* head of list */
struct nspcb *ns_pcblookup();
#endif
#endif /* !_NETNS_NS_PCB_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)ns_proto.c 7.4 (Berkeley) 6/28/90
* $Id: ns_proto.c,v 1.3 1993/12/18 00:44:36 mycroft Exp $
* from: @(#)ns_proto.c 8.1 (Berkeley) 6/10/93
* $Id: ns_proto.c,v 1.4 1994/05/13 06:11:28 mycroft Exp $
*/
#include <sys/param.h>
@ -40,18 +40,21 @@
#include <sys/domain.h>
#include <sys/mbuf.h>
#include <net/radix.h>
#include <netns/ns.h>
/*
* NS protocol family: IDP, ERR, PE, SPP, ROUTE.
*/
int ns_init();
int idp_input(), idp_output(), idp_ctlinput(), idp_usrreq();
void ns_init();
int idp_output(), idp_usrreq();
void idp_input(), idp_ctlinput();
int idp_raw_usrreq(), idp_ctloutput();
int spp_input(), spp_ctlinput();
void spp_input(), spp_ctlinput();
int spp_usrreq(), spp_usrreq_sp(), spp_ctloutput();
int spp_init(), spp_fasttimo(), spp_slowtimo();
extern int raw_usrreq();
void spp_init(), spp_fasttimo(), spp_slowtimo();
int raw_usrreq();
extern struct domain nsdomain;
@ -90,5 +93,6 @@ struct protosw nssw[] = {
struct domain nsdomain =
{ AF_NS, "network systems", 0, 0, 0,
nssw, &nssw[sizeof(nssw)/sizeof(nssw[0])] };
nssw, &nssw[sizeof(nssw)/sizeof(nssw[0])], 0,
rn_inithead, 16, sizeof(struct sockaddr_ns)};

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)sp.h 7.4 (Berkeley) 6/28/90
* $Id: sp.h,v 1.3 1993/05/20 04:36:04 cgd Exp $
* from: @(#)sp.h 8.1 (Berkeley) 6/10/93
* $Id: sp.h,v 1.4 1994/05/13 06:11:29 mycroft Exp $
*/
#ifndef _NETNS_SP_H_
#define _NETNS_SP_H_
/*
* Definitions for Xerox NS style sequenced packet protocol
*/
@ -54,5 +51,3 @@ struct sphdr {
u_short sp_ack; /* acknowledge number */
u_short sp_alo; /* allocation number */
};
#endif /* !_NETNS_SP_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)spidp.h 7.4 (Berkeley) 6/28/90
* $Id: spidp.h,v 1.3 1993/05/20 04:36:05 cgd Exp $
* from: @(#)spidp.h 8.1 (Berkeley) 6/10/93
* $Id: spidp.h,v 1.4 1994/05/13 06:11:30 mycroft Exp $
*/
#ifndef _NETNS_SPIDP_H_
#define _NETNS_SPIDP_H_
/*
* Definitions for NS(tm) Internet Datagram Protocol
* containing a Sequenced Packet Protocol packet.
@ -64,5 +61,3 @@ struct spidp_q {
#define si_seq si_s.sp_seq
#define si_ack si_s.sp_ack
#define si_alo si_s.sp_alo
#endif /* !_NETNS_SPIDP_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)spp_debug.c 7.7 (Berkeley) 6/28/90
* $Id: spp_debug.c,v 1.3 1993/12/18 00:44:38 mycroft Exp $
* from: @(#)spp_debug.c 8.1 (Berkeley) 6/10/93
* $Id: spp_debug.c,v 1.4 1994/05/13 06:11:32 mycroft Exp $
*/
#include <sys/param.h>
@ -44,7 +44,6 @@
#include <net/route.h>
#include <net/if.h>
#include <netinet/tcp_fsm.h>
#include <netns/ns.h>

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)spp_debug.h 7.4 (Berkeley) 6/28/90
* $Id: spp_debug.h,v 1.3 1993/05/20 04:36:07 cgd Exp $
* from: @(#)spp_debug.h 8.1 (Berkeley) 6/10/93
* $Id: spp_debug.h,v 1.4 1994/05/13 06:11:33 mycroft Exp $
*/
#ifndef _NETNS_SPP_DEBUG_H_
#define _NETNS_SPP_DEBUG_H_
struct spp_debug {
u_long sd_time;
short sd_act;
@ -61,5 +58,3 @@ char *sanames[] =
#define SPP_NDEBUG 100
struct spp_debug spp_debug[SPP_NDEBUG];
int spp_debx;
#endif /* !_NETNS_SPP_DEBUG_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)spp_timer.h 7.3 (Berkeley) 6/28/90
* $Id: spp_timer.h,v 1.3 1993/05/20 04:36:08 cgd Exp $
* from: @(#)spp_timer.h 8.1 (Berkeley) 6/10/93
* $Id: spp_timer.h,v 1.4 1994/05/13 06:11:34 mycroft Exp $
*/
#ifndef _NETNS_SPP_TIMER_H_
#define _NETNS_SPP_TIMER_H_
/*
* Definitions of the SPP timers. These timers are counted
* down PR_SLOWHZ times a second.
@ -124,5 +121,3 @@ char *spptimers[] =
#ifdef KERNEL
extern int spp_backoff[];
#endif
#endif /* !_NETNS_SPP_TIMER_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,8 +30,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)spp_usrreq.c 7.15 (Berkeley) 6/27/91
* $Id: spp_usrreq.c,v 1.3 1993/12/18 00:44:43 mycroft Exp $
* from: @(#)spp_usrreq.c 8.1 (Berkeley) 6/10/93
* $Id: spp_usrreq.c,v 1.4 1994/05/13 06:11:36 mycroft Exp $
*/
#include <sys/param.h>
@ -45,7 +45,6 @@
#include <net/if.h>
#include <net/route.h>
#include <netinet/tcp_fsm.h>
#include <netns/ns.h>
@ -1803,4 +1802,4 @@ spp_timers(cb, timer)
#ifndef lint
int SppcbSize = sizeof (struct sppcb);
int NspcbSize = sizeof (struct nspcb);
#endif lint
#endif /* lint */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1984, 1985, 1986, 1987 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1984, 1985, 1986, 1987, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)spp_var.h 7.7 (Berkeley) 6/28/90
* $Id: spp_var.h,v 1.2 1993/05/21 07:44:05 cgd Exp $
* from: @(#)spp_var.h 8.1 (Berkeley) 6/10/93
* $Id: spp_var.h,v 1.3 1994/05/13 06:11:39 mycroft Exp $
*/
#ifndef _NETNS_SPP_VAR_H_
#define _NETNS_SPP_VAR_H_
/*
* Sp control block, one per connection
*/
@ -217,5 +214,3 @@ short xnsCbug;
#define SSEQ_GT(a,b) (((short)((a)-(b))) > 0)
#define SSEQ_GEQ(a,b) (((short)((a)-(b))) >= 0)
#endif
#endif /* !_NETNS_SPP_VAR_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,28 +30,32 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)domain.h 7.4 (Berkeley) 6/28/90
* $Id: domain.h,v 1.3 1993/05/20 16:22:08 cgd Exp $
* from: @(#)domain.h 8.1 (Berkeley) 6/2/93
* $Id: domain.h,v 1.4 1994/05/13 06:12:04 mycroft Exp $
*/
#ifndef _SYS_DOMAIN_H_
#define _SYS_DOMAIN_H_
/*
* Structure per communications domain.
*/
struct mbuf;
struct domain {
int dom_family; /* AF_xxx */
char *dom_name;
int (*dom_init)(); /* initialize domain data structures */
int (*dom_externalize)(); /* externalize access rights */
int (*dom_dispose)(); /* dispose of internalized rights */
void (*dom_init) /* initialize domain data structures */
__P((void));
int (*dom_externalize) /* externalize access rights */
__P((struct mbuf *));
int (*dom_dispose) /* dispose of internalized rights */
__P((struct mbuf *));
struct protosw *dom_protosw, *dom_protoswNPROTOSW;
struct domain *dom_next;
int (*dom_rtattach) /* initialize routing table */
__P((void **, int));
int dom_rtoffset; /* an arg to rtattach, in bits */
int dom_maxrtkey; /* for routing layer */
};
#ifdef KERNEL
struct domain *domains;
#endif
#endif /* !_SYS_DOMAIN_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1982, 1986, 1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1988, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)mbuf.h 7.14 (Berkeley) 12/5/90
* $Id: mbuf.h,v 1.6 1994/04/15 05:10:31 deraadt Exp $
* from: @(#)mbuf.h 8.3 (Berkeley) 1/21/94
* $Id: mbuf.h,v 1.7 1994/05/13 06:12:05 mycroft Exp $
*/
#ifndef _SYS_MBUF_H_
#define _SYS_MBUF_H_
#ifndef M_WAITOK
#include <sys/malloc.h>
#endif
@ -149,12 +146,21 @@ struct mbuf {
#define M_WAIT M_WAITOK
/*
* mbuf allocation/deallocation macros:
* mbuf utility macros:
*
* MBUFLOCK(code)
* lock out network interrupt drivers for duration of this particular
* operation
*
* prevents a section of code from from being interrupted by network
* drivers.
*/
#define MBUFLOCK(code) \
{ int ms = splimp(); \
{ code } \
splx(ms); \
}
/*
* mbuf allocation/deallocation macros:
*
* MGET(struct mbuf *m, int how, int type)
* allocates an mbuf and initializes it to contain internal data.
*
@ -162,13 +168,6 @@ struct mbuf {
* allocates an mbuf and initializes it to contain a packet header
* and internal data.
*/
#define MBUFLOCK(code) \
{ \
int ms = splimp(); \
{ code } \
splx(ms); \
}
#define MGET(m, how, type) { \
MALLOC((m), struct mbuf *, MSIZE, mbtypes[type], (how)); \
if (m) { \
@ -233,7 +232,7 @@ union mcluster {
}
#define MCLFREE(p) \
MBUFLOCK( \
MBUFLOCK ( \
if (--mclrefcnt[mtocl(p)] == 0) { \
((union mcluster *)(p))->mcl_next = mclfree; \
mclfree = (union mcluster *)(p); \
@ -357,40 +356,48 @@ struct mbstat {
extern struct mbuf *mbutl; /* virtual address of mclusters */
extern char *mclrefcnt; /* cluster reference counts */
struct mbstat mbstat;
int nmbclusters;
extern int nmbclusters;
union mcluster *mclfree;
int max_linkhdr; /* largest link-level header */
int max_protohdr; /* largest protocol header */
int max_hdr; /* largest link+protocol header */
int max_datalen; /* MHLEN - max_hdr */
struct mbuf *m_get(), *m_gethdr(), *m_getclr(), *m_retry(), *m_retryhdr();
struct mbuf *m_free(), *m_copym(), *m_pullup(), *m_prepend();
int m_clalloc();
extern int mbtypes[]; /* XXX */
#ifdef MBTYPES
int mbtypes[] = { /* XXX */
M_FREE, /* MT_FREE 0 * should be on free list */
M_MBUF, /* MT_DATA 1 * dynamic (data) allocation */
M_MBUF, /* MT_HEADER 2 * packet header */
M_SOCKET, /* MT_SOCKET 3 * socket structure */
M_PCB, /* MT_PCB 4 * protocol control block */
M_RTABLE, /* MT_RTABLE 5 * routing tables */
M_HTABLE, /* MT_HTABLE 6 * IMP host tables */
0, /* MT_ATABLE 7 * address resolution tables */
M_MBUF, /* MT_SONAME 8 * socket name */
0, /* 9 */
M_SOOPTS, /* MT_SOOPTS 10 * socket options */
M_FTABLE, /* MT_FTABLE 11 * fragment reassembly header */
M_MBUF, /* MT_RIGHTS 12 * access rights */
M_IFADDR, /* MT_IFADDR 13 * interface address */
M_MBUF, /* MT_CONTROL 14 * extra-data protocol message */
M_MBUF, /* MT_OOBDATA 15 * expedited data */
#ifdef DATAKIT
struct mbuf *m_copym __P((struct mbuf *, int, int, int));
struct mbuf *m_free __P((struct mbuf *));
struct mbuf *m_get __P((int, int));
struct mbuf *m_getclr __P((int, int));
struct mbuf *m_gethdr __P((int, int));
struct mbuf *m_prepend __P((struct mbuf *, int, int));
struct mbuf *m_pullup __P((struct mbuf *, int));
struct mbuf *m_retry __P((int, int));
struct mbuf *m_retryhdr __P((int, int));
int m_clalloc __P((int, int));
void m_copyback __P((struct mbuf *, int, int, caddr_t));
void m_freem __P((struct mbuf *));
#ifdef MBTYPES
int mbtypes[] = { /* XXX */
M_FREE, /* MT_FREE 0 should be on free list */
M_MBUF, /* MT_DATA 1 dynamic (data) allocation */
M_MBUF, /* MT_HEADER 2 packet header */
M_SOCKET, /* MT_SOCKET 3 socket structure */
M_PCB, /* MT_PCB 4 protocol control block */
M_RTABLE, /* MT_RTABLE 5 routing tables */
M_HTABLE, /* MT_HTABLE 6 IMP host tables */
0, /* MT_ATABLE 7 address resolution tables */
M_MBUF, /* MT_SONAME 8 socket name */
0, /* 9 */
M_SOOPTS, /* MT_SOOPTS 10 socket options */
M_FTABLE, /* MT_FTABLE 11 fragment reassembly header */
M_MBUF, /* MT_RIGHTS 12 access rights */
M_IFADDR, /* MT_IFADDR 13 interface address */
M_MBUF, /* MT_CONTROL 14 extra-data protocol message */
M_MBUF, /* MT_OOBDATA 15 expedited data */
#ifdef DATAKIT
25, 26, 27, 28, 29, 30, 31, 32 /* datakit ugliness */
#endif
};
#endif
#endif
#endif /* !_SYS_MBUF_H_ */

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 1982, 1986 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)protosw.h 7.8 (Berkeley) 4/28/91
* $Id: protosw.h,v 1.3 1993/05/20 16:22:52 cgd Exp $
* from: @(#)protosw.h 8.1 (Berkeley) 6/2/93
* $Id: protosw.h,v 1.4 1994/05/13 06:12:08 mycroft Exp $
*/
#ifndef _SYS_PROTOSW_H_
#define _SYS_PROTOSW_H_
/*
* Protocol switch table.
*
@ -65,17 +62,18 @@ struct protosw {
short pr_protocol; /* protocol number */
short pr_flags; /* see below */
/* protocol-protocol hooks */
int (*pr_input)(); /* input to protocol (from below) */
void (*pr_input)(); /* input to protocol (from below) */
int (*pr_output)(); /* output to protocol (from above) */
int (*pr_ctlinput)(); /* control input (from below) */
void (*pr_ctlinput)(); /* control input (from below) */
int (*pr_ctloutput)(); /* control output (from above) */
/* user-protocol hook */
int (*pr_usrreq)(); /* user request: see list below */
/* utility hooks */
int (*pr_init)(); /* initialization hook */
int (*pr_fasttimo)(); /* fast timeout (200ms) */
int (*pr_slowtimo)(); /* slow timeout (500ms) */
int (*pr_drain)(); /* flush any excess space possible */
void (*pr_init)(); /* initialization hook */
void (*pr_fasttimo)(); /* fast timeout (200ms) */
void (*pr_slowtimo)(); /* slow timeout (500ms) */
void (*pr_drain)(); /* flush any excess space possible */
int (*pr_sysctl)(); /* sysctl for protocol */
};
#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
@ -211,5 +209,3 @@ char *prcorequests[] = {
#ifdef KERNEL
extern struct protosw *pffindproto(), *pffindtype();
#endif
#endif /* !_SYS_PROTOSW_H_ */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1982,1985,1986,1988 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1985, 1986, 1988, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,12 +30,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)socket.h 7.13 (Berkeley) 4/20/91
* $Id: socket.h,v 1.7 1994/05/04 11:25:25 mycroft Exp $
* from: @(#)socket.h 8.4 (Berkeley) 2/21/94
* $Id: socket.h,v 1.8 1994/05/13 06:12:10 mycroft Exp $
*/
#ifndef _SYS_SOCKET_H_
#define _SYS_SOCKET_H_
#define _SYS_SOCKET_H_
/*
* Definitions related to sockets: types, address families, options.
@ -62,6 +62,7 @@
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
#define SO_LINGER 0x0080 /* linger on close if data present */
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
#define SO_REUSEPORT 0x0200 /* allow local address & port reuse */
/*
* Additional options, not kept in so_options.
@ -92,7 +93,8 @@ struct linger {
* Address families.
*/
#define AF_UNSPEC 0 /* unspecified */
#define AF_UNIX 1 /* local to host (pipes, portals) */
#define AF_LOCAL 1 /* local to host (pipes, portals) */
#define AF_UNIX AF_LOCAL /* backward compatibility */
#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
#define AF_IMPLINK 3 /* arpanet imp addresses */
#define AF_PUP 4 /* pup protocols: e.g. BSP */
@ -112,8 +114,14 @@ struct linger {
#define AF_ROUTE 17 /* Internal Routing Protocol */
#define AF_LINK 18 /* Link layer interface */
#define pseudo_AF_XTP 19 /* eXpress Transfer Protocol (no AF) */
#define AF_COIP 20 /* connection-oriented IP, aka ST II */
#define AF_CNT 21 /* Computer Network Technology */
#define pseudo_AF_RTIP 22 /* Help Identify RTIP packets */
#define AF_IPX 23 /* Novell Internet Protocol */
#define AF_SIP 24 /* Simple Internet Protocol */
#define pseudo_AF_PIP 25 /* Help Identify PIP packets */
#define AF_MAX 20
#define AF_MAX 26
/*
* Structure used by kernel to store most
@ -138,7 +146,8 @@ struct sockproto {
* Protocol families, same as address families for now.
*/
#define PF_UNSPEC AF_UNSPEC
#define PF_UNIX AF_UNIX
#define PF_LOCAL AF_LOCAL
#define PF_UNIX PF_LOCAL /* backward compatibility */
#define PF_INET AF_INET
#define PF_IMPLINK AF_IMPLINK
#define PF_PUP AF_PUP
@ -158,9 +167,74 @@ struct sockproto {
#define PF_ROUTE AF_ROUTE
#define PF_LINK AF_LINK
#define PF_XTP pseudo_AF_XTP /* really just proto family, no AF */
#define PF_COIP AF_COIP
#define PF_CNT AF_CNT
#define PF_SIP AF_SIP
#define PF_IPX AF_IPX /* same format as AF_NS */
#define PF_RTIP pseudo_AF_FTIP /* same format as AF_INET */
#define PF_PIP pseudo_AF_PIP
#define PF_MAX AF_MAX
/*
* Definitions for network related sysctl, CTL_NET.
*
* Second level is protocol family.
* Third level is protocol number.
*
* Further levels are defined by the individual families below.
*/
#define NET_MAXID AF_MAX
#define CTL_NET_NAMES { \
{ 0, 0 }, \
{ "unix", CTLTYPE_NODE }, \
{ "inet", CTLTYPE_NODE }, \
{ "implink", CTLTYPE_NODE }, \
{ "pup", CTLTYPE_NODE }, \
{ "chaos", CTLTYPE_NODE }, \
{ "xerox_ns", CTLTYPE_NODE }, \
{ "iso", CTLTYPE_NODE }, \
{ "emca", CTLTYPE_NODE }, \
{ "datakit", CTLTYPE_NODE }, \
{ "ccitt", CTLTYPE_NODE }, \
{ "ibm_sna", CTLTYPE_NODE }, \
{ "decnet", CTLTYPE_NODE }, \
{ "dec_dli", CTLTYPE_NODE }, \
{ "lat", CTLTYPE_NODE }, \
{ "hylink", CTLTYPE_NODE }, \
{ "appletalk", CTLTYPE_NODE }, \
{ "route", CTLTYPE_NODE }, \
{ "link_layer", CTLTYPE_NODE }, \
{ "xtp", CTLTYPE_NODE }, \
{ "coip", CTLTYPE_NODE }, \
{ "cnt", CTLTYPE_NODE }, \
{ "rtip", CTLTYPE_NODE }, \
{ "ipx", CTLTYPE_NODE }, \
{ "sip", CTLTYPE_NODE }, \
{ "pip", CTLTYPE_NODE }, \
}
/*
* PF_ROUTE - Routing table
*
* Three additional levels are defined:
* Fourth: address family, 0 is wildcard
* Fifth: type of info, defined below
* Sixth: flag(s) to mask with for NET_RT_FLAGS
*/
#define NET_RT_DUMP 1 /* dump; may limit to a.f. */
#define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */
#define NET_RT_IFLIST 3 /* survey interface list */
#define NET_RT_MAXID 4
#define CTL_NET_RT_NAMES { \
{ 0, 0 }, \
{ "dump", CTLTYPE_STRUCT }, \
{ "flags", CTLTYPE_STRUCT }, \
{ "iflist", CTLTYPE_STRUCT }, \
}
/*
* Maximum queue length specifiable by listen.
*/
@ -187,6 +261,7 @@ struct msghdr {
#define MSG_TRUNC 0x10 /* data discarded before delivery */
#define MSG_CTRUNC 0x20 /* control data lost before delivery */
#define MSG_WAITALL 0x40 /* wait for full request or error */
#define MSG_DONTWAIT 0x80 /* this message should be nonblocking */
/*
* Header for ancillary data objects in msg_control buffer.
@ -201,10 +276,10 @@ struct cmsghdr {
/* followed by u_char cmsg_data[]; */
};
/* given pointer to struct adatahdr, return pointer to data */
/* given pointer to struct cmsghdr, return pointer to data */
#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1))
/* given pointer to struct adatahdr, return pointer to next adatahdr */
/* given pointer to struct cmsghdr, return pointer to next cmsghdr */
#define CMSG_NXTHDR(mhdr, cmsg) \
(((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \
(mhdr)->msg_control + (mhdr)->msg_controllen) ? \
@ -248,13 +323,13 @@ int getpeername __P((int, struct sockaddr *, int *));
int getsockname __P((int, struct sockaddr *, int *));
int getsockopt __P((int, int, int, void *, int *));
int listen __P((int, int));
int recv __P((int, void *, int, int));
int recvfrom __P((int, void *, int, int,
struct sockaddr *, int *));
int recvmsg __P((int, struct msghdr *, int));
int send __P((int, const void *, int, int));
int sendto __P((int, const void *, int, int, const struct sockaddr *, int));
int sendmsg __P((int, const struct msghdr *, int));
ssize_t recv __P((int, void *, size_t, int));
ssize_t recvfrom __P((int, void *, size_t, int, struct sockaddr *, int *));
ssize_t recvmsg __P((int, struct msghdr *, int));
ssize_t send __P((int, const void *, size_t, int));
ssize_t sendto __P((int, const void *,
size_t, int, const struct sockaddr *, int));
ssize_t sendmsg __P((int, const struct msghdr *, int));
int setsockopt __P((int, int, int, const void *, int));
int shutdown __P((int, int));
int socket __P((int, int, int));
@ -262,5 +337,4 @@ int socketpair __P((int, int, int, int *));
__END_DECLS
#endif /* !KERNEL */
#endif /* !_SYS_SOCKET_H_ */

View File

@ -1,6 +1,6 @@
/*-
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)socketvar.h 7.17 (Berkeley) 5/5/91
* $Id: socketvar.h,v 1.7 1994/05/04 11:25:27 mycroft Exp $
* from: @(#)socketvar.h 8.1 (Berkeley) 6/2/93
* $Id: socketvar.h,v 1.8 1994/05/13 06:12:12 mycroft Exp $
*/
#ifndef _SYS_SOCKETVAR_H_
#define _SYS_SOCKETVAR_H_
#include <sys/select.h> /* for struct selinfo */
/*
@ -83,21 +80,22 @@ struct socket {
u_long sb_mbmax; /* max chars of mbufs to use */
long sb_lowat; /* low water mark */
struct mbuf *sb_mb; /* the mbuf chain */
struct selinfo sb_sel; /* process selecting read/write */
struct selinfo sb_sel; /* process selecting read/write */
short sb_flags; /* flags, see below */
short sb_timeo; /* timeout for read/write */
} so_rcv, so_snd;
#define SB_MAX (64*1024) /* default for max chars in sockbuf */
#define SB_MAX (256*1024) /* default for max chars in sockbuf */
#define SB_LOCK 0x01 /* lock on data queue */
#define SB_WANT 0x02 /* someone is waiting to lock */
#define SB_WAIT 0x04 /* someone is waiting for data/space */
#define SB_SEL 0x08 /* someone is selecting */
#define SB_ASYNC 0x10 /* ASYNC I/O, need signals */
#define SB_NOTIFY (SB_WAIT|SB_SEL|SB_ASYNC)
/* was SB_COLL 0x20 * collision selecting */
#define SB_NOINTR 0x40 /* operations not interruptible */
caddr_t so_tpcb; /* Wisc. protocol control block XXX */
void (*so_upcall) __P((struct socket *so, caddr_t arg, int waitf));
caddr_t so_upcallarg; /* Arg for above */
};
/*
@ -170,8 +168,9 @@ struct socket {
* Unless SB_NOINTR is set on sockbuf, sleep is interruptible.
* Returns error without lock if sleep is interrupted.
*/
#define sblock(sb) ((sb)->sb_flags & SB_LOCK ? sb_lock(sb) : \
((sb)->sb_flags |= SB_LOCK, 0))
#define sblock(sb, wf) ((sb)->sb_flags & SB_LOCK ? \
(((wf) == M_WAITOK) ? sb_lock(sb) : EWOULDBLOCK) : \
((sb)->sb_flags |= SB_LOCK), 0)
/* release lock on sockbuf sb */
#define sbunlock(sb) { \
@ -182,13 +181,18 @@ struct socket {
} \
}
#define sorwakeup(so) sowakeup((so), &(so)->so_rcv)
#define sorwakeup(so) { sowakeup((so), &(so)->so_rcv); \
if ((so)->so_upcall) \
(*((so)->so_upcall))((so), (so)->so_upcallarg, M_DONTWAIT); \
}
#define sowwakeup(so) sowakeup((so), &(so)->so_snd)
#ifdef KERNEL
u_long sb_max;
/* to catch callers missing new second argument to sonewconn: */
#define sonewconn(head, connstatus) sonewconn1((head), (connstatus))
struct socket *sonewconn1 __P((struct socket *head, int connstatus));
/* strings for sleep message: */
extern char netio[], netcon[], netcls[];
@ -253,7 +257,4 @@ int sosetopt __P((struct socket *so, int level, int optname,
struct mbuf *m0));
int soshutdown __P((struct socket *so, int how));
void sowakeup __P((struct socket *so, struct sockbuf *sb));
#endif
#endif /* !_SYS_SOCKETVAR_H_ */
#endif /* KERNEL */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)un.h 7.7 (Berkeley) 6/28/90
* $Id: un.h,v 1.5 1994/05/04 09:08:33 mycroft Exp $
* from: @(#)un.h 8.1 (Berkeley) 6/2/93
* $Id: un.h,v 1.6 1994/05/13 06:12:14 mycroft Exp $
*/
#ifndef _SYS_UN_H_
#define _SYS_UN_H_
/*
* Definitions for UNIX IPC domain.
*/
@ -47,8 +44,7 @@ struct sockaddr_un {
};
#ifdef KERNEL
#include <sys/unpcb.h>
struct unpcb;
int uipc_usrreq __P((struct socket *so, int req, struct mbuf *m,
struct mbuf *nam, struct mbuf *control));
@ -69,6 +65,4 @@ void unp_shutdown __P((struct unpcb *unp));
/* actual length of an initialized sockaddr_un */
#define SUN_LEN(su) \
(sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path))
#endif
#endif /* !_SYS_UN_H_ */
#endif /* KERNEL */

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1982, 1986, 1989 Regents of the University of California.
* All rights reserved.
* Copyright (c) 1982, 1986, 1989, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,13 +30,10 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)unpcb.h 7.6 (Berkeley) 6/28/90
* $Id: unpcb.h,v 1.3 1993/05/20 16:23:43 cgd Exp $
* from: @(#)unpcb.h 8.1 (Berkeley) 6/2/93
* $Id: unpcb.h,v 1.4 1994/05/13 06:12:15 mycroft Exp $
*/
#ifndef _SYS_UNPCB_H_
#define _SYS_UNPCB_H_
/*
* Protocol control block for an active
* instance of a UNIX internal protocol.
@ -75,5 +72,3 @@ struct unpcb {
};
#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
#endif /* !_SYS_UNPCB_H_ */