Commit 1616435b authored by Neil Turton's avatar Neil Turton
Browse files

Import from SrcFiler

parents
| Copyright 1996 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine clean
| Copyright 1996 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
wimpslot 4000k
amu_machine all
| Copyright 1996 Acorn Computers Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
wimpslot 5000k
amu_machine rom
hdr/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
**/s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
**/c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
**/h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
&208: TEQP PC,#C -> TEQ PC,#C :OR: SVC
&234: TEQP PC,#0 -> TEQ PC,#SVC
&260: TEQP PC,#V -> TEQ PC,#V :OR: SVC
&284: TEQP PC,#V -> TEQ PC,#V :OR: SVC
File added
File added
File added
The included BlockDriver binaries are provided courtesy of The Serial Port.
They are in the public domain and are freely distributable.
Some code is distributed under the Prior BSD License:
Copyright (c) 1987 Regents of the University of California.
Copyright (c) 1989 Carnegie Mellon University.
Copyright (c) 1991 Gregory M. Christy
Copyright (c) 1993 The Australian National University.
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the author. The name of the author may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Some code is distributed under the Original BSD License:
Copyright (c) 1989 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.
Some code is distributed under the MIT License:
Copyright (c) 1989 John Bowler
Copyright (c) 1990 Acorn Computers Ltd
Copyright (c) 1992 Hugo Fiennes
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Some code is distributed under the following MIT-like license:
Copyright (c) 1994 The Australian National University.
All rights reserved.
Permission to use, copy, modify, and distribute this software and its
documentation is hereby granted, provided that the above copyright
notice appears in all copies. This software is provided without any
warranty, express or implied. The Australian National University
makes no representations about the suitability of this software for
any purpose.
IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
OR MODIFICATIONS.
Some code is distributed under the following license:
Copyright (C) 1990, RSA Data Security, Inc. All rights reserved.
License to copy and use this software is granted provided that
it is identified as the "RSA Data Security, Inc. MD5 Message-
Digest Algorithm" in all material mentioning or referencing this
software or this function.
License is also granted to make and use derivative works
provided that such works are identified as "derived from the RSA
Data Security, Inc. MD5 Message-Digest Algorithm" in all
material mentioning or referencing the derived work.
RSA Data Security, Inc. makes no representations concerning
either the merchantability of this software or the suitability
of this software for any particular purpose. It is provided "as
is" without express or implied warranty of any kind.
These notices must be retained in any copies of any part of this
documentation and/or software.
Some source code is distributed under the Apache License:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
# Copyright 1996 Acorn Computers Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Makefile for PPP
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 16-Jul-96 SMC Created
#
# Paths
#
EXP_HDR = <export$dir>
#
# Generic options:
#
MKDIR = cdir
AS = objasm -tb
CC = cc
CMHG = cmhg
CP = copy
LD = link
RM = remove
MODSQZ = modsqz
WIPE = -wipe
CD = dir
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
#
# Include files
#
INCLUDES= TCPIPLibs:,C:
#
# Program specific options:
#
COMPONENT = PPP
TARGET = rm.PPP
ROMTARGET = aof.PPP
# You may want to link with TinyStubs. if you do, set LD to tlink and
# uncomment this TINYSTUBS, and comment out the STUBS
TINYSTUBS= #-DTINYSTUBS
STUBS= C:o.Stubs
DEBUG= #-DDEBUG
CFLAGS= -pcc -ffh -zM -I${INCLUDES} -DINET ${DEBUG}\
-zps1 -depend !Depend -c -DVJC ${TINYSTUBS}
OBJS= o.if_ppp o.slcompress o.pppmodule \
o.serial o.mbuf o.ppphdr o.ppp_io o.blockdrive \
^.^.libs.socklib.socklibzm ^.^.libs.inetlib.inetlibzm \
^.^.libs.unixlib.unixlibzm #o.svcprint
#
# Rule patterns
#
.SUFFIXES: .o .s .c
.c.o:; $(CC) $(CFLAGS) -o $@ $<
.s.o:; $(AS) -o $@ $<
all: ${TARGET}
@echo ${COMPONENT}: all complete
#
# RISC OS ROM build rules:
#
rom: ${ROMTARGET}
@echo ${COMPONENT}: rom module built
export:
@echo ${COMPONENT}: export complete
install_rom: ${ROMTARGET}
${CP} ${ROMTARGET} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom module installed
clean:
$(WIPE) o.* $(WFLAGS)
$(WIPE) pppd.o.* $(WFLAGS)
$(WIPE) rm.* $(WFLAGS)
$(RM) link/sym
#
# Target
#
${TARGET}: $(OBJS) pppd
$(LD) -rmf -s link/sym -o rm.PPPu $(OBJS) $(STUBS) pppd.o.pppd
ModSqz rm.PPPu $@
#
# ROM Target
#
${ROMTARGET}: ${OBJS} pppd
${LD} -s link/sym -o $@ -aof ${OBJS} ${ROMCSTUBS} pppd.o.pppd
#
# Final link for the ROM Image (using given base address)
#
rom_link:
${MKDIR} linked
${MKDIR} map
${LD} -o linked.${COMPONENT} -map -bin -base ${ADDRESS} ${ROMTARGET} ${ABSSYM} > map.${COMPONENT}
truncate map.${COMPONENT} linked.${COMPONENT}
${CP} linked.${COMPONENT} ${LINKDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom_link complete
#
# Some rules that need explicitly declaring
#
pppd:
Dir pppd
Amu
Up
s.blockdrive:: Internal.Driver
o.ppphdr: cmhg.ppphdr
cmhg cmhg.ppphdr o.ppphdr h.ppphdr
# The following dependancies should make the files required from other build frameworks
^.^.libs.inetlib.inetlibzm :
${CD} ^.^.libs.inetlib
amu_machine inetlibzm
back
^.^.libs.socklib.socklibzm :
${CD} ^.^.libs.socklib
amu_machine socklibzm
back
^.^.libs.unixlib.unixlibzm :
${CD} ^.^.libs.unixlib
amu_machine unixlibzm
back
# Dynamic dependencies:
*
!.gitignore
This diff is collapsed.
/* Copyright 1996 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright(c) 1994 Acorn Computers Ltd., Cambridge, England
*
* $Log$
* Revision 1.1 94/12/02 11:39:04 kwelton
* Initial revision
*
*/
#include "kernel.h"
#include "swis.h"
#include "sys/param.h"
#include "sys/errno.h"
#include "sys/mbuf.h"
#include "netinet/if_ether.h"
#include "mbuf.h"
#ifdef DBGMBUF
static void df(char *s)
{
_kernel_swi_regs r;
_kernel_swi(OS_WriteI+4, &r, &r);
printf(s);
}
#endif
struct mbctl MBCTL =
{
0, /* opaque */
sizeof(struct mbctl), /* mbcsize */
MBUF_MANAGER_VERSION, /* mbcvers */
0ul, /* flags */
MINCONTIG, /* advminubs */
ETHERMTU, /* advmaxubs */
0, /* mincontig */
0ul, /* spare1 */
/*
* Rest of the structure gets initialised
* to zeroes due to the trailing comma
*/
};
/**********************************************************************/
_kernel_oserror *mb_entryinit(void)
{
return _swix(Mbuf_OpenSession, _IN(0), &MBCTL);
}
/**********************************************************************/
/*
* mb_present - check whether the mbuf manager is present or not,
* using the Mbuf_Control SWI to do so. returns 1 if manager
* present, else 0.
*/
int mb_present(void)
{
/*
* the control SWI with reason code 0 should *always*
* succeed if the mbuf manager is loaded.
*/
return(_swix(Mbuf_Control, _IN(0), 0) == NULL);
}
/**********************************************************************/
extern _kernel_oserror *mb_closesession(void)
{
return _swix(Mbuf_CloseSession, _IN(0), &MBCTL);
}
/**********************************************************************/
/* EOF mbuf.c */
/* Copyright 1996 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "kernel.h"
#include "swis.h"
#include <sys/syslog.h>
#include "socklib.h"
#include "if_ppp.h"
#include "pppif.h"
_kernel_oserror *pppif_getspeeds(int unit, const int **table, int *no_speeds)
{
const static int ro310_table[15]=
{75*2, 150*2, 300*2, 1200*2, 2400*2, 4800*2, 9600*2,
19200*2, 50*2, 110*2, (int)(134.5*2), 600*2, 1800*2,
3600*2, 7200*2};
_kernel_oserror *e;
e=_swix(ppp_softc[unit].sc_swino, _IN(0)|_OUTR(1,2), 9, table, no_speeds);
if (e)
{
if (e->errnum==0x13581) /* Unknown SerialOp */
{
/* Assume RISC OS 3.10 speeds */
e=0;
*table=ro310_table;
*no_speeds=15;
}
else
return e;
}
return 0;
}
_kernel_oserror *pppif_setspeed(int unit, int speed, int *oldspeed)
{
_kernel_oserror *e;
int flags=_INR(0,1);
if (oldspeed)
flags|=_OUT(1);
e=_swix(ppp_softc[unit].sc_swino, flags, 5, speed, oldspeed);
if (!e)
e=_swix(ppp_softc[unit].sc_swino, _INR(0,1), 6, speed);
return e;
}
_kernel_oserror *pppif_getspeed(int unit, int *speed)
{
return _swix(ppp_softc[unit].sc_swino, _INR(0,1)|_OUT(1), 5, -1, speed);
}
_kernel_oserror *pppif_setstatus(int unit, unsigned eor, unsigned and, unsigned *oldstatus)
{
int flags=_INR(0,2);
if (oldstatus)
flags|=_OUT(1);
return _swix(ppp_softc[unit].sc_swino, flags, 0, eor, and, oldstatus);
}
_kernel_oserror *pppif_setformat(int unit, int format, int *oldformat)
{
int flags=_INR(0,2);
if (oldformat)
flags|=_OUT(1);
return _swix(ppp_softc[unit].sc_swino, flags, 1, format, oldformat);
}
This diff is collapsed.
/* Copyright 1996 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
*
* $Log$
*/
#include <stdlib.h>
#include <stdio.h>
#include "errno.h"
#include "sys/types.h"
#include "sys/dcistructs.h"
#pragma no_warn_deprecated
#include "netinet/if_ether.h"
#include "sys/signal.h"
#include "sys/syslog.h"
#pragma warn_deprecated
#include "kernel.h"
#include "swis.h"
#include "ppp_io.h"
#include "pppmodule.h"
#include "blockdrive.h"
#include "if_ppp.h"
#include "pppd/main.h"
#include "serial.h"
#define TickerV 0x1C
extern int splhi(void);
extern void splx(int);
#define Event_OutputEmpty 0
#define Event_SerialError 7
#define SerialError_Overrun 0x10
#define SerialError_Framing 0x08
#define SerialError_DCD 0x02
int *driver_speedtable;
int driver_noofspeeds;
int serialevents_active;
static volatile u_char *framing_error;
extern void *module_wsp;
int poll_pending = 0;
int portnumber=0;
extern int poll_entry(void);
extern int event_entry(void);
extern int hupcheck_entry(void);
extern int hup_entry(void);
extern int term_entry(void);
/*
* iprelease - remove routine from InsV so we no longer catch serial
* input characters
*/
static void release_ticker(void)
{
_swix(OS_RemoveTickerEvent, _INR(0,1), hupcheck_entry, module_wsp);
_swix(OS_Release, _INR(0,2), TickerV, ticker_handler, module_wsp);
}
/**********************************************************************/
/*
* ipcatch - add routine to InsV to catch serial input characters
*/
static _kernel_oserror *claim_ticker(void)
{
_kernel_oserror *e=0;
e=_swix(OS_CallEvery, _INR(0,2), 99, hupcheck_entry, module_wsp);
if (e)
return e;
return _swix(OS_Claim, _INR(0,2), TickerV, ticker_handler, module_wsp);
}
/**********************************************************************/
int hupcheck_handler(_kernel_swi_regs *r, void *pw)
{
idle_time++;
if (modem && (driver_modemcontrol() & 8) == 0)
_swix(OS_AddCallBack, _INR(0,1), hup_entry, module_wsp);
else if (idle_time_limit && idle_time >= idle_time_limit)
_swix(OS_AddCallBack, _INR(0,1), term_entry, module_wsp);
return 1;
}
/**********************************************************************/
int hup_handler(_kernel_swi_regs *r, void *pw)
{
NOT_USED(pw);
NOT_USED(r);
pppd_signal_handler(SIGHUP);
return 1;
}
int term_handler(_kernel_swi_regs *r, void *pw)
{
NOT_USED(pw);
NOT_USED(r);
syslog(LOG_INFO, "Idle for %d seconds", idle_time_limit);
pppd_signal_handler(SIGTERM);
return 1;
}
void serial_enableevents(void)
{
serialevents_active=1;
}
/**********************************************************************/
/*
* poll_cancel - remove any pending call to poll_entry
*/
static void poll_cancel(void)
{
int s = splhi();
if( poll_pending )
{
_swix(OS_RemoveCallBack, _INR(0,1), poll_entry, module_wsp);
poll_pending = 0;
}
splx(s);
}
/**********************************************************************/
/* XXX Trace */
extern int rxerrors;
/*
* poll_handler - it is time to check whether there are any characters
* in the input buffer again. try to drain the buffer, then reset the
* timeout to call this routine again
*/
int poll_handler(_kernel_swi_regs *r, void *pw)
{
char buffer[256], *p=buffer;
int bytes, s, error;
NOT_USED(pw);
NOT_USED(r);
_kernel_irqs_on();
bytes=driver_getblock(buffer, sizeof buffer);
error=(driver_rxerrors() & 7);
while (bytes)
{
/*s=splhi();*/
p=buffer;
while (bytes)
{
pppinput(*p, 0);
bytes--;
p++;
}
if (error)
{
/*rxerrors++;*/
pppinput(256, 0);
}
/*splx(s);*/
bytes=driver_getblock(buffer, sizeof buffer);
error=(driver_rxerrors() & 7);
}
poll_pending = 0;
/*
* all done, return a non-zero value so
* cmhg veneers take the correct exit
*/
return 1;
}
/**********************************************************************/
_kernel_oserror *serial_finalise(void)
{
release_ticker();
poll_cancel();
driver_closedown();
return(NULL);
}
/**********************************************************************/
_kernel_oserror *serial_initialise(struct ppp_softc *sc)
{
char *error;
_kernel_oserror *e=0;
# ifdef TINYSTUBS
poll_pending=0;
portnumber=0;
# endif
error=driver_initialise();
if (error)
{
strcpy(_ppp_errblk.errmess, error);
_ppp_errblk.errnum = 1;
e=&_ppp_errblk;
}
if (!e)
e=claim_ticker();
driver_speedtable=driver_block+64;
return e;
}
/**********************************************************************/
/* EOF serial.c */
/*-
* Copyright (c) 1989 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.
*
* @(#)slcompress.c 7.7 (Berkeley) 5/7/91
*/
/*
* Routines to compress and uncompess tcp packets (for transmission
* over low speed serial lines.
*
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
* - Initial distribution.
*
* Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au,
* so that the entire packet being decompressed doesn't have
* to be in contiguous memory (just the compressed header).
*
* $Id$
*/
char *ack_sl="Copyright (c) 1989 The Regents of the University of California. "
"All rights reserved.";
#include <assert.h>
#include <string.h>
#include "sys/types.h"
#include "sys/param.h"
#include "sys/mbuf.h"
#include "sys/socketvar.h"
#include "inetlib.h"
#include "netinet/ip.h"
#include "netinet/tcp.h"
#include "kernel.h"
#include "mbuf.h"
#include "slcompress.h"
#ifndef SL_NO_STATS
#define INCR(counter) ++comp->counter;
#else
#define INCR(counter)
#endif
#define BCMP(p1, p2, n) memcmp((p1), (p2), (n))
#define BCOPY(p1, p2, n) memcpy((p2), (p1), (n))
#define ovbcopy(p1, p2, n) memmove((p2), (p1), (n))
#define bzero(p, n) memset((p), 0, (n))
void sl_compress_init(struct slcompress *comp)
{
register u_int i;
register struct cstate *tstate = comp->tstate;
bzero((char *)comp, sizeof(*comp));
for (i = MAX_STATES - 1; i > 0; --i) {
tstate[i].cs_id = i;
tstate[i].cs_next = &tstate[i - 1];
}
tstate[0].cs_next = &tstate[MAX_STATES - 1];
tstate[0].cs_id = 0;
comp->last_cs = &tstate[0];
comp->last_recv = 255;
comp->last_xmit = 255;
comp->flags = SLF_TOSS;
}
/*
* Like sl_compress_init, but we get to specify the maximum connection
* ID to use on transmission.
*/
void sl_compress_setup(struct slcompress *comp, int max_state)
{
register u_int i;
register struct cstate *tstate = comp->tstate;
if ((unsigned) max_state > MAX_STATES - 1)
max_state = MAX_STATES - 1;
bzero((char *)comp, sizeof(*comp));
for (i = max_state; i > 0; --i) {
tstate[i].cs_id = i;
tstate[i].cs_next = &tstate[i - 1];
}
tstate[0].cs_next = &tstate[max_state];
tstate[0].cs_id = 0;
comp->last_cs = &tstate[0];
comp->last_recv = 255;
comp->last_xmit = 255;
comp->flags = SLF_TOSS;
}
/* ENCODE encodes a number that is known to be non-zero. ENCODEZ
* checks for zero (since zero has to be encoded in the long, 3 byte
* form).
*/
#define ENCODE(n) { \
if ((u_short)(n) >= 256) { \
*cp++ = 0; \
cp[1] = (n); \
cp[0] = (n) >> 8; \
cp += 2; \
} else { \
*cp++ = (n); \
} \
}
#define ENCODEZ(n) { \
if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \
*cp++ = 0; \
cp[1] = (n); \
cp[0] = (n) >> 8; \
cp += 2; \
} else { \
*cp++ = (n); \
} \
}
#define DECODEL(f) { \
if (*cp == 0) {\
(f) = htonl(ntohl(f) + ((cp[1] << 8) | cp[2])); \
cp += 3; \
} else { \
(f) = htonl(ntohl(f) + (u_long)*cp++); \
} \
}
#define DECODES(f) { \
if (*cp == 0) {\
(f) = htons(ntohs(f) + ((cp[1] << 8) | cp[2])); \
cp += 3; \
} else { \
(f) = htons(ntohs(f) + (u_long)*cp++); \
} \
}
#define DECODEU(f) { \
if (*cp == 0) {\
(f) = htons((cp[1] << 8) | cp[2]); \
cp += 3; \
} else { \
(f) = htons((u_long)*cp++); \
} \
}
u_char sl_compress_tcp(struct mbuf *m, register struct ip *ip,
struct slcompress *comp, int compress_cid)
{
struct cstate *cs = comp->last_cs->cs_next;
u_int hlen = ip->ip_hl;
struct tcphdr *oth;
struct tcphdr *th;
u_int deltaS, deltaA;
u_int changes = 0;
u_char new_seq[16];
u_char *cp = new_seq;
/*
* Bail if this is an IP fragment or if the TCP packet isn't
* `compressible' (i.e., ACK isn't set or some other control bit is
* set). (We assume that the caller has already made sure the
* packet is IP proto TCP).
*/
if ((ip->ip_off & htons(0x3fff)) || m->m_len < 40)
return (TYPE_IP);
th = (struct tcphdr *)&((int *)ip)[hlen];
if ((th->th_flags & (TH_SYN|TH_FIN|TH_RST|TH_ACK)) != TH_ACK)
return (TYPE_IP);
/*
* Packet is compressible -- we're going to send either a
* COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need
* to locate (or create) the connection state. Special case the
* most recently used connection since it's most likely to be used
* again & we don't have to do any reordering if it's used.
*/
INCR(sls_packets)
if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr ||
ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr ||
*(int *)th != ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl]) {
/*
* Wasn't the first -- search for it.
*
* States are kept in a circularly linked list with
* last_cs pointing to the end of the list. The
* list is kept in lru order by moving a state to the
* head of the list whenever it is referenced. Since
* the list is short and, empirically, the connection
* we want is almost always near the front, we locate
* states via linear search. If we don't find a state
* for the datagram, the oldest state is (re-)used.
*/
struct cstate *lcs;
struct cstate *lastcs = comp->last_cs;
do {
lcs = cs; cs = cs->cs_next;
INCR(sls_searches)
if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr
&& ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr
&& *(int *)th == ((int *)&cs->cs_ip)[cs->cs_ip.ip_hl])
goto found;
} while (cs != lastcs);
/*
* Didn't find it -- re-use oldest cstate. Send an
* uncompressed packet that tells the other side what
* connection number we're using for this conversation.
* Note that since the state list is circular, the oldest
* state points to the newest and we only need to set
* last_cs to update the lru linkage.
*/
INCR(sls_misses)
comp->last_cs = lcs;
hlen += th->th_off;
hlen <<= 2;
if (hlen > m->m_len)
return (TYPE_IP);
goto uncompressed;
found:
/*
* Found it -- move to the front on the connection list.
*/
if (cs == lastcs)
comp->last_cs = lcs;
else {
lcs->cs_next = cs->cs_next;
cs->cs_next = lastcs->cs_next;
lastcs->cs_next = cs;
}
}
/*
* Make sure that only what we expect to change changed. The first
* line of the `if' checks the IP protocol version, header length &
* type of service. The 2nd line checks the "Don't fragment" bit.
* The 3rd line checks the time-to-live and protocol (the protocol
* check is unnecessary but costless). The 4th line checks the TCP
* header length. The 5th line checks IP options, if any. The 6th
* line checks TCP options, if any. If any of these things are
* different between the previous & current datagram, we send the
* current datagram `uncompressed'.
*/
oth = (struct tcphdr *)&((int *)&cs->cs_ip)[hlen];
deltaS = hlen;
hlen += th->th_off;
hlen <<= 2;
if (hlen > m->m_len)
return (TYPE_IP);
if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] ||
((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] ||
((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] ||
th->th_off != oth->th_off ||
(deltaS > 5 &&
BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) ||
(th->th_off > 5 &&
BCMP(th + 1, oth + 1, (th->th_off - 5) << 2)))
goto uncompressed;
/*
* Figure out which of the changing fields changed. The
* receiver expects changes in the order: urgent, window,
* ack, seq (the order minimizes the number of temporaries
* needed in this section of code).
*/
if (th->th_flags & TH_URG) {
deltaS = ntohs(th->th_urp);
ENCODEZ(deltaS);
changes |= NEW_U;
} else if (th->th_urp != oth->th_urp)
/* argh! URG not set but urp changed -- a sensible
* implementation should never do this but RFC793
* doesn't prohibit the change so we have to deal
* with it. */
goto uncompressed;
if (deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) {
ENCODE(deltaS);
changes |= NEW_W;
}
if (deltaA = ntohl(th->th_ack) - ntohl(oth->th_ack)) {
if (deltaA > 0xffff)
goto uncompressed;
ENCODE(deltaA);
changes |= NEW_A;
}
if (deltaS = ntohl(th->th_seq) - ntohl(oth->th_seq)) {
if (deltaS > 0xffff)
goto uncompressed;
ENCODE(deltaS);
changes |= NEW_S;
}
switch(changes) {
case 0:
/*
* Nothing changed. If this packet contains data and the
* last one didn't, this is probably a data packet following
* an ack (normal on an interactive connection) and we send
* it compressed. Otherwise it's probably a retransmit,
* retransmitted ack or window probe. Send it uncompressed
* in case the other side missed the compressed version.
*/
if (ip->ip_len != cs->cs_ip.ip_len &&
ntohs(cs->cs_ip.ip_len) == hlen)
break;
/* (fall through) */
case SPECIAL_I:
case SPECIAL_D:
/*
* actual changes match one of our special case encodings --
* send packet uncompressed.
*/
goto uncompressed;
case NEW_S|NEW_A:
if (deltaS == deltaA &&
deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
/* special case for echoed terminal traffic */
changes = SPECIAL_I;
cp = new_seq;
}
break;
case NEW_S:
if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) {
/* special case for data xfer */
changes = SPECIAL_D;
cp = new_seq;
}
break;
}
deltaS = ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id);
if (deltaS != 1) {
ENCODEZ(deltaS);
changes |= NEW_I;
}
if (th->th_flags & TH_PUSH)
changes |= TCP_PUSH_BIT;
/*
* Grab the cksum before we overwrite it below. Then update our
* state with this packet's header.
*/
deltaA = ntohs(th->th_sum);
BCOPY(ip, &cs->cs_ip, hlen);
/*
* We want to use the original packet as our compressed packet.
* (cp - new_seq) is the number of bytes we need for compressed
* sequence numbers. In addition we need one byte for the change
* mask, one for the connection id and two for the tcp checksum.
* So, (cp - new_seq) + 4 bytes of header are needed. hlen is how
* many bytes of the original packet to toss so subtract the two to
* get the new packet size.
*/
deltaS = cp - new_seq;
cp = (u_char *)ip;
if (compress_cid == 0 || comp->last_xmit != cs->cs_id) {
comp->last_xmit = cs->cs_id;
hlen -= deltaS + 4;
cp += hlen;
*cp++ = changes | NEW_C;
*cp++ = cs->cs_id;
} else {
hlen -= deltaS + 3;
cp += hlen;
*cp++ = changes;
}
m->m_len -= hlen;
m->m_off += hlen;
*cp++ = deltaA >> 8;
*cp++ = deltaA;
BCOPY(new_seq, cp, deltaS);
INCR(sls_compressed)
return (TYPE_COMPRESSED_TCP);
/*
* Update connection state cs & send uncompressed packet ('uncompressed'
* means a regular ip/tcp packet but with the 'conversation id' we hope
* to use on future compressed packets in the protocol field).
*/
uncompressed:
BCOPY(ip, &cs->cs_ip, hlen);
ip->ip_p = cs->cs_id;
comp->last_xmit = cs->cs_id;
return (TYPE_UNCOMPRESSED_TCP);
}
int sl_uncompress_tcp(u_char **bufp, int len, u_int type, struct slcompress *comp)
{
return sl_uncompress_tcp_part(bufp, len, len, type, comp);
}
/*
* Uncompress a packet of total length total_len. The first buflen
* bytes are at *bufp; this must include the entire (compressed or
* uncompressed) TCP/IP header. In addition, there must be enough
* clear space before *bufp to build a full-length TCP/IP header.
*/
int sl_uncompress_tcp_part(u_char **bufp, int buflen, int total_len,
u_int type, struct slcompress *comp)
{
u_char *cp;
u_int hlen, changes;
struct tcphdr *th;
struct cstate *cs;
struct ip *ip;
switch (type) {
case TYPE_UNCOMPRESSED_TCP:
ip = (struct ip *) *bufp;
if (ip->ip_p >= MAX_STATES)
goto bad;
cs = &comp->rstate[comp->last_recv = ip->ip_p];
comp->flags &=~ SLF_TOSS;
ip->ip_p = IPPROTO_TCP;
hlen = ip->ip_hl;
hlen += ((struct tcphdr *)&((int *)ip)[hlen])->th_off;
hlen <<= 2;
BCOPY(ip, &cs->cs_ip, hlen);
cs->cs_ip.ip_sum = 0;
cs->cs_hlen = hlen;
INCR(sls_uncompressedin)
return (total_len);
default:
goto bad;
case TYPE_COMPRESSED_TCP:
break;
}
/* We've got a compressed packet. */
INCR(sls_compressedin)
cp = *bufp;
changes = *cp++;
if (changes & NEW_C) {
/* Make sure the state index is in range, then grab the state.
* If we have a good state index, clear the 'discard' flag. */
if (*cp >= MAX_STATES)
goto bad;
comp->flags &=~ SLF_TOSS;
comp->last_recv = *cp++;
} else {
/* this packet has an implicit state index. If we've
* had a line error since the last time we got an
* explicit state index, we have to toss the packet. */
if (comp->flags & SLF_TOSS) {
INCR(sls_tossed)
return (0);
}
}
cs = &comp->rstate[comp->last_recv];
hlen = cs->cs_ip.ip_hl << 2;
th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen];
th->th_sum = htons((*cp << 8) | cp[1]);
cp += 2;
if (changes & TCP_PUSH_BIT)
th->th_flags |= TH_PUSH;
else
th->th_flags &=~ TH_PUSH;
switch (changes & SPECIALS_MASK) {
case SPECIAL_I:
{
register u_int i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen;
th->th_ack = htonl(ntohl(th->th_ack) + i);
th->th_seq = htonl(ntohl(th->th_seq) + i);
}
break;
case SPECIAL_D:
th->th_seq = htonl(ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len)
- cs->cs_hlen);
break;
default:
if (changes & NEW_U) {
th->th_flags |= TH_URG;
DECODEU(th->th_urp)
} else
th->th_flags &=~ TH_URG;
if (changes & NEW_W)
DECODES(th->th_win)
if (changes & NEW_A)
DECODEL(th->th_ack)
if (changes & NEW_S)
DECODEL(th->th_seq)
break;
}
if (changes & NEW_I) {
DECODES(cs->cs_ip.ip_id)
} else
cs->cs_ip.ip_id = htons(ntohs(cs->cs_ip.ip_id) + 1);
/*
* At this point, cp points to the first byte of data in the
* packet. If we're not aligned on a 4-byte boundary, copy the
* data down so the ip & tcp headers will be aligned. Then back up
* cp by the tcp/ip header length to make room for the reconstructed
* header (we assume the packet we were handed has enough space to
* prepend 128 bytes of header). Adjust the length to account for
* the new header & fill in the IP total length.
*/
buflen -= (cp - *bufp);
total_len -= (cp - *bufp);
if (buflen < 0)
/* we must have dropped some characters (crc should detect
* this but the old slip framing won't) */
goto bad;
if ((int)cp & 3) {
if (buflen > 0)
(void) ovbcopy(cp, (caddr_t)((int)cp &~ 3), buflen);
cp = (u_char *)((int)cp &~ 3);
}
cp -= cs->cs_hlen;
total_len += cs->cs_hlen;
cs->cs_ip.ip_len = htons(total_len);
BCOPY(&cs->cs_ip, cp, cs->cs_hlen);
*bufp = cp;
/* recompute the ip header checksum */
{
register u_short *bp = (u_short *)cp;
for (changes = 0; hlen > 0; hlen -= 2)
changes += *bp++;
changes = (changes & 0xffff) + (changes >> 16);
changes = (changes & 0xffff) + (changes >> 16);
((struct ip *)cp)->ip_sum = ~ changes;
}
return (total_len);
bad:
comp->flags |= SLF_TOSS;
INCR(sls_errorin)
return (0);
}
/* Copyright 1996 Acorn Computers Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* -*-C-*-
*
* $Header$
* $Source$
*
* Copyright(c) 1994 Acorn Computers Ltd., Cambridge, England
*
* svcprint.c
*
* print debugging information down the TML tube link.
*
* provides:
* %s - string
* %C - character in range 20->7F (space printed if outside range)
* %c - any character
* %X - reverses order of bytes if >2 (or >4) specified as width
* %x - hex
* %B - reverses order of bytes if >2 (or >4) specified as width
* %b - binary
* %D - reverses order of bytes if >2 (or >4) specified as width
* %d - decimal
*
* field width can be specified by placing a decimal number after the "%"
* character... if the width is started by a "0" then numbers are padded
* with "0"...
*
* standard format specifiers o,u,e,f and g are NOT supported
*
* $Log$
* Revision 1.2 95/03/31 11:36:04 kwelton
* Added new debugging function ctosym().
*
* Revision 1.1 94/12/02 09:57:20 kwelton
* Initial revision
*
*/
#include "kernel.h"
#include "swis.h"
#include "svcdebug.h"
#include "sys/types.h"
#ifndef NULL
# define NULL ((void *)0)
#endif
#ifdef DEBUG
/*int debug = 1;*/
#endif
/**********************************************************************/
static unsigned short ntohs(unsigned short n)
{
return(((n << 8) & 0xff00) | ((n >> 8) & 0x00ff));
}
/**********************************************************************/
static unsigned long ntohl(unsigned long n)
{
return(((n >> 24) & 0x000000ff) | ((n >> 8) & 0x0000ff00) |
((n << 8) & 0x00ff0000) | ((n << 24) & 0xff000000) );
}
/**********************************************************************/
/*
* call processor mode independant character output routine
*/
static void oswrch(unsigned char ch)
{
_kernel_swi_regs regset;
/*
* use HostFS_WriteC (SWI 0x40102) to print the character
*/
regset.r[0] = ch;
(void)_kernel_swi(0x40102, &regset, &regset);
}
/**********************************************************************/
/*
* Printn prints a number n in base b, minimum width w adding pad chars
* if needed.
*/
static void printn(unsigned n, unsigned b, int w, char pad)
{
if( n >= b )
{
printn(n / b, b, --w, pad);
oswrch("0123456789abcdef"[n % b]);
}
else
{
while (--w > 0)
oswrch(pad);
oswrch("0123456789abcdef"[n]);
}
}
/**********************************************************************/
static void prf(char *format, unsigned *argp, ...)
{
register int b; /* base to be used when displaying numbers */
register int c; /* current character read from format string */
register int w; /* field width */
char pad; /* field padding character */
unsigned val; /* value of argument */
loop:
val = *argp;
w = 0;
pad = ' ';
while( (c = *format++) != '%' )
{
if( c == '\0' )
return;
if( c == '\n' )
oswrch('\r');
oswrch(c);
}
again:
/*
* we have a special format command
*/
c = *format++;
switch( c )
{
case 's':
{
/* string */
char *p = (char *)*argp++;
int width = 0;
if (p != NULL)
{
/* NOT a NULL pointer */
while (*p)
{
oswrch(*p++);
width++;
}
}
while( width++ < w )
oswrch(' ');
goto loop;
}
case 'C':
if( (*argp < ' ') || (*argp > '~') )
{
oswrch(' ');
argp++;
goto loop;
}
case 'c':
/* character */
oswrch(*argp++);
goto loop;
case '0':
if (w == 0)
pad = '0';
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* field width */
w = (w * 10) + ((int) c - '0');
goto again;
case 'X':
/* hex number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if (w > 2)
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'x':
/* hex number */
b = 16;
goto number;
case 'B':
/* binary number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if( w > 2 )
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'b':
/* binary number */
b = 2;
goto number;
case 'D':
/* decimal number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if (w > 2)
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'd':
b = 10;
/*
* NB
*
* fall through to write number
*/
number:
printn(val,b,w,pad);
argp++;
break;
} /* switch */
goto loop;
}
/**********************************************************************/
#if 0
# define USETUBE
#endif /* 0/1 */
void Printf(char *format, ...)
{
unsigned *argp = (unsigned *)&format;
static int inprf;
#ifdef USETUBE
_kernel_swi_regs reglist;
_kernel_oserror *err;
/* int s = splhi(); */
if( (err = _kernel_swi(0x40100, &reglist, &reglist)) != NULL )
{
prf("HostVDU: ", 0);
prf(err->errmess, 0);
/* splx(s); */
return;
}
#endif /* USETUBE */
/*int s = splhi();*/
if (inprf)
return;
inprf=1;
prf(format, (argp + 1));
inprf=0;
/*splx(s);*/
#ifdef USETUBE
if( (err = _kernel_swi(0x40101, &reglist, &reglist)) != NULL )
{
prf("TubeVDU: ", 0);
prf(err->errmess, 0);
/* splx(s); */
return;
}
/* splx(s); */
#endif /* USETUBE */
}
/**********************************************************************/
/* EOF svcprint.c */
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -*-Text-*-
;
; $Header$
; $Source$
;
; PPPHdr - cmhg header file for PPP module
;
; Copyright (c) 1995 Acorn Computers Ltd., Cambridge, England
;
; $Log$
;
title-string: PPP
help-string: PPP 1.11
initialisation-code: ppp_initialise
finalisation-code: ppp_quit
service-call-handler: ppp_sc_handler &9B, ; Service_EnumerateNetworkDrivers
&9F, ; Service_DCIProtocolStatus
&A2 ; Service_MbufManagerStatus
irq-handlers: poll_entry/poll_handler,
callb_entry/callb_handler,
timeout_entry/timeout_handler,
start_entry/start_handler,
hup_entry/hup_handler,
term_entry/term_handler,
hupcheck_entry/hupcheck_handler
swi-chunk-base-number: &4B600
swi-handler-code: ppp_swi_handler
swi-decoding-table: PPP,
DCIVersion Inquire GetNetworkMTU SetNetworkMTU,
Transmit Filter Stats,
07 08 09 0A 0B 0C 0D 0E 0F,
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F,
AutoDial Answering
;
; YUCK - need to mess around with internationalised help, but cannot
; use the automatic features added as part of RISC OS 3.5; cmhg's
; handling of this used to be broken - this *must* be build with cmhg
; version 4.55 or later.
;
command-keyword-table: ppp_cli_handler
PPPInfo(min-args:0, max-args:0, help:,
invalid-syntax: "Syntax: *PPPInfo"),
PPPConnect(min-args:0, max-args:255, help:),
PPPDisconnect(min-args:0, max-args:0, help:,
invalid-syntax: "Syntax: *PPPDisconnect"),
PPPLog(min-args:0, max-args:0, help:,
invalid-syntax: "Syntax: *PPPLog")
/*
* Copyright (c) 1992 Hugo Fiennes
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/* _____________________________________________
[> <]
Project [> ARCterm VII <]
Author [> Hugo Fiennes <]
Date started [> 05-March-1990 <]
[> <]
Module name [> Driver calls <]
Current version [> 00.04 <]
Version date [> 08-January-1993 <]
State [> Unfinished <]
[> <]
[> This source is COPYRIGHT © 1992/93 by <]
[> Hugo Fiennes of The Serial Port <]
[>_____________________________________________<]
*/
extern int driver(int,...);
extern int *driver_speedtable,driver_flags,driver_version,driver_noofspeeds;
extern char *driver_info,*driver_creator;
extern void driver_init(void);
extern int driver_block[1024];
extern int portnumber;
#define DRIVER_PUTBYTE 0
#define DRIVER_GETBYTE 1
#define DRIVER_PUTBLOCK 2
#define DRIVER_GETBLOCK 3
#define DRIVER_CHECKTX 4
#define DRIVER_CHECKRX 5
#define DRIVER_FLUSHTX 6
#define DRIVER_FLUSHRX 7
#define DRIVER_CONTROLLINES 8
#define DRIVER_MODEMCONTROL 9
#define DRIVER_RXERRORS 10
#define DRIVER_BREAK 11
#define DRIVER_EXAMINE 12
#define DRIVER_TXSPEED 13
#define DRIVER_RXSPEED 14
#define DRIVER_WORDFORMAT 15
#define DRIVER_FLOWCONTROL 16
#define DRIVER_INITIALISE 17
#define DRIVER_CLOSEDOWN 18
#define DRIVER_POLL 19
#define DRIVER_SELECT 20
#define driver_txspeed(tx) driver(DRIVER_TXSPEED,portnumber,tx)
#define driver_rxspeed(rx) driver(DRIVER_RXSPEED,portnumber,rx)
#define driver_wordformat(w) driver(DRIVER_WORDFORMAT,portnumber,w)
#define driver_flowcontrol(f) driver(DRIVER_FLOWCONTROL,portnumber,f)
#define driver_initialise() (char *)(driver(DRIVER_INITIALISE,portnumber))
#define driver_closedown() driver(DRIVER_CLOSEDOWN,portnumber)
#define driver_poll() driver(DRIVER_POLL,portnumber)
#define driver_controllines(s) driver(DRIVER_CONTROLLINES,portnumber,s)
#define driver_modemcontrol(s) driver(DRIVER_MODEMCONTROL,portnumber)
#define driver_putblock(p,n) driver(DRIVER_PUTBLOCK,portnumber,p,n)
#define driver_putbyte(c) driver(DRIVER_PUTBYTE,portnumber,c)
#define driver_checkrx() driver(DRIVER_CHECKRX,portnumber)
#define driver_checktx() driver(DRIVER_CHECKTX,portnumber)
#define driver_getblock(p,n) driver(DRIVER_GETBLOCK,portnumber,p,n)
#define driver_rxerrors() driver(DRIVER_RXERRORS,portnumber)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment