forked from Imagelibrary/rtems
This commit was manufactured by cvs2svn to create branch 'rtems-4-6-branch'.
Cherrypick from master 2003-05-27 16:17:31 UTC Ralf Corsepius <ralf.corsepius@rtems.org> '2003-05-27 Ralf Corsepius <corsepiu@faw.uni-ulm.de>': c/src/tests/samples/pppd/.cvsignore c/src/tests/samples/pppd/Makefile-user c/src/tests/samples/pppd/Makefile.am c/src/tests/samples/pppd/README c/src/tests/samples/pppd/init.c c/src/tests/samples/pppd/netconfig.h c/src/tests/samples/pppd/ppp.conf c/src/tests/samples/pppd/pppd.options c/src/tests/samples/pppd/pppdapp.c c/src/tests/samples/pppd/system.h cpukit/include/rtems/stdint.h
This commit is contained in:
2
c/src/tests/samples/pppd/.cvsignore
Normal file
2
c/src/tests/samples/pppd/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
45
c/src/tests/samples/pppd/Makefile-user
Normal file
45
c/src/tests/samples/pppd/Makefile-user
Normal file
@@ -0,0 +1,45 @@
|
||||
#
|
||||
# Makefile
|
||||
#
|
||||
|
||||
#
|
||||
# RTEMS_MAKEFILE_PATH is typically set in an environment variable
|
||||
#
|
||||
|
||||
EXEC=ppptest.exe
|
||||
PGM=${ARCH}/$(EXEC)
|
||||
|
||||
# optional managers required
|
||||
MANAGERS=io event semaphore
|
||||
|
||||
# C source names
|
||||
CSRCS = init.c pppdapp.c
|
||||
|
||||
COBJS_ = $(CSRCS:.c=.o)
|
||||
COBJS = $(COBJS_:%=${ARCH}/%)
|
||||
|
||||
# C++ source names
|
||||
CXXSRCS =
|
||||
CXXOBJS_ = $(CXXSRCS:.cc=.o)
|
||||
CXXOBJS = $(CXXOBJS_:%=${ARCH}/%)
|
||||
|
||||
# AS source names
|
||||
ASSRCS =
|
||||
ASOBJS_ = $(ASSRCS:.s=.o)
|
||||
ASOBJS = $(ASOBJS_:%=${ARCH}/%)
|
||||
|
||||
# Libraries
|
||||
LIBS = -lrtemsall -lc
|
||||
|
||||
include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
|
||||
|
||||
include $(RTEMS_CUSTOM)
|
||||
include $(PROJECT_ROOT)/make/leaf.cfg
|
||||
|
||||
OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
|
||||
|
||||
all: ${ARCH} $(PGM)
|
||||
|
||||
$(PGM): $(OBJS)
|
||||
$(make-exe)
|
||||
|
||||
43
c/src/tests/samples/pppd/Makefile.am
Normal file
43
c/src/tests/samples/pppd/Makefile.am
Normal file
@@ -0,0 +1,43 @@
|
||||
##
|
||||
## $Id$
|
||||
##
|
||||
|
||||
|
||||
SAMPLE = pppd
|
||||
PGM = ${ARCH}/$(SAMPLE).exe
|
||||
|
||||
MANAGERS = io event semaphore
|
||||
|
||||
C_FILES = init.c pppdapp.c
|
||||
C_O_FILES = $(C_FILES:%.c=${ARCH}/%.$(OBJEXT))
|
||||
|
||||
H_FILES = netconfig.h system.h
|
||||
|
||||
DOCTYPES = scn
|
||||
DOCS = $(DOCTYPES:%=$(SAMPLE).%)
|
||||
|
||||
SRCS = $(DOCS) $(C_FILES) $(H_FILES)
|
||||
OBJS = $(C_O_FILES)
|
||||
|
||||
PRINT_SRCS = $(DOCS)
|
||||
|
||||
include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg
|
||||
include $(top_srcdir)/../../../../automake/compile.am
|
||||
include $(top_srcdir)/../../../../automake/leaf.am
|
||||
include $(top_srcdir)/sample.am
|
||||
|
||||
#
|
||||
# (OPTIONAL) Add local stuff here using +=
|
||||
#
|
||||
|
||||
|
||||
if HAS_NETWORKING
|
||||
all-local: ${ARCH} $(TMPINSTALL_FILES)
|
||||
|
||||
${PGM}: $(OBJS) $(LINK_FILES)
|
||||
$(make-exe)
|
||||
endif
|
||||
|
||||
EXTRA_DIST = $(C_FILES) $(H_FILES) $(DOCS)
|
||||
|
||||
include $(top_srcdir)/../../../../automake/local.am
|
||||
15
c/src/tests/samples/pppd/README
Normal file
15
c/src/tests/samples/pppd/README
Normal file
@@ -0,0 +1,15 @@
|
||||
#
|
||||
# $Id$
|
||||
#
|
||||
|
||||
This is an example user application using pppd. It is built using
|
||||
the RTEMS application Makefiles. The file Makefile-user should
|
||||
be renamed to Makefile or the -f option given to make. The file
|
||||
is renamed to avoid bootstrap -c removing it.
|
||||
|
||||
The files ppp.conf and pppd.options are sample configuration files
|
||||
that have successfully used to make ppp connections over a null
|
||||
modem serial cable to a UNIX box. Please review the man pages
|
||||
for either the ppp or pppd applications to ensure they are configured
|
||||
correctly.
|
||||
|
||||
24
c/src/tests/samples/pppd/init.c
Normal file
24
c/src/tests/samples/pppd/init.c
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <rtemspppd.h>
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
#include "system.h"
|
||||
#include "netconfig.h"
|
||||
|
||||
|
||||
extern int pppdapp_initialize(void);
|
||||
|
||||
|
||||
rtems_task Init(rtems_task_argument argument)
|
||||
{
|
||||
/* initialize network */
|
||||
rtems_bsdnet_initialize_network();
|
||||
rtems_pppd_initialize();
|
||||
pppdapp_initialize();
|
||||
|
||||
rtems_task_delete(RTEMS_SELF);
|
||||
}
|
||||
36
c/src/tests/samples/pppd/netconfig.h
Normal file
36
c/src/tests/samples/pppd/netconfig.h
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
#ifndef NETCONFIG_H_
|
||||
#define NETCONFIG_H_
|
||||
|
||||
#include <bsp.h>
|
||||
|
||||
/* external function prototypes */
|
||||
extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
|
||||
|
||||
/* Default network interface */
|
||||
static struct rtems_bsdnet_ifconfig netdriver_config = {
|
||||
"ppp0", /* name */
|
||||
rtems_ppp_driver_attach, /* attach function */
|
||||
NULL, /* No more interfaces */
|
||||
NULL, /* IP address */
|
||||
NULL, /* IP net mask */
|
||||
NULL, /* Driver supplies hardware address */
|
||||
0 /* Use default driver parameters */
|
||||
};
|
||||
|
||||
/* Network configuration */
|
||||
struct rtems_bsdnet_config rtems_bsdnet_config = {
|
||||
&netdriver_config,
|
||||
NULL,
|
||||
30, /* Default network task priority */
|
||||
(256*1024), /* Default mbuf capacity */
|
||||
(512*1024), /* Default mbuf cluster capacity */
|
||||
0, /* Host name */
|
||||
0, /* Domain name */
|
||||
0, /* Gateway */
|
||||
0, /* Log host */
|
||||
{ 0 }, /* Name server(s) */
|
||||
{ 0 }, /* NTP server(s) */
|
||||
};
|
||||
|
||||
#endif
|
||||
27
c/src/tests/samples/pppd/ppp.conf
Normal file
27
c/src/tests/samples/pppd/ppp.conf
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
#
|
||||
# Example configuration file for setting up a ppp server
|
||||
# using a null-modem serial cable:
|
||||
#
|
||||
# Tested using ppp on OpenBSD 2.9
|
||||
# - just follow instructions in man page for accepting
|
||||
# ppp connections over the serial port
|
||||
# - if pap and/or chap is enabled, you must have a ppp.secret
|
||||
# file which will be used for user authentication
|
||||
# - found useful to turn on syslog for ppp
|
||||
#
|
||||
|
||||
default:
|
||||
set log Phase Chat LQM LCP IPCP CCP command
|
||||
set device /dev/cua00
|
||||
set speed 57600
|
||||
set ctsrts on
|
||||
set dial ""
|
||||
|
||||
openbsd-server:
|
||||
set timeout 0
|
||||
set ifaddr 192.168.2.100 192.168.2.123
|
||||
enable dns
|
||||
allow users
|
||||
enable chap
|
||||
enable pap
|
||||
9
c/src/tests/samples/pppd/pppd.options
Normal file
9
c/src/tests/samples/pppd/pppd.options
Normal file
@@ -0,0 +1,9 @@
|
||||
/dev/tty00
|
||||
57600
|
||||
crtscts
|
||||
passive
|
||||
local
|
||||
noauth
|
||||
debug
|
||||
persist
|
||||
192.168.2.222:192.168.2.111
|
||||
146
c/src/tests/samples/pppd/pppdapp.c
Normal file
146
c/src/tests/samples/pppd/pppdapp.c
Normal file
@@ -0,0 +1,146 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <rtemspppd.h>
|
||||
#include "system.h"
|
||||
|
||||
|
||||
/* define global variables */
|
||||
static unsigned int pppdapp_linkcount = 0;
|
||||
static rtems_id pppdapp_taskid;
|
||||
|
||||
|
||||
static void pppdapp_linkup_hook(void)
|
||||
{
|
||||
pppdapp_linkcount++;
|
||||
printf("PPP LINK UP [%d]\n", pppdapp_linkcount);
|
||||
}
|
||||
|
||||
static void pppdapp_linkdown_hook(void)
|
||||
{
|
||||
printf("PPP LINK DOWN [%d]\n", pppdapp_linkcount);
|
||||
}
|
||||
|
||||
static void pppdapp_ipup_hook(void)
|
||||
{
|
||||
/* send ipup signal to pppdapp task */
|
||||
rtems_event_send(pppdapp_taskid, RTEMS_EVENT_10);
|
||||
}
|
||||
|
||||
static void pppdapp_ipdown_hook(void)
|
||||
{
|
||||
/* send ip down signal to pppdapp task */
|
||||
rtems_event_send(pppdapp_taskid, RTEMS_EVENT_11);
|
||||
}
|
||||
|
||||
static void pppdapp_setup(void)
|
||||
{
|
||||
const char *pUser = "oscar";
|
||||
const char *pPassword = "goldman";
|
||||
|
||||
#undef USE_MODEM
|
||||
#ifdef USE_MODEM
|
||||
const char *pTelephone = "5551234";
|
||||
const char *pInitScript = "TIMEOUT@5@@AT@@OK@";
|
||||
const char *pConnectScript = "TIMEOUT@90@@ATDT%s@CONNECT@@name:@%s@word:@%s@";
|
||||
const char *pDisconnectScript = "TIMEOUT@5@@ATH0@@OK@";
|
||||
char pConnect[128];
|
||||
|
||||
/* set the connect string */
|
||||
sprintf(pConnect, pConnectScript, pTelephone, pUser, pPassword);
|
||||
|
||||
/* set pppd options for modem */
|
||||
rtems_pppd_set_option("/dev/ttyS2", NULL);
|
||||
rtems_pppd_set_option("57600", NULL);
|
||||
rtems_pppd_set_option("crtscts", NULL);
|
||||
rtems_pppd_set_option("modem", NULL);
|
||||
rtems_pppd_set_option("noauth", NULL);
|
||||
rtems_pppd_set_option("debug", NULL);
|
||||
rtems_pppd_set_option("init", pInitScript);
|
||||
rtems_pppd_set_option("connect", pConnect);
|
||||
rtems_pppd_set_option("disconnect", pDisconnectScript);
|
||||
#else
|
||||
/* set pppd options for null modem direct link serial cable */
|
||||
rtems_pppd_set_option("/dev/ttyS1", NULL);
|
||||
rtems_pppd_set_option("57600", NULL);
|
||||
rtems_pppd_set_option("crtscts", NULL);
|
||||
rtems_pppd_set_option("local", NULL);
|
||||
rtems_pppd_set_option("noauth", NULL);
|
||||
rtems_pppd_set_option("debug", NULL);
|
||||
rtems_pppd_set_option("user", pUser);
|
||||
rtems_pppd_set_option("password", pPassword);
|
||||
#endif
|
||||
|
||||
/* set up pppd hooks */
|
||||
rtems_pppd_set_hook(RTEMS_PPPD_LINKUP_HOOK, pppdapp_linkup_hook);
|
||||
rtems_pppd_set_hook(RTEMS_PPPD_LINKDOWN_HOOK, pppdapp_linkdown_hook);
|
||||
rtems_pppd_set_hook(RTEMS_PPPD_IPUP_HOOK, pppdapp_ipup_hook);
|
||||
rtems_pppd_set_hook(RTEMS_PPPD_IPDOWN_HOOK, pppdapp_ipdown_hook);
|
||||
}
|
||||
|
||||
static rtems_task pppdapp(rtems_task_argument arg)
|
||||
{
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
rtems_interval tickspersecond = 0;
|
||||
rtems_option options;
|
||||
rtems_event_set in;
|
||||
rtems_event_set out;
|
||||
|
||||
/* initialize ticks per second */
|
||||
rtems_clock_get(RTEMS_CLOCK_GET_TICKS_PER_SECOND, &tickspersecond);
|
||||
if ( tickspersecond == 0 ) {
|
||||
/* ensure value is greater than zero */
|
||||
tickspersecond = 100;
|
||||
}
|
||||
|
||||
/* initiate connection */
|
||||
pppdapp_setup();
|
||||
rtems_pppd_connect();
|
||||
|
||||
/* enter processing loop */
|
||||
in = (RTEMS_EVENT_10 | RTEMS_EVENT_11);
|
||||
options = (RTEMS_EVENT_ANY | RTEMS_WAIT);
|
||||
while ( sc == RTEMS_SUCCESSFUL ) {
|
||||
/* wait for the next event */
|
||||
sc = rtems_event_receive(in, options, RTEMS_NO_TIMEOUT, &out);
|
||||
if ( sc == RTEMS_SUCCESSFUL ) {
|
||||
/* determine which event was sent */
|
||||
if ( out & RTEMS_EVENT_10 ) {
|
||||
/* ip up recived */
|
||||
/* call disconnect function */
|
||||
rtems_pppd_disconnect();
|
||||
}
|
||||
if ( out & RTEMS_EVENT_11 ) {
|
||||
/* ip down recived */
|
||||
/* sleep 10 seconds and call connect function */
|
||||
rtems_task_wake_after(10*tickspersecond);
|
||||
rtems_pppd_connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* terminate myself */
|
||||
rtems_task_delete(RTEMS_SELF);
|
||||
}
|
||||
|
||||
int pppdapp_initialize(void)
|
||||
{
|
||||
int iReturn = (int)-1;
|
||||
rtems_status_code status;
|
||||
rtems_name taskName;
|
||||
|
||||
taskName = rtems_build_name( 'p', 'a', 'p', 'p' );
|
||||
status = rtems_task_create(taskName,
|
||||
CONFIGURE_INIT_TASK_PRIORITY,
|
||||
CONFIGURE_INIT_TASK_STACK_SIZE,
|
||||
CONFIGURE_INIT_TASK_INITIAL_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&pppdapp_taskid);
|
||||
if ( status == RTEMS_SUCCESSFUL ) {
|
||||
status = rtems_task_start(pppdapp_taskid, pppdapp, 0);
|
||||
if ( status == RTEMS_SUCCESSFUL ) {
|
||||
iReturn = (int)0;
|
||||
}
|
||||
}
|
||||
|
||||
return ( iReturn );
|
||||
}
|
||||
42
c/src/tests/samples/pppd/system.h
Normal file
42
c/src/tests/samples/pppd/system.h
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#include <rtems.h>
|
||||
#include <tty_drv.h>
|
||||
|
||||
/* functions */
|
||||
extern rtems_task Init(rtems_task_argument argument);
|
||||
|
||||
#include <bsp.h>
|
||||
|
||||
#define CONFIGURE_HAS_OWN_DEVICE_DRIVER_TABLE
|
||||
#ifdef CONFIGURE_INIT
|
||||
rtems_driver_address_table Device_drivers[5] = {
|
||||
CONSOLE_DRIVER_TABLE_ENTRY,
|
||||
CLOCK_DRIVER_TABLE_ENTRY,
|
||||
TTY1_DRIVER_TABLE_ENTRY,
|
||||
TTY2_DRIVER_TABLE_ENTRY,
|
||||
{NULL, NULL, NULL, NULL, NULL, NULL}
|
||||
};
|
||||
#endif
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 8
|
||||
|
||||
#define CONFIGURE_EXECUTIVE_RAM_SIZE (512*1024)
|
||||
#define CONFIGURE_MAXIMUM_SEMAPHORES 20
|
||||
#define CONFIGURE_MAXIMUM_TASKS 20
|
||||
|
||||
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
|
||||
|
||||
#define CONFIGURE_INIT_TASK_STACK_SIZE (10*1024)
|
||||
#define CONFIGURE_INIT_TASK_PRIORITY 120
|
||||
#define CONFIGURE_INIT_TASK_INITIAL_MODES (RTEMS_PREEMPT | \
|
||||
RTEMS_NO_TIMESLICE | \
|
||||
RTEMS_NO_ASR | \
|
||||
RTEMS_INTERRUPT_LEVEL(0))
|
||||
|
||||
#include <confdefs.h>
|
||||
|
||||
#endif
|
||||
35
cpukit/include/rtems/stdint.h
Normal file
35
cpukit/include/rtems/stdint.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* rtems/stdint.h
|
||||
*
|
||||
* ISO C99 integer types
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef __rtems_stdint_h
|
||||
#define __rtems_stdint_h
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rtems/score/types.h>
|
||||
|
||||
/*
|
||||
* map RTEMS internal types onto C99 types
|
||||
*/
|
||||
typedef signed8 int8_t;
|
||||
typedef signed16 int16_t;
|
||||
typedef signed32 int32_t;
|
||||
typedef signed64 int64_t;
|
||||
|
||||
typedef unsigned8 uint8_t;
|
||||
typedef unsigned16 uint16_t;
|
||||
typedef unsigned32 uint32_t;
|
||||
typedef unsigned64 uint64_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user