add part7
This commit is contained in:
parent
039b7355c3
commit
df18091e1f
13
vendor/aw/homlet/Android.bp
vendored
Normal file
13
vendor/aw/homlet/Android.bp
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
optional_subdirs = [
|
||||
"hardware/*/*",
|
||||
"hardware/interface/*/*",
|
||||
"hardware/interface/*/*/*",
|
||||
]
|
||||
|
||||
prebuilt_etc {
|
||||
name: "privapp-vendor-permissions",
|
||||
sub_dir: "permissions",
|
||||
src: "privapp-vendor-permissions.xml",
|
||||
filename_from_src: true,
|
||||
}
|
||||
|
||||
8
vendor/aw/homlet/HomletBoardConfig.mk
vendored
Normal file
8
vendor/aw/homlet/HomletBoardConfig.mk
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
include vendor/aw/homlet/hardware/input/multi_ir/IRConfig.mk
|
||||
# homlet common sepolicy
|
||||
BOARD_SEPOLICY_DIRS += \
|
||||
vendor/aw/homlet/sepolicy
|
||||
|
||||
# homlet private sepolicy
|
||||
SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS += \
|
||||
vendor/aw/homlet/sepolicy/private
|
||||
95
vendor/aw/homlet/binary/Android.mk
vendored
Executable file
95
vendor/aw/homlet/binary/Android.mk
vendored
Executable file
@ -0,0 +1,95 @@
|
||||
# Copyright (C) 2010 The Android Open Source Project
|
||||
#
|
||||
# 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.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := precopy.sh
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := preinstall.sh
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := nfsprobe
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := log_bg.sh
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := genusbid.sh
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := startsoftdetector.sh
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/bin
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libbm_core.so
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := libswboostutils.so
|
||||
LOCAL_MODULE_TAGS := optional
|
||||
LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
|
||||
LOCAL_SRC_FILES := $(LOCAL_MODULE)
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
include $(BUILD_PREBUILT)
|
||||
|
||||
#######################
|
||||
15
vendor/aw/homlet/binary/genusbid.sh
vendored
Executable file
15
vendor/aw/homlet/binary/genusbid.sh
vendored
Executable file
@ -0,0 +1,15 @@
|
||||
#!/sbin/busybox sh
|
||||
|
||||
BUSYBOX="/sbin/busybox"
|
||||
|
||||
if [ ! -e /data/.usbrandom ] ; then
|
||||
echo "do genusbid job"
|
||||
$BUSYBOX echo -e "$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))$((RANDOM%10))\c" > /data/.usbrandom
|
||||
$BUSYBOX touch /data/.usbrandom
|
||||
$BUSYBOX cat /data/.usbrandom > /sys/class/android_usb/android0/iSerial
|
||||
echo "gen ok"
|
||||
else
|
||||
$BUSYBOX cat /data/.usbrandom > /sys/class/android_usb/android0/iSerial
|
||||
echo "set id ok"
|
||||
fi
|
||||
|
||||
BIN
vendor/aw/homlet/binary/libbm_core.so
vendored
Executable file
BIN
vendor/aw/homlet/binary/libbm_core.so
vendored
Executable file
Binary file not shown.
BIN
vendor/aw/homlet/binary/libswboostutils.so
vendored
Executable file
BIN
vendor/aw/homlet/binary/libswboostutils.so
vendored
Executable file
Binary file not shown.
52
vendor/aw/homlet/binary/log_bg.sh
vendored
Executable file
52
vendor/aw/homlet/binary/log_bg.sh
vendored
Executable file
@ -0,0 +1,52 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
let "size = 10"
|
||||
let "count = 0"
|
||||
let i=size-1
|
||||
while [ $i -ge 0 ]
|
||||
do
|
||||
klog="/data/anr/aw_${i}_kernel_boot.log"
|
||||
slog="/data/anr/aw_${i}_system_boot.log"
|
||||
slog_1="/data/anr/aw_${i}_system_boot.log.1"
|
||||
klogr="/data/anr/aw_`expr ${i} + 1`_kernel_boot.log"
|
||||
slogr="/data/anr/aw_`expr ${i} + 1`_system_boot.log"
|
||||
slogr_1="/data/anr/aw_`expr ${i} + 1`_system_boot.log.1"
|
||||
if [ -e ${klog} ]
|
||||
then
|
||||
mv ${klog} ${klogr}
|
||||
fi
|
||||
|
||||
if [ -e ${slog} ]
|
||||
then
|
||||
mv ${slog} ${slogr}
|
||||
fi
|
||||
|
||||
if [ -e ${slog_1} ]
|
||||
then
|
||||
mv ${slog_1} ${slogr_1}
|
||||
fi
|
||||
let i-=1
|
||||
done
|
||||
|
||||
klog="/data/anr/aw_${size}_kernel_boot.log"
|
||||
slog="/data/anr/aw_${size}_system_boot.log"
|
||||
slog_1="/data/anr/aw_${size}_system_boot.log.1"
|
||||
if [ -e ${klog} ]
|
||||
then
|
||||
rm ${klog}
|
||||
fi
|
||||
if [ -e ${slog} ]
|
||||
then
|
||||
rm ${slog}
|
||||
fi
|
||||
if [ -e ${slog_1} ]
|
||||
then
|
||||
rm ${slog_1}
|
||||
fi
|
||||
|
||||
let "count = 0"
|
||||
cat /proc/kmsg >> /data/anr/aw_${count}_kernel_boot.log &
|
||||
sleep 4
|
||||
logcat -v time -f /data/anr/aw_${count}_system_boot.log -n 1 -r 500000 &
|
||||
wait
|
||||
|
||||
BIN
vendor/aw/homlet/binary/mount.exfat
vendored
Normal file
BIN
vendor/aw/homlet/binary/mount.exfat
vendored
Normal file
Binary file not shown.
BIN
vendor/aw/homlet/binary/nfsprobe
vendored
Executable file
BIN
vendor/aw/homlet/binary/nfsprobe
vendored
Executable file
Binary file not shown.
10
vendor/aw/homlet/binary/precopy.sh
vendored
Executable file
10
vendor/aw/homlet/binary/precopy.sh
vendored
Executable file
@ -0,0 +1,10 @@
|
||||
#!/sbin/busybox sh
|
||||
|
||||
BUSYBOX="/sbin/busybox"
|
||||
|
||||
if [ ! -e /data/system.notfirstrun.precopy ]; then
|
||||
$BUSYBOX cp -rfp /system/precopy/* /data/app/
|
||||
chown system:system /data/app/*
|
||||
$BUSYBOX touch /data/system.notfirstrun.precopy
|
||||
fi
|
||||
|
||||
17
vendor/aw/homlet/binary/preinstall.sh
vendored
Executable file
17
vendor/aw/homlet/binary/preinstall.sh
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
#!/sbin/busybox sh
|
||||
|
||||
BUSYBOX="/sbin/busybox"
|
||||
|
||||
if [ ! -e /data/system.notfirstrun ] ; then
|
||||
echo "do preinstall job"
|
||||
|
||||
/system/bin/sh /system/bin/pm preinstall /system/preinstall
|
||||
/system/bin/sh /system/bin/pm preinstall /sdcard/preinstall
|
||||
|
||||
$BUSYBOX touch /data/system.notfirstrun
|
||||
|
||||
echo "preinstall ok"
|
||||
else
|
||||
echo "do nothing"
|
||||
fi
|
||||
qw --daemon
|
||||
36
vendor/aw/homlet/binary/reset_configs_factory.sh
vendored
Executable file
36
vendor/aw/homlet/binary/reset_configs_factory.sh
vendored
Executable file
@ -0,0 +1,36 @@
|
||||
#!/sbin/busybox sh
|
||||
BUSYBOX="/sbin/busybox"
|
||||
|
||||
if [ ! -d "/data/system" ];then
|
||||
$BUSYBOX mkdir -p /data/system
|
||||
fi
|
||||
|
||||
$BUSYBOX chown 1000:1000 /data/system
|
||||
$BUSYBOX chmod 0755 /data/system
|
||||
|
||||
if [ -f "/cache/pap-secrets-eth0" ];then
|
||||
$BUSYBOX cp /cache/pap-secrets-eth0 /data/system/
|
||||
$BUSYBOX chown 1000:1000 /data/system/pap-secrets-eth0
|
||||
$BUSYBOX chmod 0600 /data/system/pap-secrets-eth0
|
||||
fi
|
||||
|
||||
if [ -f "/cache/pap-secrets-wlan0" ];then
|
||||
$BUSYBOX cp /cache/pap-secrets-wlan0 /data/system/
|
||||
$BUSYBOX chown 1000:1000 /data/system/pap-secrets-wlan0
|
||||
$BUSYBOX chmod 0600 /data/system/pap-secrets-wlan0
|
||||
fi
|
||||
|
||||
if [ -f "/cache/chap-secrets-eth0" ];then
|
||||
$BUSYBOX cp /cache/chap-secrets-eth0 /data/system/
|
||||
$BUSYBOX chown 1000:1000 /data/system/chap-secrets-eth0
|
||||
$BUSYBOX chmod 0600 /data/system/chap-secrets-eth0
|
||||
fi
|
||||
|
||||
if [ -f "/cache/chap-secrets-wlan0" ];then
|
||||
$BUSYBOX cp /cache/chap-secrets-wlan0 /data/system/
|
||||
$BUSYBOX chown 1000:1000 /data/system/chap-secrets-wlan0
|
||||
$BUSYBOX chmod 0600 /data/system/chap-secrets-wlan0
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
18
vendor/aw/homlet/binary/save_configs_factory.sh
vendored
Executable file
18
vendor/aw/homlet/binary/save_configs_factory.sh
vendored
Executable file
@ -0,0 +1,18 @@
|
||||
#!/sbin/busybox sh
|
||||
BUSYBOX="/sbin/busybox"
|
||||
if [ -f "/data/system/pap-secrets-eth0" ];then
|
||||
$BUSYBOX cp /data/system/pap-secrets-eth0 /cache/pap-secrets-eth0
|
||||
fi
|
||||
|
||||
if [ -f "/data/system/pap-secrets-wlan0" ];then
|
||||
$BUSYBOX cp /data/system/pap-secrets-wlan0 /cache/pap-secrets-wlan0
|
||||
fi
|
||||
|
||||
if [ -f "/data/system/chap-secrets-eth0" ];then
|
||||
$BUSYBOX cp /data/system/chap-secrets-eth0 /cache/chap-secrets-eth0
|
||||
fi
|
||||
|
||||
if [ -f "/data/system/chap-secrets-wlan0" ];then
|
||||
$BUSYBOX cp /data/system/chap-secrets-wlan0 /cache/chap-secrets-wlan0
|
||||
fi
|
||||
exit 0
|
||||
24
vendor/aw/homlet/binary/startsoftdetector.sh
vendored
Executable file
24
vendor/aw/homlet/binary/startsoftdetector.sh
vendored
Executable file
@ -0,0 +1,24 @@
|
||||
#!/system/bin/sh
|
||||
|
||||
echo "start softdetector probe service"
|
||||
|
||||
dataFile="/data/data/com.cmcc.mid.softdetector/lib/libpcapcmcc.so"
|
||||
systemFile="/system/bin/libpcapcmcc.so"
|
||||
|
||||
echo "while"
|
||||
|
||||
while [ ! -f $dataFile ]&&[ ! -f $systemFile ]
|
||||
do
|
||||
echo "in while"
|
||||
sleep 3
|
||||
done
|
||||
|
||||
echo "if"
|
||||
sleep 1
|
||||
if [ -f $dataFile ]; then
|
||||
echo "dataFile excute"
|
||||
/data/data/oom.cmcc.mid.softdetector/lib/libpcapcmcc.so
|
||||
else
|
||||
echo "systemFile excute"
|
||||
/system/bin/libpcapcmcc.so
|
||||
fi
|
||||
19
vendor/aw/homlet/binary/tools.mk
vendored
Executable file
19
vendor/aw/homlet/binary/tools.mk
vendored
Executable file
@ -0,0 +1,19 @@
|
||||
#PRODUCT_PACKAGES += \
|
||||
# busybox \
|
||||
# busybox-smp \
|
||||
# fsck.exfat \
|
||||
# mkfs.exfat \
|
||||
# mount.exfat \
|
||||
# memtester \
|
||||
# cpu_monitor \
|
||||
# mtops \
|
||||
# ntfs-3g \
|
||||
# ntfs-3g.probe \
|
||||
# precopy.sh \
|
||||
# preinstall.sh \
|
||||
# nfsprobe \
|
||||
# genusbid.sh \
|
||||
# log_bg.sh \
|
||||
# startsoftdetector.sh \
|
||||
# save_configs_factory.sh \
|
||||
# reset_configs_factory.sh
|
||||
18
vendor/aw/homlet/external/Android.mk
vendored
Normal file
18
vendor/aw/homlet/external/Android.mk
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2010 The Android Open Source Project
|
||||
#
|
||||
# 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.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
|
||||
10
vendor/aw/homlet/external/appsdisable/Android.mk
vendored
Normal file
10
vendor/aw/homlet/external/appsdisable/Android.mk
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright 2007 The Android Open Source Project
|
||||
#
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE := appsdisable
|
||||
LOCAL_MODULE_CLASS := EXECUTABLES
|
||||
LOCAL_SRC_FILES := appsdisable
|
||||
LOCAL_INIT_RC := appsdisable.rc
|
||||
include $(BUILD_PREBUILT)
|
||||
7
vendor/aw/homlet/external/appsdisable/appsdisable
vendored
Executable file
7
vendor/aw/homlet/external/appsdisable/appsdisable
vendored
Executable file
@ -0,0 +1,7 @@
|
||||
#!/system/bin/sh
|
||||
sleep 4
|
||||
provisioned=`settings get --user 0 global start_disable`
|
||||
if [ $provisioned -ne 1 ]; then
|
||||
pm query-receivers --components -a android.intent.action.BOOT_COMPLETED | grep com.google.android | busybox xargs -n 1 pm disable
|
||||
settings put --user 0 global start_disable 1
|
||||
fi
|
||||
9
vendor/aw/homlet/external/appsdisable/appsdisable.rc
vendored
Normal file
9
vendor/aw/homlet/external/appsdisable/appsdisable.rc
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
on property:sys.boot_completed=1
|
||||
start appsdisable
|
||||
|
||||
service appsdisable /system/bin/appsdisable
|
||||
disabled
|
||||
oneshot
|
||||
user root
|
||||
group shell
|
||||
seclabel u:r:shell:s0
|
||||
18
vendor/aw/homlet/external/pppoe/Android.mk
vendored
Normal file
18
vendor/aw/homlet/external/pppoe/Android.mk
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (C) 2010 The Android Open Source Project
|
||||
#
|
||||
# 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.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
||||
|
||||
49
vendor/aw/homlet/external/pppoe/CleanSpec.mk
vendored
Normal file
49
vendor/aw/homlet/external/pppoe/CleanSpec.mk
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
# Copyright (C) 2007 The Android Open Source Project
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
# If you don't need to do a full clean build but would like to touch
|
||||
# a file or delete some intermediate files, add a clean step to the end
|
||||
# of the list. These steps will only be run once, if they haven't been
|
||||
# run before.
|
||||
#
|
||||
# E.g.:
|
||||
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
|
||||
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
|
||||
#
|
||||
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
|
||||
# files that are missing or have been moved.
|
||||
#
|
||||
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
|
||||
# Use $(OUT_DIR) to refer to the "out" directory.
|
||||
#
|
||||
# If you need to re-do something that's already mentioned, just copy
|
||||
# the command and add it to the bottom of the list. E.g., if a change
|
||||
# that you made last week required touching a file and a change you
|
||||
# made today requires touching the same file, just copy the old
|
||||
# touch step and add it to the end of the list.
|
||||
#
|
||||
# ************************************************
|
||||
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
|
||||
# ************************************************
|
||||
|
||||
# For example:
|
||||
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
|
||||
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
|
||||
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
|
||||
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
|
||||
|
||||
# ************************************************
|
||||
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
|
||||
# ************************************************
|
||||
53
vendor/aw/homlet/external/pppoe/pppd/Android.mk
vendored
Normal file
53
vendor/aw/homlet/external/pppoe/pppd/Android.mk
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
main.c \
|
||||
magic.c \
|
||||
fsm.c \
|
||||
lcp.c \
|
||||
ipcp.c \
|
||||
upap.c \
|
||||
chap-new.c \
|
||||
ccp.c \
|
||||
ecp.c \
|
||||
auth.c \
|
||||
options.c \
|
||||
sys-linux.c \
|
||||
chap_ms.c \
|
||||
demand.c \
|
||||
utils.c \
|
||||
tty.c \
|
||||
eap.c \
|
||||
chap-md5.c \
|
||||
pppcrypt.c \
|
||||
openssl-hash.c \
|
||||
pppox.c \
|
||||
src/if.c \
|
||||
src/debug.c \
|
||||
src/common.c \
|
||||
src/ppp.c \
|
||||
src/discovery.c \
|
||||
src/plugin.c
|
||||
|
||||
# options.c:623:21: error: passing 'const char *' to parameter of type 'char *' discards qualifiers.
|
||||
# # [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
|
||||
LOCAL_CLANG_CFLAGS += -Wno-incompatible-pointer-types-discards-qualifiers
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := \
|
||||
libcutils liblog libcrypto libdl
|
||||
|
||||
LOCAL_C_INCLUDES := \
|
||||
$(LOCAL_PATH)/include
|
||||
|
||||
LOCAL_CFLAGS := -DANDROID_CHANGES -DCHAPMS=1 -DMPPE=1 -Iexternal/openssl/include -DPLUGIN=1 \
|
||||
-Wno-unused-parameter -Wno-empty-body -Wno-missing-field-initializers -Wno-attributes \
|
||||
-Wno-sign-compare -Wno-pointer-sign -Werror -Wno-format-security -Wno-macro-redefined \
|
||||
-Wno-implicit-function-declaration -Wno-implicit-int
|
||||
|
||||
# Turn off warnings for now until this is fixed upstream. b/18632512
|
||||
LOCAL_CFLAGS += -Wno-unused-variable
|
||||
|
||||
LOCAL_MODULE:= pppoe
|
||||
|
||||
include $(BUILD_EXECUTABLE)
|
||||
0
vendor/aw/homlet/external/pppoe/pppd/MODULE_LICENSE_BSD
vendored
Normal file
0
vendor/aw/homlet/external/pppoe/pppd/MODULE_LICENSE_BSD
vendored
Normal file
224
vendor/aw/homlet/external/pppoe/pppd/Makefile.linux
vendored
Normal file
224
vendor/aw/homlet/external/pppoe/pppd/Makefile.linux
vendored
Normal file
@ -0,0 +1,224 @@
|
||||
#
|
||||
# pppd makefile for Linux
|
||||
# $Id: Makefile.linux,v 1.66 2004/11/13 12:02:22 paulus Exp $
|
||||
#
|
||||
|
||||
# Default installation locations
|
||||
DESTDIR = @DESTDIR@
|
||||
BINDIR = $(DESTDIR)/sbin
|
||||
MANDIR = $(DESTDIR)/share/man/man8
|
||||
INCDIR = $(DESTDIR)/include
|
||||
|
||||
TARGETS = pppd
|
||||
|
||||
PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
|
||||
ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
|
||||
demand.c utils.c tty.c eap.c chap-md5.c
|
||||
|
||||
HEADERS = ccp.h chap-new.h ecp.h fsm.h ipcp.h \
|
||||
ipxcp.h lcp.h magic.h md5.h patchlevel.h pathnames.h pppd.h \
|
||||
upap.h eap.h
|
||||
|
||||
MANPAGES = pppd.8
|
||||
PPPDOBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o md5.o ccp.o \
|
||||
ecp.o auth.o options.o demand.o utils.o sys-linux.o ipxcp.o tty.o \
|
||||
eap.o chap-md5.o
|
||||
|
||||
#
|
||||
# include dependencies if present
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
endif
|
||||
|
||||
# CC = gcc
|
||||
#
|
||||
COPTS = -O2 -pipe -Wall -g
|
||||
LIBS =
|
||||
|
||||
# Uncomment the next 2 lines to include support for Microsoft's
|
||||
# MS-CHAP authentication protocol. Also, edit plugins/radius/Makefile.linux.
|
||||
CHAPMS=y
|
||||
USE_CRYPT=y
|
||||
# Don't use MSLANMAN unless you really know what you're doing.
|
||||
#MSLANMAN=y
|
||||
# Uncomment the next line to include support for MPPE. CHAPMS (above) must
|
||||
# also be enabled. Also, edit plugins/radius/Makefile.linux.
|
||||
MPPE=y
|
||||
|
||||
# Uncomment the next line to include support for PPP packet filtering.
|
||||
# This requires that the libpcap library and headers be installed
|
||||
# and that the kernel driver support PPP packet filtering.
|
||||
FILTER=y
|
||||
|
||||
# Uncomment the next line to enable multilink PPP (enabled by default)
|
||||
# Linux distributions: Please leave multilink ENABLED in your builds
|
||||
# of pppd!
|
||||
HAVE_MULTILINK=y
|
||||
|
||||
# Uncomment the next line to enable the TDB database (enabled by default.)
|
||||
# If you enable multilink, then TDB is automatically enabled also.
|
||||
# Linux distributions: Please leave TDB ENABLED in your builds.
|
||||
USE_TDB=y
|
||||
|
||||
HAS_SHADOW=y
|
||||
#USE_PAM=y
|
||||
#HAVE_INET6=y
|
||||
|
||||
# Enable plugins
|
||||
PLUGIN=y
|
||||
|
||||
# Enable Microsoft proprietary Callback Control Protocol
|
||||
#CBCP=y
|
||||
|
||||
# Enable EAP SRP-SHA1 authentication (requires libsrp)
|
||||
#USE_SRP=y
|
||||
|
||||
MAXOCTETS=y
|
||||
|
||||
INCLUDE_DIRS= -I../include
|
||||
|
||||
COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP
|
||||
|
||||
CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS)
|
||||
|
||||
ifdef CHAPMS
|
||||
CFLAGS += -DCHAPMS=1
|
||||
NEEDDES=y
|
||||
PPPDOBJS += md4.o chap_ms.o
|
||||
HEADERS += md4.h chap_ms.h
|
||||
ifdef MSLANMAN
|
||||
CFLAGS += -DMSLANMAN=1
|
||||
endif
|
||||
ifdef MPPE
|
||||
CFLAGS += -DMPPE=1
|
||||
endif
|
||||
endif
|
||||
|
||||
# EAP SRP-SHA1
|
||||
ifdef USE_SRP
|
||||
CFLAGS += -DUSE_SRP -DOPENSSL -I/usr/local/ssl/include
|
||||
LIBS += -lsrp -L/usr/local/ssl/lib -lcrypto
|
||||
TARGETS += srp-entry
|
||||
EXTRAINSTALL = $(INSTALL) -s -c -m 555 srp-entry $(BINDIR)/srp-entry
|
||||
MANPAGES += srp-entry.8
|
||||
EXTRACLEAN += srp-entry.o
|
||||
NEEDDES=y
|
||||
else
|
||||
# OpenSSL has an integrated version of SHA-1, and its implementation
|
||||
# is incompatible with this local SHA-1 implementation. We must use
|
||||
# one or the other, not both.
|
||||
PPPDSRCS += sha1.c
|
||||
HEADERS += sha1.h
|
||||
PPPDOBJS += sha1.o
|
||||
endif
|
||||
|
||||
ifdef HAS_SHADOW
|
||||
CFLAGS += -DHAS_SHADOW
|
||||
#LIBS += -lshadow $(LIBS)
|
||||
endif
|
||||
|
||||
ifneq ($(wildcard /usr/include/crypt.h),)
|
||||
CFLAGS += -DHAVE_CRYPT_H=1
|
||||
endif
|
||||
ifneq ($(wildcard /usr/lib/libcrypt.*),)
|
||||
LIBS += -lcrypt
|
||||
endif
|
||||
|
||||
ifdef NEEDDES
|
||||
ifndef USE_CRYPT
|
||||
LIBS += -ldes $(LIBS)
|
||||
else
|
||||
CFLAGS += -DUSE_CRYPT=1
|
||||
endif
|
||||
PPPDOBJS += pppcrypt.o
|
||||
HEADERS += pppcrypt.h
|
||||
endif
|
||||
|
||||
# For "Pluggable Authentication Modules", see ftp.redhat.com:/pub/pam/.
|
||||
ifdef USE_PAM
|
||||
CFLAGS += -DUSE_PAM
|
||||
LIBS += -lpam -ldl
|
||||
endif
|
||||
|
||||
# Multi-linnk
|
||||
ifdef HAVE_MULTILINK
|
||||
# Multilink implies the use of TDB
|
||||
USE_TDB=y
|
||||
|
||||
CFLAGS += -DHAVE_MULTILINK
|
||||
PPPDSRCS += multilink.c
|
||||
PPPDOBJS += multilink.o
|
||||
endif
|
||||
|
||||
# TDB
|
||||
ifdef USE_TDB
|
||||
CFLAGS += -DUSE_TDB=1
|
||||
PPPDSRCS += tdb.c spinlock.c
|
||||
PPPDOBJS += tdb.o spinlock.o
|
||||
HEADERS += tdb.h spinlock.h
|
||||
endif
|
||||
|
||||
# Lock library binary for Linux is included in 'linux' subdirectory.
|
||||
ifdef LOCKLIB
|
||||
LIBS += -llock
|
||||
CFLAGS += -DLOCKLIB=1
|
||||
endif
|
||||
|
||||
ifdef PLUGIN
|
||||
CFLAGS += -DPLUGIN
|
||||
LDFLAGS += -Wl,-E
|
||||
LIBS += -ldl
|
||||
endif
|
||||
|
||||
ifdef FILTER
|
||||
ifneq ($(wildcard /usr/include/pcap-bpf.h),)
|
||||
LIBS += -lpcap
|
||||
CFLAGS += -DPPP_FILTER
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef HAVE_INET6
|
||||
PPPDSRCS += ipv6cp.c eui64.c
|
||||
HEADERS += ipv6cp.h eui64.h
|
||||
PPPDOBJS += ipv6cp.o eui64.o
|
||||
CFLAGS += -DINET6=1
|
||||
endif
|
||||
|
||||
ifdef CBCP
|
||||
PPPDSRCS += cbcp.c
|
||||
PPPDOBJS += cbcp.o
|
||||
CFLAGS += -DCBCP_SUPPORT
|
||||
HEADERS += cbcp.h
|
||||
endif
|
||||
|
||||
ifdef MAXOCTETS
|
||||
CFLAGS += -DMAXOCTETS
|
||||
endif
|
||||
|
||||
INSTALL= install
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
install: pppd
|
||||
mkdir -p $(BINDIR) $(MANDIR)
|
||||
$(EXTRAINSTALL)
|
||||
$(INSTALL) -s -c -m 555 pppd $(BINDIR)/pppd
|
||||
if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
|
||||
chmod o-rx,u+s $(BINDIR)/pppd; fi
|
||||
$(INSTALL) -c -m 444 pppd.8 $(MANDIR)
|
||||
|
||||
pppd: $(PPPDOBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
|
||||
|
||||
srp-entry: srp-entry.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ srp-entry.c $(LIBS)
|
||||
|
||||
install-devel:
|
||||
mkdir -p $(INCDIR)/pppd
|
||||
$(INSTALL) -c -m 644 $(HEADERS) $(INCDIR)/pppd
|
||||
|
||||
clean:
|
||||
rm -f $(PPPDOBJS) $(EXTRACLEAN) $(TARGETS) *~ #* core
|
||||
|
||||
depend:
|
||||
$(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
|
||||
56
vendor/aw/homlet/external/pppoe/pppd/Makefile.sol2
vendored
Normal file
56
vendor/aw/homlet/external/pppoe/pppd/Makefile.sol2
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
#
|
||||
# Makefile for pppd under Solaris 2.
|
||||
# $Id: Makefile.sol2,v 1.26 2004/04/14 02:39:39 carlsonj Exp $
|
||||
#
|
||||
|
||||
include ../Makedefs.com
|
||||
|
||||
CFLAGS = -I../include -DSVR4 -DSOL2 $(COPTS)
|
||||
LIBS = -lsocket -lnsl
|
||||
|
||||
OBJS = main.o magic.o fsm.o lcp.o ipcp.o upap.o chap-new.o eap.o md5.o \
|
||||
tty.o ccp.o ecp.o auth.o options.o demand.o utils.o sys-solaris.o \
|
||||
chap-md5.o
|
||||
|
||||
#
|
||||
# uncomment the following to enable plugins
|
||||
#
|
||||
CFLAGS += -DPLUGIN
|
||||
LIBS += -ldl
|
||||
|
||||
#
|
||||
# Solaris 8 and above accomodates /var/run, so uncomment the
|
||||
# following to place pppd process IDs on that location
|
||||
#
|
||||
#CFLAGS += -D_PATH_VARRUN='"/var/run/"'
|
||||
|
||||
#
|
||||
# uncomment the following to enable IPv6
|
||||
#
|
||||
# Solaris 8 and on includes support for IPv6
|
||||
#
|
||||
#CFLAGS += -DINET6
|
||||
#OBJS += ipv6cp.o eui64.o
|
||||
|
||||
# Uncomment to enable MS-CHAP
|
||||
#CFLAGS += -DUSE_CRYPT -DCHAPMS -DHAVE_CRYPT_H
|
||||
#OBJS += chap_ms.o pppcrypt.o md4.o sha1.o
|
||||
|
||||
# Uncomment for CBCP
|
||||
#CFLAGS += -DCBCP_SUPPORT
|
||||
#OBJS += cbcp.o
|
||||
|
||||
#
|
||||
# Make targets
|
||||
#
|
||||
all: pppd
|
||||
|
||||
pppd: $(OBJS)
|
||||
$(CC) -o pppd $(OBJS) $(LIBS)
|
||||
|
||||
install:
|
||||
$(INSTALL) -f $(BINDIR) -m 4755 -u root pppd
|
||||
$(INSTALL) -f $(MANDIR)/man8 -m 444 pppd.8
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS) pppd *~ core y.tab.c y.tab.h
|
||||
252
vendor/aw/homlet/external/pppoe/pppd/NOTICE
vendored
Normal file
252
vendor/aw/homlet/external/pppoe/pppd/NOTICE
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
This product includes software developed by Paul Mackerras <paulus@samba.org>
|
||||
This product includes software developed by Computing Services at Carnegie Mellon University (http://www.cmu.edu/computing/).
|
||||
This product includes software developed by Pedro Roque Marques <pedro_m@yahoo.com>
|
||||
This product includes software developed by Tommi Komulainen <Tommi.Komulainen@iki.fi>
|
||||
|
||||
Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission. For permission or any legal
|
||||
details, please contact
|
||||
Office of Technology Transfer
|
||||
Carnegie Mellon University
|
||||
5000 Forbes Avenue
|
||||
Pittsburgh, PA 15213-3890
|
||||
(412) 268-4387, fax: (412) 268-7395
|
||||
tech-transfer@andrew.cmu.edu
|
||||
|
||||
4. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by Computing Services
|
||||
at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
|
||||
CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Copyright (c) 1995 Pedro Roque Marques. 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. The names of the authors of this software must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission.
|
||||
|
||||
4. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by Pedro Roque Marques
|
||||
<pedro_m@yahoo.com>"
|
||||
|
||||
THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Copyright (C) 2000-2004 Paul Mackerras. All rights reserved.
|
||||
Copyright (c) 1994-2002 Paul Mackerras. All rights reserved.
|
||||
Copyright (c) 2003 Paul Mackerras. All rights reserved.
|
||||
Copyright (c) 1996-2002 Paul Mackerras. All rights reserved.
|
||||
Copyright (c) 1999-2004 Paul Mackerras. All rights reserved.
|
||||
Copyright (c) 2000-2002 Paul Mackerras. All rights reserved.
|
||||
Copyright (c) 1999-2002 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission.
|
||||
|
||||
3. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by Paul Mackerras
|
||||
<paulus@samba.org>".
|
||||
|
||||
THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Copyright (c) 1995 Eric Rosenquist. All rights reserved.
|
||||
Copyright (c) 2002 The Android Open Source Project
|
||||
|
||||
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. The name(s) of the authors of this software must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission.
|
||||
|
||||
THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Copyright (c) 2001 by Sun Microsystems, Inc.
|
||||
All rights reserved.
|
||||
|
||||
Non-exclusive rights to redistribute, modify, translate, and use
|
||||
this software in source and binary forms, in whole or in part, is
|
||||
hereby granted, provided that the above copyright notice is
|
||||
duplicated in any source form, and that neither the name of the
|
||||
copyright holder nor the author is used to endorse or promote
|
||||
products derived from this software.
|
||||
|
||||
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.
|
||||
|
||||
Copyright (c) 1999 Tommi Komulainen. 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. The name(s) of the authors of this software must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission.
|
||||
|
||||
4. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by Tommi Komulainen
|
||||
<Tommi.Komulainen@iki.fi>".
|
||||
|
||||
THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Copyright (c) 1998, 1999 Francis.Dupont@inria.fr, GIE DYADE,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Ce travail a été fait au sein du GIE DYADE (Groupement d'Intérêt
|
||||
Économique ayant pour membres BULL S.A. et l'INRIA).
|
||||
|
||||
Ce logiciel informatique est disponible aux conditions
|
||||
usuelles dans la recherche, c'est-à-dire qu'il peut
|
||||
être utilisé, copié, modifié, distribué à l'unique
|
||||
condition que ce texte soit conservé afin que
|
||||
l'origine de ce logiciel soit reconnue.
|
||||
|
||||
Le nom de l'Institut National de Recherche en Informatique
|
||||
et en Automatique (INRIA), de l'IMAG, ou d'une personne morale
|
||||
ou physique ayant participé à l'élaboration de ce logiciel ne peut
|
||||
être utilisé sans son accord préalable explicite.
|
||||
|
||||
Ce logiciel est fourni tel quel sans aucune garantie,
|
||||
support ou responsabilité d'aucune sorte.
|
||||
Ce logiciel est dérivé de sources d'origine
|
||||
"University of California at Berkeley" et
|
||||
"Digital Equipment Corporation" couvertes par des copyrights.
|
||||
|
||||
L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG)
|
||||
est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National
|
||||
Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant
|
||||
sept laboratoires dont le laboratoire Logiciels, Systèmes, Réseaux (LSR).
|
||||
|
||||
This work has been done in the context of GIE DYADE (joint R & D venture
|
||||
between BULL S.A. and INRIA).
|
||||
|
||||
This software is available with usual "research" terms
|
||||
with the aim of retain credits of the software.
|
||||
Permission to use, copy, modify and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies,
|
||||
and the name of INRIA, IMAG, or any contributor not be used in advertising
|
||||
or publicity pertaining to this material without the prior explicit
|
||||
permission. The software is provided "as is" without any
|
||||
warranties, support or liabilities of any kind.
|
||||
This software is derived from source code from
|
||||
"University of California at Berkeley" and
|
||||
"Digital Equipment Corporation" protected by copyrights.
|
||||
|
||||
Grenoble's Institute of Computer Science and Applied Mathematics (IMAG)
|
||||
is a federation of seven research units funded by the CNRS, National
|
||||
Polytechnic Institute of Grenoble and University Joseph Fourier.
|
||||
The research unit in Software, Systems, Networks (LSR) is member of IMAG.
|
||||
2
vendor/aw/homlet/external/pppoe/pppd/README.google
vendored
Normal file
2
vendor/aw/homlet/external/pppoe/pppd/README.google
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
Notes:
|
||||
Removed multilink.c, spinlock.[ch], tdb.[ch] as they are unused.
|
||||
9
vendor/aw/homlet/external/pppoe/pppd/ThirdPartyProject.prop
vendored
Normal file
9
vendor/aw/homlet/external/pppoe/pppd/ThirdPartyProject.prop
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright 2010 Google Inc. All Rights Reserved.
|
||||
#Fri Jul 16 10:03:09 PDT 2010
|
||||
currentVersion=2.4.5
|
||||
version=2.4.3
|
||||
isNative=true
|
||||
name=pppd
|
||||
keywords=pppd
|
||||
onDevice=true
|
||||
homepage=http\://ppp.samba.org/
|
||||
2596
vendor/aw/homlet/external/pppoe/pppd/auth.c
vendored
Normal file
2596
vendor/aw/homlet/external/pppoe/pppd/auth.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
488
vendor/aw/homlet/external/pppoe/pppd/cbcp.c
vendored
Normal file
488
vendor/aw/homlet/external/pppoe/pppd/cbcp.c
vendored
Normal file
@ -0,0 +1,488 @@
|
||||
/*
|
||||
* cbcp - Call Back Configuration Protocol.
|
||||
*
|
||||
* Copyright (c) 1995 Pedro Roque Marques. 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. The names of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Pedro Roque Marques
|
||||
* <pedro_m@yahoo.com>"
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: cbcp.c,v 1.16 2004/10/28 00:15:36 paulus Exp $"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "pppd.h"
|
||||
#include "cbcp.h"
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
static int setcbcp __P((char **));
|
||||
|
||||
static option_t cbcp_option_list[] = {
|
||||
{ "callback", o_special, (void *)setcbcp,
|
||||
"Ask for callback", OPT_PRIO | OPT_A2STRVAL, &cbcp[0].us_number },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* Protocol entry points.
|
||||
*/
|
||||
static void cbcp_init __P((int unit));
|
||||
static void cbcp_open __P((int unit));
|
||||
static void cbcp_lowerup __P((int unit));
|
||||
static void cbcp_input __P((int unit, u_char *pkt, int len));
|
||||
static void cbcp_protrej __P((int unit));
|
||||
static int cbcp_printpkt __P((u_char *pkt, int len,
|
||||
void (*printer) __P((void *, char *, ...)),
|
||||
void *arg));
|
||||
|
||||
struct protent cbcp_protent = {
|
||||
PPP_CBCP,
|
||||
cbcp_init,
|
||||
cbcp_input,
|
||||
cbcp_protrej,
|
||||
cbcp_lowerup,
|
||||
NULL,
|
||||
cbcp_open,
|
||||
NULL,
|
||||
cbcp_printpkt,
|
||||
NULL,
|
||||
0,
|
||||
"CBCP",
|
||||
NULL,
|
||||
cbcp_option_list,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
cbcp_state cbcp[NUM_PPP];
|
||||
|
||||
/* internal prototypes */
|
||||
|
||||
static void cbcp_recvreq __P((cbcp_state *us, u_char *pckt, int len));
|
||||
static void cbcp_resp __P((cbcp_state *us));
|
||||
static void cbcp_up __P((cbcp_state *us));
|
||||
static void cbcp_recvack __P((cbcp_state *us, u_char *pckt, int len));
|
||||
static void cbcp_send __P((cbcp_state *us, int code, u_char *buf, int len));
|
||||
|
||||
/* option processing */
|
||||
static int
|
||||
setcbcp(argv)
|
||||
char **argv;
|
||||
{
|
||||
lcp_wantoptions[0].neg_cbcp = 1;
|
||||
cbcp_protent.enabled_flag = 1;
|
||||
cbcp[0].us_number = strdup(*argv);
|
||||
if (cbcp[0].us_number == 0)
|
||||
novm("callback number");
|
||||
cbcp[0].us_type |= (1 << CB_CONF_USER);
|
||||
cbcp[0].us_type |= (1 << CB_CONF_ADMIN);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* init state */
|
||||
static void
|
||||
cbcp_init(iface)
|
||||
int iface;
|
||||
{
|
||||
cbcp_state *us;
|
||||
|
||||
us = &cbcp[iface];
|
||||
memset(us, 0, sizeof(cbcp_state));
|
||||
us->us_unit = iface;
|
||||
us->us_type |= (1 << CB_CONF_NO);
|
||||
}
|
||||
|
||||
/* lower layer is up */
|
||||
static void
|
||||
cbcp_lowerup(iface)
|
||||
int iface;
|
||||
{
|
||||
cbcp_state *us = &cbcp[iface];
|
||||
|
||||
dbglog("cbcp_lowerup");
|
||||
dbglog("want: %d", us->us_type);
|
||||
|
||||
if (us->us_type == CB_CONF_USER)
|
||||
dbglog("phone no: %s", us->us_number);
|
||||
}
|
||||
|
||||
static void
|
||||
cbcp_open(unit)
|
||||
int unit;
|
||||
{
|
||||
dbglog("cbcp_open");
|
||||
}
|
||||
|
||||
/* process an incomming packet */
|
||||
static void
|
||||
cbcp_input(unit, inpacket, pktlen)
|
||||
int unit;
|
||||
u_char *inpacket;
|
||||
int pktlen;
|
||||
{
|
||||
u_char *inp;
|
||||
u_char code, id;
|
||||
u_short len;
|
||||
|
||||
cbcp_state *us = &cbcp[unit];
|
||||
|
||||
inp = inpacket;
|
||||
|
||||
if (pktlen < CBCP_MINLEN) {
|
||||
if (debug)
|
||||
dbglog("CBCP packet is too small");
|
||||
return;
|
||||
}
|
||||
|
||||
GETCHAR(code, inp);
|
||||
GETCHAR(id, inp);
|
||||
GETSHORT(len, inp);
|
||||
|
||||
if (len > pktlen || len < CBCP_MINLEN) {
|
||||
if (debug)
|
||||
dbglog("CBCP packet: invalid length %d", len);
|
||||
return;
|
||||
}
|
||||
|
||||
len -= CBCP_MINLEN;
|
||||
|
||||
switch(code) {
|
||||
case CBCP_REQ:
|
||||
us->us_id = id;
|
||||
cbcp_recvreq(us, inp, len);
|
||||
break;
|
||||
|
||||
case CBCP_RESP:
|
||||
if (debug)
|
||||
dbglog("CBCP_RESP received");
|
||||
break;
|
||||
|
||||
case CBCP_ACK:
|
||||
if (debug && id != us->us_id)
|
||||
dbglog("id doesn't match: expected %d recv %d",
|
||||
us->us_id, id);
|
||||
|
||||
cbcp_recvack(us, inp, len);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* protocol was rejected by foe */
|
||||
void cbcp_protrej(int iface)
|
||||
{
|
||||
}
|
||||
|
||||
char *cbcp_codenames[] = {
|
||||
"Request", "Response", "Ack"
|
||||
};
|
||||
|
||||
char *cbcp_optionnames[] = {
|
||||
"NoCallback",
|
||||
"UserDefined",
|
||||
"AdminDefined",
|
||||
"List"
|
||||
};
|
||||
|
||||
/* pretty print a packet */
|
||||
static int
|
||||
cbcp_printpkt(p, plen, printer, arg)
|
||||
u_char *p;
|
||||
int plen;
|
||||
void (*printer) __P((void *, char *, ...));
|
||||
void *arg;
|
||||
{
|
||||
int code, opt, id, len, olen, delay;
|
||||
u_char *pstart;
|
||||
|
||||
if (plen < HEADERLEN)
|
||||
return 0;
|
||||
pstart = p;
|
||||
GETCHAR(code, p);
|
||||
GETCHAR(id, p);
|
||||
GETSHORT(len, p);
|
||||
if (len < HEADERLEN || len > plen)
|
||||
return 0;
|
||||
|
||||
if (code >= 1 && code <= sizeof(cbcp_codenames) / sizeof(char *))
|
||||
printer(arg, " %s", cbcp_codenames[code-1]);
|
||||
else
|
||||
printer(arg, " code=0x%x", code);
|
||||
|
||||
printer(arg, " id=0x%x", id);
|
||||
len -= HEADERLEN;
|
||||
|
||||
switch (code) {
|
||||
case CBCP_REQ:
|
||||
case CBCP_RESP:
|
||||
case CBCP_ACK:
|
||||
while(len >= 2) {
|
||||
GETCHAR(opt, p);
|
||||
GETCHAR(olen, p);
|
||||
|
||||
if (olen < 2 || olen > len) {
|
||||
break;
|
||||
}
|
||||
|
||||
printer(arg, " <");
|
||||
len -= olen;
|
||||
|
||||
if (opt >= 1 && opt <= sizeof(cbcp_optionnames) / sizeof(char *))
|
||||
printer(arg, " %s", cbcp_optionnames[opt-1]);
|
||||
else
|
||||
printer(arg, " option=0x%x", opt);
|
||||
|
||||
if (olen > 2) {
|
||||
GETCHAR(delay, p);
|
||||
printer(arg, " delay = %d", delay);
|
||||
}
|
||||
|
||||
if (olen > 3) {
|
||||
int addrt;
|
||||
char str[256];
|
||||
|
||||
GETCHAR(addrt, p);
|
||||
memcpy(str, p, olen - 4);
|
||||
str[olen - 4] = 0;
|
||||
printer(arg, " number = %s", str);
|
||||
}
|
||||
printer(arg, ">");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (; len > 0; --len) {
|
||||
GETCHAR(code, p);
|
||||
printer(arg, " %.2x", code);
|
||||
}
|
||||
|
||||
return p - pstart;
|
||||
}
|
||||
|
||||
/* received CBCP request */
|
||||
static void
|
||||
cbcp_recvreq(us, pckt, pcktlen)
|
||||
cbcp_state *us;
|
||||
u_char *pckt;
|
||||
int pcktlen;
|
||||
{
|
||||
u_char type, opt_len, delay, addr_type;
|
||||
char address[256];
|
||||
int len = pcktlen;
|
||||
|
||||
address[0] = 0;
|
||||
|
||||
while (len >= 2) {
|
||||
dbglog("length: %d", len);
|
||||
|
||||
GETCHAR(type, pckt);
|
||||
GETCHAR(opt_len, pckt);
|
||||
if (opt_len < 2 || opt_len > len)
|
||||
break;
|
||||
|
||||
if (opt_len > 2)
|
||||
GETCHAR(delay, pckt);
|
||||
|
||||
us->us_allowed |= (1 << type);
|
||||
|
||||
switch(type) {
|
||||
case CB_CONF_NO:
|
||||
dbglog("no callback allowed");
|
||||
break;
|
||||
|
||||
case CB_CONF_USER:
|
||||
dbglog("user callback allowed");
|
||||
if (opt_len > 4) {
|
||||
GETCHAR(addr_type, pckt);
|
||||
memcpy(address, pckt, opt_len - 4);
|
||||
address[opt_len - 4] = 0;
|
||||
if (address[0])
|
||||
dbglog("address: %s", address);
|
||||
}
|
||||
break;
|
||||
|
||||
case CB_CONF_ADMIN:
|
||||
dbglog("user admin defined allowed");
|
||||
break;
|
||||
|
||||
case CB_CONF_LIST:
|
||||
break;
|
||||
}
|
||||
len -= opt_len;
|
||||
}
|
||||
if (len != 0) {
|
||||
if (debug)
|
||||
dbglog("cbcp_recvreq: malformed packet (%d bytes left)", len);
|
||||
return;
|
||||
}
|
||||
|
||||
cbcp_resp(us);
|
||||
}
|
||||
|
||||
static void
|
||||
cbcp_resp(us)
|
||||
cbcp_state *us;
|
||||
{
|
||||
u_char cb_type;
|
||||
u_char buf[256];
|
||||
u_char *bufp = buf;
|
||||
int len = 0;
|
||||
int slen;
|
||||
|
||||
cb_type = us->us_allowed & us->us_type;
|
||||
dbglog("cbcp_resp cb_type=%d", cb_type);
|
||||
|
||||
#if 0
|
||||
if (!cb_type)
|
||||
lcp_down(us->us_unit);
|
||||
#endif
|
||||
|
||||
if (cb_type & ( 1 << CB_CONF_USER ) ) {
|
||||
dbglog("cbcp_resp CONF_USER");
|
||||
slen = strlen(us->us_number);
|
||||
if (slen > 250) {
|
||||
warn("callback number truncated to 250 characters");
|
||||
slen = 250;
|
||||
}
|
||||
PUTCHAR(CB_CONF_USER, bufp);
|
||||
len = 3 + 1 + slen + 1;
|
||||
PUTCHAR(len , bufp);
|
||||
PUTCHAR(5, bufp); /* delay */
|
||||
PUTCHAR(1, bufp);
|
||||
BCOPY(us->us_number, bufp, slen + 1);
|
||||
cbcp_send(us, CBCP_RESP, buf, len);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb_type & ( 1 << CB_CONF_ADMIN ) ) {
|
||||
dbglog("cbcp_resp CONF_ADMIN");
|
||||
PUTCHAR(CB_CONF_ADMIN, bufp);
|
||||
len = 3;
|
||||
PUTCHAR(len, bufp);
|
||||
PUTCHAR(5, bufp); /* delay */
|
||||
cbcp_send(us, CBCP_RESP, buf, len);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cb_type & ( 1 << CB_CONF_NO ) ) {
|
||||
dbglog("cbcp_resp CONF_NO");
|
||||
PUTCHAR(CB_CONF_NO, bufp);
|
||||
len = 2;
|
||||
PUTCHAR(len , bufp);
|
||||
cbcp_send(us, CBCP_RESP, buf, len);
|
||||
start_networks(us->us_unit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cbcp_send(us, code, buf, len)
|
||||
cbcp_state *us;
|
||||
int code;
|
||||
u_char *buf;
|
||||
int len;
|
||||
{
|
||||
u_char *outp;
|
||||
int outlen;
|
||||
|
||||
outp = outpacket_buf;
|
||||
|
||||
outlen = 4 + len;
|
||||
|
||||
MAKEHEADER(outp, PPP_CBCP);
|
||||
|
||||
PUTCHAR(code, outp);
|
||||
PUTCHAR(us->us_id, outp);
|
||||
PUTSHORT(outlen, outp);
|
||||
|
||||
if (len)
|
||||
BCOPY(buf, outp, len);
|
||||
|
||||
output(us->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
|
||||
}
|
||||
|
||||
static void
|
||||
cbcp_recvack(us, pckt, len)
|
||||
cbcp_state *us;
|
||||
u_char *pckt;
|
||||
int len;
|
||||
{
|
||||
u_char type, delay, addr_type;
|
||||
int opt_len;
|
||||
char address[256];
|
||||
|
||||
if (len >= 2) {
|
||||
GETCHAR(type, pckt);
|
||||
GETCHAR(opt_len, pckt);
|
||||
if (opt_len >= 2 && opt_len <= len) {
|
||||
|
||||
if (opt_len > 2)
|
||||
GETCHAR(delay, pckt);
|
||||
|
||||
if (opt_len > 4) {
|
||||
GETCHAR(addr_type, pckt);
|
||||
memcpy(address, pckt, opt_len - 4);
|
||||
address[opt_len - 4] = 0;
|
||||
if (address[0])
|
||||
dbglog("peer will call: %s", address);
|
||||
}
|
||||
if (type == CB_CONF_NO)
|
||||
return;
|
||||
|
||||
cbcp_up(us);
|
||||
|
||||
} else if (debug)
|
||||
dbglog("cbcp_recvack: malformed packet");
|
||||
}
|
||||
}
|
||||
|
||||
/* ok peer will do callback */
|
||||
static void
|
||||
cbcp_up(us)
|
||||
cbcp_state *us;
|
||||
{
|
||||
persist = 0;
|
||||
lcp_close(0, "Call me back, please");
|
||||
status = EXIT_CALLBACK;
|
||||
}
|
||||
26
vendor/aw/homlet/external/pppoe/pppd/cbcp.h
vendored
Normal file
26
vendor/aw/homlet/external/pppoe/pppd/cbcp.h
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef CBCP_H
|
||||
#define CBCP_H
|
||||
|
||||
typedef struct cbcp_state {
|
||||
int us_unit; /* Interface unit number */
|
||||
u_char us_id; /* Current id */
|
||||
u_char us_allowed;
|
||||
int us_type;
|
||||
char *us_number; /* Telefone Number */
|
||||
} cbcp_state;
|
||||
|
||||
extern cbcp_state cbcp[];
|
||||
|
||||
extern struct protent cbcp_protent;
|
||||
|
||||
#define CBCP_MINLEN 4
|
||||
|
||||
#define CBCP_REQ 1
|
||||
#define CBCP_RESP 2
|
||||
#define CBCP_ACK 3
|
||||
|
||||
#define CB_CONF_NO 1
|
||||
#define CB_CONF_USER 2
|
||||
#define CB_CONF_ADMIN 3
|
||||
#define CB_CONF_LIST 4
|
||||
#endif
|
||||
1674
vendor/aw/homlet/external/pppoe/pppd/ccp.c
vendored
Normal file
1674
vendor/aw/homlet/external/pppoe/pppd/ccp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
52
vendor/aw/homlet/external/pppoe/pppd/ccp.h
vendored
Normal file
52
vendor/aw/homlet/external/pppoe/pppd/ccp.h
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* ccp.h - Definitions for PPP Compression Control Protocol.
|
||||
*
|
||||
* Copyright (c) 1994-2002 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ccp.h,v 1.12 2004/11/04 10:02:26 paulus Exp $
|
||||
*/
|
||||
|
||||
typedef struct ccp_options {
|
||||
bool bsd_compress; /* do BSD Compress? */
|
||||
bool deflate; /* do Deflate? */
|
||||
bool predictor_1; /* do Predictor-1? */
|
||||
bool predictor_2; /* do Predictor-2? */
|
||||
bool deflate_correct; /* use correct code for deflate? */
|
||||
bool deflate_draft; /* use draft RFC code for deflate? */
|
||||
bool mppe; /* do MPPE? */
|
||||
u_short bsd_bits; /* # bits/code for BSD Compress */
|
||||
u_short deflate_size; /* lg(window size) for Deflate */
|
||||
short method; /* code for chosen compression method */
|
||||
} ccp_options;
|
||||
|
||||
extern fsm ccp_fsm[];
|
||||
extern ccp_options ccp_wantoptions[];
|
||||
extern ccp_options ccp_gotoptions[];
|
||||
extern ccp_options ccp_allowoptions[];
|
||||
extern ccp_options ccp_hisoptions[];
|
||||
|
||||
extern struct protent ccp_protent;
|
||||
117
vendor/aw/homlet/external/pppoe/pppd/chap-md5.c
vendored
Normal file
117
vendor/aw/homlet/external/pppoe/pppd/chap-md5.c
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* chap-md5.c - New CHAP/MD5 implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: chap-md5.c,v 1.4 2004/11/09 22:39:25 paulus Exp $"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pppd.h"
|
||||
#include "chap-new.h"
|
||||
#include "chap-md5.h"
|
||||
#include "magic.h"
|
||||
#include "md5.h"
|
||||
|
||||
#define MD5_HASH_SIZE 16
|
||||
#define MD5_MIN_CHALLENGE 16
|
||||
#define MD5_MAX_CHALLENGE 24
|
||||
|
||||
static void
|
||||
chap_md5_generate_challenge(unsigned char *cp)
|
||||
{
|
||||
int clen;
|
||||
|
||||
clen = (int)(drand48() * (MD5_MAX_CHALLENGE - MD5_MIN_CHALLENGE))
|
||||
+ MD5_MIN_CHALLENGE;
|
||||
*cp++ = clen;
|
||||
random_bytes(cp, clen);
|
||||
}
|
||||
|
||||
static int
|
||||
chap_md5_verify_response(int id, char *name,
|
||||
unsigned char *secret, int secret_len,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
unsigned char idbyte = id;
|
||||
unsigned char hash[MD5_HASH_SIZE];
|
||||
int challenge_len, response_len;
|
||||
|
||||
challenge_len = *challenge++;
|
||||
response_len = *response++;
|
||||
if (response_len == MD5_HASH_SIZE) {
|
||||
/* Generate hash of ID, secret, challenge */
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, &idbyte, 1);
|
||||
MD5_Update(&ctx, secret, secret_len);
|
||||
MD5_Update(&ctx, challenge, challenge_len);
|
||||
MD5_Final(hash, &ctx);
|
||||
|
||||
/* Test if our hash matches the peer's response */
|
||||
if (memcmp(hash, response, MD5_HASH_SIZE) == 0) {
|
||||
slprintf(message, message_space, "Access granted");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
slprintf(message, message_space, "Access denied");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
chap_md5_make_response(unsigned char *response, int id, char *our_name,
|
||||
unsigned char *challenge, char *secret, int secret_len,
|
||||
unsigned char *private)
|
||||
{
|
||||
MD5_CTX ctx;
|
||||
unsigned char idbyte = id;
|
||||
int challenge_len = *challenge++;
|
||||
|
||||
MD5_Init(&ctx);
|
||||
MD5_Update(&ctx, &idbyte, 1);
|
||||
MD5_Update(&ctx, secret, secret_len);
|
||||
MD5_Update(&ctx, challenge, challenge_len);
|
||||
MD5_Final(&response[1], &ctx);
|
||||
response[0] = MD5_HASH_SIZE;
|
||||
}
|
||||
|
||||
static struct chap_digest_type md5_digest = {
|
||||
CHAP_MD5, /* code */
|
||||
chap_md5_generate_challenge,
|
||||
chap_md5_verify_response,
|
||||
chap_md5_make_response,
|
||||
NULL, /* check_success */
|
||||
NULL, /* handle_failure */
|
||||
};
|
||||
|
||||
void
|
||||
chap_md5_init(void)
|
||||
{
|
||||
chap_register_digest(&md5_digest);
|
||||
}
|
||||
31
vendor/aw/homlet/external/pppoe/pppd/chap-md5.h
vendored
Normal file
31
vendor/aw/homlet/external/pppoe/pppd/chap-md5.h
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* chap-md5.h - New CHAP/MD5 implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
extern void chap_md5_init(void);
|
||||
642
vendor/aw/homlet/external/pppoe/pppd/chap-new.c
vendored
Normal file
642
vendor/aw/homlet/external/pppoe/pppd/chap-new.c
vendored
Normal file
@ -0,0 +1,642 @@
|
||||
/*
|
||||
* chap-new.c - New CHAP implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: chap-new.c,v 1.6 2004/11/04 10:02:26 paulus Exp $"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "pppd.h"
|
||||
#include "chap-new.h"
|
||||
#include "chap-md5.h"
|
||||
#ifdef ANDROID_CHANGES
|
||||
#include "openssl-hash.h"
|
||||
#endif
|
||||
|
||||
#ifdef CHAPMS
|
||||
#include "chap_ms.h"
|
||||
#define MDTYPE_ALL (MDTYPE_MICROSOFT_V2 | MDTYPE_MICROSOFT | MDTYPE_MD5)
|
||||
#else
|
||||
#define MDTYPE_ALL (MDTYPE_MD5)
|
||||
#endif
|
||||
|
||||
int chap_mdtype_all = MDTYPE_ALL;
|
||||
|
||||
/* Hook for a plugin to validate CHAP challenge */
|
||||
int (*chap_verify_hook)(char *name, char *ourname, int id,
|
||||
struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space) = NULL;
|
||||
|
||||
/*
|
||||
* Option variables.
|
||||
*/
|
||||
int chap_timeout_time = 3;
|
||||
int chap_max_transmits = 10;
|
||||
int chap_rechallenge_time = 0;
|
||||
|
||||
/*
|
||||
* Command-line options.
|
||||
*/
|
||||
static option_t chap_option_list[] = {
|
||||
{ "chap-restart", o_int, &chap_timeout_time,
|
||||
"Set timeout for CHAP", OPT_PRIO },
|
||||
{ "chap-max-challenge", o_int, &chap_max_transmits,
|
||||
"Set max #xmits for challenge", OPT_PRIO },
|
||||
{ "chap-interval", o_int, &chap_rechallenge_time,
|
||||
"Set interval for rechallenge", OPT_PRIO },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* Internal state.
|
||||
*/
|
||||
static struct chap_client_state {
|
||||
int flags;
|
||||
char *name;
|
||||
struct chap_digest_type *digest;
|
||||
unsigned char priv[64]; /* private area for digest's use */
|
||||
} client;
|
||||
|
||||
/*
|
||||
* These limits apply to challenge and response packets we send.
|
||||
* The +4 is the +1 that we actually need rounded up.
|
||||
*/
|
||||
#define CHAL_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_CHALLENGE_LEN + MAXNAMELEN)
|
||||
#define RESP_MAX_PKTLEN (PPP_HDRLEN + CHAP_HDRLEN + 4 + MAX_RESPONSE_LEN + MAXNAMELEN)
|
||||
|
||||
static struct chap_server_state {
|
||||
int flags;
|
||||
int id;
|
||||
char *name;
|
||||
struct chap_digest_type *digest;
|
||||
int challenge_xmits;
|
||||
int challenge_pktlen;
|
||||
unsigned char challenge[CHAL_MAX_PKTLEN];
|
||||
} server;
|
||||
|
||||
/* Values for flags in chap_client_state and chap_server_state */
|
||||
#define LOWERUP 1
|
||||
#define AUTH_STARTED 2
|
||||
#define AUTH_DONE 4
|
||||
#define AUTH_FAILED 8
|
||||
#define TIMEOUT_PENDING 0x10
|
||||
#define CHALLENGE_VALID 0x20
|
||||
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
static void chap_init(int unit);
|
||||
static void chap_lowerup(int unit);
|
||||
static void chap_lowerdown(int unit);
|
||||
static void chap_timeout(void *arg);
|
||||
static void chap_generate_challenge(struct chap_server_state *ss);
|
||||
static void chap_handle_response(struct chap_server_state *ss, int code,
|
||||
unsigned char *pkt, int len);
|
||||
static int chap_verify_response(char *name, char *ourname, int id,
|
||||
struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space);
|
||||
static void chap_respond(struct chap_client_state *cs, int id,
|
||||
unsigned char *pkt, int len);
|
||||
static void chap_handle_status(struct chap_client_state *cs, int code, int id,
|
||||
unsigned char *pkt, int len);
|
||||
static void chap_protrej(int unit);
|
||||
static void chap_input(int unit, unsigned char *pkt, int pktlen);
|
||||
static int chap_print_pkt(unsigned char *p, int plen,
|
||||
void (*printer) __P((void *, char *, ...)), void *arg);
|
||||
|
||||
/* List of digest types that we know about */
|
||||
static struct chap_digest_type *chap_digests;
|
||||
|
||||
/*
|
||||
* chap_init - reset to initial state.
|
||||
*/
|
||||
static void
|
||||
chap_init(int unit)
|
||||
{
|
||||
memset(&client, 0, sizeof(client));
|
||||
memset(&server, 0, sizeof(server));
|
||||
|
||||
#ifdef ANDROID_CHANGES
|
||||
openssl_hash_init();
|
||||
#endif
|
||||
chap_md5_init();
|
||||
#ifdef CHAPMS
|
||||
chapms_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a new digest type to the list.
|
||||
*/
|
||||
void
|
||||
chap_register_digest(struct chap_digest_type *dp)
|
||||
{
|
||||
dp->next = chap_digests;
|
||||
chap_digests = dp;
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_lowerup - we can start doing stuff now.
|
||||
*/
|
||||
static void
|
||||
chap_lowerup(int unit)
|
||||
{
|
||||
struct chap_client_state *cs = &client;
|
||||
struct chap_server_state *ss = &server;
|
||||
|
||||
cs->flags |= LOWERUP;
|
||||
ss->flags |= LOWERUP;
|
||||
if (ss->flags & AUTH_STARTED)
|
||||
chap_timeout(ss);
|
||||
}
|
||||
|
||||
static void
|
||||
chap_lowerdown(int unit)
|
||||
{
|
||||
struct chap_client_state *cs = &client;
|
||||
struct chap_server_state *ss = &server;
|
||||
|
||||
cs->flags = 0;
|
||||
if (ss->flags & TIMEOUT_PENDING)
|
||||
UNTIMEOUT(chap_timeout, ss);
|
||||
ss->flags = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_auth_peer - Start authenticating the peer.
|
||||
* If the lower layer is already up, we start sending challenges,
|
||||
* otherwise we wait for the lower layer to come up.
|
||||
*/
|
||||
void
|
||||
chap_auth_peer(int unit, char *our_name, int digest_code)
|
||||
{
|
||||
struct chap_server_state *ss = &server;
|
||||
struct chap_digest_type *dp;
|
||||
|
||||
if (ss->flags & AUTH_STARTED) {
|
||||
error("CHAP: peer authentication already started!");
|
||||
return;
|
||||
}
|
||||
for (dp = chap_digests; dp != NULL; dp = dp->next)
|
||||
if (dp->code == digest_code)
|
||||
break;
|
||||
if (dp == NULL)
|
||||
fatal("CHAP digest 0x%x requested but not available",
|
||||
digest_code);
|
||||
|
||||
ss->digest = dp;
|
||||
ss->name = our_name;
|
||||
/* Start with a random ID value */
|
||||
ss->id = (unsigned char)(drand48() * 256);
|
||||
ss->flags |= AUTH_STARTED;
|
||||
if (ss->flags & LOWERUP)
|
||||
chap_timeout(ss);
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_auth_with_peer - Prepare to authenticate ourselves to the peer.
|
||||
* There isn't much to do until we receive a challenge.
|
||||
*/
|
||||
void
|
||||
chap_auth_with_peer(int unit, char *our_name, int digest_code)
|
||||
{
|
||||
struct chap_client_state *cs = &client;
|
||||
struct chap_digest_type *dp;
|
||||
|
||||
if (cs->flags & AUTH_STARTED) {
|
||||
error("CHAP: authentication with peer already started!");
|
||||
return;
|
||||
}
|
||||
for (dp = chap_digests; dp != NULL; dp = dp->next)
|
||||
if (dp->code == digest_code)
|
||||
break;
|
||||
if (dp == NULL)
|
||||
fatal("CHAP digest 0x%x requested but not available",
|
||||
digest_code);
|
||||
|
||||
cs->digest = dp;
|
||||
cs->name = our_name;
|
||||
cs->flags |= AUTH_STARTED;
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_timeout - It's time to send another challenge to the peer.
|
||||
* This could be either a retransmission of a previous challenge,
|
||||
* or a new challenge to start re-authentication.
|
||||
*/
|
||||
static void
|
||||
chap_timeout(void *arg)
|
||||
{
|
||||
struct chap_server_state *ss = arg;
|
||||
|
||||
ss->flags &= ~TIMEOUT_PENDING;
|
||||
if ((ss->flags & CHALLENGE_VALID) == 0) {
|
||||
ss->challenge_xmits = 0;
|
||||
chap_generate_challenge(ss);
|
||||
ss->flags |= CHALLENGE_VALID;
|
||||
} else if (ss->challenge_xmits >= chap_max_transmits) {
|
||||
ss->flags &= ~CHALLENGE_VALID;
|
||||
ss->flags |= AUTH_DONE | AUTH_FAILED;
|
||||
auth_peer_fail(0, PPP_CHAP);
|
||||
return;
|
||||
}
|
||||
|
||||
output(0, ss->challenge, ss->challenge_pktlen);
|
||||
++ss->challenge_xmits;
|
||||
ss->flags |= TIMEOUT_PENDING;
|
||||
TIMEOUT(chap_timeout, arg, chap_timeout_time);
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_generate_challenge - generate a challenge string and format
|
||||
* the challenge packet in ss->challenge_pkt.
|
||||
*/
|
||||
static void
|
||||
chap_generate_challenge(struct chap_server_state *ss)
|
||||
{
|
||||
int clen = 1, nlen, len;
|
||||
unsigned char *p;
|
||||
|
||||
p = ss->challenge;
|
||||
MAKEHEADER(p, PPP_CHAP);
|
||||
p += CHAP_HDRLEN;
|
||||
ss->digest->generate_challenge(p);
|
||||
clen = *p;
|
||||
nlen = strlen(ss->name);
|
||||
memcpy(p + 1 + clen, ss->name, nlen);
|
||||
|
||||
len = CHAP_HDRLEN + 1 + clen + nlen;
|
||||
ss->challenge_pktlen = PPP_HDRLEN + len;
|
||||
|
||||
p = ss->challenge + PPP_HDRLEN;
|
||||
p[0] = CHAP_CHALLENGE;
|
||||
p[1] = ++ss->id;
|
||||
p[2] = len >> 8;
|
||||
p[3] = len;
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_handle_response - check the response to our challenge.
|
||||
*/
|
||||
static void
|
||||
chap_handle_response(struct chap_server_state *ss, int id,
|
||||
unsigned char *pkt, int len)
|
||||
{
|
||||
int response_len, ok, mlen;
|
||||
unsigned char *response, *p;
|
||||
char *name = NULL; /* initialized to shut gcc up */
|
||||
int (*verifier)(char *, char *, int, struct chap_digest_type *,
|
||||
unsigned char *, unsigned char *, char *, int);
|
||||
char rname[MAXNAMELEN+1];
|
||||
char message[256];
|
||||
|
||||
if ((ss->flags & LOWERUP) == 0)
|
||||
return;
|
||||
if (id != ss->challenge[PPP_HDRLEN+1] || len < 2)
|
||||
return;
|
||||
if ((ss->flags & AUTH_DONE) == 0) {
|
||||
if ((ss->flags & CHALLENGE_VALID) == 0)
|
||||
return;
|
||||
response = pkt;
|
||||
GETCHAR(response_len, pkt);
|
||||
len -= response_len + 1; /* length of name */
|
||||
name = (char *)pkt + response_len;
|
||||
if (len < 0)
|
||||
return;
|
||||
|
||||
ss->flags &= ~CHALLENGE_VALID;
|
||||
if (ss->flags & TIMEOUT_PENDING) {
|
||||
ss->flags &= ~TIMEOUT_PENDING;
|
||||
UNTIMEOUT(chap_timeout, ss);
|
||||
}
|
||||
|
||||
if (explicit_remote) {
|
||||
name = remote_name;
|
||||
} else {
|
||||
/* Null terminate and clean remote name. */
|
||||
slprintf(rname, sizeof(rname), "%.*v", len, name);
|
||||
name = rname;
|
||||
}
|
||||
|
||||
if (chap_verify_hook)
|
||||
verifier = chap_verify_hook;
|
||||
else
|
||||
verifier = chap_verify_response;
|
||||
ok = (*verifier)(name, ss->name, id, ss->digest,
|
||||
ss->challenge + PPP_HDRLEN + CHAP_HDRLEN,
|
||||
response, message, sizeof(message));
|
||||
if (!ok || !auth_number()) {
|
||||
ss->flags |= AUTH_FAILED;
|
||||
warn("Peer %q failed CHAP authentication", name);
|
||||
}
|
||||
}
|
||||
|
||||
/* send the response */
|
||||
p = outpacket_buf;
|
||||
MAKEHEADER(p, PPP_CHAP);
|
||||
mlen = strlen(message);
|
||||
len = CHAP_HDRLEN + mlen;
|
||||
p[0] = (ss->flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS;
|
||||
p[1] = id;
|
||||
p[2] = len >> 8;
|
||||
p[3] = len;
|
||||
if (mlen > 0)
|
||||
memcpy(p + CHAP_HDRLEN, message, mlen);
|
||||
output(0, outpacket_buf, PPP_HDRLEN + len);
|
||||
|
||||
if ((ss->flags & AUTH_DONE) == 0) {
|
||||
ss->flags |= AUTH_DONE;
|
||||
if (ss->flags & AUTH_FAILED) {
|
||||
auth_peer_fail(0, PPP_CHAP);
|
||||
} else {
|
||||
auth_peer_success(0, PPP_CHAP, ss->digest->code,
|
||||
name, strlen(name));
|
||||
if (chap_rechallenge_time) {
|
||||
ss->flags |= TIMEOUT_PENDING;
|
||||
TIMEOUT(chap_timeout, ss,
|
||||
chap_rechallenge_time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_verify_response - check whether the peer's response matches
|
||||
* what we think it should be. Returns 1 if it does (authentication
|
||||
* succeeded), or 0 if it doesn't.
|
||||
*/
|
||||
static int
|
||||
chap_verify_response(char *name, char *ourname, int id,
|
||||
struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space)
|
||||
{
|
||||
int ok;
|
||||
unsigned char secret[MAXSECRETLEN];
|
||||
int secret_len;
|
||||
|
||||
/* Get the secret that the peer is supposed to know */
|
||||
if (!get_secret(0, name, ourname, (char *)secret, &secret_len, 1)) {
|
||||
error("No CHAP secret found for authenticating %q", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ok = digest->verify_response(id, name, secret, secret_len, challenge,
|
||||
response, message, message_space);
|
||||
memset(secret, 0, sizeof(secret));
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_respond - Generate and send a response to a challenge.
|
||||
*/
|
||||
static void
|
||||
chap_respond(struct chap_client_state *cs, int id,
|
||||
unsigned char *pkt, int len)
|
||||
{
|
||||
int clen, nlen;
|
||||
int secret_len;
|
||||
unsigned char *p;
|
||||
unsigned char response[RESP_MAX_PKTLEN];
|
||||
char rname[MAXNAMELEN+1];
|
||||
char secret[MAXSECRETLEN+1];
|
||||
|
||||
if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED))
|
||||
return; /* not ready */
|
||||
if (len < 2 || len < pkt[0] + 1)
|
||||
return; /* too short */
|
||||
clen = pkt[0];
|
||||
nlen = len - (clen + 1);
|
||||
|
||||
/* Null terminate and clean remote name. */
|
||||
slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1);
|
||||
|
||||
/* Microsoft doesn't send their name back in the PPP packet */
|
||||
if (explicit_remote || (remote_name[0] != 0 && rname[0] == 0))
|
||||
strlcpy(rname, remote_name, sizeof(rname));
|
||||
|
||||
/* get secret for authenticating ourselves with the specified host */
|
||||
if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) {
|
||||
secret_len = 0; /* assume null secret if can't find one */
|
||||
warn("No CHAP secret found for authenticating us to %q", rname);
|
||||
}
|
||||
|
||||
p = response;
|
||||
MAKEHEADER(p, PPP_CHAP);
|
||||
p += CHAP_HDRLEN;
|
||||
|
||||
cs->digest->make_response(p, id, cs->name, pkt,
|
||||
secret, secret_len, cs->priv);
|
||||
memset(secret, 0, secret_len);
|
||||
|
||||
clen = *p;
|
||||
nlen = strlen(cs->name);
|
||||
memcpy(p + clen + 1, cs->name, nlen);
|
||||
|
||||
p = response + PPP_HDRLEN;
|
||||
len = CHAP_HDRLEN + clen + 1 + nlen;
|
||||
p[0] = CHAP_RESPONSE;
|
||||
p[1] = id;
|
||||
p[2] = len >> 8;
|
||||
p[3] = len;
|
||||
|
||||
output(0, response, PPP_HDRLEN + len);
|
||||
}
|
||||
|
||||
static void
|
||||
chap_handle_status(struct chap_client_state *cs, int code, int id,
|
||||
unsigned char *pkt, int len)
|
||||
{
|
||||
const char *msg = NULL;
|
||||
|
||||
if ((cs->flags & (AUTH_DONE|AUTH_STARTED|LOWERUP))
|
||||
!= (AUTH_STARTED|LOWERUP))
|
||||
return;
|
||||
cs->flags |= AUTH_DONE;
|
||||
|
||||
if (code == CHAP_SUCCESS) {
|
||||
/* used for MS-CHAP v2 mutual auth, yuck */
|
||||
if (cs->digest->check_success != NULL) {
|
||||
if (!(*cs->digest->check_success)(pkt, len, cs->priv))
|
||||
code = CHAP_FAILURE;
|
||||
} else
|
||||
msg = "CHAP authentication succeeded";
|
||||
} else {
|
||||
if (cs->digest->handle_failure != NULL)
|
||||
(*cs->digest->handle_failure)(pkt, len);
|
||||
else
|
||||
msg = "CHAP authentication failed";
|
||||
}
|
||||
if (msg) {
|
||||
if (len > 0)
|
||||
info("%s: %.*v", msg, len, pkt);
|
||||
else
|
||||
info("%s", msg);
|
||||
}
|
||||
if (code == CHAP_SUCCESS)
|
||||
auth_withpeer_success(0, PPP_CHAP, cs->digest->code);
|
||||
else {
|
||||
cs->flags |= AUTH_FAILED;
|
||||
auth_withpeer_fail(0, PPP_CHAP);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
chap_input(int unit, unsigned char *pkt, int pktlen)
|
||||
{
|
||||
struct chap_client_state *cs = &client;
|
||||
struct chap_server_state *ss = &server;
|
||||
unsigned char code, id;
|
||||
int len;
|
||||
|
||||
if (pktlen < CHAP_HDRLEN)
|
||||
return;
|
||||
GETCHAR(code, pkt);
|
||||
GETCHAR(id, pkt);
|
||||
GETSHORT(len, pkt);
|
||||
if (len < CHAP_HDRLEN || len > pktlen)
|
||||
return;
|
||||
len -= CHAP_HDRLEN;
|
||||
|
||||
switch (code) {
|
||||
case CHAP_CHALLENGE:
|
||||
chap_respond(cs, id, pkt, len);
|
||||
break;
|
||||
case CHAP_RESPONSE:
|
||||
chap_handle_response(ss, id, pkt, len);
|
||||
break;
|
||||
case CHAP_FAILURE:
|
||||
case CHAP_SUCCESS:
|
||||
chap_handle_status(cs, code, id, pkt, len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
chap_protrej(int unit)
|
||||
{
|
||||
struct chap_client_state *cs = &client;
|
||||
struct chap_server_state *ss = &server;
|
||||
|
||||
if (ss->flags & TIMEOUT_PENDING) {
|
||||
ss->flags &= ~TIMEOUT_PENDING;
|
||||
UNTIMEOUT(chap_timeout, ss);
|
||||
}
|
||||
if (ss->flags & AUTH_STARTED) {
|
||||
ss->flags = 0;
|
||||
auth_peer_fail(0, PPP_CHAP);
|
||||
}
|
||||
if ((cs->flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) {
|
||||
cs->flags &= ~AUTH_STARTED;
|
||||
auth_withpeer_fail(0, PPP_CHAP);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* chap_print_pkt - print the contents of a CHAP packet.
|
||||
*/
|
||||
static char *chap_code_names[] = {
|
||||
"Challenge", "Response", "Success", "Failure"
|
||||
};
|
||||
|
||||
static int
|
||||
chap_print_pkt(unsigned char *p, int plen,
|
||||
void (*printer) __P((void *, char *, ...)), void *arg)
|
||||
{
|
||||
int code, id, len;
|
||||
int clen, nlen;
|
||||
unsigned char x;
|
||||
|
||||
if (plen < CHAP_HDRLEN)
|
||||
return 0;
|
||||
GETCHAR(code, p);
|
||||
GETCHAR(id, p);
|
||||
GETSHORT(len, p);
|
||||
if (len < CHAP_HDRLEN || len > plen)
|
||||
return 0;
|
||||
|
||||
if (code >= 1 && code <= sizeof(chap_code_names) / sizeof(char *))
|
||||
printer(arg, " %s", chap_code_names[code-1]);
|
||||
else
|
||||
printer(arg, " code=0x%x", code);
|
||||
printer(arg, " id=0x%x", id);
|
||||
len -= CHAP_HDRLEN;
|
||||
switch (code) {
|
||||
case CHAP_CHALLENGE:
|
||||
case CHAP_RESPONSE:
|
||||
if (len < 1)
|
||||
break;
|
||||
clen = p[0];
|
||||
if (len < clen + 1)
|
||||
break;
|
||||
++p;
|
||||
nlen = len - clen - 1;
|
||||
printer(arg, " <");
|
||||
for (; clen > 0; --clen) {
|
||||
GETCHAR(x, p);
|
||||
printer(arg, "%.2x", x);
|
||||
}
|
||||
printer(arg, ">, name = ");
|
||||
print_string((char *)p, nlen, printer, arg);
|
||||
break;
|
||||
case CHAP_FAILURE:
|
||||
case CHAP_SUCCESS:
|
||||
printer(arg, " ");
|
||||
print_string((char *)p, len, printer, arg);
|
||||
break;
|
||||
default:
|
||||
for (clen = len; clen > 0; --clen) {
|
||||
GETCHAR(x, p);
|
||||
printer(arg, " %.2x", x);
|
||||
}
|
||||
}
|
||||
|
||||
return len + CHAP_HDRLEN;
|
||||
}
|
||||
|
||||
struct protent chap_protent = {
|
||||
PPP_CHAP,
|
||||
chap_init,
|
||||
chap_input,
|
||||
chap_protrej,
|
||||
chap_lowerup,
|
||||
chap_lowerdown,
|
||||
NULL, /* open */
|
||||
NULL, /* close */
|
||||
chap_print_pkt,
|
||||
NULL, /* datainput */
|
||||
1, /* enabled_flag */
|
||||
"CHAP", /* name */
|
||||
NULL, /* data_name */
|
||||
chap_option_list,
|
||||
NULL, /* check_options */
|
||||
};
|
||||
130
vendor/aw/homlet/external/pppoe/pppd/chap-new.h
vendored
Normal file
130
vendor/aw/homlet/external/pppoe/pppd/chap-new.h
vendored
Normal file
@ -0,0 +1,130 @@
|
||||
/*
|
||||
* chap-new.c - New CHAP implementation.
|
||||
*
|
||||
* Copyright (c) 2003 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHAP packets begin with a standard header with code, id, len (2 bytes).
|
||||
*/
|
||||
#define CHAP_HDRLEN 4
|
||||
|
||||
/*
|
||||
* Values for the code field.
|
||||
*/
|
||||
#define CHAP_CHALLENGE 1
|
||||
#define CHAP_RESPONSE 2
|
||||
#define CHAP_SUCCESS 3
|
||||
#define CHAP_FAILURE 4
|
||||
|
||||
/*
|
||||
* CHAP digest codes.
|
||||
*/
|
||||
#define CHAP_MD5 5
|
||||
#define CHAP_MICROSOFT 0x80
|
||||
#define CHAP_MICROSOFT_V2 0x81
|
||||
|
||||
/*
|
||||
* Semi-arbitrary limits on challenge and response fields.
|
||||
*/
|
||||
#define MAX_CHALLENGE_LEN 64
|
||||
#define MAX_RESPONSE_LEN 64
|
||||
|
||||
/* bitmask of supported algorithms */
|
||||
#define MDTYPE_MICROSOFT_V2 0x1
|
||||
#define MDTYPE_MICROSOFT 0x2
|
||||
#define MDTYPE_MD5 0x4
|
||||
#define MDTYPE_NONE 0
|
||||
|
||||
/* hashes supported by this instance of pppd */
|
||||
extern int chap_mdtype_all;
|
||||
|
||||
/* Return the digest alg. ID for the most preferred digest type. */
|
||||
#define CHAP_DIGEST(mdtype) \
|
||||
((mdtype) & MDTYPE_MD5)? CHAP_MD5: \
|
||||
((mdtype) & MDTYPE_MICROSOFT_V2)? CHAP_MICROSOFT_V2: \
|
||||
((mdtype) & MDTYPE_MICROSOFT)? CHAP_MICROSOFT: \
|
||||
0
|
||||
|
||||
/* Return the bit flag (lsb set) for our most preferred digest type. */
|
||||
#define CHAP_MDTYPE(mdtype) ((mdtype) ^ ((mdtype) - 1)) & (mdtype)
|
||||
|
||||
/* Return the bit flag for a given digest algorithm ID. */
|
||||
#define CHAP_MDTYPE_D(digest) \
|
||||
((digest) == CHAP_MICROSOFT_V2)? MDTYPE_MICROSOFT_V2: \
|
||||
((digest) == CHAP_MICROSOFT)? MDTYPE_MICROSOFT: \
|
||||
((digest) == CHAP_MD5)? MDTYPE_MD5: \
|
||||
0
|
||||
|
||||
/* Can we do the requested digest? */
|
||||
#define CHAP_CANDIGEST(mdtype, digest) \
|
||||
((digest) == CHAP_MICROSOFT_V2)? (mdtype) & MDTYPE_MICROSOFT_V2: \
|
||||
((digest) == CHAP_MICROSOFT)? (mdtype) & MDTYPE_MICROSOFT: \
|
||||
((digest) == CHAP_MD5)? (mdtype) & MDTYPE_MD5: \
|
||||
0
|
||||
|
||||
/*
|
||||
* The code for each digest type has to supply one of these.
|
||||
*/
|
||||
struct chap_digest_type {
|
||||
int code;
|
||||
|
||||
/*
|
||||
* Note: challenge and response arguments below are formatted as
|
||||
* a length byte followed by the actual challenge/response data.
|
||||
*/
|
||||
void (*generate_challenge)(unsigned char *challenge);
|
||||
int (*verify_response)(int id, char *name,
|
||||
unsigned char *secret, int secret_len,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space);
|
||||
void (*make_response)(unsigned char *response, int id, char *our_name,
|
||||
unsigned char *challenge, char *secret, int secret_len,
|
||||
unsigned char *priv);
|
||||
int (*check_success)(unsigned char *pkt, int len, unsigned char *priv);
|
||||
void (*handle_failure)(unsigned char *pkt, int len);
|
||||
|
||||
struct chap_digest_type *next;
|
||||
};
|
||||
|
||||
/* Hook for a plugin to validate CHAP challenge */
|
||||
extern int (*chap_verify_hook)(char *name, char *ourname, int id,
|
||||
struct chap_digest_type *digest,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space);
|
||||
|
||||
/* Called by digest code to register a digest type */
|
||||
extern void chap_register_digest(struct chap_digest_type *);
|
||||
|
||||
/* Called by authentication code to start authenticating the peer. */
|
||||
extern void chap_auth_peer(int unit, char *our_name, int digest_code);
|
||||
|
||||
/* Called by auth. code to start authenticating us to the peer. */
|
||||
extern void chap_auth_with_peer(int unit, char *our_name, int digest_code);
|
||||
|
||||
/* Represents the CHAP protocol to the main pppd code */
|
||||
extern struct protent chap_protent;
|
||||
947
vendor/aw/homlet/external/pppoe/pppd/chap_ms.c
vendored
Normal file
947
vendor/aw/homlet/external/pppoe/pppd/chap_ms.c
vendored
Normal file
@ -0,0 +1,947 @@
|
||||
/*
|
||||
* chap_ms.c - Microsoft MS-CHAP compatible implementation.
|
||||
*
|
||||
* Copyright (c) 1995 Eric Rosenquist. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modifications by Lauri Pesonen / lpesonen@clinet.fi, april 1997
|
||||
*
|
||||
* Implemented LANManager type password response to MS-CHAP challenges.
|
||||
* Now pppd provides both NT style and LANMan style blocks, and the
|
||||
* prefered is set by option "ms-lanman". Default is to use NT.
|
||||
* The hash text (StdText) was taken from Win95 RASAPI32.DLL.
|
||||
*
|
||||
* You should also use DOMAIN\\USERNAME as described in README.MSCHAP80
|
||||
*/
|
||||
|
||||
/*
|
||||
* Modifications by Frank Cusack, frank@google.com, March 2002.
|
||||
*
|
||||
* Implemented MS-CHAPv2 functionality, heavily based on sample
|
||||
* implementation in RFC 2759. Implemented MPPE functionality,
|
||||
* heavily based on sample implementation in RFC 3079.
|
||||
*
|
||||
* Copyright (c) 2002 The Android Open Source Project
|
||||
*
|
||||
* 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: chap_ms.c,v 1.33 2004/11/12 09:57:43 paulus Exp $"
|
||||
|
||||
#ifdef CHAPMS
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pppd.h"
|
||||
#include "chap-new.h"
|
||||
#include "chap_ms.h"
|
||||
#ifdef ANDROID_CHANGES
|
||||
#include "openssl-hash.h"
|
||||
#else
|
||||
#include "md4.h"
|
||||
#include "sha1.h"
|
||||
#endif
|
||||
#include "pppcrypt.h"
|
||||
#include "magic.h"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
|
||||
static void ascii2unicode __P((char[], int, u_char[]));
|
||||
static void NTPasswordHash __P((char *, int, u_char[MD4_SIGNATURE_SIZE]));
|
||||
static void ChallengeResponse __P((u_char *, u_char *, u_char[24]));
|
||||
static void ChapMS_NT __P((u_char *, char *, int, u_char[24]));
|
||||
static void ChapMS2_NT __P((char *, u_char[16], char *, char *, int,
|
||||
u_char[24]));
|
||||
static void GenerateAuthenticatorResponsePlain
|
||||
__P((char*, int, u_char[24], u_char[16], u_char *,
|
||||
char *, u_char[41]));
|
||||
#ifdef MSLANMAN
|
||||
static void ChapMS_LANMan __P((u_char *, char *, int, MS_ChapResponse *));
|
||||
#endif
|
||||
|
||||
#ifdef MPPE
|
||||
static void Set_Start_Key __P((u_char *, char *, int));
|
||||
static void SetMasterKeys __P((char *, int, u_char[24], int));
|
||||
#endif
|
||||
|
||||
#ifdef MSLANMAN
|
||||
bool ms_lanman = 0; /* Use LanMan password instead of NT */
|
||||
/* Has meaning only with MS-CHAP challenges */
|
||||
#endif
|
||||
|
||||
#ifdef MPPE
|
||||
u_char mppe_send_key[MPPE_MAX_KEY_LEN];
|
||||
u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
|
||||
int mppe_keys_set = 0; /* Have the MPPE keys been set? */
|
||||
|
||||
#ifdef DEBUGMPPEKEY
|
||||
/* For MPPE debug */
|
||||
/* Use "[]|}{?/><,`!2&&(" (sans quotes) for RFC 3079 MS-CHAPv2 test value */
|
||||
static char *mschap_challenge = NULL;
|
||||
/* Use "!@\#$%^&*()_+:3|~" (sans quotes, backslash is to escape #) for ... */
|
||||
static char *mschap2_peer_challenge = NULL;
|
||||
#endif
|
||||
|
||||
#include "fsm.h" /* Need to poke MPPE options */
|
||||
#include "ccp.h"
|
||||
#include <net/ppp-comp.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Command-line options.
|
||||
*/
|
||||
static option_t chapms_option_list[] = {
|
||||
#ifdef MSLANMAN
|
||||
{ "ms-lanman", o_bool, &ms_lanman,
|
||||
"Use LanMan passwd when using MS-CHAP", 1 },
|
||||
#endif
|
||||
#ifdef DEBUGMPPEKEY
|
||||
{ "mschap-challenge", o_string, &mschap_challenge,
|
||||
"specify CHAP challenge" },
|
||||
{ "mschap2-peer-challenge", o_string, &mschap2_peer_challenge,
|
||||
"specify CHAP peer challenge" },
|
||||
#endif
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* chapms_generate_challenge - generate a challenge for MS-CHAP.
|
||||
* For MS-CHAP the challenge length is fixed at 8 bytes.
|
||||
* The length goes in challenge[0] and the actual challenge starts
|
||||
* at challenge[1].
|
||||
*/
|
||||
static void
|
||||
chapms_generate_challenge(unsigned char *challenge)
|
||||
{
|
||||
*challenge++ = 8;
|
||||
#ifdef DEBUGMPPEKEY
|
||||
if (mschap_challenge && strlen(mschap_challenge) == 8)
|
||||
memcpy(challenge, mschap_challenge, 8);
|
||||
else
|
||||
#endif
|
||||
random_bytes(challenge, 8);
|
||||
}
|
||||
|
||||
static void
|
||||
chapms2_generate_challenge(unsigned char *challenge)
|
||||
{
|
||||
*challenge++ = 16;
|
||||
#ifdef DEBUGMPPEKEY
|
||||
if (mschap_challenge && strlen(mschap_challenge) == 16)
|
||||
memcpy(challenge, mschap_challenge, 16);
|
||||
else
|
||||
#endif
|
||||
random_bytes(challenge, 16);
|
||||
}
|
||||
|
||||
static int
|
||||
chapms_verify_response(int id, char *name,
|
||||
unsigned char *secret, int secret_len,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space)
|
||||
{
|
||||
MS_ChapResponse *rmd;
|
||||
MS_ChapResponse md;
|
||||
int diff;
|
||||
int challenge_len, response_len;
|
||||
|
||||
challenge_len = *challenge++; /* skip length, is 8 */
|
||||
response_len = *response++;
|
||||
if (response_len != MS_CHAP_RESPONSE_LEN)
|
||||
goto bad;
|
||||
|
||||
rmd = (MS_ChapResponse *) response;
|
||||
|
||||
#ifndef MSLANMAN
|
||||
if (!rmd->UseNT[0]) {
|
||||
/* Should really propagate this into the error packet. */
|
||||
notice("Peer request for LANMAN auth not supported");
|
||||
goto bad;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Generate the expected response. */
|
||||
ChapMS(challenge, (char *)secret, secret_len, &md);
|
||||
|
||||
#ifdef MSLANMAN
|
||||
/* Determine which part of response to verify against */
|
||||
if (!rmd->UseNT[0])
|
||||
diff = memcmp(&rmd->LANManResp, &md.LANManResp,
|
||||
sizeof(md.LANManResp));
|
||||
else
|
||||
#endif
|
||||
diff = memcmp(&rmd->NTResp, &md.NTResp, sizeof(md.NTResp));
|
||||
|
||||
if (diff == 0) {
|
||||
slprintf(message, message_space, "Access granted");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bad:
|
||||
/* See comments below for MS-CHAP V2 */
|
||||
slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0",
|
||||
challenge_len, challenge);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
chapms2_verify_response(int id, char *name,
|
||||
unsigned char *secret, int secret_len,
|
||||
unsigned char *challenge, unsigned char *response,
|
||||
char *message, int message_space)
|
||||
{
|
||||
MS_Chap2Response *rmd;
|
||||
MS_Chap2Response md;
|
||||
char saresponse[MS_AUTH_RESPONSE_LENGTH+1];
|
||||
int challenge_len, response_len;
|
||||
|
||||
challenge_len = *challenge++; /* skip length, is 16 */
|
||||
response_len = *response++;
|
||||
if (response_len != MS_CHAP2_RESPONSE_LEN)
|
||||
goto bad; /* not even the right length */
|
||||
|
||||
rmd = (MS_Chap2Response *) response;
|
||||
|
||||
/* Generate the expected response and our mutual auth. */
|
||||
ChapMS2(challenge, rmd->PeerChallenge, name,
|
||||
(char *)secret, secret_len, &md,
|
||||
(unsigned char *)saresponse, MS_CHAP2_AUTHENTICATOR);
|
||||
|
||||
/* compare MDs and send the appropriate status */
|
||||
/*
|
||||
* Per RFC 2759, success message must be formatted as
|
||||
* "S=<auth_string> M=<message>"
|
||||
* where
|
||||
* <auth_string> is the Authenticator Response (mutual auth)
|
||||
* <message> is a text message
|
||||
*
|
||||
* However, some versions of Windows (win98 tested) do not know
|
||||
* about the M=<message> part (required per RFC 2759) and flag
|
||||
* it as an error (reported incorrectly as an encryption error
|
||||
* to the user). Since the RFC requires it, and it can be
|
||||
* useful information, we supply it if the peer is a conforming
|
||||
* system. Luckily (?), win98 sets the Flags field to 0x04
|
||||
* (contrary to RFC requirements) so we can use that to
|
||||
* distinguish between conforming and non-conforming systems.
|
||||
*
|
||||
* Special thanks to Alex Swiridov <say@real.kharkov.ua> for
|
||||
* help debugging this.
|
||||
*/
|
||||
if (memcmp(md.NTResp, rmd->NTResp, sizeof(md.NTResp)) == 0) {
|
||||
if (rmd->Flags[0])
|
||||
slprintf(message, message_space, "S=%s", saresponse);
|
||||
else
|
||||
slprintf(message, message_space, "S=%s M=%s",
|
||||
saresponse, "Access granted");
|
||||
return 1;
|
||||
}
|
||||
|
||||
bad:
|
||||
/*
|
||||
* Failure message must be formatted as
|
||||
* "E=e R=r C=c V=v M=m"
|
||||
* where
|
||||
* e = error code (we use 691, ERROR_AUTHENTICATION_FAILURE)
|
||||
* r = retry (we use 1, ok to retry)
|
||||
* c = challenge to use for next response, we reuse previous
|
||||
* v = Change Password version supported, we use 0
|
||||
* m = text message
|
||||
*
|
||||
* The M=m part is only for MS-CHAPv2. Neither win2k nor
|
||||
* win98 (others untested) display the message to the user anyway.
|
||||
* They also both ignore the E=e code.
|
||||
*
|
||||
* Note that it's safe to reuse the same challenge as we don't
|
||||
* actually accept another response based on the error message
|
||||
* (and no clients try to resend a response anyway).
|
||||
*
|
||||
* Basically, this whole bit is useless code, even the small
|
||||
* implementation here is only because of overspecification.
|
||||
*/
|
||||
slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0 M=%s",
|
||||
challenge_len, challenge, "Access denied");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
chapms_make_response(unsigned char *response, int id, char *our_name,
|
||||
unsigned char *challenge, char *secret, int secret_len,
|
||||
unsigned char *private)
|
||||
{
|
||||
challenge++; /* skip length, should be 8 */
|
||||
*response++ = MS_CHAP_RESPONSE_LEN;
|
||||
ChapMS(challenge, secret, secret_len, (MS_ChapResponse *) response);
|
||||
}
|
||||
|
||||
static void
|
||||
chapms2_make_response(unsigned char *response, int id, char *our_name,
|
||||
unsigned char *challenge, char *secret, int secret_len,
|
||||
unsigned char *private)
|
||||
{
|
||||
challenge++; /* skip length, should be 16 */
|
||||
*response++ = MS_CHAP2_RESPONSE_LEN;
|
||||
ChapMS2(challenge,
|
||||
#ifdef DEBUGMPPEKEY
|
||||
mschap2_peer_challenge,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
our_name, secret, secret_len,
|
||||
(MS_Chap2Response *) response, private,
|
||||
MS_CHAP2_AUTHENTICATEE);
|
||||
}
|
||||
|
||||
static int
|
||||
chapms2_check_success(unsigned char *msg, int len, unsigned char *private)
|
||||
{
|
||||
if ((len < MS_AUTH_RESPONSE_LENGTH + 2) ||
|
||||
strncmp((char *)msg, "S=", 2) != 0) {
|
||||
/* Packet does not start with "S=" */
|
||||
error("MS-CHAPv2 Success packet is badly formed.");
|
||||
return 0;
|
||||
}
|
||||
msg += 2;
|
||||
len -= 2;
|
||||
if (len < MS_AUTH_RESPONSE_LENGTH
|
||||
|| memcmp(msg, private, MS_AUTH_RESPONSE_LENGTH)) {
|
||||
/* Authenticator Response did not match expected. */
|
||||
error("MS-CHAPv2 mutual authentication failed.");
|
||||
return 0;
|
||||
}
|
||||
/* Authenticator Response matches. */
|
||||
msg += MS_AUTH_RESPONSE_LENGTH; /* Eat it */
|
||||
len -= MS_AUTH_RESPONSE_LENGTH;
|
||||
if ((len >= 3) && !strncmp((char *)msg, " M=", 3)) {
|
||||
msg += 3; /* Eat the delimiter */
|
||||
} else if (len) {
|
||||
/* Packet has extra text which does not begin " M=" */
|
||||
error("MS-CHAPv2 Success packet is badly formed.");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
chapms_handle_failure(unsigned char *inp, int len)
|
||||
{
|
||||
int err;
|
||||
char *p, *msg;
|
||||
|
||||
/* We want a null-terminated string for strxxx(). */
|
||||
msg = malloc(len + 1);
|
||||
if (!msg) {
|
||||
notice("Out of memory in chapms_handle_failure");
|
||||
return;
|
||||
}
|
||||
BCOPY(inp, msg, len);
|
||||
msg[len] = 0;
|
||||
p = msg;
|
||||
|
||||
/*
|
||||
* Deal with MS-CHAP formatted failure messages; just print the
|
||||
* M=<message> part (if any). For MS-CHAP we're not really supposed
|
||||
* to use M=<message>, but it shouldn't hurt. See
|
||||
* chapms[2]_verify_response.
|
||||
*/
|
||||
if (!strncmp(p, "E=", 2))
|
||||
err = strtol(p, NULL, 10); /* Remember the error code. */
|
||||
else
|
||||
goto print_msg; /* Message is badly formatted. */
|
||||
|
||||
if (len && ((p = strstr(p, " M=")) != NULL)) {
|
||||
/* M=<message> field found. */
|
||||
p += 3;
|
||||
} else {
|
||||
/* No M=<message>; use the error code. */
|
||||
switch (err) {
|
||||
case MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS:
|
||||
p = "E=646 Restricted logon hours";
|
||||
break;
|
||||
|
||||
case MS_CHAP_ERROR_ACCT_DISABLED:
|
||||
p = "E=647 Account disabled";
|
||||
break;
|
||||
|
||||
case MS_CHAP_ERROR_PASSWD_EXPIRED:
|
||||
p = "E=648 Password expired";
|
||||
break;
|
||||
|
||||
case MS_CHAP_ERROR_NO_DIALIN_PERMISSION:
|
||||
p = "E=649 No dialin permission";
|
||||
break;
|
||||
|
||||
case MS_CHAP_ERROR_AUTHENTICATION_FAILURE:
|
||||
p = "E=691 Authentication failure";
|
||||
break;
|
||||
|
||||
case MS_CHAP_ERROR_CHANGING_PASSWORD:
|
||||
/* Should never see this, we don't support Change Password. */
|
||||
p = "E=709 Error changing password";
|
||||
break;
|
||||
|
||||
default:
|
||||
free(msg);
|
||||
error("Unknown MS-CHAP authentication failure: %.*v",
|
||||
len, inp);
|
||||
return;
|
||||
}
|
||||
}
|
||||
print_msg:
|
||||
if (p != NULL)
|
||||
error("MS-CHAP authentication failed: %v", p);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
static void
|
||||
ChallengeResponse(u_char *challenge,
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE],
|
||||
u_char response[24])
|
||||
{
|
||||
u_char ZPasswordHash[21];
|
||||
|
||||
BZERO(ZPasswordHash, sizeof(ZPasswordHash));
|
||||
BCOPY(PasswordHash, ZPasswordHash, MD4_SIGNATURE_SIZE);
|
||||
|
||||
#if 0
|
||||
dbglog("ChallengeResponse - ZPasswordHash %.*B",
|
||||
sizeof(ZPasswordHash), ZPasswordHash);
|
||||
#endif
|
||||
|
||||
(void) DesSetkey(ZPasswordHash + 0);
|
||||
DesEncrypt(challenge, response + 0);
|
||||
(void) DesSetkey(ZPasswordHash + 7);
|
||||
DesEncrypt(challenge, response + 8);
|
||||
(void) DesSetkey(ZPasswordHash + 14);
|
||||
DesEncrypt(challenge, response + 16);
|
||||
|
||||
#if 0
|
||||
dbglog("ChallengeResponse - response %.24B", response);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
ChallengeHash(u_char PeerChallenge[16], u_char *rchallenge,
|
||||
char *username, u_char Challenge[8])
|
||||
|
||||
{
|
||||
SHA1_CTX sha1Context;
|
||||
u_char sha1Hash[SHA1_SIGNATURE_SIZE];
|
||||
char *user;
|
||||
|
||||
/* remove domain from "domain\username" */
|
||||
if ((user = strrchr(username, '\\')) != NULL)
|
||||
++user;
|
||||
else
|
||||
user = username;
|
||||
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, PeerChallenge, 16);
|
||||
SHA1_Update(&sha1Context, rchallenge, 16);
|
||||
SHA1_Update(&sha1Context, (unsigned char *)user, strlen(user));
|
||||
SHA1_Final(sha1Hash, &sha1Context);
|
||||
|
||||
BCOPY(sha1Hash, Challenge, 8);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert the ASCII version of the password to Unicode.
|
||||
* This implicitly supports 8-bit ISO8859/1 characters.
|
||||
* This gives us the little-endian representation, which
|
||||
* is assumed by all M$ CHAP RFCs. (Unicode byte ordering
|
||||
* is machine-dependent.)
|
||||
*/
|
||||
static void
|
||||
ascii2unicode(char ascii[], int ascii_len, u_char unicode[])
|
||||
{
|
||||
int i;
|
||||
|
||||
BZERO(unicode, ascii_len * 2);
|
||||
for (i = 0; i < ascii_len; i++)
|
||||
unicode[i * 2] = (u_char) ascii[i];
|
||||
}
|
||||
|
||||
static void
|
||||
NTPasswordHash(char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE])
|
||||
{
|
||||
#ifdef ANDROID_CHANGES
|
||||
/* We link with MD4 routines in openssl, we have to take bytes instead */
|
||||
int mdlen = secret_len;
|
||||
#else
|
||||
#ifdef __NetBSD__
|
||||
/* NetBSD uses the libc md4 routines which take bytes instead of bits */
|
||||
int mdlen = secret_len;
|
||||
#else
|
||||
int mdlen = secret_len * 8;
|
||||
#endif
|
||||
#endif
|
||||
MD4_CTX md4Context;
|
||||
|
||||
MD4Init(&md4Context);
|
||||
MD4Update(&md4Context, (unsigned char *)secret, mdlen);
|
||||
MD4Final(hash, &md4Context);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
ChapMS_NT(u_char *rchallenge, char *secret, int secret_len,
|
||||
u_char NTResponse[24])
|
||||
{
|
||||
u_char unicodePassword[MAX_NT_PASSWORD * 2];
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE];
|
||||
|
||||
/* Hash the Unicode version of the secret (== password). */
|
||||
ascii2unicode(secret, secret_len, unicodePassword);
|
||||
NTPasswordHash((char *)unicodePassword, secret_len * 2, PasswordHash);
|
||||
|
||||
ChallengeResponse(rchallenge, PasswordHash, NTResponse);
|
||||
}
|
||||
|
||||
static void
|
||||
ChapMS2_NT(char *rchallenge, u_char PeerChallenge[16], char *username,
|
||||
char *secret, int secret_len, u_char NTResponse[24])
|
||||
{
|
||||
u_char unicodePassword[MAX_NT_PASSWORD * 2];
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE];
|
||||
u_char Challenge[8];
|
||||
|
||||
ChallengeHash(PeerChallenge, (unsigned char *)rchallenge, username,
|
||||
Challenge);
|
||||
|
||||
/* Hash the Unicode version of the secret (== password). */
|
||||
ascii2unicode(secret, secret_len, unicodePassword);
|
||||
NTPasswordHash((char *)unicodePassword, secret_len * 2, PasswordHash);
|
||||
|
||||
ChallengeResponse(Challenge, PasswordHash, NTResponse);
|
||||
}
|
||||
|
||||
#ifdef MSLANMAN
|
||||
static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */
|
||||
|
||||
static void
|
||||
ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len,
|
||||
MS_ChapResponse *response)
|
||||
{
|
||||
int i;
|
||||
u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE];
|
||||
|
||||
/* LANMan password is case insensitive */
|
||||
BZERO(UcasePassword, sizeof(UcasePassword));
|
||||
for (i = 0; i < secret_len; i++)
|
||||
UcasePassword[i] = (u_char)toupper(secret[i]);
|
||||
(void) DesSetkey(UcasePassword + 0);
|
||||
DesEncrypt( StdText, PasswordHash + 0 );
|
||||
(void) DesSetkey(UcasePassword + 7);
|
||||
DesEncrypt( StdText, PasswordHash + 8 );
|
||||
ChallengeResponse(rchallenge, PasswordHash, response->LANManResp);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
|
||||
u_char NTResponse[24], u_char PeerChallenge[16],
|
||||
u_char *rchallenge, char *username,
|
||||
u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1])
|
||||
{
|
||||
/*
|
||||
* "Magic" constants used in response generation, from RFC 2759.
|
||||
*/
|
||||
u_char Magic1[39] = /* "Magic server to client signing constant" */
|
||||
{ 0x4D, 0x61, 0x67, 0x69, 0x63, 0x20, 0x73, 0x65, 0x72, 0x76,
|
||||
0x65, 0x72, 0x20, 0x74, 0x6F, 0x20, 0x63, 0x6C, 0x69, 0x65,
|
||||
0x6E, 0x74, 0x20, 0x73, 0x69, 0x67, 0x6E, 0x69, 0x6E, 0x67,
|
||||
0x20, 0x63, 0x6F, 0x6E, 0x73, 0x74, 0x61, 0x6E, 0x74 };
|
||||
u_char Magic2[41] = /* "Pad to make it do more than one iteration" */
|
||||
{ 0x50, 0x61, 0x64, 0x20, 0x74, 0x6F, 0x20, 0x6D, 0x61, 0x6B,
|
||||
0x65, 0x20, 0x69, 0x74, 0x20, 0x64, 0x6F, 0x20, 0x6D, 0x6F,
|
||||
0x72, 0x65, 0x20, 0x74, 0x68, 0x61, 0x6E, 0x20, 0x6F, 0x6E,
|
||||
0x65, 0x20, 0x69, 0x74, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6F,
|
||||
0x6E };
|
||||
|
||||
int i;
|
||||
SHA1_CTX sha1Context;
|
||||
u_char Digest[SHA1_SIGNATURE_SIZE];
|
||||
u_char Challenge[8];
|
||||
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
|
||||
SHA1_Update(&sha1Context, NTResponse, 24);
|
||||
SHA1_Update(&sha1Context, Magic1, sizeof(Magic1));
|
||||
SHA1_Final(Digest, &sha1Context);
|
||||
|
||||
ChallengeHash(PeerChallenge, rchallenge, username, Challenge);
|
||||
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, Digest, sizeof(Digest));
|
||||
SHA1_Update(&sha1Context, Challenge, sizeof(Challenge));
|
||||
SHA1_Update(&sha1Context, Magic2, sizeof(Magic2));
|
||||
SHA1_Final(Digest, &sha1Context);
|
||||
|
||||
/* Convert to ASCII hex string. */
|
||||
for (i = 0; i < MAX((MS_AUTH_RESPONSE_LENGTH / 2), sizeof(Digest)); i++)
|
||||
sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
GenerateAuthenticatorResponsePlain
|
||||
(char *secret, int secret_len,
|
||||
u_char NTResponse[24], u_char PeerChallenge[16],
|
||||
u_char *rchallenge, char *username,
|
||||
u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1])
|
||||
{
|
||||
u_char unicodePassword[MAX_NT_PASSWORD * 2];
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE];
|
||||
u_char PasswordHashHash[MD4_SIGNATURE_SIZE];
|
||||
|
||||
/* Hash (x2) the Unicode version of the secret (== password). */
|
||||
ascii2unicode(secret, secret_len, unicodePassword);
|
||||
NTPasswordHash((char *)unicodePassword, secret_len * 2, PasswordHash);
|
||||
NTPasswordHash((char *)PasswordHash, sizeof(PasswordHash),
|
||||
PasswordHashHash);
|
||||
|
||||
GenerateAuthenticatorResponse(PasswordHashHash, NTResponse, PeerChallenge,
|
||||
rchallenge, username, authResponse);
|
||||
}
|
||||
|
||||
|
||||
#ifdef MPPE
|
||||
/*
|
||||
* Set mppe_xxxx_key from the NTPasswordHashHash.
|
||||
* RFC 2548 (RADIUS support) requires us to export this function (ugh).
|
||||
*/
|
||||
void
|
||||
mppe_set_keys(u_char *rchallenge, u_char PasswordHashHash[MD4_SIGNATURE_SIZE])
|
||||
{
|
||||
SHA1_CTX sha1Context;
|
||||
u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */
|
||||
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
|
||||
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
|
||||
SHA1_Update(&sha1Context, rchallenge, 8);
|
||||
SHA1_Final(Digest, &sha1Context);
|
||||
|
||||
/* Same key in both directions. */
|
||||
BCOPY(Digest, mppe_send_key, sizeof(mppe_send_key));
|
||||
BCOPY(Digest, mppe_recv_key, sizeof(mppe_recv_key));
|
||||
|
||||
mppe_keys_set = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set mppe_xxxx_key from MS-CHAP credentials. (see RFC 3079)
|
||||
*/
|
||||
static void
|
||||
Set_Start_Key(u_char *rchallenge, char *secret, int secret_len)
|
||||
{
|
||||
u_char unicodePassword[MAX_NT_PASSWORD * 2];
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE];
|
||||
u_char PasswordHashHash[MD4_SIGNATURE_SIZE];
|
||||
|
||||
/* Hash (x2) the Unicode version of the secret (== password). */
|
||||
ascii2unicode(secret, secret_len, unicodePassword);
|
||||
NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
|
||||
NTPasswordHash(PasswordHash, sizeof(PasswordHash), PasswordHashHash);
|
||||
|
||||
mppe_set_keys(rchallenge, PasswordHashHash);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set mppe_xxxx_key from MS-CHAPv2 credentials. (see RFC 3079)
|
||||
*
|
||||
* This helper function used in the Winbind module, which gets the
|
||||
* NTHashHash from the server.
|
||||
*/
|
||||
void
|
||||
mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
|
||||
u_char NTResponse[24], int IsServer)
|
||||
{
|
||||
SHA1_CTX sha1Context;
|
||||
u_char MasterKey[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */
|
||||
u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */
|
||||
|
||||
u_char SHApad1[40] =
|
||||
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
u_char SHApad2[40] =
|
||||
{ 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2,
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2,
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2,
|
||||
0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2, 0xf2 };
|
||||
|
||||
/* "This is the MPPE Master Key" */
|
||||
u_char Magic1[27] =
|
||||
{ 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74,
|
||||
0x68, 0x65, 0x20, 0x4d, 0x50, 0x50, 0x45, 0x20, 0x4d,
|
||||
0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x4b, 0x65, 0x79 };
|
||||
/* "On the client side, this is the send key; "
|
||||
"on the server side, it is the receive key." */
|
||||
u_char Magic2[84] =
|
||||
{ 0x4f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x20, 0x73, 0x69, 0x64, 0x65, 0x2c, 0x20,
|
||||
0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x73, 0x65, 0x6e, 0x64, 0x20, 0x6b, 0x65, 0x79,
|
||||
0x3b, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x73, 0x69, 0x64, 0x65,
|
||||
0x2c, 0x20, 0x69, 0x74, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x20,
|
||||
0x6b, 0x65, 0x79, 0x2e };
|
||||
/* "On the client side, this is the receive key; "
|
||||
"on the server side, it is the send key." */
|
||||
u_char Magic3[84] =
|
||||
{ 0x4f, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x63, 0x6c, 0x69,
|
||||
0x65, 0x6e, 0x74, 0x20, 0x73, 0x69, 0x64, 0x65, 0x2c, 0x20,
|
||||
0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x72, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x20,
|
||||
0x6b, 0x65, 0x79, 0x3b, 0x20, 0x6f, 0x6e, 0x20, 0x74, 0x68,
|
||||
0x65, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x73,
|
||||
0x69, 0x64, 0x65, 0x2c, 0x20, 0x69, 0x74, 0x20, 0x69, 0x73,
|
||||
0x20, 0x74, 0x68, 0x65, 0x20, 0x73, 0x65, 0x6e, 0x64, 0x20,
|
||||
0x6b, 0x65, 0x79, 0x2e };
|
||||
u_char *s;
|
||||
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, PasswordHashHash, MD4_SIGNATURE_SIZE);
|
||||
SHA1_Update(&sha1Context, NTResponse, 24);
|
||||
SHA1_Update(&sha1Context, Magic1, sizeof(Magic1));
|
||||
SHA1_Final(MasterKey, &sha1Context);
|
||||
|
||||
/*
|
||||
* generate send key
|
||||
*/
|
||||
if (IsServer)
|
||||
s = Magic3;
|
||||
else
|
||||
s = Magic2;
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, MasterKey, 16);
|
||||
SHA1_Update(&sha1Context, SHApad1, sizeof(SHApad1));
|
||||
SHA1_Update(&sha1Context, s, 84);
|
||||
SHA1_Update(&sha1Context, SHApad2, sizeof(SHApad2));
|
||||
SHA1_Final(Digest, &sha1Context);
|
||||
|
||||
BCOPY(Digest, mppe_send_key, sizeof(mppe_send_key));
|
||||
|
||||
/*
|
||||
* generate recv key
|
||||
*/
|
||||
if (IsServer)
|
||||
s = Magic2;
|
||||
else
|
||||
s = Magic3;
|
||||
SHA1_Init(&sha1Context);
|
||||
SHA1_Update(&sha1Context, MasterKey, 16);
|
||||
SHA1_Update(&sha1Context, SHApad1, sizeof(SHApad1));
|
||||
SHA1_Update(&sha1Context, s, 84);
|
||||
SHA1_Update(&sha1Context, SHApad2, sizeof(SHApad2));
|
||||
SHA1_Final(Digest, &sha1Context);
|
||||
|
||||
BCOPY(Digest, mppe_recv_key, sizeof(mppe_recv_key));
|
||||
|
||||
mppe_keys_set = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set mppe_xxxx_key from MS-CHAPv2 credentials. (see RFC 3079)
|
||||
*/
|
||||
static void
|
||||
SetMasterKeys(char *secret, int secret_len, u_char NTResponse[24], int IsServer)
|
||||
{
|
||||
u_char unicodePassword[MAX_NT_PASSWORD * 2];
|
||||
u_char PasswordHash[MD4_SIGNATURE_SIZE];
|
||||
u_char PasswordHashHash[MD4_SIGNATURE_SIZE];
|
||||
/* Hash (x2) the Unicode version of the secret (== password). */
|
||||
ascii2unicode(secret, secret_len, unicodePassword);
|
||||
NTPasswordHash(unicodePassword, secret_len * 2, PasswordHash);
|
||||
NTPasswordHash(PasswordHash, sizeof(PasswordHash), PasswordHashHash);
|
||||
mppe_set_keys2(PasswordHashHash, NTResponse, IsServer);
|
||||
}
|
||||
|
||||
#endif /* MPPE */
|
||||
|
||||
|
||||
void
|
||||
ChapMS(u_char *rchallenge, char *secret, int secret_len,
|
||||
MS_ChapResponse *response)
|
||||
{
|
||||
BZERO(response, sizeof(*response));
|
||||
|
||||
ChapMS_NT(rchallenge, secret, secret_len, response->NTResp);
|
||||
|
||||
#ifdef MSLANMAN
|
||||
ChapMS_LANMan(rchallenge, secret, secret_len, response);
|
||||
|
||||
/* preferred method is set by option */
|
||||
response->UseNT[0] = !ms_lanman;
|
||||
#else
|
||||
response->UseNT[0] = 1;
|
||||
#endif
|
||||
|
||||
#ifdef MPPE
|
||||
Set_Start_Key(rchallenge, secret, secret_len);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If PeerChallenge is NULL, one is generated and response->PeerChallenge
|
||||
* is filled in. Call this way when generating a response.
|
||||
* If PeerChallenge is supplied, it is copied into response->PeerChallenge.
|
||||
* Call this way when verifying a response (or debugging).
|
||||
* Do not call with PeerChallenge = response->PeerChallenge.
|
||||
*
|
||||
* response->PeerChallenge is then used for calculation of the
|
||||
* Authenticator Response.
|
||||
*/
|
||||
void
|
||||
ChapMS2(u_char *rchallenge, u_char *PeerChallenge,
|
||||
char *user, char *secret, int secret_len, MS_Chap2Response *response,
|
||||
u_char authResponse[], int authenticator)
|
||||
{
|
||||
/* ARGSUSED */
|
||||
u_char *p = response->PeerChallenge;
|
||||
int i;
|
||||
|
||||
BZERO(response, sizeof(*response));
|
||||
|
||||
/* Generate the Peer-Challenge if requested, or copy it if supplied. */
|
||||
if (!PeerChallenge)
|
||||
for (i = 0; i < sizeof(response->PeerChallenge); i++)
|
||||
*p++ = (u_char) (drand48() * 0xff);
|
||||
else
|
||||
BCOPY(PeerChallenge, response->PeerChallenge,
|
||||
sizeof(response->PeerChallenge));
|
||||
|
||||
/* Generate the NT-Response */
|
||||
ChapMS2_NT((char *)rchallenge, response->PeerChallenge, user,
|
||||
secret, secret_len, response->NTResp);
|
||||
|
||||
/* Generate the Authenticator Response. */
|
||||
GenerateAuthenticatorResponsePlain(secret, secret_len, response->NTResp,
|
||||
response->PeerChallenge, rchallenge,
|
||||
user, authResponse);
|
||||
|
||||
#ifdef MPPE
|
||||
SetMasterKeys(secret, secret_len, response->NTResp, authenticator);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef MPPE
|
||||
/*
|
||||
* Set MPPE options from plugins.
|
||||
*/
|
||||
void
|
||||
set_mppe_enc_types(int policy, int types)
|
||||
{
|
||||
/* Early exit for unknown policies. */
|
||||
if (policy != MPPE_ENC_POL_ENC_ALLOWED ||
|
||||
policy != MPPE_ENC_POL_ENC_REQUIRED)
|
||||
return;
|
||||
|
||||
/* Don't modify MPPE if it's optional and wasn't already configured. */
|
||||
if (policy == MPPE_ENC_POL_ENC_ALLOWED && !ccp_wantoptions[0].mppe)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Disable undesirable encryption types. Note that we don't ENABLE
|
||||
* any encryption types, to avoid overriding manual configuration.
|
||||
*/
|
||||
switch(types) {
|
||||
case MPPE_ENC_TYPES_RC4_40:
|
||||
ccp_wantoptions[0].mppe &= ~MPPE_OPT_128; /* disable 128-bit */
|
||||
break;
|
||||
case MPPE_ENC_TYPES_RC4_128:
|
||||
ccp_wantoptions[0].mppe &= ~MPPE_OPT_40; /* disable 40-bit */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif /* MPPE */
|
||||
|
||||
static struct chap_digest_type chapms_digest = {
|
||||
CHAP_MICROSOFT, /* code */
|
||||
chapms_generate_challenge,
|
||||
chapms_verify_response,
|
||||
chapms_make_response,
|
||||
NULL, /* check_success */
|
||||
chapms_handle_failure,
|
||||
};
|
||||
|
||||
static struct chap_digest_type chapms2_digest = {
|
||||
CHAP_MICROSOFT_V2, /* code */
|
||||
chapms2_generate_challenge,
|
||||
chapms2_verify_response,
|
||||
chapms2_make_response,
|
||||
chapms2_check_success,
|
||||
chapms_handle_failure,
|
||||
};
|
||||
|
||||
void
|
||||
chapms_init(void)
|
||||
{
|
||||
chap_register_digest(&chapms_digest);
|
||||
chap_register_digest(&chapms2_digest);
|
||||
add_options(chapms_option_list);
|
||||
}
|
||||
|
||||
#endif /* CHAPMS */
|
||||
122
vendor/aw/homlet/external/pppoe/pppd/chap_ms.h
vendored
Normal file
122
vendor/aw/homlet/external/pppoe/pppd/chap_ms.h
vendored
Normal file
@ -0,0 +1,122 @@
|
||||
/*
|
||||
* chap_ms.h - Challenge Handshake Authentication Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1995 Eric Rosenquist. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: chap_ms.h,v 1.12 2004/11/09 22:49:05 paulus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __CHAPMS_INCLUDE__
|
||||
|
||||
#define MD4_SIGNATURE_SIZE 16 /* 16 bytes in a MD4 message digest */
|
||||
#define MAX_NT_PASSWORD 256 /* Max (Unicode) chars in an NT pass */
|
||||
|
||||
#define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */
|
||||
#define MS_CHAP2_RESPONSE_LEN 49 /* Response length for MS-CHAPv2 */
|
||||
#define MS_AUTH_RESPONSE_LENGTH 40 /* MS-CHAPv2 authenticator response, */
|
||||
/* as ASCII */
|
||||
|
||||
/* E=eeeeeeeeee error codes for MS-CHAP failure messages. */
|
||||
#define MS_CHAP_ERROR_RESTRICTED_LOGON_HOURS 646
|
||||
#define MS_CHAP_ERROR_ACCT_DISABLED 647
|
||||
#define MS_CHAP_ERROR_PASSWD_EXPIRED 648
|
||||
#define MS_CHAP_ERROR_NO_DIALIN_PERMISSION 649
|
||||
#define MS_CHAP_ERROR_AUTHENTICATION_FAILURE 691
|
||||
#define MS_CHAP_ERROR_CHANGING_PASSWORD 709
|
||||
|
||||
/*
|
||||
* Apparently gcc on ARM gives all structures 4-byte alignment
|
||||
* by default. This tells gcc that these structures may be
|
||||
* unaligned and may not have extra padding inside them.
|
||||
*/
|
||||
#ifdef __GNUC__
|
||||
#define PACKED __attribute__((__packed__))
|
||||
#else
|
||||
#define PACKED
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use MS_CHAP_RESPONSE_LEN, rather than sizeof(MS_ChapResponse),
|
||||
* in case this struct gets padded.
|
||||
*/
|
||||
typedef struct {
|
||||
u_char LANManResp[24];
|
||||
u_char NTResp[24];
|
||||
u_char UseNT[1]; /* If 1, ignore the LANMan response field */
|
||||
} MS_ChapResponse PACKED;
|
||||
|
||||
/*
|
||||
* Use MS_CHAP2_RESPONSE_LEN, rather than sizeof(MS_Chap2Response),
|
||||
* in case this struct gets padded.
|
||||
*/
|
||||
typedef struct {
|
||||
u_char PeerChallenge[16];
|
||||
u_char Reserved[8]; /* Must be zero */
|
||||
u_char NTResp[24];
|
||||
u_char Flags[1]; /* Must be zero */
|
||||
} MS_Chap2Response PACKED;
|
||||
|
||||
#ifdef MPPE
|
||||
#include <net/ppp-comp.h> /* MPPE_MAX_KEY_LEN */
|
||||
extern u_char mppe_send_key[MPPE_MAX_KEY_LEN];
|
||||
extern u_char mppe_recv_key[MPPE_MAX_KEY_LEN];
|
||||
extern int mppe_keys_set;
|
||||
|
||||
/* These values are the RADIUS attribute values--see RFC 2548. */
|
||||
#define MPPE_ENC_POL_ENC_ALLOWED 1
|
||||
#define MPPE_ENC_POL_ENC_REQUIRED 2
|
||||
#define MPPE_ENC_TYPES_RC4_40 2
|
||||
#define MPPE_ENC_TYPES_RC4_128 4
|
||||
|
||||
/* used by plugins (using above values) */
|
||||
extern void set_mppe_enc_types(int, int);
|
||||
#endif
|
||||
|
||||
/* Are we the authenticator or authenticatee? For MS-CHAPv2 key derivation. */
|
||||
#define MS_CHAP2_AUTHENTICATEE 0
|
||||
#define MS_CHAP2_AUTHENTICATOR 1
|
||||
|
||||
void ChapMS __P((u_char *, char *, int, MS_ChapResponse *));
|
||||
void ChapMS2 __P((u_char *, u_char *, char *, char *, int,
|
||||
MS_Chap2Response *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int));
|
||||
#ifdef MPPE
|
||||
void mppe_set_keys __P((u_char *, u_char[MD4_SIGNATURE_SIZE]));
|
||||
void mppe_set_keys2(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
|
||||
u_char NTResponse[24], int IsServer);
|
||||
#endif
|
||||
|
||||
void ChallengeHash __P((u_char[16], u_char *, char *, u_char[8]));
|
||||
|
||||
void GenerateAuthenticatorResponse(u_char PasswordHashHash[MD4_SIGNATURE_SIZE],
|
||||
u_char NTResponse[24], u_char PeerChallenge[16],
|
||||
u_char *rchallenge, char *username,
|
||||
u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]);
|
||||
|
||||
void chapms_init(void);
|
||||
|
||||
#define __CHAPMS_INCLUDE__
|
||||
#endif /* __CHAPMS_INCLUDE__ */
|
||||
361
vendor/aw/homlet/external/pppoe/pppd/demand.c
vendored
Normal file
361
vendor/aw/homlet/external/pppoe/pppd/demand.c
vendored
Normal file
@ -0,0 +1,361 @@
|
||||
/*
|
||||
* demand.c - Support routines for demand-dialling.
|
||||
*
|
||||
* Copyright (c) 1996-2002 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: demand.c,v 1.19 2004/11/04 10:02:26 paulus Exp $"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#ifdef PPP_FILTER
|
||||
#include <pcap-bpf.h>
|
||||
#endif
|
||||
|
||||
#include "pppd.h"
|
||||
#include "fsm.h"
|
||||
#include "ipcp.h"
|
||||
#include "lcp.h"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
char *frame;
|
||||
int framelen;
|
||||
int framemax;
|
||||
int escape_flag;
|
||||
int flush_flag;
|
||||
int fcs;
|
||||
|
||||
struct packet {
|
||||
int length;
|
||||
struct packet *next;
|
||||
unsigned char data[1];
|
||||
};
|
||||
|
||||
struct packet *pend_q;
|
||||
struct packet *pend_qtail;
|
||||
|
||||
static int active_packet __P((unsigned char *, int));
|
||||
|
||||
/*
|
||||
* demand_conf - configure the interface for doing dial-on-demand.
|
||||
*/
|
||||
void
|
||||
demand_conf()
|
||||
{
|
||||
int i;
|
||||
struct protent *protp;
|
||||
|
||||
/* framemax = lcp_allowoptions[0].mru;
|
||||
if (framemax < PPP_MRU) */
|
||||
framemax = PPP_MRU;
|
||||
framemax += PPP_HDRLEN + PPP_FCSLEN;
|
||||
frame = malloc(framemax);
|
||||
if (frame == NULL)
|
||||
novm("demand frame");
|
||||
framelen = 0;
|
||||
pend_q = NULL;
|
||||
escape_flag = 0;
|
||||
flush_flag = 0;
|
||||
fcs = PPP_INITFCS;
|
||||
|
||||
netif_set_mtu(0, MIN(lcp_allowoptions[0].mru, PPP_MRU));
|
||||
if (ppp_send_config(0, PPP_MRU, (u_int32_t) 0, 0, 0) < 0
|
||||
|| ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0) < 0)
|
||||
fatal("Couldn't set up demand-dialled PPP interface: %m");
|
||||
|
||||
#ifdef PPP_FILTER
|
||||
set_filters(&pass_filter, &active_filter);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Call the demand_conf procedure for each protocol that's got one.
|
||||
*/
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
if (protp->enabled_flag && protp->demand_conf != NULL)
|
||||
if (!((*protp->demand_conf)(0)))
|
||||
die(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* demand_block - set each network protocol to block further packets.
|
||||
*/
|
||||
void
|
||||
demand_block()
|
||||
{
|
||||
int i;
|
||||
struct protent *protp;
|
||||
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
if (protp->enabled_flag && protp->demand_conf != NULL)
|
||||
sifnpmode(0, protp->protocol & ~0x8000, NPMODE_QUEUE);
|
||||
get_loop_output();
|
||||
}
|
||||
|
||||
/*
|
||||
* demand_discard - set each network protocol to discard packets
|
||||
* with an error.
|
||||
*/
|
||||
void
|
||||
demand_discard()
|
||||
{
|
||||
struct packet *pkt, *nextpkt;
|
||||
int i;
|
||||
struct protent *protp;
|
||||
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
if (protp->enabled_flag && protp->demand_conf != NULL)
|
||||
sifnpmode(0, protp->protocol & ~0x8000, NPMODE_ERROR);
|
||||
get_loop_output();
|
||||
|
||||
/* discard all saved packets */
|
||||
for (pkt = pend_q; pkt != NULL; pkt = nextpkt) {
|
||||
nextpkt = pkt->next;
|
||||
free(pkt);
|
||||
}
|
||||
pend_q = NULL;
|
||||
framelen = 0;
|
||||
flush_flag = 0;
|
||||
escape_flag = 0;
|
||||
fcs = PPP_INITFCS;
|
||||
}
|
||||
|
||||
/*
|
||||
* demand_unblock - set each enabled network protocol to pass packets.
|
||||
*/
|
||||
void
|
||||
demand_unblock()
|
||||
{
|
||||
int i;
|
||||
struct protent *protp;
|
||||
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
if (protp->enabled_flag && protp->demand_conf != NULL)
|
||||
sifnpmode(0, protp->protocol & ~0x8000, NPMODE_PASS);
|
||||
}
|
||||
|
||||
/*
|
||||
* FCS lookup table as calculated by genfcstab.
|
||||
*/
|
||||
static u_short fcstab[256] = {
|
||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
|
||||
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
|
||||
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
|
||||
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
|
||||
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
|
||||
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
|
||||
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
|
||||
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
|
||||
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
|
||||
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
|
||||
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
|
||||
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
|
||||
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
|
||||
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
|
||||
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
|
||||
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
|
||||
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
|
||||
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
|
||||
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
|
||||
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
|
||||
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
|
||||
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
|
||||
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
|
||||
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
|
||||
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
|
||||
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
|
||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||
};
|
||||
|
||||
/*
|
||||
* loop_chars - process characters received from the loopback.
|
||||
* Calls loop_frame when a complete frame has been accumulated.
|
||||
* Return value is 1 if we need to bring up the link, 0 otherwise.
|
||||
*/
|
||||
int
|
||||
loop_chars(p, n)
|
||||
unsigned char *p;
|
||||
int n;
|
||||
{
|
||||
int c, rv;
|
||||
|
||||
rv = 0;
|
||||
for (; n > 0; --n) {
|
||||
c = *p++;
|
||||
if (c == PPP_FLAG) {
|
||||
if (!escape_flag && !flush_flag
|
||||
&& framelen > 2 && fcs == PPP_GOODFCS) {
|
||||
framelen -= 2;
|
||||
if (loop_frame((unsigned char *)frame, framelen))
|
||||
rv = 1;
|
||||
}
|
||||
framelen = 0;
|
||||
flush_flag = 0;
|
||||
escape_flag = 0;
|
||||
fcs = PPP_INITFCS;
|
||||
continue;
|
||||
}
|
||||
if (flush_flag)
|
||||
continue;
|
||||
if (escape_flag) {
|
||||
c ^= PPP_TRANS;
|
||||
escape_flag = 0;
|
||||
} else if (c == PPP_ESCAPE) {
|
||||
escape_flag = 1;
|
||||
continue;
|
||||
}
|
||||
if (framelen >= framemax) {
|
||||
flush_flag = 1;
|
||||
continue;
|
||||
}
|
||||
frame[framelen++] = c;
|
||||
fcs = PPP_FCS(fcs, c);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*
|
||||
* loop_frame - given a frame obtained from the loopback,
|
||||
* decide whether to bring up the link or not, and, if we want
|
||||
* to transmit this frame later, put it on the pending queue.
|
||||
* Return value is 1 if we need to bring up the link, 0 otherwise.
|
||||
* We assume that the kernel driver has already applied the
|
||||
* pass_filter, so we won't get packets it rejected.
|
||||
* We apply the active_filter to see if we want this packet to
|
||||
* bring up the link.
|
||||
*/
|
||||
int
|
||||
loop_frame(frame, len)
|
||||
unsigned char *frame;
|
||||
int len;
|
||||
{
|
||||
struct packet *pkt;
|
||||
|
||||
/* dbglog("from loop: %P", frame, len); */
|
||||
if (len < PPP_HDRLEN)
|
||||
return 0;
|
||||
if ((PPP_PROTOCOL(frame) & 0x8000) != 0)
|
||||
return 0; /* shouldn't get any of these anyway */
|
||||
if (!active_packet(frame, len))
|
||||
return 0;
|
||||
|
||||
pkt = (struct packet *) malloc(sizeof(struct packet) + len);
|
||||
if (pkt != NULL) {
|
||||
pkt->length = len;
|
||||
pkt->next = NULL;
|
||||
memcpy(pkt->data, frame, len);
|
||||
if (pend_q == NULL)
|
||||
pend_q = pkt;
|
||||
else
|
||||
pend_qtail->next = pkt;
|
||||
pend_qtail = pkt;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* demand_rexmit - Resend all those frames which we got via the
|
||||
* loopback, now that the real serial link is up.
|
||||
*/
|
||||
void
|
||||
demand_rexmit(proto)
|
||||
int proto;
|
||||
{
|
||||
struct packet *pkt, *prev, *nextpkt;
|
||||
|
||||
prev = NULL;
|
||||
pkt = pend_q;
|
||||
pend_q = NULL;
|
||||
for (; pkt != NULL; pkt = nextpkt) {
|
||||
nextpkt = pkt->next;
|
||||
if (PPP_PROTOCOL(pkt->data) == proto) {
|
||||
output(0, pkt->data, pkt->length);
|
||||
free(pkt);
|
||||
} else {
|
||||
if (prev == NULL)
|
||||
pend_q = pkt;
|
||||
else
|
||||
prev->next = pkt;
|
||||
prev = pkt;
|
||||
}
|
||||
}
|
||||
pend_qtail = prev;
|
||||
if (prev != NULL)
|
||||
prev->next = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan a packet to decide whether it is an "active" packet,
|
||||
* that is, whether it is worth bringing up the link for.
|
||||
*/
|
||||
static int
|
||||
active_packet(p, len)
|
||||
unsigned char *p;
|
||||
int len;
|
||||
{
|
||||
int proto, i;
|
||||
struct protent *protp;
|
||||
|
||||
if (len < PPP_HDRLEN)
|
||||
return 0;
|
||||
proto = PPP_PROTOCOL(p);
|
||||
#ifdef PPP_FILTER
|
||||
if (pass_filter.bf_len != 0
|
||||
&& bpf_filter(pass_filter.bf_insns, p, len, len) == 0)
|
||||
return 0;
|
||||
if (active_filter.bf_len != 0
|
||||
&& bpf_filter(active_filter.bf_insns, p, len, len) == 0)
|
||||
return 0;
|
||||
#endif
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
|
||||
if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) {
|
||||
if (!protp->enabled_flag)
|
||||
return 0;
|
||||
if (protp->active_pkt == NULL)
|
||||
return 1;
|
||||
return (*protp->active_pkt)(p, len);
|
||||
}
|
||||
}
|
||||
return 0; /* not a supported protocol !!?? */
|
||||
}
|
||||
2428
vendor/aw/homlet/external/pppoe/pppd/eap.c
vendored
Normal file
2428
vendor/aw/homlet/external/pppoe/pppd/eap.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
158
vendor/aw/homlet/external/pppoe/pppd/eap.h
vendored
Normal file
158
vendor/aw/homlet/external/pppoe/pppd/eap.h
vendored
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* eap.h - Extensible Authentication Protocol for PPP (RFC 2284)
|
||||
*
|
||||
* Copyright (c) 2001 by Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Non-exclusive rights to redistribute, modify, translate, and use
|
||||
* this software in source and binary forms, in whole or in part, is
|
||||
* hereby granted, provided that the above copyright notice is
|
||||
* duplicated in any source form, and that neither the name of the
|
||||
* copyright holder nor the author is used to endorse or promote
|
||||
* products derived from this software.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Original version by James Carlson
|
||||
*
|
||||
* $Id: eap.h,v 1.2 2003/06/11 23:56:26 paulus Exp $
|
||||
*/
|
||||
|
||||
#ifndef PPP_EAP_H
|
||||
#define PPP_EAP_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define EAP_HEADERLEN 4
|
||||
|
||||
|
||||
/* EAP message codes. */
|
||||
#define EAP_REQUEST 1
|
||||
#define EAP_RESPONSE 2
|
||||
#define EAP_SUCCESS 3
|
||||
#define EAP_FAILURE 4
|
||||
|
||||
/* EAP types */
|
||||
#define EAPT_IDENTITY 1
|
||||
#define EAPT_NOTIFICATION 2
|
||||
#define EAPT_NAK 3 /* (response only) */
|
||||
#define EAPT_MD5CHAP 4
|
||||
#define EAPT_OTP 5 /* One-Time Password; RFC 1938 */
|
||||
#define EAPT_TOKEN 6 /* Generic Token Card */
|
||||
/* 7 and 8 are unassigned. */
|
||||
#define EAPT_RSA 9 /* RSA Public Key Authentication */
|
||||
#define EAPT_DSS 10 /* DSS Unilateral */
|
||||
#define EAPT_KEA 11 /* KEA */
|
||||
#define EAPT_KEA_VALIDATE 12 /* KEA-VALIDATE */
|
||||
#define EAPT_TLS 13 /* EAP-TLS */
|
||||
#define EAPT_DEFENDER 14 /* Defender Token (AXENT) */
|
||||
#define EAPT_W2K 15 /* Windows 2000 EAP */
|
||||
#define EAPT_ARCOT 16 /* Arcot Systems */
|
||||
#define EAPT_CISCOWIRELESS 17 /* Cisco Wireless */
|
||||
#define EAPT_NOKIACARD 18 /* Nokia IP smart card */
|
||||
#define EAPT_SRP 19 /* Secure Remote Password */
|
||||
/* 20 is deprecated */
|
||||
|
||||
/* EAP SRP-SHA1 Subtypes */
|
||||
#define EAPSRP_CHALLENGE 1 /* Request 1 - Challenge */
|
||||
#define EAPSRP_CKEY 1 /* Response 1 - Client Key */
|
||||
#define EAPSRP_SKEY 2 /* Request 2 - Server Key */
|
||||
#define EAPSRP_CVALIDATOR 2 /* Response 2 - Client Validator */
|
||||
#define EAPSRP_SVALIDATOR 3 /* Request 3 - Server Validator */
|
||||
#define EAPSRP_ACK 3 /* Response 3 - final ack */
|
||||
#define EAPSRP_LWRECHALLENGE 4 /* Req/resp 4 - Lightweight rechal */
|
||||
|
||||
#define SRPVAL_EBIT 0x00000001 /* Use shared key for ECP */
|
||||
|
||||
#define SRP_PSEUDO_ID "pseudo_"
|
||||
#define SRP_PSEUDO_LEN 7
|
||||
|
||||
#define MD5_SIGNATURE_SIZE 16
|
||||
#define MIN_CHALLENGE_LENGTH 16
|
||||
#define MAX_CHALLENGE_LENGTH 24
|
||||
|
||||
enum eap_state_code {
|
||||
eapInitial = 0, /* No EAP authentication yet requested */
|
||||
eapPending, /* Waiting for LCP (no timer) */
|
||||
eapClosed, /* Authentication not in use */
|
||||
eapListen, /* Client ready (and timer running) */
|
||||
eapIdentify, /* EAP Identify sent */
|
||||
eapSRP1, /* Sent EAP SRP-SHA1 Subtype 1 */
|
||||
eapSRP2, /* Sent EAP SRP-SHA1 Subtype 2 */
|
||||
eapSRP3, /* Sent EAP SRP-SHA1 Subtype 3 */
|
||||
eapMD5Chall, /* Sent MD5-Challenge */
|
||||
eapOpen, /* Completed authentication */
|
||||
eapSRP4, /* Sent EAP SRP-SHA1 Subtype 4 */
|
||||
eapBadAuth /* Failed authentication */
|
||||
};
|
||||
|
||||
#define EAP_STATES \
|
||||
"Initial", "Pending", "Closed", "Listen", "Identify", \
|
||||
"SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth"
|
||||
|
||||
#define eap_client_active(esp) ((esp)->es_client.ea_state == eapListen)
|
||||
#define eap_server_active(esp) \
|
||||
((esp)->es_server.ea_state >= eapIdentify && \
|
||||
(esp)->es_server.ea_state <= eapMD5Chall)
|
||||
|
||||
struct eap_auth {
|
||||
char *ea_name; /* Our name */
|
||||
char *ea_peer; /* Peer's name */
|
||||
void *ea_session; /* Authentication library linkage */
|
||||
u_char *ea_skey; /* Shared encryption key */
|
||||
int ea_timeout; /* Time to wait (for retransmit/fail) */
|
||||
int ea_maxrequests; /* Max Requests allowed */
|
||||
u_short ea_namelen; /* Length of our name */
|
||||
u_short ea_peerlen; /* Length of peer's name */
|
||||
enum eap_state_code ea_state;
|
||||
u_char ea_id; /* Current id */
|
||||
u_char ea_requests; /* Number of Requests sent/received */
|
||||
u_char ea_responses; /* Number of Responses */
|
||||
u_char ea_type; /* One of EAPT_* */
|
||||
u_int32_t ea_keyflags; /* SRP shared key usage flags */
|
||||
};
|
||||
|
||||
/*
|
||||
* Complete EAP state for one PPP session.
|
||||
*/
|
||||
typedef struct eap_state {
|
||||
int es_unit; /* Interface unit number */
|
||||
struct eap_auth es_client; /* Client (authenticatee) data */
|
||||
struct eap_auth es_server; /* Server (authenticator) data */
|
||||
int es_savedtime; /* Saved timeout */
|
||||
int es_rechallenge; /* EAP rechallenge interval */
|
||||
int es_lwrechallenge; /* SRP lightweight rechallenge inter */
|
||||
bool es_usepseudo; /* Use SRP Pseudonym if offered one */
|
||||
int es_usedpseudo; /* Set if we already sent PN */
|
||||
int es_challen; /* Length of challenge string */
|
||||
u_char es_challenge[MAX_CHALLENGE_LENGTH];
|
||||
} eap_state;
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#define EAP_DEFTIMEOUT 3 /* Timeout (seconds) for rexmit */
|
||||
#define EAP_DEFTRANSMITS 10 /* max # times to transmit */
|
||||
#define EAP_DEFREQTIME 20 /* Time to wait for peer request */
|
||||
#define EAP_DEFALLOWREQ 20 /* max # times to accept requests */
|
||||
|
||||
extern eap_state eap_states[];
|
||||
|
||||
void eap_authwithpeer __P((int unit, char *localname));
|
||||
void eap_authpeer __P((int unit, char *localname));
|
||||
|
||||
extern struct protent eap_protent;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PPP_EAP_H */
|
||||
|
||||
173
vendor/aw/homlet/external/pppoe/pppd/ecp.c
vendored
Normal file
173
vendor/aw/homlet/external/pppoe/pppd/ecp.c
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* ecp.c - PPP Encryption Control Protocol.
|
||||
*
|
||||
* Copyright (c) 2002 The Android Open Source Project
|
||||
* 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Derived from ccp.c, which is:
|
||||
*
|
||||
* Copyright (c) 1994-2002 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 3. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: ecp.c,v 1.4 2004/11/04 10:02:26 paulus Exp $"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "pppd.h"
|
||||
#include "fsm.h"
|
||||
#include "ecp.h"
|
||||
|
||||
static option_t ecp_option_list[] = {
|
||||
{ "noecp", o_bool, &ecp_protent.enabled_flag,
|
||||
"Disable ECP negotiation" },
|
||||
{ "-ecp", o_bool, &ecp_protent.enabled_flag,
|
||||
"Disable ECP negotiation", OPT_ALIAS },
|
||||
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
* Protocol entry points from main code.
|
||||
*/
|
||||
static void ecp_init __P((int unit));
|
||||
/*
|
||||
static void ecp_open __P((int unit));
|
||||
static void ecp_close __P((int unit, char *));
|
||||
static void ecp_lowerup __P((int unit));
|
||||
static void ecp_lowerdown __P((int));
|
||||
static void ecp_input __P((int unit, u_char *pkt, int len));
|
||||
static void ecp_protrej __P((int unit));
|
||||
*/
|
||||
static int ecp_printpkt __P((u_char *pkt, int len,
|
||||
void (*printer) __P((void *, char *, ...)),
|
||||
void *arg));
|
||||
/*
|
||||
static void ecp_datainput __P((int unit, u_char *pkt, int len));
|
||||
*/
|
||||
|
||||
struct protent ecp_protent = {
|
||||
PPP_ECP,
|
||||
ecp_init,
|
||||
NULL, /* ecp_input, */
|
||||
NULL, /* ecp_protrej, */
|
||||
NULL, /* ecp_lowerup, */
|
||||
NULL, /* ecp_lowerdown, */
|
||||
NULL, /* ecp_open, */
|
||||
NULL, /* ecp_close, */
|
||||
ecp_printpkt,
|
||||
NULL, /* ecp_datainput, */
|
||||
0,
|
||||
"ECP",
|
||||
"Encrypted",
|
||||
ecp_option_list,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
fsm ecp_fsm[NUM_PPP];
|
||||
ecp_options ecp_wantoptions[NUM_PPP]; /* what to request the peer to use */
|
||||
ecp_options ecp_gotoptions[NUM_PPP]; /* what the peer agreed to do */
|
||||
ecp_options ecp_allowoptions[NUM_PPP]; /* what we'll agree to do */
|
||||
ecp_options ecp_hisoptions[NUM_PPP]; /* what we agreed to do */
|
||||
|
||||
static fsm_callbacks ecp_callbacks = {
|
||||
NULL, /* ecp_resetci, */
|
||||
NULL, /* ecp_cilen, */
|
||||
NULL, /* ecp_addci, */
|
||||
NULL, /* ecp_ackci, */
|
||||
NULL, /* ecp_nakci, */
|
||||
NULL, /* ecp_rejci, */
|
||||
NULL, /* ecp_reqci, */
|
||||
NULL, /* ecp_up, */
|
||||
NULL, /* ecp_down, */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL, /* ecp_extcode, */
|
||||
"ECP"
|
||||
};
|
||||
|
||||
/*
|
||||
* ecp_init - initialize ECP.
|
||||
*/
|
||||
static void
|
||||
ecp_init(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm *f = &ecp_fsm[unit];
|
||||
|
||||
f->unit = unit;
|
||||
f->protocol = PPP_ECP;
|
||||
f->callbacks = &ecp_callbacks;
|
||||
fsm_init(f);
|
||||
|
||||
memset(&ecp_wantoptions[unit], 0, sizeof(ecp_options));
|
||||
memset(&ecp_gotoptions[unit], 0, sizeof(ecp_options));
|
||||
memset(&ecp_allowoptions[unit], 0, sizeof(ecp_options));
|
||||
memset(&ecp_hisoptions[unit], 0, sizeof(ecp_options));
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
ecp_printpkt(p, plen, printer, arg)
|
||||
u_char *p;
|
||||
int plen;
|
||||
void (*printer) __P((void *, char *, ...));
|
||||
void *arg;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
45
vendor/aw/homlet/external/pppoe/pppd/ecp.h
vendored
Normal file
45
vendor/aw/homlet/external/pppoe/pppd/ecp.h
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* ecp.h - Definitions for PPP Encryption Control Protocol.
|
||||
*
|
||||
* Copyright (c) 2002 The Android Open Source Project
|
||||
* 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ecp.h,v 1.2 2003/01/10 07:12:36 fcusack Exp $
|
||||
*/
|
||||
|
||||
typedef struct ecp_options {
|
||||
bool required; /* Is ECP required? */
|
||||
unsigned enctype; /* Encryption type */
|
||||
} ecp_options;
|
||||
|
||||
extern fsm ecp_fsm[];
|
||||
extern ecp_options ecp_wantoptions[];
|
||||
extern ecp_options ecp_gotoptions[];
|
||||
extern ecp_options ecp_allowoptions[];
|
||||
extern ecp_options ecp_hisoptions[];
|
||||
|
||||
extern struct protent ecp_protent;
|
||||
57
vendor/aw/homlet/external/pppoe/pppd/eui64.c
vendored
Normal file
57
vendor/aw/homlet/external/pppoe/pppd/eui64.c
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* eui64.c - EUI64 routines for IPv6CP.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: eui64.c,v 1.6 2002/12/04 23:03:32 paulus Exp $"
|
||||
|
||||
#include "pppd.h"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
/*
|
||||
* eui64_ntoa - Make an ascii representation of an interface identifier
|
||||
*/
|
||||
char *
|
||||
eui64_ntoa(e)
|
||||
eui64_t e;
|
||||
{
|
||||
static char buf[32];
|
||||
|
||||
snprintf(buf, 32, "%02x%02x:%02x%02x:%02x%02x:%02x%02x",
|
||||
e.e8[0], e.e8[1], e.e8[2], e.e8[3],
|
||||
e.e8[4], e.e8[5], e.e8[6], e.e8[7]);
|
||||
return buf;
|
||||
}
|
||||
114
vendor/aw/homlet/external/pppoe/pppd/eui64.h
vendored
Normal file
114
vendor/aw/homlet/external/pppoe/pppd/eui64.h
vendored
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* eui64.h - EUI64 routines for IPv6CP.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: eui64.h,v 1.6 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
#ifndef __EUI64_H__
|
||||
#define __EUI64_H__
|
||||
|
||||
#if !defined(INET6)
|
||||
#error "this file should only be included when INET6 is defined"
|
||||
#endif /* not defined(INET6) */
|
||||
|
||||
#if defined(SOL2)
|
||||
#include <netinet/in.h>
|
||||
|
||||
typedef union {
|
||||
uint8_t e8[8]; /* lower 64-bit IPv6 address */
|
||||
uint32_t e32[2]; /* lower 64-bit IPv6 address */
|
||||
} eui64_t;
|
||||
|
||||
/*
|
||||
* Declare the two below, since in.h only defines them when _KERNEL
|
||||
* is declared - which shouldn't be true when dealing with user-land programs
|
||||
*/
|
||||
#define s6_addr8 _S6_un._S6_u8
|
||||
#define s6_addr32 _S6_un._S6_u32
|
||||
|
||||
#else /* else if not defined(SOL2) */
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
*
|
||||
* Maybe this should be done by processing struct in6_addr directly...
|
||||
*/
|
||||
typedef union
|
||||
{
|
||||
u_int8_t e8[8];
|
||||
u_int16_t e16[4];
|
||||
u_int32_t e32[2];
|
||||
} eui64_t;
|
||||
|
||||
#endif /* defined(SOL2) */
|
||||
|
||||
#define eui64_iszero(e) (((e).e32[0] | (e).e32[1]) == 0)
|
||||
#define eui64_equals(e, o) (((e).e32[0] == (o).e32[0]) && \
|
||||
((e).e32[1] == (o).e32[1]))
|
||||
#define eui64_zero(e) (e).e32[0] = (e).e32[1] = 0;
|
||||
|
||||
#define eui64_copy(s, d) memcpy(&(d), &(s), sizeof(eui64_t))
|
||||
|
||||
#define eui64_magic(e) do { \
|
||||
(e).e32[0] = magic(); \
|
||||
(e).e32[1] = magic(); \
|
||||
(e).e8[0] &= ~2; \
|
||||
} while (0)
|
||||
#define eui64_magic_nz(x) do { \
|
||||
eui64_magic(x); \
|
||||
} while (eui64_iszero(x))
|
||||
#define eui64_magic_ne(x, y) do { \
|
||||
eui64_magic(x); \
|
||||
} while (eui64_equals(x, y))
|
||||
|
||||
#define eui64_get(ll, cp) do { \
|
||||
eui64_copy((*cp), (ll)); \
|
||||
(cp) += sizeof(eui64_t); \
|
||||
} while (0)
|
||||
|
||||
#define eui64_put(ll, cp) do { \
|
||||
eui64_copy((ll), (*cp)); \
|
||||
(cp) += sizeof(eui64_t); \
|
||||
} while (0)
|
||||
|
||||
#define eui64_set32(e, l) do { \
|
||||
(e).e32[0] = 0; \
|
||||
(e).e32[1] = htonl(l); \
|
||||
} while (0)
|
||||
#define eui64_setlo32(e, l) eui64_set32(e, l)
|
||||
|
||||
char *eui64_ntoa __P((eui64_t)); /* Returns ascii representation of id */
|
||||
|
||||
#endif /* __EUI64_H__ */
|
||||
|
||||
819
vendor/aw/homlet/external/pppoe/pppd/fsm.c
vendored
Normal file
819
vendor/aw/homlet/external/pppoe/pppd/fsm.c
vendored
Normal file
@ -0,0 +1,819 @@
|
||||
/*
|
||||
* fsm.c - {Link, IP} Control Protocol Finite State Machine.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: fsm.c,v 1.23 2004/11/13 02:28:15 paulus Exp $"
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Randomize fsm id on link/init.
|
||||
* Deal with variable outgoing MTU.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "pppd.h"
|
||||
#include "fsm.h"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
static void fsm_timeout __P((void *));
|
||||
static void fsm_rconfreq __P((fsm *, int, u_char *, int));
|
||||
static void fsm_rconfack __P((fsm *, int, u_char *, int));
|
||||
static void fsm_rconfnakrej __P((fsm *, int, int, u_char *, int));
|
||||
static void fsm_rtermreq __P((fsm *, int, u_char *, int));
|
||||
static void fsm_rtermack __P((fsm *));
|
||||
static void fsm_rcoderej __P((fsm *, u_char *, int));
|
||||
static void fsm_sconfreq __P((fsm *, int));
|
||||
|
||||
#define PROTO_NAME(f) ((f)->callbacks->proto_name)
|
||||
|
||||
int peer_mru[NUM_PPP];
|
||||
|
||||
|
||||
/*
|
||||
* fsm_init - Initialize fsm.
|
||||
*
|
||||
* Initialize fsm state.
|
||||
*/
|
||||
void
|
||||
fsm_init(f)
|
||||
fsm *f;
|
||||
{
|
||||
f->state = INITIAL;
|
||||
f->flags = 0;
|
||||
f->id = 0; /* XXX Start with random id? */
|
||||
f->timeouttime = DEFTIMEOUT;
|
||||
f->maxconfreqtransmits = DEFMAXCONFREQS;
|
||||
f->maxtermtransmits = DEFMAXTERMREQS;
|
||||
f->maxnakloops = DEFMAXNAKLOOPS;
|
||||
f->term_reason_len = 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_lowerup - The lower layer is up.
|
||||
*/
|
||||
void
|
||||
fsm_lowerup(f)
|
||||
fsm *f;
|
||||
{
|
||||
switch( f->state ){
|
||||
case INITIAL:
|
||||
f->state = CLOSED;
|
||||
break;
|
||||
|
||||
case STARTING:
|
||||
if( f->flags & OPT_SILENT )
|
||||
f->state = STOPPED;
|
||||
else {
|
||||
/* Send an initial configure-request */
|
||||
fsm_sconfreq(f, 0);
|
||||
f->state = REQSENT;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FSMDEBUG(("%s: Up event in state %d!", PROTO_NAME(f), f->state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_lowerdown - The lower layer is down.
|
||||
*
|
||||
* Cancel all timeouts and inform upper layers.
|
||||
*/
|
||||
void
|
||||
fsm_lowerdown(f)
|
||||
fsm *f;
|
||||
{
|
||||
switch( f->state ){
|
||||
case CLOSED:
|
||||
f->state = INITIAL;
|
||||
break;
|
||||
|
||||
case STOPPED:
|
||||
if (!persist) {
|
||||
f->state = STARTING;
|
||||
if( f->callbacks->starting )
|
||||
(*f->callbacks->starting)(f);
|
||||
}
|
||||
break;
|
||||
|
||||
case CLOSING:
|
||||
f->state = INITIAL;
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
break;
|
||||
|
||||
case STOPPING:
|
||||
case REQSENT:
|
||||
case ACKRCVD:
|
||||
case ACKSENT:
|
||||
f->state = STARTING;
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
break;
|
||||
|
||||
case OPENED:
|
||||
if( f->callbacks->down )
|
||||
(*f->callbacks->down)(f);
|
||||
f->state = STARTING;
|
||||
break;
|
||||
|
||||
default:
|
||||
FSMDEBUG(("%s: Down event in state %d!", PROTO_NAME(f), f->state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_open - Link is allowed to come up.
|
||||
*/
|
||||
void
|
||||
fsm_open(f)
|
||||
fsm *f;
|
||||
{
|
||||
switch( f->state ){
|
||||
case INITIAL:
|
||||
f->state = STARTING;
|
||||
if( f->callbacks->starting )
|
||||
(*f->callbacks->starting)(f);
|
||||
break;
|
||||
|
||||
case CLOSED:
|
||||
if( f->flags & OPT_SILENT )
|
||||
f->state = STOPPED;
|
||||
else {
|
||||
/* Send an initial configure-request */
|
||||
fsm_sconfreq(f, 0);
|
||||
f->state = REQSENT;
|
||||
}
|
||||
break;
|
||||
|
||||
case CLOSING:
|
||||
f->state = STOPPING;
|
||||
/* fall through */
|
||||
case STOPPED:
|
||||
case OPENED:
|
||||
if( f->flags & OPT_RESTART ){
|
||||
fsm_lowerdown(f);
|
||||
fsm_lowerup(f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* terminate_layer - Start process of shutting down the FSM
|
||||
*
|
||||
* Cancel any timeout running, notify upper layers we're done, and
|
||||
* send a terminate-request message as configured.
|
||||
*/
|
||||
static void
|
||||
terminate_layer(f, nextstate)
|
||||
fsm *f;
|
||||
int nextstate;
|
||||
{
|
||||
if( f->state != OPENED )
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
else if( f->callbacks->down )
|
||||
(*f->callbacks->down)(f); /* Inform upper layers we're down */
|
||||
|
||||
/* Init restart counter and send Terminate-Request */
|
||||
f->retransmits = f->maxtermtransmits;
|
||||
fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
|
||||
(u_char *) f->term_reason, f->term_reason_len);
|
||||
|
||||
if (f->retransmits == 0) {
|
||||
/*
|
||||
* User asked for no terminate requests at all; just close it.
|
||||
* We've already fired off one Terminate-Request just to be nice
|
||||
* to the peer, but we're not going to wait for a reply.
|
||||
*/
|
||||
f->state = nextstate == CLOSING ? CLOSED : STOPPED;
|
||||
if( f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
return;
|
||||
}
|
||||
|
||||
TIMEOUT(fsm_timeout, f, f->timeouttime);
|
||||
--f->retransmits;
|
||||
|
||||
f->state = nextstate;
|
||||
}
|
||||
|
||||
/*
|
||||
* fsm_close - Start closing connection.
|
||||
*
|
||||
* Cancel timeouts and either initiate close or possibly go directly to
|
||||
* the CLOSED state.
|
||||
*/
|
||||
void
|
||||
fsm_close(f, reason)
|
||||
fsm *f;
|
||||
char *reason;
|
||||
{
|
||||
f->term_reason = reason;
|
||||
f->term_reason_len = (reason == NULL? 0: strlen(reason));
|
||||
switch( f->state ){
|
||||
case STARTING:
|
||||
f->state = INITIAL;
|
||||
break;
|
||||
case STOPPED:
|
||||
f->state = CLOSED;
|
||||
break;
|
||||
case STOPPING:
|
||||
f->state = CLOSING;
|
||||
break;
|
||||
|
||||
case REQSENT:
|
||||
case ACKRCVD:
|
||||
case ACKSENT:
|
||||
case OPENED:
|
||||
terminate_layer(f, CLOSING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_timeout - Timeout expired.
|
||||
*/
|
||||
static void
|
||||
fsm_timeout(arg)
|
||||
void *arg;
|
||||
{
|
||||
fsm *f = (fsm *) arg;
|
||||
|
||||
switch (f->state) {
|
||||
case CLOSING:
|
||||
case STOPPING:
|
||||
if( f->retransmits <= 0 ){
|
||||
/*
|
||||
* We've waited for an ack long enough. Peer probably heard us.
|
||||
*/
|
||||
f->state = (f->state == CLOSING)? CLOSED: STOPPED;
|
||||
if( f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
} else {
|
||||
/* Send Terminate-Request */
|
||||
fsm_sdata(f, TERMREQ, f->reqid = ++f->id,
|
||||
(u_char *) f->term_reason, f->term_reason_len);
|
||||
TIMEOUT(fsm_timeout, f, f->timeouttime);
|
||||
--f->retransmits;
|
||||
}
|
||||
break;
|
||||
|
||||
case REQSENT:
|
||||
case ACKRCVD:
|
||||
case ACKSENT:
|
||||
if (f->retransmits <= 0) {
|
||||
warn("%s: timeout sending Config-Requests\n", PROTO_NAME(f));
|
||||
f->state = STOPPED;
|
||||
if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
|
||||
} else {
|
||||
/* Retransmit the configure-request */
|
||||
if (f->callbacks->retransmit)
|
||||
(*f->callbacks->retransmit)(f);
|
||||
fsm_sconfreq(f, 1); /* Re-send Configure-Request */
|
||||
if( f->state == ACKRCVD )
|
||||
f->state = REQSENT;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
FSMDEBUG(("%s: Timeout event in state %d!", PROTO_NAME(f), f->state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_input - Input packet.
|
||||
*/
|
||||
void
|
||||
fsm_input(f, inpacket, l)
|
||||
fsm *f;
|
||||
u_char *inpacket;
|
||||
int l;
|
||||
{
|
||||
u_char *inp;
|
||||
u_char code, id;
|
||||
int len;
|
||||
|
||||
/*
|
||||
* Parse header (code, id and length).
|
||||
* If packet too short, drop it.
|
||||
*/
|
||||
inp = inpacket;
|
||||
if (l < HEADERLEN) {
|
||||
FSMDEBUG(("fsm_input(%x): Rcvd short header.", f->protocol));
|
||||
return;
|
||||
}
|
||||
GETCHAR(code, inp);
|
||||
GETCHAR(id, inp);
|
||||
GETSHORT(len, inp);
|
||||
if (len < HEADERLEN) {
|
||||
FSMDEBUG(("fsm_input(%x): Rcvd illegal length.", f->protocol));
|
||||
return;
|
||||
}
|
||||
if (len > l) {
|
||||
FSMDEBUG(("fsm_input(%x): Rcvd short packet.", f->protocol));
|
||||
return;
|
||||
}
|
||||
len -= HEADERLEN; /* subtract header length */
|
||||
|
||||
if( f->state == INITIAL || f->state == STARTING ){
|
||||
FSMDEBUG(("fsm_input(%x): Rcvd packet in state %d.",
|
||||
f->protocol, f->state));
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Action depends on code.
|
||||
*/
|
||||
switch (code) {
|
||||
case CONFREQ:
|
||||
fsm_rconfreq(f, id, inp, len);
|
||||
break;
|
||||
|
||||
case CONFACK:
|
||||
fsm_rconfack(f, id, inp, len);
|
||||
break;
|
||||
|
||||
case CONFNAK:
|
||||
case CONFREJ:
|
||||
fsm_rconfnakrej(f, code, id, inp, len);
|
||||
break;
|
||||
|
||||
case TERMREQ:
|
||||
fsm_rtermreq(f, id, inp, len);
|
||||
break;
|
||||
|
||||
case TERMACK:
|
||||
fsm_rtermack(f);
|
||||
break;
|
||||
|
||||
case CODEREJ:
|
||||
fsm_rcoderej(f, inp, len);
|
||||
break;
|
||||
|
||||
default:
|
||||
if( !f->callbacks->extcode
|
||||
|| !(*f->callbacks->extcode)(f, code, id, inp, len) )
|
||||
fsm_sdata(f, CODEREJ, ++f->id, inpacket, len + HEADERLEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_rconfreq - Receive Configure-Request.
|
||||
*/
|
||||
static void
|
||||
fsm_rconfreq(f, id, inp, len)
|
||||
fsm *f;
|
||||
u_char id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
int code, reject_if_disagree;
|
||||
|
||||
switch( f->state ){
|
||||
case CLOSED:
|
||||
/* Go away, we're closed */
|
||||
fsm_sdata(f, TERMACK, id, NULL, 0);
|
||||
return;
|
||||
case CLOSING:
|
||||
case STOPPING:
|
||||
return;
|
||||
|
||||
case OPENED:
|
||||
/* Go down and restart negotiation */
|
||||
if( f->callbacks->down )
|
||||
(*f->callbacks->down)(f); /* Inform upper layers */
|
||||
fsm_sconfreq(f, 0); /* Send initial Configure-Request */
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
|
||||
case STOPPED:
|
||||
/* Negotiation started by our peer */
|
||||
fsm_sconfreq(f, 0); /* Send initial Configure-Request */
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Pass the requested configuration options
|
||||
* to protocol-specific code for checking.
|
||||
*/
|
||||
if (f->callbacks->reqci){ /* Check CI */
|
||||
reject_if_disagree = (f->nakloops >= f->maxnakloops);
|
||||
code = (*f->callbacks->reqci)(f, inp, &len, reject_if_disagree);
|
||||
} else if (len)
|
||||
code = CONFREJ; /* Reject all CI */
|
||||
else
|
||||
code = CONFACK;
|
||||
|
||||
/* send the Ack, Nak or Rej to the peer */
|
||||
fsm_sdata(f, code, id, inp, len);
|
||||
|
||||
if (code == CONFACK) {
|
||||
if (f->state == ACKRCVD) {
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
f->state = OPENED;
|
||||
if (f->callbacks->up)
|
||||
(*f->callbacks->up)(f); /* Inform upper layers */
|
||||
} else
|
||||
f->state = ACKSENT;
|
||||
f->nakloops = 0;
|
||||
|
||||
} else {
|
||||
/* we sent CONFACK or CONFREJ */
|
||||
if (f->state != ACKRCVD)
|
||||
f->state = REQSENT;
|
||||
if( code == CONFNAK )
|
||||
++f->nakloops;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_rconfack - Receive Configure-Ack.
|
||||
*/
|
||||
static void
|
||||
fsm_rconfack(f, id, inp, len)
|
||||
fsm *f;
|
||||
int id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
if (id != f->reqid || f->seen_ack) /* Expected id? */
|
||||
return; /* Nope, toss... */
|
||||
if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len):
|
||||
(len == 0)) ){
|
||||
/* Ack is bad - ignore it */
|
||||
error("Received bad configure-ack: %P", inp, len);
|
||||
return;
|
||||
}
|
||||
f->seen_ack = 1;
|
||||
f->rnakloops = 0;
|
||||
|
||||
switch (f->state) {
|
||||
case CLOSED:
|
||||
case STOPPED:
|
||||
fsm_sdata(f, TERMACK, id, NULL, 0);
|
||||
break;
|
||||
|
||||
case REQSENT:
|
||||
f->state = ACKRCVD;
|
||||
f->retransmits = f->maxconfreqtransmits;
|
||||
break;
|
||||
|
||||
case ACKRCVD:
|
||||
/* Huh? an extra valid Ack? oh well... */
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
fsm_sconfreq(f, 0);
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
|
||||
case ACKSENT:
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
f->state = OPENED;
|
||||
f->retransmits = f->maxconfreqtransmits;
|
||||
if (f->callbacks->up)
|
||||
(*f->callbacks->up)(f); /* Inform upper layers */
|
||||
break;
|
||||
|
||||
case OPENED:
|
||||
/* Go down and restart negotiation */
|
||||
if (f->callbacks->down)
|
||||
(*f->callbacks->down)(f); /* Inform upper layers */
|
||||
fsm_sconfreq(f, 0); /* Send initial Configure-Request */
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject.
|
||||
*/
|
||||
static void
|
||||
fsm_rconfnakrej(f, code, id, inp, len)
|
||||
fsm *f;
|
||||
int code, id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
int ret;
|
||||
int treat_as_reject;
|
||||
|
||||
if (id != f->reqid || f->seen_ack) /* Expected id? */
|
||||
return; /* Nope, toss... */
|
||||
|
||||
if (code == CONFNAK) {
|
||||
++f->rnakloops;
|
||||
treat_as_reject = (f->rnakloops >= f->maxnakloops);
|
||||
if (f->callbacks->nakci == NULL
|
||||
|| !(ret = f->callbacks->nakci(f, inp, len, treat_as_reject))) {
|
||||
error("Received bad configure-nak: %P", inp, len);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
f->rnakloops = 0;
|
||||
if (f->callbacks->rejci == NULL
|
||||
|| !(ret = f->callbacks->rejci(f, inp, len))) {
|
||||
error("Received bad configure-rej: %P", inp, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
f->seen_ack = 1;
|
||||
|
||||
switch (f->state) {
|
||||
case CLOSED:
|
||||
case STOPPED:
|
||||
fsm_sdata(f, TERMACK, id, NULL, 0);
|
||||
break;
|
||||
|
||||
case REQSENT:
|
||||
case ACKSENT:
|
||||
/* They didn't agree to what we wanted - try another request */
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
if (ret < 0)
|
||||
f->state = STOPPED; /* kludge for stopping CCP */
|
||||
else
|
||||
fsm_sconfreq(f, 0); /* Send Configure-Request */
|
||||
break;
|
||||
|
||||
case ACKRCVD:
|
||||
/* Got a Nak/reject when we had already had an Ack?? oh well... */
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
fsm_sconfreq(f, 0);
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
|
||||
case OPENED:
|
||||
/* Go down and restart negotiation */
|
||||
if (f->callbacks->down)
|
||||
(*f->callbacks->down)(f); /* Inform upper layers */
|
||||
fsm_sconfreq(f, 0); /* Send initial Configure-Request */
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_rtermreq - Receive Terminate-Req.
|
||||
*/
|
||||
static void
|
||||
fsm_rtermreq(f, id, p, len)
|
||||
fsm *f;
|
||||
int id;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
switch (f->state) {
|
||||
case ACKRCVD:
|
||||
case ACKSENT:
|
||||
f->state = REQSENT; /* Start over but keep trying */
|
||||
break;
|
||||
|
||||
case OPENED:
|
||||
if (len > 0) {
|
||||
info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p);
|
||||
} else
|
||||
info("%s terminated by peer", PROTO_NAME(f));
|
||||
f->retransmits = 0;
|
||||
f->state = STOPPING;
|
||||
if (f->callbacks->down)
|
||||
(*f->callbacks->down)(f); /* Inform upper layers */
|
||||
TIMEOUT(fsm_timeout, f, f->timeouttime);
|
||||
break;
|
||||
}
|
||||
|
||||
fsm_sdata(f, TERMACK, id, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_rtermack - Receive Terminate-Ack.
|
||||
*/
|
||||
static void
|
||||
fsm_rtermack(f)
|
||||
fsm *f;
|
||||
{
|
||||
switch (f->state) {
|
||||
case CLOSING:
|
||||
UNTIMEOUT(fsm_timeout, f);
|
||||
f->state = CLOSED;
|
||||
if( f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
break;
|
||||
case STOPPING:
|
||||
UNTIMEOUT(fsm_timeout, f);
|
||||
f->state = STOPPED;
|
||||
if( f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
break;
|
||||
|
||||
case ACKRCVD:
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
|
||||
case OPENED:
|
||||
if (f->callbacks->down)
|
||||
(*f->callbacks->down)(f); /* Inform upper layers */
|
||||
fsm_sconfreq(f, 0);
|
||||
f->state = REQSENT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_rcoderej - Receive an Code-Reject.
|
||||
*/
|
||||
static void
|
||||
fsm_rcoderej(f, inp, len)
|
||||
fsm *f;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
u_char code, id;
|
||||
|
||||
if (len < HEADERLEN) {
|
||||
FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!"));
|
||||
return;
|
||||
}
|
||||
GETCHAR(code, inp);
|
||||
GETCHAR(id, inp);
|
||||
warn("%s: Rcvd Code-Reject for code %d, id %d", PROTO_NAME(f), code, id);
|
||||
|
||||
if( f->state == ACKRCVD )
|
||||
f->state = REQSENT;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_protreject - Peer doesn't speak this protocol.
|
||||
*
|
||||
* Treat this as a catastrophic error (RXJ-).
|
||||
*/
|
||||
void
|
||||
fsm_protreject(f)
|
||||
fsm *f;
|
||||
{
|
||||
switch( f->state ){
|
||||
case CLOSING:
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
/* fall through */
|
||||
case CLOSED:
|
||||
f->state = CLOSED;
|
||||
if( f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
break;
|
||||
|
||||
case STOPPING:
|
||||
case REQSENT:
|
||||
case ACKRCVD:
|
||||
case ACKSENT:
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
/* fall through */
|
||||
case STOPPED:
|
||||
f->state = STOPPED;
|
||||
if( f->callbacks->finished )
|
||||
(*f->callbacks->finished)(f);
|
||||
break;
|
||||
|
||||
case OPENED:
|
||||
terminate_layer(f, STOPPING);
|
||||
break;
|
||||
|
||||
default:
|
||||
FSMDEBUG(("%s: Protocol-reject event in state %d!",
|
||||
PROTO_NAME(f), f->state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_sconfreq - Send a Configure-Request.
|
||||
*/
|
||||
static void
|
||||
fsm_sconfreq(f, retransmit)
|
||||
fsm *f;
|
||||
int retransmit;
|
||||
{
|
||||
u_char *outp;
|
||||
int cilen;
|
||||
|
||||
if( f->state != REQSENT && f->state != ACKRCVD && f->state != ACKSENT ){
|
||||
/* Not currently negotiating - reset options */
|
||||
if( f->callbacks->resetci )
|
||||
(*f->callbacks->resetci)(f);
|
||||
f->nakloops = 0;
|
||||
f->rnakloops = 0;
|
||||
}
|
||||
|
||||
if( !retransmit ){
|
||||
/* New request - reset retransmission counter, use new ID */
|
||||
f->retransmits = f->maxconfreqtransmits;
|
||||
f->reqid = ++f->id;
|
||||
}
|
||||
|
||||
f->seen_ack = 0;
|
||||
|
||||
/*
|
||||
* Make up the request packet
|
||||
*/
|
||||
outp = outpacket_buf + PPP_HDRLEN + HEADERLEN;
|
||||
if( f->callbacks->cilen && f->callbacks->addci ){
|
||||
cilen = (*f->callbacks->cilen)(f);
|
||||
if( cilen > peer_mru[f->unit] - HEADERLEN )
|
||||
cilen = peer_mru[f->unit] - HEADERLEN;
|
||||
if (f->callbacks->addci)
|
||||
(*f->callbacks->addci)(f, outp, &cilen);
|
||||
} else
|
||||
cilen = 0;
|
||||
|
||||
/* send the request to our peer */
|
||||
fsm_sdata(f, CONFREQ, f->reqid, outp, cilen);
|
||||
|
||||
/* start the retransmit timer */
|
||||
--f->retransmits;
|
||||
TIMEOUT(fsm_timeout, f, f->timeouttime);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* fsm_sdata - Send some data.
|
||||
*
|
||||
* Used for all packets sent to our peer by this module.
|
||||
*/
|
||||
void
|
||||
fsm_sdata(f, code, id, data, datalen)
|
||||
fsm *f;
|
||||
u_char code, id;
|
||||
u_char *data;
|
||||
int datalen;
|
||||
{
|
||||
u_char *outp;
|
||||
int outlen;
|
||||
|
||||
/* Adjust length to be smaller than MTU */
|
||||
outp = outpacket_buf;
|
||||
if (datalen > peer_mru[f->unit] - HEADERLEN)
|
||||
datalen = peer_mru[f->unit] - HEADERLEN;
|
||||
if (datalen && data != outp + PPP_HDRLEN + HEADERLEN)
|
||||
BCOPY(data, outp + PPP_HDRLEN + HEADERLEN, datalen);
|
||||
outlen = datalen + HEADERLEN;
|
||||
MAKEHEADER(outp, f->protocol);
|
||||
PUTCHAR(code, outp);
|
||||
PUTCHAR(id, outp);
|
||||
PUTSHORT(outlen, outp);
|
||||
output(f->unit, outpacket_buf, outlen + PPP_HDRLEN);
|
||||
}
|
||||
168
vendor/aw/homlet/external/pppoe/pppd/fsm.h
vendored
Normal file
168
vendor/aw/homlet/external/pppoe/pppd/fsm.h
vendored
Normal file
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: fsm.h,v 1.10 2004/11/13 02:28:15 paulus Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
#define HEADERLEN 4
|
||||
|
||||
|
||||
/*
|
||||
* CP (LCP, IPCP, etc.) codes.
|
||||
*/
|
||||
#define CONFREQ 1 /* Configuration Request */
|
||||
#define CONFACK 2 /* Configuration Ack */
|
||||
#define CONFNAK 3 /* Configuration Nak */
|
||||
#define CONFREJ 4 /* Configuration Reject */
|
||||
#define TERMREQ 5 /* Termination Request */
|
||||
#define TERMACK 6 /* Termination Ack */
|
||||
#define CODEREJ 7 /* Code Reject */
|
||||
|
||||
|
||||
/*
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
int unit; /* Interface unit number */
|
||||
int protocol; /* Data Link Layer Protocol field value */
|
||||
int state; /* State */
|
||||
int flags; /* Contains option bits */
|
||||
u_char id; /* Current id */
|
||||
u_char reqid; /* Current request id */
|
||||
u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */
|
||||
int timeouttime; /* Timeout time in milliseconds */
|
||||
int maxconfreqtransmits; /* Maximum Configure-Request transmissions */
|
||||
int retransmits; /* Number of retransmissions left */
|
||||
int maxtermtransmits; /* Maximum Terminate-Request transmissions */
|
||||
int nakloops; /* Number of nak loops since last ack */
|
||||
int rnakloops; /* Number of naks received */
|
||||
int maxnakloops; /* Maximum number of nak loops tolerated */
|
||||
struct fsm_callbacks *callbacks; /* Callback routines */
|
||||
char *term_reason; /* Reason for closing protocol */
|
||||
int term_reason_len; /* Length of term_reason */
|
||||
} fsm;
|
||||
|
||||
|
||||
typedef struct fsm_callbacks {
|
||||
void (*resetci) /* Reset our Configuration Information */
|
||||
__P((fsm *));
|
||||
int (*cilen) /* Length of our Configuration Information */
|
||||
__P((fsm *));
|
||||
void (*addci) /* Add our Configuration Information */
|
||||
__P((fsm *, u_char *, int *));
|
||||
int (*ackci) /* ACK our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*nakci) /* NAK our Configuration Information */
|
||||
__P((fsm *, u_char *, int, int));
|
||||
int (*rejci) /* Reject our Configuration Information */
|
||||
__P((fsm *, u_char *, int));
|
||||
int (*reqci) /* Request peer's Configuration Information */
|
||||
__P((fsm *, u_char *, int *, int));
|
||||
void (*up) /* Called when fsm reaches OPENED state */
|
||||
__P((fsm *));
|
||||
void (*down) /* Called when fsm leaves OPENED state */
|
||||
__P((fsm *));
|
||||
void (*starting) /* Called when we want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*finished) /* Called when we don't want the lower layer */
|
||||
__P((fsm *));
|
||||
void (*protreject) /* Called when Protocol-Reject received */
|
||||
__P((int));
|
||||
void (*retransmit) /* Retransmission is necessary */
|
||||
__P((fsm *));
|
||||
int (*extcode) /* Called when unknown code received */
|
||||
__P((fsm *, int, int, u_char *, int));
|
||||
char *proto_name; /* String name for protocol (for messages) */
|
||||
} fsm_callbacks;
|
||||
|
||||
|
||||
/*
|
||||
* Link states.
|
||||
*/
|
||||
#define INITIAL 0 /* Down, hasn't been opened */
|
||||
#define STARTING 1 /* Down, been opened */
|
||||
#define CLOSED 2 /* Up, hasn't been opened */
|
||||
#define STOPPED 3 /* Open, waiting for down event */
|
||||
#define CLOSING 4 /* Terminating the connection, not open */
|
||||
#define STOPPING 5 /* Terminating, but open */
|
||||
#define REQSENT 6 /* We've sent a Config Request */
|
||||
#define ACKRCVD 7 /* We've received a Config Ack */
|
||||
#define ACKSENT 8 /* We've sent a Config Ack */
|
||||
#define OPENED 9 /* Connection available */
|
||||
|
||||
|
||||
/*
|
||||
* Flags - indicate options controlling FSM operation
|
||||
*/
|
||||
#define OPT_PASSIVE 1 /* Don't die if we don't get a response */
|
||||
#define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */
|
||||
#define OPT_SILENT 4 /* Wait for peer to speak first */
|
||||
|
||||
|
||||
/*
|
||||
* Timeouts.
|
||||
*/
|
||||
#define DEFTIMEOUT 3 /* Timeout time in seconds */
|
||||
#define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */
|
||||
#define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */
|
||||
#define DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init __P((fsm *));
|
||||
void fsm_lowerup __P((fsm *));
|
||||
void fsm_lowerdown __P((fsm *));
|
||||
void fsm_open __P((fsm *));
|
||||
void fsm_close __P((fsm *, char *));
|
||||
void fsm_input __P((fsm *, u_char *, int));
|
||||
void fsm_protreject __P((fsm *));
|
||||
void fsm_sdata __P((fsm *, int, int, u_char *, int));
|
||||
|
||||
|
||||
/*
|
||||
* Variables
|
||||
*/
|
||||
extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
|
||||
156
vendor/aw/homlet/external/pppoe/pppd/include/net/if_ppp.h
vendored
Normal file
156
vendor/aw/homlet/external/pppoe/pppd/include/net/if_ppp.h
vendored
Normal file
@ -0,0 +1,156 @@
|
||||
/* $Id: if_ppp.h,v 1.19 2002/12/06 09:49:15 paulus Exp $ */
|
||||
|
||||
/*
|
||||
* if_ppp.h - Point-to-Point Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _IF_PPP_H_
|
||||
#define _IF_PPP_H_
|
||||
|
||||
/*
|
||||
* Bit definitions for flags.
|
||||
*/
|
||||
#define SC_COMP_PROT 0x00000001 /* protocol compression (output) */
|
||||
#define SC_COMP_AC 0x00000002 /* header compression (output) */
|
||||
#define SC_COMP_TCP 0x00000004 /* TCP (VJ) compression (output) */
|
||||
#define SC_NO_TCP_CCID 0x00000008 /* disable VJ connection-id comp. */
|
||||
#define SC_REJ_COMP_AC 0x00000010 /* reject adrs/ctrl comp. on input */
|
||||
#define SC_REJ_COMP_TCP 0x00000020 /* reject TCP (VJ) comp. on input */
|
||||
#define SC_CCP_OPEN 0x00000040 /* Look at CCP packets */
|
||||
#define SC_CCP_UP 0x00000080 /* May send/recv compressed packets */
|
||||
#define SC_DEBUG 0x00010000 /* enable debug messages */
|
||||
#define SC_LOG_INPKT 0x00020000 /* log contents of good pkts recvd */
|
||||
#define SC_LOG_OUTPKT 0x00040000 /* log contents of pkts sent */
|
||||
#define SC_LOG_RAWIN 0x00080000 /* log all chars received */
|
||||
#define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */
|
||||
#define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */
|
||||
#define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */
|
||||
#define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */
|
||||
#define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */
|
||||
#define SC_SYNC 0x00200000 /* use synchronous HDLC framing */
|
||||
#define SC_MASK 0x0fff00ff /* bits that user can change */
|
||||
|
||||
/*
|
||||
* State bits in sc_flags, not changeable by user.
|
||||
*/
|
||||
#define SC_TIMEOUT 0x00000400 /* timeout is currently pending */
|
||||
#define SC_VJ_RESET 0x00000800 /* need to reset VJ decomp */
|
||||
#define SC_COMP_RUN 0x00001000 /* compressor has been inited */
|
||||
#define SC_DECOMP_RUN 0x00002000 /* decompressor has been inited */
|
||||
#define SC_DC_ERROR 0x00004000 /* non-fatal decomp error detected */
|
||||
#define SC_DC_FERROR 0x00008000 /* fatal decomp error detected */
|
||||
#define SC_TBUSY 0x10000000 /* xmitter doesn't need a packet yet */
|
||||
#define SC_PKTLOST 0x20000000 /* have lost or dropped a packet */
|
||||
#define SC_FLUSH 0x40000000 /* flush input until next PPP_FLAG */
|
||||
#define SC_ESCAPED 0x80000000 /* saw a PPP_ESCAPE */
|
||||
|
||||
/*
|
||||
* Ioctl definitions.
|
||||
*/
|
||||
|
||||
struct npioctl {
|
||||
int protocol; /* PPP procotol, e.g. PPP_IP */
|
||||
enum NPmode mode;
|
||||
};
|
||||
|
||||
/* Structure describing a CCP configuration option, for PPPIOCSCOMPRESS */
|
||||
struct ppp_option_data {
|
||||
u_char *ptr;
|
||||
u_int length;
|
||||
int transmit;
|
||||
};
|
||||
|
||||
struct ifpppstatsreq {
|
||||
char ifr_name[IFNAMSIZ];
|
||||
struct ppp_stats stats;
|
||||
};
|
||||
|
||||
struct ifpppcstatsreq {
|
||||
char ifr_name[IFNAMSIZ];
|
||||
struct ppp_comp_stats stats;
|
||||
};
|
||||
|
||||
/*
|
||||
* Ioctl definitions.
|
||||
*/
|
||||
|
||||
#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
|
||||
#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
|
||||
#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
|
||||
#define PPPIOCSASYNCMAP _IOW('t', 87, int) /* set async map */
|
||||
#define PPPIOCGUNIT _IOR('t', 86, int) /* get ppp unit number */
|
||||
#define PPPIOCGRASYNCMAP _IOR('t', 85, int) /* get receive async map */
|
||||
#define PPPIOCSRASYNCMAP _IOW('t', 84, int) /* set receive async map */
|
||||
#define PPPIOCGMRU _IOR('t', 83, int) /* get max receive unit */
|
||||
#define PPPIOCSMRU _IOW('t', 82, int) /* set max receive unit */
|
||||
#define PPPIOCSMAXCID _IOW('t', 81, int) /* set VJ max slot ID */
|
||||
#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm) /* get extended ACCM */
|
||||
#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm) /* set extended ACCM */
|
||||
#define PPPIOCXFERUNIT _IO('t', 78) /* transfer PPP unit */
|
||||
#define PPPIOCSCOMPRESS _IOW('t', 77, struct ppp_option_data)
|
||||
#define PPPIOCGNPMODE _IOWR('t', 76, struct npioctl) /* get NP mode */
|
||||
#define PPPIOCSNPMODE _IOW('t', 75, struct npioctl) /* set NP mode */
|
||||
#define PPPIOCGIDLE _IOR('t', 74, struct ppp_idle) /* get idle time */
|
||||
#ifdef PPP_FILTER
|
||||
#define PPPIOCSPASS _IOW('t', 71, struct bpf_program) /* set pass filter */
|
||||
#define PPPIOCSACTIVE _IOW('t', 70, struct bpf_program) /* set active filt */
|
||||
#endif /* PPP_FILTER */
|
||||
|
||||
/* PPPIOC[GS]MTU are alternatives to SIOC[GS]IFMTU, used under Ultrix */
|
||||
#define PPPIOCGMTU _IOR('t', 73, int) /* get interface MTU */
|
||||
#define PPPIOCSMTU _IOW('t', 72, int) /* set interface MTU */
|
||||
|
||||
/*
|
||||
* These two are interface ioctls so that pppstats can do them on
|
||||
* a socket without having to open the serial device.
|
||||
*/
|
||||
#define SIOCGPPPSTATS _IOWR('i', 123, struct ifpppstatsreq)
|
||||
#define SIOCGPPPCSTATS _IOWR('i', 122, struct ifpppcstatsreq)
|
||||
|
||||
#if !defined(ifr_mtu)
|
||||
#define ifr_mtu ifr_ifru.ifru_metric
|
||||
#endif
|
||||
|
||||
#if (defined(_KERNEL) || defined(KERNEL)) && !defined(NeXT)
|
||||
void pppattach __P((void));
|
||||
void pppintr __P((void));
|
||||
#endif
|
||||
#endif /* _IF_PPP_H_ */
|
||||
266
vendor/aw/homlet/external/pppoe/pppd/include/net/ppp-comp.h
vendored
Normal file
266
vendor/aw/homlet/external/pppoe/pppd/include/net/ppp-comp.h
vendored
Normal file
@ -0,0 +1,266 @@
|
||||
/*
|
||||
* ppp-comp.h - Definitions for doing PPP packet compression.
|
||||
*
|
||||
* Copyright (c) 1984 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ppp-comp.h,v 1.13 2002/12/06 09:49:15 paulus Exp $
|
||||
*/
|
||||
|
||||
#ifndef _NET_PPP_COMP_H
|
||||
#define _NET_PPP_COMP_H
|
||||
|
||||
/*
|
||||
* The following symbols control whether we include code for
|
||||
* various compression methods.
|
||||
*/
|
||||
#ifndef DO_BSD_COMPRESS
|
||||
#define DO_BSD_COMPRESS 1 /* by default, include BSD-Compress */
|
||||
#endif
|
||||
#ifndef DO_DEFLATE
|
||||
#define DO_DEFLATE 1 /* by default, include Deflate */
|
||||
#endif
|
||||
#define DO_PREDICTOR_1 0
|
||||
#define DO_PREDICTOR_2 0
|
||||
|
||||
/*
|
||||
* Structure giving methods for compression/decompression.
|
||||
*/
|
||||
#ifdef PACKETPTR
|
||||
struct compressor {
|
||||
int compress_proto; /* CCP compression protocol number */
|
||||
|
||||
/* Allocate space for a compressor (transmit side) */
|
||||
void *(*comp_alloc) __P((u_char *options, int opt_len));
|
||||
/* Free space used by a compressor */
|
||||
void (*comp_free) __P((void *state));
|
||||
/* Initialize a compressor */
|
||||
int (*comp_init) __P((void *state, u_char *options, int opt_len,
|
||||
int unit, int hdrlen, int debug));
|
||||
/* Reset a compressor */
|
||||
void (*comp_reset) __P((void *state));
|
||||
/* Compress a packet */
|
||||
int (*compress) __P((void *state, PACKETPTR *mret,
|
||||
PACKETPTR mp, int orig_len, int max_len));
|
||||
/* Return compression statistics */
|
||||
void (*comp_stat) __P((void *state, struct compstat *stats));
|
||||
|
||||
/* Allocate space for a decompressor (receive side) */
|
||||
void *(*decomp_alloc) __P((u_char *options, int opt_len));
|
||||
/* Free space used by a decompressor */
|
||||
void (*decomp_free) __P((void *state));
|
||||
/* Initialize a decompressor */
|
||||
int (*decomp_init) __P((void *state, u_char *options, int opt_len,
|
||||
int unit, int hdrlen, int mru, int debug));
|
||||
/* Reset a decompressor */
|
||||
void (*decomp_reset) __P((void *state));
|
||||
/* Decompress a packet. */
|
||||
int (*decompress) __P((void *state, PACKETPTR mp,
|
||||
PACKETPTR *dmpp));
|
||||
/* Update state for an incompressible packet received */
|
||||
void (*incomp) __P((void *state, PACKETPTR mp));
|
||||
/* Return decompression statistics */
|
||||
void (*decomp_stat) __P((void *state, struct compstat *stats));
|
||||
};
|
||||
#endif /* PACKETPTR */
|
||||
|
||||
/*
|
||||
* Return values for decompress routine.
|
||||
* We need to make these distinctions so that we can disable certain
|
||||
* useful functionality, namely sending a CCP reset-request as a result
|
||||
* of an error detected after decompression. This is to avoid infringing
|
||||
* a patent held by Motorola.
|
||||
* Don't you just lurve software patents.
|
||||
*/
|
||||
#define DECOMP_OK 0 /* everything went OK */
|
||||
#define DECOMP_ERROR 1 /* error detected before decomp. */
|
||||
#define DECOMP_FATALERROR 2 /* error detected after decomp. */
|
||||
|
||||
/*
|
||||
* CCP codes.
|
||||
*/
|
||||
#define CCP_CONFREQ 1
|
||||
#define CCP_CONFACK 2
|
||||
#define CCP_TERMREQ 5
|
||||
#define CCP_TERMACK 6
|
||||
#define CCP_RESETREQ 14
|
||||
#define CCP_RESETACK 15
|
||||
|
||||
/*
|
||||
* Max # bytes for a CCP option
|
||||
*/
|
||||
#define CCP_MAX_OPTION_LENGTH 32
|
||||
|
||||
/*
|
||||
* Parts of a CCP packet.
|
||||
*/
|
||||
#define CCP_CODE(dp) ((dp)[0])
|
||||
#define CCP_ID(dp) ((dp)[1])
|
||||
#define CCP_LENGTH(dp) (((dp)[2] << 8) + (dp)[3])
|
||||
#define CCP_HDRLEN 4
|
||||
|
||||
#define CCP_OPT_CODE(dp) ((dp)[0])
|
||||
#define CCP_OPT_LENGTH(dp) ((dp)[1])
|
||||
#define CCP_OPT_MINLEN 2
|
||||
|
||||
/*
|
||||
* Definitions for BSD-Compress.
|
||||
*/
|
||||
#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */
|
||||
#define CILEN_BSD_COMPRESS 3 /* length of config. option */
|
||||
|
||||
/* Macros for handling the 3rd byte of the BSD-Compress config option. */
|
||||
#define BSD_NBITS(x) ((x) & 0x1F) /* number of bits requested */
|
||||
#define BSD_VERSION(x) ((x) >> 5) /* version of option format */
|
||||
#define BSD_CURRENT_VERSION 1 /* current version number */
|
||||
#define BSD_MAKE_OPT(v, n) (((v) << 5) | (n))
|
||||
|
||||
#define BSD_MIN_BITS 9 /* smallest code size supported */
|
||||
#define BSD_MAX_BITS 15 /* largest code size supported */
|
||||
|
||||
/*
|
||||
* Definitions for Deflate.
|
||||
*/
|
||||
#define CI_DEFLATE 26 /* config option for Deflate */
|
||||
#define CI_DEFLATE_DRAFT 24 /* value used in original draft RFC */
|
||||
#define CILEN_DEFLATE 4 /* length of its config option */
|
||||
|
||||
#define DEFLATE_MIN_SIZE 8
|
||||
#define DEFLATE_MAX_SIZE 15
|
||||
#define DEFLATE_METHOD_VAL 8
|
||||
#define DEFLATE_SIZE(x) (((x) >> 4) + DEFLATE_MIN_SIZE)
|
||||
#define DEFLATE_METHOD(x) ((x) & 0x0F)
|
||||
#define DEFLATE_MAKE_OPT(w) ((((w) - DEFLATE_MIN_SIZE) << 4) \
|
||||
+ DEFLATE_METHOD_VAL)
|
||||
#define DEFLATE_CHK_SEQUENCE 0
|
||||
|
||||
/*
|
||||
* Definitions for MPPE.
|
||||
*/
|
||||
#define CI_MPPE 18 /* config option for MPPE */
|
||||
#define CILEN_MPPE 6 /* length of config option */
|
||||
|
||||
#define MPPE_PAD 4 /* MPPE growth per frame */
|
||||
#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */
|
||||
|
||||
/* option bits for ccp_options.mppe */
|
||||
#define MPPE_OPT_40 0x01 /* 40 bit */
|
||||
#define MPPE_OPT_128 0x02 /* 128 bit */
|
||||
#define MPPE_OPT_STATEFUL 0x04 /* stateful mode */
|
||||
/* unsupported opts */
|
||||
#define MPPE_OPT_56 0x08 /* 56 bit */
|
||||
#define MPPE_OPT_MPPC 0x10 /* MPPC compression */
|
||||
#define MPPE_OPT_D 0x20 /* Unknown */
|
||||
#define MPPE_OPT_UNSUPPORTED (MPPE_OPT_56|MPPE_OPT_MPPC|MPPE_OPT_D)
|
||||
#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */
|
||||
|
||||
/*
|
||||
* This is not nice ... the alternative is a bitfield struct though.
|
||||
* And unfortunately, we cannot share the same bits for the option
|
||||
* names above since C and H are the same bit. We could do a u_int32
|
||||
* but then we have to do a htonl() all the time and/or we still need
|
||||
* to know which octet is which.
|
||||
*/
|
||||
#define MPPE_C_BIT 0x01 /* MPPC */
|
||||
#define MPPE_D_BIT 0x10 /* Obsolete, usage unknown */
|
||||
#define MPPE_L_BIT 0x20 /* 40-bit */
|
||||
#define MPPE_S_BIT 0x40 /* 128-bit */
|
||||
#define MPPE_M_BIT 0x80 /* 56-bit, not supported */
|
||||
#define MPPE_H_BIT 0x01 /* Stateless (in a different byte) */
|
||||
|
||||
/* Does not include H bit; used for least significant octet only. */
|
||||
#define MPPE_ALL_BITS (MPPE_D_BIT|MPPE_L_BIT|MPPE_S_BIT|MPPE_M_BIT|MPPE_H_BIT)
|
||||
|
||||
/* Build a CI from mppe opts (see RFC 3078) */
|
||||
#define MPPE_OPTS_TO_CI(opts, ci) \
|
||||
do { \
|
||||
u_char *ptr = ci; /* u_char[4] */ \
|
||||
\
|
||||
/* H bit */ \
|
||||
if (opts & MPPE_OPT_STATEFUL) \
|
||||
*ptr++ = 0x0; \
|
||||
else \
|
||||
*ptr++ = MPPE_H_BIT; \
|
||||
*ptr++ = 0; \
|
||||
*ptr++ = 0; \
|
||||
\
|
||||
/* S,L bits */ \
|
||||
*ptr = 0; \
|
||||
if (opts & MPPE_OPT_128) \
|
||||
*ptr |= MPPE_S_BIT; \
|
||||
if (opts & MPPE_OPT_40) \
|
||||
*ptr |= MPPE_L_BIT; \
|
||||
/* M,D,C bits not supported */ \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
/* The reverse of the above */
|
||||
#define MPPE_CI_TO_OPTS(ci, opts) \
|
||||
do { \
|
||||
u_char *ptr = ci; /* u_char[4] */ \
|
||||
\
|
||||
opts = 0; \
|
||||
\
|
||||
/* H bit */ \
|
||||
if (!(ptr[0] & MPPE_H_BIT)) \
|
||||
opts |= MPPE_OPT_STATEFUL; \
|
||||
\
|
||||
/* S,L bits */ \
|
||||
if (ptr[3] & MPPE_S_BIT) \
|
||||
opts |= MPPE_OPT_128; \
|
||||
if (ptr[3] & MPPE_L_BIT) \
|
||||
opts |= MPPE_OPT_40; \
|
||||
\
|
||||
/* M,D,C bits */ \
|
||||
if (ptr[3] & MPPE_M_BIT) \
|
||||
opts |= MPPE_OPT_56; \
|
||||
if (ptr[3] & MPPE_D_BIT) \
|
||||
opts |= MPPE_OPT_D; \
|
||||
if (ptr[3] & MPPE_C_BIT) \
|
||||
opts |= MPPE_OPT_MPPC; \
|
||||
\
|
||||
/* Other bits */ \
|
||||
if (ptr[0] & ~MPPE_H_BIT) \
|
||||
opts |= MPPE_OPT_UNKNOWN; \
|
||||
if (ptr[1] || ptr[2]) \
|
||||
opts |= MPPE_OPT_UNKNOWN; \
|
||||
if (ptr[3] & ~MPPE_ALL_BITS) \
|
||||
opts |= MPPE_OPT_UNKNOWN; \
|
||||
} while (/* CONSTCOND */ 0)
|
||||
|
||||
/*
|
||||
* Definitions for other, as yet unsupported, compression methods.
|
||||
*/
|
||||
#define CI_PREDICTOR_1 1 /* config option for Predictor-1 */
|
||||
#define CILEN_PREDICTOR_1 2 /* length of its config option */
|
||||
#define CI_PREDICTOR_2 2 /* config option for Predictor-2 */
|
||||
#define CILEN_PREDICTOR_2 2 /* length of its config option */
|
||||
|
||||
#endif /* _NET_PPP_COMP_H */
|
||||
211
vendor/aw/homlet/external/pppoe/pppd/include/net/ppp_defs.h
vendored
Normal file
211
vendor/aw/homlet/external/pppoe/pppd/include/net/ppp_defs.h
vendored
Normal file
@ -0,0 +1,211 @@
|
||||
/* $Id: ppp_defs.h,v 1.17 2002/12/06 09:49:15 paulus Exp $ */
|
||||
|
||||
/*
|
||||
* ppp_defs.h - PPP definitions.
|
||||
*
|
||||
* Copyright (c) 1984 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _PPP_DEFS_H_
|
||||
#define _PPP_DEFS_H_
|
||||
|
||||
#if defined(PPP_ADDRESS)
|
||||
#define USING_UAPI
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The basic PPP frame.
|
||||
*/
|
||||
#define PPP_HDRLEN 4 /* octets for standard ppp header */
|
||||
#define PPP_FCSLEN 2 /* octets for FCS */
|
||||
|
||||
/*
|
||||
* Packet sizes
|
||||
*
|
||||
* Note - lcp shouldn't be allowed to negotiate stuff outside these
|
||||
* limits. See lcp.h in the pppd directory.
|
||||
* (XXX - these constants should simply be shared by lcp.c instead
|
||||
* of living in lcp.h)
|
||||
*/
|
||||
#define PPP_MTU 1492 /* Default MTU (size of Info field) */
|
||||
#define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN)
|
||||
#define PPP_MINMTU 64
|
||||
#define PPP_MRU 1492 /* default MRU = max length of info field */
|
||||
#define PPP_MAXMRU 65000 /* Largest MRU we allow */
|
||||
#define PPP_MINMRU 128
|
||||
|
||||
#if !defined(USING_UAPI)
|
||||
#define PPP_ADDRESS(p) (((u_char *)(p))[0])
|
||||
#define PPP_CONTROL(p) (((u_char *)(p))[1])
|
||||
#define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3])
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Significant octet values.
|
||||
*/
|
||||
#define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */
|
||||
#define PPP_UI 0x03 /* Unnumbered Information */
|
||||
#define PPP_FLAG 0x7e /* Flag Sequence */
|
||||
#define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */
|
||||
#define PPP_TRANS 0x20 /* Asynchronous transparency modifier */
|
||||
|
||||
/*
|
||||
* Protocol field values.
|
||||
*/
|
||||
#define PPP_IP 0x21 /* Internet Protocol */
|
||||
#define PPP_AT 0x29 /* AppleTalk Protocol */
|
||||
#define PPP_IPX 0x2b /* IPX protocol */
|
||||
#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */
|
||||
#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */
|
||||
#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */
|
||||
#define PPP_COMP 0xfd /* compressed packet */
|
||||
#define PPP_IPCP 0x8021 /* IP Control Protocol */
|
||||
#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */
|
||||
#define PPP_IPXCP 0x802b /* IPX Control Protocol */
|
||||
#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */
|
||||
#define PPP_CCP 0x80fd /* Compression Control Protocol */
|
||||
#define PPP_ECP 0x8053 /* Encryption Control Protocol */
|
||||
#define PPP_LCP 0xc021 /* Link Control Protocol */
|
||||
#define PPP_PAP 0xc023 /* Password Authentication Protocol */
|
||||
#define PPP_LQR 0xc025 /* Link Quality Report protocol */
|
||||
#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */
|
||||
#define PPP_CBCP 0xc029 /* Callback Control Protocol */
|
||||
#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */
|
||||
|
||||
/*
|
||||
* Values for FCS calculations.
|
||||
*/
|
||||
#define PPP_INITFCS 0xffff /* Initial FCS value */
|
||||
#define PPP_GOODFCS 0xf0b8 /* Good final FCS value */
|
||||
#define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff])
|
||||
|
||||
/*
|
||||
* A 32-bit unsigned integral type.
|
||||
*/
|
||||
|
||||
#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
|
||||
&& !defined(__FreeBSD__) && (NS_TARGET < 40)
|
||||
#ifdef UINT32_T
|
||||
typedef UINT32_T u_int32_t;
|
||||
#else
|
||||
typedef unsigned int u_int32_t;
|
||||
typedef unsigned short u_int16_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Extended asyncmap - allows any character to be escaped.
|
||||
*/
|
||||
typedef u_int32_t ext_accm[8];
|
||||
|
||||
/*
|
||||
* What to do with network protocol (NP) packets.
|
||||
*/
|
||||
#if defined(USING_UAPI)
|
||||
/* This stuff isn't in uapi. TODO: is there a newer pppd that doesn't use this? */
|
||||
#define ifr__name b.ifr_ifrn.ifrn_name
|
||||
#define stats_ptr b.ifr_ifru.ifru_data
|
||||
struct ifpppstatsreq {
|
||||
struct ifreq b;
|
||||
struct ppp_stats stats;
|
||||
};
|
||||
#else
|
||||
enum NPmode {
|
||||
NPMODE_PASS, /* pass the packet through */
|
||||
NPMODE_DROP, /* silently drop the packet */
|
||||
NPMODE_ERROR, /* return an error */
|
||||
NPMODE_QUEUE /* save it up for later. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Statistics.
|
||||
*/
|
||||
struct pppstat {
|
||||
unsigned int ppp_ibytes; /* bytes received */
|
||||
unsigned int ppp_ipackets; /* packets received */
|
||||
unsigned int ppp_ierrors; /* receive errors */
|
||||
unsigned int ppp_obytes; /* bytes sent */
|
||||
unsigned int ppp_opackets; /* packets sent */
|
||||
unsigned int ppp_oerrors; /* transmit errors */
|
||||
};
|
||||
|
||||
struct vjstat {
|
||||
unsigned int vjs_packets; /* outbound packets */
|
||||
unsigned int vjs_compressed; /* outbound compressed packets */
|
||||
unsigned int vjs_searches; /* searches for connection state */
|
||||
unsigned int vjs_misses; /* times couldn't find conn. state */
|
||||
unsigned int vjs_uncompressedin; /* inbound uncompressed packets */
|
||||
unsigned int vjs_compressedin; /* inbound compressed packets */
|
||||
unsigned int vjs_errorin; /* inbound unknown type packets */
|
||||
unsigned int vjs_tossed; /* inbound packets tossed because of error */
|
||||
};
|
||||
|
||||
struct ppp_stats {
|
||||
struct pppstat p; /* basic PPP statistics */
|
||||
struct vjstat vj; /* VJ header compression statistics */
|
||||
};
|
||||
|
||||
struct compstat {
|
||||
unsigned int unc_bytes; /* total uncompressed bytes */
|
||||
unsigned int unc_packets; /* total uncompressed packets */
|
||||
unsigned int comp_bytes; /* compressed bytes */
|
||||
unsigned int comp_packets; /* compressed packets */
|
||||
unsigned int inc_bytes; /* incompressible bytes */
|
||||
unsigned int inc_packets; /* incompressible packets */
|
||||
unsigned int ratio; /* recent compression ratio << 8 */
|
||||
};
|
||||
|
||||
struct ppp_comp_stats {
|
||||
struct compstat c; /* packet compression statistics */
|
||||
struct compstat d; /* packet decompression statistics */
|
||||
};
|
||||
|
||||
/*
|
||||
* The following structure records the time in seconds since
|
||||
* the last NP packet was sent or received.
|
||||
*/
|
||||
struct ppp_idle {
|
||||
time_t xmit_idle; /* time since last NP packet sent */
|
||||
time_t recv_idle; /* time since last NP packet received */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __P
|
||||
#ifdef __STDC__
|
||||
#define __P(x) x
|
||||
#else
|
||||
#define __P(x) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* _PPP_DEFS_H_ */
|
||||
107
vendor/aw/homlet/external/pppoe/pppd/include/net/pppio.h
vendored
Normal file
107
vendor/aw/homlet/external/pppoe/pppd/include/net/pppio.h
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* pppio.h - ioctl and other misc. definitions for STREAMS modules.
|
||||
*
|
||||
* Copyright (c) 1994 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: pppio.h,v 1.9 2002/12/06 09:49:15 paulus Exp $
|
||||
*/
|
||||
|
||||
#define _PPPIO(n) (('p' << 8) + (n))
|
||||
|
||||
#define PPPIO_NEWPPA _PPPIO(130) /* allocate a new PPP unit */
|
||||
#define PPPIO_GETSTAT _PPPIO(131) /* get PPP statistics */
|
||||
#define PPPIO_GETCSTAT _PPPIO(132) /* get PPP compression stats */
|
||||
#define PPPIO_MTU _PPPIO(133) /* set max transmission unit */
|
||||
#define PPPIO_MRU _PPPIO(134) /* set max receive unit */
|
||||
#define PPPIO_CFLAGS _PPPIO(135) /* set/clear/get compression flags */
|
||||
#define PPPIO_XCOMP _PPPIO(136) /* alloc transmit compressor */
|
||||
#define PPPIO_RCOMP _PPPIO(137) /* alloc receive decompressor */
|
||||
#define PPPIO_XACCM _PPPIO(138) /* set transmit asyncmap */
|
||||
#define PPPIO_RACCM _PPPIO(139) /* set receive asyncmap */
|
||||
#define PPPIO_VJINIT _PPPIO(140) /* initialize VJ comp/decomp */
|
||||
#define PPPIO_ATTACH _PPPIO(141) /* attach to a ppa (without putmsg) */
|
||||
#define PPPIO_LASTMOD _PPPIO(142) /* mark last ppp module */
|
||||
#define PPPIO_GCLEAN _PPPIO(143) /* get 8-bit-clean flags */
|
||||
#define PPPIO_DEBUG _PPPIO(144) /* request debug information */
|
||||
#define PPPIO_BIND _PPPIO(145) /* bind to SAP */
|
||||
#define PPPIO_NPMODE _PPPIO(146) /* set mode for handling data pkts */
|
||||
#define PPPIO_GIDLE _PPPIO(147) /* get time since last data pkt */
|
||||
#define PPPIO_PASSFILT _PPPIO(148) /* set filter for packets to pass */
|
||||
#define PPPIO_ACTIVEFILT _PPPIO(149) /* set filter for "link active" pkts */
|
||||
|
||||
/*
|
||||
* Values for PPPIO_CFLAGS
|
||||
*/
|
||||
#define COMP_AC 0x1 /* compress address/control */
|
||||
#define DECOMP_AC 0x2 /* decompress address/control */
|
||||
#define COMP_PROT 0x4 /* compress PPP protocol */
|
||||
#define DECOMP_PROT 0x8 /* decompress PPP protocol */
|
||||
|
||||
#define COMP_VJC 0x10 /* compress TCP/IP headers */
|
||||
#define COMP_VJCCID 0x20 /* compress connection ID as well */
|
||||
#define DECOMP_VJC 0x40 /* decompress TCP/IP headers */
|
||||
#define DECOMP_VJCCID 0x80 /* accept compressed connection ID */
|
||||
|
||||
#define CCP_ISOPEN 0x100 /* look at CCP packets */
|
||||
#define CCP_ISUP 0x200 /* do packet comp/decomp */
|
||||
#define CCP_ERROR 0x400 /* (status) error in packet decomp */
|
||||
#define CCP_FATALERROR 0x800 /* (status) fatal error ditto */
|
||||
#define CCP_COMP_RUN 0x1000 /* (status) seen CCP ack sent */
|
||||
#define CCP_DECOMP_RUN 0x2000 /* (status) seen CCP ack rcvd */
|
||||
|
||||
/*
|
||||
* Values for 8-bit-clean flags.
|
||||
*/
|
||||
#define RCV_B7_0 1 /* have rcvd char with bit 7 = 0 */
|
||||
#define RCV_B7_1 2 /* have rcvd char with bit 7 = 1 */
|
||||
#define RCV_EVNP 4 /* have rcvd char with even parity */
|
||||
#define RCV_ODDP 8 /* have rcvd char with odd parity */
|
||||
|
||||
/*
|
||||
* Values for the first byte of M_CTL messages passed between
|
||||
* PPP modules.
|
||||
*/
|
||||
#define PPPCTL_OERROR 0xe0 /* output error [up] */
|
||||
#define PPPCTL_IERROR 0xe1 /* input error (e.g. FCS) [up] */
|
||||
#define PPPCTL_MTU 0xe2 /* set MTU [down] */
|
||||
#define PPPCTL_MRU 0xe3 /* set MRU [down] */
|
||||
#define PPPCTL_UNIT 0xe4 /* note PPP unit number [down] */
|
||||
|
||||
/*
|
||||
* Values for the integer argument to PPPIO_DEBUG.
|
||||
*/
|
||||
#define PPPDBG_DUMP 0x10000 /* print out debug info now */
|
||||
#define PPPDBG_LOG 0x100 /* log various things */
|
||||
#define PPPDBG_DRIVER 0 /* identifies ppp driver as target */
|
||||
#define PPPDBG_IF 1 /* identifies ppp network i/f target */
|
||||
#define PPPDBG_COMP 2 /* identifies ppp compression target */
|
||||
#define PPPDBG_AHDLC 3 /* identifies ppp async hdlc target */
|
||||
148
vendor/aw/homlet/external/pppoe/pppd/include/net/slcompress.h
vendored
Normal file
148
vendor/aw/homlet/external/pppoe/pppd/include/net/slcompress.h
vendored
Normal file
@ -0,0 +1,148 @@
|
||||
/*
|
||||
* Definitions for tcp compression routines.
|
||||
*
|
||||
* $Id: slcompress.h,v 1.4 1994/09/21 06:50:08 paulus Exp $
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* 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 University of California, Berkeley. The name of the
|
||||
* University 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.
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
*/
|
||||
|
||||
#ifndef _SLCOMPRESS_H_
|
||||
#define _SLCOMPRESS_H_
|
||||
|
||||
#define MAX_STATES 16 /* must be > 2 and < 256 */
|
||||
#define MAX_HDR MLEN /* XXX 4bsd-ism: should really be 128 */
|
||||
|
||||
/*
|
||||
* Compressed packet format:
|
||||
*
|
||||
* The first octet contains the packet type (top 3 bits), TCP
|
||||
* 'push' bit, and flags that indicate which of the 4 TCP sequence
|
||||
* numbers have changed (bottom 5 bits). The next octet is a
|
||||
* conversation number that associates a saved IP/TCP header with
|
||||
* the compressed packet. The next two octets are the TCP checksum
|
||||
* from the original datagram. The next 0 to 15 octets are
|
||||
* sequence number changes, one change per bit set in the header
|
||||
* (there may be no changes and there are two special cases where
|
||||
* the receiver implicitly knows what changed -- see below).
|
||||
*
|
||||
* There are 5 numbers which can change (they are always inserted
|
||||
* in the following order): TCP urgent pointer, window,
|
||||
* acknowlegement, sequence number and IP ID. (The urgent pointer
|
||||
* is different from the others in that its value is sent, not the
|
||||
* change in value.) Since typical use of SLIP links is biased
|
||||
* toward small packets (see comments on MTU/MSS below), changes
|
||||
* use a variable length coding with one octet for numbers in the
|
||||
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
|
||||
* range 256 - 65535 or 0. (If the change in sequence number or
|
||||
* ack is more than 65535, an uncompressed packet is sent.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet types (must not conflict with IP protocol version)
|
||||
*
|
||||
* The top nibble of the first octet is the packet type. There are
|
||||
* three possible types: IP (not proto TCP or tcp with one of the
|
||||
* control flags set); uncompressed TCP (a normal IP/TCP packet but
|
||||
* with the 8-bit protocol field replaced by an 8-bit connection id --
|
||||
* this type of packet syncs the sender & receiver); and compressed
|
||||
* TCP (described above).
|
||||
*
|
||||
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
|
||||
* is logically part of the 4-bit "changes" field that follows. Top
|
||||
* three bits are actual packet type. For backward compatibility
|
||||
* and in the interest of conserving bits, numbers are chosen so the
|
||||
* IP protocol version number (4) which normally appears in this nibble
|
||||
* means "IP packet".
|
||||
*/
|
||||
|
||||
/* packet types */
|
||||
#define TYPE_IP 0x40
|
||||
#define TYPE_UNCOMPRESSED_TCP 0x70
|
||||
#define TYPE_COMPRESSED_TCP 0x80
|
||||
#define TYPE_ERROR 0x00
|
||||
|
||||
/* Bits in first octet of compressed packet */
|
||||
#define NEW_C 0x40 /* flag bits for what changed in a packet */
|
||||
#define NEW_I 0x20
|
||||
#define NEW_S 0x08
|
||||
#define NEW_A 0x04
|
||||
#define NEW_W 0x02
|
||||
#define NEW_U 0x01
|
||||
|
||||
/* reserved, special-case values of above */
|
||||
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
|
||||
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
|
||||
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
|
||||
|
||||
#define TCP_PUSH_BIT 0x10
|
||||
|
||||
|
||||
/*
|
||||
* "state" data for each active tcp conversation on the wire. This is
|
||||
* basically a copy of the entire IP/TCP header from the last packet
|
||||
* we saw from the conversation together with a small identifier
|
||||
* the transmit & receive ends of the line use to locate saved header.
|
||||
*/
|
||||
struct cstate {
|
||||
struct cstate *cs_next; /* next most recently used cstate (xmit only) */
|
||||
u_short cs_hlen; /* size of hdr (receive only) */
|
||||
u_char cs_id; /* connection # associated with this state */
|
||||
u_char cs_filler;
|
||||
union {
|
||||
char csu_hdr[MAX_HDR];
|
||||
struct ip csu_ip; /* ip/tcp hdr from most recent packet */
|
||||
} slcs_u;
|
||||
};
|
||||
#define cs_ip slcs_u.csu_ip
|
||||
#define cs_hdr slcs_u.csu_hdr
|
||||
|
||||
/*
|
||||
* all the state data for one serial line (we need one of these
|
||||
* per line).
|
||||
*/
|
||||
struct slcompress {
|
||||
struct cstate *last_cs; /* most recently used tstate */
|
||||
u_char last_recv; /* last rcvd conn. id */
|
||||
u_char last_xmit; /* last sent conn. id */
|
||||
u_short flags;
|
||||
#ifndef SL_NO_STATS
|
||||
int sls_packets; /* outbound packets */
|
||||
int sls_compressed; /* outbound compressed packets */
|
||||
int sls_searches; /* searches for connection state */
|
||||
int sls_misses; /* times couldn't find conn. state */
|
||||
int sls_uncompressedin; /* inbound uncompressed packets */
|
||||
int sls_compressedin; /* inbound compressed packets */
|
||||
int sls_errorin; /* inbound unknown type packets */
|
||||
int sls_tossed; /* inbound packets tossed because of error */
|
||||
#endif
|
||||
struct cstate tstate[MAX_STATES]; /* xmit connection states */
|
||||
struct cstate rstate[MAX_STATES]; /* receive connection states */
|
||||
};
|
||||
/* flag values */
|
||||
#define SLF_TOSS 1 /* tossing rcvd frames because of input err */
|
||||
|
||||
void sl_compress_init __P((struct slcompress *));
|
||||
void sl_compress_setup __P((struct slcompress *, int));
|
||||
u_int sl_compress_tcp __P((struct mbuf *,
|
||||
struct ip *, struct slcompress *, int));
|
||||
int sl_uncompress_tcp __P((u_char **, int, u_int, struct slcompress *));
|
||||
int sl_uncompress_tcp_core __P((u_char *, int, int, u_int,
|
||||
struct slcompress *, u_char **, u_int *));
|
||||
|
||||
#endif /* _SLCOMPRESS_H_ */
|
||||
144
vendor/aw/homlet/external/pppoe/pppd/include/net/vjcompress.h
vendored
Normal file
144
vendor/aw/homlet/external/pppoe/pppd/include/net/vjcompress.h
vendored
Normal file
@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Definitions for tcp compression routines.
|
||||
*
|
||||
* $Id: vjcompress.h,v 1.3 1996/05/28 00:55:33 paulus Exp $
|
||||
*
|
||||
* Copyright (c) 1989 Regents of the University of California.
|
||||
* 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 University of California, Berkeley. The name of the
|
||||
* University 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.
|
||||
*
|
||||
* Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989:
|
||||
* - Initial distribution.
|
||||
*/
|
||||
|
||||
#ifndef _VJCOMPRESS_H_
|
||||
#define _VJCOMPRESS_H_
|
||||
|
||||
#define MAX_STATES 16 /* must be > 2 and < 256 */
|
||||
#define MAX_HDR 128
|
||||
|
||||
/*
|
||||
* Compressed packet format:
|
||||
*
|
||||
* The first octet contains the packet type (top 3 bits), TCP
|
||||
* 'push' bit, and flags that indicate which of the 4 TCP sequence
|
||||
* numbers have changed (bottom 5 bits). The next octet is a
|
||||
* conversation number that associates a saved IP/TCP header with
|
||||
* the compressed packet. The next two octets are the TCP checksum
|
||||
* from the original datagram. The next 0 to 15 octets are
|
||||
* sequence number changes, one change per bit set in the header
|
||||
* (there may be no changes and there are two special cases where
|
||||
* the receiver implicitly knows what changed -- see below).
|
||||
*
|
||||
* There are 5 numbers which can change (they are always inserted
|
||||
* in the following order): TCP urgent pointer, window,
|
||||
* acknowlegement, sequence number and IP ID. (The urgent pointer
|
||||
* is different from the others in that its value is sent, not the
|
||||
* change in value.) Since typical use of SLIP links is biased
|
||||
* toward small packets (see comments on MTU/MSS below), changes
|
||||
* use a variable length coding with one octet for numbers in the
|
||||
* range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the
|
||||
* range 256 - 65535 or 0. (If the change in sequence number or
|
||||
* ack is more than 65535, an uncompressed packet is sent.)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Packet types (must not conflict with IP protocol version)
|
||||
*
|
||||
* The top nibble of the first octet is the packet type. There are
|
||||
* three possible types: IP (not proto TCP or tcp with one of the
|
||||
* control flags set); uncompressed TCP (a normal IP/TCP packet but
|
||||
* with the 8-bit protocol field replaced by an 8-bit connection id --
|
||||
* this type of packet syncs the sender & receiver); and compressed
|
||||
* TCP (described above).
|
||||
*
|
||||
* LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and
|
||||
* is logically part of the 4-bit "changes" field that follows. Top
|
||||
* three bits are actual packet type. For backward compatibility
|
||||
* and in the interest of conserving bits, numbers are chosen so the
|
||||
* IP protocol version number (4) which normally appears in this nibble
|
||||
* means "IP packet".
|
||||
*/
|
||||
|
||||
/* packet types */
|
||||
#define TYPE_IP 0x40
|
||||
#define TYPE_UNCOMPRESSED_TCP 0x70
|
||||
#define TYPE_COMPRESSED_TCP 0x80
|
||||
#define TYPE_ERROR 0x00
|
||||
|
||||
/* Bits in first octet of compressed packet */
|
||||
#define NEW_C 0x40 /* flag bits for what changed in a packet */
|
||||
#define NEW_I 0x20
|
||||
#define NEW_S 0x08
|
||||
#define NEW_A 0x04
|
||||
#define NEW_W 0x02
|
||||
#define NEW_U 0x01
|
||||
|
||||
/* reserved, special-case values of above */
|
||||
#define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */
|
||||
#define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */
|
||||
#define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U)
|
||||
|
||||
#define TCP_PUSH_BIT 0x10
|
||||
|
||||
|
||||
/*
|
||||
* "state" data for each active tcp conversation on the wire. This is
|
||||
* basically a copy of the entire IP/TCP header from the last packet
|
||||
* we saw from the conversation together with a small identifier
|
||||
* the transmit & receive ends of the line use to locate saved header.
|
||||
*/
|
||||
struct cstate {
|
||||
struct cstate *cs_next; /* next most recently used state (xmit only) */
|
||||
u_short cs_hlen; /* size of hdr (receive only) */
|
||||
u_char cs_id; /* connection # associated with this state */
|
||||
u_char cs_filler;
|
||||
union {
|
||||
char csu_hdr[MAX_HDR];
|
||||
struct ip csu_ip; /* ip/tcp hdr from most recent packet */
|
||||
} vjcs_u;
|
||||
};
|
||||
#define cs_ip vjcs_u.csu_ip
|
||||
#define cs_hdr vjcs_u.csu_hdr
|
||||
|
||||
/*
|
||||
* all the state data for one serial line (we need one of these per line).
|
||||
*/
|
||||
struct vjcompress {
|
||||
struct cstate *last_cs; /* most recently used tstate */
|
||||
u_char last_recv; /* last rcvd conn. id */
|
||||
u_char last_xmit; /* last sent conn. id */
|
||||
u_short flags;
|
||||
#ifndef VJ_NO_STATS
|
||||
struct vjstat stats;
|
||||
#endif
|
||||
struct cstate tstate[MAX_STATES]; /* xmit connection states */
|
||||
struct cstate rstate[MAX_STATES]; /* receive connection states */
|
||||
};
|
||||
|
||||
/* flag values */
|
||||
#define VJF_TOSS 1 /* tossing rcvd frames because of input err */
|
||||
|
||||
extern void vj_compress_init __P((struct vjcompress *comp, int max_state));
|
||||
extern u_int vj_compress_tcp __P((struct ip *ip, u_int mlen,
|
||||
struct vjcompress *comp, int compress_cid_flag,
|
||||
u_char **vjhdrp));
|
||||
extern void vj_uncompress_err __P((struct vjcompress *comp));
|
||||
extern int vj_uncompress_uncomp __P((u_char *buf, int buflen,
|
||||
struct vjcompress *comp));
|
||||
extern int vj_uncompress_tcp __P((u_char *buf, int buflen, int total_len,
|
||||
struct vjcompress *comp, u_char **hdrp,
|
||||
u_int *hlenp));
|
||||
|
||||
#endif /* _VJCOMPRESS_H_ */
|
||||
117
vendor/aw/homlet/external/pppoe/pppd/include/pcap-int.h
vendored
Normal file
117
vendor/aw/homlet/external/pppoe/pppd/include/pcap-int.h
vendored
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 1995, 1996
|
||||
* 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 Computer Systems
|
||||
* Engineering Group at Lawrence Berkeley Laboratory.
|
||||
* 4. Neither the name of the University nor of the Laboratory 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.
|
||||
*
|
||||
* @(#) $Header: /data/cvs/ppp/include/pcap-int.h,v 1.1 2000/08/01 01:37:24 paulus Exp $ (LBL)
|
||||
*/
|
||||
|
||||
#ifndef pcap_int_h
|
||||
#define pcap_int_h
|
||||
|
||||
#include <pcap.h>
|
||||
|
||||
/*
|
||||
* Savefile
|
||||
*/
|
||||
struct pcap_sf {
|
||||
FILE *rfile;
|
||||
int swapped;
|
||||
int version_major;
|
||||
int version_minor;
|
||||
u_char *base;
|
||||
};
|
||||
|
||||
struct pcap_md {
|
||||
struct pcap_stat stat;
|
||||
/*XXX*/
|
||||
int use_bpf;
|
||||
u_long TotPkts; /* can't oflow for 79 hrs on ether */
|
||||
u_long TotAccepted; /* count accepted by filter */
|
||||
u_long TotDrops; /* count of dropped packets */
|
||||
long TotMissed; /* missed by i/f during this run */
|
||||
long OrigMissed; /* missed by i/f before this run */
|
||||
#ifdef linux
|
||||
int pad;
|
||||
int skip;
|
||||
char *device;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct pcap {
|
||||
int fd;
|
||||
int snapshot;
|
||||
int linktype;
|
||||
int tzoff; /* timezone offset */
|
||||
int offset; /* offset for proper alignment */
|
||||
|
||||
struct pcap_sf sf;
|
||||
struct pcap_md md;
|
||||
|
||||
/*
|
||||
* Read buffer.
|
||||
*/
|
||||
int bufsize;
|
||||
u_char *buffer;
|
||||
u_char *bp;
|
||||
int cc;
|
||||
|
||||
/*
|
||||
* Place holder for pcap_next().
|
||||
*/
|
||||
u_char *pkt;
|
||||
|
||||
|
||||
/*
|
||||
* Placeholder for filter code if bpf not in kernel.
|
||||
*/
|
||||
struct bpf_program fcode;
|
||||
|
||||
char errbuf[PCAP_ERRBUF_SIZE];
|
||||
};
|
||||
|
||||
int yylex(void);
|
||||
|
||||
#ifndef min
|
||||
#define min(a, b) ((a) > (b) ? (b) : (a))
|
||||
#endif
|
||||
|
||||
/* XXX should these be in pcap.h? */
|
||||
int pcap_offline_read(pcap_t *, int, pcap_handler, u_char *);
|
||||
int pcap_read(pcap_t *, int cnt, pcap_handler, u_char *);
|
||||
|
||||
/* Ultrix pads to make everything line up on a nice boundary */
|
||||
#if defined(ultrix) || defined(__alpha)
|
||||
#define PCAP_FDDIPAD 3
|
||||
#endif
|
||||
|
||||
/* XXX */
|
||||
extern int pcap_fddipad;
|
||||
#endif
|
||||
2196
vendor/aw/homlet/external/pppoe/pppd/ipcp.c
vendored
Normal file
2196
vendor/aw/homlet/external/pppoe/pppd/ipcp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
96
vendor/aw/homlet/external/pppoe/pppd/ipcp.h
vendored
Normal file
96
vendor/aw/homlet/external/pppoe/pppd/ipcp.h
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipcp.h,v 1.14 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_ADDRS 1 /* IP Addresses */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
#define CI_ADDR 3
|
||||
|
||||
#define CI_MS_DNS1 129 /* Primary DNS value */
|
||||
#define CI_MS_WINS1 130 /* Primary WINS value */
|
||||
#define CI_MS_DNS2 131 /* Secondary DNS value */
|
||||
#define CI_MS_WINS2 132 /* Secondary WINS value */
|
||||
|
||||
#define MAX_STATES 16 /* from slcompress.h */
|
||||
|
||||
#define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */
|
||||
#define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */
|
||||
#define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */
|
||||
/* maxslot and slot number compression) */
|
||||
|
||||
#define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/
|
||||
#define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */
|
||||
/* compression option*/
|
||||
|
||||
typedef struct ipcp_options {
|
||||
bool neg_addr; /* Negotiate IP Address? */
|
||||
bool old_addrs; /* Use old (IP-Addresses) option? */
|
||||
bool req_addr; /* Ask peer to send IP address? */
|
||||
bool default_route; /* Assign default route through interface? */
|
||||
bool proxy_arp; /* Make proxy ARP entry for peer? */
|
||||
bool neg_vj; /* Van Jacobson Compression? */
|
||||
bool old_vj; /* use old (short) form of VJ option? */
|
||||
bool accept_local; /* accept peer's value for ouraddr */
|
||||
bool accept_remote; /* accept peer's value for hisaddr */
|
||||
bool req_dns1; /* Ask peer to send primary DNS address? */
|
||||
bool req_dns2; /* Ask peer to send secondary DNS address? */
|
||||
int vj_protocol; /* protocol value to use in VJ option */
|
||||
int maxslotindex; /* values for RFC1332 VJ compression neg. */
|
||||
bool cflag;
|
||||
u_int32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */
|
||||
u_int32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */
|
||||
u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
} ipcp_options;
|
||||
|
||||
extern fsm ipcp_fsm[];
|
||||
extern ipcp_options ipcp_wantoptions[];
|
||||
extern ipcp_options ipcp_gotoptions[];
|
||||
extern ipcp_options ipcp_allowoptions[];
|
||||
extern ipcp_options ipcp_hisoptions[];
|
||||
|
||||
char *ip_ntoa __P((u_int32_t));
|
||||
|
||||
extern struct protent ipcp_protent;
|
||||
1561
vendor/aw/homlet/external/pppoe/pppd/ipv6cp.c
vendored
Normal file
1561
vendor/aw/homlet/external/pppoe/pppd/ipv6cp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
171
vendor/aw/homlet/external/pppoe/pppd/ipv6cp.h
vendored
Normal file
171
vendor/aw/homlet/external/pppoe/pppd/ipv6cp.h
vendored
Normal file
@ -0,0 +1,171 @@
|
||||
/*
|
||||
* ipv6cp.h - PPP IPV6 Control Protocol.
|
||||
*
|
||||
* Copyright (c) 1999 Tommi Komulainen. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Tommi Komulainen
|
||||
* <Tommi.Komulainen@iki.fi>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Original version, based on RFC2023 :
|
||||
|
||||
Copyright (c) 1995, 1996, 1997 Francis.Dupont@inria.fr, INRIA Rocquencourt,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Copyright (c) 1998, 1999 Francis.Dupont@inria.fr, GIE DYADE,
|
||||
Alain.Durand@imag.fr, IMAG,
|
||||
Jean-Luc.Richier@imag.fr, IMAG-LSR.
|
||||
|
||||
Ce travail a été fait au sein du GIE DYADE (Groupement d'Intérêt
|
||||
Économique ayant pour membres BULL S.A. et l'INRIA).
|
||||
|
||||
Ce logiciel informatique est disponible aux conditions
|
||||
usuelles dans la recherche, c'est-à-dire qu'il peut
|
||||
être utilisé, copié, modifié, distribué à l'unique
|
||||
condition que ce texte soit conservé afin que
|
||||
l'origine de ce logiciel soit reconnue.
|
||||
|
||||
Le nom de l'Institut National de Recherche en Informatique
|
||||
et en Automatique (INRIA), de l'IMAG, ou d'une personne morale
|
||||
ou physique ayant participé à l'élaboration de ce logiciel ne peut
|
||||
être utilisé sans son accord préalable explicite.
|
||||
|
||||
Ce logiciel est fourni tel quel sans aucune garantie,
|
||||
support ou responsabilité d'aucune sorte.
|
||||
Ce logiciel est dérivé de sources d'origine
|
||||
"University of California at Berkeley" et
|
||||
"Digital Equipment Corporation" couvertes par des copyrights.
|
||||
|
||||
L'Institut d'Informatique et de Mathématiques Appliquées de Grenoble (IMAG)
|
||||
est une fédération d'unités mixtes de recherche du CNRS, de l'Institut National
|
||||
Polytechnique de Grenoble et de l'Université Joseph Fourier regroupant
|
||||
sept laboratoires dont le laboratoire Logiciels, Systèmes, Réseaux (LSR).
|
||||
|
||||
This work has been done in the context of GIE DYADE (joint R & D venture
|
||||
between BULL S.A. and INRIA).
|
||||
|
||||
This software is available with usual "research" terms
|
||||
with the aim of retain credits of the software.
|
||||
Permission to use, copy, modify and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies,
|
||||
and the name of INRIA, IMAG, or any contributor not be used in advertising
|
||||
or publicity pertaining to this material without the prior explicit
|
||||
permission. The software is provided "as is" without any
|
||||
warranties, support or liabilities of any kind.
|
||||
This software is derived from source code from
|
||||
"University of California at Berkeley" and
|
||||
"Digital Equipment Corporation" protected by copyrights.
|
||||
|
||||
Grenoble's Institute of Computer Science and Applied Mathematics (IMAG)
|
||||
is a federation of seven research units funded by the CNRS, National
|
||||
Polytechnic Institute of Grenoble and University Joseph Fourier.
|
||||
The research unit in Software, Systems, Networks (LSR) is member of IMAG.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Derived from :
|
||||
*
|
||||
*
|
||||
* ipcp.h - IP Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipv6cp.h,v 1.7 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_IFACEID 1 /* Interface Identifier */
|
||||
#define CI_COMPRESSTYPE 2 /* Compression Type */
|
||||
|
||||
/* No compression types yet defined.
|
||||
*#define IPV6CP_COMP 0x004f
|
||||
*/
|
||||
typedef struct ipv6cp_options {
|
||||
int neg_ifaceid; /* Negotiate interface identifier? */
|
||||
int req_ifaceid; /* Ask peer to send interface identifier? */
|
||||
int accept_local; /* accept peer's value for iface id? */
|
||||
int opt_local; /* ourtoken set by option */
|
||||
int opt_remote; /* histoken set by option */
|
||||
int use_ip; /* use IP as interface identifier */
|
||||
#if defined(SOL2) || defined(__linux__)
|
||||
int use_persistent; /* use uniquely persistent value for address */
|
||||
#endif /* defined(SOL2) */
|
||||
int neg_vj; /* Van Jacobson Compression? */
|
||||
u_short vj_protocol; /* protocol value to use in VJ option */
|
||||
eui64_t ourid, hisid; /* Interface identifiers */
|
||||
} ipv6cp_options;
|
||||
|
||||
extern fsm ipv6cp_fsm[];
|
||||
extern ipv6cp_options ipv6cp_wantoptions[];
|
||||
extern ipv6cp_options ipv6cp_gotoptions[];
|
||||
extern ipv6cp_options ipv6cp_allowoptions[];
|
||||
extern ipv6cp_options ipv6cp_hisoptions[];
|
||||
|
||||
extern struct protent ipv6cp_protent;
|
||||
1598
vendor/aw/homlet/external/pppoe/pppd/ipxcp.c
vendored
Normal file
1598
vendor/aw/homlet/external/pppoe/pppd/ipxcp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
94
vendor/aw/homlet/external/pppoe/pppd/ipxcp.h
vendored
Normal file
94
vendor/aw/homlet/external/pppoe/pppd/ipxcp.h
vendored
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* ipxcp.h - IPX Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: ipxcp.h,v 1.5 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define IPX_NETWORK_NUMBER 1 /* IPX Network Number */
|
||||
#define IPX_NODE_NUMBER 2
|
||||
#define IPX_COMPRESSION_PROTOCOL 3
|
||||
#define IPX_ROUTER_PROTOCOL 4
|
||||
#define IPX_ROUTER_NAME 5
|
||||
#define IPX_COMPLETE 6
|
||||
|
||||
/* Values for the router protocol */
|
||||
#define IPX_NONE 0
|
||||
#define RIP_SAP 2
|
||||
#define NLSP 4
|
||||
|
||||
typedef struct ipxcp_options {
|
||||
bool neg_node; /* Negotiate IPX node number? */
|
||||
bool req_node; /* Ask peer to send IPX node number? */
|
||||
|
||||
bool neg_nn; /* Negotiate IPX network number? */
|
||||
bool req_nn; /* Ask peer to send IPX network number */
|
||||
|
||||
bool neg_name; /* Negotiate IPX router name */
|
||||
bool neg_complete; /* Negotiate completion */
|
||||
bool neg_router; /* Negotiate IPX router number */
|
||||
|
||||
bool accept_local; /* accept peer's value for ournode */
|
||||
bool accept_remote; /* accept peer's value for hisnode */
|
||||
bool accept_network; /* accept network number */
|
||||
|
||||
bool tried_nlsp; /* I have suggested NLSP already */
|
||||
bool tried_rip; /* I have suggested RIP/SAP already */
|
||||
|
||||
u_int32_t his_network; /* base network number */
|
||||
u_int32_t our_network; /* our value for network number */
|
||||
u_int32_t network; /* the final network number */
|
||||
|
||||
u_char his_node[6]; /* peer's node number */
|
||||
u_char our_node[6]; /* our node number */
|
||||
u_char name [48]; /* name of the router */
|
||||
int router; /* routing protocol */
|
||||
} ipxcp_options;
|
||||
|
||||
extern fsm ipxcp_fsm[];
|
||||
extern ipxcp_options ipxcp_wantoptions[];
|
||||
extern ipxcp_options ipxcp_gotoptions[];
|
||||
extern ipxcp_options ipxcp_allowoptions[];
|
||||
extern ipxcp_options ipxcp_hisoptions[];
|
||||
|
||||
extern struct protent ipxcp_protent;
|
||||
2338
vendor/aw/homlet/external/pppoe/pppd/lcp.c
vendored
Normal file
2338
vendor/aw/homlet/external/pppoe/pppd/lcp.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
119
vendor/aw/homlet/external/pppoe/pppd/lcp.h
vendored
Normal file
119
vendor/aw/homlet/external/pppoe/pppd/lcp.h
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* lcp.h - Link Control Protocol definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: lcp.h,v 1.19 2002/12/04 23:03:32 paulus Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
#define CI_MRU 1 /* Maximum Receive Unit */
|
||||
#define CI_ASYNCMAP 2 /* Async Control Character Map */
|
||||
#define CI_AUTHTYPE 3 /* Authentication Type */
|
||||
#define CI_QUALITY 4 /* Quality Protocol */
|
||||
#define CI_MAGICNUMBER 5 /* Magic Number */
|
||||
#define CI_PCOMPRESSION 7 /* Protocol Field Compression */
|
||||
#define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */
|
||||
#define CI_CALLBACK 13 /* callback */
|
||||
#define CI_MRRU 17 /* max reconstructed receive unit; multilink */
|
||||
#define CI_SSNHF 18 /* short sequence numbers for multilink */
|
||||
#define CI_EPDISC 19 /* endpoint discriminator */
|
||||
|
||||
/*
|
||||
* LCP-specific packet types.
|
||||
*/
|
||||
#define PROTREJ 8 /* Protocol Reject */
|
||||
#define ECHOREQ 9 /* Echo Request */
|
||||
#define ECHOREP 10 /* Echo Reply */
|
||||
#define DISCREQ 11 /* Discard Request */
|
||||
#define CBCP_OPT 6 /* Use callback control protocol */
|
||||
|
||||
/*
|
||||
* The state of options is described by an lcp_options structure.
|
||||
*/
|
||||
typedef struct lcp_options {
|
||||
bool passive; /* Don't die if we don't get a response */
|
||||
bool silent; /* Wait for the other end to start first */
|
||||
bool restart; /* Restart vs. exit after close */
|
||||
bool neg_mru; /* Negotiate the MRU? */
|
||||
bool neg_asyncmap; /* Negotiate the async map? */
|
||||
bool neg_upap; /* Ask for UPAP authentication? */
|
||||
bool neg_chap; /* Ask for CHAP authentication? */
|
||||
bool neg_eap; /* Ask for EAP authentication? */
|
||||
bool neg_magicnumber; /* Ask for magic number? */
|
||||
bool neg_pcompression; /* HDLC Protocol Field Compression? */
|
||||
bool neg_accompression; /* HDLC Address/Control Field Compression? */
|
||||
bool neg_lqr; /* Negotiate use of Link Quality Reports */
|
||||
bool neg_cbcp; /* Negotiate use of CBCP */
|
||||
bool neg_mrru; /* negotiate multilink MRRU */
|
||||
bool neg_ssnhf; /* negotiate short sequence numbers */
|
||||
bool neg_endpoint; /* negotiate endpoint discriminator */
|
||||
int mru; /* Value of MRU */
|
||||
int mrru; /* Value of MRRU, and multilink enable */
|
||||
u_char chap_mdtype; /* which MD types (hashing algorithm) */
|
||||
u_int32_t asyncmap; /* Value of async map */
|
||||
u_int32_t magicnumber;
|
||||
int numloops; /* Number of loops during magic number neg. */
|
||||
u_int32_t lqr_period; /* Reporting period for LQR 1/100ths second */
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
extern fsm lcp_fsm[];
|
||||
extern lcp_options lcp_wantoptions[];
|
||||
extern lcp_options lcp_gotoptions[];
|
||||
extern lcp_options lcp_allowoptions[];
|
||||
extern lcp_options lcp_hisoptions[];
|
||||
|
||||
#define DEFMRU 1500 /* Try for this */
|
||||
#define MINMRU 128 /* No MRUs below this */
|
||||
#define MAXMRU 16384 /* Normally limit MRU to this */
|
||||
|
||||
void lcp_open __P((int));
|
||||
void lcp_close __P((int, char *));
|
||||
void lcp_lowerup __P((int));
|
||||
void lcp_lowerdown __P((int));
|
||||
void lcp_sprotrej __P((int, u_char *, int)); /* send protocol reject */
|
||||
|
||||
extern struct protent lcp_protent;
|
||||
|
||||
/* Default number of times we receive our magic number from the peer
|
||||
before deciding the link is looped-back. */
|
||||
#define DEFLOOPBACKFAIL 10
|
||||
123
vendor/aw/homlet/external/pppoe/pppd/magic.c
vendored
Normal file
123
vendor/aw/homlet/external/pppoe/pppd/magic.c
vendored
Normal file
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* magic.c - PPP Magic Number routines.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define RCSID "$Id: magic.c,v 1.11 2003/06/11 23:56:26 paulus Exp $"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "pppd.h"
|
||||
#include "magic.h"
|
||||
|
||||
static const char rcsid[] = RCSID;
|
||||
|
||||
extern long mrand48 __P((void));
|
||||
extern void srand48 __P((long));
|
||||
|
||||
/*
|
||||
* magic_init - Initialize the magic number generator.
|
||||
*
|
||||
* Attempts to compute a random number seed which will not repeat.
|
||||
* The current method uses the current hostid, current process ID
|
||||
* and current time, currently.
|
||||
*/
|
||||
void
|
||||
magic_init()
|
||||
{
|
||||
long seed;
|
||||
struct timeval t;
|
||||
|
||||
gettimeofday(&t, NULL);
|
||||
seed = get_host_seed() ^ t.tv_sec ^ t.tv_usec ^ getpid();
|
||||
srand48(seed);
|
||||
}
|
||||
|
||||
/*
|
||||
* magic - Returns the next magic number.
|
||||
*/
|
||||
u_int32_t
|
||||
magic()
|
||||
{
|
||||
return (u_int32_t) mrand48();
|
||||
}
|
||||
|
||||
/*
|
||||
* random_bytes - Fill a buffer with random bytes.
|
||||
*/
|
||||
void
|
||||
random_bytes(unsigned char *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; ++i)
|
||||
buf[i] = mrand48() >> 24;
|
||||
}
|
||||
|
||||
#ifdef NO_DRAND48
|
||||
/*
|
||||
* Substitute procedures for those systems which don't have
|
||||
* drand48 et al.
|
||||
*/
|
||||
|
||||
double
|
||||
drand48()
|
||||
{
|
||||
return (double)random() / (double)0x7fffffffL; /* 2**31-1 */
|
||||
}
|
||||
|
||||
long
|
||||
mrand48()
|
||||
{
|
||||
return random();
|
||||
}
|
||||
|
||||
void
|
||||
srand48(seedval)
|
||||
long seedval;
|
||||
{
|
||||
srandom((int)seedval);
|
||||
}
|
||||
|
||||
#endif
|
||||
49
vendor/aw/homlet/external/pppoe/pppd/magic.h
vendored
Normal file
49
vendor/aw/homlet/external/pppoe/pppd/magic.h
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* magic.h - PPP Magic Number definitions.
|
||||
*
|
||||
* Copyright (c) 1984-2000 Carnegie Mellon University. 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. The name "Carnegie Mellon University" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For permission or any legal
|
||||
* details, please contact
|
||||
* Office of Technology Transfer
|
||||
* Carnegie Mellon University
|
||||
* 5000 Forbes Avenue
|
||||
* Pittsburgh, PA 15213-3890
|
||||
* (412) 268-4387, fax: (412) 268-7395
|
||||
* tech-transfer@andrew.cmu.edu
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Computing Services
|
||||
* at Carnegie Mellon University (http://www.cmu.edu/computing/)."
|
||||
*
|
||||
* CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
|
||||
* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* $Id: magic.h,v 1.5 2003/06/11 23:56:26 paulus Exp $
|
||||
*/
|
||||
|
||||
void magic_init __P((void)); /* Initialize the magic number generator */
|
||||
u_int32_t magic __P((void)); /* Returns the next magic number */
|
||||
|
||||
/* Fill buffer with random bytes */
|
||||
void random_bytes __P((unsigned char *buf, int len));
|
||||
2141
vendor/aw/homlet/external/pppoe/pppd/main.c
vendored
Normal file
2141
vendor/aw/homlet/external/pppoe/pppd/main.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
298
vendor/aw/homlet/external/pppoe/pppd/md4.c
vendored
Normal file
298
vendor/aw/homlet/external/pppoe/pppd/md4.c
vendored
Normal file
@ -0,0 +1,298 @@
|
||||
/*
|
||||
** ********************************************************************
|
||||
** md4.c -- Implementation of MD4 Message Digest Algorithm **
|
||||
** Updated: 2/16/90 by Ronald L. Rivest **
|
||||
** (C) 1990 RSA Data Security, Inc. **
|
||||
** ********************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
** To use MD4:
|
||||
** -- Include md4.h in your program
|
||||
** -- Declare an MDstruct MD to hold the state of the digest
|
||||
** computation.
|
||||
** -- Initialize MD using MDbegin(&MD)
|
||||
** -- For each full block (64 bytes) X you wish to process, call
|
||||
** MD4Update(&MD,X,512)
|
||||
** (512 is the number of bits in a full block.)
|
||||
** -- For the last block (less than 64 bytes) you wish to process,
|
||||
** MD4Update(&MD,X,n)
|
||||
** where n is the number of bits in the partial block. A partial
|
||||
** block terminates the computation, so every MD computation
|
||||
** should terminate by processing a partial block, even if it
|
||||
** has n = 0.
|
||||
** -- The message digest is available in MD.buffer[0] ...
|
||||
** MD.buffer[3]. (Least-significant byte of each word
|
||||
** should be output first.)
|
||||
** -- You can print out the digest using MDprint(&MD)
|
||||
*/
|
||||
|
||||
/* Implementation notes:
|
||||
** This implementation assumes that ints are 32-bit quantities.
|
||||
*/
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* Compile-time includes
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "md4.h"
|
||||
#include "pppd.h"
|
||||
|
||||
/* Compile-time declarations of MD4 "magic constants".
|
||||
*/
|
||||
#define I0 0x67452301 /* Initial values for MD buffer */
|
||||
#define I1 0xefcdab89
|
||||
#define I2 0x98badcfe
|
||||
#define I3 0x10325476
|
||||
#define C2 013240474631 /* round 2 constant = sqrt(2) in octal */
|
||||
#define C3 015666365641 /* round 3 constant = sqrt(3) in octal */
|
||||
/* C2 and C3 are from Knuth, The Art of Programming, Volume 2
|
||||
** (Seminumerical Algorithms), Second Edition (1981), Addison-Wesley.
|
||||
** Table 2, page 660.
|
||||
*/
|
||||
|
||||
#define fs1 3 /* round 1 shift amounts */
|
||||
#define fs2 7
|
||||
#define fs3 11
|
||||
#define fs4 19
|
||||
#define gs1 3 /* round 2 shift amounts */
|
||||
#define gs2 5
|
||||
#define gs3 9
|
||||
#define gs4 13
|
||||
#define hs1 3 /* round 3 shift amounts */
|
||||
#define hs2 9
|
||||
#define hs3 11
|
||||
#define hs4 15
|
||||
|
||||
/* Compile-time macro declarations for MD4.
|
||||
** Note: The "rot" operator uses the variable "tmp".
|
||||
** It assumes tmp is declared as unsigned int, so that the >>
|
||||
** operator will shift in zeros rather than extending the sign bit.
|
||||
*/
|
||||
#define f(X,Y,Z) ((X&Y) | ((~X)&Z))
|
||||
#define g(X,Y,Z) ((X&Y) | (X&Z) | (Y&Z))
|
||||
#define h(X,Y,Z) (X^Y^Z)
|
||||
#define rot(X,S) (tmp=X,(tmp<<S) | (tmp>>(32-S)))
|
||||
#define ff(A,B,C,D,i,s) A = rot((A + f(B,C,D) + X[i]),s)
|
||||
#define gg(A,B,C,D,i,s) A = rot((A + g(B,C,D) + X[i] + C2),s)
|
||||
#define hh(A,B,C,D,i,s) A = rot((A + h(B,C,D) + X[i] + C3),s)
|
||||
|
||||
/* MD4print(MDp)
|
||||
** Print message digest buffer MDp as 32 hexadecimal digits.
|
||||
** Order is from low-order byte of buffer[0] to high-order byte of
|
||||
** buffer[3].
|
||||
** Each byte is printed with high-order hexadecimal digit first.
|
||||
** This is a user-callable routine.
|
||||
*/
|
||||
void
|
||||
MD4Print(MDp)
|
||||
MD4_CTX *MDp;
|
||||
{
|
||||
int i,j;
|
||||
for (i=0;i<4;i++)
|
||||
for (j=0;j<32;j=j+8)
|
||||
printf("%02x",(MDp->buffer[i]>>j) & 0xFF);
|
||||
}
|
||||
|
||||
/* MD4Init(MDp)
|
||||
** Initialize message digest buffer MDp.
|
||||
** This is a user-callable routine.
|
||||
*/
|
||||
void
|
||||
MD4Init(MDp)
|
||||
MD4_CTX *MDp;
|
||||
{
|
||||
int i;
|
||||
MDp->buffer[0] = I0;
|
||||
MDp->buffer[1] = I1;
|
||||
MDp->buffer[2] = I2;
|
||||
MDp->buffer[3] = I3;
|
||||
for (i=0;i<8;i++) MDp->count[i] = 0;
|
||||
MDp->done = 0;
|
||||
}
|
||||
|
||||
/* MDblock(MDp,X)
|
||||
** Update message digest buffer MDp->buffer using 16-word data block X.
|
||||
** Assumes all 16 words of X are full of data.
|
||||
** Does not update MDp->count.
|
||||
** This routine is not user-callable.
|
||||
*/
|
||||
static void
|
||||
MDblock(MDp,Xb)
|
||||
MD4_CTX *MDp;
|
||||
unsigned char *Xb;
|
||||
{
|
||||
register unsigned int tmp, A, B, C, D;
|
||||
unsigned int X[16];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 16; ++i) {
|
||||
X[i] = Xb[0] + (Xb[1] << 8) + (Xb[2] << 16) + (Xb[3] << 24);
|
||||
Xb += 4;
|
||||
}
|
||||
|
||||
A = MDp->buffer[0];
|
||||
B = MDp->buffer[1];
|
||||
C = MDp->buffer[2];
|
||||
D = MDp->buffer[3];
|
||||
/* Update the message digest buffer */
|
||||
ff(A , B , C , D , 0 , fs1); /* Round 1 */
|
||||
ff(D , A , B , C , 1 , fs2);
|
||||
ff(C , D , A , B , 2 , fs3);
|
||||
ff(B , C , D , A , 3 , fs4);
|
||||
ff(A , B , C , D , 4 , fs1);
|
||||
ff(D , A , B , C , 5 , fs2);
|
||||
ff(C , D , A , B , 6 , fs3);
|
||||
ff(B , C , D , A , 7 , fs4);
|
||||
ff(A , B , C , D , 8 , fs1);
|
||||
ff(D , A , B , C , 9 , fs2);
|
||||
ff(C , D , A , B , 10 , fs3);
|
||||
ff(B , C , D , A , 11 , fs4);
|
||||
ff(A , B , C , D , 12 , fs1);
|
||||
ff(D , A , B , C , 13 , fs2);
|
||||
ff(C , D , A , B , 14 , fs3);
|
||||
ff(B , C , D , A , 15 , fs4);
|
||||
gg(A , B , C , D , 0 , gs1); /* Round 2 */
|
||||
gg(D , A , B , C , 4 , gs2);
|
||||
gg(C , D , A , B , 8 , gs3);
|
||||
gg(B , C , D , A , 12 , gs4);
|
||||
gg(A , B , C , D , 1 , gs1);
|
||||
gg(D , A , B , C , 5 , gs2);
|
||||
gg(C , D , A , B , 9 , gs3);
|
||||
gg(B , C , D , A , 13 , gs4);
|
||||
gg(A , B , C , D , 2 , gs1);
|
||||
gg(D , A , B , C , 6 , gs2);
|
||||
gg(C , D , A , B , 10 , gs3);
|
||||
gg(B , C , D , A , 14 , gs4);
|
||||
gg(A , B , C , D , 3 , gs1);
|
||||
gg(D , A , B , C , 7 , gs2);
|
||||
gg(C , D , A , B , 11 , gs3);
|
||||
gg(B , C , D , A , 15 , gs4);
|
||||
hh(A , B , C , D , 0 , hs1); /* Round 3 */
|
||||
hh(D , A , B , C , 8 , hs2);
|
||||
hh(C , D , A , B , 4 , hs3);
|
||||
hh(B , C , D , A , 12 , hs4);
|
||||
hh(A , B , C , D , 2 , hs1);
|
||||
hh(D , A , B , C , 10 , hs2);
|
||||
hh(C , D , A , B , 6 , hs3);
|
||||
hh(B , C , D , A , 14 , hs4);
|
||||
hh(A , B , C , D , 1 , hs1);
|
||||
hh(D , A , B , C , 9 , hs2);
|
||||
hh(C , D , A , B , 5 , hs3);
|
||||
hh(B , C , D , A , 13 , hs4);
|
||||
hh(A , B , C , D , 3 , hs1);
|
||||
hh(D , A , B , C , 11 , hs2);
|
||||
hh(C , D , A , B , 7 , hs3);
|
||||
hh(B , C , D , A , 15 , hs4);
|
||||
MDp->buffer[0] += A;
|
||||
MDp->buffer[1] += B;
|
||||
MDp->buffer[2] += C;
|
||||
MDp->buffer[3] += D;
|
||||
}
|
||||
|
||||
/* MD4Update(MDp,X,count)
|
||||
** Input: X -- a pointer to an array of unsigned characters.
|
||||
** count -- the number of bits of X to use.
|
||||
** (if not a multiple of 8, uses high bits of last byte.)
|
||||
** Update MDp using the number of bits of X given by count.
|
||||
** This is the basic input routine for an MD4 user.
|
||||
** The routine completes the MD computation when count < 512, so
|
||||
** every MD computation should end with one call to MD4Update with a
|
||||
** count less than 512. A call with count 0 will be ignored if the
|
||||
** MD has already been terminated (done != 0), so an extra call with
|
||||
** count 0 can be given as a "courtesy close" to force termination
|
||||
** if desired.
|
||||
*/
|
||||
void
|
||||
MD4Update(MDp,X,count)
|
||||
MD4_CTX *MDp;
|
||||
unsigned char *X;
|
||||
unsigned int count;
|
||||
{
|
||||
unsigned int i, tmp, bit, byte, mask;
|
||||
unsigned char XX[64];
|
||||
unsigned char *p;
|
||||
|
||||
/* return with no error if this is a courtesy close with count
|
||||
** zero and MDp->done is true.
|
||||
*/
|
||||
if (count == 0 && MDp->done) return;
|
||||
/* check to see if MD is already done and report error */
|
||||
if (MDp->done)
|
||||
{ printf("\nError: MD4Update MD already done."); return; }
|
||||
|
||||
/* Add count to MDp->count */
|
||||
tmp = count;
|
||||
p = MDp->count;
|
||||
while (tmp)
|
||||
{ tmp += *p;
|
||||
*p++ = tmp;
|
||||
tmp = tmp >> 8;
|
||||
}
|
||||
|
||||
/* Process data */
|
||||
if (count == 512)
|
||||
{ /* Full block of data to handle */
|
||||
MDblock(MDp,X);
|
||||
}
|
||||
else if (count > 512) /* Check for count too large */
|
||||
{
|
||||
printf("\nError: MD4Update called with illegal count value %d.",
|
||||
count);
|
||||
return;
|
||||
}
|
||||
else /* partial block -- must be last block so finish up */
|
||||
{
|
||||
/* Find out how many bytes and residual bits there are */
|
||||
byte = count >> 3;
|
||||
bit = count & 7;
|
||||
/* Copy X into XX since we need to modify it */
|
||||
for (i=0;i<=byte;i++) XX[i] = X[i];
|
||||
for (i=byte+1;i<64;i++) XX[i] = 0;
|
||||
/* Add padding '1' bit and low-order zeros in last byte */
|
||||
mask = 1 << (7 - bit);
|
||||
XX[byte] = (XX[byte] | mask) & ~( mask - 1);
|
||||
/* If room for bit count, finish up with this block */
|
||||
if (byte <= 55)
|
||||
{
|
||||
for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
|
||||
MDblock(MDp,XX);
|
||||
}
|
||||
else /* need to do two blocks to finish up */
|
||||
{
|
||||
MDblock(MDp,XX);
|
||||
for (i=0;i<56;i++) XX[i] = 0;
|
||||
for (i=0;i<8;i++) XX[56+i] = MDp->count[i];
|
||||
MDblock(MDp,XX);
|
||||
}
|
||||
/* Set flag saying we're done with MD computation */
|
||||
MDp->done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Finish up MD4 computation and return message digest.
|
||||
*/
|
||||
void
|
||||
MD4Final(buf, MD)
|
||||
unsigned char *buf;
|
||||
MD4_CTX *MD;
|
||||
{
|
||||
int i, j;
|
||||
unsigned int w;
|
||||
|
||||
MD4Update(MD, NULL, 0);
|
||||
for (i = 0; i < 4; ++i) {
|
||||
w = MD->buffer[i];
|
||||
for (j = 0; j < 4; ++j) {
|
||||
*buf++ = w;
|
||||
w >>= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** End of md4.c
|
||||
****************************(cut)***********************************/
|
||||
64
vendor/aw/homlet/external/pppoe/pppd/md4.h
vendored
Normal file
64
vendor/aw/homlet/external/pppoe/pppd/md4.h
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
/*
|
||||
** ********************************************************************
|
||||
** md4.h -- Header file for implementation of **
|
||||
** MD4 Message Digest Algorithm **
|
||||
** Updated: 2/13/90 by Ronald L. Rivest **
|
||||
** (C) 1990 RSA Data Security, Inc. **
|
||||
** ********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __P
|
||||
# if defined(__STDC__) || defined(__GNUC__)
|
||||
# define __P(x) x
|
||||
# else
|
||||
# define __P(x) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/* MDstruct is the data structure for a message digest computation.
|
||||
*/
|
||||
typedef struct {
|
||||
unsigned int buffer[4]; /* Holds 4-word result of MD computation */
|
||||
unsigned char count[8]; /* Number of bits processed so far */
|
||||
unsigned int done; /* Nonzero means MD computation finished */
|
||||
} MD4_CTX;
|
||||
|
||||
/* MD4Init(MD4_CTX *)
|
||||
** Initialize the MD4_CTX prepatory to doing a message digest
|
||||
** computation.
|
||||
*/
|
||||
extern void MD4Init __P((MD4_CTX *MD));
|
||||
|
||||
/* MD4Update(MD,X,count)
|
||||
** Input: X -- a pointer to an array of unsigned characters.
|
||||
** count -- the number of bits of X to use (an unsigned int).
|
||||
** Updates MD using the first "count" bits of X.
|
||||
** The array pointed to by X is not modified.
|
||||
** If count is not a multiple of 8, MD4Update uses high bits of
|
||||
** last byte.
|
||||
** This is the basic input routine for a user.
|
||||
** The routine terminates the MD computation when count < 512, so
|
||||
** every MD computation should end with one call to MD4Update with a
|
||||
** count less than 512. Zero is OK for a count.
|
||||
*/
|
||||
extern void MD4Update __P((MD4_CTX *MD, unsigned char *X, unsigned int count));
|
||||
|
||||
/* MD4Print(MD)
|
||||
** Prints message digest buffer MD as 32 hexadecimal digits.
|
||||
** Order is from low-order byte of buffer[0] to high-order byte
|
||||
** of buffer[3].
|
||||
** Each byte is printed with high-order hexadecimal digit first.
|
||||
*/
|
||||
extern void MD4Print __P((MD4_CTX *));
|
||||
|
||||
/* MD4Final(buf, MD)
|
||||
** Returns message digest from MD and terminates the message
|
||||
** digest computation.
|
||||
*/
|
||||
extern void MD4Final __P((unsigned char *, MD4_CTX *));
|
||||
|
||||
/*
|
||||
** End of md4.h
|
||||
****************************(cut)***********************************/
|
||||
307
vendor/aw/homlet/external/pppoe/pppd/md5.c
vendored
Normal file
307
vendor/aw/homlet/external/pppoe/pppd/md5.c
vendored
Normal file
@ -0,0 +1,307 @@
|
||||
|
||||
|
||||
/*
|
||||
***********************************************************************
|
||||
** md5.c -- the source code for MD5 routines **
|
||||
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
|
||||
** Created: 2/17/90 RLR **
|
||||
** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. **
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
***********************************************************************
|
||||
** 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. **
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "md5.h"
|
||||
|
||||
/*
|
||||
***********************************************************************
|
||||
** Message-digest routines: **
|
||||
** To form the message digest for a message M **
|
||||
** (1) Initialize a context buffer mdContext using MD5_Init **
|
||||
** (2) Call MD5_Update on mdContext and M **
|
||||
** (3) Call MD5_Final on mdContext **
|
||||
** The message digest is now in mdContext->digest[0...15] **
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
/* forward declaration */
|
||||
static void Transform ();
|
||||
|
||||
static unsigned char PADDING[64] = {
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* F, G, H and I are basic MD5 functions */
|
||||
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
|
||||
/* ROTATE_LEFT rotates x left n bits */
|
||||
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
|
||||
|
||||
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
|
||||
/* Rotation is separate from addition to prevent recomputation */
|
||||
#define FF(a, b, c, d, x, s, ac) \
|
||||
{(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define GG(a, b, c, d, x, s, ac) \
|
||||
{(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define HH(a, b, c, d, x, s, ac) \
|
||||
{(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
#define II(a, b, c, d, x, s, ac) \
|
||||
{(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
|
||||
(a) = ROTATE_LEFT ((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
#ifdef __STDC__
|
||||
#define UL(x) x##U
|
||||
#else
|
||||
#define UL(x) x
|
||||
#endif
|
||||
|
||||
/* The routine MD5_Init initializes the message-digest context
|
||||
mdContext. All fields are set to zero.
|
||||
*/
|
||||
void MD5_Init (mdContext)
|
||||
MD5_CTX *mdContext;
|
||||
{
|
||||
mdContext->i[0] = mdContext->i[1] = (UINT4)0;
|
||||
|
||||
/* Load magic initialization constants.
|
||||
*/
|
||||
mdContext->buf[0] = (UINT4)0x67452301;
|
||||
mdContext->buf[1] = (UINT4)0xefcdab89;
|
||||
mdContext->buf[2] = (UINT4)0x98badcfe;
|
||||
mdContext->buf[3] = (UINT4)0x10325476;
|
||||
}
|
||||
|
||||
/* The routine MD5Update updates the message-digest context to
|
||||
account for the presence of each of the characters inBuf[0..inLen-1]
|
||||
in the message whose digest is being computed.
|
||||
*/
|
||||
void MD5_Update (mdContext, inBuf, inLen)
|
||||
MD5_CTX *mdContext;
|
||||
unsigned char *inBuf;
|
||||
unsigned int inLen;
|
||||
{
|
||||
UINT4 in[16];
|
||||
int mdi;
|
||||
unsigned int i, ii;
|
||||
|
||||
/* compute number of bytes mod 64 */
|
||||
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
|
||||
|
||||
/* update number of bits */
|
||||
if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
|
||||
mdContext->i[1]++;
|
||||
mdContext->i[0] += ((UINT4)inLen << 3);
|
||||
mdContext->i[1] += ((UINT4)inLen >> 29);
|
||||
|
||||
while (inLen--) {
|
||||
/* add new character to buffer, increment mdi */
|
||||
mdContext->in[mdi++] = *inBuf++;
|
||||
|
||||
/* transform if necessary */
|
||||
if (mdi == 0x40) {
|
||||
for (i = 0, ii = 0; i < 16; i++, ii += 4)
|
||||
in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
|
||||
(((UINT4)mdContext->in[ii+2]) << 16) |
|
||||
(((UINT4)mdContext->in[ii+1]) << 8) |
|
||||
((UINT4)mdContext->in[ii]);
|
||||
Transform (mdContext->buf, in);
|
||||
mdi = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* The routine MD5Final terminates the message-digest computation and
|
||||
ends with the desired message digest in mdContext->digest[0...15].
|
||||
*/
|
||||
void MD5_Final (hash, mdContext)
|
||||
unsigned char hash[];
|
||||
MD5_CTX *mdContext;
|
||||
{
|
||||
UINT4 in[16];
|
||||
int mdi;
|
||||
unsigned int i, ii;
|
||||
unsigned int padLen;
|
||||
|
||||
/* save number of bits */
|
||||
in[14] = mdContext->i[0];
|
||||
in[15] = mdContext->i[1];
|
||||
|
||||
/* compute number of bytes mod 64 */
|
||||
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
|
||||
|
||||
/* pad out to 56 mod 64 */
|
||||
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
|
||||
MD5_Update (mdContext, PADDING, padLen);
|
||||
|
||||
/* append length in bits and transform */
|
||||
for (i = 0, ii = 0; i < 14; i++, ii += 4)
|
||||
in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
|
||||
(((UINT4)mdContext->in[ii+2]) << 16) |
|
||||
(((UINT4)mdContext->in[ii+1]) << 8) |
|
||||
((UINT4)mdContext->in[ii]);
|
||||
Transform (mdContext->buf, in);
|
||||
|
||||
/* store buffer in digest */
|
||||
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
|
||||
mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
|
||||
mdContext->digest[ii+1] =
|
||||
(unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
|
||||
mdContext->digest[ii+2] =
|
||||
(unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
|
||||
mdContext->digest[ii+3] =
|
||||
(unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
|
||||
}
|
||||
memcpy(hash, mdContext->digest, 16);
|
||||
}
|
||||
|
||||
/* Basic MD5 step. Transforms buf based on in.
|
||||
*/
|
||||
static void Transform (buf, in)
|
||||
UINT4 *buf;
|
||||
UINT4 *in;
|
||||
{
|
||||
UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
|
||||
|
||||
/* Round 1 */
|
||||
#define S11 7
|
||||
#define S12 12
|
||||
#define S13 17
|
||||
#define S14 22
|
||||
FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */
|
||||
FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */
|
||||
FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */
|
||||
FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */
|
||||
FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */
|
||||
FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */
|
||||
FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */
|
||||
FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */
|
||||
FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */
|
||||
FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */
|
||||
FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */
|
||||
FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */
|
||||
FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */
|
||||
FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */
|
||||
FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */
|
||||
FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */
|
||||
|
||||
/* Round 2 */
|
||||
#define S21 5
|
||||
#define S22 9
|
||||
#define S23 14
|
||||
#define S24 20
|
||||
GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */
|
||||
GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */
|
||||
GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */
|
||||
GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */
|
||||
GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */
|
||||
GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */
|
||||
GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */
|
||||
GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */
|
||||
GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */
|
||||
GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */
|
||||
GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */
|
||||
GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */
|
||||
GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */
|
||||
GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */
|
||||
GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */
|
||||
GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */
|
||||
|
||||
/* Round 3 */
|
||||
#define S31 4
|
||||
#define S32 11
|
||||
#define S33 16
|
||||
#define S34 23
|
||||
HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */
|
||||
HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */
|
||||
HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */
|
||||
HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */
|
||||
HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */
|
||||
HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */
|
||||
HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */
|
||||
HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */
|
||||
HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */
|
||||
HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */
|
||||
HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */
|
||||
HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */
|
||||
HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */
|
||||
HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */
|
||||
HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */
|
||||
HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */
|
||||
|
||||
/* Round 4 */
|
||||
#define S41 6
|
||||
#define S42 10
|
||||
#define S43 15
|
||||
#define S44 21
|
||||
II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */
|
||||
II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */
|
||||
II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */
|
||||
II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */
|
||||
II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */
|
||||
II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */
|
||||
II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */
|
||||
II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */
|
||||
II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */
|
||||
II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */
|
||||
II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */
|
||||
II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */
|
||||
II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */
|
||||
II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */
|
||||
II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */
|
||||
II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
/*
|
||||
***********************************************************************
|
||||
** End of md5.c **
|
||||
******************************** (cut) ********************************
|
||||
*/
|
||||
65
vendor/aw/homlet/external/pppoe/pppd/md5.h
vendored
Normal file
65
vendor/aw/homlet/external/pppoe/pppd/md5.h
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
***********************************************************************
|
||||
** md5.h -- header file for implementation of MD5 **
|
||||
** RSA Data Security, Inc. MD5 Message-Digest Algorithm **
|
||||
** Created: 2/17/90 RLR **
|
||||
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
|
||||
** Revised (for MD5): RLR 4/27/91 **
|
||||
** -- G modified to have y&~z instead of y&z **
|
||||
** -- FF, GG, HH modified to add in last register done **
|
||||
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
|
||||
** -- distinct additive constant for each step **
|
||||
** -- round 4 added, working mod 7 **
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
***********************************************************************
|
||||
** 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. **
|
||||
***********************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __MD5_INCLUDE__
|
||||
|
||||
/* typedef a 32-bit type */
|
||||
#ifdef _LP64
|
||||
typedef unsigned int UINT4;
|
||||
typedef int INT4;
|
||||
#else
|
||||
typedef unsigned long UINT4;
|
||||
typedef long INT4;
|
||||
#endif
|
||||
#define _UINT4_T
|
||||
|
||||
/* Data structure for MD5 (Message-Digest) computation */
|
||||
typedef struct {
|
||||
UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
|
||||
UINT4 buf[4]; /* scratch buffer */
|
||||
unsigned char in[64]; /* input buffer */
|
||||
unsigned char digest[16]; /* actual digest after MD5Final call */
|
||||
} MD5_CTX;
|
||||
|
||||
void MD5_Init ();
|
||||
void MD5_Update ();
|
||||
void MD5_Final ();
|
||||
|
||||
#define __MD5_INCLUDE__
|
||||
#endif /* __MD5_INCLUDE__ */
|
||||
41
vendor/aw/homlet/external/pppoe/pppd/openssl-hash.c
vendored
Normal file
41
vendor/aw/homlet/external/pppoe/pppd/openssl-hash.c
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* 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 <openssl/evp.h>
|
||||
|
||||
const EVP_MD *sha1_md;
|
||||
const EVP_MD *md4_md;
|
||||
const EVP_MD *md5_md;
|
||||
|
||||
void openssl_hash_init() {
|
||||
/* Use the SHA1 functions in openssl to save the flash space.*/
|
||||
OpenSSL_add_all_digests();
|
||||
sha1_md = EVP_get_digestbyname("sha1");
|
||||
if (!sha1_md) {
|
||||
dbglog("Error Unknown message digest SHA1\n");
|
||||
exit(1);
|
||||
}
|
||||
md4_md = EVP_get_digestbyname("md4");
|
||||
if (!md4_md) {
|
||||
dbglog("Error Unknown message digest MD4\n");
|
||||
exit(1);
|
||||
}
|
||||
md5_md = EVP_get_digestbyname("md5");
|
||||
if (!md5_md) {
|
||||
dbglog("Error Unknown message digest MD5\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
55
vendor/aw/homlet/external/pppoe/pppd/openssl-hash.h
vendored
Normal file
55
vendor/aw/homlet/external/pppoe/pppd/openssl-hash.h
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2009 The Android Open Source Project
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __OPENSSL_HASH__
|
||||
#define __OPENSSL_HASH__
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
extern const EVP_MD *sha1_md;
|
||||
#define SHA1_SIGNATURE_SIZE 20
|
||||
#define SHA1_CTX EVP_MD_CTX
|
||||
#define SHA1_Init(ctx) { \
|
||||
EVP_MD_CTX_init(ctx); \
|
||||
EVP_DigestInit_ex(ctx, sha1_md, NULL); \
|
||||
}
|
||||
#define SHA1_Update EVP_DigestUpdate
|
||||
#define SHA1_Final(digest, ctx) { \
|
||||
int md_len; \
|
||||
EVP_DigestFinal_ex(ctx, digest, &md_len); \
|
||||
}
|
||||
|
||||
extern const EVP_MD *md4_md;
|
||||
#define MD4_CTX EVP_MD_CTX
|
||||
#define MD4Init(ctx) { \
|
||||
EVP_MD_CTX_init(ctx); \
|
||||
EVP_DigestInit_ex(ctx, md4_md, NULL); \
|
||||
}
|
||||
#define MD4Update EVP_DigestUpdate
|
||||
#define MD4Final SHA1_Final
|
||||
|
||||
extern const EVP_MD *md5_md;
|
||||
#define MD5_CTX EVP_MD_CTX
|
||||
#define MD5_Init(ctx) { \
|
||||
EVP_MD_CTX_init(ctx); \
|
||||
EVP_DigestInit_ex(ctx, md5_md, NULL); \
|
||||
}
|
||||
#define MD5_Update EVP_DigestUpdate
|
||||
#define MD5_Final SHA1_Final
|
||||
|
||||
extern void openssl_hash_init();
|
||||
|
||||
#endif
|
||||
1630
vendor/aw/homlet/external/pppoe/pppd/options.c
vendored
Normal file
1630
vendor/aw/homlet/external/pppoe/pppd/options.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4
vendor/aw/homlet/external/pppoe/pppd/patchlevel.h
vendored
Normal file
4
vendor/aw/homlet/external/pppoe/pppd/patchlevel.h
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
/* $Id: patchlevel.h,v 1.62 2004/11/13 12:08:01 paulus Exp $ */
|
||||
|
||||
#define VERSION "2.4.3"
|
||||
#define DATE "13 November 2004"
|
||||
62
vendor/aw/homlet/external/pppoe/pppd/pathnames.h
vendored
Normal file
62
vendor/aw/homlet/external/pppoe/pppd/pathnames.h
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* define path names
|
||||
*
|
||||
* $Id: pathnames.h,v 1.16 2004/11/13 12:02:22 paulus Exp $
|
||||
*/
|
||||
|
||||
#ifdef HAVE_PATHS_H
|
||||
#include <paths.h>
|
||||
|
||||
#else /* HAVE_PATHS_H */
|
||||
#ifndef _PATH_VARRUN
|
||||
#define _PATH_VARRUN "/etc/ppp/"
|
||||
#endif
|
||||
#define _PATH_DEVNULL "/dev/null"
|
||||
#endif /* HAVE_PATHS_H */
|
||||
|
||||
//#ifndef _ROOT_PATH
|
||||
#define _ROOT_PATH
|
||||
//#endif
|
||||
|
||||
#define _PATH_UPAPFILE _ROOT_PATH "/data/system/pap-secrets"
|
||||
#define _PATH_CHAPFILE _ROOT_PATH "/data/system/chap-secrets"
|
||||
#define _PATH_SRPFILE _ROOT_PATH "/data/system/srp-secrets"
|
||||
//#define _PATH_UPAPFILE _ROOT_PATH "/etc/ppp/pap-secrets"
|
||||
//#define _PATH_CHAPFILE _ROOT_PATH "/etc/ppp/chap-secrets"
|
||||
//#define _PATH_SRPFILE _ROOT_PATH "/etc/ppp/srp-secrets"
|
||||
#define _PATH_SYSOPTIONS _ROOT_PATH "/etc/ppp/options"
|
||||
#define _PATH_IPUP _ROOT_PATH "/etc/ppp/ip-up"
|
||||
#define _PATH_IPDOWN _ROOT_PATH "/etc/ppp/ip-down"
|
||||
#define _PATH_AUTHUP _ROOT_PATH "/etc/ppp/auth-up"
|
||||
#define _PATH_AUTHDOWN _ROOT_PATH "/etc/ppp/auth-down"
|
||||
#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_USEROPT ".ppprc"
|
||||
#define _PATH_PSEUDONYM ".ppp_pseudonym"
|
||||
|
||||
#ifdef INET6
|
||||
#define _PATH_IPV6UP _ROOT_PATH "/etc/ppp/ipv6-up"
|
||||
#define _PATH_IPV6DOWN _ROOT_PATH "/etc/ppp/ipv6-down"
|
||||
#endif
|
||||
|
||||
#ifdef IPX_CHANGE
|
||||
#define _PATH_IPXUP _ROOT_PATH "/etc/ppp/ipx-up"
|
||||
#define _PATH_IPXDOWN _ROOT_PATH "/etc/ppp/ipx-down"
|
||||
#endif /* IPX_CHANGE */
|
||||
|
||||
#ifdef __STDC__
|
||||
#define _PATH_PPPDB _ROOT_PATH _PATH_VARRUN "pppd2.tdb"
|
||||
#else /* __STDC__ */
|
||||
#ifdef HAVE_PATHS_H
|
||||
#define _PATH_PPPDB "/var/run/pppd2.tdb"
|
||||
#else
|
||||
#define _PATH_PPPDB "/etc/ppp/pppd2.tdb"
|
||||
#endif
|
||||
#endif /* __STDC__ */
|
||||
|
||||
#ifdef PLUGIN
|
||||
#define _PATH_PLUGIN "/usr/lib/pppd/" VERSION
|
||||
#endif /* PLUGIN */
|
||||
41
vendor/aw/homlet/external/pppoe/pppd/plugins/Makefile.linux
vendored
Normal file
41
vendor/aw/homlet/external/pppoe/pppd/plugins/Makefile.linux
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
CC = gcc
|
||||
COPTS = -O2 -g
|
||||
CFLAGS = $(COPTS) -I.. -I../../include -fPIC
|
||||
LDFLAGS = -shared
|
||||
INSTALL = install
|
||||
|
||||
DESTDIR = @DESTDIR@
|
||||
BINDIR = $(DESTDIR)/sbin
|
||||
MANDIR = $(DESTDIR)/share/man/man8
|
||||
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
|
||||
|
||||
SUBDIRS := rp-pppoe pppoatm radius
|
||||
# Uncomment the next line to include the radius authentication plugin
|
||||
# SUBDIRS += radius
|
||||
PLUGINS := minconn.so passprompt.so passwordfd.so winbind.so
|
||||
|
||||
# include dependencies if present
|
||||
ifeq (.depend,$(wildcard .depend))
|
||||
include .depend
|
||||
endif
|
||||
|
||||
all: $(PLUGINS)
|
||||
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d all; done
|
||||
|
||||
%.so: %.c
|
||||
$(CC) -o $@ $(LDFLAGS) $(CFLAGS) $^
|
||||
|
||||
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../patchlevel.h)
|
||||
|
||||
install: $(PLUGINS)
|
||||
$(INSTALL) -d $(LIBDIR)
|
||||
$(INSTALL) $? $(LIBDIR)
|
||||
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d install; done
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.a
|
||||
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d clean; done
|
||||
|
||||
depend:
|
||||
$(CPP) -M $(CFLAGS) *.c >.depend
|
||||
for d in $(SUBDIRS); do $(MAKE) $(MFLAGS) -C $$d depend; done
|
||||
27
vendor/aw/homlet/external/pppoe/pppd/plugins/Makefile.sol2
vendored
Normal file
27
vendor/aw/homlet/external/pppoe/pppd/plugins/Makefile.sol2
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
#
|
||||
# Makefile for plugins on Solaris 2
|
||||
#
|
||||
# $Id: Makefile.sol2,v 1.3 2002/09/07 05:15:25 carlsonj Exp $
|
||||
#
|
||||
|
||||
include ../../Makedefs.com
|
||||
|
||||
CFLAGS = -c -O -I.. -I../../include $(COPTS)
|
||||
LDFLAGS = -G
|
||||
|
||||
all: minconn.so
|
||||
|
||||
minconn.so: minconn.o
|
||||
ld -o $@ $(LDFLAGS) -h $@ minconn.o
|
||||
|
||||
minconn.o: minconn.c
|
||||
$(CC) $(CFLAGS) -c $?
|
||||
|
||||
passprompt.so: passprompt.o
|
||||
ld -o $@ $(LDFLAGS) -h $@ passprompt.o
|
||||
|
||||
passprompt.o: passprompt.c
|
||||
$(CC) $(CFLAGS) -c $?
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so
|
||||
66
vendor/aw/homlet/external/pppoe/pppd/plugins/minconn.c
vendored
Normal file
66
vendor/aw/homlet/external/pppoe/pppd/plugins/minconn.c
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* minconn.c - pppd plugin to implement a `minconnect' option.
|
||||
*
|
||||
* Copyright (c) 1999 Paul Mackerras. 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. The name(s) of the authors of this software must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission.
|
||||
*
|
||||
* 4. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by Paul Mackerras
|
||||
* <paulus@samba.org>".
|
||||
*
|
||||
* THE AUTHORS OF THIS SOFTWARE DISCLAIM ALL WARRANTIES WITH REGARD TO
|
||||
* THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS, IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
||||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <time.h>
|
||||
#include "pppd.h"
|
||||
|
||||
char pppd_version[] = VERSION;
|
||||
|
||||
static int minconnect = 0;
|
||||
|
||||
static option_t my_options[] = {
|
||||
{ "minconnect", o_int, &minconnect,
|
||||
"Set minimum connect time before idle timeout applies" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static int my_get_idle(struct ppp_idle *idle)
|
||||
{
|
||||
time_t t;
|
||||
|
||||
if (idle == NULL)
|
||||
return minconnect? minconnect: idle_time_limit;
|
||||
t = idle->xmit_idle;
|
||||
if (idle->recv_idle < t)
|
||||
t = idle->recv_idle;
|
||||
return idle_time_limit - t;
|
||||
}
|
||||
|
||||
void plugin_init(void)
|
||||
{
|
||||
info("plugin_init");
|
||||
add_options(my_options);
|
||||
idle_time_hook = my_get_idle;
|
||||
}
|
||||
110
vendor/aw/homlet/external/pppoe/pppd/plugins/passprompt.c
vendored
Normal file
110
vendor/aw/homlet/external/pppoe/pppd/plugins/passprompt.c
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* passprompt.c - pppd plugin to invoke an external PAP password prompter
|
||||
*
|
||||
* Copyright 1999 Paul Mackerras, Alan Curry.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include <syslog.h>
|
||||
#include "pppd.h"
|
||||
|
||||
char pppd_version[] = VERSION;
|
||||
|
||||
static char promptprog[PATH_MAX+1];
|
||||
|
||||
static option_t options[] = {
|
||||
{ "promptprog", o_string, promptprog,
|
||||
"External PAP password prompting program",
|
||||
OPT_STATIC, NULL, PATH_MAX },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static int promptpass(char *user, char *passwd)
|
||||
{
|
||||
int p[2];
|
||||
pid_t kid;
|
||||
int readgood, wstat;
|
||||
ssize_t red;
|
||||
|
||||
if (promptprog[0] == 0 || access(promptprog, X_OK) < 0)
|
||||
return -1; /* sorry, can't help */
|
||||
|
||||
if (!passwd)
|
||||
return 1;
|
||||
|
||||
if (pipe(p)) {
|
||||
warn("Can't make a pipe for %s", promptprog);
|
||||
return 0;
|
||||
}
|
||||
if ((kid = fork()) == (pid_t) -1) {
|
||||
warn("Can't fork to run %s", promptprog);
|
||||
close(p[0]);
|
||||
close(p[1]);
|
||||
return 0;
|
||||
}
|
||||
if (!kid) {
|
||||
/* we are the child, exec the program */
|
||||
char *argv[4], fdstr[32];
|
||||
sys_close();
|
||||
closelog();
|
||||
close(p[0]);
|
||||
seteuid(getuid());
|
||||
setegid(getgid());
|
||||
argv[0] = promptprog;
|
||||
argv[1] = user;
|
||||
argv[2] = remote_name;
|
||||
sprintf(fdstr, "%d", p[1]);
|
||||
argv[3] = fdstr;
|
||||
argv[4] = 0;
|
||||
execv(*argv, argv);
|
||||
_exit(127);
|
||||
}
|
||||
|
||||
/* we are the parent, read the password from the pipe */
|
||||
close(p[1]);
|
||||
readgood = 0;
|
||||
do {
|
||||
red = read(p[0], passwd + readgood, MAXSECRETLEN-1 - readgood);
|
||||
if (red == 0)
|
||||
break;
|
||||
if (red < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
error("Can't read secret from %s: %m", promptprog);
|
||||
readgood = -1;
|
||||
break;
|
||||
}
|
||||
readgood += red;
|
||||
} while (readgood < MAXSECRETLEN - 1);
|
||||
passwd[readgood] = 0;
|
||||
close(p[0]);
|
||||
|
||||
/* now wait for child to exit */
|
||||
while (waitpid(kid, &wstat, 0) < 0) {
|
||||
if (errno != EINTR) {
|
||||
warn("error waiting for %s: %m", promptprog);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (readgood < 0)
|
||||
return 0;
|
||||
if (!WIFEXITED(wstat))
|
||||
warn("%s terminated abnormally", promptprog);
|
||||
if (WEXITSTATUS(wstat))
|
||||
warn("%s exited with code %d", promptprog, WEXITSTATUS(status));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void plugin_init(void)
|
||||
{
|
||||
add_options(options);
|
||||
pap_passwd_hook = promptpass;
|
||||
}
|
||||
82
vendor/aw/homlet/external/pppoe/pppd/plugins/passwordfd.c
vendored
Normal file
82
vendor/aw/homlet/external/pppoe/pppd/plugins/passwordfd.c
vendored
Normal file
@ -0,0 +1,82 @@
|
||||
|
||||
/*
|
||||
* Author: Arvin Schnell <arvin@suse.de>
|
||||
*
|
||||
* This plugin let's you pass the password to the pppd via
|
||||
* a file descriptor. That's easy and secure - no fiddling
|
||||
* with pap- and chap-secrets files.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "pppd.h"
|
||||
|
||||
char pppd_version[] = VERSION;
|
||||
|
||||
static int passwdfd = -1;
|
||||
static char save_passwd[MAXSECRETLEN];
|
||||
|
||||
static option_t options[] = {
|
||||
{ "passwordfd", o_int, &passwdfd,
|
||||
"Receive password on this file descriptor" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
static int pwfd_check (void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int pwfd_passwd (char *user, char *passwd)
|
||||
{
|
||||
int readgood, red;
|
||||
|
||||
if (passwdfd == -1)
|
||||
return -1;
|
||||
|
||||
if (passwd == NULL)
|
||||
return 1;
|
||||
|
||||
if (passwdfd == -2) {
|
||||
strcpy (passwd, save_passwd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
readgood = 0;
|
||||
do {
|
||||
red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood);
|
||||
if (red == 0)
|
||||
break;
|
||||
if (red < 0) {
|
||||
error ("Can't read secret from fd\n");
|
||||
readgood = -1;
|
||||
break;
|
||||
}
|
||||
readgood += red;
|
||||
} while (readgood < MAXSECRETLEN - 1);
|
||||
|
||||
close (passwdfd);
|
||||
|
||||
if (readgood < 0)
|
||||
return 0;
|
||||
|
||||
passwd[readgood] = 0;
|
||||
strcpy (save_passwd, passwd);
|
||||
passwdfd = -2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void plugin_init (void)
|
||||
{
|
||||
add_options (options);
|
||||
|
||||
pap_check_hook = pwfd_check;
|
||||
pap_passwd_hook = pwfd_passwd;
|
||||
|
||||
chap_check_hook = pwfd_check;
|
||||
chap_passwd_hook = pwfd_passwd;
|
||||
}
|
||||
7
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/COPYING
vendored
Normal file
7
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/COPYING
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
The files ans.c, atm.h, atmres.h, atmsap.h, misc.c, text2atm.c and
|
||||
text2qos.c are taken from the linux-atm libraries. These are
|
||||
Copyright 1995-2000 EPFL-LRC/ICA, and are licensed under the GNU Lesser
|
||||
General Public License.
|
||||
|
||||
The file pppoatm.c contains its own copyright notice, and is licensed
|
||||
under the GPL.
|
||||
46
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/Makefile.linux
vendored
Normal file
46
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/Makefile.linux
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
CC = gcc
|
||||
COPTS = -O2 -g
|
||||
CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC
|
||||
LDFLAGS = -shared
|
||||
INSTALL = install
|
||||
|
||||
#***********************************************************************
|
||||
|
||||
DESTDIR = @DESTDIR@
|
||||
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
|
||||
|
||||
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
|
||||
|
||||
PLUGIN := pppoatm.so
|
||||
PLUGIN_OBJS := pppoatm.o
|
||||
|
||||
#*******
|
||||
# Do we have the ATM libraries installed? Set HAVE_LIBATM to use them,
|
||||
# or leave it unset to build the few routines we actually _use_ into
|
||||
# the plugin directly.
|
||||
#
|
||||
#HAVE_LIBATM=yes
|
||||
|
||||
ifdef HAVE_LIBATM
|
||||
LIBS := -latm
|
||||
else
|
||||
CFLAGS += -I.
|
||||
PLUGIN_OBJS += text2qos.o text2atm.o misc.o ans.o
|
||||
LIBS := -lresolv
|
||||
endif
|
||||
|
||||
#*********
|
||||
all: $(PLUGIN)
|
||||
|
||||
$(PLUGIN): $(PLUGIN_OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ -shared $^ $(LIBS)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d -m 755 $(LIBDIR)
|
||||
$(INSTALL) -c -m 4550 $(PLUGIN) $(LIBDIR)
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
262
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/ans.c
vendored
Normal file
262
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/ans.c
vendored
Normal file
@ -0,0 +1,262 @@
|
||||
/* ans.c - Interface for text2atm and atm2text to ANS */
|
||||
|
||||
/* Written 1996-2000 by Werner Almesberger, EPFL-LRC/ICA */
|
||||
|
||||
|
||||
/*
|
||||
* This stuff is a temporary hack to avoid using gethostbyname_nsap and such
|
||||
* without doing the "full upgrade" to getaddrinfo/getnameinfo. This also
|
||||
* serves as an exercise for me to get all the details right before I propose
|
||||
* a patch that would eventually end up in libc (and that should therefore be
|
||||
* as stable as possible).
|
||||
*/
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/nameser.h>
|
||||
#include <netdb.h>
|
||||
#include <resolv.h>
|
||||
|
||||
#include "atm.h"
|
||||
#include "atmres.h"
|
||||
|
||||
|
||||
#define MAX_ANSWER 2048
|
||||
#define MAX_NAME 1024
|
||||
|
||||
#define MAX_LINE 2048 /* in /etc/e164_cc */
|
||||
#define E164_CC_DEFAULT_LEN 2
|
||||
#define E164_CC_FILE "/etc/e164_cc"
|
||||
|
||||
#define GET16(pos) (((pos)[0] << 8) | (pos)[1])
|
||||
|
||||
|
||||
static int ans(const char *text,int wanted,void *result,int res_len)
|
||||
{
|
||||
unsigned char answer[MAX_ANSWER];
|
||||
unsigned char name[MAX_NAME];
|
||||
unsigned char *pos,*data,*found;
|
||||
int answer_len,name_len,data_len,found_len;
|
||||
int questions,answers;
|
||||
|
||||
found_len = 0; /* gcc wants it */
|
||||
if ((answer_len = res_search(text,C_IN,wanted,answer,MAX_ANSWER)) < 0)
|
||||
return TRY_OTHER;
|
||||
/*
|
||||
* Response header: id, flags, #queries, #answers, #authority,
|
||||
* #additional (all 16 bits)
|
||||
*/
|
||||
pos = answer+12;
|
||||
if (answer[3] & 15) return TRY_OTHER; /* rcode != 0 */
|
||||
questions = GET16(answer+4);
|
||||
if (questions != 1) return TRY_OTHER; /* trouble ... */
|
||||
answers = GET16(answer+6);
|
||||
if (answers < 1) return TRY_OTHER;
|
||||
/*
|
||||
* Query: name, type (16), class (16)
|
||||
*/
|
||||
if ((name_len = dn_expand(answer,answer+answer_len,pos,name,MAX_NAME)) < 0)
|
||||
return TRY_OTHER;
|
||||
pos += name_len;
|
||||
if (GET16(pos) != wanted || GET16(pos+2) != C_IN) return TRY_OTHER;
|
||||
pos += 4;
|
||||
/*
|
||||
* Iterate over answers until we find something we like, giving priority
|
||||
* to ATMA_AESA (until signaling is fixed to work with E.164 too)
|
||||
*/
|
||||
found = NULL;
|
||||
while (answers--) {
|
||||
/*
|
||||
* RR: name, type (16), class (16), TTL (32), resource_len (16),
|
||||
* resource_data ...
|
||||
*/
|
||||
if ((name_len = dn_expand(answer,answer+answer_len,pos,name,MAX_NAME))
|
||||
< 0) return TRY_OTHER;
|
||||
pos += name_len;
|
||||
data_len = GET16(pos+8);
|
||||
data = pos+10;
|
||||
pos = data+data_len;
|
||||
if (GET16(data-10) != wanted || GET16(data-8) != C_IN || !--data_len)
|
||||
continue;
|
||||
switch (wanted) {
|
||||
case T_NSAP:
|
||||
data_len++;
|
||||
if (data_len != ATM_ESA_LEN) continue;
|
||||
memcpy(((struct sockaddr_atmsvc *) result)->
|
||||
sas_addr.prv,data,ATM_ESA_LEN);
|
||||
return 0;
|
||||
case T_ATMA:
|
||||
switch (*data++) {
|
||||
case ATMA_AESA:
|
||||
if (data_len != ATM_ESA_LEN) continue;
|
||||
memcpy(((struct sockaddr_atmsvc *) result)->
|
||||
sas_addr.prv,data,ATM_ESA_LEN);
|
||||
return 0;
|
||||
case ATMA_E164:
|
||||
if (data_len > ATM_E164_LEN) continue;
|
||||
if (!found) {
|
||||
found = data;
|
||||
found_len = data_len;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
case T_PTR:
|
||||
if (dn_expand(answer,answer+answer_len,data,result,
|
||||
res_len) < 0) return FATAL;
|
||||
return 0;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!found) return TRY_OTHER;
|
||||
memcpy(((struct sockaddr_atmsvc *) result)->sas_addr.pub,found,
|
||||
found_len);
|
||||
((struct sockaddr_atmsvc *) result)->sas_addr.pub[found_len] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ans_byname(const char *text,struct sockaddr_atmsvc *addr,int length,
|
||||
int flags)
|
||||
{
|
||||
if (!(flags & T2A_SVC) || length != sizeof(*addr)) return TRY_OTHER;
|
||||
memset(addr,0,sizeof(*addr));
|
||||
addr->sas_family = AF_ATMSVC;
|
||||
if (!ans(text,T_ATMA,addr,length)) return 0;
|
||||
return ans(text,T_NSAP,addr,length);
|
||||
}
|
||||
|
||||
|
||||
static int encode_nsap(char *buf,const unsigned char *addr)
|
||||
{
|
||||
static int fmt_dcc[] = { 2,12,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
|
||||
4,2,0 };
|
||||
static int fmt_e164[] = { 2,12,1,1,1,1,1,1,1,1,16,2,0 };
|
||||
int *fmt;
|
||||
int pos,i,j;
|
||||
|
||||
switch (*addr) {
|
||||
case ATM_AFI_DCC:
|
||||
case ATM_AFI_ICD:
|
||||
case ATM_AFI_LOCAL:
|
||||
case ATM_AFI_DCC_GROUP:
|
||||
case ATM_AFI_ICD_GROUP:
|
||||
case ATM_AFI_LOCAL_GROUP:
|
||||
fmt = fmt_dcc;
|
||||
break;
|
||||
case ATM_AFI_E164:
|
||||
case ATM_AFI_E164_GROUP:
|
||||
fmt = fmt_e164;
|
||||
break;
|
||||
default:
|
||||
return TRY_OTHER;
|
||||
}
|
||||
pos = 2*ATM_ESA_LEN;
|
||||
for (i = 0; fmt[i]; i++) {
|
||||
pos -= fmt[i];
|
||||
for (j = 0; j < fmt[i]; j++)
|
||||
sprintf(buf++,"%x",
|
||||
(addr[(pos+j) >> 1] >> 4*(1-((pos+j) & 1))) & 0xf);
|
||||
*buf++ = '.';
|
||||
}
|
||||
strcpy(buf,"AESA.ATMA.INT.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int encode_nsap_new(char *buf,const unsigned char *addr)
|
||||
{
|
||||
int i;
|
||||
int digit;
|
||||
|
||||
for (i = 20; i; ) {
|
||||
i--;
|
||||
digit = addr[i] & 0x0F;
|
||||
*(buf++) = digit + (digit >= 10 ? '7' : '0');
|
||||
*(buf++) = '.';
|
||||
digit = ((unsigned char) (addr[i])) >> 4;
|
||||
*(buf++) = digit + (digit >= 10 ? '7' : '0');
|
||||
*(buf++) = '.';
|
||||
}
|
||||
strcpy (buf, "NSAP.INT.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int cc_len(int p0,int p1)
|
||||
{
|
||||
static char *cc_table = NULL;
|
||||
FILE *file;
|
||||
char buffer[MAX_LINE];
|
||||
char *here;
|
||||
int cc;
|
||||
|
||||
if (!cc_table) {
|
||||
if (!(cc_table = malloc(100))) {
|
||||
perror("malloc");
|
||||
return E164_CC_DEFAULT_LEN;
|
||||
}
|
||||
memset(cc_table,E164_CC_DEFAULT_LEN,100);
|
||||
if (!(file = fopen(E164_CC_FILE,"r")))
|
||||
perror(E164_CC_FILE);
|
||||
else {
|
||||
while (fgets(buffer,MAX_LINE,file)) {
|
||||
here = strchr(buffer,'#');
|
||||
if (here) *here = 0;
|
||||
if (sscanf(buffer,"%d",&cc) == 1) {
|
||||
if (cc < 10) cc_table[cc] = 1;
|
||||
else if (cc < 100) cc_table[cc] = 2;
|
||||
else cc_table[cc/10] = 3;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
if (cc_table[p0] == 1) return 1;
|
||||
return cc_table[p0*10+p1];
|
||||
}
|
||||
|
||||
|
||||
static int encode_e164(char *buf,const char *addr)
|
||||
{
|
||||
const char *prefix,*here;
|
||||
|
||||
prefix = addr+cc_len(addr[0]-48,addr[1]-48);
|
||||
here = strchr(addr,0);
|
||||
while (here > prefix) {
|
||||
*buf++ = *--here;
|
||||
*buf++ = '.';
|
||||
}
|
||||
while (here > addr) *buf++ = *addr++;
|
||||
strcpy(buf,".E164.ATMA.INT.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int ans_byaddr(char *buffer,int length,const struct sockaddr_atmsvc *addr,
|
||||
int flags)
|
||||
{
|
||||
char tmp[MAX_NAME]; /* could be smaller ... */
|
||||
int res;
|
||||
|
||||
if (addr->sas_addr.prv) {
|
||||
res = encode_nsap(tmp,addr->sas_addr.prv);
|
||||
if (!res && !ans(tmp,T_PTR,buffer,length)) return 0;
|
||||
res = encode_nsap_new(tmp,addr->sas_addr.prv);
|
||||
if (res < 0) return res;
|
||||
return ans(tmp,T_PTR,buffer,length);
|
||||
} else {
|
||||
res = encode_e164(tmp,addr->sas_addr.pub);
|
||||
if (res < 0) return res;
|
||||
return ans(tmp,T_PTR,buffer,length);
|
||||
}
|
||||
}
|
||||
108
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/atm.h
vendored
Normal file
108
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/atm.h
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
/* atm.h - Functions useful for ATM applications */
|
||||
|
||||
/* Written 1995-2000 by Werner Almesberger, EPFL-LRC/ICA */
|
||||
|
||||
|
||||
#ifndef _ATM_H
|
||||
#define _ATM_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/atm.h>
|
||||
|
||||
|
||||
/*
|
||||
* For versions of glibc < 2.1
|
||||
*/
|
||||
|
||||
#ifndef AF_ATMPVC
|
||||
#define AF_ATMPVC 8
|
||||
#endif
|
||||
|
||||
#ifndef AF_ATMSVC
|
||||
#define AF_ATMSVC 20
|
||||
#endif
|
||||
|
||||
#ifndef PF_ATMPVC
|
||||
#define PF_ATMPVC AF_ATMPVC
|
||||
#endif
|
||||
|
||||
#ifndef PF_ATMSVC
|
||||
#define PF_ATMSVC AF_ATMSVC
|
||||
#endif
|
||||
|
||||
#ifndef SOL_ATM
|
||||
#define SOL_ATM 264
|
||||
#endif
|
||||
|
||||
#ifndef SOL_AAL
|
||||
#define SOL_AAL 265
|
||||
#endif
|
||||
|
||||
|
||||
#define HOSTS_ATM "/etc/hosts.atm"
|
||||
|
||||
/* text2atm flags */
|
||||
#define T2A_PVC 1 /* address is PVC */
|
||||
#define T2A_SVC 2 /* address is SVC */
|
||||
#define T2A_UNSPEC 4 /* allow unspecified parts in PVC address */
|
||||
#define T2A_WILDCARD 8 /* allow wildcards in PVC or SVC address */
|
||||
#define T2A_NNI 16 /* allow NNI VPI range (PVC) */
|
||||
#define T2A_NAME 32 /* allow name resolution */
|
||||
#define T2A_REMOTE 64 /* OBSOLETE */
|
||||
#define T2A_LOCAL 128 /* don't use ANS */
|
||||
|
||||
/* atm2text flags */
|
||||
#define A2T_PRETTY 1 /* add syntactic sugar */
|
||||
#define A2T_NAME 2 /* attempt name lookup */
|
||||
#define A2T_REMOTE 4 /* OBSOLETE */
|
||||
#define A2T_LOCAL 8 /* don't use ANS */
|
||||
|
||||
/* atm_equal flags */
|
||||
#define AXE_WILDCARD 1 /* allow wildcard match */
|
||||
#define AXE_PRVOPT 2 /* private part of SVC address is optional */
|
||||
|
||||
/* text2qos flags */
|
||||
#define T2Q_DEFAULTS 1 /* structure contains default values */
|
||||
|
||||
/* text2sap flags */
|
||||
#define T2S_NAME 1 /* attempt name lookup */
|
||||
#define T2S_LOCAL 2 /* we may support NIS or such in the future */
|
||||
|
||||
/* sap2text flags */
|
||||
#define S2T_NAME 1 /* attempt name lookup */
|
||||
#define S2T_LOCAL 2 /* we may support NIS or such in the future */
|
||||
|
||||
/* sap_equal flags */
|
||||
#define SXE_COMPATIBLE 1 /* check for compatibility instead of identity*/
|
||||
#define SXE_NEGOTIATION 2 /* allow negotiation; requires SXE_COMPATIBLE;
|
||||
assumes "a" defines the available
|
||||
capabilities */
|
||||
#define SXE_RESULT 4 /* return selected SAP */
|
||||
|
||||
#define MAX_ATM_ADDR_LEN (2*ATM_ESA_LEN+ATM_E164_LEN+5)
|
||||
/* 4 dots, 1 plus */
|
||||
#define MAX_ATM_NAME_LEN 256 /* wild guess */
|
||||
#define MAX_ATM_QOS_LEN 116 /* 5+4+2*(3+3*(7+9)+2)+1 */
|
||||
#define MAX_ATM_SAP_LEN 255 /* BHLI(27)+1+3*BLLI(L2=33,L3=41,+1)+2 */
|
||||
|
||||
|
||||
int text2atm(const char *text,struct sockaddr *addr,int length,int flags);
|
||||
int atm2text(char *buffer,int length,const struct sockaddr *addr,int flags);
|
||||
int atm_equal(const struct sockaddr *a,const struct sockaddr *b,int len,
|
||||
int flags);
|
||||
|
||||
int sdu2cell(int s,int sizes,const int *sdu_size,int *num_sdu);
|
||||
|
||||
int text2qos(const char *text,struct atm_qos *qos,int flags);
|
||||
int qos2text(char *buffer,int length,const struct atm_qos *qos,int flags);
|
||||
int qos_equal(const struct atm_qos *a,const struct atm_qos *b);
|
||||
|
||||
int text2sap(const char *text,struct atm_sap *sap,int flags);
|
||||
int sap2text(char *buffer,int length,const struct atm_sap *sap,int flags);
|
||||
int sap_equal(const struct atm_sap *a,const struct atm_sap *b,int flags,...);
|
||||
|
||||
int __t2q_get_rate(const char **text,int up);
|
||||
int __atmlib_fetch(const char **pos,...); /* internal use only */
|
||||
|
||||
#endif
|
||||
36
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/atmres.h
vendored
Normal file
36
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/atmres.h
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
/* atmres.h - Common definitions and prototypes for resolver functions */
|
||||
|
||||
/* Written 1996,1998 by Werner Almesberger, EPFL-LRC/ICA */
|
||||
|
||||
|
||||
#ifndef _ATMRES_H
|
||||
#define _ATMRES_H
|
||||
|
||||
#include <arpa/nameser.h>
|
||||
#include <linux/atm.h>
|
||||
|
||||
|
||||
/* Some #defines that may be needed if ANS isn't installed on that system */
|
||||
|
||||
#ifndef T_ATMA
|
||||
#define T_ATMA 34
|
||||
#endif
|
||||
#ifndef ATMA_AESA
|
||||
#define ATMA_AESA 0
|
||||
#endif
|
||||
#ifndef ATMA_E164
|
||||
#define ATMA_E164 1
|
||||
#endif
|
||||
|
||||
/* Return codes for text2atm and atm2text */
|
||||
|
||||
#define TRY_OTHER -2
|
||||
#define FATAL -1 /* must be -1 */
|
||||
|
||||
|
||||
int ans_byname(const char *text,struct sockaddr_atmsvc *addr,int length,
|
||||
int flags);
|
||||
int ans_byaddr(char *buffer,int length,const struct sockaddr_atmsvc *addr,
|
||||
int flags);
|
||||
|
||||
#endif
|
||||
45
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/atmsap.h
vendored
Normal file
45
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/atmsap.h
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
/* atmsap.h - ATM Service Access Point addressing definitions */
|
||||
|
||||
/* Written 1996-1998 by Werner Almesberger, EPFL LRC/ICA */
|
||||
|
||||
|
||||
#ifndef _ATMSAP_H
|
||||
#define _ATMSAP_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <linux/atmsap.h>
|
||||
|
||||
|
||||
/*
|
||||
* Selected ISO/IEC TR 9577 Network Layer Protocol Identifiers (NLPID)
|
||||
*/
|
||||
|
||||
#define NLPID_IEEE802_1_SNAP 0x80 /* IEEE 802.1 SNAP */
|
||||
|
||||
/*
|
||||
* Selected Organizationally Unique Identifiers (OUIs)
|
||||
*/
|
||||
|
||||
#define ATM_FORUM_OUI "\x00\xA0\x3E" /* ATM Forum */
|
||||
#define EPFL_OUI "\x00\x60\xD7" /* EPF Lausanne, CH */
|
||||
|
||||
/*
|
||||
* Selected vendor-specific application identifiers (for B-HLI). Such an
|
||||
* identifier consists of three bytes containing the OUI, followed by four
|
||||
* bytes assigned by the organization owning the OUI.
|
||||
*/
|
||||
|
||||
#define ANS_HLT_VS_ID ATM_FORUM_OUI "\x00\x00\x00\x01"
|
||||
/* ATM Name System, af-saa-0069.000 */
|
||||
#define VOD_HLT_VS_ID ATM_FORUM_OUI "\x00\x00\x00\x02"
|
||||
/* VoD, af-saa-0049.001 */
|
||||
#define AREQUIPA_HLT_VS_ID EPFL_OUI "\x01\x00\x00\x01" /* Arequipa */
|
||||
#define TTCP_HLT_VS_ID EPFL_OUI "\x01\x00\x00\x03" /* ttcp_atm */
|
||||
|
||||
|
||||
/* Mapping of "well-known" TCP, UDP, etc. port numbers to ATM BHLIs.
|
||||
btd-saa-api-bhli-01.02 */
|
||||
|
||||
void atm_tcpip_port_mapping(char *vs_id,uint8_t protocol,uint16_t port);
|
||||
|
||||
#endif
|
||||
51
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/misc.c
vendored
Normal file
51
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/misc.c
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
/* misc.c - Miscellaneous library functions */
|
||||
|
||||
/* Written 1997-2000 by Werner Almesberger, EPFL-ICA/ICA */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h> /* for htons */
|
||||
|
||||
#include <atm.h>
|
||||
#include <atmsap.h>
|
||||
|
||||
|
||||
int __atmlib_fetch(const char **pos,...)
|
||||
{
|
||||
const char *value;
|
||||
int ref_len,best_len,len;
|
||||
int i,best;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap,pos);
|
||||
ref_len = strlen(*pos);
|
||||
best_len = 0;
|
||||
best = -1;
|
||||
for (i = 0; (value = va_arg(ap,const char *)); i++) {
|
||||
len = strlen(value);
|
||||
if (*value != '!' && len <= ref_len && len > best_len &&
|
||||
!strncasecmp(*pos,value,len)) {
|
||||
best = i;
|
||||
best_len = len;
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
if (best > -1) (*pos) += best_len;
|
||||
return best;
|
||||
}
|
||||
|
||||
|
||||
void atm_tcpip_port_mapping(char *vs_id,uint8_t protocol,uint16_t port)
|
||||
{
|
||||
memcpy(vs_id,ATM_FORUM_OUI "\x01",4);
|
||||
vs_id[4] = protocol; /* e.g. IP_TCP or IP_UDP; from netinet/protocols.h */
|
||||
vs_id[5] = (htons(port) >> 8) & 255;
|
||||
vs_id[6] = htons(port) & 255;
|
||||
}
|
||||
225
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/pppoatm.c
vendored
Normal file
225
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/pppoatm.c
vendored
Normal file
@ -0,0 +1,225 @@
|
||||
/* pppoatm.c - pppd plugin to implement PPPoATM protocol.
|
||||
*
|
||||
* Copyright 2000 Mitchell Blank Jr.
|
||||
* Based in part on work from Jens Axboe and Paul Mackerras.
|
||||
* Updated to ppp-2.4.1 by Bernhard Kaindl
|
||||
*
|
||||
* Updated to ppp-2.4.2 by David Woodhouse 2004.
|
||||
* - disconnect method added
|
||||
* - remove_options() abuse removed.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "pppd.h"
|
||||
#include "pathnames.h"
|
||||
#include "fsm.h" /* Needed for lcp.h to include cleanly */
|
||||
#include "lcp.h"
|
||||
#include <atm.h>
|
||||
#include <linux/atmdev.h>
|
||||
#include <linux/atmppp.h>
|
||||
#include <sys/stat.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
const char pppd_version[] = VERSION;
|
||||
|
||||
static struct sockaddr_atmpvc pvcaddr;
|
||||
static char *qosstr = NULL;
|
||||
static bool llc_encaps = 0;
|
||||
static bool vc_encaps = 0;
|
||||
static int device_got_set = 0;
|
||||
static int pppoatm_max_mtu, pppoatm_max_mru;
|
||||
static int setdevname_pppoatm(const char *cp, const char **argv, int doit);
|
||||
struct channel pppoa_channel;
|
||||
static int pppoa_fd = -1;
|
||||
|
||||
static option_t pppoa_options[] = {
|
||||
{ "device name", o_wild, (void *) &setdevname_pppoatm,
|
||||
"ATM service provider IDs: VPI.VCI",
|
||||
OPT_DEVNAM | OPT_PRIVFIX | OPT_NOARG | OPT_A2STRVAL | OPT_STATIC,
|
||||
devnam},
|
||||
{ "llc-encaps", o_bool, &llc_encaps,
|
||||
"use LLC encapsulation for PPPoATM", 1},
|
||||
{ "vc-encaps", o_bool, &vc_encaps,
|
||||
"use VC multiplexing for PPPoATM (default)", 1},
|
||||
{ "qos", o_string, &qosstr,
|
||||
"set QoS for PPPoATM connection", 1},
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
/* returns:
|
||||
* -1 if there's a problem with setting the device
|
||||
* 0 if we can't parse "cp" as a valid name of a device
|
||||
* 1 if "cp" is a reasonable thing to name a device
|
||||
* Note that we don't actually open the device at this point
|
||||
* We do need to fill in:
|
||||
* devnam: a string representation of the device
|
||||
* devstat: a stat structure of the device. In this case
|
||||
* we're not opening a device, so we just make sure
|
||||
* to set up S_ISCHR(devstat.st_mode) != 1, so we
|
||||
* don't get confused that we're on stdin.
|
||||
*/
|
||||
int (*old_setdevname_hook)(const char* cp) = NULL;
|
||||
static int setdevname_pppoatm(const char *cp, const char **argv, int doit)
|
||||
{
|
||||
struct sockaddr_atmpvc addr;
|
||||
extern struct stat devstat;
|
||||
if (device_got_set)
|
||||
return 0;
|
||||
//info("PPPoATM setdevname_pppoatm: '%s'", cp);
|
||||
memset(&addr, 0, sizeof addr);
|
||||
if (text2atm(cp, (struct sockaddr *) &addr, sizeof(addr),
|
||||
T2A_PVC | T2A_NAME) < 0) {
|
||||
if(doit)
|
||||
info("atm does not recognize: %s", cp);
|
||||
return 0;
|
||||
}
|
||||
if (!doit) return 1;
|
||||
//if (!dev_set_ok()) return -1;
|
||||
memcpy(&pvcaddr, &addr, sizeof pvcaddr);
|
||||
strlcpy(devnam, cp, sizeof devnam);
|
||||
devstat.st_mode = S_IFSOCK;
|
||||
if (the_channel != &pppoa_channel) {
|
||||
the_channel = &pppoa_channel;
|
||||
lcp_wantoptions[0].neg_accompression = 0;
|
||||
lcp_allowoptions[0].neg_accompression = 0;
|
||||
lcp_wantoptions[0].neg_asyncmap = 0;
|
||||
lcp_allowoptions[0].neg_asyncmap = 0;
|
||||
lcp_wantoptions[0].neg_pcompression = 0;
|
||||
}
|
||||
info("PPPoATM setdevname_pppoatm - SUCCESS:%s", cp);
|
||||
device_got_set = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define pppoatm_overhead() (llc_encaps ? 6 : 2)
|
||||
|
||||
static void no_device_given_pppoatm(void)
|
||||
{
|
||||
fatal("No vpi.vci specified");
|
||||
}
|
||||
|
||||
static void set_line_discipline_pppoatm(int fd)
|
||||
{
|
||||
struct atm_backend_ppp be;
|
||||
be.backend_num = ATM_BACKEND_PPP;
|
||||
if (!llc_encaps)
|
||||
be.encaps = PPPOATM_ENCAPS_VC;
|
||||
else if (!vc_encaps)
|
||||
be.encaps = PPPOATM_ENCAPS_LLC;
|
||||
else
|
||||
be.encaps = PPPOATM_ENCAPS_AUTODETECT;
|
||||
if (ioctl(fd, ATM_SETBACKEND, &be) < 0)
|
||||
fatal("ioctl(ATM_SETBACKEND): %m");
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void reset_line_discipline_pppoatm(int fd)
|
||||
{
|
||||
atm_backend_t be = ATM_BACKEND_RAW;
|
||||
/* 2.4 doesn't support this yet */
|
||||
(void) ioctl(fd, ATM_SETBACKEND, &be);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int connect_pppoatm(void)
|
||||
{
|
||||
int fd;
|
||||
struct atm_qos qos;
|
||||
|
||||
/* XXX: This won't work on Android */
|
||||
system ("/sbin/modprobe pppoatm");
|
||||
|
||||
if (!device_got_set)
|
||||
no_device_given_pppoatm();
|
||||
fd = socket(AF_ATMPVC, SOCK_DGRAM, 0);
|
||||
if (fd < 0)
|
||||
fatal("failed to create socket: %m");
|
||||
memset(&qos, 0, sizeof qos);
|
||||
qos.txtp.traffic_class = qos.rxtp.traffic_class = ATM_UBR;
|
||||
/* TODO: support simplified QoS setting */
|
||||
if (qosstr != NULL)
|
||||
if (text2qos(qosstr, &qos, 0))
|
||||
fatal("Can't parse QoS: \"%s\"");
|
||||
qos.txtp.max_sdu = lcp_allowoptions[0].mru + pppoatm_overhead();
|
||||
qos.rxtp.max_sdu = lcp_wantoptions[0].mru + pppoatm_overhead();
|
||||
qos.aal = ATM_AAL5;
|
||||
if (setsockopt(fd, SOL_ATM, SO_ATMQOS, &qos, sizeof(qos)) < 0)
|
||||
fatal("setsockopt(SO_ATMQOS): %m");
|
||||
/* TODO: accept on SVCs... */
|
||||
if (connect(fd, (struct sockaddr *) &pvcaddr,
|
||||
sizeof(struct sockaddr_atmpvc)))
|
||||
fatal("connect(%s): %m", devnam);
|
||||
pppoatm_max_mtu = lcp_allowoptions[0].mru;
|
||||
pppoatm_max_mru = lcp_wantoptions[0].mru;
|
||||
set_line_discipline_pppoatm(fd);
|
||||
strlcpy(ppp_devnam, devnam, sizeof(ppp_devnam));
|
||||
pppoa_fd = fd;
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void disconnect_pppoatm(void)
|
||||
{
|
||||
close(pppoa_fd);
|
||||
}
|
||||
|
||||
static void send_config_pppoa(int mtu,
|
||||
u_int32_t asyncmap,
|
||||
int pcomp,
|
||||
int accomp)
|
||||
{
|
||||
int sock;
|
||||
struct ifreq ifr;
|
||||
if (mtu > pppoatm_max_mtu)
|
||||
error("Couldn't increase MTU to %d", mtu);
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0)
|
||||
fatal("Couldn't create IP socket: %m");
|
||||
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_mtu = mtu;
|
||||
if (ioctl(sock, SIOCSIFMTU, (caddr_t) &ifr) < 0)
|
||||
fatal("ioctl(SIOCSIFMTU): %m");
|
||||
(void) close (sock);
|
||||
}
|
||||
|
||||
static void recv_config_pppoa(int mru,
|
||||
u_int32_t asyncmap,
|
||||
int pcomp,
|
||||
int accomp)
|
||||
{
|
||||
if (mru > pppoatm_max_mru)
|
||||
error("Couldn't increase MRU to %d", mru);
|
||||
}
|
||||
|
||||
void plugin_init(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
extern int new_style_driver; /* From sys-linux.c */
|
||||
if (!ppp_available() && !new_style_driver)
|
||||
fatal("Kernel doesn't support ppp_generic - "
|
||||
"needed for PPPoATM");
|
||||
#else
|
||||
fatal("No PPPoATM support on this OS");
|
||||
#endif
|
||||
info("PPPoATM plugin_init");
|
||||
add_options(pppoa_options);
|
||||
}
|
||||
struct channel pppoa_channel = {
|
||||
options: pppoa_options,
|
||||
process_extra_options: NULL,
|
||||
check_options: NULL,
|
||||
connect: &connect_pppoatm,
|
||||
disconnect: &disconnect_pppoatm,
|
||||
establish_ppp: &generic_establish_ppp,
|
||||
disestablish_ppp: &generic_disestablish_ppp,
|
||||
send_config: &send_config_pppoa,
|
||||
recv_config: &recv_config_pppoa,
|
||||
close: NULL,
|
||||
cleanup: NULL
|
||||
};
|
||||
249
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/text2atm.c
vendored
Normal file
249
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/text2atm.c
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
/* text2atm.c - Converts textual representation of ATM address to binary
|
||||
encoding */
|
||||
|
||||
/* Written 1995-2000 by Werner Almesberger, EPFL-LRC/ICA */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "atm.h"
|
||||
#include "atmsap.h"
|
||||
#include "atmres.h"
|
||||
|
||||
|
||||
static int try_pvc(const char *text,struct sockaddr_atmpvc *addr,int flags)
|
||||
{
|
||||
int part[3];
|
||||
int i;
|
||||
|
||||
part[0] = part[1] = part[2] = 0;
|
||||
i = 0;
|
||||
while (1) {
|
||||
if (!*text) return FATAL; /* empty or ends with a dot */
|
||||
if (i == 3) return TRY_OTHER; /* too long */
|
||||
if (isdigit(*text)) {
|
||||
if (*text == '0' && isdigit(text[1])) return TRY_OTHER;
|
||||
/* no leading zeroes */
|
||||
do {
|
||||
if (part[i] > INT_MAX/10) return TRY_OTHER;/* number too big */
|
||||
part[i] = part[i]*10+*text++-'0';
|
||||
}
|
||||
while (isdigit(*text));
|
||||
i++;
|
||||
if (!*text) break;
|
||||
if (*text++ != '.') return TRY_OTHER; /* non-PVC character */
|
||||
continue;
|
||||
}
|
||||
if (*text == '*') {
|
||||
if (!(flags & T2A_WILDCARD)) return FATAL; /* not allowed */
|
||||
part[i++] = ATM_ITF_ANY; /* all *_ANY have the same value */
|
||||
}
|
||||
else {
|
||||
if (*text != '?') return TRY_OTHER; /* invalid character */
|
||||
if (!(flags & T2A_UNSPEC)) return FATAL; /* not allowed */
|
||||
part[i++] = ATM_VPI_UNSPEC; /* all *_UNSPEC have the same
|
||||
value */
|
||||
}
|
||||
if (!*++text) break;
|
||||
if (*text++ != '.') return FATAL; /* dot required */
|
||||
}
|
||||
if (i < 2) return TRY_OTHER; /* no dots */
|
||||
if (i == 2) {
|
||||
part[2] = part[1];
|
||||
part[1] = part[0];
|
||||
part[0] = 0; /* default interface */
|
||||
}
|
||||
if (part[0] > SHRT_MAX || part[2] > ATM_MAX_VCI)
|
||||
return TRY_OTHER; /* too big */
|
||||
if (part[1] > (flags & T2A_NNI ? ATM_MAX_VPI_NNI : ATM_MAX_VPI))
|
||||
return TRY_OTHER; /* too big */
|
||||
if (part[0] == ATM_VPI_UNSPEC) return FATAL; /* bad */
|
||||
addr->sap_family = AF_ATMPVC;
|
||||
addr->sap_addr.itf = part[0];
|
||||
addr->sap_addr.vpi = part[1];
|
||||
addr->sap_addr.vci = part[2];
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int do_try_nsap(const char *text,struct sockaddr_atmsvc *addr,int flags)
|
||||
{
|
||||
const char *walk;
|
||||
int count,pos,dot;
|
||||
int offset,len;
|
||||
char value;
|
||||
|
||||
count = dot = 0;
|
||||
for (walk = text; *walk; walk++)
|
||||
if (isdigit(*walk)) {
|
||||
if (count++ == 15) break;
|
||||
dot = 1;
|
||||
}
|
||||
else if (*text != '.') break;
|
||||
else if (!dot) return FATAL; /* two dots in a row */
|
||||
else dot = 0;
|
||||
if (*walk != ':') {
|
||||
pos = 0;
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
if (!dot || *text == '0') return FATAL;
|
||||
addr->sas_addr.prv[0] = ATM_AFI_E164;
|
||||
addr->sas_addr.prv[1] = 0;
|
||||
memset(addr->sas_addr.prv+1,0,8);
|
||||
for (pos = 18-count-1; *text; text++) {
|
||||
if (*text == '.') continue;
|
||||
if (*text == ':') break;
|
||||
else {
|
||||
if (pos & 1) addr->sas_addr.prv[pos >> 1] |= *text-'0';
|
||||
else addr->sas_addr.prv[pos >> 1] = (*text-'0') << 4;
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
addr->sas_addr.prv[8] |= 0xf;
|
||||
text++;
|
||||
pos++;
|
||||
offset = 72;
|
||||
}
|
||||
for (dot = 0; *text; text++)
|
||||
if (isxdigit(*text)) {
|
||||
if (pos == ATM_ESA_LEN*2) return TRY_OTHER; /* too long */
|
||||
value = isdigit(*text) ? *text-'0' : (islower(*text) ?
|
||||
toupper(*text) : *text)-'A'+10;
|
||||
if (pos & 1) addr->sas_addr.prv[pos >> 1] |= value;
|
||||
else addr->sas_addr.prv[pos >> 1] = value << 4;
|
||||
pos++;
|
||||
dot = 1;
|
||||
}
|
||||
else
|
||||
if (*text == '/' && (flags & T2A_WILDCARD)) break;
|
||||
else if (*text != '.') return TRY_OTHER;
|
||||
else {
|
||||
if (!dot) return FATAL; /* two dots in a row */
|
||||
dot = 0;
|
||||
}
|
||||
if (!dot) return FATAL;
|
||||
if (pos > 1 && !*addr->sas_addr.prv)
|
||||
return TRY_OTHER; /* no leading zeroes */
|
||||
if (!*text)
|
||||
return pos != ATM_ESA_LEN*2 ? TRY_OTHER : ATM_ESA_LEN*2;
|
||||
/* handle bad length */
|
||||
len = 0;
|
||||
while (*++text) {
|
||||
if (!isdigit(*text)) return -1; /* non-digit in length */
|
||||
if (len >= pos*4) return -1; /* too long */
|
||||
len = len*10+*text-'0';
|
||||
}
|
||||
if (len > 7 && addr->sas_addr.prv[0] != ATM_AFI_E164) offset = 72;
|
||||
if (len < offset) return FATAL;
|
||||
return len > pos*4 ? TRY_OTHER : len;
|
||||
}
|
||||
|
||||
|
||||
static int try_nsap(const char *text,struct sockaddr_atmsvc *addr,int flags)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = do_try_nsap(text,addr,flags);
|
||||
if (result < 0) return result;
|
||||
addr->sas_family = AF_ATMSVC;
|
||||
*addr->sas_addr.pub = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int try_e164(const char *text,struct sockaddr_atmsvc *addr,int flags)
|
||||
{
|
||||
int i,dot,result;
|
||||
|
||||
if (*text == ':' || *text == '+') text++;
|
||||
for (i = dot = 0; *text; text++)
|
||||
if (isdigit(*text)) {
|
||||
if (i == ATM_E164_LEN) return TRY_OTHER; /* too long */
|
||||
addr->sas_addr.pub[i++] = *text;
|
||||
dot = 1;
|
||||
}
|
||||
else if (*text != '.') break;
|
||||
else {
|
||||
if (!dot) return TRY_OTHER; /* two dots in a row */
|
||||
dot = 0;
|
||||
}
|
||||
if (!dot) return TRY_OTHER;
|
||||
addr->sas_addr.pub[i] = 0;
|
||||
*addr->sas_addr.prv = 0;
|
||||
result = 0;
|
||||
if (*text) {
|
||||
if (*text++ != '+') return TRY_OTHER;
|
||||
else {
|
||||
result = do_try_nsap(text,addr,flags);
|
||||
if (result < 0) return FATAL;
|
||||
}
|
||||
}
|
||||
addr->sas_family = AF_ATMSVC;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int search(FILE *file,const char *text,struct sockaddr *addr,int length,
|
||||
int flags)
|
||||
{
|
||||
char line[MAX_ATM_NAME_LEN+1];
|
||||
const char *here;
|
||||
int result;
|
||||
|
||||
while (fgets(line,MAX_ATM_NAME_LEN,file)) {
|
||||
if (!strtok(line,"\t\n ")) continue;
|
||||
while ((here = strtok(NULL,"\t\n ")))
|
||||
if (!strcasecmp(here,text)) {
|
||||
here = strtok(line,"\t\n ");
|
||||
result = text2atm(here,addr,length,flags);
|
||||
if (result >= 0) return result;
|
||||
}
|
||||
}
|
||||
return TRY_OTHER;
|
||||
}
|
||||
|
||||
|
||||
static int try_name(const char *text,struct sockaddr *addr,int length,
|
||||
int flags)
|
||||
{
|
||||
FILE *file;
|
||||
int result;
|
||||
|
||||
if (!(file = fopen(HOSTS_ATM,"r"))) return TRY_OTHER;
|
||||
result = search(file,text,addr,length,flags);
|
||||
(void) fclose(file);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
int text2atm(const char *text,struct sockaddr *addr,int length,int flags)
|
||||
{
|
||||
int result;
|
||||
|
||||
if (!*text) return -1;
|
||||
if (!(flags & (T2A_PVC | T2A_SVC))) flags |= T2A_PVC | T2A_SVC;
|
||||
if (length < sizeof(struct sockaddr_atmpvc)) return -1;
|
||||
if (flags & T2A_PVC) {
|
||||
result = try_pvc(text,(struct sockaddr_atmpvc *) addr,flags);
|
||||
if (result != TRY_OTHER) return result;
|
||||
}
|
||||
if ((flags & T2A_SVC) && length >= sizeof(struct sockaddr_atmsvc)) {
|
||||
result = try_nsap(text,(struct sockaddr_atmsvc *) addr,flags);
|
||||
if (result != TRY_OTHER) return result;
|
||||
result = try_e164(text,(struct sockaddr_atmsvc *) addr,flags);
|
||||
if (result != TRY_OTHER) return result;
|
||||
}
|
||||
if (!(flags & T2A_NAME)) return -1;
|
||||
result = try_name(text,addr,length,flags & ~T2A_NAME);
|
||||
if (result == TRY_OTHER && !(flags & T2A_LOCAL))
|
||||
result = ans_byname(text,(struct sockaddr_atmsvc *) addr,length,flags);
|
||||
if (result != TRY_OTHER) return result;
|
||||
return -1;
|
||||
}
|
||||
180
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/text2qos.c
vendored
Normal file
180
vendor/aw/homlet/external/pppoe/pppd/plugins/pppoatm/text2qos.c
vendored
Normal file
@ -0,0 +1,180 @@
|
||||
/* text2qos.c - Converts textual representation of QOS parameters to binary
|
||||
encoding */
|
||||
|
||||
/* Written 1996-2000 by Werner Almesberger, EPFL-LRC/ICA */
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "atm.h"
|
||||
|
||||
|
||||
#define fetch __atmlib_fetch
|
||||
|
||||
|
||||
#define RATE_ERROR -2
|
||||
|
||||
|
||||
int __t2q_get_rate(const char **text,int up)
|
||||
{
|
||||
const char mult[] = "kKmMgGg";
|
||||
const char *multiplier;
|
||||
char *end;
|
||||
unsigned int rate,fract;
|
||||
int power;
|
||||
|
||||
if (!strncmp(*text,"max",3)) {
|
||||
*text += 3;
|
||||
return ATM_MAX_PCR;
|
||||
}
|
||||
rate = strtoul(*text,&end,10);
|
||||
power = fract = 0;
|
||||
if (*end == '.')
|
||||
for (end++; *end && isdigit(*end); end++) {
|
||||
fract = fract*10+*end-48;
|
||||
if (--power == -9) break;
|
||||
}
|
||||
multiplier = NULL;
|
||||
if (*end && (multiplier = strchr(mult,*end))) {
|
||||
while (multiplier >= mult) {
|
||||
if (rate > UINT_MAX/1000) return RATE_ERROR;
|
||||
rate *= 1000;
|
||||
power += 3;
|
||||
multiplier -= 2;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
while (power && fract)
|
||||
if (power < 0) {
|
||||
fract /= 10;
|
||||
power++;
|
||||
}
|
||||
else {
|
||||
fract *= 10;
|
||||
power--;
|
||||
}
|
||||
rate += fract;
|
||||
if (strlen(end) < 3) {
|
||||
if (multiplier) return RATE_ERROR;
|
||||
}
|
||||
else if (!strncmp(end,"cps",3)) end += 3;
|
||||
else if (!strncmp(end,"bps",3)) {
|
||||
rate = (rate+(up ? 8*ATM_CELL_PAYLOAD-1 : 0))/8/
|
||||
ATM_CELL_PAYLOAD;
|
||||
end += 3;
|
||||
}
|
||||
else if (multiplier) return RATE_ERROR;
|
||||
if (rate > INT_MAX) return RATE_ERROR;
|
||||
*text = end;
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
static int params(const char **text,struct atm_trafprm *a,
|
||||
struct atm_trafprm *b)
|
||||
{
|
||||
int value;
|
||||
char *end;
|
||||
|
||||
if (*(*text)++ != ':') return -1;
|
||||
while (1) {
|
||||
if (!**text) return -1;
|
||||
switch (fetch(text,"max_pcr=","pcr=","min_pcr=","max_sdu=","sdu=",
|
||||
NULL)) {
|
||||
case 0:
|
||||
if ((value = __t2q_get_rate(text,0)) == RATE_ERROR) return -1;
|
||||
if (a) a->max_pcr = value;
|
||||
if (b) b->max_pcr = value;
|
||||
break;
|
||||
case 1:
|
||||
if ((value = __t2q_get_rate(text,0)) == RATE_ERROR) return -1;
|
||||
if (a) a->pcr = value;
|
||||
if (b) b->pcr = value;
|
||||
break;
|
||||
case 2:
|
||||
if ((value = __t2q_get_rate(text,1)) == RATE_ERROR) return -1;
|
||||
if (value == ATM_MAX_PCR) return -1;
|
||||
if (a) a->min_pcr = value;
|
||||
if (b) b->min_pcr = value;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
value = strtol(*text,&end,10);
|
||||
if (value < 0) return -1;
|
||||
*text = end;
|
||||
if (a) a->max_sdu = value;
|
||||
if (b) b->max_sdu = value;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
if (!**text) break;
|
||||
if (*(*text)++ != ',') return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int text2qos(const char *text,struct atm_qos *qos,int flags)
|
||||
{
|
||||
int traffic_class,aal;
|
||||
|
||||
traffic_class = ATM_NONE;
|
||||
aal = ATM_NO_AAL;
|
||||
do {
|
||||
static const unsigned char aal_number[] = { ATM_AAL0, ATM_AAL5 };
|
||||
int item;
|
||||
|
||||
item = fetch(&text,"!none","ubr","cbr","vbr","abr","aal0","aal5",NULL);
|
||||
switch (item) {
|
||||
case 1:
|
||||
case 2:
|
||||
/* we don't support VBR yet */
|
||||
case 4:
|
||||
traffic_class = item;
|
||||
break;
|
||||
case 5:
|
||||
case 6:
|
||||
aal = aal_number[item-5];
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (*text == ',' ? text++ : 0);
|
||||
if (!traffic_class) return -1;
|
||||
if (qos && !(flags & T2Q_DEFAULTS)) memset(qos,0,sizeof(*qos));
|
||||
if (qos) qos->txtp.traffic_class = qos->rxtp.traffic_class = traffic_class;
|
||||
if (qos && aal) qos->aal = aal;
|
||||
if (!*text) return 0;
|
||||
if (params(&text,qos ? &qos->txtp : NULL,qos ? &qos->rxtp : NULL))
|
||||
return -1;
|
||||
if (!*text) return 0;
|
||||
switch (fetch(&text,"tx","rx",NULL)) {
|
||||
case 0:
|
||||
if (!fetch(&text,":none",NULL)) {
|
||||
if (qos) qos->txtp.traffic_class = ATM_NONE;
|
||||
if (*text == ',') text++;
|
||||
break;
|
||||
}
|
||||
if (params(&text,qos ? &qos->txtp : NULL,NULL)) return -1;
|
||||
break;
|
||||
case 1:
|
||||
text -= 2;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
if (!*text) return 0;
|
||||
if (fetch(&text,"rx",NULL)) return -1;
|
||||
if (!fetch(&text,":none",NULL) && qos) qos->rxtp.traffic_class = ATM_NONE;
|
||||
else if (params(&text,qos ? &qos->rxtp : NULL,NULL)) return -1;
|
||||
return *text ? -1 : 0;
|
||||
}
|
||||
90
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/COPYRIGHT
vendored
Normal file
90
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/COPYRIGHT
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
See the respective source files to find out which copyrights apply.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C) 2002 Roaring Penguin Software Inc.
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that this
|
||||
copyright and permission notice appear on all copies and supporting
|
||||
documentation, the name of Roaring Penguin Software Inc. not be used
|
||||
in advertising or publicity pertaining to distribution of the program
|
||||
without specific prior permission, and notice be given in supporting
|
||||
documentation that copying and distribution is by permission of
|
||||
Roaring Penguin Software Inc..
|
||||
|
||||
Roaring Penguin Software Inc. makes no representations about the
|
||||
suitability of this software for any purpose. It is provided "as is"
|
||||
without express or implied warranty.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C) 1995,1996,1997,1998 Lars Fenneberg <lf@elemental.net>
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that this copyright and
|
||||
permission notice appear on all copies and supporting documentation, the
|
||||
name of Lars Fenneberg not be used in advertising or publicity pertaining to
|
||||
distribution of the program without specific prior permission, and notice be
|
||||
given in supporting documentation that copying and distribution is by
|
||||
permission of Lars Fenneberg.
|
||||
|
||||
Lars Fenneberg makes no representations about the suitability of this
|
||||
software for any purpose. It is provided "as is" without express or implied
|
||||
warranty.
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Copyright 1992 Livingston Enterprises, Inc.
|
||||
Livingston Enterprises, Inc. 6920 Koll Center Parkway Pleasanton, CA 94566
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
purpose and without fee is hereby granted, provided that this copyright
|
||||
and permission notice appear on all copies and supporting documentation,
|
||||
the name of Livingston Enterprises, Inc. not be used in advertising or
|
||||
publicity pertaining to distribution of the program without specific
|
||||
prior permission, and notice be given in supporting documentation that
|
||||
copying and distribution is by permission of Livingston Enterprises, Inc.
|
||||
|
||||
Livingston Enterprises, Inc. makes no representations about the suitability
|
||||
of this software for any purpose. It is provided "as is" without express
|
||||
or implied warranty.
|
||||
------------------------------------------------------------------------------
|
||||
[C] The Regents of the University of Michigan and Merit Network, Inc. 1992,
|
||||
1993, 1994, 1995 All Rights Reserved
|
||||
|
||||
Permission to use, copy, modify, and distribute this software and its
|
||||
documentation for any purpose and without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear in all
|
||||
copies of the software and derivative works or modified versions thereof,
|
||||
and that both the copyright notice and this permission and disclaimer
|
||||
notice appear in supporting documentation.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
|
||||
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF THE
|
||||
UNIVERSITY OF MICHIGAN AND MERIT NETWORK, INC. DO NOT WARRANT THAT THE
|
||||
FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET LICENSEE'S REQUIREMENTS OR
|
||||
THAT OPERATION WILL BE UNINTERRUPTED OR ERROR FREE. The Regents of the
|
||||
University of Michigan and Merit Network, Inc. shall not be liable for any
|
||||
special, indirect, incidental or consequential damages with respect to any
|
||||
claim by Licensee or any third party arising from use of the software.
|
||||
------------------------------------------------------------------------------
|
||||
Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991.
|
||||
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.
|
||||
------------------------------------------------------------------------------
|
||||
65
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/Makefile.linux
vendored
Normal file
65
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/Makefile.linux
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
# Makefile for RADIUS plugin
|
||||
#
|
||||
# Copyright 2002 Roaring Penguin Software Inc.
|
||||
#
|
||||
|
||||
DESTDIR = @DESTDIR@
|
||||
MANDIR = $(DESTDIR)/share/man/man8
|
||||
LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION)
|
||||
|
||||
VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h)
|
||||
|
||||
INSTALL = install
|
||||
|
||||
PLUGIN=radius.so radattr.so radrealms.so
|
||||
CFLAGS=-I. -I../.. -I../../../include -O2 -fPIC -DRC_LOG_FACILITY=LOG_DAEMON
|
||||
|
||||
# Uncomment the next line to include support for Microsoft's
|
||||
# MS-CHAP authentication protocol.
|
||||
CHAPMS=y
|
||||
# Uncomment the next line to include support for MPPE.
|
||||
MPPE=y
|
||||
# Uncomment the next lint to include support for traffic limiting
|
||||
MAXOCTETS=y
|
||||
|
||||
ifdef CHAPMS
|
||||
CFLAGS += -DCHAPMS=1
|
||||
ifdef MPPE
|
||||
CFLAGS += -DMPPE=1
|
||||
endif
|
||||
endif
|
||||
ifdef MAXOCTETS
|
||||
CFLAGS += -DMAXOCTETS=1
|
||||
endif
|
||||
|
||||
all: $(PLUGIN)
|
||||
|
||||
install: all
|
||||
$(INSTALL) -d -m 755 $(LIBDIR)
|
||||
$(INSTALL) -s -c -m 755 radius.so $(LIBDIR)
|
||||
$(INSTALL) -s -c -m 755 radattr.so $(LIBDIR)
|
||||
$(INSTALL) -s -c -m 755 radrealms.so $(LIBDIR)
|
||||
$(INSTALL) -c -m 444 pppd-radius.8 $(MANDIR)
|
||||
$(INSTALL) -c -m 444 pppd-radattr.8 $(MANDIR)
|
||||
|
||||
radius.so: radius.o libradiusclient.a
|
||||
$(CC) -o radius.so -shared radius.o libradiusclient.a
|
||||
|
||||
radattr.so: radattr.o
|
||||
$(CC) -o radattr.so -shared radattr.o
|
||||
|
||||
radrealms.so: radrealms.o
|
||||
$(CC) -o radrealms.so -shared radrealms.o
|
||||
|
||||
CLIENTOBJS = avpair.o buildreq.o config.o dict.o ip_util.o \
|
||||
clientid.o sendserver.o lock.o util.o md5.o
|
||||
libradiusclient.a: $(CLIENTOBJS)
|
||||
$(AR) rv $@ $?
|
||||
|
||||
clean:
|
||||
rm -f *.o *.so *.a
|
||||
|
||||
distclean:
|
||||
rm -f *.o *.so *.a
|
||||
|
||||
dist-clean: distclean
|
||||
795
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/avpair.c
vendored
Normal file
795
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/avpair.c
vendored
Normal file
@ -0,0 +1,795 @@
|
||||
/*
|
||||
* $Id: avpair.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
|
||||
*
|
||||
* Copyright (C) 1995 Lars Fenneberg
|
||||
*
|
||||
* Copyright 1992 Livingston Enterprises, Inc.
|
||||
*
|
||||
* Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
|
||||
* and Merit Network, Inc. All Rights Reserved
|
||||
*
|
||||
* See the file COPYRIGHT for the respective terms and conditions.
|
||||
* If the file is missing contact me at lf@elemental.net
|
||||
* and I'll send you a copy.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <includes.h>
|
||||
#include <radiusclient.h>
|
||||
|
||||
static void rc_extract_vendor_specific_attributes(int attrlen,
|
||||
unsigned char *ptr,
|
||||
VALUE_PAIR **vp);
|
||||
/*
|
||||
* Function: rc_avpair_add
|
||||
*
|
||||
* Purpose: add an attribute-value pair to the given list.
|
||||
*
|
||||
* Returns: pointer to added a/v pair upon success, NULL pointer upon failure.
|
||||
*
|
||||
* Remarks: Always appends the new pair to the end of the list.
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE_PAIR *rc_avpair_add (VALUE_PAIR **list, int attrid, void *pval, int len,
|
||||
int vendorcode)
|
||||
{
|
||||
VALUE_PAIR *vp;
|
||||
|
||||
vp = rc_avpair_new (attrid, pval, len, vendorcode);
|
||||
|
||||
if (vp != (VALUE_PAIR *) NULL)
|
||||
{
|
||||
rc_avpair_insert (list, (VALUE_PAIR *) NULL, vp);
|
||||
}
|
||||
|
||||
return vp;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_assign
|
||||
*
|
||||
* Purpose: assign the given value to an attribute-value pair.
|
||||
*
|
||||
* Returns: 0 on success,
|
||||
* -1 on failure.
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_avpair_assign (VALUE_PAIR *vp, void *pval, int len)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
switch (vp->type)
|
||||
{
|
||||
case PW_TYPE_STRING:
|
||||
|
||||
if (((len == 0) && (strlen ((char *) pval)) > AUTH_STRING_LEN)
|
||||
|| (len > AUTH_STRING_LEN)) {
|
||||
error("rc_avpair_assign: bad attribute length");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
memcpy(vp->strvalue, (char *)pval, len);
|
||||
vp->strvalue[len] = '\0';
|
||||
vp->lvalue = len;
|
||||
} else {
|
||||
strncpy (vp->strvalue, (char *) pval, AUTH_STRING_LEN);
|
||||
vp->lvalue = strlen((char *) pval);
|
||||
}
|
||||
|
||||
result = 0;
|
||||
break;
|
||||
|
||||
case PW_TYPE_DATE:
|
||||
case PW_TYPE_INTEGER:
|
||||
case PW_TYPE_IPADDR:
|
||||
|
||||
vp->lvalue = * (UINT4 *) pval;
|
||||
|
||||
result = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
error("rc_avpair_assign: unknown attribute %d", vp->type);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_new
|
||||
*
|
||||
* Purpose: make a new attribute-value pair with given parameters.
|
||||
*
|
||||
* Returns: pointer to generated a/v pair when successful, NULL when failure.
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE_PAIR *rc_avpair_new (int attrid, void *pval, int len, int vendorcode)
|
||||
{
|
||||
VALUE_PAIR *vp = (VALUE_PAIR *) NULL;
|
||||
DICT_ATTR *pda;
|
||||
|
||||
if ((pda = rc_dict_getattr (attrid, vendorcode)) == (DICT_ATTR *) NULL)
|
||||
{
|
||||
error("rc_avpair_new: unknown attribute %d", attrid);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((vp = (VALUE_PAIR *) malloc (sizeof (VALUE_PAIR)))
|
||||
!= (VALUE_PAIR *) NULL)
|
||||
{
|
||||
strncpy (vp->name, pda->name, sizeof (vp->name));
|
||||
vp->attribute = attrid;
|
||||
vp->vendorcode = vendorcode;
|
||||
vp->next = (VALUE_PAIR *) NULL;
|
||||
vp->type = pda->type;
|
||||
if (rc_avpair_assign (vp, pval, len) == 0)
|
||||
{
|
||||
return vp;
|
||||
}
|
||||
free (vp);
|
||||
vp = (VALUE_PAIR *) NULL;
|
||||
}
|
||||
else
|
||||
novm("rc_avpair_new");
|
||||
}
|
||||
return vp;
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Function: rc_avpair_gen
|
||||
*
|
||||
* Purpose: takes attribute/value pairs from buffer and builds a
|
||||
* value_pair list using allocated memory.
|
||||
*
|
||||
* Returns: value_pair list or NULL on failure
|
||||
*/
|
||||
|
||||
VALUE_PAIR *rc_avpair_gen (AUTH_HDR *auth)
|
||||
{
|
||||
int length;
|
||||
int x_len;
|
||||
int attribute;
|
||||
int attrlen;
|
||||
UINT4 lvalue;
|
||||
unsigned char *x_ptr;
|
||||
unsigned char *ptr;
|
||||
DICT_ATTR *attr;
|
||||
VALUE_PAIR *vp;
|
||||
VALUE_PAIR *pair;
|
||||
unsigned char hex[3]; /* For hex string conversion. */
|
||||
char buffer[512];
|
||||
|
||||
/*
|
||||
* Extract attribute-value pairs
|
||||
*/
|
||||
ptr = auth->data;
|
||||
length = ntohs ((unsigned short) auth->length) - AUTH_HDR_LEN;
|
||||
vp = (VALUE_PAIR *) NULL;
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
attribute = *ptr++;
|
||||
attrlen = *ptr++;
|
||||
attrlen -= 2;
|
||||
if (attrlen < 0)
|
||||
{
|
||||
error("rc_avpair_gen: received attribute with invalid length");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle vendor-specific specially */
|
||||
if (attribute == PW_VENDOR_SPECIFIC) {
|
||||
rc_extract_vendor_specific_attributes(attrlen, ptr, &vp);
|
||||
ptr += attrlen;
|
||||
length -= (attrlen + 2);
|
||||
continue;
|
||||
}
|
||||
if ((attr = rc_dict_getattr (attribute, VENDOR_NONE)) == (DICT_ATTR *) NULL)
|
||||
{
|
||||
*buffer= '\0'; /* Initial length. */
|
||||
for (x_ptr = ptr, x_len = attrlen ;
|
||||
x_len > 0 ;
|
||||
x_len--, x_ptr++)
|
||||
{
|
||||
sprintf (hex, "%2.2X", *x_ptr);
|
||||
strcat (buffer, hex);
|
||||
}
|
||||
warn("rc_avpair_gen: received unknown attribute %d of length %d: 0x%s",
|
||||
attribute, attrlen, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((pair =
|
||||
(VALUE_PAIR *) malloc (sizeof (VALUE_PAIR))) ==
|
||||
(VALUE_PAIR *) NULL)
|
||||
{
|
||||
novm("rc_avpair_gen");
|
||||
rc_avpair_free(vp);
|
||||
return NULL;
|
||||
}
|
||||
strcpy (pair->name, attr->name);
|
||||
pair->attribute = attr->value;
|
||||
pair->vendorcode = VENDOR_NONE;
|
||||
pair->type = attr->type;
|
||||
pair->next = (VALUE_PAIR *) NULL;
|
||||
|
||||
switch (attr->type)
|
||||
{
|
||||
|
||||
case PW_TYPE_STRING:
|
||||
memcpy (pair->strvalue, (char *) ptr, (size_t) attrlen);
|
||||
pair->strvalue[attrlen] = '\0';
|
||||
pair->lvalue = attrlen;
|
||||
rc_avpair_insert (&vp, (VALUE_PAIR *) NULL, pair);
|
||||
break;
|
||||
|
||||
case PW_TYPE_INTEGER:
|
||||
case PW_TYPE_IPADDR:
|
||||
memcpy ((char *) &lvalue, (char *) ptr,
|
||||
sizeof (UINT4));
|
||||
pair->lvalue = ntohl (lvalue);
|
||||
rc_avpair_insert (&vp, (VALUE_PAIR *) NULL, pair);
|
||||
break;
|
||||
|
||||
default:
|
||||
warn("rc_avpair_gen: %s has unknown type", attr->name);
|
||||
free (pair);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
ptr += attrlen;
|
||||
length -= attrlen + 2;
|
||||
}
|
||||
return (vp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_extract_vendor_specific_attributes
|
||||
*
|
||||
* Purpose: Extracts vendor-specific attributes, assuming they are in
|
||||
* the "SHOULD" format recommended by RCF 2138.
|
||||
*
|
||||
* Returns: found value_pair
|
||||
*
|
||||
*/
|
||||
static void rc_extract_vendor_specific_attributes(int attrlen,
|
||||
unsigned char *ptr,
|
||||
VALUE_PAIR **vp)
|
||||
{
|
||||
int vendor_id;
|
||||
int vtype;
|
||||
int vlen;
|
||||
UINT4 lvalue;
|
||||
DICT_ATTR *attr;
|
||||
VALUE_PAIR *pair;
|
||||
|
||||
/* ptr is sitting at vendor-ID */
|
||||
if (attrlen < 8) {
|
||||
/* Nothing to see here... */
|
||||
return;
|
||||
}
|
||||
|
||||
/* High-order octet of Vendor-Id must be zero (RFC2138) */
|
||||
if (*ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Extract vendor_id */
|
||||
vendor_id = (int) (
|
||||
((unsigned int) ptr[1]) * 256 * 256 +
|
||||
((unsigned int) ptr[2]) * 256 +
|
||||
((unsigned int) ptr[3]));
|
||||
/* Bump ptr up to contents */
|
||||
ptr += 4;
|
||||
|
||||
/* Set attrlen to length of data */
|
||||
attrlen -= 4;
|
||||
for (; attrlen; attrlen -= vlen+2, ptr += vlen) {
|
||||
vtype = *ptr++;
|
||||
vlen = *ptr++;
|
||||
vlen -= 2;
|
||||
if (vlen < 0 || vlen > attrlen - 2) {
|
||||
/* Do not log an error. We are supposed to be able to cope with
|
||||
arbitrary vendor-specific gunk */
|
||||
return;
|
||||
}
|
||||
/* Looks plausible... */
|
||||
if ((attr = rc_dict_getattr(vtype, vendor_id)) == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* TODO: Check that length matches data size!!!!! */
|
||||
pair = (VALUE_PAIR *) malloc(sizeof(VALUE_PAIR));
|
||||
if (!pair) {
|
||||
novm("rc_avpair_gen");
|
||||
return;
|
||||
}
|
||||
strcpy(pair->name, attr->name);
|
||||
pair->attribute = attr->value;
|
||||
pair->vendorcode = vendor_id;
|
||||
pair->type = attr->type;
|
||||
pair->next = NULL;
|
||||
switch (attr->type) {
|
||||
case PW_TYPE_STRING:
|
||||
memcpy (pair->strvalue, (char *) ptr, (size_t) vlen);
|
||||
pair->strvalue[vlen] = '\0';
|
||||
pair->lvalue = vlen;
|
||||
rc_avpair_insert (vp, (VALUE_PAIR *) NULL, pair);
|
||||
break;
|
||||
|
||||
case PW_TYPE_INTEGER:
|
||||
case PW_TYPE_IPADDR:
|
||||
memcpy ((char *) &lvalue, (char *) ptr,
|
||||
sizeof (UINT4));
|
||||
pair->lvalue = ntohl (lvalue);
|
||||
rc_avpair_insert (vp, (VALUE_PAIR *) NULL, pair);
|
||||
break;
|
||||
|
||||
default:
|
||||
warn("rc_avpair_gen: %s has unknown type", attr->name);
|
||||
free (pair);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_get
|
||||
*
|
||||
* Purpose: Find the first attribute value-pair (which matches the given
|
||||
* attribute) from the specified value-pair list.
|
||||
*
|
||||
* Returns: found value_pair
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE_PAIR *rc_avpair_get (VALUE_PAIR *vp, UINT4 attr)
|
||||
{
|
||||
for (; vp != (VALUE_PAIR *) NULL && vp->attribute != attr; vp = vp->next)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return (vp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_copy
|
||||
*
|
||||
* Purpose: Return a copy of the existing list "p" ala strdup().
|
||||
*
|
||||
*/
|
||||
VALUE_PAIR *rc_avpair_copy(VALUE_PAIR *p)
|
||||
{
|
||||
VALUE_PAIR *vp, *fp = NULL, *lp = NULL;
|
||||
|
||||
while (p) {
|
||||
vp = malloc(sizeof(VALUE_PAIR));
|
||||
if (!vp) {
|
||||
novm("rc_avpair_copy");
|
||||
return NULL; /* leaks a little but so what */
|
||||
}
|
||||
*vp = *p;
|
||||
if (!fp)
|
||||
fp = vp;
|
||||
if (lp)
|
||||
lp->next = vp;
|
||||
lp = vp;
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_insert
|
||||
*
|
||||
* Purpose: Given the address of an existing list "a" and a pointer
|
||||
* to an entry "p" in that list, add the list "b" to
|
||||
* the "a" list after the "p" entry. If "p" is NULL, add
|
||||
* the list "b" to the end of "a".
|
||||
*
|
||||
*/
|
||||
|
||||
void rc_avpair_insert (VALUE_PAIR **a, VALUE_PAIR *p, VALUE_PAIR *b)
|
||||
{
|
||||
VALUE_PAIR *this_node = NULL;
|
||||
VALUE_PAIR *vp;
|
||||
|
||||
if (*a == (VALUE_PAIR *) NULL)
|
||||
{
|
||||
*a = b;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!b)
|
||||
return;
|
||||
|
||||
vp = *a;
|
||||
|
||||
if ( p == (VALUE_PAIR *) NULL) /* run to end of "a" list */
|
||||
{
|
||||
while (vp != (VALUE_PAIR *) NULL)
|
||||
{
|
||||
this_node = vp;
|
||||
vp = vp->next;
|
||||
}
|
||||
}
|
||||
else /* look for the "p" entry in the "a" list (or run to end) */
|
||||
{
|
||||
this_node = *a;
|
||||
while (this_node != (VALUE_PAIR *) NULL)
|
||||
{
|
||||
if (this_node == p)
|
||||
{
|
||||
break;
|
||||
}
|
||||
this_node = this_node->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* add "b" at this_node */
|
||||
vp = this_node->next;
|
||||
this_node->next = b;
|
||||
|
||||
/* run to end of "b" and connect the rest of "a" */
|
||||
while (b->next)
|
||||
b = b->next;
|
||||
b->next = vp;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_free
|
||||
*
|
||||
* Purpose: frees all value_pairs in the list
|
||||
*
|
||||
*/
|
||||
|
||||
void rc_avpair_free (VALUE_PAIR *pair)
|
||||
{
|
||||
VALUE_PAIR *next;
|
||||
|
||||
while (pair != (VALUE_PAIR *) NULL)
|
||||
{
|
||||
next = pair->next;
|
||||
free (pair);
|
||||
pair = next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_fieldcpy
|
||||
*
|
||||
* Purpose: Copy a data field from the buffer. Advance the buffer
|
||||
* past the data field.
|
||||
*
|
||||
*/
|
||||
|
||||
static void rc_fieldcpy (char *string, char **uptr)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
ptr = *uptr;
|
||||
if (*ptr == '"')
|
||||
{
|
||||
ptr++;
|
||||
while (*ptr != '"' && *ptr != '\0' && *ptr != '\n')
|
||||
{
|
||||
*string++ = *ptr++;
|
||||
}
|
||||
*string = '\0';
|
||||
if (*ptr == '"')
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
*uptr = ptr;
|
||||
return;
|
||||
}
|
||||
|
||||
while (*ptr != ' ' && *ptr != '\t' && *ptr != '\0' && *ptr != '\n' &&
|
||||
*ptr != '=' && *ptr != ',')
|
||||
{
|
||||
*string++ = *ptr++;
|
||||
}
|
||||
*string = '\0';
|
||||
*uptr = ptr;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_parse
|
||||
*
|
||||
* Purpose: parses the buffer to extract the attribute-value pairs.
|
||||
*
|
||||
* Returns: 0 = successful parse of attribute-value pair,
|
||||
* -1 = syntax (or other) error detected.
|
||||
*
|
||||
*/
|
||||
|
||||
#define PARSE_MODE_NAME 0
|
||||
#define PARSE_MODE_EQUAL 1
|
||||
#define PARSE_MODE_VALUE 2
|
||||
#define PARSE_MODE_INVALID 3
|
||||
|
||||
int rc_avpair_parse (char *buffer, VALUE_PAIR **first_pair)
|
||||
{
|
||||
int mode;
|
||||
char attrstr[AUTH_ID_LEN];
|
||||
char valstr[AUTH_ID_LEN];
|
||||
DICT_ATTR *attr = NULL;
|
||||
DICT_VALUE *dval;
|
||||
VALUE_PAIR *pair;
|
||||
VALUE_PAIR *link;
|
||||
struct tm *tm;
|
||||
time_t timeval;
|
||||
|
||||
mode = PARSE_MODE_NAME;
|
||||
while (*buffer != '\n' && *buffer != '\0')
|
||||
{
|
||||
if (*buffer == ' ' || *buffer == '\t')
|
||||
{
|
||||
buffer++;
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case PARSE_MODE_NAME: /* Attribute Name */
|
||||
rc_fieldcpy (attrstr, &buffer);
|
||||
if ((attr =
|
||||
rc_dict_findattr (attrstr)) == (DICT_ATTR *) NULL)
|
||||
{
|
||||
error("rc_avpair_parse: unknown attribute");
|
||||
if (*first_pair) {
|
||||
rc_avpair_free(*first_pair);
|
||||
*first_pair = (VALUE_PAIR *) NULL;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
mode = PARSE_MODE_EQUAL;
|
||||
break;
|
||||
|
||||
case PARSE_MODE_EQUAL: /* Equal sign */
|
||||
if (*buffer == '=')
|
||||
{
|
||||
mode = PARSE_MODE_VALUE;
|
||||
buffer++;
|
||||
}
|
||||
else
|
||||
{
|
||||
error("rc_avpair_parse: missing or misplaced equal sign");
|
||||
if (*first_pair) {
|
||||
rc_avpair_free(*first_pair);
|
||||
*first_pair = (VALUE_PAIR *) NULL;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
|
||||
case PARSE_MODE_VALUE: /* Value */
|
||||
rc_fieldcpy (valstr, &buffer);
|
||||
|
||||
if ((pair =
|
||||
(VALUE_PAIR *) malloc (sizeof (VALUE_PAIR)))
|
||||
== (VALUE_PAIR *) NULL)
|
||||
{
|
||||
novm("rc_avpair_parse");
|
||||
if (*first_pair) {
|
||||
rc_avpair_free(*first_pair);
|
||||
*first_pair = (VALUE_PAIR *) NULL;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
strcpy (pair->name, attr->name);
|
||||
pair->attribute = attr->value;
|
||||
pair->type = attr->type;
|
||||
pair->vendorcode = attr->vendorcode;
|
||||
|
||||
switch (pair->type)
|
||||
{
|
||||
|
||||
case PW_TYPE_STRING:
|
||||
strcpy (pair->strvalue, valstr);
|
||||
pair->lvalue = strlen(valstr);
|
||||
break;
|
||||
|
||||
case PW_TYPE_INTEGER:
|
||||
if (isdigit (*valstr))
|
||||
{
|
||||
pair->lvalue = atoi (valstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((dval = rc_dict_findval (valstr))
|
||||
== (DICT_VALUE *) NULL)
|
||||
{
|
||||
error("rc_avpair_parse: unknown attribute value: %s", valstr);
|
||||
if (*first_pair) {
|
||||
rc_avpair_free(*first_pair);
|
||||
*first_pair = (VALUE_PAIR *) NULL;
|
||||
}
|
||||
free (pair);
|
||||
return (-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
pair->lvalue = dval->value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PW_TYPE_IPADDR:
|
||||
pair->lvalue = rc_get_ipaddr(valstr);
|
||||
break;
|
||||
|
||||
case PW_TYPE_DATE:
|
||||
timeval = time (0);
|
||||
tm = localtime (&timeval);
|
||||
tm->tm_hour = 0;
|
||||
tm->tm_min = 0;
|
||||
tm->tm_sec = 0;
|
||||
rc_str2tm (valstr, tm);
|
||||
#ifdef TIMELOCAL
|
||||
pair->lvalue = (UINT4) timelocal (tm);
|
||||
#else /* TIMELOCAL */
|
||||
pair->lvalue = (UINT4) mktime (tm);
|
||||
#endif /* TIMELOCAL */
|
||||
break;
|
||||
|
||||
default:
|
||||
error("rc_avpair_parse: unknown attribute type %d", pair->type);
|
||||
if (*first_pair) {
|
||||
rc_avpair_free(*first_pair);
|
||||
*first_pair = (VALUE_PAIR *) NULL;
|
||||
}
|
||||
free (pair);
|
||||
return (-1);
|
||||
}
|
||||
pair->next = (VALUE_PAIR *) NULL;
|
||||
|
||||
if (*first_pair == (VALUE_PAIR *) NULL)
|
||||
{
|
||||
*first_pair = pair;
|
||||
}
|
||||
else
|
||||
{
|
||||
link = *first_pair;
|
||||
while (link->next != (VALUE_PAIR *) NULL)
|
||||
{
|
||||
link = link->next;
|
||||
}
|
||||
link->next = pair;
|
||||
}
|
||||
|
||||
mode = PARSE_MODE_NAME;
|
||||
break;
|
||||
|
||||
default:
|
||||
mode = PARSE_MODE_NAME;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_tostr
|
||||
*
|
||||
* Purpose: Translate an av_pair into two strings
|
||||
*
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_avpair_tostr (VALUE_PAIR *pair, char *name, int ln, char *value, int lv)
|
||||
{
|
||||
DICT_VALUE *dval;
|
||||
char buffer[32];
|
||||
struct in_addr inad;
|
||||
unsigned char *ptr;
|
||||
|
||||
*name = *value = '\0';
|
||||
|
||||
if (!pair || pair->name[0] == '\0') {
|
||||
error("rc_avpair_tostr: pair is NULL or empty");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
strncpy(name, pair->name, (size_t) ln);
|
||||
|
||||
switch (pair->type)
|
||||
{
|
||||
case PW_TYPE_STRING:
|
||||
lv--;
|
||||
ptr = (unsigned char *) pair->strvalue;
|
||||
while (*ptr != '\0')
|
||||
{
|
||||
if (!(isprint (*ptr)))
|
||||
{
|
||||
sprintf (buffer, "\\%03o", *ptr);
|
||||
strncat(value, buffer, (size_t) lv);
|
||||
lv -= 4;
|
||||
if (lv < 0) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncat(value, ptr, 1);
|
||||
lv--;
|
||||
if (lv < 0) break;
|
||||
}
|
||||
ptr++;
|
||||
}
|
||||
break;
|
||||
|
||||
case PW_TYPE_INTEGER:
|
||||
dval = rc_dict_getval (pair->lvalue, pair->name);
|
||||
if (dval != (DICT_VALUE *) NULL)
|
||||
{
|
||||
strncpy(value, dval->name, (size_t) lv-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf (buffer, "%ld", pair->lvalue);
|
||||
strncpy(value, buffer, (size_t) lv);
|
||||
}
|
||||
break;
|
||||
|
||||
case PW_TYPE_IPADDR:
|
||||
inad.s_addr = htonl(pair->lvalue);
|
||||
strncpy (value, inet_ntoa (inad), (size_t) lv-1);
|
||||
break;
|
||||
|
||||
case PW_TYPE_DATE:
|
||||
strftime (buffer, sizeof (buffer), "%m/%d/%y %H:%M:%S",
|
||||
gmtime ((time_t *) & pair->lvalue));
|
||||
strncpy(value, buffer, lv-1);
|
||||
break;
|
||||
|
||||
default:
|
||||
error("rc_avpair_tostr: unknown attribute type %d", pair->type);
|
||||
return (-1);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_avpair_readin
|
||||
*
|
||||
* Purpose: get a sequence of attribute value pairs from the file input
|
||||
* and make them into a list of value_pairs
|
||||
*
|
||||
*/
|
||||
|
||||
VALUE_PAIR *rc_avpair_readin(FILE *input)
|
||||
{
|
||||
VALUE_PAIR *vp = NULL;
|
||||
char buffer[1024], *q;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), input) != NULL)
|
||||
{
|
||||
q = buffer;
|
||||
|
||||
while(*q && isspace(*q)) q++;
|
||||
|
||||
if ((*q == '\n') || (*q == '#') || (*q == '\0'))
|
||||
continue;
|
||||
|
||||
if (rc_avpair_parse(q, &vp) < 0) {
|
||||
error("rc_avpair_readin: malformed attribute: %s", buffer);
|
||||
rc_avpair_free(vp);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return vp;
|
||||
}
|
||||
446
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/buildreq.c
vendored
Normal file
446
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/buildreq.c
vendored
Normal file
@ -0,0 +1,446 @@
|
||||
/*
|
||||
* $Id: buildreq.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
|
||||
*
|
||||
* Copyright (C) 1995,1997 Lars Fenneberg
|
||||
*
|
||||
* See the file COPYRIGHT for the respective terms and conditions.
|
||||
* If the file is missing contact me at lf@elemental.net
|
||||
* and I'll send you a copy.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <includes.h>
|
||||
#include <radiusclient.h>
|
||||
|
||||
unsigned char rc_get_seqnbr(void);
|
||||
|
||||
/*
|
||||
* Function: rc_get_nas_id
|
||||
*
|
||||
* Purpose: fills in NAS-Identifier or NAS-IP-Address in request
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_get_nas_id(VALUE_PAIR **sendpairs)
|
||||
{
|
||||
UINT4 client_id;
|
||||
char *nasid;
|
||||
|
||||
nasid = rc_conf_str("nas_identifier");
|
||||
if (strlen(nasid)) {
|
||||
/*
|
||||
* Fill in NAS-Identifier
|
||||
*/
|
||||
if (rc_avpair_add(sendpairs, PW_NAS_IDENTIFIER, nasid, 0,
|
||||
VENDOR_NONE) == NULL)
|
||||
return (ERROR_RC);
|
||||
|
||||
return (OK_RC);
|
||||
|
||||
} else {
|
||||
/*
|
||||
* Fill in NAS-IP-Address
|
||||
*/
|
||||
if ((client_id = rc_own_ipaddress()) == 0)
|
||||
return (ERROR_RC);
|
||||
|
||||
if (rc_avpair_add(sendpairs, PW_NAS_IP_ADDRESS, &client_id,
|
||||
0, VENDOR_NONE) == NULL)
|
||||
return (ERROR_RC);
|
||||
}
|
||||
|
||||
return (OK_RC);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_buildreq
|
||||
*
|
||||
* Purpose: builds a skeleton RADIUS request using information from the
|
||||
* config file.
|
||||
*
|
||||
*/
|
||||
|
||||
void rc_buildreq(SEND_DATA *data, int code, char *server, unsigned short port,
|
||||
int timeout, int retries)
|
||||
{
|
||||
data->server = server;
|
||||
data->svc_port = port;
|
||||
data->seq_nbr = rc_get_seqnbr();
|
||||
data->timeout = timeout;
|
||||
data->retries = retries;
|
||||
data->code = code;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_guess_seqnbr
|
||||
*
|
||||
* Purpose: return a random sequence number
|
||||
*
|
||||
*/
|
||||
|
||||
static unsigned char rc_guess_seqnbr(void)
|
||||
{
|
||||
return (unsigned char)(magic() & UCHAR_MAX);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_get_seqnbr
|
||||
*
|
||||
* Purpose: generate a sequence number
|
||||
*
|
||||
*/
|
||||
|
||||
unsigned char rc_get_seqnbr(void)
|
||||
{
|
||||
FILE *sf;
|
||||
int tries = 1;
|
||||
int seq_nbr, pos;
|
||||
char *seqfile = rc_conf_str("seqfile");
|
||||
|
||||
if ((sf = fopen(seqfile, "a+")) == NULL)
|
||||
{
|
||||
error("rc_get_seqnbr: couldn't open sequence file %s: %s", seqfile, strerror(errno));
|
||||
/* well, so guess a sequence number */
|
||||
return rc_guess_seqnbr();
|
||||
}
|
||||
|
||||
while (do_lock_exclusive(fileno(sf))!= 0)
|
||||
{
|
||||
if (errno != EWOULDBLOCK) {
|
||||
error("rc_get_seqnbr: flock failure: %s: %s", seqfile, strerror(errno));
|
||||
fclose(sf);
|
||||
return rc_guess_seqnbr();
|
||||
}
|
||||
tries++;
|
||||
if (tries <= 10)
|
||||
rc_mdelay(500);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if (tries > 10) {
|
||||
error("rc_get_seqnbr: couldn't get lock after %d tries: %s", tries-1, seqfile);
|
||||
fclose(sf);
|
||||
return rc_guess_seqnbr();
|
||||
}
|
||||
|
||||
pos = ftell(sf);
|
||||
rewind(sf);
|
||||
if (fscanf(sf, "%d", &seq_nbr) != 1) {
|
||||
if (pos != ftell(sf)) {
|
||||
/* file was not empty */
|
||||
error("rc_get_seqnbr: fscanf failure: %s", seqfile);
|
||||
}
|
||||
seq_nbr = rc_guess_seqnbr();
|
||||
}
|
||||
|
||||
rewind(sf);
|
||||
ftruncate(fileno(sf),0);
|
||||
fprintf(sf,"%d\n", (seq_nbr+1) & UCHAR_MAX);
|
||||
|
||||
fflush(sf); /* fflush because a process may read it between the do_unlock and fclose */
|
||||
|
||||
if (do_unlock(fileno(sf)) != 0)
|
||||
error("rc_get_seqnbr: couldn't release lock on %s: %s", seqfile, strerror(errno));
|
||||
|
||||
fclose(sf);
|
||||
|
||||
return (unsigned char)seq_nbr;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_auth
|
||||
*
|
||||
* Purpose: Builds an authentication request for port id client_port
|
||||
* with the value_pairs send and submits it to a server
|
||||
*
|
||||
* Returns: received value_pairs in received, messages from the server in msg
|
||||
* and 0 on success, negative on failure as return value
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_auth(UINT4 client_port, VALUE_PAIR *send, VALUE_PAIR **received,
|
||||
char *msg, REQUEST_INFO *info)
|
||||
{
|
||||
SERVER *authserver = rc_conf_srv("authserver");
|
||||
|
||||
if (!authserver) {
|
||||
return (ERROR_RC);
|
||||
}
|
||||
return rc_auth_using_server(authserver, client_port, send, received,
|
||||
msg, info);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_auth_using_server
|
||||
*
|
||||
* Purpose: Builds an authentication request for port id client_port
|
||||
* with the value_pairs send and submits it to a server. You
|
||||
* explicitly supply a server list.
|
||||
*
|
||||
* Returns: received value_pairs in received, messages from the server in msg
|
||||
* and 0 on success, negative on failure as return value
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_auth_using_server(SERVER *authserver,
|
||||
UINT4 client_port,
|
||||
VALUE_PAIR *send,
|
||||
VALUE_PAIR **received,
|
||||
char *msg, REQUEST_INFO *info)
|
||||
{
|
||||
SEND_DATA data;
|
||||
int result;
|
||||
int i;
|
||||
int timeout = rc_conf_int("radius_timeout");
|
||||
int retries = rc_conf_int("radius_retries");
|
||||
|
||||
data.send_pairs = send;
|
||||
data.receive_pairs = NULL;
|
||||
|
||||
/*
|
||||
* Fill in NAS-IP-Address or NAS-Identifier
|
||||
*/
|
||||
|
||||
if (rc_get_nas_id(&(data.send_pairs)) == ERROR_RC)
|
||||
return (ERROR_RC);
|
||||
|
||||
/*
|
||||
* Fill in NAS-Port
|
||||
*/
|
||||
|
||||
if (rc_avpair_add(&(data.send_pairs), PW_NAS_PORT, &client_port, 0, VENDOR_NONE) == NULL)
|
||||
return (ERROR_RC);
|
||||
|
||||
result = ERROR_RC;
|
||||
for(i=0; (i<authserver->max) && (result != OK_RC) && (result != BADRESP_RC)
|
||||
; i++)
|
||||
{
|
||||
if (data.receive_pairs != NULL) {
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
data.receive_pairs = NULL;
|
||||
}
|
||||
rc_buildreq(&data, PW_ACCESS_REQUEST, authserver->name[i],
|
||||
authserver->port[i], timeout, retries);
|
||||
|
||||
result = rc_send_server (&data, msg, info);
|
||||
}
|
||||
|
||||
*received = data.receive_pairs;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_auth_proxy
|
||||
*
|
||||
* Purpose: Builds an authentication request
|
||||
* with the value_pairs send and submits it to a server.
|
||||
* Works for a proxy; does not add IP address, and does
|
||||
* does not rely on config file.
|
||||
*
|
||||
* Returns: received value_pairs in received, messages from the server in msg
|
||||
* and 0 on success, negative on failure as return value
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_auth_proxy(VALUE_PAIR *send, VALUE_PAIR **received, char *msg)
|
||||
{
|
||||
SEND_DATA data;
|
||||
int result;
|
||||
int i;
|
||||
SERVER *authserver = rc_conf_srv("authserver");
|
||||
int timeout = rc_conf_int("radius_timeout");
|
||||
int retries = rc_conf_int("radius_retries");
|
||||
|
||||
data.send_pairs = send;
|
||||
data.receive_pairs = NULL;
|
||||
|
||||
result = ERROR_RC;
|
||||
for(i=0; (i<authserver->max) && (result != OK_RC) && (result != BADRESP_RC)
|
||||
; i++)
|
||||
{
|
||||
if (data.receive_pairs != NULL) {
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
data.receive_pairs = NULL;
|
||||
}
|
||||
rc_buildreq(&data, PW_ACCESS_REQUEST, authserver->name[i],
|
||||
authserver->port[i], timeout, retries);
|
||||
|
||||
result = rc_send_server (&data, msg, NULL);
|
||||
}
|
||||
|
||||
*received = data.receive_pairs;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: rc_acct_using_server
|
||||
*
|
||||
* Purpose: Builds an accounting request for port id client_port
|
||||
* with the value_pairs send. You explicitly supply server list.
|
||||
*
|
||||
* Remarks: NAS-Identifier/NAS-IP-Address, NAS-Port and Acct-Delay-Time get
|
||||
* filled in by this function, the rest has to be supplied.
|
||||
*/
|
||||
|
||||
int rc_acct_using_server(SERVER *acctserver,
|
||||
UINT4 client_port,
|
||||
VALUE_PAIR *send)
|
||||
{
|
||||
SEND_DATA data;
|
||||
VALUE_PAIR *adt_vp;
|
||||
int result;
|
||||
time_t start_time, dtime;
|
||||
char msg[4096];
|
||||
int i;
|
||||
int timeout = rc_conf_int("radius_timeout");
|
||||
int retries = rc_conf_int("radius_retries");
|
||||
|
||||
data.send_pairs = send;
|
||||
data.receive_pairs = NULL;
|
||||
|
||||
/*
|
||||
* Fill in NAS-IP-Address or NAS-Identifier
|
||||
*/
|
||||
|
||||
if (rc_get_nas_id(&(data.send_pairs)) == ERROR_RC)
|
||||
return (ERROR_RC);
|
||||
|
||||
/*
|
||||
* Fill in NAS-Port
|
||||
*/
|
||||
|
||||
if (rc_avpair_add(&(data.send_pairs), PW_NAS_PORT, &client_port, 0, VENDOR_NONE) == NULL)
|
||||
return (ERROR_RC);
|
||||
|
||||
/*
|
||||
* Fill in Acct-Delay-Time
|
||||
*/
|
||||
|
||||
dtime = 0;
|
||||
if ((adt_vp = rc_avpair_add(&(data.send_pairs), PW_ACCT_DELAY_TIME, &dtime, 0, VENDOR_NONE)) == NULL)
|
||||
return (ERROR_RC);
|
||||
|
||||
start_time = time(NULL);
|
||||
result = ERROR_RC;
|
||||
for(i=0; (i<acctserver->max) && (result != OK_RC) && (result != BADRESP_RC)
|
||||
; i++)
|
||||
{
|
||||
if (data.receive_pairs != NULL) {
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
data.receive_pairs = NULL;
|
||||
}
|
||||
rc_buildreq(&data, PW_ACCOUNTING_REQUEST, acctserver->name[i],
|
||||
acctserver->port[i], timeout, retries);
|
||||
|
||||
dtime = time(NULL) - start_time;
|
||||
rc_avpair_assign(adt_vp, &dtime, 0);
|
||||
|
||||
result = rc_send_server (&data, msg, NULL);
|
||||
}
|
||||
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_acct
|
||||
*
|
||||
* Purpose: Builds an accounting request for port id client_port
|
||||
* with the value_pairs send
|
||||
*
|
||||
* Remarks: NAS-Identifier/NAS-IP-Address, NAS-Port and Acct-Delay-Time get
|
||||
* filled in by this function, the rest has to be supplied.
|
||||
*/
|
||||
|
||||
int rc_acct(UINT4 client_port, VALUE_PAIR *send)
|
||||
{
|
||||
SERVER *acctserver = rc_conf_srv("acctserver");
|
||||
if (!acctserver) return (ERROR_RC);
|
||||
|
||||
return rc_acct_using_server(acctserver, client_port, send);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_acct_proxy
|
||||
*
|
||||
* Purpose: Builds an accounting request with the value_pairs send
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_acct_proxy(VALUE_PAIR *send)
|
||||
{
|
||||
SEND_DATA data;
|
||||
int result;
|
||||
char msg[4096];
|
||||
int i;
|
||||
SERVER *acctserver = rc_conf_srv("authserver");
|
||||
int timeout = rc_conf_int("radius_timeout");
|
||||
int retries = rc_conf_int("radius_retries");
|
||||
|
||||
data.send_pairs = send;
|
||||
data.receive_pairs = NULL;
|
||||
|
||||
result = ERROR_RC;
|
||||
for(i=0; (i<acctserver->max) && (result != OK_RC) && (result != BADRESP_RC)
|
||||
; i++)
|
||||
{
|
||||
if (data.receive_pairs != NULL) {
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
data.receive_pairs = NULL;
|
||||
}
|
||||
rc_buildreq(&data, PW_ACCOUNTING_REQUEST, acctserver->name[i],
|
||||
acctserver->port[i], timeout, retries);
|
||||
|
||||
result = rc_send_server (&data, msg, NULL);
|
||||
}
|
||||
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_check
|
||||
*
|
||||
* Purpose: ask the server hostname on the specified port for a
|
||||
* status message
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_check(char *host, unsigned short port, char *msg)
|
||||
{
|
||||
SEND_DATA data;
|
||||
int result;
|
||||
UINT4 service_type;
|
||||
int timeout = rc_conf_int("radius_timeout");
|
||||
int retries = rc_conf_int("radius_retries");
|
||||
|
||||
data.send_pairs = data.receive_pairs = NULL;
|
||||
|
||||
/*
|
||||
* Fill in NAS-IP-Address or NAS-Identifier,
|
||||
* although it isn't neccessary
|
||||
*/
|
||||
|
||||
if (rc_get_nas_id(&(data.send_pairs)) == ERROR_RC)
|
||||
return (ERROR_RC);
|
||||
|
||||
/*
|
||||
* Fill in Service-Type
|
||||
*/
|
||||
|
||||
service_type = PW_ADMINISTRATIVE;
|
||||
rc_avpair_add(&(data.send_pairs), PW_SERVICE_TYPE, &service_type, 0, VENDOR_NONE);
|
||||
|
||||
rc_buildreq(&data, PW_STATUS_SERVER, host, port, timeout, retries);
|
||||
result = rc_send_server (&data, msg, NULL);
|
||||
|
||||
rc_avpair_free(data.receive_pairs);
|
||||
|
||||
return result;
|
||||
}
|
||||
121
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/clientid.c
vendored
Normal file
121
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/clientid.c
vendored
Normal file
@ -0,0 +1,121 @@
|
||||
/*
|
||||
* $Id: clientid.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
|
||||
*
|
||||
* Copyright (C) 1995,1996,1997 Lars Fenneberg
|
||||
*
|
||||
* See the file COPYRIGHT for the respective terms and conditions.
|
||||
* If the file is missing contact me at lf@elemental.net
|
||||
* and I'll send you a copy.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <includes.h>
|
||||
#include <radiusclient.h>
|
||||
|
||||
struct map2id_s {
|
||||
char *name;
|
||||
UINT4 id;
|
||||
|
||||
struct map2id_s *next;
|
||||
};
|
||||
|
||||
static struct map2id_s *map2id_list = NULL;
|
||||
|
||||
/*
|
||||
* Function: rc_read_mapfile
|
||||
*
|
||||
* Purpose: Read in the ttyname to port id map file
|
||||
*
|
||||
* Arguments: the file name of the map file
|
||||
*
|
||||
* Returns: zero on success, negative integer on failure
|
||||
*/
|
||||
|
||||
int rc_read_mapfile(char *filename)
|
||||
{
|
||||
char buffer[1024];
|
||||
FILE *mapfd;
|
||||
char *c, *name, *id, *q;
|
||||
struct map2id_s *p;
|
||||
int lnr = 0;
|
||||
|
||||
if ((mapfd = fopen(filename,"r")) == NULL)
|
||||
{
|
||||
error("rc_read_mapfile: can't read %s: %s", filename, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#define SKIP(p) while(*p && isspace(*p)) p++;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer), mapfd) != NULL)
|
||||
{
|
||||
lnr++;
|
||||
|
||||
q = buffer;
|
||||
|
||||
SKIP(q);
|
||||
|
||||
if ((*q == '\n') || (*q == '#') || (*q == '\0'))
|
||||
continue;
|
||||
|
||||
if (( c = strchr(q, ' ')) || (c = strchr(q,'\t'))) {
|
||||
|
||||
*c = '\0'; c++;
|
||||
SKIP(c);
|
||||
|
||||
name = q;
|
||||
id = c;
|
||||
|
||||
if ((p = (struct map2id_s *)malloc(sizeof(*p))) == NULL) {
|
||||
novm("rc_read_mapfile");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
p->name = strdup(name);
|
||||
p->id = atoi(id);
|
||||
p->next = map2id_list;
|
||||
map2id_list = p;
|
||||
|
||||
} else {
|
||||
|
||||
error("rc_read_mapfile: malformed line in %s, line %d", filename, lnr);
|
||||
return (-1);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#undef SKIP
|
||||
|
||||
fclose(mapfd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_map2id
|
||||
*
|
||||
* Purpose: Map ttyname to port id
|
||||
*
|
||||
* Arguments: full pathname of the tty
|
||||
*
|
||||
* Returns: port id, zero if no entry found
|
||||
*/
|
||||
|
||||
UINT4 rc_map2id(char *name)
|
||||
{
|
||||
struct map2id_s *p;
|
||||
char ttyname[PATH_MAX];
|
||||
|
||||
*ttyname = '\0';
|
||||
if (*name != '/')
|
||||
strcpy(ttyname, "/dev/");
|
||||
|
||||
strncat(ttyname, name, sizeof(ttyname));
|
||||
|
||||
for(p = map2id_list; p; p = p->next)
|
||||
if (!strcmp(ttyname, p->name)) return p->id;
|
||||
|
||||
warn("rc_map2id: can't find tty %s in map database", ttyname);
|
||||
|
||||
return 0;
|
||||
}
|
||||
544
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/config.c
vendored
Normal file
544
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/config.c
vendored
Normal file
@ -0,0 +1,544 @@
|
||||
/*
|
||||
* $Id: config.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
|
||||
*
|
||||
* Copyright (C) 1995,1996,1997 Lars Fenneberg
|
||||
*
|
||||
* Copyright 1992 Livingston Enterprises, Inc.
|
||||
*
|
||||
* Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
|
||||
* and Merit Network, Inc. All Rights Reserved
|
||||
*
|
||||
* See the file COPYRIGHT for the respective terms and conditions.
|
||||
* If the file is missing contact me at lf@elemental.net
|
||||
* and I'll send you a copy.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <includes.h>
|
||||
#include <radiusclient.h>
|
||||
#include <options.h>
|
||||
|
||||
static int test_config(char *);
|
||||
|
||||
/*
|
||||
* Function: find_option
|
||||
*
|
||||
* Purpose: find an option in the option list
|
||||
*
|
||||
* Returns: pointer to option on success, NULL otherwise
|
||||
*/
|
||||
|
||||
static OPTION *find_option(char *optname, unsigned int type)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* there're so few options that a binary search seems not necessary */
|
||||
for (i = 0; i < num_options; i++) {
|
||||
if (!strcmp(config_options[i].name, optname) &&
|
||||
(config_options[i].type & type))
|
||||
return &config_options[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: set_option_...
|
||||
*
|
||||
* Purpose: set a specific option doing type conversions
|
||||
*
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*/
|
||||
|
||||
static int set_option_str(char *filename, int line, OPTION *option, char *p)
|
||||
{
|
||||
if (p)
|
||||
option->val = (void *) strdup(p);
|
||||
else
|
||||
option->val = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_option_int(char *filename, int line, OPTION *option, char *p)
|
||||
{
|
||||
int *iptr;
|
||||
|
||||
if (p == NULL) {
|
||||
error("%s: line %d: bogus option value", filename, line);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if ((iptr = (int *) malloc(sizeof(iptr))) == NULL) {
|
||||
novm("read_config");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
*iptr = atoi(p);
|
||||
option->val = (void *) iptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_option_srv(char *filename, int line, OPTION *option, char *p)
|
||||
{
|
||||
SERVER *serv;
|
||||
char *q;
|
||||
struct servent *svp;
|
||||
int i;
|
||||
|
||||
if (p == NULL) {
|
||||
error("%s: line %d: bogus option value", filename, line);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
serv = (SERVER *) option->val;
|
||||
|
||||
for (i = 0; i < serv->max; i++) {
|
||||
free(serv->name[i]);
|
||||
}
|
||||
serv->max = 0;
|
||||
|
||||
while ((p = strtok(p, ", \t")) != NULL) {
|
||||
|
||||
if ((q = strchr(p,':')) != NULL) {
|
||||
*q = '\0';
|
||||
q++;
|
||||
serv->port[serv->max] = atoi(q);
|
||||
} else {
|
||||
if (!strcmp(option->name,"authserver"))
|
||||
if ((svp = getservbyname ("radius", "udp")) == NULL)
|
||||
serv->port[serv->max] = PW_AUTH_UDP_PORT;
|
||||
else
|
||||
serv->port[serv->max] = ntohs ((unsigned int) svp->s_port);
|
||||
else if (!strcmp(option->name, "acctserver"))
|
||||
if ((svp = getservbyname ("radacct", "udp")) == NULL)
|
||||
serv->port[serv->max] = PW_ACCT_UDP_PORT;
|
||||
else
|
||||
serv->port[serv->max] = ntohs ((unsigned int) svp->s_port);
|
||||
else {
|
||||
error("%s: line %d: no default port for %s", filename, line, option->name);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
serv->name[serv->max++] = strdup(p);
|
||||
|
||||
p = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int set_option_auo(char *filename, int line, OPTION *option, char *p)
|
||||
{
|
||||
int *iptr;
|
||||
|
||||
if (p == NULL) {
|
||||
warn("%s: line %d: bogus option value", filename, line);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if ((iptr = (int *) malloc(sizeof(iptr))) == NULL) {
|
||||
novm("read_config");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
*iptr = 0;
|
||||
p = strtok(p, ", \t");
|
||||
|
||||
if (!strncmp(p, "local", 5))
|
||||
*iptr = AUTH_LOCAL_FST;
|
||||
else if (!strncmp(p, "radius", 6))
|
||||
*iptr = AUTH_RADIUS_FST;
|
||||
else {
|
||||
error("%s: auth_order: unknown keyword: %s", filename, p);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
p = strtok(NULL, ", \t");
|
||||
|
||||
if (p && (*p != '\0')) {
|
||||
if ((*iptr & AUTH_RADIUS_FST) && !strcmp(p, "local"))
|
||||
*iptr = (*iptr) | AUTH_LOCAL_SND;
|
||||
else if ((*iptr & AUTH_LOCAL_FST) && !strcmp(p, "radius"))
|
||||
*iptr = (*iptr) | AUTH_RADIUS_SND;
|
||||
else {
|
||||
error("%s: auth_order: unknown or unexpected keyword: %s", filename, p);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
option->val = (void *) iptr;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: rc_read_config
|
||||
*
|
||||
* Purpose: read the global config file
|
||||
*
|
||||
* Returns: 0 on success, -1 when failure
|
||||
*/
|
||||
|
||||
int rc_read_config(char *filename)
|
||||
{
|
||||
FILE *configfd;
|
||||
char buffer[512], *p;
|
||||
OPTION *option;
|
||||
int line, pos;
|
||||
|
||||
if ((configfd = fopen(filename,"r")) == NULL)
|
||||
{
|
||||
error("rc_read_config: can't open %s: %m", filename);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
line = 0;
|
||||
while ((fgets(buffer, sizeof(buffer), configfd) != NULL))
|
||||
{
|
||||
line++;
|
||||
p = buffer;
|
||||
|
||||
if ((*p == '\n') || (*p == '#') || (*p == '\0'))
|
||||
continue;
|
||||
|
||||
p[strlen(p)-1] = '\0';
|
||||
|
||||
|
||||
if ((pos = strcspn(p, "\t ")) == 0) {
|
||||
error("%s: line %d: bogus format: %s", filename, line, p);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
p[pos] = '\0';
|
||||
|
||||
if ((option = find_option(p, OT_ANY)) == NULL) {
|
||||
error("%s: line %d: unrecognized keyword: %s", filename, line, p);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (option->status != ST_UNDEF) {
|
||||
error("%s: line %d: duplicate option line: %s", filename, line, p);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
p += pos+1;
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
switch (option->type) {
|
||||
case OT_STR:
|
||||
if (set_option_str(filename, line, option, p) < 0)
|
||||
return (-1);
|
||||
break;
|
||||
case OT_INT:
|
||||
if (set_option_int(filename, line, option, p) < 0)
|
||||
return (-1);
|
||||
break;
|
||||
case OT_SRV:
|
||||
if (set_option_srv(filename, line, option, p) < 0)
|
||||
return (-1);
|
||||
break;
|
||||
case OT_AUO:
|
||||
if (set_option_auo(filename, line, option, p) < 0)
|
||||
return (-1);
|
||||
break;
|
||||
default:
|
||||
fatal("rc_read_config: impossible case branch!");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
fclose(configfd);
|
||||
|
||||
return test_config(filename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_conf_str, rc_conf_int, rc_conf_src
|
||||
*
|
||||
* Purpose: get the value of a config option
|
||||
*
|
||||
* Returns: config option value
|
||||
*/
|
||||
|
||||
char *rc_conf_str(char *optname)
|
||||
{
|
||||
OPTION *option;
|
||||
|
||||
option = find_option(optname, OT_STR);
|
||||
|
||||
if (option == NULL)
|
||||
fatal("rc_conf_str: unkown config option requested: %s", optname);
|
||||
return (char *)option->val;
|
||||
}
|
||||
|
||||
int rc_conf_int(char *optname)
|
||||
{
|
||||
OPTION *option;
|
||||
|
||||
option = find_option(optname, OT_INT|OT_AUO);
|
||||
|
||||
if (option == NULL)
|
||||
fatal("rc_conf_int: unkown config option requested: %s", optname);
|
||||
return *((int *)option->val);
|
||||
}
|
||||
|
||||
SERVER *rc_conf_srv(char *optname)
|
||||
{
|
||||
OPTION *option;
|
||||
|
||||
option = find_option(optname, OT_SRV);
|
||||
|
||||
if (option == NULL)
|
||||
fatal("rc_conf_srv: unkown config option requested: %s", optname);
|
||||
return (SERVER *)option->val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: test_config
|
||||
*
|
||||
* Purpose: test the configuration the user supplied
|
||||
*
|
||||
* Returns: 0 on success, -1 when failure
|
||||
*/
|
||||
|
||||
static int test_config(char *filename)
|
||||
{
|
||||
#if 0
|
||||
struct stat st;
|
||||
char *file;
|
||||
#endif
|
||||
|
||||
if (!(rc_conf_srv("authserver")->max))
|
||||
{
|
||||
error("%s: no authserver specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (!(rc_conf_srv("acctserver")->max))
|
||||
{
|
||||
error("%s: no acctserver specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (!rc_conf_str("servers"))
|
||||
{
|
||||
error("%s: no servers file specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (!rc_conf_str("dictionary"))
|
||||
{
|
||||
error("%s: no dictionary specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (rc_conf_int("radius_timeout") <= 0)
|
||||
{
|
||||
error("%s: radius_timeout <= 0 is illegal", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (rc_conf_int("radius_retries") <= 0)
|
||||
{
|
||||
error("%s: radius_retries <= 0 is illegal", filename);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
file = rc_conf_str("login_local");
|
||||
if (stat(file, &st) == 0)
|
||||
{
|
||||
if (!S_ISREG(st.st_mode)) {
|
||||
error("%s: not a regular file: %s", filename, file);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
error("%s: file not found: %s", filename, file);
|
||||
return (-1);
|
||||
}
|
||||
file = rc_conf_str("login_radius");
|
||||
if (stat(file, &st) == 0)
|
||||
{
|
||||
if (!S_ISREG(st.st_mode)) {
|
||||
error("%s: not a regular file: %s", filename, file);
|
||||
return (-1);
|
||||
}
|
||||
} else {
|
||||
error("%s: file not found: %s", filename, file);
|
||||
return (-1);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rc_conf_int("login_tries") <= 0)
|
||||
{
|
||||
error("%s: login_tries <= 0 is illegal", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (rc_conf_str("seqfile") == NULL)
|
||||
{
|
||||
error("%s: seqfile not specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (rc_conf_int("login_timeout") <= 0)
|
||||
{
|
||||
error("%s: login_timeout <= 0 is illegal", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (rc_conf_str("mapfile") == NULL)
|
||||
{
|
||||
error("%s: mapfile not specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
if (rc_conf_str("nologin") == NULL)
|
||||
{
|
||||
error("%s: nologin not specified", filename);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_find_match
|
||||
*
|
||||
* Purpose: see if ip_addr is one of the ip addresses of hostname
|
||||
*
|
||||
* Returns: 0 on success, -1 when failure
|
||||
*
|
||||
*/
|
||||
|
||||
static int find_match (UINT4 *ip_addr, char *hostname)
|
||||
{
|
||||
UINT4 addr;
|
||||
char **paddr;
|
||||
struct hostent *hp;
|
||||
|
||||
if (rc_good_ipaddr (hostname) == 0)
|
||||
{
|
||||
if (*ip_addr == ntohl(inet_addr (hostname)))
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((hp = gethostbyname (hostname)) == (struct hostent *) NULL)
|
||||
{
|
||||
return (-1);
|
||||
}
|
||||
for (paddr = hp->h_addr_list; *paddr; paddr++)
|
||||
{
|
||||
addr = ** (UINT4 **) paddr;
|
||||
if (ntohl(addr) == *ip_addr)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_find_server
|
||||
*
|
||||
* Purpose: search a server in the servers file
|
||||
*
|
||||
* Returns: 0 on success, -1 on failure
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_find_server (char *server_name, UINT4 *ip_addr, char *secret)
|
||||
{
|
||||
UINT4 myipaddr = 0;
|
||||
int len;
|
||||
int result;
|
||||
FILE *clientfd;
|
||||
char *h;
|
||||
char *s;
|
||||
char *host2;
|
||||
char buffer[128];
|
||||
char hostnm[AUTH_ID_LEN + 1];
|
||||
|
||||
/* Get the IP address of the authentication server */
|
||||
if ((*ip_addr = rc_get_ipaddr (server_name)) == (UINT4) 0)
|
||||
return (-1);
|
||||
|
||||
if ((clientfd = fopen (rc_conf_str("servers"), "r")) == (FILE *) NULL)
|
||||
{
|
||||
error("rc_find_server: couldn't open file: %m: %s", rc_conf_str("servers"));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
myipaddr = rc_own_ipaddress();
|
||||
|
||||
result = 0;
|
||||
while (fgets (buffer, sizeof (buffer), clientfd) != (char *) NULL)
|
||||
{
|
||||
if (*buffer == '#')
|
||||
continue;
|
||||
|
||||
if ((h = strtok (buffer, " \t\n")) == NULL) /* first hostname */
|
||||
continue;
|
||||
|
||||
memset (hostnm, '\0', AUTH_ID_LEN);
|
||||
len = strlen (h);
|
||||
if (len > AUTH_ID_LEN)
|
||||
{
|
||||
len = AUTH_ID_LEN;
|
||||
}
|
||||
strncpy (hostnm, h, (size_t) len);
|
||||
hostnm[AUTH_ID_LEN] = '\0';
|
||||
|
||||
if ((s = strtok (NULL, " \t\n")) == NULL) /* and secret field */
|
||||
continue;
|
||||
|
||||
memset (secret, '\0', MAX_SECRET_LENGTH);
|
||||
len = strlen (s);
|
||||
if (len > MAX_SECRET_LENGTH)
|
||||
{
|
||||
len = MAX_SECRET_LENGTH;
|
||||
}
|
||||
strncpy (secret, s, (size_t) len);
|
||||
secret[MAX_SECRET_LENGTH] = '\0';
|
||||
|
||||
if (!strchr (hostnm, '/')) /* If single name form */
|
||||
{
|
||||
if (find_match (ip_addr, hostnm) == 0)
|
||||
{
|
||||
result++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* <name1>/<name2> "paired" form */
|
||||
{
|
||||
strtok (hostnm, "/");
|
||||
if (find_match (&myipaddr, hostnm) == 0)
|
||||
{ /* If we're the 1st name, target is 2nd */
|
||||
host2 = strtok (NULL, " ");
|
||||
if (find_match (ip_addr, host2) == 0)
|
||||
{
|
||||
result++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* If we were 2nd name, target is 1st name */
|
||||
{
|
||||
if (find_match (ip_addr, hostnm) == 0)
|
||||
{
|
||||
result++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose (clientfd);
|
||||
if (result == 0)
|
||||
{
|
||||
memset (buffer, '\0', sizeof (buffer));
|
||||
memset (secret, '\0', sizeof (secret));
|
||||
error("rc_find_server: couldn't find RADIUS server %s in %s",
|
||||
server_name, rc_conf_str("servers"));
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
450
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/dict.c
vendored
Normal file
450
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/dict.c
vendored
Normal file
@ -0,0 +1,450 @@
|
||||
/*
|
||||
* $Id: dict.c,v 1.1 2004/11/14 07:26:26 paulus Exp $
|
||||
*
|
||||
* Copyright (C) 2002 Roaring Penguin Software Inc.
|
||||
*
|
||||
* Copyright (C) 1995,1996,1997 Lars Fenneberg
|
||||
*
|
||||
* Copyright 1992 Livingston Enterprises, Inc.
|
||||
*
|
||||
* Copyright 1992,1993, 1994,1995 The Regents of the University of Michigan
|
||||
* and Merit Network, Inc. All Rights Reserved
|
||||
*
|
||||
* See the file COPYRIGHT for the respective terms and conditions.
|
||||
* If the file is missing contact me at lf@elemental.net
|
||||
* and I'll send you a copy.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <includes.h>
|
||||
#include <radiusclient.h>
|
||||
|
||||
static DICT_ATTR *dictionary_attributes = NULL;
|
||||
static DICT_VALUE *dictionary_values = NULL;
|
||||
static VENDOR_DICT *vendor_dictionaries = NULL;
|
||||
|
||||
/*
|
||||
* Function: rc_read_dictionary
|
||||
*
|
||||
* Purpose: Initialize the dictionary. Read all ATTRIBUTES into
|
||||
* the dictionary_attributes list. Read all VALUES into
|
||||
* the dictionary_values list. Construct VENDOR dictionaries
|
||||
* as required.
|
||||
*
|
||||
*/
|
||||
|
||||
int rc_read_dictionary (char *filename)
|
||||
{
|
||||
FILE *dictfd;
|
||||
char dummystr[AUTH_ID_LEN];
|
||||
char namestr[AUTH_ID_LEN];
|
||||
char valstr[AUTH_ID_LEN];
|
||||
char attrstr[AUTH_ID_LEN];
|
||||
char typestr[AUTH_ID_LEN];
|
||||
char vendorstr[AUTH_ID_LEN];
|
||||
int line_no;
|
||||
DICT_ATTR *attr;
|
||||
DICT_VALUE *dval;
|
||||
VENDOR_DICT *vdict;
|
||||
char buffer[256];
|
||||
int value;
|
||||
int type;
|
||||
int n;
|
||||
int retcode;
|
||||
if ((dictfd = fopen (filename, "r")) == (FILE *) NULL)
|
||||
{
|
||||
error( "rc_read_dictionary: couldn't open dictionary %s: %s",
|
||||
filename, strerror(errno));
|
||||
return (-1);
|
||||
}
|
||||
|
||||
line_no = 0;
|
||||
retcode = 0;
|
||||
while (fgets (buffer, sizeof (buffer), dictfd) != (char *) NULL)
|
||||
{
|
||||
line_no++;
|
||||
|
||||
/* Skip empty space */
|
||||
if (*buffer == '#' || *buffer == '\0' || *buffer == '\n')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (strncmp (buffer, "VENDOR", 6) == 0) {
|
||||
/* Read the VENDOR line */
|
||||
if (sscanf(buffer, "%s%s%d", dummystr, namestr, &value) != 3) {
|
||||
error("rc_read_dictionary: invalid vendor on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
/* Validate entry */
|
||||
if (strlen (namestr) > NAME_LENGTH) {
|
||||
error("rc_read_dictionary: invalid name length on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
/* Create new vendor entry */
|
||||
vdict = (VENDOR_DICT *) malloc (sizeof (VENDOR_DICT));
|
||||
if (!vdict) {
|
||||
novm("rc_read_dictionary");
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
strcpy(vdict->vendorname, namestr);
|
||||
vdict->vendorcode = value;
|
||||
vdict->attributes = NULL;
|
||||
vdict->next = vendor_dictionaries;
|
||||
vendor_dictionaries = vdict;
|
||||
}
|
||||
else if (strncmp (buffer, "ATTRIBUTE", 9) == 0)
|
||||
{
|
||||
|
||||
/* Read the ATTRIBUTE line. It is one of:
|
||||
* ATTRIBUTE attr_name attr_val type OR
|
||||
* ATTRIBUTE attr_name attr_val type vendor */
|
||||
vendorstr[0] = 0;
|
||||
n = sscanf(buffer, "%s%s%s%s%s", dummystr, namestr, valstr, typestr, vendorstr);
|
||||
if (n != 4 && n != 5)
|
||||
{
|
||||
error("rc_read_dictionary: invalid attribute on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate all entries
|
||||
*/
|
||||
if (strlen (namestr) > NAME_LENGTH)
|
||||
{
|
||||
error("rc_read_dictionary: invalid name length on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen (vendorstr) > NAME_LENGTH)
|
||||
{
|
||||
error("rc_read_dictionary: invalid name length on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isdigit (*valstr))
|
||||
{
|
||||
error("rc_read_dictionary: invalid value on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
value = atoi (valstr);
|
||||
|
||||
if (strcmp (typestr, "string") == 0)
|
||||
{
|
||||
type = PW_TYPE_STRING;
|
||||
}
|
||||
else if (strcmp (typestr, "integer") == 0)
|
||||
{
|
||||
type = PW_TYPE_INTEGER;
|
||||
}
|
||||
else if (strcmp (typestr, "ipaddr") == 0)
|
||||
{
|
||||
type = PW_TYPE_IPADDR;
|
||||
}
|
||||
else if (strcmp (typestr, "date") == 0)
|
||||
{
|
||||
type = PW_TYPE_DATE;
|
||||
}
|
||||
else
|
||||
{
|
||||
error("rc_read_dictionary: invalid type on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Search for vendor if supplied */
|
||||
if (*vendorstr) {
|
||||
vdict = rc_dict_findvendor(vendorstr);
|
||||
if (!vdict) {
|
||||
error("rc_read_dictionary: unknown vendor on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
vdict = NULL;
|
||||
}
|
||||
/* Create a new attribute for the list */
|
||||
if ((attr =
|
||||
(DICT_ATTR *) malloc (sizeof (DICT_ATTR)))
|
||||
== (DICT_ATTR *) NULL)
|
||||
{
|
||||
novm("rc_read_dictionary");
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
strcpy (attr->name, namestr);
|
||||
if (vdict) {
|
||||
attr->vendorcode = vdict->vendorcode;
|
||||
} else {
|
||||
attr->vendorcode = VENDOR_NONE;
|
||||
}
|
||||
attr->value = value;
|
||||
attr->type = type;
|
||||
|
||||
/* Insert it into the list */
|
||||
if (vdict) {
|
||||
attr->next = vdict->attributes;
|
||||
vdict->attributes = attr;
|
||||
} else {
|
||||
attr->next = dictionary_attributes;
|
||||
dictionary_attributes = attr;
|
||||
}
|
||||
}
|
||||
else if (strncmp (buffer, "VALUE", 5) == 0)
|
||||
{
|
||||
/* Read the VALUE line */
|
||||
if (sscanf (buffer, "%s%s%s%s", dummystr, attrstr,
|
||||
namestr, valstr) != 4)
|
||||
{
|
||||
error("rc_read_dictionary: invalid value entry on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate all entries
|
||||
*/
|
||||
if (strlen (attrstr) > NAME_LENGTH)
|
||||
{
|
||||
error("rc_read_dictionary: invalid attribute length on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (strlen (namestr) > NAME_LENGTH)
|
||||
{
|
||||
error("rc_read_dictionary: invalid name length on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!isdigit (*valstr))
|
||||
{
|
||||
error("rc_read_dictionary: invalid value on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
value = atoi (valstr);
|
||||
|
||||
/* Create a new VALUE entry for the list */
|
||||
if ((dval =
|
||||
(DICT_VALUE *) malloc (sizeof (DICT_VALUE)))
|
||||
== (DICT_VALUE *) NULL)
|
||||
{
|
||||
novm("rc_read_dictionary");
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
strcpy (dval->attrname, attrstr);
|
||||
strcpy (dval->name, namestr);
|
||||
dval->value = value;
|
||||
|
||||
/* Insert it into the list */
|
||||
dval->next = dictionary_values;
|
||||
dictionary_values = dval;
|
||||
}
|
||||
else if (strncmp (buffer, "INCLUDE", 7) == 0)
|
||||
{
|
||||
/* Read the INCLUDE line */
|
||||
if (sscanf (buffer, "%s%s", dummystr, namestr) != 2)
|
||||
{
|
||||
error("rc_read_dictionary: invalid include entry on line %d of dictionary %s",
|
||||
line_no, filename);
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
if (rc_read_dictionary(namestr) == -1)
|
||||
{
|
||||
retcode = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose (dictfd);
|
||||
return retcode;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_dict_getattr
|
||||
*
|
||||
* Purpose: Return the full attribute structure based on the
|
||||
* attribute id number and vendor code. If vendor code is VENDOR_NONE,
|
||||
* non-vendor-specific attributes are used
|
||||
*
|
||||
*/
|
||||
|
||||
DICT_ATTR *rc_dict_getattr (int attribute, int vendor)
|
||||
{
|
||||
DICT_ATTR *attr;
|
||||
VENDOR_DICT *dict;
|
||||
|
||||
if (vendor == VENDOR_NONE) {
|
||||
attr = dictionary_attributes;
|
||||
while (attr != (DICT_ATTR *) NULL) {
|
||||
if (attr->value == attribute) {
|
||||
return (attr);
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
} else {
|
||||
dict = rc_dict_getvendor(vendor);
|
||||
if (!dict) {
|
||||
return NULL;
|
||||
}
|
||||
attr = dict->attributes;
|
||||
while (attr) {
|
||||
if (attr->value == attribute) {
|
||||
return attr;
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_dict_findattr
|
||||
*
|
||||
* Purpose: Return the full attribute structure based on the
|
||||
* attribute name.
|
||||
*
|
||||
*/
|
||||
|
||||
DICT_ATTR *rc_dict_findattr (char *attrname)
|
||||
{
|
||||
DICT_ATTR *attr;
|
||||
VENDOR_DICT *dict;
|
||||
|
||||
attr = dictionary_attributes;
|
||||
while (attr != (DICT_ATTR *) NULL)
|
||||
{
|
||||
if (strcasecmp (attr->name, attrname) == 0)
|
||||
{
|
||||
return (attr);
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
|
||||
/* Search vendor-specific dictionaries */
|
||||
dict = vendor_dictionaries;
|
||||
while (dict) {
|
||||
attr = dict->attributes;
|
||||
while (attr) {
|
||||
if (strcasecmp (attr->name, attrname) == 0) {
|
||||
return (attr);
|
||||
}
|
||||
attr = attr->next;
|
||||
}
|
||||
dict = dict->next;
|
||||
}
|
||||
return ((DICT_ATTR *) NULL);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function: rc_dict_findval
|
||||
*
|
||||
* Purpose: Return the full value structure based on the
|
||||
* value name.
|
||||
*
|
||||
*/
|
||||
|
||||
DICT_VALUE *rc_dict_findval (char *valname)
|
||||
{
|
||||
DICT_VALUE *val;
|
||||
|
||||
val = dictionary_values;
|
||||
while (val != (DICT_VALUE *) NULL)
|
||||
{
|
||||
if (strcasecmp (val->name, valname) == 0)
|
||||
{
|
||||
return (val);
|
||||
}
|
||||
val = val->next;
|
||||
}
|
||||
return ((DICT_VALUE *) NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: dict_getval
|
||||
*
|
||||
* Purpose: Return the full value structure based on the
|
||||
* actual value and the associated attribute name.
|
||||
*
|
||||
*/
|
||||
|
||||
DICT_VALUE * rc_dict_getval (UINT4 value, char *attrname)
|
||||
{
|
||||
DICT_VALUE *val;
|
||||
|
||||
val = dictionary_values;
|
||||
while (val != (DICT_VALUE *) NULL)
|
||||
{
|
||||
if (strcmp (val->attrname, attrname) == 0 &&
|
||||
val->value == value)
|
||||
{
|
||||
return (val);
|
||||
}
|
||||
val = val->next;
|
||||
}
|
||||
return ((DICT_VALUE *) NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_dict_findvendor
|
||||
*
|
||||
* Purpose: Return the vendor's dictionary given the vendor name.
|
||||
*
|
||||
*/
|
||||
VENDOR_DICT * rc_dict_findvendor (char *vendorname)
|
||||
{
|
||||
VENDOR_DICT *dict;
|
||||
|
||||
dict = vendor_dictionaries;
|
||||
while (dict) {
|
||||
if (!strcmp(vendorname, dict->vendorname)) {
|
||||
return dict;
|
||||
}
|
||||
dict = dict->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: rc_dict_getvendor
|
||||
*
|
||||
* Purpose: Return the vendor's dictionary given the vendor ID
|
||||
*
|
||||
*/
|
||||
VENDOR_DICT * rc_dict_getvendor (int id)
|
||||
{
|
||||
VENDOR_DICT *dict;
|
||||
|
||||
dict = vendor_dictionaries;
|
||||
while (dict) {
|
||||
if (id == dict->vendorcode) {
|
||||
return dict;
|
||||
}
|
||||
dict = dict->next;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
253
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/etc/dictionary
vendored
Normal file
253
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/etc/dictionary
vendored
Normal file
@ -0,0 +1,253 @@
|
||||
#
|
||||
# Updated 97/06/13 to livingston-radius-2.01 miquels@cistron.nl
|
||||
#
|
||||
# This file contains dictionary translations for parsing
|
||||
# requests and generating responses. All transactions are
|
||||
# composed of Attribute/Value Pairs. The value of each attribute
|
||||
# is specified as one of 4 data types. Valid data types are:
|
||||
#
|
||||
# string - 0-253 octets
|
||||
# ipaddr - 4 octets in network byte order
|
||||
# integer - 32 bit value in big endian order (high byte first)
|
||||
# date - 32 bit value in big endian order - seconds since
|
||||
# 00:00:00 GMT, Jan. 1, 1970
|
||||
#
|
||||
# Enumerated values are stored in the user file with dictionary
|
||||
# VALUE translations for easy administration.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# ATTRIBUTE VALUE
|
||||
# --------------- -----
|
||||
# Framed-Protocol = PPP
|
||||
# 7 = 1 (integer encoding)
|
||||
#
|
||||
|
||||
# The dictionary format now supports vendor-specific attributes.
|
||||
# Vendors are introduced like this:
|
||||
#
|
||||
# VENDOR vendor_name vendor_number
|
||||
#
|
||||
# For example:
|
||||
#
|
||||
# VENDOR RoaringPenguin 10055
|
||||
#
|
||||
# Vendor-specific attributes have a fifth field with the name of the
|
||||
# vendor. For example:
|
||||
#
|
||||
# ATTRIBUTE RP-Upstream-Speed-Limit 1 integer RoaringPenguin
|
||||
#
|
||||
# introduces a Roaring Penguin vendor-specific attribbute with name
|
||||
# RP-Upstream-Speed-Limit, number 1, type integer and vendor RoaringPenguin.
|
||||
|
||||
#
|
||||
# Following are the proper new names. Use these.
|
||||
#
|
||||
ATTRIBUTE User-Name 1 string
|
||||
ATTRIBUTE Password 2 string
|
||||
ATTRIBUTE CHAP-Password 3 string
|
||||
ATTRIBUTE NAS-IP-Address 4 ipaddr
|
||||
ATTRIBUTE NAS-Port-Id 5 integer
|
||||
ATTRIBUTE Service-Type 6 integer
|
||||
ATTRIBUTE Framed-Protocol 7 integer
|
||||
ATTRIBUTE Framed-IP-Address 8 ipaddr
|
||||
ATTRIBUTE Framed-IP-Netmask 9 ipaddr
|
||||
ATTRIBUTE Framed-Routing 10 integer
|
||||
ATTRIBUTE Filter-Id 11 string
|
||||
ATTRIBUTE Framed-MTU 12 integer
|
||||
ATTRIBUTE Framed-Compression 13 integer
|
||||
ATTRIBUTE Login-IP-Host 14 ipaddr
|
||||
ATTRIBUTE Login-Service 15 integer
|
||||
ATTRIBUTE Login-TCP-Port 16 integer
|
||||
ATTRIBUTE Reply-Message 18 string
|
||||
ATTRIBUTE Callback-Number 19 string
|
||||
ATTRIBUTE Callback-Id 20 string
|
||||
ATTRIBUTE Framed-Route 22 string
|
||||
ATTRIBUTE Framed-IPX-Network 23 ipaddr
|
||||
ATTRIBUTE State 24 string
|
||||
ATTRIBUTE Class 25 string
|
||||
ATTRIBUTE Session-Timeout 27 integer
|
||||
ATTRIBUTE Idle-Timeout 28 integer
|
||||
ATTRIBUTE Termination-Action 29 integer
|
||||
ATTRIBUTE Called-Station-Id 30 string
|
||||
ATTRIBUTE Calling-Station-Id 31 string
|
||||
ATTRIBUTE NAS-Identifier 32 string
|
||||
ATTRIBUTE Acct-Status-Type 40 integer
|
||||
ATTRIBUTE Acct-Delay-Time 41 integer
|
||||
ATTRIBUTE Acct-Input-Octets 42 integer
|
||||
ATTRIBUTE Acct-Output-Octets 43 integer
|
||||
ATTRIBUTE Acct-Session-Id 44 string
|
||||
ATTRIBUTE Acct-Authentic 45 integer
|
||||
ATTRIBUTE Acct-Session-Time 46 integer
|
||||
ATTRIBUTE Acct-Input-Packets 47 integer
|
||||
ATTRIBUTE Acct-Output-Packets 48 integer
|
||||
ATTRIBUTE Acct-Terminate-Cause 49 integer
|
||||
ATTRIBUTE Chap-Challenge 60 string
|
||||
ATTRIBUTE NAS-Port-Type 61 integer
|
||||
ATTRIBUTE Port-Limit 62 integer
|
||||
ATTRIBUTE Connect-Info 77 string
|
||||
|
||||
# RFC 2869
|
||||
ATTRIBUTE Acct-Interim-Interval 85 integer
|
||||
|
||||
#
|
||||
# Experimental Non Protocol Attributes used by Cistron-Radiusd
|
||||
#
|
||||
ATTRIBUTE Huntgroup-Name 221 string
|
||||
ATTRIBUTE User-Category 1029 string
|
||||
ATTRIBUTE Group-Name 1030 string
|
||||
ATTRIBUTE Simultaneous-Use 1034 integer
|
||||
ATTRIBUTE Strip-User-Name 1035 integer
|
||||
ATTRIBUTE Fall-Through 1036 integer
|
||||
ATTRIBUTE Add-Port-To-IP-Address 1037 integer
|
||||
ATTRIBUTE Exec-Program 1038 string
|
||||
ATTRIBUTE Exec-Program-Wait 1039 string
|
||||
ATTRIBUTE Hint 1040 string
|
||||
|
||||
#
|
||||
# Non-Protocol Attributes
|
||||
# These attributes are used internally by the server
|
||||
#
|
||||
ATTRIBUTE Expiration 21 date
|
||||
ATTRIBUTE Auth-Type 1000 integer
|
||||
ATTRIBUTE Menu 1001 string
|
||||
ATTRIBUTE Termination-Menu 1002 string
|
||||
ATTRIBUTE Prefix 1003 string
|
||||
ATTRIBUTE Suffix 1004 string
|
||||
ATTRIBUTE Group 1005 string
|
||||
ATTRIBUTE Crypt-Password 1006 string
|
||||
ATTRIBUTE Connect-Rate 1007 integer
|
||||
|
||||
#
|
||||
# Experimental, implementation specific attributes
|
||||
#
|
||||
# Limit session traffic
|
||||
ATTRIBUTE Session-Octets-Limit 227 integer
|
||||
# What to assume as limit - 0 in+out, 1 in, 2 out, 3 max(in,out)
|
||||
ATTRIBUTE Octets-Direction 228 integer
|
||||
|
||||
#
|
||||
# Integer Translations
|
||||
#
|
||||
|
||||
# User Types
|
||||
|
||||
VALUE Service-Type Login-User 1
|
||||
VALUE Service-Type Framed-User 2
|
||||
VALUE Service-Type Callback-Login-User 3
|
||||
VALUE Service-Type Callback-Framed-User 4
|
||||
VALUE Service-Type Outbound-User 5
|
||||
VALUE Service-Type Administrative-User 6
|
||||
VALUE Service-Type NAS-Prompt-User 7
|
||||
|
||||
# Framed Protocols
|
||||
|
||||
VALUE Framed-Protocol PPP 1
|
||||
VALUE Framed-Protocol SLIP 2
|
||||
|
||||
# Framed Routing Values
|
||||
|
||||
VALUE Framed-Routing None 0
|
||||
VALUE Framed-Routing Broadcast 1
|
||||
VALUE Framed-Routing Listen 2
|
||||
VALUE Framed-Routing Broadcast-Listen 3
|
||||
|
||||
# Framed Compression Types
|
||||
|
||||
VALUE Framed-Compression None 0
|
||||
VALUE Framed-Compression Van-Jacobson-TCP-IP 1
|
||||
|
||||
# Login Services
|
||||
|
||||
VALUE Login-Service Telnet 0
|
||||
VALUE Login-Service Rlogin 1
|
||||
VALUE Login-Service TCP-Clear 2
|
||||
VALUE Login-Service PortMaster 3
|
||||
|
||||
# Status Types
|
||||
|
||||
VALUE Acct-Status-Type Start 1
|
||||
VALUE Acct-Status-Type Stop 2
|
||||
VALUE Acct-Status-Type Accounting-On 7
|
||||
VALUE Acct-Status-Type Accounting-Off 8
|
||||
|
||||
# Authentication Types
|
||||
|
||||
VALUE Acct-Authentic RADIUS 1
|
||||
VALUE Acct-Authentic Local 2
|
||||
VALUE Acct-Authentic PowerLink128 100
|
||||
|
||||
# Termination Options
|
||||
|
||||
VALUE Termination-Action Default 0
|
||||
VALUE Termination-Action RADIUS-Request 1
|
||||
|
||||
# NAS Port Types, available in 3.3.1 and later
|
||||
|
||||
VALUE NAS-Port-Type Async 0
|
||||
VALUE NAS-Port-Type Sync 1
|
||||
VALUE NAS-Port-Type ISDN 2
|
||||
VALUE NAS-Port-Type ISDN-V120 3
|
||||
VALUE NAS-Port-Type ISDN-V110 4
|
||||
|
||||
# Acct Terminate Causes, available in 3.3.2 and later
|
||||
|
||||
VALUE Acct-Terminate-Cause User-Request 1
|
||||
VALUE Acct-Terminate-Cause Lost-Carrier 2
|
||||
VALUE Acct-Terminate-Cause Lost-Service 3
|
||||
VALUE Acct-Terminate-Cause Idle-Timeout 4
|
||||
VALUE Acct-Terminate-Cause Session-Timeout 5
|
||||
VALUE Acct-Terminate-Cause Admin-Reset 6
|
||||
VALUE Acct-Terminate-Cause Admin-Reboot 7
|
||||
VALUE Acct-Terminate-Cause Port-Error 8
|
||||
VALUE Acct-Terminate-Cause NAS-Error 9
|
||||
VALUE Acct-Terminate-Cause NAS-Request 10
|
||||
VALUE Acct-Terminate-Cause NAS-Reboot 11
|
||||
VALUE Acct-Terminate-Cause Port-Unneeded 12
|
||||
VALUE Acct-Terminate-Cause Port-Preempted 13
|
||||
VALUE Acct-Terminate-Cause Port-Suspended 14
|
||||
VALUE Acct-Terminate-Cause Service-Unavailable 15
|
||||
VALUE Acct-Terminate-Cause Callback 16
|
||||
VALUE Acct-Terminate-Cause User-Error 17
|
||||
VALUE Acct-Terminate-Cause Host-Request 18
|
||||
|
||||
#
|
||||
# Non-Protocol Integer Translations
|
||||
#
|
||||
|
||||
VALUE Auth-Type Local 0
|
||||
VALUE Auth-Type System 1
|
||||
VALUE Auth-Type SecurID 2
|
||||
VALUE Auth-Type Crypt-Local 3
|
||||
VALUE Auth-Type Reject 4
|
||||
|
||||
#
|
||||
# Cistron extensions
|
||||
#
|
||||
VALUE Auth-Type Pam 253
|
||||
VALUE Auth-Type None 254
|
||||
|
||||
#
|
||||
# Experimental Non-Protocol Integer Translations for Cistron-Radiusd
|
||||
#
|
||||
VALUE Fall-Through No 0
|
||||
VALUE Fall-Through Yes 1
|
||||
VALUE Add-Port-To-IP-Address No 0
|
||||
VALUE Add-Port-To-IP-Address Yes 1
|
||||
|
||||
#
|
||||
# Configuration Values
|
||||
# uncomment these two lines to turn account expiration on
|
||||
#
|
||||
|
||||
#VALUE Server-Config Password-Expiration 30
|
||||
#VALUE Server-Config Password-Warning 5
|
||||
|
||||
# Octets-Direction
|
||||
VALUE Octets-Direction Sum 0
|
||||
VALUE Octets-Direction Input 1
|
||||
VALUE Octets-Direction Output 2
|
||||
VALUE Octets-Direction MaxOveral 3
|
||||
VALUE Octets-Direction MaxSession 4
|
||||
|
||||
INCLUDE /etc/radiusclient/dictionary.microsoft
|
||||
295
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/etc/dictionary.ascend
vendored
Normal file
295
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/etc/dictionary.ascend
vendored
Normal file
@ -0,0 +1,295 @@
|
||||
#
|
||||
# Ascend dictionary.
|
||||
#
|
||||
#
|
||||
# Version: 1.00 21-Jul-1997 Jens Glaser <jens@regio.net>
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# Ascend specific extensions
|
||||
# Used by ASCEND MAX/Pipeline products
|
||||
#
|
||||
ATTRIBUTE Ascend-FCP-Parameter 119 string
|
||||
ATTRIBUTE Ascend-Modem-PortNo 120 integer
|
||||
ATTRIBUTE Ascend-Modem-SlotNo 121 integer
|
||||
ATTRIBUTE Ascend-Modem-ShelfNo 122 integer
|
||||
ATTRIBUTE Ascend-Call-Attempt-Limit 123 integer
|
||||
ATTRIBUTE Ascend-Call-Block-Duration 124 integer
|
||||
ATTRIBUTE Ascend-Maximum-Call-Duration 125 integer
|
||||
ATTRIBUTE Ascend-Temporary-Rtes 126 integer
|
||||
ATTRIBUTE Tunneling-Protocol 127 integer
|
||||
ATTRIBUTE Ascend-Shared-Profile-Enable 128 integer
|
||||
ATTRIBUTE Ascend-Primary-Home-Agent 129 string
|
||||
ATTRIBUTE Ascend-Secondary-Home-Agent 130 string
|
||||
ATTRIBUTE Ascend-Dialout-Allowed 131 integer
|
||||
ATTRIBUTE Ascend-Client-Gateway 132 ipaddr
|
||||
ATTRIBUTE Ascend-BACP-Enable 133 integer
|
||||
ATTRIBUTE Ascend-DHCP-Maximum-Leases 134 integer
|
||||
ATTRIBUTE Ascend-Client-Primary-DNS 135 ipaddr
|
||||
ATTRIBUTE Ascend-Client-Secondary-DNS 136 ipaddr
|
||||
ATTRIBUTE Ascend-Client-Assign-DNS 137 integer
|
||||
ATTRIBUTE Ascend-User-Acct-Type 138 integer
|
||||
ATTRIBUTE Ascend-User-Acct-Host 139 ipaddr
|
||||
ATTRIBUTE Ascend-User-Acct-Port 140 integer
|
||||
ATTRIBUTE Ascend-User-Acct-Key 141 string
|
||||
ATTRIBUTE Ascend-User-Acct-Base 142 integer
|
||||
ATTRIBUTE Ascend-User-Acct-Time 143 integer
|
||||
ATTRIBUTE Ascend-Assign-IP-Client 144 ipaddr
|
||||
ATTRIBUTE Ascend-Assign-IP-Server 145 ipaddr
|
||||
ATTRIBUTE Ascend-Assign-IP-Global-Pool 146 string
|
||||
ATTRIBUTE Ascend-DHCP-Reply 147 integer
|
||||
ATTRIBUTE Ascend-DHCP-Pool-Number 148 integer
|
||||
ATTRIBUTE Ascend-Expect-Callback 149 integer
|
||||
ATTRIBUTE Ascend-Event-Type 150 integer
|
||||
ATTRIBUTE Ascend-Session-Svr-Key 151 string
|
||||
ATTRIBUTE Ascend-Multicast-Rate-Limit 152 integer
|
||||
ATTRIBUTE Ascend-IF-Netmask 153 ipaddr
|
||||
ATTRIBUTE Ascend-Remote-Addr 154 ipaddr
|
||||
ATTRIBUTE Ascend-Multicast-Client 155 integer
|
||||
ATTRIBUTE Ascend-FR-Circuit-Name 156 string
|
||||
ATTRIBUTE Ascend-FR-LinkUp 157 integer
|
||||
ATTRIBUTE Ascend-FR-Nailed-Grp 158 integer
|
||||
ATTRIBUTE Ascend-FR-Type 159 integer
|
||||
ATTRIBUTE Ascend-FR-Link-Mgt 160 integer
|
||||
ATTRIBUTE Ascend-FR-N391 161 integer
|
||||
ATTRIBUTE Ascend-FR-DCE-N392 162 integer
|
||||
ATTRIBUTE Ascend-FR-DTE-N392 163 integer
|
||||
ATTRIBUTE Ascend-FR-DCE-N393 164 integer
|
||||
ATTRIBUTE Ascend-FR-DTE-N393 165 integer
|
||||
ATTRIBUTE Ascend-FR-T391 166 integer
|
||||
ATTRIBUTE Ascend-FR-T392 167 integer
|
||||
ATTRIBUTE Ascend-Bridge-Address 168 string
|
||||
ATTRIBUTE Ascend-TS-Idle-Limit 169 integer
|
||||
ATTRIBUTE Ascend-TS-Idle-Mode 170 integer
|
||||
ATTRIBUTE Ascend-DBA-Monitor 171 integer
|
||||
ATTRIBUTE Ascend-Base-Channel-Count 172 integer
|
||||
ATTRIBUTE Ascend-Minimum-Channels 173 integer
|
||||
ATTRIBUTE Ascend-IPX-Route 174 string
|
||||
ATTRIBUTE Ascend-FT1-Caller 175 integer
|
||||
ATTRIBUTE Ascend-Backup 176 string
|
||||
ATTRIBUTE Ascend-Call-Type 177 integer
|
||||
ATTRIBUTE Ascend-Group 178 string
|
||||
ATTRIBUTE Ascend-FR-DLCI 179 integer
|
||||
ATTRIBUTE Ascend-FR-Profile-Name 180 string
|
||||
ATTRIBUTE Ascend-Ara-PW 181 string
|
||||
ATTRIBUTE Ascend-IPX-Node-Addr 182 string
|
||||
ATTRIBUTE Ascend-Home-Agent-IP-Addr 183 ipaddr
|
||||
ATTRIBUTE Ascend-Home-Agent-Password 184 string
|
||||
ATTRIBUTE Ascend-Home-Network-Name 185 string
|
||||
ATTRIBUTE Ascend-Home-Agent-UDP-Port 186 integer
|
||||
ATTRIBUTE Ascend-Multilink-ID 187 integer
|
||||
ATTRIBUTE Ascend-Num-In-Multilink 188 integer
|
||||
ATTRIBUTE Ascend-First-Dest 189 ipaddr
|
||||
ATTRIBUTE Ascend-Pre-Input-Octets 190 integer
|
||||
ATTRIBUTE Ascend-Pre-Output-Octets 191 integer
|
||||
ATTRIBUTE Ascend-Pre-Input-Packets 192 integer
|
||||
ATTRIBUTE Ascend-Pre-Output-Packets 193 integer
|
||||
ATTRIBUTE Ascend-Maximum-Time 194 integer
|
||||
ATTRIBUTE Ascend-Disconnect-Cause 195 integer
|
||||
ATTRIBUTE Ascend-Connect-Progress 196 integer
|
||||
ATTRIBUTE Ascend-Data-Rate 197 integer
|
||||
ATTRIBUTE Ascend-PreSession-Time 198 integer
|
||||
ATTRIBUTE Ascend-Token-Idle 199 integer
|
||||
ATTRIBUTE Ascend-Token-Immediate 200 integer
|
||||
ATTRIBUTE Ascend-Require-Auth 201 integer
|
||||
ATTRIBUTE Ascend-Number-Sessions 202 string
|
||||
ATTRIBUTE Ascend-Authen-Alias 203 string
|
||||
ATTRIBUTE Ascend-Token-Expiry 204 integer
|
||||
ATTRIBUTE Ascend-Menu-Selector 205 string
|
||||
ATTRIBUTE Ascend-Menu-Item 206 string
|
||||
ATTRIBUTE Ascend-PW-Warntime 207 integer
|
||||
ATTRIBUTE Ascend-PW-Lifetime 208 integer
|
||||
ATTRIBUTE Ascend-IP-Direct 209 ipaddr
|
||||
ATTRIBUTE Ascend-PPP-VJ-Slot-Comp 210 integer
|
||||
ATTRIBUTE Ascend-PPP-VJ-1172 211 integer
|
||||
ATTRIBUTE Ascend-PPP-Async-Map 212 integer
|
||||
ATTRIBUTE Ascend-Third-Prompt 213 string
|
||||
ATTRIBUTE Ascend-Send-Secret 214 string
|
||||
ATTRIBUTE Ascend-Receive-Secret 215 string
|
||||
ATTRIBUTE Ascend-IPX-Peer-Mode 216 integer
|
||||
ATTRIBUTE Ascend-IP-Pool-Definition 217 string
|
||||
ATTRIBUTE Ascend-Assign-IP-Pool 218 integer
|
||||
ATTRIBUTE Ascend-FR-Direct 219 integer
|
||||
ATTRIBUTE Ascend-FR-Direct-Profile 220 string
|
||||
ATTRIBUTE Ascend-FR-Direct-DLCI 221 integer
|
||||
ATTRIBUTE Ascend-Handle-IPX 222 integer
|
||||
ATTRIBUTE Ascend-Netware-timeout 223 integer
|
||||
ATTRIBUTE Ascend-IPX-Alias 224 integer
|
||||
ATTRIBUTE Ascend-Metric 225 integer
|
||||
ATTRIBUTE Ascend-PRI-Number-Type 226 integer
|
||||
ATTRIBUTE Ascend-Dial-Number 227 string
|
||||
ATTRIBUTE Ascend-Route-IP 228 integer
|
||||
ATTRIBUTE Ascend-Route-IPX 229 integer
|
||||
ATTRIBUTE Ascend-Bridge 230 integer
|
||||
ATTRIBUTE Ascend-Send-Auth 231 integer
|
||||
ATTRIBUTE Ascend-Send-Passwd 232 string
|
||||
ATTRIBUTE Ascend-Link-Compression 233 integer
|
||||
ATTRIBUTE Ascend-Target-Util 234 integer
|
||||
ATTRIBUTE Ascend-Maximum-Channels 235 integer
|
||||
ATTRIBUTE Ascend-Inc-Channel-Count 236 integer
|
||||
ATTRIBUTE Ascend-Dec-Channel-Count 237 integer
|
||||
ATTRIBUTE Ascend-Seconds-Of-History 238 integer
|
||||
ATTRIBUTE Ascend-History-Weigh-Type 239 integer
|
||||
ATTRIBUTE Ascend-Add-Seconds 240 integer
|
||||
ATTRIBUTE Ascend-Remove-Seconds 241 integer
|
||||
ATTRIBUTE Ascend-Idle-Limit 244 integer
|
||||
ATTRIBUTE Ascend-Preempt-Limit 245 integer
|
||||
ATTRIBUTE Ascend-Callback 246 integer
|
||||
ATTRIBUTE Ascend-Data-Svc 247 integer
|
||||
ATTRIBUTE Ascend-Force-56 248 integer
|
||||
ATTRIBUTE Ascend-Billing-Number 249 string
|
||||
ATTRIBUTE Ascend-Call-By-Call 250 integer
|
||||
ATTRIBUTE Ascend-Transit-Number 251 string
|
||||
ATTRIBUTE Ascend-Host-Info 252 string
|
||||
ATTRIBUTE Ascend-PPP-Address 253 ipaddr
|
||||
ATTRIBUTE Ascend-MPP-Idle-Percent 254 integer
|
||||
ATTRIBUTE Ascend-Xmit-Rate 255 integer
|
||||
|
||||
|
||||
|
||||
# Ascend protocols
|
||||
VALUE Service-Type Dialout-Framed-User 5
|
||||
VALUE Framed-Protocol ARA 255
|
||||
VALUE Framed-Protocol MPP 256
|
||||
VALUE Framed-Protocol EURAW 257
|
||||
VALUE Framed-Protocol EUUI 258
|
||||
VALUE Framed-Protocol X25 259
|
||||
VALUE Framed-Protocol COMB 260
|
||||
VALUE Framed-Protocol FR 261
|
||||
VALUE Framed-Protocol MP 262
|
||||
VALUE Framed-Protocol FR-CIR 263
|
||||
|
||||
|
||||
#
|
||||
# Ascend specific extensions
|
||||
# Used by ASCEND MAX/Pipeline products (see above)
|
||||
#
|
||||
|
||||
VALUE Ascend-FR-Direct FR-Direct-No 0
|
||||
VALUE Ascend-FR-Direct FR-Direct-Yes 1
|
||||
VALUE Ascend-Handle-IPX Handle-IPX-None 0
|
||||
VALUE Ascend-Handle-IPX Handle-IPX-Client 1
|
||||
VALUE Ascend-Handle-IPX Handle-IPX-Server 2
|
||||
VALUE Ascend-IPX-Peer-Mode IPX-Peer-Router 0
|
||||
VALUE Ascend-IPX-Peer-Mode IPX-Peer-Dialin 1
|
||||
VALUE Ascend-Call-Type Nailed 1
|
||||
VALUE Ascend-Call-Type Nailed/Mpp 2
|
||||
VALUE Ascend-Call-Type Perm/Switched 3
|
||||
VALUE Ascend-FT1-Caller FT1-No 0
|
||||
VALUE Ascend-FT1-Caller FT1-Yes 1
|
||||
VALUE Ascend-PRI-Number-Type Unknown-Number 0
|
||||
VALUE Ascend-PRI-Number-Type Intl-Number 1
|
||||
VALUE Ascend-PRI-Number-Type National-Number 2
|
||||
VALUE Ascend-PRI-Number-Type Local-Number 4
|
||||
VALUE Ascend-PRI-Number-Type Abbrev-Number 5
|
||||
VALUE Ascend-Route-IPX Route-IPX-No 0
|
||||
VALUE Ascend-Route-IPX Route-IPX-Yes 1
|
||||
VALUE Ascend-Bridge Bridge-No 0
|
||||
VALUE Ascend-Bridge Bridge-Yes 1
|
||||
VALUE Ascend-TS-Idle-Mode TS-Idle-None 0
|
||||
VALUE Ascend-TS-Idle-Mode TS-Idle-Input 1
|
||||
VALUE Ascend-TS-Idle-Mode TS-Idle-Input-Output 2
|
||||
VALUE Ascend-Send-Auth Send-Auth-None 0
|
||||
VALUE Ascend-Send-Auth Send-Auth-PAP 1
|
||||
VALUE Ascend-Send-Auth Send-Auth-CHAP 2
|
||||
VALUE Ascend-Send-Auth Send-Auth-MS-CHAP 3
|
||||
VALUE Ascend-Link-Compression Link-Comp-None 0
|
||||
VALUE Ascend-Link-Compression Link-Comp-Stac 1
|
||||
VALUE Ascend-Link-Compression Link-Comp-Stac-Draft-9 2
|
||||
VALUE Ascend-Link-Compression Link-Comp-MS-Stac 3
|
||||
VALUE Ascend-History-Weigh-Type History-Constant 0
|
||||
VALUE Ascend-History-Weigh-Type History-Linear 1
|
||||
VALUE Ascend-History-Weigh-Type History-Quadratic 2
|
||||
VALUE Ascend-Callback Callback-No 0
|
||||
VALUE Ascend-Callback Callback-Yes 1
|
||||
VALUE Ascend-Expect-Callback Expect-Callback-No 0
|
||||
VALUE Ascend-Expect-Callback Expect-Callback-Yes 1
|
||||
VALUE Ascend-Data-Svc Switched-Voice-Bearer 0
|
||||
VALUE Ascend-Data-Svc Switched-56KR 1
|
||||
VALUE Ascend-Data-Svc Switched-64K 2
|
||||
VALUE Ascend-Data-Svc Switched-64KR 3
|
||||
VALUE Ascend-Data-Svc Switched-56K 4
|
||||
VALUE Ascend-Data-Svc Switched-384KR 5
|
||||
VALUE Ascend-Data-Svc Switched-384K 6
|
||||
VALUE Ascend-Data-Svc Switched-1536K 7
|
||||
VALUE Ascend-Data-Svc Switched-1536KR 8
|
||||
VALUE Ascend-Data-Svc Switched-128K 9
|
||||
VALUE Ascend-Data-Svc Switched-192K 10
|
||||
VALUE Ascend-Data-Svc Switched-256K 11
|
||||
VALUE Ascend-Data-Svc Switched-320K 12
|
||||
VALUE Ascend-Data-Svc Switched-384K-MR 13
|
||||
VALUE Ascend-Data-Svc Switched-448K 14
|
||||
VALUE Ascend-Data-Svc Switched-512K 15
|
||||
VALUE Ascend-Data-Svc Switched-576K 16
|
||||
VALUE Ascend-Data-Svc Switched-640K 17
|
||||
VALUE Ascend-Data-Svc Switched-704K 18
|
||||
VALUE Ascend-Data-Svc Switched-768K 19
|
||||
VALUE Ascend-Data-Svc Switched-832K 20
|
||||
VALUE Ascend-Data-Svc Switched-896K 21
|
||||
VALUE Ascend-Data-Svc Switched-960K 22
|
||||
VALUE Ascend-Data-Svc Switched-1024K 23
|
||||
VALUE Ascend-Data-Svc Switched-1088K 24
|
||||
VALUE Ascend-Data-Svc Switched-1152K 25
|
||||
VALUE Ascend-Data-Svc Switched-1216K 26
|
||||
VALUE Ascend-Data-Svc Switched-1280K 27
|
||||
VALUE Ascend-Data-Svc Switched-1344K 28
|
||||
VALUE Ascend-Data-Svc Switched-1408K 29
|
||||
VALUE Ascend-Data-Svc Switched-1472K 30
|
||||
VALUE Ascend-Data-Svc Switched-1600K 31
|
||||
VALUE Ascend-Data-Svc Switched-1664K 32
|
||||
VALUE Ascend-Data-Svc Switched-1728K 33
|
||||
VALUE Ascend-Data-Svc Switched-1792K 34
|
||||
VALUE Ascend-Data-Svc Switched-1856K 35
|
||||
VALUE Ascend-Data-Svc Switched-1920K 36
|
||||
VALUE Ascend-Data-Svc Switched-inherited 37
|
||||
VALUE Ascend-Data-Svc Switched-restricted-bearer-x30 38
|
||||
VALUE Ascend-Data-Svc Switched-clear-bearer-v110 39
|
||||
VALUE Ascend-Data-Svc Switched-restricted-64-x30 40
|
||||
VALUE Ascend-Data-Svc Switched-clear-56-v110 41
|
||||
VALUE Ascend-Data-Svc Switched-modem 42
|
||||
VALUE Ascend-Data-Svc Switched-atmodem 43
|
||||
VALUE Ascend-Data-Svc Nailed-56KR 1
|
||||
VALUE Ascend-Data-Svc Nailed-64K 2
|
||||
VALUE Ascend-Force-56 Force-56-No 0
|
||||
VALUE Ascend-Force-56 Force-56-Yes 1
|
||||
VALUE Ascend-PW-Lifetime Lifetime-In-Days 0
|
||||
VALUE Ascend-PW-Warntime Days-Of-Warning 0
|
||||
VALUE Ascend-PPP-VJ-1172 PPP-VJ-1172 1
|
||||
VALUE Ascend-PPP-VJ-Slot-Comp VJ-Slot-Comp-No 1
|
||||
VALUE Ascend-Require-Auth Not-Require-Auth 0
|
||||
VALUE Ascend-Require-Auth Require-Auth 1
|
||||
VALUE Ascend-Token-Immediate Tok-Imm-No 0
|
||||
VALUE Ascend-Token-Immediate Tok-Imm-Yes 1
|
||||
VALUE Ascend-DBA-Monitor DBA-Transmit 0
|
||||
VALUE Ascend-DBA-Monitor DBA-Transmit-Recv 1
|
||||
VALUE Ascend-DBA-Monitor DBA-None 2
|
||||
VALUE Ascend-FR-Type Ascend-FR-DTE 0
|
||||
VALUE Ascend-FR-Type Ascend-FR-DCE 1
|
||||
VALUE Ascend-FR-Type Ascend-FR-NNI 2
|
||||
VALUE Ascend-FR-Link-Mgt Ascend-FR-No-Link-Mgt 0
|
||||
VALUE Ascend-FR-Link-Mgt Ascend-FR-T1-617D 1
|
||||
VALUE Ascend-FR-Link-Mgt Ascend-FR-Q-933A 2
|
||||
VALUE Ascend-FR-LinkUp Ascend-LinkUp-Default 0
|
||||
VALUE Ascend-FR-LinkUp Ascend-LinkUp-AlwaysUp 1
|
||||
VALUE Ascend-Multicast-Client Multicast-No 0
|
||||
VALUE Ascend-Multicast-Client Multicast-Yes 1
|
||||
VALUE Ascend-User-Acct-Type Ascend-User-Acct-None 0
|
||||
VALUE Ascend-User-Acct-Type Ascend-User-Acct-User 1
|
||||
VALUE Ascend-User-Acct-Type Ascend-User-Acct-User-Default 2
|
||||
VALUE Ascend-User-Acct-Base Base-10 0
|
||||
VALUE Ascend-User-Acct-Base Base-16 1
|
||||
VALUE Ascend-DHCP-Reply DHCP-Reply-No 0
|
||||
VALUE Ascend-DHCP-Reply DHCP-Reply-Yes 1
|
||||
VALUE Ascend-Client-Assign-DNS DNS-Assign-No 0
|
||||
VALUE Ascend-Client-Assign-DNS DNS-Assign-Yes 1
|
||||
VALUE Ascend-Event-Type Ascend-ColdStart 1
|
||||
VALUE Ascend-Event-Type Ascend-Session-Event 2
|
||||
VALUE Ascend-BACP-Enable BACP-No 0
|
||||
VALUE Ascend-BACP-Enable BACP-Yes 1
|
||||
VALUE Ascend-Dialout-Allowed Dialout-Not-Allowed 0
|
||||
VALUE Ascend-Dialout-Allowed Dialout-Allowed 1
|
||||
VALUE Ascend-Shared-Profile-Enable Shared-Profile-No 0
|
||||
VALUE Ascend-Shared-Profile-Enable Shared-Profile-Yes 1
|
||||
VALUE Ascend-Temporary-Rtes Temp-Rtes-No 0
|
||||
VALUE Ascend-Temporary-Rtes Temp-Rtes-Yes 1
|
||||
45
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/etc/dictionary.compat
vendored
Normal file
45
vendor/aw/homlet/external/pppoe/pppd/plugins/radius/etc/dictionary.compat
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# Obsolete names for backwards compatibility with older users files.
|
||||
#
|
||||
ATTRIBUTE Client-Id 4 ipaddr
|
||||
ATTRIBUTE Client-Port-Id 5 integer
|
||||
ATTRIBUTE User-Service-Type 6 integer
|
||||
ATTRIBUTE Framed-Address 8 ipaddr
|
||||
ATTRIBUTE Framed-Netmask 9 ipaddr
|
||||
ATTRIBUTE Framed-Filter-Id 11 string
|
||||
ATTRIBUTE Login-Host 14 ipaddr
|
||||
ATTRIBUTE Login-Port 16 integer
|
||||
ATTRIBUTE Old-Password 17 string
|
||||
ATTRIBUTE Port-Message 18 string
|
||||
ATTRIBUTE Dialback-No 19 string
|
||||
ATTRIBUTE Dialback-Name 20 string
|
||||
ATTRIBUTE Challenge-State 24 string
|
||||
VALUE Framed-Compression Van-Jacobsen-TCP-IP 1
|
||||
VALUE Framed-Compression VJ-TCP-IP 1
|
||||
VALUE Service-Type Shell-User 6
|
||||
VALUE Auth-Type Unix 1
|
||||
VALUE Service-Type Dialback-Login-User 3
|
||||
VALUE Service-Type Dialback-Framed-User 4
|
||||
|
||||
#
|
||||
# For compatibility with MERIT users files.
|
||||
#
|
||||
ATTRIBUTE NAS-Port 5 integer
|
||||
ATTRIBUTE Login-Host 14 ipaddr
|
||||
ATTRIBUTE Login-Callback-Number 19 string
|
||||
ATTRIBUTE Framed-Callback-Id 20 string
|
||||
ATTRIBUTE Client-Port-DNIS 30 string
|
||||
ATTRIBUTE Caller-ID 31 string
|
||||
VALUE Service-Type Login 1
|
||||
VALUE Service-Type Framed 2
|
||||
VALUE Service-Type Callback-Login 3
|
||||
VALUE Service-Type Callback-Framed 4
|
||||
VALUE Service-Type Exec-User 7
|
||||
|
||||
#
|
||||
# For compatibility with ESVA RADIUS, Old Cistron RADIUS
|
||||
#
|
||||
ATTRIBUTE Session 1034 integer
|
||||
ATTRIBUTE User-Name-Is-Star 1035 integer
|
||||
VALUE User-Name-Is-Star No 0
|
||||
VALUE User-Name-Is-Star Yes 1
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user