mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 07:15:58 +08:00
ppp: Port to new stack
This commit is contained in:
30
Makefile
30
Makefile
@@ -22,6 +22,7 @@ COMMON_FLAGS += -Ifreebsd/lib/libutil
|
||||
COMMON_FLAGS += -Ifreebsd/lib/libkvm
|
||||
COMMON_FLAGS += -Ifreebsd/lib/libmemstat
|
||||
COMMON_FLAGS += -Ifreebsd/lib/libipsec
|
||||
COMMON_FLAGS += -Irtemsbsd/sys
|
||||
COMMON_FLAGS += -ImDNSResponder/mDNSCore
|
||||
COMMON_FLAGS += -ImDNSResponder/mDNSShared
|
||||
COMMON_FLAGS += -ImDNSResponder/mDNSPosix
|
||||
@@ -100,11 +101,29 @@ LIB_C_FILES += rtemsbsd/rtems/rtems_mii_ioctl_kern.c
|
||||
LIB_C_FILES += rtemsbsd/rtems/rtems-syslog-initialize.c
|
||||
LIB_C_FILES += rtemsbsd/rtems/syslog.c
|
||||
LIB_C_FILES += rtemsbsd/ftpd/ftpd.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/auth.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/ccp.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/chap.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/chap_ms.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/chat.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/demand.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/fsm.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/ipcp.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/lcp.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/magic.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/options.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/rtemsmain.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/rtemspppd.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/sys-rtems.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/upap.c
|
||||
LIB_C_FILES += rtemsbsd/pppd/utils.c
|
||||
LIB_C_FILES += rtemsbsd/sys/dev/usb/controller/ehci_mpc83xx.c
|
||||
LIB_C_FILES += rtemsbsd/sys/dev/usb/controller/ohci_lpc24xx.c
|
||||
LIB_C_FILES += rtemsbsd/sys/dev/usb/controller/ohci_lpc32xx.c
|
||||
LIB_C_FILES += rtemsbsd/sys/dev/smc/if_smc_nexus.c
|
||||
LIB_C_FILES += rtemsbsd/sys/dev/ffec/if_ffec_mcf548x.c
|
||||
LIB_C_FILES += rtemsbsd/sys/net/if_ppp.c
|
||||
LIB_C_FILES += rtemsbsd/sys/net/ppp_tty.c
|
||||
LIB_C_FILES += rtemsbsd/telnetd/check_passwd.c
|
||||
LIB_C_FILES += rtemsbsd/telnetd/des.c
|
||||
LIB_C_FILES += rtemsbsd/telnetd/pty.c
|
||||
@@ -1338,6 +1357,17 @@ TESTS += $(TEST_CONDVAR01)
|
||||
O_FILES += $(TEST_CONDVAR01_O_FILES)
|
||||
D_FILES += $(TEST_CONDVAR01_D_FILES)
|
||||
RUN_TESTS += $(TEST_CONDVAR01)
|
||||
|
||||
TEST_PPP01 = testsuite/ppp01/ppp01.exe
|
||||
TEST_PPP01_O_FILES =
|
||||
TEST_PPP01_D_FILES =
|
||||
TEST_PPP01_O_FILES += testsuite/ppp01/test_main.o
|
||||
TEST_PPP01_D_FILES += testsuite/ppp01/test_main.d
|
||||
$(TEST_PPP01): $(TEST_PPP01_O_FILES) $(LIB)
|
||||
$(LINK.c) -Wl,-Map,testsuite/ppp01/ppp01.map $^ -lm -lz -o $@
|
||||
TESTS += $(TEST_PPP01)
|
||||
O_FILES += $(TEST_PPP01_O_FILES)
|
||||
D_FILES += $(TEST_PPP01_D_FILES)
|
||||
LIB_C_FILES += dhcpcd/arp.c
|
||||
dhcpcd/arp.o: dhcpcd/arp.c
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) -D__FreeBSD__ -DTHERE_IS_NO_FORK -DMASTER_ONLY -DINET -DINET6 -c $< -o $@
|
||||
|
@@ -428,6 +428,7 @@ class ModuleManager:
|
||||
'COMMON_FLAGS += -Ifreebsd/lib/libkvm\n' \
|
||||
'COMMON_FLAGS += -Ifreebsd/lib/libmemstat\n' \
|
||||
'COMMON_FLAGS += -Ifreebsd/lib/libipsec\n' \
|
||||
'COMMON_FLAGS += -Irtemsbsd/sys\n' \
|
||||
'COMMON_FLAGS += -ImDNSResponder/mDNSCore\n' \
|
||||
'COMMON_FLAGS += -ImDNSResponder/mDNSShared\n' \
|
||||
'COMMON_FLAGS += -ImDNSResponder/mDNSPosix\n' \
|
||||
@@ -698,11 +699,29 @@ rtems.addRTEMSSourceFiles(
|
||||
'rtems/rtems-syslog-initialize.c',
|
||||
'rtems/syslog.c',
|
||||
'ftpd/ftpd.c',
|
||||
'pppd/auth.c',
|
||||
'pppd/ccp.c',
|
||||
'pppd/chap.c',
|
||||
'pppd/chap_ms.c',
|
||||
'pppd/chat.c',
|
||||
'pppd/demand.c',
|
||||
'pppd/fsm.c',
|
||||
'pppd/ipcp.c',
|
||||
'pppd/lcp.c',
|
||||
'pppd/magic.c',
|
||||
'pppd/options.c',
|
||||
'pppd/rtemsmain.c',
|
||||
'pppd/rtemspppd.c',
|
||||
'pppd/sys-rtems.c',
|
||||
'pppd/upap.c',
|
||||
'pppd/utils.c',
|
||||
'sys/dev/usb/controller/ehci_mpc83xx.c',
|
||||
'sys/dev/usb/controller/ohci_lpc24xx.c',
|
||||
'sys/dev/usb/controller/ohci_lpc32xx.c',
|
||||
'sys/dev/smc/if_smc_nexus.c',
|
||||
'sys/dev/ffec/if_ffec_mcf548x.c',
|
||||
'sys/net/if_ppp.c',
|
||||
'sys/net/ppp_tty.c',
|
||||
'telnetd/check_passwd.c',
|
||||
'telnetd/des.c',
|
||||
'telnetd/pty.c',
|
||||
@@ -2473,6 +2492,7 @@ tests.addTest('init01', ['test_main'])
|
||||
tests.addTest('thread01', ['test_main'])
|
||||
tests.addTest('mutex01', ['test_main'])
|
||||
tests.addTest('condvar01', ['test_main'])
|
||||
tests.addTest('ppp01', ['test_main'], runTest = False)
|
||||
|
||||
dhcpcd = Module('dhcpcd')
|
||||
dhcpcd.addSourceFiles(
|
||||
|
0
rtemsbsd/include/rtems/bsd/local/opt_mac.h
Normal file
0
rtemsbsd/include/rtems/bsd/local/opt_mac.h
Normal file
@@ -38,8 +38,6 @@
|
||||
#include "ipcp.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
#include <rtems/bsdnet/servers.h>
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
/* global vars */
|
||||
@@ -1577,23 +1575,24 @@ static void
|
||||
create_resolv(
|
||||
uint32_t peerdns1, uint32_t peerdns2)
|
||||
{
|
||||
/* initialize values */
|
||||
rtems_bsdnet_nameserver_count = 0;
|
||||
FILE *f;
|
||||
|
||||
/* check to see if primary was specified */
|
||||
if ( peerdns1 ) {
|
||||
rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns1;
|
||||
rtems_bsdnet_nameserver_count++;
|
||||
}
|
||||
f = fopen(_PATH_RESOLV, "w");
|
||||
if (f == NULL) {
|
||||
error("Failed to create %s: %m", _PATH_RESOLV);
|
||||
return;
|
||||
}
|
||||
|
||||
/* check to see if secondary was specified */
|
||||
if ( peerdns2 ) {
|
||||
rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns2;
|
||||
rtems_bsdnet_nameserver_count++;
|
||||
}
|
||||
if (peerdns1)
|
||||
fprintf(f, "nameserver %s\n", ip_ntoa(peerdns1));
|
||||
|
||||
/* initialize resolver */
|
||||
__res_init();
|
||||
if (peerdns2)
|
||||
fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2));
|
||||
|
||||
if (ferror(f))
|
||||
error("Write failed to %s: %m", _PATH_RESOLV);
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
/*
|
||||
|
147
rtemsbsd/pppd/namespace.h
Normal file
147
rtemsbsd/pppd/namespace.h
Normal file
@@ -0,0 +1,147 @@
|
||||
#define abort_next rtems_pppd_abort_next
|
||||
#define abort_string rtems_pppd_abort_string
|
||||
#define allow_any_ip rtems_pppd_allow_any_ip
|
||||
#define auth_linkdown_hook rtems_pppd_auth_linkdown_hook
|
||||
#define auth_linkup_hook rtems_pppd_auth_linkup_hook
|
||||
#define auth_options rtems_pppd_auth_options
|
||||
#define auth_required rtems_pppd_auth_required
|
||||
#define baud_rate rtems_pppd_baud_rate
|
||||
#define callback_script rtems_pppd_callback_script
|
||||
#define ccp_allowoptions rtems_pppd_ccp_allowoptions
|
||||
#define ccp_fsm rtems_pppd_ccp_fsm
|
||||
#define ccp_gotoptions rtems_pppd_ccp_gotoptions
|
||||
#define ccp_hisoptions rtems_pppd_ccp_hisoptions
|
||||
#define ccp_protent rtems_pppd_ccp_protent
|
||||
#define ccp_wantoptions rtems_pppd_ccp_wantoptions
|
||||
#define chap rtems_pppd_chap
|
||||
#define chap_protent rtems_pppd_chap_protent
|
||||
#define clear_abort_next rtems_pppd_clear_abort_next
|
||||
#define clear_report_next rtems_pppd_clear_report_next
|
||||
#define connect_delay rtems_pppd_connect_delay
|
||||
#define connect_script rtems_pppd_connect_script
|
||||
#define connect_script_info rtems_pppd_connect_script_info
|
||||
#define crtscts rtems_pppd_crtscts
|
||||
#define cryptpap rtems_pppd_cryptpap
|
||||
#define current_option rtems_pppd_current_option
|
||||
#define debug rtems_pppd_debug
|
||||
#define default_device rtems_pppd_default_device
|
||||
#define demand rtems_pppd_demand
|
||||
#define detached rtems_pppd_detached
|
||||
#define devnam rtems_pppd_devnam
|
||||
#define devnam_fixed rtems_pppd_devnam_fixed
|
||||
#define devnam_info rtems_pppd_devnam_info
|
||||
#define devstat rtems_pppd_devstat
|
||||
#define disable_defaultip rtems_pppd_disable_defaultip
|
||||
#define disconnect_script rtems_pppd_disconnect_script
|
||||
#define disconnect_script_info rtems_pppd_disconnect_script_info
|
||||
#define do_callback rtems_pppd_do_callback
|
||||
#define doing_callback rtems_pppd_doing_callback
|
||||
#define echo_next rtems_pppd_echo_next
|
||||
#define explicit_remote rtems_pppd_explicit_remote
|
||||
#define fail_buffer rtems_pppd_fail_buffer
|
||||
#define fail_reason rtems_pppd_fail_reason
|
||||
#define general_options rtems_pppd_general_options
|
||||
#define holdoff rtems_pppd_holdoff
|
||||
#define holdoff_hook rtems_pppd_holdoff_hook
|
||||
#define holdoff_specified rtems_pppd_holdoff_specified
|
||||
#define hostname rtems_pppd_hostname
|
||||
#define hungup rtems_pppd_hungup
|
||||
#define hup_next rtems_pppd_hup_next
|
||||
#define idle_time_hook rtems_pppd_idle_time_hook
|
||||
#define idle_time_limit rtems_pppd_idle_time_limit
|
||||
#define ifname rtems_pppd_ifname
|
||||
#define initializer rtems_pppd_initializer
|
||||
#define initializer_info rtems_pppd_initializer_info
|
||||
#define inpacket_buf rtems_pppd_inpacket_buf
|
||||
#define inspeed rtems_pppd_inspeed
|
||||
#define ipcp_allowoptions rtems_pppd_ipcp_allowoptions
|
||||
#define ipcp_fsm rtems_pppd_ipcp_fsm
|
||||
#define ipcp_gotoptions rtems_pppd_ipcp_gotoptions
|
||||
#define ipcp_hisoptions rtems_pppd_ipcp_hisoptions
|
||||
#define ipcp_protent rtems_pppd_ipcp_protent
|
||||
#define ipcp_wantoptions rtems_pppd_ipcp_wantoptions
|
||||
#define ip_down_hook rtems_pppd_ip_down_hook
|
||||
#define ipparam rtems_pppd_ipparam
|
||||
#define ip_up_hook rtems_pppd_ip_up_hook
|
||||
#define kdebugflag rtems_pppd_kdebugflag
|
||||
#define lcp_allowoptions rtems_pppd_lcp_allowoptions
|
||||
#define lcp_fsm rtems_pppd_lcp_fsm
|
||||
#define lcp_gotoptions rtems_pppd_lcp_gotoptions
|
||||
#define lcp_hisoptions rtems_pppd_lcp_hisoptions
|
||||
#define lcp_loopbackfail rtems_pppd_lcp_loopbackfail
|
||||
#define lcp_protent rtems_pppd_lcp_protent
|
||||
#define lcp_wantoptions rtems_pppd_lcp_wantoptions
|
||||
#define line rtems_pppd_line
|
||||
#define linep rtems_pppd_linep
|
||||
#define link_connect_time rtems_pppd_link_connect_time
|
||||
#define linkname rtems_pppd_linkname
|
||||
#define link_stats rtems_pppd_link_stats
|
||||
#define link_stats_valid rtems_pppd_link_stats_valid
|
||||
#define lockflag rtems_pppd_lockflag
|
||||
#define log_to_fd rtems_pppd_log_to_fd
|
||||
#define log_to_file rtems_pppd_log_to_file
|
||||
#define maxconnect rtems_pppd_maxconnect
|
||||
#define maxfail rtems_pppd_maxfail
|
||||
#define modem rtems_pppd_modem
|
||||
#define n_aborts rtems_pppd_n_aborts
|
||||
#define need_holdoff rtems_pppd_need_holdoff
|
||||
#define netmask rtems_pppd_netmask
|
||||
#define new_phase_hook rtems_pppd_new_phase_hook
|
||||
#define nodetach rtems_pppd_nodetach
|
||||
#define no_ppp_msg rtems_pppd_no_ppp_msg
|
||||
#define notty rtems_pppd_notty
|
||||
#define n_reports rtems_pppd_n_reports
|
||||
#define open_ccp_flag rtems_pppd_open_ccp_flag
|
||||
#define option_source rtems_pppd_option_source
|
||||
#define our_name rtems_pppd_our_name
|
||||
#define outpacket_buf rtems_pppd_outpacket_buf
|
||||
#define pap_auth_hook rtems_pppd_pap_auth_hook
|
||||
#define pap_check_hook rtems_pppd_pap_check_hook
|
||||
#define pap_logout_hook rtems_pppd_pap_logout_hook
|
||||
#define pap_passwd_hook rtems_pppd_pap_passwd_hook
|
||||
#define pap_protent rtems_pppd_pap_protent
|
||||
#define passwd rtems_pppd_passwd
|
||||
#define peer_authname rtems_pppd_peer_authname
|
||||
#define peer_mru rtems_pppd_peer_mru
|
||||
#define pend_q rtems_pppd_pend_q
|
||||
#define pend_qtail rtems_pppd_pend_qtail
|
||||
#define persist rtems_pppd_persist
|
||||
#define pppd_dialer rtems_pppd_pppd_dialer
|
||||
#define pppd_kill_link rtems_pppd_pppd_kill_link
|
||||
#define pppd_phase rtems_pppd_pppd_phase
|
||||
#define pppd_status rtems_pppd_pppd_status
|
||||
#define pppd_ttyfd rtems_pppd_pppd_ttyfd
|
||||
#define pppifunit rtems_pppd_pppifunit
|
||||
#define prepass rtems_pppd_prepass
|
||||
#define privileged rtems_pppd_privileged
|
||||
#define privileged_option rtems_pppd_privileged_option
|
||||
#define protocol_list rtems_pppd_protocol_list
|
||||
#define protocols rtems_pppd_protocols
|
||||
#define ptycommand rtems_pppd_ptycommand
|
||||
#define ptycommand_info rtems_pppd_ptycommand_info
|
||||
#define record_file rtems_pppd_record_file
|
||||
#define refuse_chap rtems_pppd_refuse_chap
|
||||
#define refuse_pap rtems_pppd_refuse_pap
|
||||
#define remote_name rtems_pppd_remote_name
|
||||
#define report_buffer rtems_pppd_report_buffer
|
||||
#define report_gathering rtems_pppd_report_gathering
|
||||
#define report_next rtems_pppd_report_next
|
||||
#define report_string rtems_pppd_report_string
|
||||
#define saved_tty_parameters rtems_pppd_saved_tty_parameters
|
||||
#define say_next rtems_pppd_say_next
|
||||
#define script_env rtems_pppd_script_env
|
||||
#define s_env_nalloc rtems_pppd_s_env_nalloc
|
||||
#define sync_serial rtems_pppd_sync_serial
|
||||
#define temp2 rtems_pppd_temp2
|
||||
#define timeout_next rtems_pppd_timeout_next
|
||||
#define tune_kernel rtems_pppd_tune_kernel
|
||||
#define unsuccess rtems_pppd_unsuccess
|
||||
#define upap rtems_pppd_upap
|
||||
#define updetach rtems_pppd_updetach
|
||||
#define usehostname rtems_pppd_usehostname
|
||||
#define uselogin rtems_pppd_uselogin
|
||||
#define user rtems_pppd_user
|
||||
#define using_pty rtems_pppd_using_pty
|
||||
#define welcomer rtems_pppd_welcomer
|
||||
#define welcomer_info rtems_pppd_welcomer_info
|
||||
#define xmit_accm rtems_pppd_xmit_accm
|
@@ -28,7 +28,7 @@
|
||||
#define _PATH_TTYOPT _ROOT_PATH "/etc/ppp/options."
|
||||
#define _PATH_CONNERRS _ROOT_PATH "/etc/ppp/connect-errors"
|
||||
#define _PATH_PEERFILES _ROOT_PATH "/etc/ppp/peers/"
|
||||
#define _PATH_RESOLV _ROOT_PATH "/etc/ppp/resolv.conf"
|
||||
#define _PATH_RESOLV _ROOT_PATH "/etc/resolv.conf"
|
||||
|
||||
#define _PATH_USEROPT ".ppprc"
|
||||
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#include <net/ppp_defs.h>
|
||||
#include <rtems/rtemsdialer.h>
|
||||
#include <stdint.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <arpa/nameser_compat.h>
|
||||
|
||||
#if defined(__STDC__)
|
||||
#include <stdarg.h>
|
||||
@@ -46,6 +48,8 @@
|
||||
#include "eui64.h"
|
||||
#endif
|
||||
|
||||
#include "namespace.h"
|
||||
|
||||
/*
|
||||
* Limits.
|
||||
*/
|
||||
@@ -502,29 +506,6 @@ extern void (*auth_linkdown_hook)(void);
|
||||
*(cp)++ = (u_char) (c); \
|
||||
}
|
||||
|
||||
|
||||
#define GETSHORT(s, cp) { \
|
||||
(s) = *(cp)++ << 8; \
|
||||
(s) |= *(cp)++; \
|
||||
}
|
||||
#define PUTSHORT(s, cp) { \
|
||||
*(cp)++ = (u_char) ((s) >> 8); \
|
||||
*(cp)++ = (u_char) (s); \
|
||||
}
|
||||
|
||||
#define GETLONG(l, cp) { \
|
||||
(l) = *(cp)++ << 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; (l) <<= 8; \
|
||||
(l) |= *(cp)++; \
|
||||
}
|
||||
#define PUTLONG(l, cp) { \
|
||||
*(cp)++ = (u_char) ((l) >> 24); \
|
||||
*(cp)++ = (u_char) ((l) >> 16); \
|
||||
*(cp)++ = (u_char) ((l) >> 8); \
|
||||
*(cp)++ = (u_char) (l); \
|
||||
}
|
||||
|
||||
#define INCPTR(n, cp) ((cp) += (n))
|
||||
#define DECPTR(n, cp) ((cp) -= (n))
|
||||
|
||||
|
@@ -41,6 +41,7 @@
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <rtems/rtemsdialer.h>
|
||||
|
||||
#include "pppd.h"
|
||||
#include "magic.h"
|
||||
@@ -55,7 +56,6 @@
|
||||
#include "ccp.h"
|
||||
#include "pathnames.h"
|
||||
#include "patchlevel.h"
|
||||
#include "rtemsdialer.h"
|
||||
|
||||
#ifdef CBCP_SUPPORT
|
||||
#include "cbcp.h"
|
||||
|
@@ -10,10 +10,9 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#include <rtems/rtemspppd.h>
|
||||
#include <rtems.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include "pppd.h"
|
||||
#include "rtemspppd.h"
|
||||
|
||||
|
||||
/* define pppd function prototypes */
|
||||
@@ -82,11 +81,6 @@ int rtems_pppd_initialize(void)
|
||||
rtems_status_code status;
|
||||
rtems_name taskName;
|
||||
|
||||
/* determine priority value */
|
||||
if ( rtems_bsdnet_config.network_task_priority ) {
|
||||
priority = rtems_bsdnet_config.network_task_priority;
|
||||
}
|
||||
|
||||
/* initialize the exit hook */
|
||||
rtems_pppd_exitfp = (rtems_pppd_hookfunction)0;
|
||||
|
||||
|
@@ -59,7 +59,6 @@
|
||||
#include <rtems.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <rtems/termiostypes.h>
|
||||
extern int rtems_bsdnet_microseconds_per_tick;
|
||||
extern rtems_id rtems_pppd_taskid;
|
||||
|
||||
#include "pppd.h"
|
||||
@@ -500,7 +499,7 @@ ppp_delay(void)
|
||||
rtems_interval ticks;
|
||||
|
||||
/* recommended delay to help negotiation */
|
||||
ticks = 300000/rtems_bsdnet_microseconds_per_tick;
|
||||
ticks = 300000/rtems_configuration_get_microseconds_per_tick();
|
||||
rtems_task_wake_after(ticks);
|
||||
}
|
||||
|
||||
@@ -522,7 +521,7 @@ wait_input(
|
||||
wait = RTEMS_NO_WAIT;
|
||||
else {
|
||||
ticks = (timo->tv_sec * 1000000 + timo->tv_usec) /
|
||||
rtems_bsdnet_microseconds_per_tick;
|
||||
rtems_configuration_get_microseconds_per_tick();
|
||||
if(ticks <= 0)
|
||||
ticks = 1;
|
||||
}
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*
|
||||
* if_ppp.c - Point-to-Point Protocol (PPP) Asynchronous driver.
|
||||
*/
|
||||
@@ -79,10 +81,10 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "opt_inet.h"
|
||||
#include "opt_ipx.h"
|
||||
#include "opt_mac.h"
|
||||
#include "opt_ppp.h"
|
||||
#include <rtems/bsd/local/opt_inet.h>
|
||||
#include <rtems/bsd/local/opt_ipx.h>
|
||||
#include <rtems/bsd/local/opt_mac.h>
|
||||
#include <rtems/bsd/local/opt_ppp.h>
|
||||
|
||||
#if NPPP > 0
|
||||
|
||||
@@ -90,7 +92,7 @@
|
||||
#include <rtems/termiostypes.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
#include <rtems/rtemspppd.h>
|
||||
#include <sys/param.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@@ -99,6 +101,10 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
@@ -188,7 +194,6 @@ struct compressor *ppp_compressors[8] = {
|
||||
};
|
||||
#endif /* PPP_COMPRESS */
|
||||
|
||||
extern struct ifqueue ipintrq;
|
||||
static struct timeval ppp_time;
|
||||
|
||||
#ifndef __rtems__
|
||||
@@ -198,13 +203,12 @@ TEXT_SET(pseudo_set, ppp_rxdaemon);
|
||||
static int
|
||||
ppp_unit(struct ppp_softc *sc)
|
||||
{
|
||||
return sc->sc_if.if_unit;
|
||||
return device_get_unit(sc->sc_dev);
|
||||
}
|
||||
|
||||
static rtems_task ppp_rxdaemon(rtems_task_argument arg)
|
||||
{
|
||||
rtems_event_set events;
|
||||
rtems_interrupt_level level;
|
||||
struct ppp_softc *sc = (struct ppp_softc *)arg;
|
||||
struct mbuf *mp = (struct mbuf *)0;
|
||||
struct mbuf *m;
|
||||
@@ -219,15 +223,10 @@ static rtems_task ppp_rxdaemon(rtems_task_argument arg)
|
||||
}
|
||||
|
||||
if ( events ) {
|
||||
/* get the network semaphore */
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
|
||||
/* check to see if new packet was received */
|
||||
if ( events & RX_PACKET ) {
|
||||
/* get received packet mbuf chain */
|
||||
rtems_interrupt_disable(level);
|
||||
IF_DEQUEUE(&sc->sc_rawq, m);
|
||||
rtems_interrupt_enable(level);
|
||||
m = if_ppp_dequeue(&sc->sc_rawq);
|
||||
|
||||
/* ensure packet was retrieved */
|
||||
if ( m != (struct mbuf *)0 ) {
|
||||
@@ -242,14 +241,9 @@ static rtems_task ppp_rxdaemon(rtems_task_argument arg)
|
||||
}
|
||||
|
||||
/* place mbuf on freeq */
|
||||
rtems_interrupt_disable(level);
|
||||
IF_ENQUEUE(&sc->sc_freeq, mp);
|
||||
rtems_interrupt_enable(level);
|
||||
if_ppp_enqueue(&sc->sc_freeq, mp);
|
||||
mp = (struct mbuf *)0;
|
||||
|
||||
/* release the network semaphore */
|
||||
rtems_bsdnet_semaphore_release();
|
||||
|
||||
/* check to see if queue is empty */
|
||||
if ( sc->sc_rawq.ifq_head ) {
|
||||
/* queue is not empty - post another event */
|
||||
@@ -279,11 +273,7 @@ static rtems_task ppp_txdaemon(rtems_task_argument arg)
|
||||
rtems_event_receive(TX_PACKET|TX_TRANSMIT,RTEMS_WAIT|RTEMS_EVENT_ANY,RTEMS_NO_TIMEOUT,&events);
|
||||
if ( events & TX_TRANSMIT ) {
|
||||
/* received event from interrupt handler - free current mbuf */
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
|
||||
m_freem(sc->sc_outm);
|
||||
|
||||
rtems_bsdnet_semaphore_release();
|
||||
|
||||
/* chain is done - clear the values */
|
||||
sc->sc_outm = (struct mbuf *)0;
|
||||
@@ -303,13 +293,13 @@ static rtems_task ppp_txdaemon(rtems_task_argument arg)
|
||||
if ( sc->sc_outm == NULL ) {
|
||||
/* clear output flags */
|
||||
sc->sc_outflag = 0;
|
||||
sc->sc_if.if_flags &= ~IFF_OACTIVE;
|
||||
sc->sc_ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
||||
}
|
||||
else {
|
||||
/* set flag to start process */
|
||||
iprocess = 1;
|
||||
sc->sc_outflag = SC_TX_BUSY;
|
||||
sc->sc_if.if_flags |= IFF_OACTIVE;
|
||||
sc->sc_ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -389,7 +379,7 @@ static rtems_task ppp_txdaemon(rtems_task_argument arg)
|
||||
/* place FCS value into buffer */
|
||||
sc->sc_outfcsbuf[sc->sc_outfcslen++] = ~sc->sc_outfcs & 0xff;
|
||||
sc->sc_outfcsbuf[sc->sc_outfcslen++] = (~sc->sc_outfcs >> 8) & 0xff;
|
||||
microtime(&sc->sc_if.if_lastchange);
|
||||
microtime(&sc->sc_ifp->if_lastchange);
|
||||
|
||||
/* write out frame byte to start the transmission */
|
||||
sc->sc_outchar = (u_char)PPP_FLAG;
|
||||
@@ -399,9 +389,7 @@ static rtems_task ppp_txdaemon(rtems_task_argument arg)
|
||||
/* check to see if we need to free some empty mbufs */
|
||||
if ( mf != (struct mbuf *)0 ) {
|
||||
/* free empty mbufs */
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
m_freem(mf);
|
||||
rtems_bsdnet_semaphore_release();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,11 +400,6 @@ static void ppp_init(struct ppp_softc *sc)
|
||||
rtems_status_code status;
|
||||
uint32_t priority = 100;
|
||||
|
||||
/* determine priority value */
|
||||
if ( rtems_bsdnet_config.network_task_priority ) {
|
||||
priority = rtems_bsdnet_config.network_task_priority;
|
||||
}
|
||||
|
||||
/* check to see if we need to start up daemons */
|
||||
if ( sc->sc_rxtask == 0 ) {
|
||||
/* start rx daemon task */
|
||||
@@ -452,54 +435,50 @@ static void ppp_init(struct ppp_softc *sc)
|
||||
|
||||
/* mark driver running and output inactive */
|
||||
/* ilya: IFF_RUNNING flag will be marked after the IPCP goes up */
|
||||
/* sc->sc_if.if_flags |= IFF_RUNNING; */
|
||||
/* sc->sc_ifp->if_flags |= IFF_RUNNING; */
|
||||
}
|
||||
|
||||
/*
|
||||
* Called from boot code to establish ppp interfaces.
|
||||
*/
|
||||
int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
|
||||
static int ppp_attach(device_t dev)
|
||||
{
|
||||
/* int i = (int)0; */
|
||||
struct ppp_softc *sc;
|
||||
char *name;
|
||||
int number;
|
||||
|
||||
|
||||
number = rtems_bsdnet_parse_driver_name (config, &name);
|
||||
|
||||
if (!attaching || (number >= NPPP))
|
||||
return 0;
|
||||
|
||||
sc = &ppp_softc[number];
|
||||
|
||||
if (sc->sc_if.if_name != NULL)
|
||||
return 0; /* interface is already attached */
|
||||
|
||||
/* for (sc = ppp_softc; i < NPPP; sc++) { */
|
||||
sc->sc_if.if_name = name /*"ppp"*/;
|
||||
sc->sc_if.if_unit = number /*i++*/;
|
||||
sc->sc_if.if_mtu = PPP_MTU;
|
||||
sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
|
||||
sc->sc_if.if_type = IFT_PPP;
|
||||
sc->sc_if.if_hdrlen = PPP_HDRLEN;
|
||||
sc->sc_if.if_ioctl = pppsioctl;
|
||||
sc->sc_if.if_output = pppoutput;
|
||||
sc->sc_if.if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->sc_freeq.ifq_maxlen = NUM_MBUFQ;
|
||||
int unit = device_get_unit(dev);
|
||||
struct ppp_softc *sc;
|
||||
struct ifnet *ifp;
|
||||
|
||||
/* initialize and attach */
|
||||
ppp_init(sc);
|
||||
if_attach(&sc->sc_if);
|
||||
#if NBPFILTER > 0
|
||||
bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
|
||||
#endif
|
||||
/* } */
|
||||
if (unit >= NPPP)
|
||||
return (ENXIO);
|
||||
|
||||
return ( 1 );
|
||||
sc = &ppp_softc[unit];
|
||||
device_set_softc(dev, sc);
|
||||
|
||||
sc->sc_ifp = ifp = if_alloc(IFT_PPP);
|
||||
if (sc->sc_ifp == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
sc->sc_dev = dev;
|
||||
sc->sc_inq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
|
||||
sc->sc_freeq.ifq_maxlen = NUM_MBUFQ;
|
||||
|
||||
ifq_init(&sc->sc_fastq, ifp);
|
||||
|
||||
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
||||
ifp->if_softc = sc;
|
||||
ifp->if_mtu = PPP_MTU;
|
||||
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
|
||||
ifp->if_type = IFT_PPP;
|
||||
ifp->if_hdrlen = PPP_HDRLEN;
|
||||
ifp->if_ioctl = pppsioctl;
|
||||
ifp->if_output = pppoutput;
|
||||
ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;
|
||||
|
||||
/* initialize and attach */
|
||||
ppp_init(sc);
|
||||
if_attach(ifp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -553,14 +532,13 @@ void
|
||||
pppdealloc(struct ppp_softc *sc)
|
||||
{
|
||||
struct mbuf *m;
|
||||
rtems_interrupt_level level;
|
||||
|
||||
if_down(&sc->sc_if);
|
||||
sc->sc_if.if_flags &= ~(IFF_UP|IFF_RUNNING);
|
||||
if_down(sc->sc_ifp);
|
||||
sc->sc_ifp->if_flags &= ~IFF_UP;
|
||||
sc->sc_ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
||||
sc->sc_devp = NULL;
|
||||
sc->sc_xfer = 0;
|
||||
|
||||
rtems_interrupt_disable(level);
|
||||
if ( sc->sc_m != NULL ) {
|
||||
m_freem(sc->sc_m);
|
||||
sc->sc_m = (struct mbuf *)0;
|
||||
@@ -572,18 +550,17 @@ pppdealloc(struct ppp_softc *sc)
|
||||
sc->sc_outflag = 0;
|
||||
}
|
||||
do {
|
||||
IF_DEQUEUE(&sc->sc_freeq, m);
|
||||
m = if_ppp_dequeue(&sc->sc_freeq);
|
||||
if (m != NULL) {
|
||||
m_freem(m);
|
||||
}
|
||||
} while ( m != NULL );
|
||||
do {
|
||||
IF_DEQUEUE(&sc->sc_rawq, m);
|
||||
m = if_ppp_dequeue(&sc->sc_rawq);
|
||||
if (m != NULL) {
|
||||
m_freem(m);
|
||||
}
|
||||
} while ( m != NULL );
|
||||
rtems_interrupt_enable(level);
|
||||
|
||||
for (;;) {
|
||||
IF_DEQUEUE(&sc->sc_inq, m);
|
||||
@@ -850,7 +827,7 @@ static int
|
||||
pppsioctl(struct ifnet *ifp, ioctl_command_t cmd, caddr_t data)
|
||||
{
|
||||
/*struct proc *p = curproc;*/ /* XXX */
|
||||
register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
|
||||
register struct ppp_softc *sc = ifp->if_softc;
|
||||
register struct ifaddr *ifa = (struct ifaddr *)data;
|
||||
register struct ifreq *ifr = (struct ifreq *)data;
|
||||
struct ppp_stats *psp;
|
||||
@@ -861,7 +838,7 @@ pppsioctl(struct ifnet *ifp, ioctl_command_t cmd, caddr_t data)
|
||||
|
||||
switch (cmd) {
|
||||
case SIOCSIFFLAGS:
|
||||
if ((ifp->if_flags & IFF_RUNNING) == 0)
|
||||
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
|
||||
ifp->if_flags &= ~IFF_UP;
|
||||
break;
|
||||
|
||||
@@ -876,11 +853,11 @@ pppsioctl(struct ifnet *ifp, ioctl_command_t cmd, caddr_t data)
|
||||
break;
|
||||
|
||||
case SIOCSIFMTU:
|
||||
sc->sc_if.if_mtu = ifr->ifr_mtu;
|
||||
sc->sc_ifp->if_mtu = ifr->ifr_mtu;
|
||||
break;
|
||||
|
||||
case SIOCGIFMTU:
|
||||
ifr->ifr_mtu = sc->sc_if.if_mtu;
|
||||
ifr->ifr_mtu = sc->sc_ifp->if_mtu;
|
||||
break;
|
||||
|
||||
case SIOCADDMULTI:
|
||||
@@ -900,16 +877,6 @@ pppsioctl(struct ifnet *ifp, ioctl_command_t cmd, caddr_t data)
|
||||
}
|
||||
break;
|
||||
|
||||
case SIO_RTEMS_SHOW_STATS:
|
||||
printf(" MRU:%-8u", sc->sc_mru);
|
||||
printf(" Bytes received:%-8u", sc->sc_stats.ppp_ibytes);
|
||||
printf(" Packets received:%-8u", sc->sc_stats.ppp_ipackets);
|
||||
printf(" Receive errors:%-8u\n", sc->sc_stats.ppp_ierrors);
|
||||
printf(" Bytes sent:%-8u", sc->sc_stats.ppp_obytes);
|
||||
printf(" Packets sent:%-8u", sc->sc_stats.ppp_opackets);
|
||||
printf(" Transmit errors:%-8u\n", sc->sc_stats.ppp_oerrors);
|
||||
break;
|
||||
|
||||
case SIOCGPPPSTATS:
|
||||
psp = &((struct ifpppstatsreq *) data)->stats;
|
||||
bzero(psp, sizeof(*psp));
|
||||
@@ -952,19 +919,19 @@ pppsioctl(struct ifnet *ifp, ioctl_command_t cmd, caddr_t data)
|
||||
*/
|
||||
int
|
||||
pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
|
||||
struct rtentry *rtp)
|
||||
struct route *rtp)
|
||||
{
|
||||
register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
|
||||
register struct ppp_softc *sc = ifp->if_softc;
|
||||
int protocol, address, control;
|
||||
u_char *cp;
|
||||
int s, error;
|
||||
struct ip *ip;
|
||||
struct ifqueue *ifq;
|
||||
struct ifaltq *ifq;
|
||||
enum NPmode mode;
|
||||
int len;
|
||||
struct mbuf *m;
|
||||
|
||||
if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
|
||||
if (sc->sc_devp == NULL || (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0
|
||||
|| ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
|
||||
error = ENETDOWN; /* sort of */
|
||||
goto bad;
|
||||
@@ -1095,10 +1062,10 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, struct sockaddr *dst,
|
||||
sc->sc_npqtail = &m0->m_nextpkt;
|
||||
} else {
|
||||
ifq = (m0->m_flags & M_HIGHPRI)? &sc->sc_fastq: &ifp->if_snd;
|
||||
if (IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
|
||||
IF_DROP(ifq);
|
||||
if (_IF_QFULL(ifq) && dst->sa_family != AF_UNSPEC) {
|
||||
IFQ_INC_DROPS(ifq);
|
||||
splx(s);
|
||||
sc->sc_if.if_oerrors++;
|
||||
sc->sc_ifp->if_oerrors++;
|
||||
sc->sc_stats.ppp_oerrors++;
|
||||
error = ENOBUFS;
|
||||
goto bad;
|
||||
@@ -1127,7 +1094,7 @@ static void
|
||||
ppp_requeue(struct ppp_softc *sc)
|
||||
{
|
||||
struct mbuf *m, **mpp;
|
||||
struct ifqueue *ifq;
|
||||
struct ifaltq *ifq;
|
||||
enum NPmode mode;
|
||||
|
||||
for (mpp = &sc->sc_npqueue; (m = *mpp) != NULL; ) {
|
||||
@@ -1146,10 +1113,10 @@ ppp_requeue(struct ppp_softc *sc)
|
||||
*/
|
||||
*mpp = m->m_nextpkt;
|
||||
m->m_nextpkt = NULL;
|
||||
ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_if.if_snd;
|
||||
if (IF_QFULL(ifq)) {
|
||||
IF_DROP(ifq);
|
||||
sc->sc_if.if_oerrors++;
|
||||
ifq = (m->m_flags & M_HIGHPRI)? &sc->sc_fastq: &sc->sc_ifp->if_snd;
|
||||
if (_IF_QFULL(ifq)) {
|
||||
IFQ_INC_DROPS(ifq);
|
||||
sc->sc_ifp->if_oerrors++;
|
||||
sc->sc_stats.ppp_oerrors++;
|
||||
} else
|
||||
IF_ENQUEUE(ifq, m);
|
||||
@@ -1189,11 +1156,9 @@ ppp_dequeue(struct ppp_softc *sc)
|
||||
* Grab a packet to send: first try the fast queue, then the
|
||||
* normal queue.
|
||||
*/
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
IF_DEQUEUE(&sc->sc_fastq, m);
|
||||
if (m == NULL)
|
||||
IF_DEQUEUE(&sc->sc_if.if_snd, m);
|
||||
rtems_bsdnet_semaphore_release();
|
||||
IF_DEQUEUE(&sc->sc_ifp->if_snd, m);
|
||||
|
||||
if (m == NULL)
|
||||
return NULL;
|
||||
@@ -1266,7 +1231,7 @@ ppp_dequeue(struct ppp_softc *sc)
|
||||
for (mp = m; mp != NULL; mp = mp->m_next)
|
||||
slen += mp->m_len;
|
||||
clen = (*sc->sc_xcomp->compress)
|
||||
(sc->sc_xc_state, &mcomp, m, slen, sc->sc_if.if_mtu + PPP_HDRLEN);
|
||||
(sc->sc_xc_state, &mcomp, m, slen, sc->sc_ifp->if_mtu + PPP_HDRLEN);
|
||||
if (mcomp != NULL) {
|
||||
if (sc->sc_flags & SC_CCP_UP) {
|
||||
/* Send the compressed packet instead of the original. */
|
||||
@@ -1429,7 +1394,7 @@ static struct mbuf *
|
||||
ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
|
||||
{
|
||||
struct mbuf *mf = (struct mbuf *)0;
|
||||
struct ifnet *ifp = &sc->sc_if;
|
||||
struct ifnet *ifp = sc->sc_ifp;
|
||||
struct ifqueue *inq;
|
||||
int s, ilen, proto, rv;
|
||||
u_char *cp;
|
||||
@@ -1680,8 +1645,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
|
||||
m->m_pkthdr.len -= PPP_HDRLEN;
|
||||
m->m_data += PPP_HDRLEN;
|
||||
m->m_len -= PPP_HDRLEN;
|
||||
schednetisr(NETISR_IP);
|
||||
inq = &ipintrq;
|
||||
netisr_dispatch(NETISR_IP, m);
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -1691,24 +1655,25 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
|
||||
*/
|
||||
inq = &sc->sc_inq;
|
||||
rv = 1;
|
||||
|
||||
/*
|
||||
* Put the packet on the appropriate input queue.
|
||||
*/
|
||||
s = splimp();
|
||||
if (_IF_QFULL(inq)) {
|
||||
IFQ_INC_DROPS(inq);
|
||||
splx(s);
|
||||
if (sc->sc_flags & SC_DEBUG)
|
||||
printf("ppp%d: input queue full\n", ppp_unit(sc));
|
||||
ifp->if_iqdrops++;
|
||||
goto bad;
|
||||
}
|
||||
IF_ENQUEUE(inq, m);
|
||||
splx(s);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Put the packet on the appropriate input queue.
|
||||
*/
|
||||
s = splimp();
|
||||
if (IF_QFULL(inq)) {
|
||||
IF_DROP(inq);
|
||||
splx(s);
|
||||
if (sc->sc_flags & SC_DEBUG)
|
||||
printf("ppp%d: input queue full\n", ppp_unit(sc));
|
||||
ifp->if_iqdrops++;
|
||||
goto bad;
|
||||
}
|
||||
IF_ENQUEUE(inq, m);
|
||||
splx(s);
|
||||
|
||||
ifp->if_ipackets++;
|
||||
ifp->if_ibytes += ilen;
|
||||
microtime(&ppp_time);
|
||||
@@ -1722,7 +1687,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
|
||||
|
||||
bad:
|
||||
m_freem(m);
|
||||
sc->sc_if.if_ierrors++;
|
||||
sc->sc_ifp->if_ierrors++;
|
||||
sc->sc_stats.ppp_ierrors++;
|
||||
return mf;
|
||||
}
|
||||
@@ -1762,4 +1727,40 @@ done:
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
|
||||
static int ppp_probe(device_t dev)
|
||||
{
|
||||
int unit = device_get_unit(dev);
|
||||
int error;
|
||||
|
||||
if (unit < NPPP) {
|
||||
error = BUS_PROBE_DEFAULT;
|
||||
} else {
|
||||
error = ENXIO;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
static device_method_t ppp_methods[] = {
|
||||
/* Device interface */
|
||||
DEVMETHOD(device_probe, ppp_probe),
|
||||
DEVMETHOD(device_attach, ppp_attach),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
static driver_t ppp_nexus_driver = {
|
||||
"ppp",
|
||||
ppp_methods,
|
||||
0,
|
||||
NULL,
|
||||
0,
|
||||
NULL
|
||||
};
|
||||
|
||||
static devclass_t ppp_devclass;
|
||||
|
||||
DRIVER_MODULE(ppp, nexus, ppp_nexus_driver, ppp_devclass, 0, 0);
|
||||
MODULE_DEPEND(ppp, nexus, 1, 1, 1);
|
||||
|
||||
#endif /* NPPP > 0 */
|
||||
|
@@ -69,7 +69,9 @@ struct proc;
|
||||
* Structure describing each ppp unit.
|
||||
*/
|
||||
struct ppp_softc {
|
||||
struct ifnet sc_if; /* network-visible interface */
|
||||
device_t sc_dev;
|
||||
struct mtx sc_mtx;
|
||||
struct ifnet *sc_ifp; /* network-visible interface */
|
||||
u_int sc_flags; /* control/status bits; see if_ppp.h */
|
||||
void *sc_devp; /* pointer to device-dep structure */
|
||||
void (*sc_start)(struct ppp_softc *); /* start output proc */
|
||||
@@ -77,9 +79,9 @@ struct ppp_softc {
|
||||
void (*sc_relinq)(struct ppp_softc *); /* relinquish ifunit */
|
||||
short sc_mru; /* max receive unit */
|
||||
pid_t sc_xfer; /* used in transferring unit */
|
||||
struct ifqueue sc_rawq; /* received packets */
|
||||
struct ifqueue sc_rawq; /* received packets */
|
||||
struct ifqueue sc_inq; /* queue of input packets for daemon */
|
||||
struct ifqueue sc_fastq; /* interactive output packet q */
|
||||
struct ifaltq sc_fastq; /* interactive output packet q */
|
||||
struct mbuf *sc_npqueue; /* output packets not to be sent yet */
|
||||
struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */
|
||||
struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */
|
||||
@@ -130,7 +132,7 @@ struct ppp_softc {
|
||||
struct ppp_softc *pppalloc(pid_t pid);
|
||||
void pppdealloc(struct ppp_softc *sc);
|
||||
int pppoutput(struct ifnet *, struct mbuf *,
|
||||
struct sockaddr *, struct rtentry *);
|
||||
struct sockaddr *, struct route *);
|
||||
int pppioctl(struct ppp_softc *sc, ioctl_command_t cmd, caddr_t data,
|
||||
int flag, struct proc *p);
|
||||
struct mbuf *ppp_dequeue(struct ppp_softc *sc);
|
||||
@@ -153,6 +155,34 @@ void pppallocmbuf(struct ppp_softc *sc, struct mbuf **mp);
|
||||
#define SC_TX_LASTCHAR 0x0008
|
||||
#define SC_TX_PENDING 0x0010
|
||||
|
||||
/*
|
||||
* Special interface queue functions to exchange mbufs between task and
|
||||
* interrupt context via pppinput() and pppstart().
|
||||
*/
|
||||
|
||||
static inline void
|
||||
if_ppp_enqueue(struct ifqueue *ifq, struct mbuf *m)
|
||||
{
|
||||
rtems_interrupt_level level;
|
||||
|
||||
rtems_interrupt_disable(level);
|
||||
_IF_ENQUEUE(ifq, m);
|
||||
rtems_interrupt_enable(level);
|
||||
}
|
||||
|
||||
static inline struct mbuf *
|
||||
if_ppp_dequeue(struct ifqueue *ifq)
|
||||
{
|
||||
struct mbuf *m;
|
||||
rtems_interrupt_level level;
|
||||
|
||||
rtems_interrupt_disable(level);
|
||||
_IF_DEQUEUE(ifq, m);
|
||||
rtems_interrupt_enable(level);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#include <machine/rtems-bsd-kernel-space.h>
|
||||
|
||||
/*
|
||||
* ppp_tty.c - Point-to-Point Protocol (PPP) driver for asynchronous
|
||||
* tty devices.
|
||||
@@ -78,11 +80,11 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "opt_ppp.h" /* XXX for ppp_defs.h */
|
||||
#include <rtems/bsd/local/opt_ppp.h> /* XXX for ppp_defs.h */
|
||||
|
||||
#if NPPP > 0
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <rtems/bsd/sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/mbuf.h>
|
||||
@@ -226,7 +228,6 @@ pppopen(struct rtems_termios_tty *tty)
|
||||
sc->sc_outmc = NULL;
|
||||
|
||||
/* preallocate mbufs for free queue */
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
for (i=0; i<NUM_MBUFQ; i++) {
|
||||
pppallocmbuf(sc, &m);
|
||||
if ( i == 0 ) {
|
||||
@@ -235,15 +236,14 @@ pppopen(struct rtems_termios_tty *tty)
|
||||
}
|
||||
else {
|
||||
/* enqueue mbuf for later use */
|
||||
IF_ENQUEUE(&sc->sc_freeq, m);
|
||||
if_ppp_enqueue(&sc->sc_freeq, m);
|
||||
}
|
||||
m = (struct mbuf *)0;
|
||||
}
|
||||
rtems_bsdnet_semaphore_release();
|
||||
|
||||
/* initialize values */
|
||||
sc->sc_if.if_flags |= IFF_RUNNING;
|
||||
sc->sc_if.if_baudrate =
|
||||
sc->sc_ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
||||
sc->sc_ifp->if_baudrate =
|
||||
rtems_termios_baud_to_number(tty->termios.c_cflag & CBAUD);
|
||||
|
||||
tty->t_sc = (void *)sc;
|
||||
@@ -267,10 +267,8 @@ pppclose(struct rtems_termios_tty *tty)
|
||||
if (sc != NULL) {
|
||||
tty->t_sc = NULL;
|
||||
if (tty == (struct rtems_termios_tty *)sc->sc_devp) {
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
pppasyncrelinq(sc);
|
||||
pppdealloc(sc);
|
||||
rtems_bsdnet_semaphore_release();
|
||||
}
|
||||
}
|
||||
return ( RTEMS_SUCCESSFUL );
|
||||
@@ -328,7 +326,6 @@ pppread(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
|
||||
}
|
||||
|
||||
/* Get the packet from the input queue */
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
IF_DEQUEUE(&sc->sc_inq, m0);
|
||||
|
||||
/* loop over mbuf chain */
|
||||
@@ -347,7 +344,6 @@ pppread(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
|
||||
|
||||
/* free mbuf chain */
|
||||
m_freem(m0);
|
||||
rtems_bsdnet_semaphore_release();
|
||||
|
||||
/* update return values */
|
||||
rw_args->bytes_moved = count;
|
||||
@@ -380,7 +376,6 @@ pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
|
||||
struct mbuf *m0;
|
||||
struct mbuf **mp;
|
||||
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
for (mp = &m0; maximum; mp = &m->m_next) {
|
||||
MGET(m, M_WAIT, MT_DATA);
|
||||
if ((*mp = m) == NULL) {
|
||||
@@ -410,8 +405,7 @@ pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
|
||||
m0->m_data += PPP_HDRLEN;
|
||||
m0->m_len -= PPP_HDRLEN;
|
||||
|
||||
n = pppoutput(&sc->sc_if, m0, &dst, (struct rtentry *)0);
|
||||
rtems_bsdnet_semaphore_release();
|
||||
n = pppoutput(sc->sc_ifp, m0, &dst, NULL);
|
||||
|
||||
return ( n );
|
||||
}
|
||||
@@ -470,9 +464,7 @@ ppptioctl(struct rtems_termios_tty *tty, rtems_libio_ioctl_args_t *args)
|
||||
break;
|
||||
|
||||
default:
|
||||
rtems_bsdnet_semaphore_obtain();
|
||||
error = pppioctl(sc, cmd, data, 0, NULL);
|
||||
rtems_bsdnet_semaphore_release();
|
||||
}
|
||||
return error;
|
||||
}
|
||||
@@ -746,7 +738,7 @@ pppinput(int c, struct rtems_termios_tty *tp)
|
||||
return 0;
|
||||
if (sc->sc_m == NULL) {
|
||||
rtems_event_send(sc->sc_rxtask, RX_EMPTY);
|
||||
IF_DEQUEUE(&sc->sc_freeq, sc->sc_m);
|
||||
sc->sc_m = if_ppp_dequeue(&sc->sc_freeq);
|
||||
if ( sc->sc_m == NULL ) {
|
||||
return 0;
|
||||
}
|
||||
@@ -777,7 +769,7 @@ pppinput(int c, struct rtems_termios_tty *tp)
|
||||
sc->sc_flags |= SC_PKTLOST; /* note the dropped packet */
|
||||
if ((sc->sc_flags & (SC_FLUSH | SC_ESCAPED)) == 0){
|
||||
/* bad fcs error */
|
||||
sc->sc_if.if_ierrors++;
|
||||
sc->sc_ifp->if_ierrors++;
|
||||
sc->sc_stats.ppp_ierrors++;
|
||||
} else
|
||||
sc->sc_flags &= ~(SC_FLUSH | SC_ESCAPED);
|
||||
@@ -787,7 +779,7 @@ pppinput(int c, struct rtems_termios_tty *tp)
|
||||
if (ilen < PPP_HDRLEN + PPP_FCSLEN) {
|
||||
if (ilen) {
|
||||
/* too short error */
|
||||
sc->sc_if.if_ierrors++;
|
||||
sc->sc_ifp->if_ierrors++;
|
||||
sc->sc_stats.ppp_ierrors++;
|
||||
sc->sc_flags |= SC_PKTLOST;
|
||||
}
|
||||
@@ -808,10 +800,10 @@ pppinput(int c, struct rtems_termios_tty *tp)
|
||||
m->m_flags |= M_ERRMARK;
|
||||
sc->sc_flags &= ~SC_PKTLOST;
|
||||
}
|
||||
IF_ENQUEUE(&sc->sc_rawq, m);
|
||||
if_ppp_enqueue(&sc->sc_rawq, m);
|
||||
|
||||
/* setup next mbuf chain */
|
||||
IF_DEQUEUE(&sc->sc_freeq, sc->sc_m);
|
||||
sc->sc_m = if_ppp_dequeue(&sc->sc_freeq);
|
||||
|
||||
/* send rx packet event */
|
||||
rtems_event_send(sc->sc_rxtask, RX_PACKET);
|
||||
@@ -882,7 +874,7 @@ pppinput(int c, struct rtems_termios_tty *tp)
|
||||
if (M_TRAILINGSPACE(m) <= 0) {
|
||||
if (m->m_next == NULL) {
|
||||
/* get next available mbuf for the chain */
|
||||
IF_DEQUEUE(&sc->sc_freeq, m->m_next);
|
||||
m->m_next = if_ppp_dequeue(&sc->sc_freeq);
|
||||
if (m->m_next == NULL) {
|
||||
/* too few mbufs */
|
||||
goto flush;
|
||||
@@ -906,7 +898,7 @@ pppinput(int c, struct rtems_termios_tty *tp)
|
||||
|
||||
flush:
|
||||
if (!(sc->sc_flags & SC_FLUSH)) {
|
||||
sc->sc_if.if_ierrors++;
|
||||
sc->sc_ifp->if_ierrors++;
|
||||
sc->sc_stats.ppp_ierrors++;
|
||||
sc->sc_flags |= SC_FLUSH;
|
||||
}
|
||||
|
281
testsuite/ppp01/test_main.c
Normal file
281
testsuite/ppp01/test_main.c
Normal file
@@ -0,0 +1,281 @@
|
||||
/*
|
||||
* Copyright (c) 2014 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* To test PPP connect the RTEMS target with your host. Start PPP on the host
|
||||
* with something like this:
|
||||
*
|
||||
* pppd nodetach noauth 192.168.100.11:192.168.100.70 proxyarp 115200 dump \
|
||||
* local nocrtscts debug mtu 296 mru 296 nolock ms-dns 192.168.96.1 /dev/ttyS0
|
||||
*
|
||||
* Make sure IP forwarding is enabled and check the firewall settings if you
|
||||
* want to access the internet.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sysexits.h>
|
||||
|
||||
#include <machine/rtems-bsd-commands.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/bsd/bsd.h>
|
||||
#include <rtems/telnetd.h>
|
||||
#include <rtems/ftpd.h>
|
||||
#include <rtems/rtemspppd.h>
|
||||
|
||||
#define TEST_NAME "LIBBSD PPP 1"
|
||||
|
||||
static void
|
||||
set_pppd_options(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = rtems_pppd_set_option("/dev/ttyS1", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("115200", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("crtscts", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("debug", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("defaultroute", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("local", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("noauth", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("noipdefault", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("usepeerdns", NULL);
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("password", "wurst");
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("user", "hans");
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("mru", "296");
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("mtu", "296");
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("lcp-echo-failure", "5");
|
||||
assert(rv == 1);
|
||||
|
||||
rv = rtems_pppd_set_option("lcp-echo-interval", "5");
|
||||
assert(rv == 1);
|
||||
}
|
||||
|
||||
static void
|
||||
linkup_hook(void)
|
||||
{
|
||||
printf("linkup hook\n");
|
||||
}
|
||||
|
||||
static void
|
||||
linkdown_hook(void)
|
||||
{
|
||||
printf("linkdown hook\n");
|
||||
}
|
||||
|
||||
static void
|
||||
ipup_hook(void)
|
||||
{
|
||||
static bool first = true;
|
||||
|
||||
printf("ipup hook\n");
|
||||
|
||||
if (first) {
|
||||
int rv;
|
||||
rtems_status_code sc;
|
||||
|
||||
first = false;
|
||||
|
||||
sc = rtems_telnetd_initialize();
|
||||
assert(sc == RTEMS_SUCCESSFUL);
|
||||
|
||||
rv = rtems_initialize_ftpd();
|
||||
assert(rv == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ipdown_hook(void)
|
||||
{
|
||||
printf("ipdown hook\n");
|
||||
}
|
||||
|
||||
static void
|
||||
exit_hook(void)
|
||||
{
|
||||
printf("exit hook\n");
|
||||
}
|
||||
|
||||
static void
|
||||
error_hook(void)
|
||||
{
|
||||
printf("error hook\n");
|
||||
}
|
||||
|
||||
static void
|
||||
set_pppd_hooks(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
rv = rtems_pppd_set_hook(RTEMS_PPPD_LINKUP_HOOK, linkup_hook);
|
||||
assert(rv == 0);
|
||||
|
||||
rv = rtems_pppd_set_hook(RTEMS_PPPD_LINKDOWN_HOOK, linkdown_hook);
|
||||
assert(rv == 0);
|
||||
|
||||
rv = rtems_pppd_set_hook(RTEMS_PPPD_IPUP_HOOK, ipup_hook);
|
||||
assert(rv == 0);
|
||||
|
||||
rv = rtems_pppd_set_hook(RTEMS_PPPD_IPDOWN_HOOK, ipdown_hook);
|
||||
assert(rv == 0);
|
||||
|
||||
rv = rtems_pppd_set_hook(RTEMS_PPPD_EXIT_HOOK, exit_hook);
|
||||
assert(rv == 0);
|
||||
|
||||
rv = rtems_pppd_set_hook(RTEMS_PPPD_ERROR_HOOK, error_hook);
|
||||
assert(rv == 0);
|
||||
}
|
||||
|
||||
static void
|
||||
ifconfig_ppp0(void)
|
||||
{
|
||||
int exit_code;
|
||||
char *ifcfg[] = {
|
||||
"ifconfig",
|
||||
"ppp0",
|
||||
"up",
|
||||
NULL
|
||||
};
|
||||
|
||||
exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(ifcfg), ifcfg);
|
||||
assert(exit_code == EX_OK);
|
||||
}
|
||||
|
||||
static void
|
||||
telnet_shell(char *name, void *arg)
|
||||
{
|
||||
rtems_shell_env_t env;
|
||||
|
||||
memset(&env, 0, sizeof(env));
|
||||
|
||||
env.devname = name;
|
||||
env.taskname = "TLNT";
|
||||
env.login_check = NULL;
|
||||
env.forever = false;
|
||||
|
||||
rtems_shell_main_loop(&env);
|
||||
}
|
||||
|
||||
rtems_telnetd_config_table rtems_telnetd_config = {
|
||||
.command = telnet_shell,
|
||||
.arg = NULL,
|
||||
.priority = 0,
|
||||
.stack_size = 0,
|
||||
.login_check = NULL,
|
||||
.keep_stdio = false
|
||||
};
|
||||
|
||||
struct rtems_ftpd_configuration rtems_ftpd_configuration = {
|
||||
/* FTPD task priority */
|
||||
.priority = 100,
|
||||
|
||||
/* Maximum buffersize for hooks */
|
||||
.max_hook_filesize = 0,
|
||||
|
||||
/* Well-known port */
|
||||
.port = 21,
|
||||
|
||||
/* List of hooks */
|
||||
.hooks = NULL,
|
||||
|
||||
/* Root for FTPD or NULL for "/" */
|
||||
.root = NULL,
|
||||
|
||||
/* Max. connections */
|
||||
.tasks_count = 4,
|
||||
|
||||
/* Idle timeout in seconds or 0 for no (infinite) timeout */
|
||||
.idle = 5 * 60,
|
||||
|
||||
/* Access: 0 - r/w, 1 - read-only, 2 - write-only, 3 - browse-only */
|
||||
.access = 0
|
||||
};
|
||||
|
||||
static void
|
||||
test_main(void)
|
||||
{
|
||||
int rv;
|
||||
|
||||
ifconfig_ppp0();
|
||||
|
||||
rv = rtems_pppd_initialize();
|
||||
assert(rv == 0);
|
||||
|
||||
set_pppd_options();
|
||||
set_pppd_hooks();
|
||||
|
||||
rv = rtems_pppd_connect();
|
||||
assert(rv == 0);
|
||||
|
||||
rtems_task_delete(RTEMS_SELF);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
RTEMS_BSD_DEFINE_NEXUS_DEVICE(ppp, 0, 0, NULL);
|
||||
|
||||
#define CONFIGURE_MAXIMUM_DRIVERS 32
|
||||
|
||||
#define DEFAULT_NETWORK_SHELL
|
||||
#define DEFAULT_NETWORK_DHCPCD_ENABLE
|
||||
#define DEFAULT_NETWORK_NO_INTERFACE_0
|
||||
|
||||
#include <rtems/bsd/test/default-network-init.h>
|
Reference in New Issue
Block a user