From 3c05a4e7193ee553bf502560e7de4be6489c7629 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 8 Mar 2021 18:19:04 +0800 Subject: [PATCH] [compoenets] auto & manual formatted --- components/cplusplus/Lock.h | 2 +- components/cplusplus/Mail.h | 2 +- components/cplusplus/Mutex.h | 2 +- components/cplusplus/Queue.h | 2 +- components/cplusplus/Semaphore.h | 2 +- components/cplusplus/Thread.h | 2 +- components/cplusplus/crt.h | 2 +- components/cplusplus/crt_init.c | 16 +- components/cplusplus/cxx_Mutex.cpp | 3 +- components/cplusplus/cxx_Semaphore.cpp | 3 +- components/cplusplus/cxx_Thread.cpp | 3 +- components/cplusplus/cxx_crt.cpp | 10 +- components/dfs/filesystems/devfs/devfs.c | 4 +- components/dfs/filesystems/devfs/devfs.h | 2 +- components/dfs/filesystems/elmfat/dfs_elm.c | 2 +- components/dfs/filesystems/elmfat/dfs_elm.h | 2 +- components/dfs/filesystems/elmfat/diskio.h | 58 +- components/dfs/filesystems/jffs2/dfs_jffs2.c | 2 +- components/dfs/filesystems/jffs2/dfs_jffs2.h | 4 +- components/dfs/filesystems/nfs/dfs_nfs.c | 2 +- components/dfs/filesystems/nfs/dfs_nfs.h | 2 +- components/dfs/filesystems/nfs/mount.h | 84 +- components/dfs/filesystems/nfs/mount_clnt.c | 62 +- components/dfs/filesystems/nfs/mount_xdr.c | 126 +- components/dfs/filesystems/nfs/nfs.h | 866 ++-- components/dfs/filesystems/nfs/nfs_auth.c | 2 +- components/dfs/filesystems/nfs/nfs_clnt.c | 222 +- components/dfs/filesystems/nfs/nfs_xdr.c | 1900 ++++---- components/dfs/filesystems/nfs/rpc/auth.h | 102 +- .../dfs/filesystems/nfs/rpc/auth_none.c | 98 +- components/dfs/filesystems/nfs/rpc/clnt.h | 240 +- .../dfs/filesystems/nfs/rpc/clnt_generic.c | 2 +- components/dfs/filesystems/nfs/rpc/clnt_udp.c | 544 +-- components/dfs/filesystems/nfs/rpc/pmap.c | 70 +- components/dfs/filesystems/nfs/rpc/pmap.h | 58 +- components/dfs/filesystems/nfs/rpc/rpc.h | 12 +- components/dfs/filesystems/nfs/rpc/rpc_msg.h | 152 +- components/dfs/filesystems/nfs/rpc/rpc_prot.c | 264 +- components/dfs/filesystems/nfs/rpc/types.h | 2 +- components/dfs/filesystems/nfs/rpc/xdr.c | 830 ++-- components/dfs/filesystems/nfs/rpc/xdr.h | 174 +- components/dfs/filesystems/nfs/rpc/xdr_mem.c | 68 +- components/dfs/filesystems/ramfs/dfs_ramfs.c | 2 +- components/dfs/filesystems/ramfs/dfs_ramfs.h | 2 +- components/dfs/filesystems/romfs/dfs_romfs.c | 2 +- components/dfs/filesystems/romfs/dfs_romfs.h | 2 +- components/dfs/filesystems/romfs/romfs.c | 2 +- .../dfs/filesystems/skeleton/skeleton.c | 2 +- .../dfs/filesystems/skeleton/skeleton.h | 2 +- components/dfs/filesystems/uffs/dfs_uffs.c | 2 +- components/dfs/filesystems/uffs/dfs_uffs.h | 2 +- .../dfs/filesystems/uffs/uffs_rtthread.c | 100 +- components/dfs/include/dfs.h | 2 +- components/dfs/include/dfs_file.h | 2 +- components/dfs/include/dfs_fs.h | 2 +- components/dfs/include/dfs_poll.h | 2 +- components/dfs/include/dfs_posix.h | 2 +- components/dfs/include/dfs_private.h | 2 +- components/dfs/include/dfs_select.h | 2 +- components/dfs/src/dfs.c | 2 +- components/dfs/src/dfs_file.c | 2 +- components/dfs/src/dfs_fs.c | 12 +- components/dfs/src/dfs_posix.c | 2 +- components/dfs/src/poll.c | 6 +- components/dfs/src/select.c | 4 +- components/drivers/audio/audio.c | 2 +- components/drivers/audio/audio_pipe.c | 2 +- components/drivers/audio/audio_pipe.h | 2 +- components/drivers/can/can.c | 2 +- components/drivers/cputime/cputime.c | 10 +- components/drivers/cputime/cputime_cortexm.c | 12 +- components/drivers/hwcrypto/hw_bignum.c | 36 +- components/drivers/hwcrypto/hw_bignum.h | 34 +- components/drivers/hwcrypto/hw_crc.c | 10 +- components/drivers/hwcrypto/hw_crc.h | 6 +- components/drivers/hwcrypto/hw_gcm.c | 2 +- components/drivers/hwcrypto/hw_gcm.h | 2 +- components/drivers/hwcrypto/hw_hash.c | 2 +- components/drivers/hwcrypto/hw_hash.h | 2 +- components/drivers/hwcrypto/hw_rng.c | 4 +- components/drivers/hwcrypto/hw_rng.h | 4 +- components/drivers/hwcrypto/hw_symmetric.c | 4 +- components/drivers/hwcrypto/hw_symmetric.h | 2 +- components/drivers/hwcrypto/hwcrypto.c | 2 +- components/drivers/hwcrypto/hwcrypto.h | 2 +- components/drivers/hwtimer/hwtimer.c | 4 +- components/drivers/i2c/i2c-bit-ops.c | 2 +- components/drivers/i2c/i2c_core.c | 2 +- components/drivers/i2c/i2c_dev.c | 6 +- components/drivers/include/drivers/adc.h | 2 +- components/drivers/include/drivers/alarm.h | 2 +- components/drivers/include/drivers/audio.h | 2 +- components/drivers/include/drivers/can.h | 2 +- components/drivers/include/drivers/cputime.h | 2 +- components/drivers/include/drivers/crypto.h | 2 +- components/drivers/include/drivers/dac.h | 2 +- components/drivers/include/drivers/hwtimer.h | 2 +- .../drivers/include/drivers/i2c-bit-ops.h | 2 +- components/drivers/include/drivers/i2c.h | 2 +- components/drivers/include/drivers/i2c_dev.h | 2 +- components/drivers/include/drivers/mmc.h | 258 +- .../drivers/include/drivers/mmcsd_card.h | 194 +- .../drivers/include/drivers/mmcsd_cmd.h | 12 +- .../drivers/include/drivers/mmcsd_core.h | 282 +- .../drivers/include/drivers/mmcsd_host.h | 156 +- components/drivers/include/drivers/mtd_nand.h | 2 +- components/drivers/include/drivers/mtd_nor.h | 44 +- components/drivers/include/drivers/phy.h | 2 +- components/drivers/include/drivers/phy_mdio.h | 2 +- components/drivers/include/drivers/pin.h | 2 +- components/drivers/include/drivers/pm.h | 2 +- .../drivers/include/drivers/pulse_encoder.h | 2 +- .../drivers/include/drivers/rt_drv_pwm.h | 2 +- .../drivers/include/drivers/rt_inputcapture.h | 2 +- components/drivers/include/drivers/rtc.h | 2 +- components/drivers/include/drivers/sd.h | 2 +- components/drivers/include/drivers/sdio.h | 14 +- .../drivers/include/drivers/sdio_func_ids.h | 4 +- components/drivers/include/drivers/serial.h | 6 +- components/drivers/include/drivers/spi.h | 4 +- .../drivers/include/drivers/usb_common.h | 18 +- .../drivers/include/drivers/usb_device.h | 16 +- components/drivers/include/drivers/usb_host.h | 38 +- components/drivers/include/drivers/watchdog.h | 2 +- components/drivers/include/drivers/wlan.h | 2 +- components/drivers/include/ipc/completion.h | 2 +- components/drivers/include/ipc/dataqueue.h | 2 +- components/drivers/include/ipc/pipe.h | 2 +- components/drivers/include/ipc/poll.h | 2 +- components/drivers/include/ipc/ringblk_buf.h | 2 +- components/drivers/include/ipc/ringbuffer.h | 2 +- components/drivers/include/ipc/waitqueue.h | 4 +- components/drivers/include/ipc/workqueue.h | 2 +- components/drivers/include/rtdevice.h | 2 +- components/drivers/misc/adc.c | 2 +- components/drivers/misc/dac.c | 4 +- components/drivers/misc/pin.c | 4 +- components/drivers/misc/pulse_encoder.c | 2 +- components/drivers/misc/rt_drv_pwm.c | 2 +- components/drivers/misc/rt_inputcapture.c | 2 +- components/drivers/mtd/mtd_nand.c | 2 +- components/drivers/mtd/mtd_nor.c | 6 +- components/drivers/phy/phy.c | 6 +- components/drivers/pm/pm.c | 4 +- components/drivers/rtc/alarm.c | 2 +- components/drivers/rtc/rtc.c | 4 +- components/drivers/rtc/soft_rtc.c | 4 +- components/drivers/sdio/block_dev.c | 72 +- components/drivers/sdio/mmc.c | 134 +- components/drivers/sdio/mmcsd_core.c | 92 +- components/drivers/sdio/sd.c | 60 +- components/drivers/sdio/sdio.c | 124 +- components/drivers/sensors/sensor.c | 2 +- components/drivers/sensors/sensor.h | 4 +- components/drivers/sensors/sensor_cmd.c | 6 +- components/drivers/serial/serial.c | 20 +- components/drivers/spi/enc28j60.c | 4 +- components/drivers/spi/enc28j60.h | 2 +- components/drivers/spi/qspi_core.c | 10 +- components/drivers/spi/sfud/inc/sfud_def.h | 4 +- components/drivers/spi/sfud/src/sfud_sfdp.c | 2 +- components/drivers/spi/spi_core.c | 2 +- components/drivers/spi/spi_dev.c | 10 +- components/drivers/spi/spi_flash.h | 10 +- components/drivers/spi/spi_flash_sfud.c | 2 +- components/drivers/spi/spi_flash_sfud.h | 2 +- components/drivers/spi/spi_msd.c | 6 +- components/drivers/spi/spi_msd.h | 14 +- components/drivers/spi/spi_wifi_rw009.c | 4 +- components/drivers/spi/spi_wifi_rw009.h | 4 +- components/drivers/src/completion.c | 2 +- components/drivers/src/dataqueue.c | 28 +- components/drivers/src/pipe.c | 10 +- components/drivers/src/ringblk_buf.c | 2 +- components/drivers/src/ringbuffer.c | 12 +- components/drivers/src/waitqueue.c | 4 +- components/drivers/src/workqueue.c | 2 +- components/drivers/touch/touch.c | 2 +- components/drivers/touch/touch.h | 2 +- .../drivers/usb/usbdevice/class/audio_mic.c | 2 +- .../usb/usbdevice/class/audio_speaker.c | 2 +- components/drivers/usb/usbdevice/class/cdc.h | 16 +- .../drivers/usb/usbdevice/class/cdc_vcom.c | 74 +- components/drivers/usb/usbdevice/class/ecm.c | 26 +- components/drivers/usb/usbdevice/class/hid.c | 20 +- components/drivers/usb/usbdevice/class/hid.h | 2 +- .../drivers/usb/usbdevice/class/mstorage.c | 248 +- .../drivers/usb/usbdevice/class/mstorage.h | 6 +- components/drivers/usb/usbdevice/class/ndis.h | 88 +- .../drivers/usb/usbdevice/class/rndis.c | 20 +- .../drivers/usb/usbdevice/class/rndis.h | 196 +- .../drivers/usb/usbdevice/class/winusb.c | 16 +- .../drivers/usb/usbdevice/class/winusb.h | 2 +- .../drivers/usb/usbdevice/core/usbdevice.c | 6 +- .../usb/usbdevice/core/usbdevice_core.c | 150 +- components/drivers/usb/usbhost/class/adk.c | 2 +- components/drivers/usb/usbhost/class/adk.h | 4 +- components/drivers/usb/usbhost/class/hid.c | 116 +- components/drivers/usb/usbhost/class/hid.h | 8 +- components/drivers/usb/usbhost/class/mass.c | 178 +- components/drivers/usb/usbhost/class/mass.h | 10 +- components/drivers/usb/usbhost/class/udisk.c | 2 +- components/drivers/usb/usbhost/class/ukbd.c | 20 +- components/drivers/usb/usbhost/class/umouse.c | 2 +- components/drivers/usb/usbhost/core/driver.c | 22 +- components/drivers/usb/usbhost/core/hub.c | 186 +- components/drivers/usb/usbhost/core/usbhost.c | 6 +- .../drivers/usb/usbhost/core/usbhost_core.c | 126 +- components/drivers/watchdog/watchdog.c | 6 +- components/drivers/wlan/wlan_cfg.c | 2 +- components/drivers/wlan/wlan_cfg.h | 2 +- components/drivers/wlan/wlan_cmd.c | 2 +- components/drivers/wlan/wlan_dev.c | 2 +- components/drivers/wlan/wlan_dev.h | 4 +- components/drivers/wlan/wlan_lwip.c | 2 +- components/drivers/wlan/wlan_mgnt.c | 2 +- components/drivers/wlan/wlan_mgnt.h | 2 +- components/drivers/wlan/wlan_prot.c | 2 +- components/drivers/wlan/wlan_prot.h | 2 +- components/drivers/wlan/wlan_workqueue.c | 2 +- components/drivers/wlan/wlan_workqueue.h | 2 +- components/finsh/cmd.c | 8 +- components/finsh/finsh.h | 2 +- components/finsh/finsh_api.h | 2 +- components/finsh/finsh_compiler.c | 2 +- components/finsh/finsh_error.c | 2 +- components/finsh/finsh_error.h | 2 +- components/finsh/finsh_heap.c | 2 +- components/finsh/finsh_heap.h | 2 +- components/finsh/finsh_init.c | 2 +- components/finsh/finsh_node.c | 2 +- components/finsh/finsh_node.h | 2 +- components/finsh/finsh_ops.c | 2 +- components/finsh/finsh_ops.h | 100 +- components/finsh/finsh_parser.c | 2 +- components/finsh/finsh_parser.h | 2 +- components/finsh/finsh_token.c | 2 +- components/finsh/finsh_token.h | 2 +- components/finsh/finsh_var.c | 2 +- components/finsh/finsh_var.h | 2 +- components/finsh/finsh_vm.c | 2 +- components/finsh/finsh_vm.h | 2 +- components/finsh/msh.c | 2 +- components/finsh/msh.h | 2 +- components/finsh/msh_file.c | 2 +- components/finsh/shell.c | 4 +- components/finsh/shell.h | 2 +- components/finsh/symbol.c | 4 +- components/libc/aio/posix_aio.c | 378 +- components/libc/aio/posix_aio.h | 2 +- components/libc/compilers/armlibc/dirent.h | 28 +- components/libc/compilers/armlibc/fcntl.h | 2 +- components/libc/compilers/armlibc/libc.c | 2 +- components/libc/compilers/armlibc/libc.h | 2 +- components/libc/compilers/armlibc/libc_syms.c | 2 +- components/libc/compilers/armlibc/mem_std.c | 2 +- components/libc/compilers/armlibc/stdio.c | 2 +- components/libc/compilers/armlibc/sys/errno.h | 2 +- components/libc/compilers/armlibc/sys/ioctl.h | 2 +- components/libc/compilers/armlibc/sys/mman.h | 2 +- components/libc/compilers/armlibc/sys/stat.h | 2 +- components/libc/compilers/armlibc/sys/types.h | 2 +- .../libc/compilers/armlibc/sys/unistd.h | 2 +- components/libc/compilers/armlibc/syscalls.c | 8 +- components/libc/compilers/armlibc/unistd.h | 2 +- components/libc/compilers/common/stdlib.c | 2 +- components/libc/compilers/common/sys/time.h | 2 +- components/libc/compilers/common/termios.h | 2 +- components/libc/compilers/common/time.c | 6 +- components/libc/compilers/common/unistd.c | 2 +- components/libc/compilers/dlib/dirent.h | 2 +- components/libc/compilers/dlib/environ.c | 2 +- components/libc/compilers/dlib/fcntl.h | 2 +- components/libc/compilers/dlib/libc.c | 2 +- components/libc/compilers/dlib/libc.h | 2 +- components/libc/compilers/dlib/rmtx.c | 4 +- components/libc/compilers/dlib/stdio.c | 2 +- components/libc/compilers/dlib/sys/errno.h | 2 +- components/libc/compilers/dlib/sys/mman.h | 2 +- components/libc/compilers/dlib/sys/signal.h | 2 +- components/libc/compilers/dlib/sys/stat.h | 2 +- components/libc/compilers/dlib/sys/types.h | 2 +- components/libc/compilers/dlib/sys/unistd.h | 34 +- .../libc/compilers/dlib/syscall_close.c | 2 +- .../libc/compilers/dlib/syscall_lseek.c | 2 +- components/libc/compilers/dlib/syscall_mem.c | 2 +- components/libc/compilers/dlib/syscall_open.c | 2 +- components/libc/compilers/dlib/syscall_read.c | 2 +- .../libc/compilers/dlib/syscall_remove.c | 2 +- .../libc/compilers/dlib/syscall_write.c | 2 +- components/libc/compilers/dlib/syscalls.c | 2 +- components/libc/compilers/dlib/unistd.h | 2 +- components/libc/compilers/newlib/libc.c | 4 +- components/libc/compilers/newlib/libc.h | 2 +- components/libc/compilers/newlib/libc_syms.c | 2 +- .../libc/compilers/newlib/machine/time.h | 2 +- components/libc/compilers/newlib/minilib.c | 2 +- components/libc/compilers/newlib/stdio.c | 6 +- components/libc/compilers/newlib/sys/dirent.h | 34 +- components/libc/compilers/newlib/sys/mman.h | 2 +- components/libc/compilers/newlib/sys/statfs.h | 8 +- .../libc/compilers/newlib/sys/termios.h | 2 +- components/libc/compilers/newlib/syscalls.c | 2 +- components/libc/getline/posix_getline.c | 4 +- components/libc/getline/posix_getline.h | 2 +- components/libc/libdl/arch/arm.c | 4 +- components/libc/libdl/arch/x86.c | 10 +- components/libc/libdl/dlclose.c | 2 +- components/libc/libdl/dlelf.c | 10 +- components/libc/libdl/dlelf.h | 4 +- components/libc/libdl/dlerror.c | 6 +- components/libc/libdl/dlfcn.h | 4 +- components/libc/libdl/dlmodule.c | 8 +- components/libc/libdl/dlmodule.h | 2 +- components/libc/libdl/dlopen.c | 6 +- components/libc/libdl/dlsym.c | 4 +- components/libc/mmap/posix_mmap.c | 2 +- components/libc/pthreads/mqueue.c | 2 +- components/libc/pthreads/mqueue.h | 2 +- components/libc/pthreads/posix_types.h | 4 +- components/libc/pthreads/pthread.c | 4 +- components/libc/pthreads/pthread.h | 4 +- components/libc/pthreads/pthread_attr.c | 4 +- components/libc/pthreads/pthread_barrier.c | 2 +- components/libc/pthreads/pthread_cond.c | 10 +- components/libc/pthreads/pthread_internal.h | 2 +- components/libc/pthreads/pthread_mutex.c | 4 +- components/libc/pthreads/pthread_rwlock.c | 10 +- components/libc/pthreads/pthread_spin.c | 2 +- components/libc/pthreads/pthread_tls.c | 2 +- components/libc/pthreads/sched.c | 2 +- components/libc/pthreads/sched.h | 2 +- components/libc/pthreads/semaphore.c | 2 +- components/libc/pthreads/semaphore.h | 2 +- components/libc/signal/posix_signal.c | 2 +- components/libc/signal/posix_signal.h | 2 +- components/libc/termios/posix_termios.c | 2 +- components/libc/termios/posix_termios.h | 2 +- components/lwp/lwp.c | 2 +- components/lwp/lwp.h | 2 +- components/lwp/lwp_mem.c | 6 +- components/lwp/lwp_mem.h | 2 +- components/lwp/lwp_memheap.c | 2 +- components/lwp/lwp_memheap.h | 2 +- components/lwp/lwp_syscall.c | 2 +- components/lwp/lwp_syscall.h | 12 +- components/net/at/at_socket/at_socket.c | 40 +- components/net/at/at_socket/at_socket.h | 2 +- components/net/at/include/at.h | 2 +- components/net/at/include/at_log.h | 2 +- components/net/at/src/at_base_cmd.c | 2 +- components/net/at/src/at_cli.c | 4 +- components/net/at/src/at_client.c | 4 +- components/net/at/src/at_server.c | 2 +- components/net/at/src/at_utils.c | 2 +- components/net/lwip-1.4.1/src/api/api_lib.c | 30 +- components/net/lwip-1.4.1/src/api/api_msg.c | 34 +- components/net/lwip-1.4.1/src/api/err.c | 28 +- components/net/lwip-1.4.1/src/api/netbuf.c | 32 +- components/net/lwip-1.4.1/src/api/netdb.c | 26 +- components/net/lwip-1.4.1/src/api/netifapi.c | 24 +- components/net/lwip-1.4.1/src/api/sockets.c | 32 +- components/net/lwip-1.4.1/src/api/tcpip.c | 8 +- .../net/lwip-1.4.1/src/arch/include/arch/cc.h | 16 +- .../lwip-1.4.1/src/arch/include/arch/perf.h | 52 +- .../src/arch/include/arch/sys_arch.h | 48 +- components/net/lwip-1.4.1/src/arch/sys_arch.c | 6 +- components/net/lwip-1.4.1/src/core/def.c | 2 +- components/net/lwip-1.4.1/src/core/dhcp.c | 14 +- components/net/lwip-1.4.1/src/core/dns.c | 14 +- components/net/lwip-1.4.1/src/core/init.c | 30 +- .../net/lwip-1.4.1/src/core/ipv4/autoip.c | 14 +- .../net/lwip-1.4.1/src/core/ipv4/icmp.c | 4 +- .../net/lwip-1.4.1/src/core/ipv4/igmp.c | 68 +- .../lwip-1.4.1/src/core/ipv4/inet_chksum.c | 14 +- components/net/lwip-1.4.1/src/core/ipv4/ip.c | 4 +- .../net/lwip-1.4.1/src/core/ipv4/ip_addr.c | 32 +- .../net/lwip-1.4.1/src/core/ipv4/ip_frag.c | 52 +- .../net/lwip-1.4.1/src/core/ipv6/inet6.c | 42 +- .../net/lwip-1.4.1/src/core/ipv6/ip6_addr.c | 30 +- components/net/lwip-1.4.1/src/core/mem.c | 2 +- components/net/lwip-1.4.1/src/core/memp.c | 48 +- components/net/lwip-1.4.1/src/core/netif.c | 20 +- components/net/lwip-1.4.1/src/core/pbuf.c | 22 +- components/net/lwip-1.4.1/src/core/raw.c | 10 +- components/net/lwip-1.4.1/src/core/stats.c | 100 +- components/net/lwip-1.4.1/src/core/tcp.c | 116 +- components/net/lwip-1.4.1/src/core/tcp_in.c | 54 +- components/net/lwip-1.4.1/src/core/tcp_out.c | 42 +- components/net/lwip-1.4.1/src/core/udp.c | 12 +- .../lwip-1.4.1/src/include/ipv4/lwip/autoip.h | 2 +- .../lwip-1.4.1/src/include/ipv4/lwip/icmp.h | 28 +- .../lwip-1.4.1/src/include/ipv4/lwip/igmp.h | 46 +- .../lwip-1.4.1/src/include/ipv4/lwip/inet.h | 28 +- .../src/include/ipv4/lwip/inet_chksum.h | 28 +- .../net/lwip-1.4.1/src/include/ipv4/lwip/ip.h | 30 +- .../src/include/ipv4/lwip/ip_frag.h | 28 +- .../lwip-1.4.1/src/include/ipv6/lwip/icmp.h | 28 +- .../lwip-1.4.1/src/include/ipv6/lwip/inet.h | 28 +- .../net/lwip-1.4.1/src/include/ipv6/lwip/ip.h | 30 +- .../src/include/ipv6/lwip/ip_addr.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/api.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/api_msg.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/arch.h | 30 +- .../net/lwip-1.4.1/src/include/lwip/debug.h | 32 +- .../net/lwip-1.4.1/src/include/lwip/def.h | 30 +- .../net/lwip-1.4.1/src/include/lwip/dhcp.h | 18 +- .../net/lwip-1.4.1/src/include/lwip/dns.h | 2 +- .../net/lwip-1.4.1/src/include/lwip/err.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/init.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/mem.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/memp.h | 28 +- .../lwip-1.4.1/src/include/lwip/memp_std.h | 2 +- .../net/lwip-1.4.1/src/include/lwip/netbuf.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/netdb.h | 24 +- .../net/lwip-1.4.1/src/include/lwip/netif.h | 30 +- .../lwip-1.4.1/src/include/lwip/netifapi.h | 26 +- .../net/lwip-1.4.1/src/include/lwip/opt.h | 56 +- .../net/lwip-1.4.1/src/include/lwip/pbuf.h | 32 +- .../net/lwip-1.4.1/src/include/lwip/sio.h | 48 +- .../net/lwip-1.4.1/src/include/lwip/snmp.h | 54 +- .../lwip-1.4.1/src/include/lwip/snmp_asn1.h | 2 +- .../src/include/lwip/snmp_structs.h | 8 +- .../net/lwip-1.4.1/src/include/lwip/sockets.h | 30 +- .../net/lwip-1.4.1/src/include/lwip/stats.h | 30 +- .../net/lwip-1.4.1/src/include/lwip/sys.h | 32 +- .../net/lwip-1.4.1/src/include/lwip/tcp.h | 38 +- .../lwip-1.4.1/src/include/lwip/tcp_impl.h | 34 +- .../net/lwip-1.4.1/src/include/lwip/tcpip.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/timers.h | 28 +- .../net/lwip-1.4.1/src/include/lwip/udp.h | 30 +- .../net/lwip-1.4.1/src/include/netif/etharp.h | 28 +- .../lwip-1.4.1/src/include/netif/ethernetif.h | 10 +- .../net/lwip-1.4.1/src/include/netif/ppp_oe.h | 4 +- .../net/lwip-1.4.1/src/include/netif/slipif.h | 52 +- .../net/lwip-1.4.1/src/include/posix/netdb.h | 22 +- .../lwip-1.4.1/src/include/posix/sys/socket.h | 22 +- components/net/lwip-1.4.1/src/netif/etharp.c | 40 +- .../net/lwip-1.4.1/src/netif/ethernetif.c | 48 +- .../net/lwip-1.4.1/src/netif/ppp/auth.c | 22 +- .../net/lwip-1.4.1/src/netif/ppp/auth.h | 4 +- .../net/lwip-1.4.1/src/netif/ppp/chap.c | 64 +- .../net/lwip-1.4.1/src/netif/ppp/chap.h | 4 +- .../net/lwip-1.4.1/src/netif/ppp/chpms.c | 10 +- .../net/lwip-1.4.1/src/netif/ppp/chpms.h | 4 +- components/net/lwip-1.4.1/src/netif/ppp/fsm.c | 78 +- components/net/lwip-1.4.1/src/netif/ppp/fsm.h | 4 +- .../net/lwip-1.4.1/src/netif/ppp/ipcp.c | 14 +- .../net/lwip-1.4.1/src/netif/ppp/ipcp.h | 6 +- components/net/lwip-1.4.1/src/netif/ppp/lcp.c | 62 +- components/net/lwip-1.4.1/src/netif/ppp/lcp.h | 4 +- .../net/lwip-1.4.1/src/netif/ppp/magic.c | 4 +- .../net/lwip-1.4.1/src/netif/ppp/magic.h | 4 +- components/net/lwip-1.4.1/src/netif/ppp/md5.c | 2 +- components/net/lwip-1.4.1/src/netif/ppp/pap.c | 8 +- components/net/lwip-1.4.1/src/netif/ppp/pap.h | 4 +- components/net/lwip-1.4.1/src/netif/ppp/ppp.c | 54 +- components/net/lwip-1.4.1/src/netif/ppp/ppp.h | 12 +- .../net/lwip-1.4.1/src/netif/ppp/ppp_impl.h | 6 +- .../net/lwip-1.4.1/src/netif/ppp/ppp_oe.c | 10 +- .../net/lwip-1.4.1/src/netif/ppp/pppdebug.h | 4 +- .../net/lwip-1.4.1/src/netif/ppp/randm.c | 6 +- .../net/lwip-1.4.1/src/netif/ppp/randm.h | 4 +- components/net/lwip-1.4.1/src/netif/ppp/vj.c | 40 +- components/net/lwip-1.4.1/src/netif/ppp/vj.h | 2 +- components/net/lwip-1.4.1/src/netif/slipif.c | 52 +- .../net/lwip-1.4.1/test/unit/lwipopts.h | 28 +- .../net/lwip-1.4.1/test/unit/tcp/test_tcp.c | 2 +- .../net/lwip-2.0.2/doc/NO_SYS_SampleCode.c | 8 +- .../net/lwip-2.0.2/doc/doxygen/main_page.h | 21 +- components/net/lwip-2.0.2/src/api/api_lib.c | 14 +- components/net/lwip-2.0.2/src/api/api_msg.c | 4 +- components/net/lwip-2.0.2/src/api/netifapi.c | 12 +- components/net/lwip-2.0.2/src/api/sockets.c | 2 +- components/net/lwip-2.0.2/src/api/tcpip.c | 2 +- components/net/lwip-2.0.2/src/apps/httpd/fs.c | 28 +- .../net/lwip-2.0.2/src/apps/httpd/fsdata.h | 28 +- .../net/lwip-2.0.2/src/apps/httpd/httpd.c | 4 +- .../net/lwip-2.0.2/src/apps/lwiperf/lwiperf.c | 2 +- .../net/lwip-2.0.2/src/apps/mdns/mdns.c | 4 +- .../net/lwip-2.0.2/src/apps/mqtt/mqtt.c | 2 +- .../lwip-2.0.2/src/apps/netbiosns/netbiosns.c | 6 +- .../net/lwip-2.0.2/src/apps/snmp/snmp_core.c | 58 +- .../src/apps/snmp/snmp_mib2_system.c | 2 +- .../lwip-2.0.2/src/apps/snmp/snmp_mib2_udp.c | 22 +- .../net/lwip-2.0.2/src/apps/snmp/snmp_msg.c | 44 +- .../net/lwip-2.0.2/src/apps/snmp/snmp_msg.h | 2 +- .../lwip-2.0.2/src/apps/snmp/snmp_netconn.c | 10 +- .../net/lwip-2.0.2/src/apps/snmp/snmp_raw.c | 4 +- .../lwip-2.0.2/src/apps/snmp/snmp_scalar.c | 10 +- .../net/lwip-2.0.2/src/apps/snmp/snmp_table.c | 6 +- .../src/apps/snmp/snmp_threadsync.c | 8 +- .../net/lwip-2.0.2/src/apps/snmp/snmp_traps.c | 4 +- .../lwip-2.0.2/src/apps/snmp/snmpv3_dummy.c | 12 +- .../lwip-2.0.2/src/apps/snmp/snmpv3_mbedtls.c | 18 +- .../lwip-2.0.2/src/apps/tftp/tftp_server.c | 30 +- .../net/lwip-2.0.2/src/arch/include/arch/cc.h | 12 +- .../lwip-2.0.2/src/arch/include/arch/perf.h | 52 +- .../src/arch/include/arch/sys_arch.h | 48 +- components/net/lwip-2.0.2/src/arch/sys_arch.c | 2 +- components/net/lwip-2.0.2/src/core/def.c | 2 +- components/net/lwip-2.0.2/src/core/dns.c | 6 +- .../net/lwip-2.0.2/src/core/inet_chksum.c | 2 +- components/net/lwip-2.0.2/src/core/init.c | 2 +- components/net/lwip-2.0.2/src/core/ip.c | 8 +- .../net/lwip-2.0.2/src/core/ipv4/autoip.c | 8 +- .../net/lwip-2.0.2/src/core/ipv4/igmp.c | 10 +- components/net/lwip-2.0.2/src/core/ipv6/nd6.c | 10 +- components/net/lwip-2.0.2/src/core/netif.c | 14 +- components/net/lwip-2.0.2/src/core/pbuf.c | 12 +- components/net/lwip-2.0.2/src/core/raw.c | 2 +- components/net/lwip-2.0.2/src/core/tcp.c | 4 +- components/net/lwip-2.0.2/src/core/udp.c | 2 +- .../net/lwip-2.0.2/src/include/lwip/api.h | 16 +- .../net/lwip-2.0.2/src/include/lwip/apps/fs.h | 28 +- .../lwip-2.0.2/src/include/lwip/apps/httpd.h | 2 +- .../src/include/lwip/apps/httpd_opts.h | 2 +- .../lwip-2.0.2/src/include/lwip/apps/mqtt.h | 4 +- .../src/include/lwip/apps/mqtt_opts.h | 2 +- .../src/include/lwip/apps/snmp_core.h | 2 +- .../src/include/lwip/apps/tftp_opts.h | 2 +- .../src/include/lwip/apps/tftp_server.h | 4 +- .../net/lwip-2.0.2/src/include/lwip/arch.h | 4 +- .../net/lwip-2.0.2/src/include/lwip/igmp.h | 2 +- .../net/lwip-2.0.2/src/include/lwip/ip_addr.h | 2 +- .../net/lwip-2.0.2/src/include/lwip/mld6.h | 2 +- .../net/lwip-2.0.2/src/include/lwip/opt.h | 4 +- .../src/include/lwip/prot/ethernet.h | 2 +- .../lwip-2.0.2/src/include/lwip/prot/ip6.h | 2 +- .../lwip-2.0.2/src/include/netif/ethernetif.h | 10 +- .../lwip-2.0.2/src/include/netif/ppp/ccp.h | 82 +- .../src/include/netif/ppp/chap-new.h | 90 +- .../lwip-2.0.2/src/include/netif/ppp/eap.h | 172 +- .../lwip-2.0.2/src/include/netif/ppp/ecp.h | 4 +- .../lwip-2.0.2/src/include/netif/ppp/eui64.h | 60 +- .../lwip-2.0.2/src/include/netif/ppp/fsm.h | 142 +- .../lwip-2.0.2/src/include/netif/ppp/ipcp.h | 36 +- .../lwip-2.0.2/src/include/netif/ppp/ipv6cp.h | 10 +- .../lwip-2.0.2/src/include/netif/ppp/lcp.h | 92 +- .../lwip-2.0.2/src/include/netif/ppp/magic.h | 2 +- .../lwip-2.0.2/src/include/netif/ppp/mppe.h | 154 +- .../src/include/netif/ppp/polarssl/arc4.h | 4 +- .../src/include/netif/ppp/polarssl/des.h | 4 +- .../src/include/netif/ppp/polarssl/md4.h | 4 +- .../src/include/netif/ppp/polarssl/md5.h | 4 +- .../src/include/netif/ppp/polarssl/sha1.h | 4 +- .../lwip-2.0.2/src/include/netif/ppp/ppp.h | 8 +- .../src/include/netif/ppp/ppp_impl.h | 254 +- .../src/include/netif/ppp/pppcrypt.h | 2 +- .../src/include/netif/ppp/pppdebug.h | 4 +- .../lwip-2.0.2/src/include/netif/ppp/pppoe.h | 4 +- .../lwip-2.0.2/src/include/netif/ppp/upap.h | 52 +- .../net/lwip-2.0.2/src/netif/ethernet.c | 4 +- .../net/lwip-2.0.2/src/netif/ethernetif.c | 36 +- .../net/lwip-2.0.2/src/netif/ppp/auth.c | 1494 +++---- components/net/lwip-2.0.2/src/netif/ppp/ccp.c | 1610 +++---- .../net/lwip-2.0.2/src/netif/ppp/chap-md5.c | 116 +- .../net/lwip-2.0.2/src/netif/ppp/chap-new.c | 884 ++-- .../net/lwip-2.0.2/src/netif/ppp/chap_ms.c | 786 ++-- .../net/lwip-2.0.2/src/netif/ppp/demand.c | 298 +- components/net/lwip-2.0.2/src/netif/ppp/eap.c | 3820 ++++++++--------- components/net/lwip-2.0.2/src/netif/ppp/ecp.c | 12 +- .../net/lwip-2.0.2/src/netif/ppp/eui64.c | 4 +- components/net/lwip-2.0.2/src/netif/ppp/fsm.c | 610 +-- .../net/lwip-2.0.2/src/netif/ppp/ipcp.c | 2026 ++++----- .../net/lwip-2.0.2/src/netif/ppp/ipv6cp.c | 1026 ++--- components/net/lwip-2.0.2/src/netif/ppp/lcp.c | 2370 +++++----- .../net/lwip-2.0.2/src/netif/ppp/mppe.c | 588 +-- .../net/lwip-2.0.2/src/netif/ppp/multilink.c | 888 ++-- .../lwip-2.0.2/src/netif/ppp/polarssl/arc4.c | 4 +- .../lwip-2.0.2/src/netif/ppp/polarssl/des.c | 4 +- .../lwip-2.0.2/src/netif/ppp/polarssl/md4.c | 4 +- .../lwip-2.0.2/src/netif/ppp/polarssl/md5.c | 6 +- .../lwip-2.0.2/src/netif/ppp/polarssl/sha1.c | 4 +- components/net/lwip-2.0.2/src/netif/ppp/ppp.c | 2 +- .../net/lwip-2.0.2/src/netif/ppp/pppapi.c | 22 +- .../net/lwip-2.0.2/src/netif/ppp/pppcrypt.c | 26 +- .../net/lwip-2.0.2/src/netif/ppp/pppoe.c | 8 +- .../net/lwip-2.0.2/src/netif/ppp/pppol2tp.c | 18 +- .../net/lwip-2.0.2/src/netif/ppp/upap.c | 260 +- .../net/lwip-2.0.2/src/netif/ppp/utils.c | 890 ++-- components/net/lwip-2.0.2/test/fuzz/fuzz.c | 28 +- .../net/lwip-2.0.2/test/fuzz/lwipopts.h | 28 +- .../net/lwip-2.0.2/test/unit/dhcp/test_dhcp.c | 2 +- .../net/lwip-2.0.2/test/unit/lwipopts.h | 28 +- .../net/lwip-2.0.2/test/unit/tcp/tcp_helper.c | 4 +- .../net/lwip-2.0.2/test/unit/tcp/test_tcp.c | 2 +- components/net/lwip-2.1.2/src/api/tcpip.c | 2 +- .../src/apps/altcp_tls/altcp_tls_mbedtls.c | 2 +- .../lwip-2.1.2/src/apps/http/http_client.c | 8 +- .../net/lwip-2.1.2/src/apps/http/httpd.c | 2 +- .../src/apps/http/makefsdata/tinydir.h | 824 ++-- .../net/lwip-2.1.2/src/apps/smtp/smtp.c | 12 +- .../net/lwip-2.1.2/src/arch/include/arch/cc.h | 16 +- .../lwip-2.1.2/src/arch/include/arch/perf.h | 52 +- components/net/lwip-2.1.2/src/arch/sys_arch.c | 2 +- components/net/lwip-2.1.2/src/core/altcp.c | 6 +- .../net/lwip-2.1.2/src/core/ipv4/dhcp.c | 2 +- components/net/lwip-2.1.2/src/core/ipv6/ip6.c | 2 +- .../net/lwip-2.1.2/src/core/ipv6/mld6.c | 2 +- components/net/lwip-2.1.2/src/core/ipv6/nd6.c | 6 +- components/net/lwip-2.1.2/src/core/sys.c | 12 +- components/net/lwip-2.1.2/src/core/tcp.c | 26 +- components/net/lwip-2.1.2/src/core/tcp_out.c | 2 +- components/net/lwip-2.1.2/src/core/timeouts.c | 4 +- components/net/lwip-2.1.2/src/core/udp.c | 8 +- .../src/include/compat/posix/net/if.h | 22 +- .../net/lwip-2.1.2/src/include/lwip/api.h | 16 +- .../net/lwip-2.1.2/src/include/lwip/apps/fs.h | 28 +- .../src/include/lwip/apps/http_client.h | 10 +- .../src/include/lwip/apps/httpd_opts.h | 2 +- .../lwip-2.1.2/src/include/lwip/apps/mqtt.h | 4 +- .../src/include/lwip/apps/smtp_opts.h | 6 +- .../src/include/lwip/apps/snmp_core.h | 2 +- .../src/include/lwip/apps/tftp_opts.h | 2 +- .../src/include/lwip/apps/tftp_server.h | 4 +- .../net/lwip-2.1.2/src/include/lwip/arch.h | 4 +- .../net/lwip-2.1.2/src/include/lwip/igmp.h | 2 +- .../net/lwip-2.1.2/src/include/lwip/ip_addr.h | 2 +- .../net/lwip-2.1.2/src/include/lwip/mld6.h | 2 +- .../net/lwip-2.1.2/src/include/lwip/netif.h | 2 +- .../net/lwip-2.1.2/src/include/lwip/opt.h | 8 +- .../net/lwip-2.1.2/src/include/lwip/pbuf.h | 2 +- .../lwip-2.1.2/src/include/lwip/prot/ieee.h | 2 +- .../net/lwip-2.1.2/src/include/lwip/sys.h | 26 +- .../lwip-2.1.2/src/include/netif/ethernetif.h | 10 +- .../src/include/netif/lowpan6_ble.h | 6 +- .../src/include/netif/lowpan6_opts.h | 2 +- .../lwip-2.1.2/src/include/netif/ppp/ccp.h | 82 +- .../src/include/netif/ppp/chap-new.h | 90 +- .../lwip-2.1.2/src/include/netif/ppp/eap.h | 172 +- .../lwip-2.1.2/src/include/netif/ppp/ecp.h | 4 +- .../lwip-2.1.2/src/include/netif/ppp/eui64.h | 60 +- .../lwip-2.1.2/src/include/netif/ppp/fsm.h | 142 +- .../lwip-2.1.2/src/include/netif/ppp/ipcp.h | 36 +- .../lwip-2.1.2/src/include/netif/ppp/ipv6cp.h | 10 +- .../lwip-2.1.2/src/include/netif/ppp/lcp.h | 92 +- .../lwip-2.1.2/src/include/netif/ppp/magic.h | 2 +- .../lwip-2.1.2/src/include/netif/ppp/mppe.h | 154 +- .../src/include/netif/ppp/polarssl/arc4.h | 4 +- .../src/include/netif/ppp/polarssl/des.h | 4 +- .../src/include/netif/ppp/polarssl/md4.h | 4 +- .../src/include/netif/ppp/polarssl/md5.h | 4 +- .../src/include/netif/ppp/polarssl/sha1.h | 4 +- .../lwip-2.1.2/src/include/netif/ppp/ppp.h | 8 +- .../src/include/netif/ppp/ppp_impl.h | 254 +- .../src/include/netif/ppp/pppcrypt.h | 2 +- .../src/include/netif/ppp/pppdebug.h | 4 +- .../lwip-2.1.2/src/include/netif/ppp/pppoe.h | 4 +- .../lwip-2.1.2/src/include/netif/ppp/upap.h | 52 +- .../net/lwip-2.1.2/src/netif/bridgeif_fdb.c | 6 +- .../net/lwip-2.1.2/src/netif/ethernetif.c | 78 +- .../net/lwip-2.1.2/src/netif/lowpan6_ble.c | 32 +- .../net/lwip-2.1.2/src/netif/lowpan6_common.c | 2 +- .../net/lwip-2.1.2/src/netif/ppp/auth.c | 1494 +++---- components/net/lwip-2.1.2/src/netif/ppp/ccp.c | 1610 +++---- .../net/lwip-2.1.2/src/netif/ppp/chap-md5.c | 116 +- .../net/lwip-2.1.2/src/netif/ppp/chap-new.c | 884 ++-- .../net/lwip-2.1.2/src/netif/ppp/chap_ms.c | 786 ++-- .../net/lwip-2.1.2/src/netif/ppp/demand.c | 298 +- components/net/lwip-2.1.2/src/netif/ppp/eap.c | 3820 ++++++++--------- components/net/lwip-2.1.2/src/netif/ppp/ecp.c | 12 +- .../net/lwip-2.1.2/src/netif/ppp/eui64.c | 4 +- components/net/lwip-2.1.2/src/netif/ppp/fsm.c | 610 +-- .../net/lwip-2.1.2/src/netif/ppp/ipcp.c | 2026 ++++----- .../net/lwip-2.1.2/src/netif/ppp/ipv6cp.c | 1026 ++--- components/net/lwip-2.1.2/src/netif/ppp/lcp.c | 2370 +++++----- .../net/lwip-2.1.2/src/netif/ppp/mppe.c | 588 +-- .../net/lwip-2.1.2/src/netif/ppp/multilink.c | 888 ++-- .../lwip-2.1.2/src/netif/ppp/polarssl/arc4.c | 4 +- .../lwip-2.1.2/src/netif/ppp/polarssl/des.c | 4 +- .../lwip-2.1.2/src/netif/ppp/polarssl/md4.c | 4 +- .../lwip-2.1.2/src/netif/ppp/polarssl/md5.c | 6 +- .../lwip-2.1.2/src/netif/ppp/polarssl/sha1.c | 4 +- components/net/lwip-2.1.2/src/netif/ppp/ppp.c | 2 +- .../net/lwip-2.1.2/src/netif/ppp/pppapi.c | 22 +- .../net/lwip-2.1.2/src/netif/ppp/pppcrypt.c | 26 +- .../net/lwip-2.1.2/src/netif/ppp/pppoe.c | 8 +- .../net/lwip-2.1.2/src/netif/ppp/upap.c | 260 +- .../net/lwip-2.1.2/src/netif/ppp/utils.c | 890 ++-- components/net/lwip-2.1.2/test/fuzz/fuzz.c | 28 +- .../net/lwip-2.1.2/test/fuzz/lwipopts.h | 28 +- .../test/sockets/sockets_stresstest.c | 28 +- .../test/sockets/sockets_stresstest.h | 26 +- .../lwip-2.1.2/test/unit/api/test_sockets.c | 10 +- .../net/lwip-2.1.2/test/unit/arch/sys_arch.c | 28 +- .../net/lwip-2.1.2/test/unit/arch/sys_arch.h | 28 +- .../lwip-2.1.2/test/unit/core/test_timers.c | 6 +- .../net/lwip-2.1.2/test/unit/lwipopts.h | 28 +- .../net/lwip-2.1.2/test/unit/tcp/tcp_helper.c | 4 +- .../net/lwip-2.1.2/test/unit/tcp/test_tcp.c | 10 +- components/net/lwip_dhcpd/dhcp_server_raw.c | 2 +- components/net/netdev/include/arpa/inet.h | 2 +- components/net/netdev/include/netdev.h | 10 +- components/net/netdev/include/netdev_ipaddr.h | 42 +- components/net/netdev/src/netdev.c | 2 +- components/net/netdev/src/netdev_ipaddr.c | 2 +- components/net/sal_socket/dfs_net/dfs_net.c | 6 +- components/net/sal_socket/impl/af_inet.h | 2 +- components/net/sal_socket/impl/af_inet_at.c | 4 +- components/net/sal_socket/impl/af_inet_lwip.c | 8 +- .../net/sal_socket/impl/proto_mbedtls.c | 22 +- .../net/sal_socket/include/dfs_net/dfs_net.h | 2 +- .../include/dfs_net/sys_select/sys/select.h | 2 +- components/net/sal_socket/include/sal.h | 2 +- components/net/sal_socket/include/sal_netdb.h | 2 +- .../net/sal_socket/include/sal_socket.h | 4 +- components/net/sal_socket/include/sal_tls.h | 2 +- .../net/sal_socket/include/socket/netdb.h | 2 +- .../sal_socket/include/socket/netinet/in.h | 2 +- .../sal_socket/include/socket/netinet/tcp.h | 2 +- .../sal_socket/include/socket/netinet/udp.h | 2 +- .../include/socket/sys_socket/sys/socket.h | 2 +- components/net/sal_socket/socket/net_netdb.c | 2 +- .../net/sal_socket/socket/net_sockets.c | 6 +- components/net/sal_socket/src/sal_socket.c | 2 +- .../utilities/ulog/backend/console_be.c | 2 +- components/utilities/ulog/syslog/syslog.c | 2 +- components/utilities/ulog/syslog/syslog.h | 2 +- components/utilities/ulog/ulog.c | 2 +- components/utilities/ulog/ulog.h | 2 +- components/utilities/ulog/ulog_def.h | 8 +- components/utilities/utest/utest.c | 2 +- components/utilities/utest/utest.h | 60 +- components/utilities/utest/utest_assert.h | 10 +- components/utilities/utest/utest_log.h | 2 +- components/utilities/ymodem/ymodem.c | 4 +- components/utilities/ymodem/ymodem.h | 2 +- components/utilities/zmodem/crc.h | 12 +- components/utilities/zmodem/rz.c | 572 +-- components/utilities/zmodem/sz.c | 446 +- components/utilities/zmodem/zcore.c | 1410 +++--- components/utilities/zmodem/zdef.h | 208 +- components/utilities/zmodem/zdevice.c | 106 +- components/utilities/zmodem/zstart.c | 36 +- components/vbus/prio_queue.c | 4 +- components/vbus/prio_queue.h | 4 +- components/vbus/share_hdr/vbus_api.h | 2 +- components/vbus/vbus.c | 14 +- components/vbus/vbus.h | 14 +- components/vbus/vbus_chnx.c | 4 +- components/vbus/watermark_queue.c | 4 +- components/vbus/watermark_queue.h | 4 +- components/vmm/vmm.c | 4 +- components/vmm/vmm.h | 4 +- components/vmm/vmm_context.c | 4 +- components/vmm/vmm_context.h | 4 +- components/vmm/vmm_iomap.c | 4 +- components/vmm/vmm_vector.c | 12 +- 749 files changed, 28493 insertions(+), 28489 deletions(-) diff --git a/components/cplusplus/Lock.h b/components/cplusplus/Lock.h index 08d57c4850..c3cc1d2dae 100644 --- a/components/cplusplus/Lock.h +++ b/components/cplusplus/Lock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/Mail.h b/components/cplusplus/Mail.h index a4c98e4007..ae3bfb5c41 100644 --- a/components/cplusplus/Mail.h +++ b/components/cplusplus/Mail.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/Mutex.h b/components/cplusplus/Mutex.h index 6fee315155..63efb4a6ea 100644 --- a/components/cplusplus/Mutex.h +++ b/components/cplusplus/Mutex.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/Queue.h b/components/cplusplus/Queue.h index 23a4638798..f6b91e1a21 100644 --- a/components/cplusplus/Queue.h +++ b/components/cplusplus/Queue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/Semaphore.h b/components/cplusplus/Semaphore.h index cebaf91234..45c916e169 100644 --- a/components/cplusplus/Semaphore.h +++ b/components/cplusplus/Semaphore.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/Thread.h b/components/cplusplus/Thread.h index b578659489..0e681e5c2a 100644 --- a/components/cplusplus/Thread.h +++ b/components/cplusplus/Thread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/crt.h b/components/cplusplus/crt.h index 84e5a4b820..903d4c86cd 100644 --- a/components/cplusplus/crt.h +++ b/components/cplusplus/crt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/cplusplus/crt_init.c b/components/cplusplus/crt_init.c index fe12932457..977dee6ee9 100644 --- a/components/cplusplus/crt_init.c +++ b/components/cplusplus/crt_init.c @@ -1,15 +1,15 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * -* Change Logs: -* Date Author Notes -* 2014-12-03 Bernard Add copyright header. -* 2014-12-29 Bernard Add cplusplus initialization for ARMCC. -* 2016-06-28 Bernard Add _init/_fini routines for GCC. -* 2016-10-02 Bernard Add WEAK for cplusplus_system_init routine. -*/ + * Change Logs: + * Date Author Notes + * 2014-12-03 Bernard Add copyright header. + * 2014-12-29 Bernard Add cplusplus initialization for ARMCC. + * 2016-06-28 Bernard Add _init/_fini routines for GCC. + * 2016-10-02 Bernard Add WEAK for cplusplus_system_init routine. + */ #include diff --git a/components/cplusplus/cxx_Mutex.cpp b/components/cplusplus/cxx_Mutex.cpp index 229e842446..ad20e805e9 100644 --- a/components/cplusplus/cxx_Mutex.cpp +++ b/components/cplusplus/cxx_Mutex.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ + #include "Mutex.h" using namespace rtthread; diff --git a/components/cplusplus/cxx_Semaphore.cpp b/components/cplusplus/cxx_Semaphore.cpp index c977a27c1a..eda71f24a3 100644 --- a/components/cplusplus/cxx_Semaphore.cpp +++ b/components/cplusplus/cxx_Semaphore.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ + #include "Semaphore.h" using namespace rtthread; diff --git a/components/cplusplus/cxx_Thread.cpp b/components/cplusplus/cxx_Thread.cpp index b21fbdce1f..9689f6691b 100644 --- a/components/cplusplus/cxx_Thread.cpp +++ b/components/cplusplus/cxx_Thread.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ + #include "Thread.h" using namespace rtthread; diff --git a/components/cplusplus/cxx_crt.cpp b/components/cplusplus/cxx_crt.cpp index d4cb84f77c..750e01e0cb 100644 --- a/components/cplusplus/cxx_crt.cpp +++ b/components/cplusplus/cxx_crt.cpp @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * -* Change Logs: -* Date Author Notes -* 2015-03-07 Bernard Add copyright header. -*/ + * Change Logs: + * Date Author Notes + * 2015-03-07 Bernard Add copyright header. + */ #include #include "crt.h" diff --git a/components/dfs/filesystems/devfs/devfs.c b/components/dfs/filesystems/devfs/devfs.c index e457f18727..2e2248d5cc 100644 --- a/components/dfs/filesystems/devfs/devfs.c +++ b/components/dfs/filesystems/devfs/devfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -271,7 +271,7 @@ int dfs_device_fs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t co if (count == 0) return -EINVAL; - for (index = 0; index < count && index + root_dirent->read_index < root_dirent->device_count; + for (index = 0; index < count && index + root_dirent->read_index < root_dirent->device_count; index ++) { object = (rt_object_t)root_dirent->devices[root_dirent->read_index + index]; diff --git a/components/dfs/filesystems/devfs/devfs.h b/components/dfs/filesystems/devfs/devfs.h index ab2134043c..30a9482a35 100644 --- a/components/dfs/filesystems/devfs/devfs.h +++ b/components/dfs/filesystems/devfs/devfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c index 7e5e00aaf6..07b8f62fed 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.c +++ b/components/dfs/filesystems/elmfat/dfs_elm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/elmfat/dfs_elm.h b/components/dfs/filesystems/elmfat/dfs_elm.h index 1e9f577062..36a49bf18e 100644 --- a/components/dfs/filesystems/elmfat/dfs_elm.h +++ b/components/dfs/filesystems/elmfat/dfs_elm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/elmfat/diskio.h b/components/dfs/filesystems/elmfat/diskio.h index e4ead78380..511269ce3d 100644 --- a/components/dfs/filesystems/elmfat/diskio.h +++ b/components/dfs/filesystems/elmfat/diskio.h @@ -10,15 +10,15 @@ extern "C" { #endif /* Status of Disk Functions */ -typedef BYTE DSTATUS; +typedef BYTE DSTATUS; /* Results of Disk Functions */ typedef enum { - RES_OK = 0, /* 0: Successful */ - RES_ERROR, /* 1: R/W Error */ - RES_WRPRT, /* 2: Write Protected */ - RES_NOTRDY, /* 3: Not Ready */ - RES_PARERR /* 4: Invalid Parameter */ + RES_OK = 0, /* 0: Successful */ + RES_ERROR, /* 1: R/W Error */ + RES_WRPRT, /* 2: Write Protected */ + RES_NOTRDY, /* 3: Not Ready */ + RES_PARERR /* 4: Invalid Parameter */ } DRESULT; @@ -35,40 +35,40 @@ DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff); /* Disk Status Bits (DSTATUS) */ -#define STA_NOINIT 0x01 /* Drive not initialized */ -#define STA_NODISK 0x02 /* No medium in the drive */ -#define STA_PROTECT 0x04 /* Write protected */ +#define STA_NOINIT 0x01 /* Drive not initialized */ +#define STA_NODISK 0x02 /* No medium in the drive */ +#define STA_PROTECT 0x04 /* Write protected */ /* Command code for disk_ioctrl fucntion */ /* Generic command (Used by FatFs) */ -#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ -#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ -#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ -#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ -#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ +#define CTRL_SYNC 0 /* Complete pending write process (needed at FF_FS_READONLY == 0) */ +#define GET_SECTOR_COUNT 1 /* Get media size (needed at FF_USE_MKFS == 1) */ +#define GET_SECTOR_SIZE 2 /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */ +#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at FF_USE_MKFS == 1) */ +#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */ /* Generic command (Not used by FatFs) */ -#define CTRL_POWER 5 /* Get/Set power status */ -#define CTRL_LOCK 6 /* Lock/Unlock media removal */ -#define CTRL_EJECT 7 /* Eject media */ -#define CTRL_FORMAT 8 /* Create physical format on the media */ +#define CTRL_POWER 5 /* Get/Set power status */ +#define CTRL_LOCK 6 /* Lock/Unlock media removal */ +#define CTRL_EJECT 7 /* Eject media */ +#define CTRL_FORMAT 8 /* Create physical format on the media */ /* MMC/SDC specific ioctl command */ -#define MMC_GET_TYPE 10 /* Get card type */ -#define MMC_GET_CSD 11 /* Get CSD */ -#define MMC_GET_CID 12 /* Get CID */ -#define MMC_GET_OCR 13 /* Get OCR */ -#define MMC_GET_SDSTAT 14 /* Get SD status */ -#define ISDIO_READ 55 /* Read data form SD iSDIO register */ -#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ -#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ +#define MMC_GET_TYPE 10 /* Get card type */ +#define MMC_GET_CSD 11 /* Get CSD */ +#define MMC_GET_CID 12 /* Get CID */ +#define MMC_GET_OCR 13 /* Get OCR */ +#define MMC_GET_SDSTAT 14 /* Get SD status */ +#define ISDIO_READ 55 /* Read data form SD iSDIO register */ +#define ISDIO_WRITE 56 /* Write data to SD iSDIO register */ +#define ISDIO_MRITE 57 /* Masked write data to SD iSDIO register */ /* ATA/CF specific ioctl command */ -#define ATA_GET_REV 20 /* Get F/W revision */ -#define ATA_GET_MODEL 21 /* Get model name */ -#define ATA_GET_SN 22 /* Get serial number */ +#define ATA_GET_REV 20 /* Get F/W revision */ +#define ATA_GET_MODEL 21 /* Get model name */ +#define ATA_GET_SN 22 /* Get serial number */ #ifdef __cplusplus } diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.c b/components/dfs/filesystems/jffs2/dfs_jffs2.c index c082c21d73..c9e032a413 100644 --- a/components/dfs/filesystems/jffs2/dfs_jffs2.c +++ b/components/dfs/filesystems/jffs2/dfs_jffs2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.h b/components/dfs/filesystems/jffs2/dfs_jffs2.h index 1be403a19c..ccb8ad7993 100644 --- a/components/dfs/filesystems/jffs2/dfs_jffs2.h +++ b/components/dfs/filesystems/jffs2/dfs_jffs2.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -#ifndef __DFS_JFFS2_H__ +#ifndef __DFS_JFFS2_H__ #define __DFS_JFFS2_H__ int dfs_jffs2_init(void); diff --git a/components/dfs/filesystems/nfs/dfs_nfs.c b/components/dfs/filesystems/nfs/dfs_nfs.c index e60f6f98c0..e7ad488f7d 100644 --- a/components/dfs/filesystems/nfs/dfs_nfs.c +++ b/components/dfs/filesystems/nfs/dfs_nfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/nfs/dfs_nfs.h b/components/dfs/filesystems/nfs/dfs_nfs.h index d607776ef1..460027410d 100644 --- a/components/dfs/filesystems/nfs/dfs_nfs.h +++ b/components/dfs/filesystems/nfs/dfs_nfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/nfs/mount.h b/components/dfs/filesystems/nfs/mount.h index aac0fd6bed..ff0cec76fb 100644 --- a/components/dfs/filesystems/nfs/mount.h +++ b/components/dfs/filesystems/nfs/mount.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -12,7 +12,7 @@ */ #ifndef _MOUNT_H_RPCGEN -#define _MOUNT_H_RPCGEN +#define _MOUNT_H_RPCGEN #include @@ -23,13 +23,13 @@ extern "C" { /* This file is copied from RFC1813 * Copyright 1995 Sun Micrososystems (I assume) */ -#define MNTPATHLEN 1024 -#define MNTNAMLEN 255 -#define FHSIZE3 64 +#define MNTPATHLEN 1024 +#define MNTNAMLEN 255 +#define FHSIZE3 64 typedef struct { - unsigned int fhandle3_len; - char *fhandle3_val; + unsigned int fhandle3_len; + char *fhandle3_val; } fhandle3; typedef char *dirpath; @@ -43,70 +43,70 @@ typedef struct groupnode *groups; typedef struct mountbody *mountlist; enum mountstat3 { - MNT3_OK = 0, - MNT3ERR_PERM = 1, - MNT3ERR_NOENT = 2, - MNT3ERR_IO = 5, - MNT3ERR_ACCES = 13, - MNT3ERR_NOTDIR = 20, - MNT3ERR_INVAL = 22, - MNT3ERR_NAMETOOLONG = 63, - MNT3ERR_NOTSUPP = 10004, - MNT3ERR_SERVERFAULT = 10006 + MNT3_OK = 0, + MNT3ERR_PERM = 1, + MNT3ERR_NOENT = 2, + MNT3ERR_IO = 5, + MNT3ERR_ACCES = 13, + MNT3ERR_NOTDIR = 20, + MNT3ERR_INVAL = 22, + MNT3ERR_NAMETOOLONG = 63, + MNT3ERR_NOTSUPP = 10004, + MNT3ERR_SERVERFAULT = 10006 }; typedef enum mountstat3 mountstat3; struct mountres3_ok { - fhandle3 fhandle; - struct { - unsigned int auth_flavors_len; - int *auth_flavors_val; - } auth_flavors; + fhandle3 fhandle; + struct { + unsigned int auth_flavors_len; + int *auth_flavors_val; + } auth_flavors; }; typedef struct mountres3_ok mountres3_ok; struct mountres3 { - mountstat3 fhs_status; - union { - mountres3_ok mountinfo; - } mountres3_u; + mountstat3 fhs_status; + union { + mountres3_ok mountinfo; + } mountres3_u; }; typedef struct mountres3 mountres3; struct mountbody { - name ml_hostname; - dirpath ml_directory; - mountlist ml_next; + name ml_hostname; + dirpath ml_directory; + mountlist ml_next; }; typedef struct mountbody mountbody; struct groupnode { - name gr_name; - groups gr_next; + name gr_name; + groups gr_next; }; typedef struct groupnode groupnode; struct exportnode { - dirpath ex_dir; - groups ex_groups; - exports ex_next; + dirpath ex_dir; + groups ex_groups; + exports ex_next; }; typedef struct exportnode exportnode; -#define MOUNT_PROGRAM 100005 -#define MOUNT_V3 3 +#define MOUNT_PROGRAM 100005 +#define MOUNT_V3 3 -#define MOUNTPROC3_NULL 0 +#define MOUNTPROC3_NULL 0 extern enum clnt_stat mountproc3_null_3(void *, CLIENT *); -#define MOUNTPROC3_MNT 1 +#define MOUNTPROC3_MNT 1 extern enum clnt_stat mountproc3_mnt_3(dirpath , mountres3 *, CLIENT *); -#define MOUNTPROC3_DUMP 2 +#define MOUNTPROC3_DUMP 2 extern enum clnt_stat mountproc3_dump_3(mountlist *, CLIENT *); -#define MOUNTPROC3_UMNT 3 +#define MOUNTPROC3_UMNT 3 extern enum clnt_stat mountproc3_umnt_3(dirpath , void *, CLIENT *); -#define MOUNTPROC3_UMNTALL 4 +#define MOUNTPROC3_UMNTALL 4 extern enum clnt_stat mountproc3_umntall_3(void *, CLIENT *); -#define MOUNTPROC3_EXPORT 5 +#define MOUNTPROC3_EXPORT 5 extern enum clnt_stat mountproc3_export_3(exports *, CLIENT *); /* the xdr functions */ diff --git a/components/dfs/filesystems/nfs/mount_clnt.c b/components/dfs/filesystems/nfs/mount_clnt.c index 5c65e75aa5..9e05f7ee61 100644 --- a/components/dfs/filesystems/nfs/mount_clnt.c +++ b/components/dfs/filesystems/nfs/mount_clnt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -23,56 +23,56 @@ typedef char* caddr_t; /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; -enum clnt_stat +enum clnt_stat mountproc3_null_3(void *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, MOUNTPROC3_NULL, - (xdrproc_t) xdr_void, (caddr_t) NULL, - (xdrproc_t) xdr_void, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, MOUNTPROC3_NULL, + (xdrproc_t) xdr_void, (caddr_t) NULL, + (xdrproc_t) xdr_void, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat mountproc3_mnt_3(dirpath arg1, mountres3 *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, MOUNTPROC3_MNT, - (xdrproc_t) xdr_dirpath, (caddr_t) &arg1, - (xdrproc_t) xdr_mountres3, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, MOUNTPROC3_MNT, + (xdrproc_t) xdr_dirpath, (caddr_t) &arg1, + (xdrproc_t) xdr_mountres3, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat mountproc3_dump_3(mountlist *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, MOUNTPROC3_DUMP, - (xdrproc_t) xdr_void, (caddr_t) NULL, - (xdrproc_t) xdr_mountlist, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, MOUNTPROC3_DUMP, + (xdrproc_t) xdr_void, (caddr_t) NULL, + (xdrproc_t) xdr_mountlist, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat mountproc3_umnt_3(dirpath arg1, void *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, MOUNTPROC3_UMNT, - (xdrproc_t) xdr_dirpath, (caddr_t) &arg1, - (xdrproc_t) xdr_void, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, MOUNTPROC3_UMNT, + (xdrproc_t) xdr_dirpath, (caddr_t) &arg1, + (xdrproc_t) xdr_void, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat mountproc3_umntall_3(void *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, MOUNTPROC3_UMNTALL, - (xdrproc_t) xdr_void, (caddr_t) NULL, - (xdrproc_t) xdr_void, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, MOUNTPROC3_UMNTALL, + (xdrproc_t) xdr_void, (caddr_t) NULL, + (xdrproc_t) xdr_void, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat mountproc3_export_3(exports *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, MOUNTPROC3_EXPORT, - (xdrproc_t) xdr_void, (caddr_t) NULL, - (xdrproc_t) xdr_exports, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, MOUNTPROC3_EXPORT, + (xdrproc_t) xdr_void, (caddr_t) NULL, + (xdrproc_t) xdr_exports, (caddr_t) clnt_res, + TIMEOUT)); } diff --git a/components/dfs/filesystems/nfs/mount_xdr.c b/components/dfs/filesystems/nfs/mount_xdr.c index 04faa3bb7a..e1e797000f 100644 --- a/components/dfs/filesystems/nfs/mount_xdr.c +++ b/components/dfs/filesystems/nfs/mount_xdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -19,124 +19,124 @@ bool_t xdr_fhandle3(register XDR *xdrs, fhandle3 *objp) { - if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) - return (FALSE); - return (TRUE); + if (!xdr_bytes(xdrs, (char **)&objp->fhandle3_val, (unsigned int *) &objp->fhandle3_len, FHSIZE3)) + return (FALSE); + return (TRUE); } bool_t xdr_dirpath(register XDR *xdrs, dirpath *objp) { - if (!xdr_string(xdrs, objp, MNTPATHLEN)) - return (FALSE); - return (TRUE); + if (!xdr_string(xdrs, objp, MNTPATHLEN)) + return (FALSE); + return (TRUE); } bool_t xdr_name(register XDR *xdrs, name *objp) { - if (!xdr_string(xdrs, objp, MNTNAMLEN)) - return (FALSE); - return (TRUE); + if (!xdr_string(xdrs, objp, MNTNAMLEN)) + return (FALSE); + return (TRUE); } bool_t xdr_exports(register XDR *xdrs, exports *objp) { - if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode)) - return (FALSE); - return (TRUE); + if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct exportnode), (xdrproc_t) xdr_exportnode)) + return (FALSE); + return (TRUE); } bool_t xdr_groups(register XDR *xdrs, groups *objp) { - if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode)) - return (FALSE); - return (TRUE); + if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct groupnode), (xdrproc_t) xdr_groupnode)) + return (FALSE); + return (TRUE); } bool_t xdr_mountlist(register XDR *xdrs, mountlist *objp) { - if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody)) - return (FALSE); - return (TRUE); + if (!xdr_pointer(xdrs, (char **)objp, sizeof (struct mountbody), (xdrproc_t) xdr_mountbody)) + return (FALSE); + return (TRUE); } bool_t xdr_mountstat3(register XDR *xdrs, mountstat3 *objp) { - int enum_objp; + int enum_objp; - enum_objp = *objp; + enum_objp = *objp; - if (!xdr_enum(xdrs, (enum_t *)&enum_objp)) - { - *objp = (mountstat3)enum_objp; - return (FALSE); - } + if (!xdr_enum(xdrs, (enum_t *)&enum_objp)) + { + *objp = (mountstat3)enum_objp; + return (FALSE); + } - return (TRUE); + return (TRUE); } bool_t xdr_mountres3_ok(register XDR *xdrs, mountres3_ok *objp) { - if (!xdr_fhandle3(xdrs, &objp->fhandle)) - return (FALSE); - if (!xdr_array(xdrs, (char **)&objp->auth_flavors.auth_flavors_val, (unsigned int *) &objp->auth_flavors.auth_flavors_len, ~0, - sizeof (int), (xdrproc_t) xdr_int)) - return (FALSE); - return (TRUE); + if (!xdr_fhandle3(xdrs, &objp->fhandle)) + return (FALSE); + if (!xdr_array(xdrs, (char **)&objp->auth_flavors.auth_flavors_val, (unsigned int *) &objp->auth_flavors.auth_flavors_len, ~0, + sizeof (int), (xdrproc_t) xdr_int)) + return (FALSE); + return (TRUE); } bool_t xdr_mountres3(register XDR *xdrs, mountres3 *objp) { - if (!xdr_mountstat3(xdrs, &objp->fhs_status)) - return (FALSE); - switch (objp->fhs_status) { - case MNT3_OK: - if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) - return (FALSE); - break; - default : - return (FALSE); - } - return (TRUE); + if (!xdr_mountstat3(xdrs, &objp->fhs_status)) + return (FALSE); + switch (objp->fhs_status) { + case MNT3_OK: + if (!xdr_mountres3_ok(xdrs, &objp->mountres3_u.mountinfo)) + return (FALSE); + break; + default : + return (FALSE); + } + return (TRUE); } bool_t xdr_mountbody(register XDR *xdrs, mountbody *objp) { - if (!xdr_name(xdrs, &objp->ml_hostname)) - return (FALSE); - if (!xdr_dirpath(xdrs, &objp->ml_directory)) - return (FALSE); - if (!xdr_mountlist(xdrs, &objp->ml_next)) - return (FALSE); - return (TRUE); + if (!xdr_name(xdrs, &objp->ml_hostname)) + return (FALSE); + if (!xdr_dirpath(xdrs, &objp->ml_directory)) + return (FALSE); + if (!xdr_mountlist(xdrs, &objp->ml_next)) + return (FALSE); + return (TRUE); } bool_t xdr_groupnode(register XDR *xdrs, groupnode *objp) { - if (!xdr_name(xdrs, &objp->gr_name)) - return (FALSE); - if (!xdr_groups(xdrs, &objp->gr_next)) - return (FALSE); - return (TRUE); + if (!xdr_name(xdrs, &objp->gr_name)) + return (FALSE); + if (!xdr_groups(xdrs, &objp->gr_next)) + return (FALSE); + return (TRUE); } bool_t xdr_exportnode(register XDR *xdrs, exportnode *objp) { - if (!xdr_dirpath(xdrs, &objp->ex_dir)) - return (FALSE); - if (!xdr_groups(xdrs, &objp->ex_groups)) - return (FALSE); - if (!xdr_exports(xdrs, &objp->ex_next)) - return (FALSE); - return (TRUE); + if (!xdr_dirpath(xdrs, &objp->ex_dir)) + return (FALSE); + if (!xdr_groups(xdrs, &objp->ex_groups)) + return (FALSE); + if (!xdr_exports(xdrs, &objp->ex_next)) + return (FALSE); + return (TRUE); } diff --git a/components/dfs/filesystems/nfs/nfs.h b/components/dfs/filesystems/nfs/nfs.h index 34054b0084..8c417ec7f4 100644 --- a/components/dfs/filesystems/nfs/nfs.h +++ b/components/dfs/filesystems/nfs/nfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -12,7 +12,7 @@ */ #ifndef _NFS_H_RPCGEN -#define _NFS_H_RPCGEN +#define _NFS_H_RPCGEN #include @@ -23,20 +23,20 @@ extern "C" { /* This file is copied from RFC1813 * Copyright 1995 Sun Micrososystems (I assume) */ -#define NFS3_FHSIZE 64 -#define NFS3_COOKIEVERFSIZE 8 -#define NFS3_CREATEVERFSIZE 8 -#define NFS3_WRITEVERFSIZE 8 -#define ACCESS3_READ 0x0001 -#define ACCESS3_LOOKUP 0x0002 -#define ACCESS3_MODIFY 0x0004 -#define ACCESS3_EXTEND 0x0008 -#define ACCESS3_DELETE 0x0010 -#define ACCESS3_EXECUTE 0x0020 -#define FSF3_LINK 0x0001 -#define FSF3_SYMLINK 0x0002 -#define FSF3_HOMOGENEOUS 0x0008 -#define FSF3_CANSETTIME 0x0010 +#define NFS3_FHSIZE 64 +#define NFS3_COOKIEVERFSIZE 8 +#define NFS3_CREATEVERFSIZE 8 +#define NFS3_WRITEVERFSIZE 8 +#define ACCESS3_READ 0x0001 +#define ACCESS3_LOOKUP 0x0002 +#define ACCESS3_MODIFY 0x0004 +#define ACCESS3_EXTEND 0x0008 +#define ACCESS3_DELETE 0x0010 +#define ACCESS3_EXECUTE 0x0020 +#define FSF3_LINK 0x0001 +#define FSF3_SYMLINK 0x0002 +#define FSF3_HOMOGENEOUS 0x0008 +#define FSF3_CANSETTIME 0x0010 typedef unsigned long long uint64; @@ -73,900 +73,900 @@ typedef uint32 mode3; typedef uint32 count3; enum nfsstat3 { - NFS3_OK = 0, - NFS3ERR_PERM = 1, - NFS3ERR_NOENT = 2, - NFS3ERR_IO = 5, - NFS3ERR_NXIO = 6, - NFS3ERR_ACCES = 13, - NFS3ERR_EXIST = 17, - NFS3ERR_XDEV = 18, - NFS3ERR_NODEV = 19, - NFS3ERR_NOTDIR = 20, - NFS3ERR_ISDIR = 21, - NFS3ERR_INVAL = 22, - NFS3ERR_FBIG = 27, - NFS3ERR_NOSPC = 28, - NFS3ERR_ROFS = 30, - NFS3ERR_MLINK = 31, - NFS3ERR_NAMETOOLONG = 63, - NFS3ERR_NOTEMPTY = 66, - NFS3ERR_DQUOT = 69, - NFS3ERR_STALE = 70, - NFS3ERR_REMOTE = 71, - NFS3ERR_BADHANDLE = 10001, - NFS3ERR_NOT_SYNC = 10002, - NFS3ERR_BAD_COOKIE = 10003, - NFS3ERR_NOTSUPP = 10004, - NFS3ERR_TOOSMALL = 10005, - NFS3ERR_SERVERFAULT = 10006, - NFS3ERR_BADTYPE = 10007, - NFS3ERR_JUKEBOX = 10008 + NFS3_OK = 0, + NFS3ERR_PERM = 1, + NFS3ERR_NOENT = 2, + NFS3ERR_IO = 5, + NFS3ERR_NXIO = 6, + NFS3ERR_ACCES = 13, + NFS3ERR_EXIST = 17, + NFS3ERR_XDEV = 18, + NFS3ERR_NODEV = 19, + NFS3ERR_NOTDIR = 20, + NFS3ERR_ISDIR = 21, + NFS3ERR_INVAL = 22, + NFS3ERR_FBIG = 27, + NFS3ERR_NOSPC = 28, + NFS3ERR_ROFS = 30, + NFS3ERR_MLINK = 31, + NFS3ERR_NAMETOOLONG = 63, + NFS3ERR_NOTEMPTY = 66, + NFS3ERR_DQUOT = 69, + NFS3ERR_STALE = 70, + NFS3ERR_REMOTE = 71, + NFS3ERR_BADHANDLE = 10001, + NFS3ERR_NOT_SYNC = 10002, + NFS3ERR_BAD_COOKIE = 10003, + NFS3ERR_NOTSUPP = 10004, + NFS3ERR_TOOSMALL = 10005, + NFS3ERR_SERVERFAULT = 10006, + NFS3ERR_BADTYPE = 10007, + NFS3ERR_JUKEBOX = 10008 }; typedef enum nfsstat3 nfsstat3; enum ftype3 { - NFS3REG = 1, - NFS3DIR = 2, - NFS3BLK = 3, - NFS3CHR = 4, - NFS3LNK = 5, - NFS3SOCK = 6, - NFS3FIFO = 7 + NFS3REG = 1, + NFS3DIR = 2, + NFS3BLK = 3, + NFS3CHR = 4, + NFS3LNK = 5, + NFS3SOCK = 6, + NFS3FIFO = 7 }; typedef enum ftype3 ftype3; enum stable_how { - UNSTABLE = 0, - DATA_SYNC = 1, - FILE_SYNC = 2 + UNSTABLE = 0, + DATA_SYNC = 1, + FILE_SYNC = 2 }; typedef enum stable_how stable_how; enum createmode3 { - UNCHECKED = 0, - GUARDED = 1, - EXCLUSIVE = 2 + UNCHECKED = 0, + GUARDED = 1, + EXCLUSIVE = 2 }; typedef enum createmode3 createmode3; struct specdata3 { - uint32 specdata1; - uint32 specdata2; + uint32 specdata1; + uint32 specdata2; }; typedef struct specdata3 specdata3; struct nfs_fh3 { - struct { - unsigned int data_len; - char *data_val; - } data; + struct { + unsigned int data_len; + char *data_val; + } data; }; typedef struct nfs_fh3 nfs_fh3; struct nfstime3 { - uint32 seconds; - uint32 nseconds; + uint32 seconds; + uint32 nseconds; }; typedef struct nfstime3 nfstime3; struct fattr3 { - ftype3 type; - mode3 mode; - uint32 nlink; - uid3 uid; - gid3 gid; - size3 size; - size3 used; - specdata3 rdev; - uint64 fsid; - fileid3 fileid; - nfstime3 atime; - nfstime3 mtime; - nfstime3 ctime; + ftype3 type; + mode3 mode; + uint32 nlink; + uid3 uid; + gid3 gid; + size3 size; + size3 used; + specdata3 rdev; + uint64 fsid; + fileid3 fileid; + nfstime3 atime; + nfstime3 mtime; + nfstime3 ctime; }; typedef struct fattr3 fattr3; struct post_op_attr { - bool_t attributes_follow; - union { - fattr3 attributes; - } post_op_attr_u; + bool_t attributes_follow; + union { + fattr3 attributes; + } post_op_attr_u; }; typedef struct post_op_attr post_op_attr; struct wcc_attr { - size3 size; - nfstime3 mtime; - nfstime3 ctime; + size3 size; + nfstime3 mtime; + nfstime3 ctime; }; typedef struct wcc_attr wcc_attr; struct pre_op_attr { - bool_t attributes_follow; - union { - wcc_attr attributes; - } pre_op_attr_u; + bool_t attributes_follow; + union { + wcc_attr attributes; + } pre_op_attr_u; }; typedef struct pre_op_attr pre_op_attr; struct wcc_data { - pre_op_attr before; - post_op_attr after; + pre_op_attr before; + post_op_attr after; }; typedef struct wcc_data wcc_data; struct post_op_fh3 { - bool_t handle_follows; - union { - nfs_fh3 handle; - } post_op_fh3_u; + bool_t handle_follows; + union { + nfs_fh3 handle; + } post_op_fh3_u; }; typedef struct post_op_fh3 post_op_fh3; enum time_how { - DONT_CHANGE = 0, - SET_TO_SERVER_TIME = 1, - SET_TO_CLIENT_TIME = 2 + DONT_CHANGE = 0, + SET_TO_SERVER_TIME = 1, + SET_TO_CLIENT_TIME = 2 }; typedef enum time_how time_how; struct set_mode3 { - bool_t set_it; - union { - mode3 mode; - } set_mode3_u; + bool_t set_it; + union { + mode3 mode; + } set_mode3_u; }; typedef struct set_mode3 set_mode3; struct set_uid3 { - bool_t set_it; - union { - uid3 uid; - } set_uid3_u; + bool_t set_it; + union { + uid3 uid; + } set_uid3_u; }; typedef struct set_uid3 set_uid3; struct set_gid3 { - bool_t set_it; - union { - gid3 gid; - } set_gid3_u; + bool_t set_it; + union { + gid3 gid; + } set_gid3_u; }; typedef struct set_gid3 set_gid3; struct set_size3 { - bool_t set_it; - union { - size3 size; - } set_size3_u; + bool_t set_it; + union { + size3 size; + } set_size3_u; }; typedef struct set_size3 set_size3; struct set_atime { - time_how set_it; - union { - nfstime3 atime; - } set_atime_u; + time_how set_it; + union { + nfstime3 atime; + } set_atime_u; }; typedef struct set_atime set_atime; struct set_mtime { - time_how set_it; - union { - nfstime3 mtime; - } set_mtime_u; + time_how set_it; + union { + nfstime3 mtime; + } set_mtime_u; }; typedef struct set_mtime set_mtime; struct sattr3 { - set_mode3 mode; - set_uid3 uid; - set_gid3 gid; - set_size3 size; - set_atime atime; - set_mtime mtime; + set_mode3 mode; + set_uid3 uid; + set_gid3 gid; + set_size3 size; + set_atime atime; + set_mtime mtime; }; typedef struct sattr3 sattr3; struct diropargs3 { - nfs_fh3 dir; - filename3 name; + nfs_fh3 dir; + filename3 name; }; typedef struct diropargs3 diropargs3; struct GETATTR3args { - nfs_fh3 object; + nfs_fh3 object; }; typedef struct GETATTR3args GETATTR3args; struct GETATTR3resok { - fattr3 obj_attributes; + fattr3 obj_attributes; }; typedef struct GETATTR3resok GETATTR3resok; struct GETATTR3res { - nfsstat3 status; - union { - GETATTR3resok resok; - } GETATTR3res_u; + nfsstat3 status; + union { + GETATTR3resok resok; + } GETATTR3res_u; }; typedef struct GETATTR3res GETATTR3res; struct sattrguard3 { - bool_t check; - union { - nfstime3 obj_ctime; - } sattrguard3_u; + bool_t check; + union { + nfstime3 obj_ctime; + } sattrguard3_u; }; typedef struct sattrguard3 sattrguard3; struct SETATTR3args { - nfs_fh3 object; - sattr3 new_attributes; - sattrguard3 guard; + nfs_fh3 object; + sattr3 new_attributes; + sattrguard3 guard; }; typedef struct SETATTR3args SETATTR3args; struct SETATTR3resok { - wcc_data obj_wcc; + wcc_data obj_wcc; }; typedef struct SETATTR3resok SETATTR3resok; struct SETATTR3resfail { - wcc_data obj_wcc; + wcc_data obj_wcc; }; typedef struct SETATTR3resfail SETATTR3resfail; struct SETATTR3res { - nfsstat3 status; - union { - SETATTR3resok resok; - SETATTR3resfail resfail; - } SETATTR3res_u; + nfsstat3 status; + union { + SETATTR3resok resok; + SETATTR3resfail resfail; + } SETATTR3res_u; }; typedef struct SETATTR3res SETATTR3res; struct LOOKUP3args { - diropargs3 what; + diropargs3 what; }; typedef struct LOOKUP3args LOOKUP3args; struct LOOKUP3resok { - nfs_fh3 object; - post_op_attr obj_attributes; - post_op_attr dir_attributes; + nfs_fh3 object; + post_op_attr obj_attributes; + post_op_attr dir_attributes; }; typedef struct LOOKUP3resok LOOKUP3resok; struct LOOKUP3resfail { - post_op_attr dir_attributes; + post_op_attr dir_attributes; }; typedef struct LOOKUP3resfail LOOKUP3resfail; struct LOOKUP3res { - nfsstat3 status; - union { - LOOKUP3resok resok; - LOOKUP3resfail resfail; - } LOOKUP3res_u; + nfsstat3 status; + union { + LOOKUP3resok resok; + LOOKUP3resfail resfail; + } LOOKUP3res_u; }; typedef struct LOOKUP3res LOOKUP3res; struct ACCESS3args { - nfs_fh3 object; - uint32 access; + nfs_fh3 object; + uint32 access; }; typedef struct ACCESS3args ACCESS3args; struct ACCESS3resok { - post_op_attr obj_attributes; - uint32 access; + post_op_attr obj_attributes; + uint32 access; }; typedef struct ACCESS3resok ACCESS3resok; struct ACCESS3resfail { - post_op_attr obj_attributes; + post_op_attr obj_attributes; }; typedef struct ACCESS3resfail ACCESS3resfail; struct ACCESS3res { - nfsstat3 status; - union { - ACCESS3resok resok; - ACCESS3resfail resfail; - } ACCESS3res_u; + nfsstat3 status; + union { + ACCESS3resok resok; + ACCESS3resfail resfail; + } ACCESS3res_u; }; typedef struct ACCESS3res ACCESS3res; struct READLINK3args { - nfs_fh3 symlink; + nfs_fh3 symlink; }; typedef struct READLINK3args READLINK3args; struct READLINK3resok { - post_op_attr symlink_attributes; - nfspath3 data; + post_op_attr symlink_attributes; + nfspath3 data; }; typedef struct READLINK3resok READLINK3resok; struct READLINK3resfail { - post_op_attr symlink_attributes; + post_op_attr symlink_attributes; }; typedef struct READLINK3resfail READLINK3resfail; struct READLINK3res { - nfsstat3 status; - union { - READLINK3resok resok; - READLINK3resfail resfail; - } READLINK3res_u; + nfsstat3 status; + union { + READLINK3resok resok; + READLINK3resfail resfail; + } READLINK3res_u; }; typedef struct READLINK3res READLINK3res; struct READ3args { - nfs_fh3 file; - offset3 offset; - count3 count; + nfs_fh3 file; + offset3 offset; + count3 count; }; typedef struct READ3args READ3args; struct READ3resok { - post_op_attr file_attributes; - count3 count; - bool_t eof; - struct { - unsigned int data_len; - char *data_val; - } data; + post_op_attr file_attributes; + count3 count; + bool_t eof; + struct { + unsigned int data_len; + char *data_val; + } data; }; typedef struct READ3resok READ3resok; struct READ3resfail { - post_op_attr file_attributes; + post_op_attr file_attributes; }; typedef struct READ3resfail READ3resfail; struct READ3res { - nfsstat3 status; - union { - READ3resok resok; - READ3resfail resfail; - } READ3res_u; + nfsstat3 status; + union { + READ3resok resok; + READ3resfail resfail; + } READ3res_u; }; typedef struct READ3res READ3res; struct WRITE3args { - nfs_fh3 file; - offset3 offset; - count3 count; - stable_how stable; - struct { - unsigned int data_len; - char *data_val; - } data; + nfs_fh3 file; + offset3 offset; + count3 count; + stable_how stable; + struct { + unsigned int data_len; + char *data_val; + } data; }; typedef struct WRITE3args WRITE3args; struct WRITE3resok { - wcc_data file_wcc; - count3 count; - stable_how committed; - writeverf3 verf; + wcc_data file_wcc; + count3 count; + stable_how committed; + writeverf3 verf; }; typedef struct WRITE3resok WRITE3resok; struct WRITE3resfail { - wcc_data file_wcc; + wcc_data file_wcc; }; typedef struct WRITE3resfail WRITE3resfail; struct WRITE3res { - nfsstat3 status; - union { - WRITE3resok resok; - WRITE3resfail resfail; - } WRITE3res_u; + nfsstat3 status; + union { + WRITE3resok resok; + WRITE3resfail resfail; + } WRITE3res_u; }; typedef struct WRITE3res WRITE3res; struct createhow3 { - createmode3 mode; - union { - sattr3 obj_attributes; - createverf3 verf; - } createhow3_u; + createmode3 mode; + union { + sattr3 obj_attributes; + createverf3 verf; + } createhow3_u; }; typedef struct createhow3 createhow3; struct CREATE3args { - diropargs3 where; - createhow3 how; + diropargs3 where; + createhow3 how; }; typedef struct CREATE3args CREATE3args; struct CREATE3resok { - post_op_fh3 obj; - post_op_attr obj_attributes; - wcc_data dir_wcc; + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; }; typedef struct CREATE3resok CREATE3resok; struct CREATE3resfail { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct CREATE3resfail CREATE3resfail; struct CREATE3res { - nfsstat3 status; - union { - CREATE3resok resok; - CREATE3resfail resfail; - } CREATE3res_u; + nfsstat3 status; + union { + CREATE3resok resok; + CREATE3resfail resfail; + } CREATE3res_u; }; typedef struct CREATE3res CREATE3res; struct MKDIR3args { - diropargs3 where; - sattr3 attributes; + diropargs3 where; + sattr3 attributes; }; typedef struct MKDIR3args MKDIR3args; struct MKDIR3resok { - post_op_fh3 obj; - post_op_attr obj_attributes; - wcc_data dir_wcc; + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; }; typedef struct MKDIR3resok MKDIR3resok; struct MKDIR3resfail { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct MKDIR3resfail MKDIR3resfail; struct MKDIR3res { - nfsstat3 status; - union { - MKDIR3resok resok; - MKDIR3resfail resfail; - } MKDIR3res_u; + nfsstat3 status; + union { + MKDIR3resok resok; + MKDIR3resfail resfail; + } MKDIR3res_u; }; typedef struct MKDIR3res MKDIR3res; struct symlinkdata3 { - sattr3 symlink_attributes; - nfspath3 symlink_data; + sattr3 symlink_attributes; + nfspath3 symlink_data; }; typedef struct symlinkdata3 symlinkdata3; struct SYMLINK3args { - diropargs3 where; - symlinkdata3 symlink; + diropargs3 where; + symlinkdata3 symlink; }; typedef struct SYMLINK3args SYMLINK3args; struct SYMLINK3resok { - post_op_fh3 obj; - post_op_attr obj_attributes; - wcc_data dir_wcc; + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; }; typedef struct SYMLINK3resok SYMLINK3resok; struct SYMLINK3resfail { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct SYMLINK3resfail SYMLINK3resfail; struct SYMLINK3res { - nfsstat3 status; - union { - SYMLINK3resok resok; - SYMLINK3resfail resfail; - } SYMLINK3res_u; + nfsstat3 status; + union { + SYMLINK3resok resok; + SYMLINK3resfail resfail; + } SYMLINK3res_u; }; typedef struct SYMLINK3res SYMLINK3res; struct devicedata3 { - sattr3 dev_attributes; - specdata3 spec; + sattr3 dev_attributes; + specdata3 spec; }; typedef struct devicedata3 devicedata3; struct mknoddata3 { - ftype3 type; - union { - devicedata3 device; - sattr3 pipe_attributes; - } mknoddata3_u; + ftype3 type; + union { + devicedata3 device; + sattr3 pipe_attributes; + } mknoddata3_u; }; typedef struct mknoddata3 mknoddata3; struct MKNOD3args { - diropargs3 where; - mknoddata3 what; + diropargs3 where; + mknoddata3 what; }; typedef struct MKNOD3args MKNOD3args; struct MKNOD3resok { - post_op_fh3 obj; - post_op_attr obj_attributes; - wcc_data dir_wcc; + post_op_fh3 obj; + post_op_attr obj_attributes; + wcc_data dir_wcc; }; typedef struct MKNOD3resok MKNOD3resok; struct MKNOD3resfail { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct MKNOD3resfail MKNOD3resfail; struct MKNOD3res { - nfsstat3 status; - union { - MKNOD3resok resok; - MKNOD3resfail resfail; - } MKNOD3res_u; + nfsstat3 status; + union { + MKNOD3resok resok; + MKNOD3resfail resfail; + } MKNOD3res_u; }; typedef struct MKNOD3res MKNOD3res; struct REMOVE3args { - diropargs3 object; + diropargs3 object; }; typedef struct REMOVE3args REMOVE3args; struct REMOVE3resok { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct REMOVE3resok REMOVE3resok; struct REMOVE3resfail { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct REMOVE3resfail REMOVE3resfail; struct REMOVE3res { - nfsstat3 status; - union { - REMOVE3resok resok; - REMOVE3resfail resfail; - } REMOVE3res_u; + nfsstat3 status; + union { + REMOVE3resok resok; + REMOVE3resfail resfail; + } REMOVE3res_u; }; typedef struct REMOVE3res REMOVE3res; struct RMDIR3args { - diropargs3 object; + diropargs3 object; }; typedef struct RMDIR3args RMDIR3args; struct RMDIR3resok { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct RMDIR3resok RMDIR3resok; struct RMDIR3resfail { - wcc_data dir_wcc; + wcc_data dir_wcc; }; typedef struct RMDIR3resfail RMDIR3resfail; struct RMDIR3res { - nfsstat3 status; - union { - RMDIR3resok resok; - RMDIR3resfail resfail; - } RMDIR3res_u; + nfsstat3 status; + union { + RMDIR3resok resok; + RMDIR3resfail resfail; + } RMDIR3res_u; }; typedef struct RMDIR3res RMDIR3res; struct RENAME3args { - diropargs3 from; - diropargs3 to; + diropargs3 from; + diropargs3 to; }; typedef struct RENAME3args RENAME3args; struct RENAME3resok { - wcc_data fromdir_wcc; - wcc_data todir_wcc; + wcc_data fromdir_wcc; + wcc_data todir_wcc; }; typedef struct RENAME3resok RENAME3resok; struct RENAME3resfail { - wcc_data fromdir_wcc; - wcc_data todir_wcc; + wcc_data fromdir_wcc; + wcc_data todir_wcc; }; typedef struct RENAME3resfail RENAME3resfail; struct RENAME3res { - nfsstat3 status; - union { - RENAME3resok resok; - RENAME3resfail resfail; - } RENAME3res_u; + nfsstat3 status; + union { + RENAME3resok resok; + RENAME3resfail resfail; + } RENAME3res_u; }; typedef struct RENAME3res RENAME3res; struct LINK3args { - nfs_fh3 file; - diropargs3 link; + nfs_fh3 file; + diropargs3 link; }; typedef struct LINK3args LINK3args; struct LINK3resok { - post_op_attr file_attributes; - wcc_data linkdir_wcc; + post_op_attr file_attributes; + wcc_data linkdir_wcc; }; typedef struct LINK3resok LINK3resok; struct LINK3resfail { - post_op_attr file_attributes; - wcc_data linkdir_wcc; + post_op_attr file_attributes; + wcc_data linkdir_wcc; }; typedef struct LINK3resfail LINK3resfail; struct LINK3res { - nfsstat3 status; - union { - LINK3resok resok; - LINK3resfail resfail; - } LINK3res_u; + nfsstat3 status; + union { + LINK3resok resok; + LINK3resfail resfail; + } LINK3res_u; }; typedef struct LINK3res LINK3res; struct READDIR3args { - nfs_fh3 dir; - cookie3 cookie; - cookieverf3 cookieverf; - count3 count; + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 count; }; typedef struct READDIR3args READDIR3args; struct entry3 { - fileid3 fileid; - filename3 name; - cookie3 cookie; - struct entry3 *nextentry; + fileid3 fileid; + filename3 name; + cookie3 cookie; + struct entry3 *nextentry; }; typedef struct entry3 entry3; struct dirlist3 { - entry3 *entries; - bool_t eof; + entry3 *entries; + bool_t eof; }; typedef struct dirlist3 dirlist3; struct READDIR3resok { - post_op_attr dir_attributes; - cookieverf3 cookieverf; - dirlist3 reply; + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlist3 reply; }; typedef struct READDIR3resok READDIR3resok; struct READDIR3resfail { - post_op_attr dir_attributes; + post_op_attr dir_attributes; }; typedef struct READDIR3resfail READDIR3resfail; struct READDIR3res { - nfsstat3 status; - union { - READDIR3resok resok; - READDIR3resfail resfail; - } READDIR3res_u; + nfsstat3 status; + union { + READDIR3resok resok; + READDIR3resfail resfail; + } READDIR3res_u; }; typedef struct READDIR3res READDIR3res; struct READDIRPLUS3args { - nfs_fh3 dir; - cookie3 cookie; - cookieverf3 cookieverf; - count3 dircount; - count3 maxcount; + nfs_fh3 dir; + cookie3 cookie; + cookieverf3 cookieverf; + count3 dircount; + count3 maxcount; }; typedef struct READDIRPLUS3args READDIRPLUS3args; struct entryplus3 { - fileid3 fileid; - filename3 name; - cookie3 cookie; - post_op_attr name_attributes; - post_op_fh3 name_handle; - struct entryplus3 *nextentry; + fileid3 fileid; + filename3 name; + cookie3 cookie; + post_op_attr name_attributes; + post_op_fh3 name_handle; + struct entryplus3 *nextentry; }; typedef struct entryplus3 entryplus3; struct dirlistplus3 { - entryplus3 *entries; - bool_t eof; + entryplus3 *entries; + bool_t eof; }; typedef struct dirlistplus3 dirlistplus3; struct READDIRPLUS3resok { - post_op_attr dir_attributes; - cookieverf3 cookieverf; - dirlistplus3 reply; + post_op_attr dir_attributes; + cookieverf3 cookieverf; + dirlistplus3 reply; }; typedef struct READDIRPLUS3resok READDIRPLUS3resok; struct READDIRPLUS3resfail { - post_op_attr dir_attributes; + post_op_attr dir_attributes; }; typedef struct READDIRPLUS3resfail READDIRPLUS3resfail; struct READDIRPLUS3res { - nfsstat3 status; - union { - READDIRPLUS3resok resok; - READDIRPLUS3resfail resfail; - } READDIRPLUS3res_u; + nfsstat3 status; + union { + READDIRPLUS3resok resok; + READDIRPLUS3resfail resfail; + } READDIRPLUS3res_u; }; typedef struct READDIRPLUS3res READDIRPLUS3res; struct FSSTAT3args { - nfs_fh3 fsroot; + nfs_fh3 fsroot; }; typedef struct FSSTAT3args FSSTAT3args; struct FSSTAT3resok { - post_op_attr obj_attributes; - size3 tbytes; - size3 fbytes; - size3 abytes; - size3 tfiles; - size3 ffiles; - size3 afiles; - uint32 invarsec; + post_op_attr obj_attributes; + size3 tbytes; + size3 fbytes; + size3 abytes; + size3 tfiles; + size3 ffiles; + size3 afiles; + uint32 invarsec; }; typedef struct FSSTAT3resok FSSTAT3resok; struct FSSTAT3resfail { - post_op_attr obj_attributes; + post_op_attr obj_attributes; }; typedef struct FSSTAT3resfail FSSTAT3resfail; struct FSSTAT3res { - nfsstat3 status; - union { - FSSTAT3resok resok; - FSSTAT3resfail resfail; - } FSSTAT3res_u; + nfsstat3 status; + union { + FSSTAT3resok resok; + FSSTAT3resfail resfail; + } FSSTAT3res_u; }; typedef struct FSSTAT3res FSSTAT3res; struct FSINFO3args { - nfs_fh3 fsroot; + nfs_fh3 fsroot; }; typedef struct FSINFO3args FSINFO3args; struct FSINFO3resok { - post_op_attr obj_attributes; - uint32 rtmax; - uint32 rtpref; - uint32 rtmult; - uint32 wtmax; - uint32 wtpref; - uint32 wtmult; - uint32 dtpref; - size3 maxfilesize; - nfstime3 time_delta; - uint32 properties; + post_op_attr obj_attributes; + uint32 rtmax; + uint32 rtpref; + uint32 rtmult; + uint32 wtmax; + uint32 wtpref; + uint32 wtmult; + uint32 dtpref; + size3 maxfilesize; + nfstime3 time_delta; + uint32 properties; }; typedef struct FSINFO3resok FSINFO3resok; struct FSINFO3resfail { - post_op_attr obj_attributes; + post_op_attr obj_attributes; }; typedef struct FSINFO3resfail FSINFO3resfail; struct FSINFO3res { - nfsstat3 status; - union { - FSINFO3resok resok; - FSINFO3resfail resfail; - } FSINFO3res_u; + nfsstat3 status; + union { + FSINFO3resok resok; + FSINFO3resfail resfail; + } FSINFO3res_u; }; typedef struct FSINFO3res FSINFO3res; struct PATHCONF3args { - nfs_fh3 object; + nfs_fh3 object; }; typedef struct PATHCONF3args PATHCONF3args; struct PATHCONF3resok { - post_op_attr obj_attributes; - uint32 linkmax; - uint32 name_max; - bool_t no_trunc; - bool_t chown_restricted; - bool_t case_insensitive; - bool_t case_preserving; + post_op_attr obj_attributes; + uint32 linkmax; + uint32 name_max; + bool_t no_trunc; + bool_t chown_restricted; + bool_t case_insensitive; + bool_t case_preserving; }; typedef struct PATHCONF3resok PATHCONF3resok; struct PATHCONF3resfail { - post_op_attr obj_attributes; + post_op_attr obj_attributes; }; typedef struct PATHCONF3resfail PATHCONF3resfail; struct PATHCONF3res { - nfsstat3 status; - union { - PATHCONF3resok resok; - PATHCONF3resfail resfail; - } PATHCONF3res_u; + nfsstat3 status; + union { + PATHCONF3resok resok; + PATHCONF3resfail resfail; + } PATHCONF3res_u; }; typedef struct PATHCONF3res PATHCONF3res; struct COMMIT3args { - nfs_fh3 file; - offset3 offset; - count3 count; + nfs_fh3 file; + offset3 offset; + count3 count; }; typedef struct COMMIT3args COMMIT3args; struct COMMIT3resok { - wcc_data file_wcc; - writeverf3 verf; + wcc_data file_wcc; + writeverf3 verf; }; typedef struct COMMIT3resok COMMIT3resok; struct COMMIT3resfail { - wcc_data file_wcc; + wcc_data file_wcc; }; typedef struct COMMIT3resfail COMMIT3resfail; struct COMMIT3res { - nfsstat3 status; - union { - COMMIT3resok resok; - COMMIT3resfail resfail; - } COMMIT3res_u; + nfsstat3 status; + union { + COMMIT3resok resok; + COMMIT3resfail resfail; + } COMMIT3res_u; }; typedef struct COMMIT3res COMMIT3res; -#define NFS_PROGRAM 100003 -#define NFS_V3 3 +#define NFS_PROGRAM 100003 +#define NFS_V3 3 -#define NFSPROC3_NULL 0 +#define NFSPROC3_NULL 0 extern enum clnt_stat nfsproc3_null_3(void *, CLIENT *); -#define NFSPROC3_GETATTR 1 +#define NFSPROC3_GETATTR 1 extern enum clnt_stat nfsproc3_getattr_3(GETATTR3args , GETATTR3res *, CLIENT *); -#define NFSPROC3_SETATTR 2 +#define NFSPROC3_SETATTR 2 extern enum clnt_stat nfsproc3_setattr_3(SETATTR3args , SETATTR3res *, CLIENT *); -#define NFSPROC3_LOOKUP 3 +#define NFSPROC3_LOOKUP 3 extern enum clnt_stat nfsproc3_lookup_3(LOOKUP3args , LOOKUP3res *, CLIENT *); -#define NFSPROC3_ACCESS 4 +#define NFSPROC3_ACCESS 4 extern enum clnt_stat nfsproc3_access_3(ACCESS3args , ACCESS3res *, CLIENT *); -#define NFSPROC3_READLINK 5 +#define NFSPROC3_READLINK 5 extern enum clnt_stat nfsproc3_readlink_3(READLINK3args , READLINK3res *, CLIENT *); -#define NFSPROC3_READ 6 +#define NFSPROC3_READ 6 extern enum clnt_stat nfsproc3_read_3(READ3args , READ3res *, CLIENT *); -#define NFSPROC3_WRITE 7 +#define NFSPROC3_WRITE 7 extern enum clnt_stat nfsproc3_write_3(WRITE3args , WRITE3res *, CLIENT *); -#define NFSPROC3_CREATE 8 +#define NFSPROC3_CREATE 8 extern enum clnt_stat nfsproc3_create_3(CREATE3args , CREATE3res *, CLIENT *); -#define NFSPROC3_MKDIR 9 +#define NFSPROC3_MKDIR 9 extern enum clnt_stat nfsproc3_mkdir_3(MKDIR3args , MKDIR3res *, CLIENT *); -#define NFSPROC3_SYMLINK 10 +#define NFSPROC3_SYMLINK 10 extern enum clnt_stat nfsproc3_symlink_3(SYMLINK3args , SYMLINK3res *, CLIENT *); -#define NFSPROC3_MKNOD 11 +#define NFSPROC3_MKNOD 11 extern enum clnt_stat nfsproc3_mknod_3(MKNOD3args , MKNOD3res *, CLIENT *); -#define NFSPROC3_REMOVE 12 +#define NFSPROC3_REMOVE 12 extern enum clnt_stat nfsproc3_remove_3(REMOVE3args , REMOVE3res *, CLIENT *); -#define NFSPROC3_RMDIR 13 +#define NFSPROC3_RMDIR 13 extern enum clnt_stat nfsproc3_rmdir_3(RMDIR3args , RMDIR3res *, CLIENT *); -#define NFSPROC3_RENAME 14 +#define NFSPROC3_RENAME 14 extern enum clnt_stat nfsproc3_rename_3(RENAME3args , RENAME3res *, CLIENT *); -#define NFSPROC3_LINK 15 +#define NFSPROC3_LINK 15 extern enum clnt_stat nfsproc3_link_3(LINK3args , LINK3res *, CLIENT *); -#define NFSPROC3_READDIR 16 +#define NFSPROC3_READDIR 16 extern enum clnt_stat nfsproc3_readdir_3(READDIR3args , READDIR3res *, CLIENT *); -#define NFSPROC3_READDIRPLUS 17 +#define NFSPROC3_READDIRPLUS 17 extern enum clnt_stat nfsproc3_readdirplus_3(READDIRPLUS3args , READDIRPLUS3res *, CLIENT *); -#define NFSPROC3_FSSTAT 18 +#define NFSPROC3_FSSTAT 18 extern enum clnt_stat nfsproc3_fsstat_3(FSSTAT3args , FSSTAT3res *, CLIENT *); -#define NFSPROC3_FSINFO 19 +#define NFSPROC3_FSINFO 19 extern enum clnt_stat nfsproc3_fsinfo_3(FSINFO3args , FSINFO3res *, CLIENT *); -#define NFSPROC3_PATHCONF 20 +#define NFSPROC3_PATHCONF 20 extern enum clnt_stat nfsproc3_pathconf_3(PATHCONF3args , PATHCONF3res *, CLIENT *); -#define NFSPROC3_COMMIT 21 +#define NFSPROC3_COMMIT 21 extern enum clnt_stat nfsproc3_commit_3(COMMIT3args , COMMIT3res *, CLIENT *); /* the xdr functions */ diff --git a/components/dfs/filesystems/nfs/nfs_auth.c b/components/dfs/filesystems/nfs/nfs_auth.c index c65a1126a6..4b6be8d498 100644 --- a/components/dfs/filesystems/nfs/nfs_auth.c +++ b/components/dfs/filesystems/nfs/nfs_auth.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/nfs/nfs_clnt.c b/components/dfs/filesystems/nfs/nfs_clnt.c index c17fee9e80..b50cf7ff1d 100644 --- a/components/dfs/filesystems/nfs/nfs_clnt.c +++ b/components/dfs/filesystems/nfs/nfs_clnt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -23,200 +23,200 @@ typedef char* caddr_t; /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; -enum clnt_stat +enum clnt_stat nfsproc3_null_3(void *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_NULL, - (xdrproc_t) xdr_void, (caddr_t) NULL, - (xdrproc_t) xdr_void, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_NULL, + (xdrproc_t) xdr_void, (caddr_t) NULL, + (xdrproc_t) xdr_void, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_getattr_3(GETATTR3args arg1, GETATTR3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_GETATTR, - (xdrproc_t) xdr_GETATTR3args, (caddr_t) &arg1, - (xdrproc_t) xdr_GETATTR3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_GETATTR, + (xdrproc_t) xdr_GETATTR3args, (caddr_t) &arg1, + (xdrproc_t) xdr_GETATTR3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_setattr_3(SETATTR3args arg1, SETATTR3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_SETATTR, - (xdrproc_t) xdr_SETATTR3args, (caddr_t) &arg1, - (xdrproc_t) xdr_SETATTR3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_SETATTR, + (xdrproc_t) xdr_SETATTR3args, (caddr_t) &arg1, + (xdrproc_t) xdr_SETATTR3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_lookup_3(LOOKUP3args arg1, LOOKUP3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_LOOKUP, - (xdrproc_t) xdr_LOOKUP3args, (caddr_t) &arg1, - (xdrproc_t) xdr_LOOKUP3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_LOOKUP, + (xdrproc_t) xdr_LOOKUP3args, (caddr_t) &arg1, + (xdrproc_t) xdr_LOOKUP3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_access_3(ACCESS3args arg1, ACCESS3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_ACCESS, - (xdrproc_t) xdr_ACCESS3args, (caddr_t) &arg1, - (xdrproc_t) xdr_ACCESS3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_ACCESS, + (xdrproc_t) xdr_ACCESS3args, (caddr_t) &arg1, + (xdrproc_t) xdr_ACCESS3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_readlink_3(READLINK3args arg1, READLINK3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_READLINK, - (xdrproc_t) xdr_READLINK3args, (caddr_t) &arg1, - (xdrproc_t) xdr_READLINK3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_READLINK, + (xdrproc_t) xdr_READLINK3args, (caddr_t) &arg1, + (xdrproc_t) xdr_READLINK3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_read_3(READ3args arg1, READ3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_READ, - (xdrproc_t) xdr_READ3args, (caddr_t) &arg1, - (xdrproc_t) xdr_READ3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_READ, + (xdrproc_t) xdr_READ3args, (caddr_t) &arg1, + (xdrproc_t) xdr_READ3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_write_3(WRITE3args arg1, WRITE3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_WRITE, - (xdrproc_t) xdr_WRITE3args, (caddr_t) &arg1, - (xdrproc_t) xdr_WRITE3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_WRITE, + (xdrproc_t) xdr_WRITE3args, (caddr_t) &arg1, + (xdrproc_t) xdr_WRITE3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_create_3(CREATE3args arg1, CREATE3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_CREATE, - (xdrproc_t) xdr_CREATE3args, (caddr_t) &arg1, - (xdrproc_t) xdr_CREATE3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_CREATE, + (xdrproc_t) xdr_CREATE3args, (caddr_t) &arg1, + (xdrproc_t) xdr_CREATE3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_mkdir_3(MKDIR3args arg1, MKDIR3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_MKDIR, - (xdrproc_t) xdr_MKDIR3args, (caddr_t) &arg1, - (xdrproc_t) xdr_MKDIR3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_MKDIR, + (xdrproc_t) xdr_MKDIR3args, (caddr_t) &arg1, + (xdrproc_t) xdr_MKDIR3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_symlink_3(SYMLINK3args arg1, SYMLINK3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_SYMLINK, - (xdrproc_t) xdr_SYMLINK3args, (caddr_t) &arg1, - (xdrproc_t) xdr_SYMLINK3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_SYMLINK, + (xdrproc_t) xdr_SYMLINK3args, (caddr_t) &arg1, + (xdrproc_t) xdr_SYMLINK3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_mknod_3(MKNOD3args arg1, MKNOD3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_MKNOD, - (xdrproc_t) xdr_MKNOD3args, (caddr_t) &arg1, - (xdrproc_t) xdr_MKNOD3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_MKNOD, + (xdrproc_t) xdr_MKNOD3args, (caddr_t) &arg1, + (xdrproc_t) xdr_MKNOD3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_remove_3(REMOVE3args arg1, REMOVE3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_REMOVE, - (xdrproc_t) xdr_REMOVE3args, (caddr_t) &arg1, - (xdrproc_t) xdr_REMOVE3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_REMOVE, + (xdrproc_t) xdr_REMOVE3args, (caddr_t) &arg1, + (xdrproc_t) xdr_REMOVE3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_rmdir_3(RMDIR3args arg1, RMDIR3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_RMDIR, - (xdrproc_t) xdr_RMDIR3args, (caddr_t) &arg1, - (xdrproc_t) xdr_RMDIR3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_RMDIR, + (xdrproc_t) xdr_RMDIR3args, (caddr_t) &arg1, + (xdrproc_t) xdr_RMDIR3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_rename_3(RENAME3args arg1, RENAME3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_RENAME, - (xdrproc_t) xdr_RENAME3args, (caddr_t) &arg1, - (xdrproc_t) xdr_RENAME3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_RENAME, + (xdrproc_t) xdr_RENAME3args, (caddr_t) &arg1, + (xdrproc_t) xdr_RENAME3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_link_3(LINK3args arg1, LINK3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_LINK, - (xdrproc_t) xdr_LINK3args, (caddr_t) &arg1, - (xdrproc_t) xdr_LINK3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_LINK, + (xdrproc_t) xdr_LINK3args, (caddr_t) &arg1, + (xdrproc_t) xdr_LINK3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_readdir_3(READDIR3args arg1, READDIR3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_READDIR, - (xdrproc_t) xdr_READDIR3args, (caddr_t) &arg1, - (xdrproc_t) xdr_READDIR3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_READDIR, + (xdrproc_t) xdr_READDIR3args, (caddr_t) &arg1, + (xdrproc_t) xdr_READDIR3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_readdirplus_3(READDIRPLUS3args arg1, READDIRPLUS3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_READDIRPLUS, - (xdrproc_t) xdr_READDIRPLUS3args, (caddr_t) &arg1, - (xdrproc_t) xdr_READDIRPLUS3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_READDIRPLUS, + (xdrproc_t) xdr_READDIRPLUS3args, (caddr_t) &arg1, + (xdrproc_t) xdr_READDIRPLUS3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_fsstat_3(FSSTAT3args arg1, FSSTAT3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_FSSTAT, - (xdrproc_t) xdr_FSSTAT3args, (caddr_t) &arg1, - (xdrproc_t) xdr_FSSTAT3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_FSSTAT, + (xdrproc_t) xdr_FSSTAT3args, (caddr_t) &arg1, + (xdrproc_t) xdr_FSSTAT3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_fsinfo_3(FSINFO3args arg1, FSINFO3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_FSINFO, - (xdrproc_t) xdr_FSINFO3args, (caddr_t) &arg1, - (xdrproc_t) xdr_FSINFO3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_FSINFO, + (xdrproc_t) xdr_FSINFO3args, (caddr_t) &arg1, + (xdrproc_t) xdr_FSINFO3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_pathconf_3(PATHCONF3args arg1, PATHCONF3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_PATHCONF, - (xdrproc_t) xdr_PATHCONF3args, (caddr_t) &arg1, - (xdrproc_t) xdr_PATHCONF3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_PATHCONF, + (xdrproc_t) xdr_PATHCONF3args, (caddr_t) &arg1, + (xdrproc_t) xdr_PATHCONF3res, (caddr_t) clnt_res, + TIMEOUT)); } -enum clnt_stat +enum clnt_stat nfsproc3_commit_3(COMMIT3args arg1, COMMIT3res *clnt_res, CLIENT *clnt) { - return (clnt_call(clnt, NFSPROC3_COMMIT, - (xdrproc_t) xdr_COMMIT3args, (caddr_t) &arg1, - (xdrproc_t) xdr_COMMIT3res, (caddr_t) clnt_res, - TIMEOUT)); + return (clnt_call(clnt, NFSPROC3_COMMIT, + (xdrproc_t) xdr_COMMIT3args, (caddr_t) &arg1, + (xdrproc_t) xdr_COMMIT3res, (caddr_t) clnt_res, + TIMEOUT)); } diff --git a/components/dfs/filesystems/nfs/nfs_xdr.c b/components/dfs/filesystems/nfs/nfs_xdr.c index 33563976c3..2662a17df6 100644 --- a/components/dfs/filesystems/nfs/nfs_xdr.c +++ b/components/dfs/filesystems/nfs/nfs_xdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -19,1604 +19,1604 @@ bool_t xdr_uint64(register XDR *xdrs, uint64 *objp) { - if (!xdr_u_longlong_t(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_u_longlong_t(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_int64(register XDR *xdrs, int64 *objp) { - if (!xdr_longlong_t(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_longlong_t(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_uint32(register XDR *xdrs, uint32 *objp) { - if (!xdr_u_long(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_u_long(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_int32(register XDR *xdrs, int32 *objp) { - if (!xdr_long(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_long(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_filename3(register XDR *xdrs, filename3 *objp) { - if (!xdr_string(xdrs, objp, ~0)) - return (FALSE); - return (TRUE); + if (!xdr_string(xdrs, objp, ~0)) + return (FALSE); + return (TRUE); } bool_t xdr_nfspath3(register XDR *xdrs, nfspath3 *objp) { - if (!xdr_string(xdrs, objp, ~0)) - return (FALSE); - return (TRUE); + if (!xdr_string(xdrs, objp, ~0)) + return (FALSE); + return (TRUE); } bool_t xdr_fileid3(register XDR *xdrs, fileid3 *objp) { - if (!xdr_uint64(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint64(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_cookie3(register XDR *xdrs, cookie3 *objp) { - if (!xdr_uint64(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint64(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_cookieverf3(register XDR *xdrs, cookieverf3 objp) { - if (!xdr_opaque(xdrs, objp, NFS3_COOKIEVERFSIZE)) - return (FALSE); - return (TRUE); + if (!xdr_opaque(xdrs, objp, NFS3_COOKIEVERFSIZE)) + return (FALSE); + return (TRUE); } bool_t xdr_createverf3(register XDR *xdrs, createverf3 objp) { - if (!xdr_opaque(xdrs, objp, NFS3_CREATEVERFSIZE)) - return (FALSE); - return (TRUE); + if (!xdr_opaque(xdrs, objp, NFS3_CREATEVERFSIZE)) + return (FALSE); + return (TRUE); } bool_t xdr_writeverf3(register XDR *xdrs, writeverf3 objp) { - if (!xdr_opaque(xdrs, objp, NFS3_WRITEVERFSIZE)) - return (FALSE); - return (TRUE); + if (!xdr_opaque(xdrs, objp, NFS3_WRITEVERFSIZE)) + return (FALSE); + return (TRUE); } bool_t xdr_uid3(register XDR *xdrs, uid3 *objp) { - if (!xdr_uint32(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint32(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_gid3(register XDR *xdrs, gid3 *objp) { - if (!xdr_uint32(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint32(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_size3(register XDR *xdrs, size3 *objp) { - if (!xdr_uint64(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint64(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_offset3(register XDR *xdrs, offset3 *objp) { - if (!xdr_uint64(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint64(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_mode3(register XDR *xdrs, mode3 *objp) { - if (!xdr_uint32(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint32(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_count3(register XDR *xdrs, count3 *objp) { - if (!xdr_uint32(xdrs, objp)) - return (FALSE); - return (TRUE); + if (!xdr_uint32(xdrs, objp)) + return (FALSE); + return (TRUE); } bool_t xdr_nfsstat3(register XDR *xdrs, nfsstat3 *objp) { - int enum_objp; - enum_objp = *objp; - if (!xdr_enum(xdrs, (enum_t *)objp)) - { - *objp = (nfsstat3)enum_objp; - return (FALSE); - } + int enum_objp; + enum_objp = *objp; + if (!xdr_enum(xdrs, (enum_t *)objp)) + { + *objp = (nfsstat3)enum_objp; + return (FALSE); + } - return (TRUE); + return (TRUE); } bool_t xdr_ftype3(register XDR *xdrs, ftype3 *objp) { - int enum_objp; - enum_objp = *objp; - if (!xdr_enum(xdrs, (enum_t *)objp)) - { - *objp = (ftype3)enum_objp; - return (FALSE); - } - - return (TRUE); + int enum_objp; + enum_objp = *objp; + if (!xdr_enum(xdrs, (enum_t *)objp)) + { + *objp = (ftype3)enum_objp; + return (FALSE); + } + + return (TRUE); } bool_t xdr_stable_how(register XDR *xdrs, stable_how *objp) { - int enum_objp; - enum_objp = *objp; - if (!xdr_enum(xdrs, (enum_t *)objp)) - { - *objp = (stable_how)enum_objp; - return (FALSE); - } - - return (TRUE); + int enum_objp; + enum_objp = *objp; + if (!xdr_enum(xdrs, (enum_t *)objp)) + { + *objp = (stable_how)enum_objp; + return (FALSE); + } + + return (TRUE); } bool_t xdr_createmode3(register XDR *xdrs, createmode3 *objp) { - int enum_objp; - enum_objp = *objp; - if (!xdr_enum(xdrs, (enum_t *)objp)) - { - *objp = (createmode3)enum_objp; - return (FALSE); - } - - return (TRUE); + int enum_objp; + enum_objp = *objp; + if (!xdr_enum(xdrs, (enum_t *)objp)) + { + *objp = (createmode3)enum_objp; + return (FALSE); + } + + return (TRUE); } bool_t xdr_specdata3(register XDR *xdrs, specdata3 *objp) { - if (!xdr_uint32(xdrs, &objp->specdata1)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->specdata2)) - return (FALSE); - return (TRUE); + if (!xdr_uint32(xdrs, &objp->specdata1)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->specdata2)) + return (FALSE); + return (TRUE); } bool_t xdr_nfs_fh3(register XDR *xdrs, nfs_fh3 *objp) { - if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, NFS3_FHSIZE)) - return (FALSE); - return (TRUE); + if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, NFS3_FHSIZE)) + return (FALSE); + return (TRUE); } bool_t xdr_nfstime3(register XDR *xdrs, nfstime3 *objp) { - if (!xdr_uint32(xdrs, &objp->seconds)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->nseconds)) - return (FALSE); - return (TRUE); + if (!xdr_uint32(xdrs, &objp->seconds)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->nseconds)) + return (FALSE); + return (TRUE); } bool_t xdr_fattr3(register XDR *xdrs, fattr3 *objp) { - if (!xdr_ftype3(xdrs, &objp->type)) - return (FALSE); - if (!xdr_mode3(xdrs, &objp->mode)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->nlink)) - return (FALSE); - if (!xdr_uid3(xdrs, &objp->uid)) - return (FALSE); - if (!xdr_gid3(xdrs, &objp->gid)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->size)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->used)) - return (FALSE); - if (!xdr_specdata3(xdrs, &objp->rdev)) - return (FALSE); - if (!xdr_uint64(xdrs, &objp->fsid)) - return (FALSE); - if (!xdr_fileid3(xdrs, &objp->fileid)) - return (FALSE); - if (!xdr_nfstime3(xdrs, &objp->atime)) - return (FALSE); - if (!xdr_nfstime3(xdrs, &objp->mtime)) - return (FALSE); - if (!xdr_nfstime3(xdrs, &objp->ctime)) - return (FALSE); - return (TRUE); + if (!xdr_ftype3(xdrs, &objp->type)) + return (FALSE); + if (!xdr_mode3(xdrs, &objp->mode)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->nlink)) + return (FALSE); + if (!xdr_uid3(xdrs, &objp->uid)) + return (FALSE); + if (!xdr_gid3(xdrs, &objp->gid)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->size)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->used)) + return (FALSE); + if (!xdr_specdata3(xdrs, &objp->rdev)) + return (FALSE); + if (!xdr_uint64(xdrs, &objp->fsid)) + return (FALSE); + if (!xdr_fileid3(xdrs, &objp->fileid)) + return (FALSE); + if (!xdr_nfstime3(xdrs, &objp->atime)) + return (FALSE); + if (!xdr_nfstime3(xdrs, &objp->mtime)) + return (FALSE); + if (!xdr_nfstime3(xdrs, &objp->ctime)) + return (FALSE); + return (TRUE); } bool_t xdr_post_op_attr(register XDR *xdrs, post_op_attr *objp) { - if (!xdr_bool(xdrs, &objp->attributes_follow)) - return (FALSE); - switch (objp->attributes_follow) { - case TRUE: - if (!xdr_fattr3(xdrs, &objp->post_op_attr_u.attributes)) - return (FALSE); - break; - case FALSE: - break; - default: - return (FALSE); - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->attributes_follow)) + return (FALSE); + switch (objp->attributes_follow) { + case TRUE: + if (!xdr_fattr3(xdrs, &objp->post_op_attr_u.attributes)) + return (FALSE); + break; + case FALSE: + break; + default: + return (FALSE); + } + return (TRUE); } bool_t xdr_wcc_attr(register XDR *xdrs, wcc_attr *objp) { - if (!xdr_size3(xdrs, &objp->size)) - return (FALSE); - if (!xdr_nfstime3(xdrs, &objp->mtime)) - return (FALSE); - if (!xdr_nfstime3(xdrs, &objp->ctime)) - return (FALSE); - return (TRUE); + if (!xdr_size3(xdrs, &objp->size)) + return (FALSE); + if (!xdr_nfstime3(xdrs, &objp->mtime)) + return (FALSE); + if (!xdr_nfstime3(xdrs, &objp->ctime)) + return (FALSE); + return (TRUE); } bool_t xdr_pre_op_attr(register XDR *xdrs, pre_op_attr *objp) { - if (!xdr_bool(xdrs, &objp->attributes_follow)) - return (FALSE); - switch (objp->attributes_follow) { - case TRUE: - if (!xdr_wcc_attr(xdrs, &objp->pre_op_attr_u.attributes)) - return (FALSE); - break; - case FALSE: - break; - default: - return (FALSE); - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->attributes_follow)) + return (FALSE); + switch (objp->attributes_follow) { + case TRUE: + if (!xdr_wcc_attr(xdrs, &objp->pre_op_attr_u.attributes)) + return (FALSE); + break; + case FALSE: + break; + default: + return (FALSE); + } + return (TRUE); } bool_t xdr_wcc_data(register XDR *xdrs, wcc_data *objp) { - if (!xdr_pre_op_attr(xdrs, &objp->before)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->after)) - return (FALSE); - return (TRUE); + if (!xdr_pre_op_attr(xdrs, &objp->before)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->after)) + return (FALSE); + return (TRUE); } bool_t xdr_post_op_fh3(register XDR *xdrs, post_op_fh3 *objp) { - if (!xdr_bool(xdrs, &objp->handle_follows)) - return (FALSE); - switch (objp->handle_follows) { - case TRUE: - if (!xdr_nfs_fh3(xdrs, &objp->post_op_fh3_u.handle)) - return (FALSE); - break; - case FALSE: - break; - default: - return (FALSE); - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->handle_follows)) + return (FALSE); + switch (objp->handle_follows) { + case TRUE: + if (!xdr_nfs_fh3(xdrs, &objp->post_op_fh3_u.handle)) + return (FALSE); + break; + case FALSE: + break; + default: + return (FALSE); + } + return (TRUE); } bool_t xdr_time_how(register XDR *xdrs, time_how *objp) { - int enum_objp; - enum_objp = *objp; - if (!xdr_enum(xdrs, (enum_t *)objp)) - { - *objp = (time_how)enum_objp; - return (FALSE); - } - - return (TRUE); + int enum_objp; + enum_objp = *objp; + if (!xdr_enum(xdrs, (enum_t *)objp)) + { + *objp = (time_how)enum_objp; + return (FALSE); + } + + return (TRUE); } bool_t xdr_set_mode3(register XDR *xdrs, set_mode3 *objp) { - if (!xdr_bool(xdrs, &objp->set_it)) - return (FALSE); - switch (objp->set_it) { - case TRUE: - if (!xdr_mode3(xdrs, &objp->set_mode3_u.mode)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->set_it)) + return (FALSE); + switch (objp->set_it) { + case TRUE: + if (!xdr_mode3(xdrs, &objp->set_mode3_u.mode)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_set_uid3(register XDR *xdrs, set_uid3 *objp) { - if (!xdr_bool(xdrs, &objp->set_it)) - return (FALSE); - switch (objp->set_it) { - case TRUE: - if (!xdr_uid3(xdrs, &objp->set_uid3_u.uid)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->set_it)) + return (FALSE); + switch (objp->set_it) { + case TRUE: + if (!xdr_uid3(xdrs, &objp->set_uid3_u.uid)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_set_gid3(register XDR *xdrs, set_gid3 *objp) { - if (!xdr_bool(xdrs, &objp->set_it)) - return (FALSE); - switch (objp->set_it) { - case TRUE: - if (!xdr_gid3(xdrs, &objp->set_gid3_u.gid)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->set_it)) + return (FALSE); + switch (objp->set_it) { + case TRUE: + if (!xdr_gid3(xdrs, &objp->set_gid3_u.gid)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_set_size3(register XDR *xdrs, set_size3 *objp) { - if (!xdr_bool(xdrs, &objp->set_it)) - return (FALSE); - switch (objp->set_it) { - case TRUE: - if (!xdr_size3(xdrs, &objp->set_size3_u.size)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->set_it)) + return (FALSE); + switch (objp->set_it) { + case TRUE: + if (!xdr_size3(xdrs, &objp->set_size3_u.size)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_set_atime(register XDR *xdrs, set_atime *objp) { - if (!xdr_time_how(xdrs, &objp->set_it)) - return (FALSE); - switch (objp->set_it) { - case SET_TO_CLIENT_TIME: - if (!xdr_nfstime3(xdrs, &objp->set_atime_u.atime)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_time_how(xdrs, &objp->set_it)) + return (FALSE); + switch (objp->set_it) { + case SET_TO_CLIENT_TIME: + if (!xdr_nfstime3(xdrs, &objp->set_atime_u.atime)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_set_mtime(register XDR *xdrs, set_mtime *objp) { - if (!xdr_time_how(xdrs, &objp->set_it)) - return (FALSE); - switch (objp->set_it) { - case SET_TO_CLIENT_TIME: - if (!xdr_nfstime3(xdrs, &objp->set_mtime_u.mtime)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_time_how(xdrs, &objp->set_it)) + return (FALSE); + switch (objp->set_it) { + case SET_TO_CLIENT_TIME: + if (!xdr_nfstime3(xdrs, &objp->set_mtime_u.mtime)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_sattr3(register XDR *xdrs, sattr3 *objp) { - if (!xdr_set_mode3(xdrs, &objp->mode)) - return (FALSE); - if (!xdr_set_uid3(xdrs, &objp->uid)) - return (FALSE); - if (!xdr_set_gid3(xdrs, &objp->gid)) - return (FALSE); - if (!xdr_set_size3(xdrs, &objp->size)) - return (FALSE); - if (!xdr_set_atime(xdrs, &objp->atime)) - return (FALSE); - if (!xdr_set_mtime(xdrs, &objp->mtime)) - return (FALSE); - return (TRUE); + if (!xdr_set_mode3(xdrs, &objp->mode)) + return (FALSE); + if (!xdr_set_uid3(xdrs, &objp->uid)) + return (FALSE); + if (!xdr_set_gid3(xdrs, &objp->gid)) + return (FALSE); + if (!xdr_set_size3(xdrs, &objp->size)) + return (FALSE); + if (!xdr_set_atime(xdrs, &objp->atime)) + return (FALSE); + if (!xdr_set_mtime(xdrs, &objp->mtime)) + return (FALSE); + return (TRUE); } bool_t xdr_diropargs3(register XDR *xdrs, diropargs3 *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->dir)) - return (FALSE); - if (!xdr_filename3(xdrs, &objp->name)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->dir)) + return (FALSE); + if (!xdr_filename3(xdrs, &objp->name)) + return (FALSE); + return (TRUE); } bool_t xdr_GETATTR3args(register XDR *xdrs, GETATTR3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->object)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->object)) + return (FALSE); + return (TRUE); } bool_t xdr_GETATTR3resok(register XDR *xdrs, GETATTR3resok *objp) { - if (!xdr_fattr3(xdrs, &objp->obj_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_fattr3(xdrs, &objp->obj_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_GETATTR3res(register XDR *xdrs, GETATTR3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_GETATTR3resok(xdrs, &objp->GETATTR3res_u.resok)) - return (FALSE); - break; - default : - return (FALSE); - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_GETATTR3resok(xdrs, &objp->GETATTR3res_u.resok)) + return (FALSE); + break; + default : + return (FALSE); + } + return (TRUE); } bool_t xdr_sattrguard3(register XDR *xdrs, sattrguard3 *objp) { - if (!xdr_bool(xdrs, &objp->check)) - return (FALSE); - switch (objp->check) { - case TRUE: - if (!xdr_nfstime3(xdrs, &objp->sattrguard3_u.obj_ctime)) - return (FALSE); - break; - case FALSE: - break; - default: - return (FALSE); - } - return (TRUE); + if (!xdr_bool(xdrs, &objp->check)) + return (FALSE); + switch (objp->check) { + case TRUE: + if (!xdr_nfstime3(xdrs, &objp->sattrguard3_u.obj_ctime)) + return (FALSE); + break; + case FALSE: + break; + default: + return (FALSE); + } + return (TRUE); } bool_t xdr_SETATTR3args(register XDR *xdrs, SETATTR3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->object)) - return (FALSE); - if (!xdr_sattr3(xdrs, &objp->new_attributes)) - return (FALSE); - if (!xdr_sattrguard3(xdrs, &objp->guard)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->object)) + return (FALSE); + if (!xdr_sattr3(xdrs, &objp->new_attributes)) + return (FALSE); + if (!xdr_sattrguard3(xdrs, &objp->guard)) + return (FALSE); + return (TRUE); } bool_t xdr_SETATTR3resok(register XDR *xdrs, SETATTR3resok *objp) { - if (!xdr_wcc_data(xdrs, &objp->obj_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->obj_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_SETATTR3resfail(register XDR *xdrs, SETATTR3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->obj_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->obj_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_SETATTR3res(register XDR *xdrs, SETATTR3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_SETATTR3resok(xdrs, &objp->SETATTR3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_SETATTR3resfail(xdrs, &objp->SETATTR3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_SETATTR3resok(xdrs, &objp->SETATTR3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_SETATTR3resfail(xdrs, &objp->SETATTR3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_LOOKUP3args(register XDR *xdrs, LOOKUP3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->what)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->what)) + return (FALSE); + return (TRUE); } bool_t xdr_LOOKUP3resok(register XDR *xdrs, LOOKUP3resok *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->object)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->object)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_LOOKUP3resfail(register XDR *xdrs, LOOKUP3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_LOOKUP3res(register XDR *xdrs, LOOKUP3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_LOOKUP3resok(xdrs, &objp->LOOKUP3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_LOOKUP3resfail(xdrs, &objp->LOOKUP3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_LOOKUP3resok(xdrs, &objp->LOOKUP3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_LOOKUP3resfail(xdrs, &objp->LOOKUP3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_ACCESS3args(register XDR *xdrs, ACCESS3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->object)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->access)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->object)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->access)) + return (FALSE); + return (TRUE); } bool_t xdr_ACCESS3resok(register XDR *xdrs, ACCESS3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->access)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->access)) + return (FALSE); + return (TRUE); } bool_t xdr_ACCESS3resfail(register XDR *xdrs, ACCESS3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_ACCESS3res(register XDR *xdrs, ACCESS3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_ACCESS3resok(xdrs, &objp->ACCESS3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_ACCESS3resfail(xdrs, &objp->ACCESS3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_ACCESS3resok(xdrs, &objp->ACCESS3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_ACCESS3resfail(xdrs, &objp->ACCESS3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_READLINK3args(register XDR *xdrs, READLINK3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->symlink)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->symlink)) + return (FALSE); + return (TRUE); } bool_t xdr_READLINK3resok(register XDR *xdrs, READLINK3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->symlink_attributes)) - return (FALSE); - if (!xdr_nfspath3(xdrs, &objp->data)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->symlink_attributes)) + return (FALSE); + if (!xdr_nfspath3(xdrs, &objp->data)) + return (FALSE); + return (TRUE); } bool_t xdr_READLINK3resfail(register XDR *xdrs, READLINK3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->symlink_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->symlink_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_READLINK3res(register XDR *xdrs, READLINK3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_READLINK3resok(xdrs, &objp->READLINK3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_READLINK3resfail(xdrs, &objp->READLINK3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_READLINK3resok(xdrs, &objp->READLINK3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_READLINK3resfail(xdrs, &objp->READLINK3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_READ3args(register XDR *xdrs, READ3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->file)) - return (FALSE); - if (!xdr_offset3(xdrs, &objp->offset)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->count)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->file)) + return (FALSE); + if (!xdr_offset3(xdrs, &objp->offset)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->count)) + return (FALSE); + return (TRUE); } bool_t xdr_READ3resok(register XDR *xdrs, READ3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->count)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->eof)) - return (FALSE); - if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, ~0)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->count)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->eof)) + return (FALSE); + if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, ~0)) + return (FALSE); + return (TRUE); } bool_t xdr_READ3resfail(register XDR *xdrs, READ3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_READ3res(register XDR *xdrs, READ3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_READ3resok(xdrs, &objp->READ3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_READ3resfail(xdrs, &objp->READ3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_READ3resok(xdrs, &objp->READ3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_READ3resfail(xdrs, &objp->READ3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_WRITE3args(register XDR *xdrs, WRITE3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->file)) - return (FALSE); - if (!xdr_offset3(xdrs, &objp->offset)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->count)) - return (FALSE); - if (!xdr_stable_how(xdrs, &objp->stable)) - return (FALSE); - if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, ~0)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->file)) + return (FALSE); + if (!xdr_offset3(xdrs, &objp->offset)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->count)) + return (FALSE); + if (!xdr_stable_how(xdrs, &objp->stable)) + return (FALSE); + if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (unsigned int *) &objp->data.data_len, ~0)) + return (FALSE); + return (TRUE); } bool_t xdr_WRITE3resok(register XDR *xdrs, WRITE3resok *objp) { - if (!xdr_wcc_data(xdrs, &objp->file_wcc)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->count)) - return (FALSE); - if (!xdr_stable_how(xdrs, &objp->committed)) - return (FALSE); - if (!xdr_writeverf3(xdrs, objp->verf)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->file_wcc)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->count)) + return (FALSE); + if (!xdr_stable_how(xdrs, &objp->committed)) + return (FALSE); + if (!xdr_writeverf3(xdrs, objp->verf)) + return (FALSE); + return (TRUE); } bool_t xdr_WRITE3resfail(register XDR *xdrs, WRITE3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->file_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->file_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_WRITE3res(register XDR *xdrs, WRITE3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_WRITE3resok(xdrs, &objp->WRITE3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_WRITE3resfail(xdrs, &objp->WRITE3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_WRITE3resok(xdrs, &objp->WRITE3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_WRITE3resfail(xdrs, &objp->WRITE3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_createhow3(register XDR *xdrs, createhow3 *objp) { - if (!xdr_createmode3(xdrs, &objp->mode)) - return (FALSE); - switch (objp->mode) { - case UNCHECKED: - case GUARDED: - if (!xdr_sattr3(xdrs, &objp->createhow3_u.obj_attributes)) - return (FALSE); - break; - case EXCLUSIVE: - if (!xdr_createverf3(xdrs, objp->createhow3_u.verf)) - return (FALSE); - break; - default: - return (FALSE); - } - return (TRUE); + if (!xdr_createmode3(xdrs, &objp->mode)) + return (FALSE); + switch (objp->mode) { + case UNCHECKED: + case GUARDED: + if (!xdr_sattr3(xdrs, &objp->createhow3_u.obj_attributes)) + return (FALSE); + break; + case EXCLUSIVE: + if (!xdr_createverf3(xdrs, objp->createhow3_u.verf)) + return (FALSE); + break; + default: + return (FALSE); + } + return (TRUE); } bool_t xdr_CREATE3args(register XDR *xdrs, CREATE3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->where)) - return (FALSE); - if (!xdr_createhow3(xdrs, &objp->how)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->where)) + return (FALSE); + if (!xdr_createhow3(xdrs, &objp->how)) + return (FALSE); + return (TRUE); } bool_t xdr_CREATE3resok(register XDR *xdrs, CREATE3resok *objp) { - if (!xdr_post_op_fh3(xdrs, &objp->obj)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_fh3(xdrs, &objp->obj)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_CREATE3resfail(register XDR *xdrs, CREATE3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_CREATE3res(register XDR *xdrs, CREATE3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_CREATE3resok(xdrs, &objp->CREATE3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_CREATE3resfail(xdrs, &objp->CREATE3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_CREATE3resok(xdrs, &objp->CREATE3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_CREATE3resfail(xdrs, &objp->CREATE3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_MKDIR3args(register XDR *xdrs, MKDIR3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->where)) - return (FALSE); - if (!xdr_sattr3(xdrs, &objp->attributes)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->where)) + return (FALSE); + if (!xdr_sattr3(xdrs, &objp->attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_MKDIR3resok(register XDR *xdrs, MKDIR3resok *objp) { - if (!xdr_post_op_fh3(xdrs, &objp->obj)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_fh3(xdrs, &objp->obj)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_MKDIR3resfail(register XDR *xdrs, MKDIR3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_MKDIR3res(register XDR *xdrs, MKDIR3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_MKDIR3resok(xdrs, &objp->MKDIR3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_MKDIR3resfail(xdrs, &objp->MKDIR3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_MKDIR3resok(xdrs, &objp->MKDIR3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_MKDIR3resfail(xdrs, &objp->MKDIR3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_symlinkdata3(register XDR *xdrs, symlinkdata3 *objp) { - if (!xdr_sattr3(xdrs, &objp->symlink_attributes)) - return (FALSE); - if (!xdr_nfspath3(xdrs, &objp->symlink_data)) - return (FALSE); - return (TRUE); + if (!xdr_sattr3(xdrs, &objp->symlink_attributes)) + return (FALSE); + if (!xdr_nfspath3(xdrs, &objp->symlink_data)) + return (FALSE); + return (TRUE); } bool_t xdr_SYMLINK3args(register XDR *xdrs, SYMLINK3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->where)) - return (FALSE); - if (!xdr_symlinkdata3(xdrs, &objp->symlink)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->where)) + return (FALSE); + if (!xdr_symlinkdata3(xdrs, &objp->symlink)) + return (FALSE); + return (TRUE); } bool_t xdr_SYMLINK3resok(register XDR *xdrs, SYMLINK3resok *objp) { - if (!xdr_post_op_fh3(xdrs, &objp->obj)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_fh3(xdrs, &objp->obj)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_SYMLINK3resfail(register XDR *xdrs, SYMLINK3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_SYMLINK3res(register XDR *xdrs, SYMLINK3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_SYMLINK3resok(xdrs, &objp->SYMLINK3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_SYMLINK3resfail(xdrs, &objp->SYMLINK3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_SYMLINK3resok(xdrs, &objp->SYMLINK3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_SYMLINK3resfail(xdrs, &objp->SYMLINK3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_devicedata3(register XDR *xdrs, devicedata3 *objp) { - if (!xdr_sattr3(xdrs, &objp->dev_attributes)) - return (FALSE); - if (!xdr_specdata3(xdrs, &objp->spec)) - return (FALSE); - return (TRUE); + if (!xdr_sattr3(xdrs, &objp->dev_attributes)) + return (FALSE); + if (!xdr_specdata3(xdrs, &objp->spec)) + return (FALSE); + return (TRUE); } bool_t xdr_mknoddata3(register XDR *xdrs, mknoddata3 *objp) { - if (!xdr_ftype3(xdrs, &objp->type)) - return (FALSE); - switch (objp->type) { - case NFS3CHR: - case NFS3BLK: - if (!xdr_devicedata3(xdrs, &objp->mknoddata3_u.device)) - return (FALSE); - break; - case NFS3SOCK: - case NFS3FIFO: - if (!xdr_sattr3(xdrs, &objp->mknoddata3_u.pipe_attributes)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_ftype3(xdrs, &objp->type)) + return (FALSE); + switch (objp->type) { + case NFS3CHR: + case NFS3BLK: + if (!xdr_devicedata3(xdrs, &objp->mknoddata3_u.device)) + return (FALSE); + break; + case NFS3SOCK: + case NFS3FIFO: + if (!xdr_sattr3(xdrs, &objp->mknoddata3_u.pipe_attributes)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_MKNOD3args(register XDR *xdrs, MKNOD3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->where)) - return (FALSE); - if (!xdr_mknoddata3(xdrs, &objp->what)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->where)) + return (FALSE); + if (!xdr_mknoddata3(xdrs, &objp->what)) + return (FALSE); + return (TRUE); } bool_t xdr_MKNOD3resok(register XDR *xdrs, MKNOD3resok *objp) { - if (!xdr_post_op_fh3(xdrs, &objp->obj)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_fh3(xdrs, &objp->obj)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_MKNOD3resfail(register XDR *xdrs, MKNOD3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_MKNOD3res(register XDR *xdrs, MKNOD3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_MKNOD3resok(xdrs, &objp->MKNOD3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_MKNOD3resfail(xdrs, &objp->MKNOD3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_MKNOD3resok(xdrs, &objp->MKNOD3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_MKNOD3resfail(xdrs, &objp->MKNOD3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_REMOVE3args(register XDR *xdrs, REMOVE3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->object)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->object)) + return (FALSE); + return (TRUE); } bool_t xdr_REMOVE3resok(register XDR *xdrs, REMOVE3resok *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_REMOVE3resfail(register XDR *xdrs, REMOVE3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_REMOVE3res(register XDR *xdrs, REMOVE3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_REMOVE3resok(xdrs, &objp->REMOVE3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_REMOVE3resfail(xdrs, &objp->REMOVE3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_REMOVE3resok(xdrs, &objp->REMOVE3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_REMOVE3resfail(xdrs, &objp->REMOVE3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_RMDIR3args(register XDR *xdrs, RMDIR3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->object)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->object)) + return (FALSE); + return (TRUE); } bool_t xdr_RMDIR3resok(register XDR *xdrs, RMDIR3resok *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_RMDIR3resfail(register XDR *xdrs, RMDIR3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->dir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_RMDIR3res(register XDR *xdrs, RMDIR3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_RMDIR3resok(xdrs, &objp->RMDIR3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_RMDIR3resfail(xdrs, &objp->RMDIR3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_RMDIR3resok(xdrs, &objp->RMDIR3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_RMDIR3resfail(xdrs, &objp->RMDIR3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_RENAME3args(register XDR *xdrs, RENAME3args *objp) { - if (!xdr_diropargs3(xdrs, &objp->from)) - return (FALSE); - if (!xdr_diropargs3(xdrs, &objp->to)) - return (FALSE); - return (TRUE); + if (!xdr_diropargs3(xdrs, &objp->from)) + return (FALSE); + if (!xdr_diropargs3(xdrs, &objp->to)) + return (FALSE); + return (TRUE); } bool_t xdr_RENAME3resok(register XDR *xdrs, RENAME3resok *objp) { - if (!xdr_wcc_data(xdrs, &objp->fromdir_wcc)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->todir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->fromdir_wcc)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->todir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_RENAME3resfail(register XDR *xdrs, RENAME3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->fromdir_wcc)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->todir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->fromdir_wcc)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->todir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_RENAME3res(register XDR *xdrs, RENAME3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_RENAME3resok(xdrs, &objp->RENAME3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_RENAME3resfail(xdrs, &objp->RENAME3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_RENAME3resok(xdrs, &objp->RENAME3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_RENAME3resfail(xdrs, &objp->RENAME3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_LINK3args(register XDR *xdrs, LINK3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->file)) - return (FALSE); - if (!xdr_diropargs3(xdrs, &objp->link)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->file)) + return (FALSE); + if (!xdr_diropargs3(xdrs, &objp->link)) + return (FALSE); + return (TRUE); } bool_t xdr_LINK3resok(register XDR *xdrs, LINK3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->linkdir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->linkdir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_LINK3resfail(register XDR *xdrs, LINK3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) - return (FALSE); - if (!xdr_wcc_data(xdrs, &objp->linkdir_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->file_attributes)) + return (FALSE); + if (!xdr_wcc_data(xdrs, &objp->linkdir_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_LINK3res(register XDR *xdrs, LINK3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_LINK3resok(xdrs, &objp->LINK3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_LINK3resfail(xdrs, &objp->LINK3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_LINK3resok(xdrs, &objp->LINK3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_LINK3resfail(xdrs, &objp->LINK3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_READDIR3args(register XDR *xdrs, READDIR3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->dir)) - return (FALSE); - if (!xdr_cookie3(xdrs, &objp->cookie)) - return (FALSE); - if (!xdr_cookieverf3(xdrs, objp->cookieverf)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->count)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->dir)) + return (FALSE); + if (!xdr_cookie3(xdrs, &objp->cookie)) + return (FALSE); + if (!xdr_cookieverf3(xdrs, objp->cookieverf)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->count)) + return (FALSE); + return (TRUE); } bool_t xdr_entry3(register XDR *xdrs, entry3 *objp) { - if (!xdr_fileid3(xdrs, &objp->fileid)) - return (FALSE); - if (!xdr_filename3(xdrs, &objp->name)) - return (FALSE); - if (!xdr_cookie3(xdrs, &objp->cookie)) - return (FALSE); - if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof (entry3), (xdrproc_t) xdr_entry3)) - return (FALSE); - return (TRUE); + if (!xdr_fileid3(xdrs, &objp->fileid)) + return (FALSE); + if (!xdr_filename3(xdrs, &objp->name)) + return (FALSE); + if (!xdr_cookie3(xdrs, &objp->cookie)) + return (FALSE); + if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof (entry3), (xdrproc_t) xdr_entry3)) + return (FALSE); + return (TRUE); } bool_t xdr_dirlist3(register XDR *xdrs, dirlist3 *objp) { - if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof (entry3), (xdrproc_t) xdr_entry3)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->eof)) - return (FALSE); - return (TRUE); + if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof (entry3), (xdrproc_t) xdr_entry3)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->eof)) + return (FALSE); + return (TRUE); } bool_t xdr_READDIR3resok(register XDR *xdrs, READDIR3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) - return (FALSE); - if (!xdr_cookieverf3(xdrs, objp->cookieverf)) - return (FALSE); - if (!xdr_dirlist3(xdrs, &objp->reply)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + return (FALSE); + if (!xdr_cookieverf3(xdrs, objp->cookieverf)) + return (FALSE); + if (!xdr_dirlist3(xdrs, &objp->reply)) + return (FALSE); + return (TRUE); } bool_t xdr_READDIR3resfail(register XDR *xdrs, READDIR3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_READDIR3res(register XDR *xdrs, READDIR3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_READDIR3resok(xdrs, &objp->READDIR3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_READDIR3resfail(xdrs, &objp->READDIR3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_READDIR3resok(xdrs, &objp->READDIR3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_READDIR3resfail(xdrs, &objp->READDIR3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_READDIRPLUS3args(register XDR *xdrs, READDIRPLUS3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->dir)) - return (FALSE); - if (!xdr_cookie3(xdrs, &objp->cookie)) - return (FALSE); - if (!xdr_cookieverf3(xdrs, objp->cookieverf)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->dircount)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->maxcount)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->dir)) + return (FALSE); + if (!xdr_cookie3(xdrs, &objp->cookie)) + return (FALSE); + if (!xdr_cookieverf3(xdrs, objp->cookieverf)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->dircount)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->maxcount)) + return (FALSE); + return (TRUE); } bool_t xdr_entryplus3(register XDR *xdrs, entryplus3 *objp) { - if (!xdr_fileid3(xdrs, &objp->fileid)) - return (FALSE); - if (!xdr_filename3(xdrs, &objp->name)) - return (FALSE); - if (!xdr_cookie3(xdrs, &objp->cookie)) - return (FALSE); - if (!xdr_post_op_attr(xdrs, &objp->name_attributes)) - return (FALSE); - if (!xdr_post_op_fh3(xdrs, &objp->name_handle)) - return (FALSE); - if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof (entryplus3), (xdrproc_t) xdr_entryplus3)) - return (FALSE); - return (TRUE); + if (!xdr_fileid3(xdrs, &objp->fileid)) + return (FALSE); + if (!xdr_filename3(xdrs, &objp->name)) + return (FALSE); + if (!xdr_cookie3(xdrs, &objp->cookie)) + return (FALSE); + if (!xdr_post_op_attr(xdrs, &objp->name_attributes)) + return (FALSE); + if (!xdr_post_op_fh3(xdrs, &objp->name_handle)) + return (FALSE); + if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof (entryplus3), (xdrproc_t) xdr_entryplus3)) + return (FALSE); + return (TRUE); } bool_t xdr_dirlistplus3(register XDR *xdrs, dirlistplus3 *objp) { - if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof (entryplus3), (xdrproc_t) xdr_entryplus3)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->eof)) - return (FALSE); - return (TRUE); + if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof (entryplus3), (xdrproc_t) xdr_entryplus3)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->eof)) + return (FALSE); + return (TRUE); } bool_t xdr_READDIRPLUS3resok(register XDR *xdrs, READDIRPLUS3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) - return (FALSE); - if (!xdr_cookieverf3(xdrs, objp->cookieverf)) - return (FALSE); - if (!xdr_dirlistplus3(xdrs, &objp->reply)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + return (FALSE); + if (!xdr_cookieverf3(xdrs, objp->cookieverf)) + return (FALSE); + if (!xdr_dirlistplus3(xdrs, &objp->reply)) + return (FALSE); + return (TRUE); } bool_t xdr_READDIRPLUS3resfail(register XDR *xdrs, READDIRPLUS3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->dir_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_READDIRPLUS3res(register XDR *xdrs, READDIRPLUS3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_READDIRPLUS3resok(xdrs, &objp->READDIRPLUS3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_READDIRPLUS3resfail(xdrs, &objp->READDIRPLUS3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_READDIRPLUS3resok(xdrs, &objp->READDIRPLUS3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_READDIRPLUS3resfail(xdrs, &objp->READDIRPLUS3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_FSSTAT3args(register XDR *xdrs, FSSTAT3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->fsroot)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->fsroot)) + return (FALSE); + return (TRUE); } bool_t xdr_FSSTAT3resok(register XDR *xdrs, FSSTAT3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->tbytes)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->fbytes)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->abytes)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->tfiles)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->ffiles)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->afiles)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->invarsec)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->tbytes)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->fbytes)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->abytes)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->tfiles)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->ffiles)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->afiles)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->invarsec)) + return (FALSE); + return (TRUE); } bool_t xdr_FSSTAT3resfail(register XDR *xdrs, FSSTAT3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_FSSTAT3res(register XDR *xdrs, FSSTAT3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_FSSTAT3resok(xdrs, &objp->FSSTAT3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_FSSTAT3resfail(xdrs, &objp->FSSTAT3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_FSSTAT3resok(xdrs, &objp->FSSTAT3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_FSSTAT3resfail(xdrs, &objp->FSSTAT3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_FSINFO3args(register XDR *xdrs, FSINFO3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->fsroot)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->fsroot)) + return (FALSE); + return (TRUE); } bool_t xdr_FSINFO3resok(register XDR *xdrs, FSINFO3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->rtmax)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->rtpref)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->rtmult)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->wtmax)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->wtpref)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->wtmult)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->dtpref)) - return (FALSE); - if (!xdr_size3(xdrs, &objp->maxfilesize)) - return (FALSE); - if (!xdr_nfstime3(xdrs, &objp->time_delta)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->properties)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->rtmax)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->rtpref)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->rtmult)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->wtmax)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->wtpref)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->wtmult)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->dtpref)) + return (FALSE); + if (!xdr_size3(xdrs, &objp->maxfilesize)) + return (FALSE); + if (!xdr_nfstime3(xdrs, &objp->time_delta)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->properties)) + return (FALSE); + return (TRUE); } bool_t xdr_FSINFO3resfail(register XDR *xdrs, FSINFO3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_FSINFO3res(register XDR *xdrs, FSINFO3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_FSINFO3resok(xdrs, &objp->FSINFO3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_FSINFO3resfail(xdrs, &objp->FSINFO3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_FSINFO3resok(xdrs, &objp->FSINFO3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_FSINFO3resfail(xdrs, &objp->FSINFO3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_PATHCONF3args(register XDR *xdrs, PATHCONF3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->object)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->object)) + return (FALSE); + return (TRUE); } bool_t xdr_PATHCONF3resok(register XDR *xdrs, PATHCONF3resok *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->linkmax)) - return (FALSE); - if (!xdr_uint32(xdrs, &objp->name_max)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->no_trunc)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->chown_restricted)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->case_insensitive)) - return (FALSE); - if (!xdr_bool(xdrs, &objp->case_preserving)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->linkmax)) + return (FALSE); + if (!xdr_uint32(xdrs, &objp->name_max)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->no_trunc)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->chown_restricted)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->case_insensitive)) + return (FALSE); + if (!xdr_bool(xdrs, &objp->case_preserving)) + return (FALSE); + return (TRUE); } bool_t xdr_PATHCONF3resfail(register XDR *xdrs, PATHCONF3resfail *objp) { - if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) - return (FALSE); - return (TRUE); + if (!xdr_post_op_attr(xdrs, &objp->obj_attributes)) + return (FALSE); + return (TRUE); } bool_t xdr_PATHCONF3res(register XDR *xdrs, PATHCONF3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_PATHCONF3resok(xdrs, &objp->PATHCONF3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_PATHCONF3resfail(xdrs, &objp->PATHCONF3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_PATHCONF3resok(xdrs, &objp->PATHCONF3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_PATHCONF3resfail(xdrs, &objp->PATHCONF3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } bool_t xdr_COMMIT3args(register XDR *xdrs, COMMIT3args *objp) { - if (!xdr_nfs_fh3(xdrs, &objp->file)) - return (FALSE); - if (!xdr_offset3(xdrs, &objp->offset)) - return (FALSE); - if (!xdr_count3(xdrs, &objp->count)) - return (FALSE); - return (TRUE); + if (!xdr_nfs_fh3(xdrs, &objp->file)) + return (FALSE); + if (!xdr_offset3(xdrs, &objp->offset)) + return (FALSE); + if (!xdr_count3(xdrs, &objp->count)) + return (FALSE); + return (TRUE); } bool_t xdr_COMMIT3resok(register XDR *xdrs, COMMIT3resok *objp) { - if (!xdr_wcc_data(xdrs, &objp->file_wcc)) - return (FALSE); - if (!xdr_writeverf3(xdrs, objp->verf)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->file_wcc)) + return (FALSE); + if (!xdr_writeverf3(xdrs, objp->verf)) + return (FALSE); + return (TRUE); } bool_t xdr_COMMIT3resfail(register XDR *xdrs, COMMIT3resfail *objp) { - if (!xdr_wcc_data(xdrs, &objp->file_wcc)) - return (FALSE); - return (TRUE); + if (!xdr_wcc_data(xdrs, &objp->file_wcc)) + return (FALSE); + return (TRUE); } bool_t xdr_COMMIT3res(register XDR *xdrs, COMMIT3res *objp) { - if (!xdr_nfsstat3(xdrs, &objp->status)) - return (FALSE); - switch (objp->status) { - case NFS3_OK: - if (!xdr_COMMIT3resok(xdrs, &objp->COMMIT3res_u.resok)) - return (FALSE); - break; - default: - if (!xdr_COMMIT3resfail(xdrs, &objp->COMMIT3res_u.resfail)) - return (FALSE); - break; - } - return (TRUE); + if (!xdr_nfsstat3(xdrs, &objp->status)) + return (FALSE); + switch (objp->status) { + case NFS3_OK: + if (!xdr_COMMIT3resok(xdrs, &objp->COMMIT3res_u.resok)) + return (FALSE); + break; + default: + if (!xdr_COMMIT3resfail(xdrs, &objp->COMMIT3res_u.resfail)) + return (FALSE); + break; + } + return (TRUE); } diff --git a/components/dfs/filesystems/nfs/rpc/auth.h b/components/dfs/filesystems/nfs/rpc/auth.h index f7dd76c237..0dc947a887 100644 --- a/components/dfs/filesystems/nfs/rpc/auth.h +++ b/components/dfs/filesystems/nfs/rpc/auth.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -15,28 +15,28 @@ * Status returned from authentication check */ enum auth_stat { - AUTH_OK=0, - /* - * failed at remote end - */ - AUTH_BADCRED=1, /* bogus credentials (seal broken) */ - AUTH_REJECTEDCRED=2, /* client should begin new session */ - AUTH_BADVERF=3, /* bogus verifier (seal broken) */ - AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ - AUTH_TOOWEAK=5, /* rejected due to security reasons */ - /* - * failed locally - */ - AUTH_INVALIDRESP=6, /* bogus response verifier */ - AUTH_FAILED=7 /* some unknown reason */ + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ }; union des_block { - struct { - uint32_t high; - uint32_t low; - } key; - char c[8]; + struct { + uint32_t high; + uint32_t low; + } key; + char c[8]; }; typedef union des_block des_block; @@ -44,9 +44,9 @@ typedef union des_block des_block; * Authentication info. Opaque to client. */ struct opaque_auth { - enum_t oa_flavor; /* flavor of auth */ - char* oa_base; /* address of more auth stuff */ - unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */ + enum_t oa_flavor; /* flavor of auth */ + char* oa_base; /* address of more auth stuff */ + unsigned int oa_length; /* not to exceed MAX_AUTH_BYTES */ }; /* @@ -59,11 +59,11 @@ struct AUTH { union des_block ah_key; struct auth_ops { void (*ah_nextverf) (AUTH *); - int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ + int (*ah_marshal) (AUTH *, XDR *); /* nextverf & serialize */ int (*ah_validate) (AUTH *, struct opaque_auth *); - /* validate verifier */ - int (*ah_refresh) (AUTH *); /* refresh credentials */ - void (*ah_destroy) (AUTH *); /* destroy this structure */ + /* validate verifier */ + int (*ah_refresh) (AUTH *); /* refresh credentials */ + void (*ah_destroy) (AUTH *); /* destroy this structure */ } *ah_ops; char* ah_private; }; @@ -75,37 +75,37 @@ extern struct opaque_auth _null_auth; * Authentication ops. * The ops and the auth handle provide the interface to the authenticators. * - * AUTH *auth; - * XDR *xdrs; + * AUTH *auth; + * XDR *xdrs; * struct opaque_auth verf; */ -#define AUTH_NEXTVERF(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) -#define auth_nextverf(auth) \ - ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) -#define AUTH_MARSHALL(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) -#define auth_marshall(auth, xdrs) \ - ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) -#define AUTH_VALIDATE(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) -#define auth_validate(auth, verfp) \ - ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) -#define AUTH_REFRESH(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) -#define auth_refresh(auth) \ - ((*((auth)->ah_ops->ah_refresh))(auth)) +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) -#define AUTH_DESTROY(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)) -#define auth_destroy(auth) \ - ((*((auth)->ah_ops->ah_destroy))(auth)) +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) -#define MAX_AUTH_BYTES 400 -#define MAXNETNAMELEN 255 /* maximum length of network user's name */ +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ AUTH *authnone_create(void); diff --git a/components/dfs/filesystems/nfs/rpc/auth_none.c b/components/dfs/filesystems/nfs/rpc/auth_none.c index 9f5ad05002..7e22e7d864 100644 --- a/components/dfs/filesystems/nfs/rpc/auth_none.c +++ b/components/dfs/filesystems/nfs/rpc/auth_none.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */ +/* @(#)auth_none.c 2.1 88/07/29 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -14,23 +14,23 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 @@ -38,15 +38,15 @@ #if !defined(lint) && defined(SCCSIDS) static char sccsid[] = - "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; + "@(#)auth_none.c 1.19 87/08/11 Copyr 1984 Sun Micro"; #endif /* * auth_none.c - * Creates a client authentication handle for passing "null" - * credentials and verifiers to remote systems. - * - * Copyright (C) 1984, Sun Microsystems, Inc. + * Creates a client authentication handle for passing "null" + * credentials and verifiers to remote systems. + * + * Copyright (C) 1984, Sun Microsystems, Inc. */ #include @@ -63,55 +63,55 @@ static bool_t authnone_marshal(AUTH *client, XDR *xdrs); struct opaque_auth _null_auth; static struct auth_ops ops = { - authnone_verf, - authnone_marshal, - authnone_validate, - authnone_refresh, - authnone_destroy + authnone_verf, + authnone_marshal, + authnone_validate, + authnone_refresh, + authnone_destroy }; static struct authnone_private { - AUTH no_client; - char marshalled_client[MAX_MARSHEL_SIZE]; - unsigned int mcnt; + AUTH no_client; + char marshalled_client[MAX_MARSHEL_SIZE]; + unsigned int mcnt; } *authnone_private; AUTH *authnone_create() { - register struct authnone_private *ap = authnone_private; - XDR xdr_stream; - register XDR *xdrs; + register struct authnone_private *ap = authnone_private; + XDR xdr_stream; + register XDR *xdrs; extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap); - if (ap == 0) { - ap = (struct authnone_private *) rt_malloc (sizeof(*ap)); - if (ap == 0) return NULL; - memset(ap, 0, sizeof(*ap)); - authnone_private = ap; - } - if (!ap->mcnt) { - ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; - ap->no_client.ah_ops = &ops; - xdrs = &xdr_stream; - xdrmem_create(xdrs, ap->marshalled_client, - (unsigned int) MAX_MARSHEL_SIZE, XDR_ENCODE); - (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); - (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); - ap->mcnt = XDR_GETPOS(xdrs); - XDR_DESTROY(xdrs); - } - return (&ap->no_client); + if (ap == 0) { + ap = (struct authnone_private *) rt_malloc (sizeof(*ap)); + if (ap == 0) return NULL; + memset(ap, 0, sizeof(*ap)); + authnone_private = ap; + } + if (!ap->mcnt) { + ap->no_client.ah_cred = ap->no_client.ah_verf = _null_auth; + ap->no_client.ah_ops = &ops; + xdrs = &xdr_stream; + xdrmem_create(xdrs, ap->marshalled_client, + (unsigned int) MAX_MARSHEL_SIZE, XDR_ENCODE); + (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_cred); + (void) xdr_opaque_auth(xdrs, &ap->no_client.ah_verf); + ap->mcnt = XDR_GETPOS(xdrs); + XDR_DESTROY(xdrs); + } + return (&ap->no_client); } -/*ARGSUSED*/ +/*ARGSUSED*/ static bool_t authnone_marshal(AUTH *client, XDR *xdrs) { - register struct authnone_private *ap = authnone_private; + register struct authnone_private *ap = authnone_private; - if (ap == 0) - return (0); - return ((*xdrs->x_ops->x_putbytes) (xdrs, - ap->marshalled_client, ap->mcnt)); + if (ap == 0) + return (0); + return ((*xdrs->x_ops->x_putbytes) (xdrs, + ap->marshalled_client, ap->mcnt)); } static void authnone_verf(AUTH *x) @@ -121,13 +121,13 @@ static void authnone_verf(AUTH *x) static bool_t authnone_validate(AUTH *x, struct opaque_auth *x1) { - return (TRUE); + return (TRUE); } static bool_t authnone_refresh(AUTH *x) { - return (FALSE); + return (FALSE); } static void authnone_destroy(AUTH *x) diff --git a/components/dfs/filesystems/nfs/rpc/clnt.h b/components/dfs/filesystems/nfs/rpc/clnt.h index e86f8be789..1d27dee359 100644 --- a/components/dfs/filesystems/nfs/rpc/clnt.h +++ b/components/dfs/filesystems/nfs/rpc/clnt.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ +/* @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -43,7 +43,7 @@ */ #ifndef _RPC_CLNT_H -#define _RPC_CLNT_H 1 +#define _RPC_CLNT_H 1 #include #include @@ -55,47 +55,47 @@ * independent) list of errors. */ enum clnt_stat { - RPC_SUCCESS=0, /* call succeeded */ - /* - * local errors - */ - RPC_CANTENCODEARGS=1, /* can't encode arguments */ - RPC_CANTDECODERES=2, /* can't decode results */ - RPC_CANTSEND=3, /* failure in sending call */ - RPC_CANTRECV=4, /* failure in receiving result */ - RPC_TIMEDOUT=5, /* call timed out */ - /* - * remote errors - */ - RPC_VERSMISMATCH=6, /* rpc versions not compatible */ - RPC_AUTHERROR=7, /* authentication error */ - RPC_PROGUNAVAIL=8, /* program not available */ - RPC_PROGVERSMISMATCH=9, /* program version mismatched */ - RPC_PROCUNAVAIL=10, /* procedure unavailable */ - RPC_CANTDECODEARGS=11, /* decode arguments error */ - RPC_SYSTEMERROR=12, /* generic "other problem" */ - RPC_NOBROADCAST = 21, /* Broadcasting not supported */ - /* - * callrpc & clnt_create errors - */ - RPC_UNKNOWNHOST=13, /* unknown host name */ - RPC_UNKNOWNPROTO=17, /* unknown protocol */ - RPC_UNKNOWNADDR = 19, /* Remote address unknown */ + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + RPC_NOBROADCAST = 21, /* Broadcasting not supported */ + /* + * callrpc & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unknown protocol */ + RPC_UNKNOWNADDR = 19, /* Remote address unknown */ - /* - * rpcbind errors - */ - RPC_RPCBFAILURE=14, /* portmapper failed in its call */ + /* + * rpcbind errors + */ + RPC_RPCBFAILURE=14, /* portmapper failed in its call */ #define RPC_PMAPFAILURE RPC_RPCBFAILURE - RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ - RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ - /* - * unspecified error - */ - RPC_FAILED=16, - RPC_INTR=18, - RPC_TLIERROR=20, - RPC_UDERROR=23, + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + RPC_N2AXLATEFAILURE = 22, /* Name to addr translation failed */ + /* + * unspecified error + */ + RPC_FAILED=16, + RPC_INTR=18, + RPC_TLIERROR=20, + RPC_UDERROR=23, /* * asynchronous errors */ @@ -110,21 +110,21 @@ enum clnt_stat { struct rpc_err { int re_status; union { - int RE_errno; /* related system error */ - int RE_why; /* why the auth error occurred */ + int RE_errno; /* related system error */ + int RE_why; /* why the auth error occurred */ struct { - unsigned long low; /* lowest verion supported */ - unsigned long high; /* highest verion supported */ + unsigned long low; /* lowest verion supported */ + unsigned long high; /* highest verion supported */ } RE_vers; - struct { /* maybe meaningful if RPC_FAILED */ + struct { /* maybe meaningful if RPC_FAILED */ long s1; long s2; - } RE_lb; /* life boot & debugging only */ + } RE_lb; /* life boot & debugging only */ } ru; -#define re_errno ru.RE_errno -#define re_why ru.RE_why -#define re_vers ru.RE_vers -#define re_lb ru.RE_lb +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb }; @@ -135,21 +135,21 @@ struct rpc_err { */ typedef struct CLIENT CLIENT; struct CLIENT { - AUTH *cl_auth; /* authenticator */ + AUTH *cl_auth; /* authenticator */ struct clnt_ops { enum clnt_stat (*cl_call) (CLIENT *, unsigned long, xdrproc_t, char*, xdrproc_t, - char*, struct timeval); - /* call remote procedure */ - void (*cl_abort) (void); /* abort a call */ + char*, struct timeval); + /* call remote procedure */ + void (*cl_abort) (void); /* abort a call */ void (*cl_geterr) (CLIENT *, struct rpc_err *); - /* get specific error code */ + /* get specific error code */ bool_t (*cl_freeres) (CLIENT *, xdrproc_t, char*); - /* frees results */ + /* frees results */ void (*cl_destroy) (CLIENT *); /* destroy this structure */ bool_t (*cl_control) (CLIENT *, int, char *); - /* the ioctl() of rpc */ + /* the ioctl() of rpc */ } *cl_ops; - char* cl_private; /* private stuff */ + char* cl_private; /* private stuff */ }; @@ -163,45 +163,45 @@ struct CLIENT { /* * enum clnt_stat * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) - * CLIENT *rh; - * unsigned long proc; - * xdrproc_t xargs; - * char* argsp; - * xdrproc_t xres; - * char* resp; - * struct timeval timeout; + * CLIENT *rh; + * unsigned long proc; + * xdrproc_t xargs; + * char* argsp; + * xdrproc_t xres; + * char* resp; + * struct timeval timeout; */ -#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) -#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ - ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) /* * void * CLNT_ABORT(rh); - * CLIENT *rh; + * CLIENT *rh; */ -#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) -#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) /* * struct rpc_err * CLNT_GETERR(rh); - * CLIENT *rh; + * CLIENT *rh; */ -#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) -#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) /* * bool_t * CLNT_FREERES(rh, xres, resp); - * CLIENT *rh; - * xdrproc_t xres; - * char* resp; + * CLIENT *rh; + * xdrproc_t xres; + * char* resp; */ -#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) -#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) /* * bool_t @@ -210,8 +210,8 @@ struct CLIENT { * unsigned int request; * char *info; */ -#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) -#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) /* * control operations that apply to all transports @@ -239,16 +239,16 @@ struct CLIENT { /* * Connectionless only control operations */ -#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ -#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ /* * void * CLNT_DESTROY(rh); - * CLIENT *rh; + * CLIENT *rh; */ -#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) -#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) /* @@ -257,10 +257,10 @@ struct CLIENT { * and network administration. */ -#define RPCTEST_PROGRAM ((unsigned long)1) -#define RPCTEST_VERSION ((unsigned long)1) -#define RPCTEST_NULL_PROC ((unsigned long)2) -#define RPCTEST_NULL_BATCH_PROC ((unsigned long)3) +#define RPCTEST_PROGRAM ((unsigned long)1) +#define RPCTEST_VERSION ((unsigned long)1) +#define RPCTEST_NULL_PROC ((unsigned long)2) +#define RPCTEST_NULL_BATCH_PROC ((unsigned long)3) /* * By convention, procedure 0 takes null arguments and returns them @@ -279,51 +279,51 @@ struct CLIENT { * "unix" * CLIENT * * clnt_create(host, prog, vers, prot) - * char *host; -- hostname - * unsigned long prog; -- program number - * u_ong vers; -- version number - * char *prot; -- protocol + * char *host; -- hostname + * unsigned long prog; -- program number + * u_ong vers; -- version number + * char *prot; -- protocol */ extern CLIENT *clnt_create (const char *__host, const unsigned long __prog, - const unsigned long __vers, const char *__prot) + const unsigned long __vers, const char *__prot) ; /* * UDP based rpc. * CLIENT * * clntudp_create(raddr, program, version, wait, sockp) - * struct sockaddr_in *raddr; - * unsigned long program; - * unsigned long version; - * struct timeval wait_resend; - * int *sockp; + * struct sockaddr_in *raddr; + * unsigned long program; + * unsigned long version; + * struct timeval wait_resend; + * int *sockp; * * Same as above, but you specify max packet sizes. * CLIENT * * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) - * struct sockaddr_in *raddr; - * unsigned long program; - * unsigned long version; - * struct timeval wait_resend; - * int *sockp; - * unsigned int sendsz; - * unsigned int recvsz; + * struct sockaddr_in *raddr; + * unsigned long program; + * unsigned long version; + * struct timeval wait_resend; + * int *sockp; + * unsigned int sendsz; + * unsigned int recvsz; */ extern CLIENT *clntudp_create (struct sockaddr_in *__raddr, unsigned long __program, - unsigned long __version, struct timeval __wait_resend, - int *__sockp); + unsigned long __version, struct timeval __wait_resend, + int *__sockp); extern CLIENT *clntudp_bufcreate (struct sockaddr_in *__raddr, - unsigned long __program, unsigned long __version, - struct timeval __wait_resend, int *__sockp, - unsigned int __sendsz, unsigned int __recvsz); + unsigned long __program, unsigned long __version, + struct timeval __wait_resend, int *__sockp, + unsigned int __sendsz, unsigned int __recvsz); extern int callrpc (const char *__host, const unsigned long __prognum, - const unsigned long __versnum, const unsigned long __procnum, - const xdrproc_t __inproc, const char *__in, - const xdrproc_t __outproc, char *__out); + const unsigned long __versnum, const unsigned long __procnum, + const xdrproc_t __inproc, const char *__in, + const xdrproc_t __outproc, char *__out); -#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ -#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ void clnt_perror(CLIENT *rpch, const char *s); diff --git a/components/dfs/filesystems/nfs/rpc/clnt_generic.c b/components/dfs/filesystems/nfs/rpc/clnt_generic.c index bd241b5835..bbcd8011ef 100644 --- a/components/dfs/filesystems/nfs/rpc/clnt_generic.c +++ b/components/dfs/filesystems/nfs/rpc/clnt_generic.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/nfs/rpc/clnt_udp.c b/components/dfs/filesystems/nfs/rpc/clnt_udp.c index 6b4f7bfb13..17933539da 100644 --- a/components/dfs/filesystems/nfs/rpc/clnt_udp.c +++ b/components/dfs/filesystems/nfs/rpc/clnt_udp.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */ +/* @(#)clnt_udp.c 2.2 88/08/01 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -53,12 +53,12 @@ static char sccsid[] = "@(#)clnt_udp.c 1.39 87/08/11 Copyr 1984 Sun Micro"; * UDP bases client side rpc operations */ static enum clnt_stat clntudp_call(register CLIENT *cl, /* client handle */ - unsigned long proc, /* procedure number */ - xdrproc_t xargs, /* xdr routine for args */ - char* argsp, /* pointer to args */ - xdrproc_t xresults, /* xdr routine for results */ - char* resultsp, /* pointer to results */ - struct timeval utimeout); + unsigned long proc, /* procedure number */ + xdrproc_t xargs, /* xdr routine for args */ + char* argsp, /* pointer to args */ + xdrproc_t xresults, /* xdr routine for results */ + char* resultsp, /* pointer to results */ + struct timeval utimeout); static void clntudp_abort(void); static void clntudp_geterr(CLIENT *, struct rpc_err *); @@ -68,12 +68,12 @@ static void clntudp_destroy(CLIENT *); static struct clnt_ops udp_ops = { - clntudp_call, - clntudp_abort, - clntudp_geterr, - clntudp_freeres, - clntudp_destroy, - clntudp_control + clntudp_call, + clntudp_abort, + clntudp_geterr, + clntudp_freeres, + clntudp_destroy, + clntudp_control }; /* @@ -81,19 +81,19 @@ static struct clnt_ops udp_ops = */ struct cu_data { - int cu_sock; - bool_t cu_closeit; - struct sockaddr_in cu_raddr; - int cu_rlen; - struct timeval cu_wait; - struct timeval cu_total; - struct rpc_err cu_error; - XDR cu_outxdrs; - unsigned int cu_xdrpos; - unsigned int cu_sendsz; - char *cu_outbuf; - unsigned int cu_recvsz; - char cu_inbuf[1]; + int cu_sock; + bool_t cu_closeit; + struct sockaddr_in cu_raddr; + int cu_rlen; + struct timeval cu_wait; + struct timeval cu_total; + struct rpc_err cu_error; + XDR cu_outxdrs; + unsigned int cu_xdrpos; + unsigned int cu_sendsz; + char *cu_outbuf; + unsigned int cu_recvsz; + char cu_inbuf[1]; }; /* @@ -112,241 +112,241 @@ struct cu_data * sendsz and recvsz are the maximum allowable packet sizes that can be * sent and received. */ -CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, - unsigned long program, - unsigned long version, - struct timeval wait, - int *sockp, - unsigned int sendsz, - unsigned int recvsz) +CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, + unsigned long program, + unsigned long version, + struct timeval wait, + int *sockp, + unsigned int sendsz, + unsigned int recvsz) { - CLIENT *cl; - register struct cu_data *cu = NULL; - struct rpc_msg call_msg; - static int xid_count = 0; - - cl = (CLIENT *) rt_malloc (sizeof(CLIENT)); - if (cl == NULL) - { - rt_kprintf("clntudp_create: out of memory\n"); - goto fooy; - } - sendsz = ((sendsz + 3) / 4) * 4; - recvsz = ((recvsz + 3) / 4) * 4; - cu = (struct cu_data *) rt_malloc (sizeof(*cu) + sendsz + recvsz); - if (cu == NULL) - { - rt_kprintf("clntudp_create: out of memory\n"); - goto fooy; - } - cu->cu_outbuf = &cu->cu_inbuf[recvsz]; - - if (raddr->sin_port == 0) { - unsigned short port; - extern unsigned short pmap_getport(struct sockaddr_in *address, - unsigned long program, - unsigned long version, - unsigned int protocol); - - if ((port = - pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { - goto fooy; - } - raddr->sin_port = htons(port); - } - - cl->cl_ops = &udp_ops; - cl->cl_private = (char*) cu; - cu->cu_raddr = *raddr; - cu->cu_rlen = sizeof(cu->cu_raddr); - cu->cu_wait = wait; - cu->cu_total.tv_sec = -1; - cu->cu_total.tv_usec = -1; - cu->cu_sendsz = sendsz; - cu->cu_recvsz = recvsz; - call_msg.rm_xid = ((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++); - call_msg.rm_direction = CALL; - call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; - call_msg.rm_call.cb_prog = program; - call_msg.rm_call.cb_vers = version; - xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); - if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) - { - goto fooy; - } - cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); - if (*sockp < 0) - { - *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (*sockp < 0) - { - rt_kprintf("create socket error\n"); - goto fooy; - } - cu->cu_closeit = TRUE; - } - else - { - cu->cu_closeit = FALSE; - } - cu->cu_sock = *sockp; - cl->cl_auth = authnone_create(); - return (cl); + CLIENT *cl; + register struct cu_data *cu = NULL; + struct rpc_msg call_msg; + static int xid_count = 0; + + cl = (CLIENT *) rt_malloc (sizeof(CLIENT)); + if (cl == NULL) + { + rt_kprintf("clntudp_create: out of memory\n"); + goto fooy; + } + sendsz = ((sendsz + 3) / 4) * 4; + recvsz = ((recvsz + 3) / 4) * 4; + cu = (struct cu_data *) rt_malloc (sizeof(*cu) + sendsz + recvsz); + if (cu == NULL) + { + rt_kprintf("clntudp_create: out of memory\n"); + goto fooy; + } + cu->cu_outbuf = &cu->cu_inbuf[recvsz]; + + if (raddr->sin_port == 0) { + unsigned short port; + extern unsigned short pmap_getport(struct sockaddr_in *address, + unsigned long program, + unsigned long version, + unsigned int protocol); + + if ((port = + pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { + goto fooy; + } + raddr->sin_port = htons(port); + } + + cl->cl_ops = &udp_ops; + cl->cl_private = (char*) cu; + cu->cu_raddr = *raddr; + cu->cu_rlen = sizeof(cu->cu_raddr); + cu->cu_wait = wait; + cu->cu_total.tv_sec = -1; + cu->cu_total.tv_usec = -1; + cu->cu_sendsz = sendsz; + cu->cu_recvsz = recvsz; + call_msg.rm_xid = ((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++); + call_msg.rm_direction = CALL; + call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; + call_msg.rm_call.cb_prog = program; + call_msg.rm_call.cb_vers = version; + xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); + if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) + { + goto fooy; + } + cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); + if (*sockp < 0) + { + *sockp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (*sockp < 0) + { + rt_kprintf("create socket error\n"); + goto fooy; + } + cu->cu_closeit = TRUE; + } + else + { + cu->cu_closeit = FALSE; + } + cu->cu_sock = *sockp; + cl->cl_auth = authnone_create(); + return (cl); fooy: - if (cu) rt_free(cu); - if (cl) rt_free(cl); + if (cu) rt_free(cu); + if (cl) rt_free(cl); - return ((CLIENT *) NULL); + return ((CLIENT *) NULL); } -CLIENT *clntudp_create(struct sockaddr_in *raddr, - unsigned long program, - unsigned long version, - struct timeval wait, - int *sockp) +CLIENT *clntudp_create(struct sockaddr_in *raddr, + unsigned long program, + unsigned long version, + struct timeval wait, + int *sockp) { - return (clntudp_bufcreate(raddr, program, version, wait, sockp, - UDPMSGSIZE, UDPMSGSIZE)); + return (clntudp_bufcreate(raddr, program, version, wait, sockp, + UDPMSGSIZE, UDPMSGSIZE)); } -static enum clnt_stat clntudp_call(CLIENT *cl, unsigned long proc, - xdrproc_t xargs, char* argsp, - xdrproc_t xresults, char* resultsp, - struct timeval utimeout) +static enum clnt_stat clntudp_call(CLIENT *cl, unsigned long proc, + xdrproc_t xargs, char* argsp, + xdrproc_t xresults, char* resultsp, + struct timeval utimeout) { - register struct cu_data *cu = (struct cu_data *) cl->cl_private; - register XDR *xdrs; - register int outlen; - register int inlen; - socklen_t fromlen; - - struct sockaddr_in from; - struct rpc_msg reply_msg; - XDR reply_xdrs; - bool_t ok; - int nrefreshes = 2; /* number of times to refresh cred */ + register struct cu_data *cu = (struct cu_data *) cl->cl_private; + register XDR *xdrs; + register int outlen; + register int inlen; + socklen_t fromlen; + + struct sockaddr_in from; + struct rpc_msg reply_msg; + XDR reply_xdrs; + bool_t ok; + int nrefreshes = 2; /* number of times to refresh cred */ call_again: - xdrs = &(cu->cu_outxdrs); - xdrs->x_op = XDR_ENCODE; - XDR_SETPOS(xdrs, cu->cu_xdrpos); + xdrs = &(cu->cu_outxdrs); + xdrs->x_op = XDR_ENCODE; + XDR_SETPOS(xdrs, cu->cu_xdrpos); - /* - * the transaction is the first thing in the out buffer - */ - (*(unsigned long *) (cu->cu_outbuf))++; + /* + * the transaction is the first thing in the out buffer + */ + (*(unsigned long *) (cu->cu_outbuf))++; - if ((!XDR_PUTLONG(xdrs, (long *) &proc)) || - (!AUTH_MARSHALL(cl->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp))) + if ((!XDR_PUTLONG(xdrs, (long *) &proc)) || + (!AUTH_MARSHALL(cl->cl_auth, xdrs)) || (!(*xargs) (xdrs, argsp))) { cu->cu_error.re_status = RPC_CANTENCODEARGS; - return RPC_CANTENCODEARGS; + return RPC_CANTENCODEARGS; } - outlen = (int) XDR_GETPOS(xdrs); + outlen = (int) XDR_GETPOS(xdrs); send_again: - if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, - (struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen) - != outlen) - { - cu->cu_error.re_errno = errno; + if (sendto(cu->cu_sock, cu->cu_outbuf, outlen, 0, + (struct sockaddr *) &(cu->cu_raddr), cu->cu_rlen) + != outlen) + { + cu->cu_error.re_errno = errno; cu->cu_error.re_status = RPC_CANTSEND; - - return RPC_CANTSEND; - } - - /* - * sub-optimal code appears here because we have - * some clock time to spare while the packets are in flight. - * (We assume that this is actually only executed once.) - */ - reply_msg.acpted_rply.ar_verf = _null_auth; - reply_msg.acpted_rply.ar_results.where = resultsp; - reply_msg.acpted_rply.ar_results.proc = xresults; - - /* do recv */ - do - { - fromlen = sizeof(struct sockaddr); - - inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, - (int) cu->cu_recvsz, 0, - (struct sockaddr *) &from, &fromlen); - }while (inlen < 0 && errno == EINTR); - - if (inlen < 4) - { - rt_kprintf("recv error, len %d\n", inlen); - cu->cu_error.re_errno = errno; - cu->cu_error.re_status = RPC_CANTRECV; - - return RPC_CANTRECV; - } - - /* see if reply transaction id matches sent id */ - if (*((uint32_t *) (cu->cu_inbuf)) != *((uint32_t *) (cu->cu_outbuf))) - goto send_again; - - /* we now assume we have the proper reply */ - - /* - * now decode and validate the response - */ - xdrmem_create(&reply_xdrs, cu->cu_inbuf, (unsigned int) inlen, XDR_DECODE); - ok = xdr_replymsg(&reply_xdrs, &reply_msg); - /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ - if (ok) - { - _seterr_reply(&reply_msg, &(cu->cu_error)); - if (cu->cu_error.re_status == RPC_SUCCESS) - { - if (!AUTH_VALIDATE(cl->cl_auth, - &reply_msg.acpted_rply.ar_verf)) - { - cu->cu_error.re_status = RPC_AUTHERROR; - cu->cu_error.re_why = AUTH_INVALIDRESP; - } - if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) - { - extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap); - - xdrs->x_op = XDR_FREE; - (void) xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); - } - } /* end successful completion */ - else - { - /* maybe our credentials need to be refreshed ... */ - if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) - { - nrefreshes--; - goto call_again; - } - } /* end of unsuccessful completion */ - } /* end of valid reply message */ - else - { - cu->cu_error.re_status = RPC_CANTDECODERES; - } - - return (enum clnt_stat)(cu->cu_error.re_status); + + return RPC_CANTSEND; + } + + /* + * sub-optimal code appears here because we have + * some clock time to spare while the packets are in flight. + * (We assume that this is actually only executed once.) + */ + reply_msg.acpted_rply.ar_verf = _null_auth; + reply_msg.acpted_rply.ar_results.where = resultsp; + reply_msg.acpted_rply.ar_results.proc = xresults; + + /* do recv */ + do + { + fromlen = sizeof(struct sockaddr); + + inlen = recvfrom(cu->cu_sock, cu->cu_inbuf, + (int) cu->cu_recvsz, 0, + (struct sockaddr *) &from, &fromlen); + }while (inlen < 0 && errno == EINTR); + + if (inlen < 4) + { + rt_kprintf("recv error, len %d\n", inlen); + cu->cu_error.re_errno = errno; + cu->cu_error.re_status = RPC_CANTRECV; + + return RPC_CANTRECV; + } + + /* see if reply transaction id matches sent id */ + if (*((uint32_t *) (cu->cu_inbuf)) != *((uint32_t *) (cu->cu_outbuf))) + goto send_again; + + /* we now assume we have the proper reply */ + + /* + * now decode and validate the response + */ + xdrmem_create(&reply_xdrs, cu->cu_inbuf, (unsigned int) inlen, XDR_DECODE); + ok = xdr_replymsg(&reply_xdrs, &reply_msg); + /* XDR_DESTROY(&reply_xdrs); save a few cycles on noop destroy */ + if (ok) + { + _seterr_reply(&reply_msg, &(cu->cu_error)); + if (cu->cu_error.re_status == RPC_SUCCESS) + { + if (!AUTH_VALIDATE(cl->cl_auth, + &reply_msg.acpted_rply.ar_verf)) + { + cu->cu_error.re_status = RPC_AUTHERROR; + cu->cu_error.re_why = AUTH_INVALIDRESP; + } + if (reply_msg.acpted_rply.ar_verf.oa_base != NULL) + { + extern bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap); + + xdrs->x_op = XDR_FREE; + (void) xdr_opaque_auth(xdrs, &(reply_msg.acpted_rply.ar_verf)); + } + } /* end successful completion */ + else + { + /* maybe our credentials need to be refreshed ... */ + if (nrefreshes > 0 && AUTH_REFRESH(cl->cl_auth)) + { + nrefreshes--; + goto call_again; + } + } /* end of unsuccessful completion */ + } /* end of valid reply message */ + else + { + cu->cu_error.re_status = RPC_CANTDECODERES; + } + + return (enum clnt_stat)(cu->cu_error.re_status); } static void clntudp_geterr(CLIENT *cl, struct rpc_err *errp) { - register struct cu_data *cu = (struct cu_data *) cl->cl_private; + register struct cu_data *cu = (struct cu_data *) cl->cl_private; - *errp = cu->cu_error; + *errp = cu->cu_error; } static bool_t clntudp_freeres(CLIENT *cl, xdrproc_t xdr_res, char* res_ptr) { - register struct cu_data *cu = (struct cu_data *) cl->cl_private; - register XDR *xdrs = &(cu->cu_outxdrs); + register struct cu_data *cu = (struct cu_data *) cl->cl_private; + register XDR *xdrs = &(cu->cu_outxdrs); - xdrs->x_op = XDR_FREE; - return ((*xdr_res) (xdrs, res_ptr)); + xdrs->x_op = XDR_FREE; + return ((*xdr_res) (xdrs, res_ptr)); } static void clntudp_abort() @@ -355,50 +355,50 @@ static void clntudp_abort() static bool_t clntudp_control(CLIENT *cl, int request, char *info) { - register struct cu_data *cu = (struct cu_data *) cl->cl_private; - - switch (request) - { - case CLSET_TIMEOUT: - { - int mtimeout; - - cu->cu_total = *(struct timeval *) info; - mtimeout = ((cu->cu_total.tv_sec * 1000) + ((cu->cu_total.tv_usec + 500)/1000)); - - /* set socket option, note: lwip only support msecond timeout */ - setsockopt(cu->cu_sock, SOL_SOCKET, SO_RCVTIMEO, - &mtimeout, sizeof(mtimeout)); - } - break; - case CLGET_TIMEOUT: - *(struct timeval *) info = cu->cu_total; - break; - case CLSET_RETRY_TIMEOUT: - cu->cu_wait = *(struct timeval *) info; - break; - case CLGET_RETRY_TIMEOUT: - *(struct timeval *) info = cu->cu_wait; - break; - case CLGET_SERVER_ADDR: - *(struct sockaddr_in *) info = cu->cu_raddr; - break; - default: - return (FALSE); - } - return (TRUE); + register struct cu_data *cu = (struct cu_data *) cl->cl_private; + + switch (request) + { + case CLSET_TIMEOUT: + { + int mtimeout; + + cu->cu_total = *(struct timeval *) info; + mtimeout = ((cu->cu_total.tv_sec * 1000) + ((cu->cu_total.tv_usec + 500)/1000)); + + /* set socket option, note: lwip only support msecond timeout */ + setsockopt(cu->cu_sock, SOL_SOCKET, SO_RCVTIMEO, + &mtimeout, sizeof(mtimeout)); + } + break; + case CLGET_TIMEOUT: + *(struct timeval *) info = cu->cu_total; + break; + case CLSET_RETRY_TIMEOUT: + cu->cu_wait = *(struct timeval *) info; + break; + case CLGET_RETRY_TIMEOUT: + *(struct timeval *) info = cu->cu_wait; + break; + case CLGET_SERVER_ADDR: + *(struct sockaddr_in *) info = cu->cu_raddr; + break; + default: + return (FALSE); + } + return (TRUE); } static void clntudp_destroy(CLIENT *cl) { - register struct cu_data *cu = (struct cu_data *) cl->cl_private; + register struct cu_data *cu = (struct cu_data *) cl->cl_private; - if (cu->cu_closeit) - { - lwip_close(cu->cu_sock); - } + if (cu->cu_closeit) + { + lwip_close(cu->cu_sock); + } - XDR_DESTROY(&(cu->cu_outxdrs)); - rt_free(cu); - rt_free(cl); + XDR_DESTROY(&(cu->cu_outxdrs)); + rt_free(cu); + rt_free(cl); } diff --git a/components/dfs/filesystems/nfs/rpc/pmap.c b/components/dfs/filesystems/nfs/rpc/pmap.c index dc5a2ccb8d..afa2583d09 100644 --- a/components/dfs/filesystems/nfs/rpc/pmap.c +++ b/components/dfs/filesystems/nfs/rpc/pmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -16,11 +16,11 @@ static struct timeval tottimeout = { 60, 0 }; bool_t xdr_pmap(XDR *xdrs, struct pmap *regs) { - if (xdr_u_long(xdrs, ®s->pm_prog) && - xdr_u_long(xdrs, ®s->pm_vers) && - xdr_u_long(xdrs, ®s->pm_prot)) - return (xdr_u_long(xdrs, ®s->pm_port)); - return (FALSE); + if (xdr_u_long(xdrs, ®s->pm_prog) && + xdr_u_long(xdrs, ®s->pm_vers) && + xdr_u_long(xdrs, ®s->pm_prot)) + return (xdr_u_long(xdrs, ®s->pm_port)); + return (FALSE); } /* @@ -30,33 +30,33 @@ bool_t xdr_pmap(XDR *xdrs, struct pmap *regs) */ unsigned short pmap_getport(struct sockaddr_in *address, unsigned long program, unsigned long version, unsigned int protocol) { - unsigned short port = 0; - int socket = -1; - register CLIENT *client = RT_NULL; - struct pmap parms; - - address->sin_port = htons((unsigned short)PMAPPORT); - if (protocol == IPPROTO_UDP) - client = clntudp_bufcreate(address, PMAPPROG, PMAPVERS, timeout, - &socket, RPCSMALLMSGSIZE, - RPCSMALLMSGSIZE); - - if (client != (CLIENT *) NULL) - { - parms.pm_prog = program; - parms.pm_vers = version; - parms.pm_prot = protocol; - parms.pm_port = 0; /* not needed or used */ - if (CLNT_CALL(client, PMAPPROC_GETPORT, (xdrproc_t)xdr_pmap, (char*)&parms, - (xdrproc_t)xdr_u_short, (char*)&port, tottimeout) != RPC_SUCCESS) - { - rt_kprintf("pmap failure\n"); - } - CLNT_DESTROY(client); - } - - (void) lwip_close(socket); - address->sin_port = 0; - - return (port); + unsigned short port = 0; + int socket = -1; + register CLIENT *client = RT_NULL; + struct pmap parms; + + address->sin_port = htons((unsigned short)PMAPPORT); + if (protocol == IPPROTO_UDP) + client = clntudp_bufcreate(address, PMAPPROG, PMAPVERS, timeout, + &socket, RPCSMALLMSGSIZE, + RPCSMALLMSGSIZE); + + if (client != (CLIENT *) NULL) + { + parms.pm_prog = program; + parms.pm_vers = version; + parms.pm_prot = protocol; + parms.pm_port = 0; /* not needed or used */ + if (CLNT_CALL(client, PMAPPROC_GETPORT, (xdrproc_t)xdr_pmap, (char*)&parms, + (xdrproc_t)xdr_u_short, (char*)&port, tottimeout) != RPC_SUCCESS) + { + rt_kprintf("pmap failure\n"); + } + CLNT_DESTROY(client); + } + + (void) lwip_close(socket); + address->sin_port = 0; + + return (port); } diff --git a/components/dfs/filesystems/nfs/rpc/pmap.h b/components/dfs/filesystems/nfs/rpc/pmap.h index 8ae706c0aa..3a0305a6b8 100644 --- a/components/dfs/filesystems/nfs/rpc/pmap.h +++ b/components/dfs/filesystems/nfs/rpc/pmap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -14,51 +14,51 @@ /* The following procedures are supported by the protocol: * * PMAPPROC_NULL() returns () - * takes nothing, returns nothing + * takes nothing, returns nothing * * PMAPPROC_SET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Registers the tuple - * [prog, vers, prot, port]. + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. * * PMAPPROC_UNSET(struct pmap) returns (bool_t) - * TRUE is success, FALSE is failure. Un-registers pair - * [prog, vers]. prot and port are ignored. + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. * * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). - * 0 is failure. Otherwise returns the port number where the pair - * [prog, vers] is registered. It may lie! + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! * * PMAPPROC_DUMP() RETURNS (struct pmaplist *) * * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) - * RETURNS (port, string<>); + * RETURNS (port, string<>); * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); - * Calls the procedure on the local machine. If it is not registered, - * this procedure is quite; ie it does not return error information!!! - * This procedure only is supported on rpc/udp and calls via - * rpc/udp. This routine only passes null authentication parameters. - * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. * * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. */ -#define PMAPPORT ((unsigned short)111) -#define PMAPPROG ((unsigned long)100000) -#define PMAPVERS ((unsigned long)2) -#define PMAPVERS_PROTO ((unsigned long)2) -#define PMAPVERS_ORIG ((unsigned long)1) -#define PMAPPROC_NULL ((unsigned long)0) -#define PMAPPROC_SET ((unsigned long)1) -#define PMAPPROC_UNSET ((unsigned long)2) -#define PMAPPROC_GETPORT ((unsigned long)3) -#define PMAPPROC_DUMP ((unsigned long)4) -#define PMAPPROC_CALLIT ((unsigned long)5) +#define PMAPPORT ((unsigned short)111) +#define PMAPPROG ((unsigned long)100000) +#define PMAPVERS ((unsigned long)2) +#define PMAPVERS_PROTO ((unsigned long)2) +#define PMAPVERS_ORIG ((unsigned long)1) +#define PMAPPROC_NULL ((unsigned long)0) +#define PMAPPROC_SET ((unsigned long)1) +#define PMAPPROC_UNSET ((unsigned long)2) +#define PMAPPROC_GETPORT ((unsigned long)3) +#define PMAPPROC_DUMP ((unsigned long)4) +#define PMAPPROC_CALLIT ((unsigned long)5) struct pmap { - long unsigned pm_prog; - long unsigned pm_vers; - long unsigned pm_prot; - long unsigned pm_port; + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; }; extern bool_t xdr_pmap (XDR *__xdrs, struct pmap *__regs); diff --git a/components/dfs/filesystems/nfs/rpc/rpc.h b/components/dfs/filesystems/nfs/rpc/rpc.h index 7256d336a1..12d2477ef6 100644 --- a/components/dfs/filesystems/nfs/rpc/rpc.h +++ b/components/dfs/filesystems/nfs/rpc/rpc.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ +/* @(#)rpc.h 2.3 88/08/10 4.0 RPCSRC; from 1.9 88/02/08 SMI */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -46,17 +46,17 @@ #ifndef _RPC_RPC_H #define _RPC_RPC_H 1 -#include /* some typedefs */ +#include /* some typedefs */ /* external data representation interfaces */ -#include /* generic (de)serializer */ +#include /* generic (de)serializer */ #include /* Client side (mostly) remote procedure call */ -#include /* generic rpc stuff */ +#include /* generic rpc stuff */ /* semi-private protocol headers */ -#include /* protocol for rpc messages */ +#include /* protocol for rpc messages */ #endif diff --git a/components/dfs/filesystems/nfs/rpc/rpc_msg.h b/components/dfs/filesystems/nfs/rpc/rpc_msg.h index a21ca1ce7d..358c3f7903 100644 --- a/components/dfs/filesystems/nfs/rpc/rpc_msg.h +++ b/components/dfs/filesystems/nfs/rpc/rpc_msg.h @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ +/* @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -50,8 +50,8 @@ * Copyright (C) 1984, Sun Microsystems, Inc. */ -#define RPC_MSG_VERSION ((unsigned long) 2) -#define RPC_SERVICE_PORT ((unsigned short) 2048) +#define RPC_MSG_VERSION ((unsigned long) 2) +#define RPC_SERVICE_PORT ((unsigned short) 2048) /* * Bottom up definition of an rpc message. @@ -60,27 +60,27 @@ */ enum msg_type { - CALL=0, - REPLY=1 + CALL=0, + REPLY=1 }; enum reply_stat { - MSG_ACCEPTED=0, - MSG_DENIED=1 + MSG_ACCEPTED=0, + MSG_DENIED=1 }; enum accept_stat { - SUCCESS=0, - PROG_UNAVAIL=1, - PROG_MISMATCH=2, - PROC_UNAVAIL=3, - GARBAGE_ARGS=4, - SYSTEM_ERR=5 + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 }; enum reject_stat { - RPC_MISMATCH=0, - AUTH_ERROR=1 + RPC_MISMATCH=0, + AUTH_ERROR=1 }; /* @@ -93,111 +93,111 @@ enum reject_stat { * accepted. */ struct accepted_reply { - struct opaque_auth ar_verf; - int ar_stat; - union { - struct { - unsigned long low; - unsigned long high; - } AR_versions; - struct { - char* where; - xdrproc_t proc; - } AR_results; - /* and many other null cases */ - } ru; -#define ar_results ru.AR_results -#define ar_vers ru.AR_versions + struct opaque_auth ar_verf; + int ar_stat; + union { + struct { + unsigned long low; + unsigned long high; + } AR_versions; + struct { + char* where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions }; /* * Reply to an rpc request that was rejected by the server. */ struct rejected_reply { - int rj_stat; - union { - struct { - unsigned long low; - unsigned long high; - } RJ_versions; - int RJ_why; /* why authentication did not work */ - } ru; -#define rj_vers ru.RJ_versions -#define rj_why ru.RJ_why + int rj_stat; + union { + struct { + unsigned long low; + unsigned long high; + } RJ_versions; + int RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why }; /* * Body of a reply to an rpc request. */ struct reply_body { - int rp_stat; - union { - struct accepted_reply RP_ar; - struct rejected_reply RP_dr; - } ru; -#define rp_acpt ru.RP_ar -#define rp_rjct ru.RP_dr + int rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr }; /* * Body of an rpc request call. */ struct call_body { - unsigned long cb_rpcvers; /* must be equal to two */ - unsigned long cb_prog; - unsigned long cb_vers; - unsigned long cb_proc; - struct opaque_auth cb_cred; - struct opaque_auth cb_verf; /* protocol specific - provided by client */ + unsigned long cb_rpcvers; /* must be equal to two */ + unsigned long cb_prog; + unsigned long cb_vers; + unsigned long cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ }; /* * The rpc message */ struct rpc_msg { - unsigned long rm_xid; - int rm_direction; - union { - struct call_body RM_cmb; - struct reply_body RM_rmb; - } ru; -#define rm_call ru.RM_cmb -#define rm_reply ru.RM_rmb + unsigned long rm_xid; + int rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb }; -#define acpted_rply ru.RM_rmb.ru.RP_ar -#define rjcted_rply ru.RM_rmb.ru.RP_dr +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr /* * XDR routine to handle a rpc message. * xdr_callmsg(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; + * XDR *xdrs; + * struct rpc_msg *cmsg; */ -extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg); +extern bool_t xdr_callmsg (XDR *__xdrs, struct rpc_msg *__cmsg); /* * XDR routine to pre-serialize the static part of a rpc message. * xdr_callhdr(xdrs, cmsg) - * XDR *xdrs; - * struct rpc_msg *cmsg; + * XDR *xdrs; + * struct rpc_msg *cmsg; */ -extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg); +extern bool_t xdr_callhdr (XDR *__xdrs, struct rpc_msg *__cmsg); /* * XDR routine to handle a rpc reply. * xdr_replymsg(xdrs, rmsg) - * XDR *xdrs; - * struct rpc_msg *rmsg; + * XDR *xdrs; + * struct rpc_msg *rmsg; */ -extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg); +extern bool_t xdr_replymsg (XDR *__xdrs, struct rpc_msg *__rmsg); /* * Fills in the error part of a reply message. * _seterr_reply(msg, error) - * struct rpc_msg *msg; - * struct rpc_err *error; + * struct rpc_msg *msg; + * struct rpc_err *error; */ -extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error); +extern void _seterr_reply (struct rpc_msg *__msg, struct rpc_err *__error); #endif /* rpc/rpc_msg.h */ diff --git a/components/dfs/filesystems/nfs/rpc/rpc_prot.c b/components/dfs/filesystems/nfs/rpc/rpc_prot.c index 427d7a11e4..61cb6cbc85 100644 --- a/components/dfs/filesystems/nfs/rpc/rpc_prot.c +++ b/components/dfs/filesystems/nfs/rpc/rpc_prot.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */ +/* @(#)rpc_prot.c 2.3 88/08/07 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -14,23 +14,23 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 @@ -63,10 +63,10 @@ static char sccsid[] = "@(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro"; bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap) { - if (xdr_enum(xdrs, &(ap->oa_flavor))) - return (xdr_bytes(xdrs, &ap->oa_base, - &ap->oa_length, MAX_AUTH_BYTES)); - return (FALSE); + if (xdr_enum(xdrs, &(ap->oa_flavor))) + return (xdr_bytes(xdrs, &ap->oa_base, + &ap->oa_length, MAX_AUTH_BYTES)); + return (FALSE); } /* @@ -74,7 +74,7 @@ bool_t xdr_opaque_auth(XDR *xdrs, struct opaque_auth *ap) */ bool_t xdr_des_block(XDR *xdrs, des_block *blkp) { - return (xdr_opaque(xdrs, (char*) blkp, sizeof(des_block))); + return (xdr_opaque(xdrs, (char*) blkp, sizeof(des_block))); } /* * * * * * * * * * * * * * XDR RPC MESSAGE * * * * * * * * * * * * * * * */ @@ -85,22 +85,22 @@ bool_t xdr_des_block(XDR *xdrs, des_block *blkp) static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar) { - /* personalized union, rather than calling xdr_union */ - if (!xdr_opaque_auth(xdrs, &(ar->ar_verf))) - return (FALSE); - if (!xdr_enum(xdrs, (enum_t *) & (ar->ar_stat))) - return (FALSE); - switch (ar->ar_stat) { - - case SUCCESS: - return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where)); - - case PROG_MISMATCH: - if (!xdr_u_long(xdrs, &(ar->ar_vers.low))) - return (FALSE); - return (xdr_u_long(xdrs, &(ar->ar_vers.high))); - } - return (TRUE); /* TRUE => open ended set of problems */ + /* personalized union, rather than calling xdr_union */ + if (!xdr_opaque_auth(xdrs, &(ar->ar_verf))) + return (FALSE); + if (!xdr_enum(xdrs, (enum_t *) & (ar->ar_stat))) + return (FALSE); + switch (ar->ar_stat) { + + case SUCCESS: + return ((*(ar->ar_results.proc)) (xdrs, ar->ar_results.where)); + + case PROG_MISMATCH: + if (!xdr_u_long(xdrs, &(ar->ar_vers.low))) + return (FALSE); + return (xdr_u_long(xdrs, &(ar->ar_vers.high))); + } + return (TRUE); /* TRUE => open ended set of problems */ } /* @@ -109,26 +109,26 @@ static bool_t xdr_accepted_reply(XDR *xdrs, struct accepted_reply *ar) static bool_t xdr_rejected_reply(XDR *xdrs, struct rejected_reply *rr) { - /* personalized union, rather than calling xdr_union */ - if (!xdr_enum(xdrs, (enum_t *) & (rr->rj_stat))) - return (FALSE); - switch (rr->rj_stat) { + /* personalized union, rather than calling xdr_union */ + if (!xdr_enum(xdrs, (enum_t *) & (rr->rj_stat))) + return (FALSE); + switch (rr->rj_stat) { - case RPC_MISMATCH: - if (!xdr_u_long(xdrs, &(rr->rj_vers.low))) - return (FALSE); - return (xdr_u_long(xdrs, &(rr->rj_vers.high))); + case RPC_MISMATCH: + if (!xdr_u_long(xdrs, &(rr->rj_vers.low))) + return (FALSE); + return (xdr_u_long(xdrs, &(rr->rj_vers.high))); - case AUTH_ERROR: - return (xdr_enum(xdrs, (enum_t *) & (rr->rj_why))); - } - return (FALSE); + case AUTH_ERROR: + return (xdr_enum(xdrs, (enum_t *) & (rr->rj_why))); + } + return (FALSE); } static struct xdr_discrim reply_dscrm[3] = { - {(int) MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply}, - {(int) MSG_DENIED, (xdrproc_t)xdr_rejected_reply}, - {__dontcare__, NULL_xdrproc_t} + {(int) MSG_ACCEPTED, (xdrproc_t)xdr_accepted_reply}, + {(int) MSG_DENIED, (xdrproc_t)xdr_rejected_reply}, + {__dontcare__, NULL_xdrproc_t} }; /* @@ -136,13 +136,13 @@ static struct xdr_discrim reply_dscrm[3] = { */ bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg) { - if (xdr_u_long(xdrs, &(rmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *) & (rmsg->rm_direction)) && - (rmsg->rm_direction == REPLY)) - return (xdr_union(xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat), - (char*) & (rmsg->rm_reply.ru), reply_dscrm, - NULL_xdrproc_t)); - return (FALSE); + if (xdr_u_long(xdrs, &(rmsg->rm_xid)) && + xdr_enum(xdrs, (enum_t *) & (rmsg->rm_direction)) && + (rmsg->rm_direction == REPLY)) + return (xdr_union(xdrs, (enum_t *) & (rmsg->rm_reply.rp_stat), + (char*) & (rmsg->rm_reply.ru), reply_dscrm, + NULL_xdrproc_t)); + return (FALSE); } @@ -154,16 +154,16 @@ bool_t xdr_replymsg(XDR *xdrs, struct rpc_msg *rmsg) bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg) { - cmsg->rm_direction = CALL; - cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; - if ( - (xdrs->x_op == XDR_ENCODE) && - xdr_u_long(xdrs, &(cmsg->rm_xid)) && - xdr_enum(xdrs, (enum_t *) & (cmsg->rm_direction)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && - xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog))) - return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); - return (FALSE); + cmsg->rm_direction = CALL; + cmsg->rm_call.cb_rpcvers = RPC_MSG_VERSION; + if ( + (xdrs->x_op == XDR_ENCODE) && + xdr_u_long(xdrs, &(cmsg->rm_xid)) && + xdr_enum(xdrs, (enum_t *) & (cmsg->rm_direction)) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_rpcvers)) && + xdr_u_long(xdrs, &(cmsg->rm_call.cb_prog))) + return (xdr_u_long(xdrs, &(cmsg->rm_call.cb_vers))); + return (FALSE); } /* ************************** Client utility routine ************* */ @@ -171,55 +171,55 @@ bool_t xdr_callhdr(XDR *xdrs, struct rpc_msg *cmsg) static void accepted(enum accept_stat acpt_stat, struct rpc_err *error) { - switch (acpt_stat) { + switch (acpt_stat) { - case PROG_UNAVAIL: - error->re_status = RPC_PROGUNAVAIL; - return; + case PROG_UNAVAIL: + error->re_status = RPC_PROGUNAVAIL; + return; - case PROG_MISMATCH: - error->re_status = RPC_PROGVERSMISMATCH; - return; + case PROG_MISMATCH: + error->re_status = RPC_PROGVERSMISMATCH; + return; - case PROC_UNAVAIL: - error->re_status = RPC_PROCUNAVAIL; - return; + case PROC_UNAVAIL: + error->re_status = RPC_PROCUNAVAIL; + return; - case GARBAGE_ARGS: - error->re_status = RPC_CANTDECODEARGS; - return; + case GARBAGE_ARGS: + error->re_status = RPC_CANTDECODEARGS; + return; - case SYSTEM_ERR: - error->re_status = RPC_SYSTEMERROR; - return; + case SYSTEM_ERR: + error->re_status = RPC_SYSTEMERROR; + return; - case SUCCESS: - error->re_status = RPC_SUCCESS; - return; - } - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long) MSG_ACCEPTED; - error->re_lb.s2 = (long) acpt_stat; + case SUCCESS: + error->re_status = RPC_SUCCESS; + return; + } + /* something's wrong, but we don't know what ... */ + error->re_status = RPC_FAILED; + error->re_lb.s1 = (long) MSG_ACCEPTED; + error->re_lb.s2 = (long) acpt_stat; } static void rejected(enum reject_stat rjct_stat, struct rpc_err *error) { - switch (rjct_stat) { + switch (rjct_stat) { - case RPC_VERSMISMATCH: - error->re_status = RPC_VERSMISMATCH; - return; + case RPC_VERSMISMATCH: + error->re_status = RPC_VERSMISMATCH; + return; - case AUTH_ERROR: - error->re_status = RPC_AUTHERROR; - return; - } - /* something's wrong, but we don't know what ... */ - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long) MSG_DENIED; - error->re_lb.s2 = (long) rjct_stat; + case AUTH_ERROR: + error->re_status = RPC_AUTHERROR; + return; + } + /* something's wrong, but we don't know what ... */ + error->re_status = RPC_FAILED; + error->re_lb.s1 = (long) MSG_DENIED; + error->re_lb.s2 = (long) rjct_stat; } /* @@ -228,40 +228,40 @@ static void rejected(enum reject_stat rjct_stat, struct rpc_err *error) void _seterr_reply(struct rpc_msg *msg, struct rpc_err *error) { - /* optimized for normal, SUCCESSful case */ - switch (msg->rm_reply.rp_stat) { - - case MSG_ACCEPTED: - if (msg->acpted_rply.ar_stat == SUCCESS) { - error->re_status = RPC_SUCCESS; - return; - }; - accepted((enum accept_stat)msg->acpted_rply.ar_stat, error); - break; - - case MSG_DENIED: - rejected((enum reject_stat)msg->rjcted_rply.rj_stat, error); - break; - - default: - error->re_status = RPC_FAILED; - error->re_lb.s1 = (long) (msg->rm_reply.rp_stat); - break; - } - switch (error->re_status) { - - case RPC_VERSMISMATCH: - error->re_vers.low = msg->rjcted_rply.rj_vers.low; - error->re_vers.high = msg->rjcted_rply.rj_vers.high; - break; - - case RPC_AUTHERROR: - error->re_why = msg->rjcted_rply.rj_why; - break; - - case RPC_PROGVERSMISMATCH: - error->re_vers.low = msg->acpted_rply.ar_vers.low; - error->re_vers.high = msg->acpted_rply.ar_vers.high; - break; - } + /* optimized for normal, SUCCESSful case */ + switch (msg->rm_reply.rp_stat) { + + case MSG_ACCEPTED: + if (msg->acpted_rply.ar_stat == SUCCESS) { + error->re_status = RPC_SUCCESS; + return; + }; + accepted((enum accept_stat)msg->acpted_rply.ar_stat, error); + break; + + case MSG_DENIED: + rejected((enum reject_stat)msg->rjcted_rply.rj_stat, error); + break; + + default: + error->re_status = RPC_FAILED; + error->re_lb.s1 = (long) (msg->rm_reply.rp_stat); + break; + } + switch (error->re_status) { + + case RPC_VERSMISMATCH: + error->re_vers.low = msg->rjcted_rply.rj_vers.low; + error->re_vers.high = msg->rjcted_rply.rj_vers.high; + break; + + case RPC_AUTHERROR: + error->re_why = msg->rjcted_rply.rj_why; + break; + + case RPC_PROGVERSMISMATCH: + error->re_vers.low = msg->acpted_rply.ar_vers.low; + error->re_vers.high = msg->acpted_rply.ar_vers.high; + break; + } } diff --git a/components/dfs/filesystems/nfs/rpc/types.h b/components/dfs/filesystems/nfs/rpc/types.h index d76d89146c..043bfab896 100644 --- a/components/dfs/filesystems/nfs/rpc/types.h +++ b/components/dfs/filesystems/nfs/rpc/types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/nfs/rpc/xdr.c b/components/dfs/filesystems/nfs/rpc/xdr.c index a6b1b67afb..fa3b12ef00 100644 --- a/components/dfs/filesystems/nfs/rpc/xdr.c +++ b/components/dfs/filesystems/nfs/rpc/xdr.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ +/* @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -14,23 +14,23 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 @@ -58,9 +58,9 @@ static char sccsid[] = "@(#)xdr.c 1.35 87/08/12"; /* * constants specific to the xdr "protocol" */ -#define XDR_FALSE ((long) 0) -#define XDR_TRUE ((long) 1) -#define LASTUNSIGNED ((unsigned int) 0-1) +#define XDR_FALSE ((long) 0) +#define XDR_TRUE ((long) 1) +#define LASTUNSIGNED ((unsigned int) 0-1) /* * for unit alignment @@ -73,21 +73,21 @@ static char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; */ void xdr_free(xdrproc_t proc, char* objp) { - XDR x; + XDR x; - x.x_op = XDR_FREE; - (*proc) (&x, objp); + x.x_op = XDR_FREE; + (*proc) (&x, objp); } /* * XDR nothing */ bool_t xdr_void( /* xdrs, addr */ ) - /* XDR *xdrs; */ - /* char* addr; */ + /* XDR *xdrs; */ + /* char* addr; */ { - return (TRUE); + return (TRUE); } /* @@ -95,25 +95,25 @@ bool_t xdr_void( /* xdrs, addr */ ) */ bool_t xdr_int(XDR* xdrs, int* ip) { - if (sizeof(int) == sizeof(long)) { - return (xdr_long(xdrs, (long *) ip)); - } else if (sizeof(int) < sizeof(long)) { - long l; - switch (xdrs->x_op) { - case XDR_ENCODE: - l = (long) *ip; - return XDR_PUTLONG(xdrs, &l); - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) - return FALSE; - *ip = (int) l; - case XDR_FREE: - return TRUE; - } - return FALSE; - } else { - return (xdr_short(xdrs, (short *) ip)); - } + if (sizeof(int) == sizeof(long)) { + return (xdr_long(xdrs, (long *) ip)); + } else if (sizeof(int) < sizeof(long)) { + long l; + switch (xdrs->x_op) { + case XDR_ENCODE: + l = (long) *ip; + return XDR_PUTLONG(xdrs, &l); + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, &l)) + return FALSE; + *ip = (int) l; + case XDR_FREE: + return TRUE; + } + return FALSE; + } else { + return (xdr_short(xdrs, (short *) ip)); + } } /* @@ -121,25 +121,25 @@ bool_t xdr_int(XDR* xdrs, int* ip) */ bool_t xdr_u_int(XDR* xdrs, unsigned int* up) { - if (sizeof(unsigned int) == sizeof(unsigned long)) { - return (xdr_u_long(xdrs, (unsigned long *) up)); - } else if (sizeof(unsigned int) < sizeof(unsigned long)) { - unsigned long l; - switch (xdrs->x_op) { - case XDR_ENCODE: - l = (unsigned long) *up; - return XDR_PUTLONG(xdrs, (long*)&l); - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long*)&l)) - return FALSE; - *up = (unsigned int) l; - case XDR_FREE: - return TRUE; - } - return FALSE; - } else { - return (xdr_short(xdrs, (short *) up)); - } + if (sizeof(unsigned int) == sizeof(unsigned long)) { + return (xdr_u_long(xdrs, (unsigned long *) up)); + } else if (sizeof(unsigned int) < sizeof(unsigned long)) { + unsigned long l; + switch (xdrs->x_op) { + case XDR_ENCODE: + l = (unsigned long) *up; + return XDR_PUTLONG(xdrs, (long*)&l); + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, (long*)&l)) + return FALSE; + *up = (unsigned int) l; + case XDR_FREE: + return TRUE; + } + return FALSE; + } else { + return (xdr_short(xdrs, (short *) up)); + } } /* @@ -149,18 +149,18 @@ bool_t xdr_u_int(XDR* xdrs, unsigned int* up) bool_t xdr_long(XDR* xdrs, long* lp) { - if (xdrs->x_op == XDR_ENCODE - && (sizeof(int32_t) == sizeof(long) - || (int32_t) *lp == *lp)) - return (XDR_PUTLONG(xdrs, lp)); + if (xdrs->x_op == XDR_ENCODE + && (sizeof(int32_t) == sizeof(long) + || (int32_t) *lp == *lp)) + return (XDR_PUTLONG(xdrs, lp)); - if (xdrs->x_op == XDR_DECODE) - return (XDR_GETLONG(xdrs, lp)); + if (xdrs->x_op == XDR_DECODE) + return (XDR_GETLONG(xdrs, lp)); - if (xdrs->x_op == XDR_FREE) - return (TRUE); + if (xdrs->x_op == XDR_FREE) + return (TRUE); - return (FALSE); + return (FALSE); } /* @@ -171,25 +171,25 @@ bool_t xdr_u_long(XDR* xdrs, unsigned long* ulp) { if (xdrs->x_op == XDR_DECODE) { - long l; - if (XDR_GETLONG(xdrs, &l) == FALSE) - return FALSE; - *ulp = (uint32_t) l; - return TRUE; + long l; + if (XDR_GETLONG(xdrs, &l) == FALSE) + return FALSE; + *ulp = (uint32_t) l; + return TRUE; } if (xdrs->x_op == XDR_ENCODE) { - if (sizeof(uint32_t) != sizeof(unsigned long) - && (uint32_t) *ulp != *ulp) - return FALSE; + if (sizeof(uint32_t) != sizeof(unsigned long) + && (uint32_t) *ulp != *ulp) + return FALSE; - return (XDR_PUTLONG(xdrs, (long *) ulp)); + return (XDR_PUTLONG(xdrs, (long *) ulp)); } - if (xdrs->x_op == XDR_FREE) - return (TRUE); + if (xdrs->x_op == XDR_FREE) + return (TRUE); - return (FALSE); + return (FALSE); } @@ -254,25 +254,25 @@ bool_t xdr_u_longlong_t (XDR * xdrs, unsigned long long* ullp) */ bool_t xdr_short(XDR* xdrs, short* sp) { - long l; + long l; - switch (xdrs->x_op) { + switch (xdrs->x_op) { - case XDR_ENCODE: - l = (long) *sp; - return (XDR_PUTLONG(xdrs, &l)); + case XDR_ENCODE: + l = (long) *sp; + return (XDR_PUTLONG(xdrs, &l)); - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &l)) { - return (FALSE); - } - *sp = (short) l; - return (TRUE); + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, &l)) { + return (FALSE); + } + *sp = (short) l; + return (TRUE); - case XDR_FREE: - return (TRUE); - } - return (FALSE); + case XDR_FREE: + return (TRUE); + } + return (FALSE); } /* @@ -280,25 +280,25 @@ bool_t xdr_short(XDR* xdrs, short* sp) */ bool_t xdr_u_short(XDR* xdrs, unsigned short* usp) { - unsigned long l; + unsigned long l; - switch (xdrs->x_op) { + switch (xdrs->x_op) { - case XDR_ENCODE: - l = (unsigned long) * usp; - return (XDR_PUTLONG(xdrs, (long*)&l)); + case XDR_ENCODE: + l = (unsigned long) * usp; + return (XDR_PUTLONG(xdrs, (long*)&l)); - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, (long*)&l)) { - return (FALSE); - } - *usp = (unsigned short) l; - return (TRUE); + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, (long*)&l)) { + return (FALSE); + } + *usp = (unsigned short) l; + return (TRUE); - case XDR_FREE: - return (TRUE); - } - return (FALSE); + case XDR_FREE: + return (TRUE); + } + return (FALSE); } @@ -307,14 +307,14 @@ bool_t xdr_u_short(XDR* xdrs, unsigned short* usp) */ bool_t xdr_char(XDR* xdrs, char* cp) { - int i; - - i = (*cp); - if (!xdr_int(xdrs, &i)) { - return (FALSE); - } - *cp = i; - return (TRUE); + int i; + + i = (*cp); + if (!xdr_int(xdrs, &i)) { + return (FALSE); + } + *cp = i; + return (TRUE); } /* @@ -322,14 +322,14 @@ bool_t xdr_char(XDR* xdrs, char* cp) */ bool_t xdr_u_char(XDR* xdrs, unsigned char* cp) { - unsigned int u; - - u = (*cp); - if (!xdr_u_int(xdrs, &u)) { - return (FALSE); - } - *cp = u; - return (TRUE); + unsigned int u; + + u = (*cp); + if (!xdr_u_int(xdrs, &u)) { + return (FALSE); + } + *cp = u; + return (TRUE); } /* @@ -337,25 +337,25 @@ bool_t xdr_u_char(XDR* xdrs, unsigned char* cp) */ bool_t xdr_bool(XDR *xdrs, bool_t *bp) { - long lb; + long lb; - switch (xdrs->x_op) { + switch (xdrs->x_op) { - case XDR_ENCODE: - lb = *bp ? XDR_TRUE : XDR_FALSE; - return (XDR_PUTLONG(xdrs, &lb)); + case XDR_ENCODE: + lb = *bp ? XDR_TRUE : XDR_FALSE; + return (XDR_PUTLONG(xdrs, &lb)); - case XDR_DECODE: - if (!XDR_GETLONG(xdrs, &lb)) { - return (FALSE); - } - *bp = (lb == XDR_FALSE) ? FALSE : TRUE; - return (TRUE); + case XDR_DECODE: + if (!XDR_GETLONG(xdrs, &lb)) { + return (FALSE); + } + *bp = (lb == XDR_FALSE) ? FALSE : TRUE; + return (TRUE); - case XDR_FREE: - return (TRUE); - } - return (FALSE); + case XDR_FREE: + return (TRUE); + } + return (FALSE); } /* @@ -363,10 +363,10 @@ bool_t xdr_bool(XDR *xdrs, bool_t *bp) */ bool_t xdr_enum(XDR *xdrs, enum_t *ep) { - /* - * enums are treated as ints - */ - return (xdr_long(xdrs, (long *) ep)); + /* + * enums are treated as ints + */ + return (xdr_long(xdrs, (long *) ep)); } /* @@ -376,45 +376,45 @@ bool_t xdr_enum(XDR *xdrs, enum_t *ep) */ bool_t xdr_opaque(XDR *xdrs, char* cp, unsigned int cnt) { - register unsigned int rndup; - static char crud[BYTES_PER_XDR_UNIT]; - - /* - * if no data we are done - */ - if (cnt == 0) - return (TRUE); - - /* - * round byte count to full xdr units - */ - rndup = cnt % BYTES_PER_XDR_UNIT; - if (rndup > 0) - rndup = BYTES_PER_XDR_UNIT - rndup; - - if (xdrs->x_op == XDR_DECODE) { - if (!XDR_GETBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_GETBYTES(xdrs, crud, rndup)); - } - - if (xdrs->x_op == XDR_ENCODE) { - if (!XDR_PUTBYTES(xdrs, cp, cnt)) { - return (FALSE); - } - if (rndup == 0) - return (TRUE); - return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); - } - - if (xdrs->x_op == XDR_FREE) { - return (TRUE); - } - - return (FALSE); + register unsigned int rndup; + static char crud[BYTES_PER_XDR_UNIT]; + + /* + * if no data we are done + */ + if (cnt == 0) + return (TRUE); + + /* + * round byte count to full xdr units + */ + rndup = cnt % BYTES_PER_XDR_UNIT; + if (rndup > 0) + rndup = BYTES_PER_XDR_UNIT - rndup; + + if (xdrs->x_op == XDR_DECODE) { + if (!XDR_GETBYTES(xdrs, cp, cnt)) { + return (FALSE); + } + if (rndup == 0) + return (TRUE); + return (XDR_GETBYTES(xdrs, crud, rndup)); + } + + if (xdrs->x_op == XDR_ENCODE) { + if (!XDR_PUTBYTES(xdrs, cp, cnt)) { + return (FALSE); + } + if (rndup == 0) + return (TRUE); + return (XDR_PUTBYTES(xdrs, xdr_zero, rndup)); + } + + if (xdrs->x_op == XDR_FREE) { + return (TRUE); + } + + return (FALSE); } /* @@ -424,49 +424,49 @@ bool_t xdr_opaque(XDR *xdrs, char* cp, unsigned int cnt) */ bool_t xdr_bytes(XDR *xdrs, char** cpp, unsigned int *sizep, unsigned int maxsize) { - register char *sp = *cpp; /* sp is the actual string pointer */ - register unsigned int nodesize; - - /* - * first deal with the length since xdr bytes are counted - */ - if (!xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - nodesize = *sizep; - if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) { - *cpp = sp = (char *) rt_malloc(nodesize); - } - if (sp == NULL) { - rt_kprintf("xdr_bytes: out of memory\n"); - return (FALSE); - } - /* fall into ... */ - - case XDR_ENCODE: - return (xdr_opaque(xdrs, sp, nodesize)); - - case XDR_FREE: - if (sp != NULL) { - rt_free(sp); - *cpp = NULL; - } - return (TRUE); - } - return (FALSE); + register char *sp = *cpp; /* sp is the actual string pointer */ + register unsigned int nodesize; + + /* + * first deal with the length since xdr bytes are counted + */ + if (!xdr_u_int(xdrs, sizep)) { + return (FALSE); + } + nodesize = *sizep; + if ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE)) { + return (FALSE); + } + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + + case XDR_DECODE: + if (nodesize == 0) { + return (TRUE); + } + if (sp == NULL) { + *cpp = sp = (char *) rt_malloc(nodesize); + } + if (sp == NULL) { + rt_kprintf("xdr_bytes: out of memory\n"); + return (FALSE); + } + /* fall into ... */ + + case XDR_ENCODE: + return (xdr_opaque(xdrs, sp, nodesize)); + + case XDR_FREE: + if (sp != NULL) { + rt_free(sp); + *cpp = NULL; + } + return (TRUE); + } + return (FALSE); } /* @@ -474,7 +474,7 @@ bool_t xdr_bytes(XDR *xdrs, char** cpp, unsigned int *sizep, unsigned int maxsiz */ bool_t xdr_netobj(XDR *xdrs, struct netobj *np) { - return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); + return (xdr_bytes(xdrs, &np->n_bytes, &np->n_len, MAX_NETOBJ_SZ)); } /* @@ -490,30 +490,30 @@ bool_t xdr_netobj(XDR *xdrs, struct netobj *np) */ bool_t xdr_union(XDR* xdrs, enum_t* dscmp, char* unp, const struct xdr_discrim* choices, xdrproc_t dfault) { - register enum_t dscm; - - /* - * we deal with the discriminator; it's an enum - */ - if (!xdr_enum(xdrs, dscmp)) { - return (FALSE); - } - dscm = *dscmp; - - /* - * search choices for a value that matches the discriminator. - * if we find one, execute the xdr routine for that value. - */ - for (; choices->proc != NULL_xdrproc_t; choices++) { - if (choices->value == dscm) - return ((*(choices->proc)) (xdrs, unp, LASTUNSIGNED)); - } - - /* - * no match - execute the default xdr routine if there is one - */ - return ((dfault == NULL_xdrproc_t) ? FALSE : - (*dfault) (xdrs, unp, LASTUNSIGNED)); + register enum_t dscm; + + /* + * we deal with the discriminator; it's an enum + */ + if (!xdr_enum(xdrs, dscmp)) { + return (FALSE); + } + dscm = *dscmp; + + /* + * search choices for a value that matches the discriminator. + * if we find one, execute the xdr routine for that value. + */ + for (; choices->proc != NULL_xdrproc_t; choices++) { + if (choices->value == dscm) + return ((*(choices->proc)) (xdrs, unp, LASTUNSIGNED)); + } + + /* + * no match - execute the default xdr routine if there is one + */ + return ((dfault == NULL_xdrproc_t) ? FALSE : + (*dfault) (xdrs, unp, LASTUNSIGNED)); } @@ -533,70 +533,70 @@ bool_t xdr_union(XDR* xdrs, enum_t* dscmp, char* unp, const struct xdr_discrim* */ bool_t xdr_string(XDR *xdrs, char **cpp, unsigned int maxsize) { - register char *sp = *cpp; /* sp is the actual string pointer */ - unsigned int size; - unsigned int nodesize; - - /* - * first deal with the length since xdr strings are counted-strings - */ - switch (xdrs->x_op) { - case XDR_FREE: - if (sp == NULL) { - return (TRUE); /* already free */ - } - /* fall through... */ - case XDR_ENCODE: - size = strlen(sp); - break; - } - if (!xdr_u_int(xdrs, &size)) { - return (FALSE); - } - if (size > maxsize) { - return (FALSE); - } - nodesize = size + 1; - - /* - * now deal with the actual bytes - */ - switch (xdrs->x_op) { - - case XDR_DECODE: - if (nodesize == 0) { - return (TRUE); - } - if (sp == NULL) - *cpp = sp = (char *) rt_malloc(nodesize); - if (sp == NULL) { - rt_kprintf("xdr_string: out of memory\n"); - return (FALSE); - } - sp[size] = 0; - /* fall into ... */ - - case XDR_ENCODE: - return (xdr_opaque(xdrs, sp, size)); - - case XDR_FREE: - rt_free(sp); - *cpp = NULL; - return (TRUE); - } - return (FALSE); + register char *sp = *cpp; /* sp is the actual string pointer */ + unsigned int size; + unsigned int nodesize; + + /* + * first deal with the length since xdr strings are counted-strings + */ + switch (xdrs->x_op) { + case XDR_FREE: + if (sp == NULL) { + return (TRUE); /* already free */ + } + /* fall through... */ + case XDR_ENCODE: + size = strlen(sp); + break; + } + if (!xdr_u_int(xdrs, &size)) { + return (FALSE); + } + if (size > maxsize) { + return (FALSE); + } + nodesize = size + 1; + + /* + * now deal with the actual bytes + */ + switch (xdrs->x_op) { + + case XDR_DECODE: + if (nodesize == 0) { + return (TRUE); + } + if (sp == NULL) + *cpp = sp = (char *) rt_malloc(nodesize); + if (sp == NULL) { + rt_kprintf("xdr_string: out of memory\n"); + return (FALSE); + } + sp[size] = 0; + /* fall into ... */ + + case XDR_ENCODE: + return (xdr_opaque(xdrs, sp, size)); + + case XDR_FREE: + rt_free(sp); + *cpp = NULL; + return (TRUE); + } + return (FALSE); } -/* - * Wrapper for xdr_string that can be called directly from +/* + * Wrapper for xdr_string that can be called directly from * routines like clnt_call */ bool_t xdr_wrapstring(XDR *xdrs, char **cpp) { - if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { - return (TRUE); - } - return (FALSE); + if (xdr_string(xdrs, cpp, LASTUNSIGNED)) { + return (TRUE); + } + return (FALSE); } /* @@ -608,69 +608,69 @@ bool_t xdr_wrapstring(XDR *xdrs, char **cpp) */ bool_t xdr_array(XDR *xdrs, char **addrp, unsigned int *sizep, unsigned int maxsize, unsigned int elsize, xdrproc_t elproc) { - register unsigned int i; - register char* target = *addrp; - register unsigned int c; /* the actual element count */ - register bool_t stat = TRUE; - register unsigned int nodesize; - - /* like strings, arrays are really counted arrays */ - if (!xdr_u_int(xdrs, sizep)) { - return (FALSE); - } - c = *sizep; - if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { - return (FALSE); - } - /* duh, look for integer overflow (fefe) */ - { - unsigned int i; - nodesize = 0; - for (i=c; i; --i) { - unsigned int tmp=nodesize+elsize; - if (tmpx_op) { - case XDR_DECODE: - if (c == 0) - return (TRUE); - *addrp = target = rt_malloc(nodesize); - if (target == NULL) { - rt_kprintf("xdr_array: out of memory\n"); - return (FALSE); - } - memset(target, 0, nodesize); - break; - - case XDR_FREE: - return (TRUE); - } - - /* - * now we xdr each element of array - */ - for (i = 0; (i < c) && stat; i++) { - stat = (*elproc) (xdrs, target, LASTUNSIGNED); - target += elsize; - } - - /* - * the array may need freeing - */ - if (xdrs->x_op == XDR_FREE) { - rt_free(*addrp); - *addrp = NULL; - } - return (stat); + register unsigned int i; + register char* target = *addrp; + register unsigned int c; /* the actual element count */ + register bool_t stat = TRUE; + register unsigned int nodesize; + + /* like strings, arrays are really counted arrays */ + if (!xdr_u_int(xdrs, sizep)) { + return (FALSE); + } + c = *sizep; + if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) { + return (FALSE); + } + /* duh, look for integer overflow (fefe) */ + { + unsigned int i; + nodesize = 0; + for (i=c; i; --i) { + unsigned int tmp=nodesize+elsize; + if (tmpx_op) { + case XDR_DECODE: + if (c == 0) + return (TRUE); + *addrp = target = rt_malloc(nodesize); + if (target == NULL) { + rt_kprintf("xdr_array: out of memory\n"); + return (FALSE); + } + memset(target, 0, nodesize); + break; + + case XDR_FREE: + return (TRUE); + } + + /* + * now we xdr each element of array + */ + for (i = 0; (i < c) && stat; i++) { + stat = (*elproc) (xdrs, target, LASTUNSIGNED); + target += elsize; + } + + /* + * the array may need freeing + */ + if (xdrs->x_op == XDR_FREE) { + rt_free(*addrp); + *addrp = NULL; + } + return (stat); } /* @@ -685,17 +685,17 @@ bool_t xdr_array(XDR *xdrs, char **addrp, unsigned int *sizep, unsigned int maxs */ bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elemsize, xdrproc_t xdr_elem) { - register unsigned int i; - register char *elptr; - - elptr = basep; - for (i = 0; i < nelem; i++) { - if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) { - return (FALSE); - } - elptr += elemsize; - } - return (TRUE); + register unsigned int i; + register char *elptr; + + elptr = basep; + for (i = 0; i < nelem; i++) { + if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED)) { + return (FALSE); + } + elptr += elemsize; + } + return (TRUE); } @@ -710,31 +710,31 @@ bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elems */ bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc) { - register char* loc = *pp; - register bool_t stat; - - if (loc == NULL) - switch (xdrs->x_op) { - case XDR_FREE: - return (TRUE); - - case XDR_DECODE: - *pp = loc = (char*) rt_malloc(size); - if (loc == NULL) { - rt_kprintf("xdr_reference: out of memory\n"); - return (FALSE); - } - memset(loc, 0, (int) size); - break; - } - - stat = (*proc) (xdrs, loc, LASTUNSIGNED); - - if (xdrs->x_op == XDR_FREE) { - rt_free(loc); - *pp = NULL; - } - return (stat); + register char* loc = *pp; + register bool_t stat; + + if (loc == NULL) + switch (xdrs->x_op) { + case XDR_FREE: + return (TRUE); + + case XDR_DECODE: + *pp = loc = (char*) rt_malloc(size); + if (loc == NULL) { + rt_kprintf("xdr_reference: out of memory\n"); + return (FALSE); + } + memset(loc, 0, (int) size); + break; + } + + stat = (*proc) (xdrs, loc, LASTUNSIGNED); + + if (xdrs->x_op == XDR_FREE) { + rt_free(loc); + *pp = NULL; + } + return (stat); } @@ -760,15 +760,15 @@ bool_t xdr_reference(XDR *xdrs, char **pp, unsigned int size, xdrproc_t proc) bool_t xdr_pointer(XDR *xdrs, char **objpp, unsigned int obj_size, xdrproc_t xdr_obj) { - bool_t more_data; - - more_data = (*objpp != NULL); - if (!xdr_bool(xdrs, &more_data)) { - return (FALSE); - } - if (!more_data) { - *objpp = NULL; - return (TRUE); - } - return (xdr_reference(xdrs, objpp, obj_size, xdr_obj)); + bool_t more_data; + + more_data = (*objpp != NULL); + if (!xdr_bool(xdrs, &more_data)) { + return (FALSE); + } + if (!more_data) { + *objpp = NULL; + return (TRUE); + } + return (xdr_reference(xdrs, objpp, obj_size, xdr_obj)); } diff --git a/components/dfs/filesystems/nfs/rpc/xdr.h b/components/dfs/filesystems/nfs/rpc/xdr.h index fe38c4d120..d938f0eaa8 100644 --- a/components/dfs/filesystems/nfs/rpc/xdr.h +++ b/components/dfs/filesystems/nfs/rpc/xdr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -93,7 +93,7 @@ enum xdr_op { /* * This is the number of bytes per unit of external data. */ -#define BYTES_PER_XDR_UNIT (4) +#define BYTES_PER_XDR_UNIT (4) /* * This only works if the above is a power of 2. But it's defined to be * 4 by the appropriate RFCs. So it will work. And it's normally quicker @@ -110,35 +110,35 @@ enum xdr_op { typedef struct XDR XDR; struct XDR { - enum xdr_op x_op; /* operation; fast additional param */ + enum xdr_op x_op; /* operation; fast additional param */ struct xdr_ops { - bool_t (*x_getlong) (XDR *__xdrs, long *__lp); - /* get a long from underlying stream */ - bool_t (*x_putlong) (XDR *__xdrs, const long *__lp); - /* put a long to " */ - bool_t (*x_getbytes) (XDR *__xdrs, char* __addr, unsigned int __len); - /* get some bytes from " */ - bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, unsigned int __len); - /* put some bytes to " */ - unsigned int (*x_getpostn) (const XDR *__xdrs); - /* returns bytes off from beginning */ - bool_t (*x_setpostn) (XDR *__xdrs, unsigned int __pos); - /* lets you reposition the stream */ - int32_t *(*x_inline) (XDR *__xdrs, unsigned int __len); - /* buf quick ptr to buffered data */ - void (*x_destroy) (XDR *__xdrs); - /* free privates of this xdr_stream */ - bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); - /* get a int from underlying stream */ - bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip); - /* put a int to " */ + bool_t (*x_getlong) (XDR *__xdrs, long *__lp); + /* get a long from underlying stream */ + bool_t (*x_putlong) (XDR *__xdrs, const long *__lp); + /* put a long to " */ + bool_t (*x_getbytes) (XDR *__xdrs, char* __addr, unsigned int __len); + /* get some bytes from " */ + bool_t (*x_putbytes) (XDR *__xdrs, const char *__addr, unsigned int __len); + /* put some bytes to " */ + unsigned int (*x_getpostn) (const XDR *__xdrs); + /* returns bytes off from beginning */ + bool_t (*x_setpostn) (XDR *__xdrs, unsigned int __pos); + /* lets you reposition the stream */ + int32_t *(*x_inline) (XDR *__xdrs, unsigned int __len); + /* buf quick ptr to buffered data */ + void (*x_destroy) (XDR *__xdrs); + /* free privates of this xdr_stream */ + bool_t (*x_getint32) (XDR *__xdrs, int32_t *__ip); + /* get a int from underlying stream */ + bool_t (*x_putint32) (XDR *__xdrs, const int32_t *__ip); + /* put a int to " */ } *x_ops; - char* x_public; /* users' data */ - char* x_private; /* pointer to private data */ - char* x_base; /* private used for position info */ - unsigned int x_handy; /* extra private word */ + char* x_public; /* users' data */ + char* x_private; /* pointer to private data */ + char* x_base; /* private used for position info */ + unsigned int x_handy; /* extra private word */ }; /* @@ -173,51 +173,51 @@ typedef bool_t (*xdrproc_t) (XDR *, void *,...); #define xdr_putint32(xdrs, int32p) \ (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) -#define XDR_GETLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) -#define xdr_getlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, longp) - -#define XDR_PUTLONG(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) -#define xdr_putlong(xdrs, longp) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, longp) - -#define XDR_GETBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) -#define xdr_getbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) - -#define XDR_PUTBYTES(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) -#define xdr_putbytes(xdrs, addr, len) \ - (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) - -#define XDR_GETPOS(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) -#define xdr_getpos(xdrs) \ - (*(xdrs)->x_ops->x_getpostn)(xdrs) - -#define XDR_SETPOS(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) -#define xdr_setpos(xdrs, pos) \ - (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) - -#define XDR_INLINE(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) -#define xdr_inline(xdrs, len) \ - (*(xdrs)->x_ops->x_inline)(xdrs, len) - -#define XDR_DESTROY(xdrs) \ - do { \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs); \ - } while (0) -#define xdr_destroy(xdrs) \ - do { \ - if ((xdrs)->x_ops->x_destroy) \ - (*(xdrs)->x_ops->x_destroy)(xdrs); \ - } while (0) +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) +#define xdr_destroy(xdrs) \ + do { \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs); \ + } while (0) /* * Support struct for discriminated unions. @@ -261,10 +261,10 @@ struct xdr_discrim * and shouldn't be used any longer. Code which use this defines or longs * in the RPC code will not work on 64bit Solaris platforms ! */ -#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf)) -#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v))) -#define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf)) -#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) +#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf)) +#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v))) +#define IXDR_GET_U_LONG(buf) ((unsigned long)IXDR_GET_LONG(buf)) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG(buf, (long)(v)) #define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) @@ -305,24 +305,24 @@ extern bool_t xdr_uint64_t (XDR *__xdrs, uint64_t *__up); extern bool_t xdr_bool (XDR *__xdrs, bool_t *__bp); extern bool_t xdr_enum (XDR *__xdrs, enum_t *__ep); extern bool_t xdr_array (XDR * _xdrs, char* *__addrp, unsigned int *__sizep, - unsigned int __maxsize, unsigned int __elsize, xdrproc_t __elproc); + unsigned int __maxsize, unsigned int __elsize, xdrproc_t __elproc); extern bool_t xdr_bytes (XDR *xdrs, char **cpp, unsigned int *sizep, - unsigned int maxsize); + unsigned int maxsize); extern bool_t xdr_opaque (XDR *__xdrs, char* __cp, unsigned int __cnt); extern bool_t xdr_string (XDR *xdrs, char **cpp, unsigned int maxsize); extern bool_t xdr_union (XDR *__xdrs, enum_t *__dscmp, char *__unp, - const struct xdr_discrim *__choices, - xdrproc_t dfault); + const struct xdr_discrim *__choices, + xdrproc_t dfault); extern bool_t xdr_char (XDR *__xdrs, char *__cp); extern bool_t xdr_u_char (XDR *__xdrs, unsigned char *__cp); extern bool_t xdr_vector (XDR *__xdrs, char *__basep, unsigned int __nelem, - unsigned int __elemsize, xdrproc_t __xdr_elem); + unsigned int __elemsize, xdrproc_t __xdr_elem); extern bool_t xdr_float (XDR *__xdrs, float *__fp); extern bool_t xdr_double (XDR *__xdrs, double *__dp); extern bool_t xdr_reference (XDR *__xdrs, char* *__xpp, unsigned int __size, - xdrproc_t __proc); + xdrproc_t __proc); extern bool_t xdr_pointer (XDR *__xdrs, char **__objpp, - unsigned int __obj_size, xdrproc_t __xdr_obj); + unsigned int __obj_size, xdrproc_t __xdr_obj); extern bool_t xdr_wrapstring (XDR *__xdrs, char **cpp); extern unsigned long xdr_sizeof (xdrproc_t, void *); @@ -346,13 +346,13 @@ extern bool_t xdr_netobj (XDR *__xdrs, struct netobj *__np); /* XDR using memory buffers */ extern void xdrmem_create (XDR *__xdrs, const char* __addr, - unsigned int __size, enum xdr_op __xop); + unsigned int __size, enum xdr_op __xop); /* XDR pseudo records for tcp */ extern void xdrrec_create (XDR *__xdrs, unsigned int __sendsize, - unsigned int __recvsize, char* __tcp_handle, - int (*__readit) (char *, char *, int), - int (*__writeit) (char *, char *, int)); + unsigned int __recvsize, char* __tcp_handle, + int (*__readit) (char *, char *, int), + int (*__writeit) (char *, char *, int)); /* make end of xdr record */ extern bool_t xdrrec_endofrecord (XDR *__xdrs, bool_t __sendnow); diff --git a/components/dfs/filesystems/nfs/rpc/xdr_mem.c b/components/dfs/filesystems/nfs/rpc/xdr_mem.c index ca69ed3647..7bd4737e16 100644 --- a/components/dfs/filesystems/nfs/rpc/xdr_mem.c +++ b/components/dfs/filesystems/nfs/rpc/xdr_mem.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes */ -/* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */ +/* @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -14,23 +14,23 @@ * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. - * + * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. - * + * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. - * + * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. - * + * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. - * + * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 @@ -65,30 +65,30 @@ static int32_t *xdrmem_inline (XDR *, unsigned int); static void xdrmem_destroy (XDR *); static struct xdr_ops xdrmem_ops = { - xdrmem_getlong, - xdrmem_putlong, - xdrmem_getbytes, - xdrmem_putbytes, - xdrmem_getpos, - xdrmem_setpos, - xdrmem_inline, - xdrmem_destroy, - NULL, - NULL + xdrmem_getlong, + xdrmem_putlong, + xdrmem_getbytes, + xdrmem_putbytes, + xdrmem_getpos, + xdrmem_setpos, + xdrmem_inline, + xdrmem_destroy, + NULL, + NULL }; /* * The procedure xdrmem_create initializes a stream descriptor for a - * memory buffer. + * memory buffer. */ void xdrmem_create (XDR *xdrs, const char* addr, unsigned int size, enum xdr_op op) { - xdrs->x_op = op; - xdrs->x_ops = &xdrmem_ops; - xdrs->x_private = xdrs->x_base = (char*)addr; - xdrs->x_handy = size; + xdrs->x_op = op; + xdrs->x_ops = &xdrmem_ops; + xdrs->x_private = xdrs->x_base = (char*)addr; + xdrs->x_handy = size; } static void @@ -140,7 +140,7 @@ xdrmem_putbytes (XDR *xdrs, const char *addr, unsigned int len) static unsigned int xdrmem_getpos (const XDR *xdrs) { - return ((unsigned long) xdrs->x_private - (unsigned long) xdrs->x_base); + return ((unsigned long) xdrs->x_private - (unsigned long) xdrs->x_base); } static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos) @@ -149,9 +149,9 @@ static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos) register char* lastaddr = xdrs->x_private + xdrs->x_handy; if ((long) newaddr > (long) lastaddr - || (UINT_MAX < LONG_MAX - && (long) UINT_MAX < (long) lastaddr - (long) newaddr)) - return (FALSE); + || (UINT_MAX < LONG_MAX + && (long) UINT_MAX < (long) lastaddr - (long) newaddr)) + return (FALSE); xdrs->x_private = newaddr; xdrs->x_handy = (long) lastaddr - (long) newaddr; return (TRUE); @@ -160,13 +160,13 @@ static bool_t xdrmem_setpos(XDR *xdrs, unsigned int pos) static int32_t * xdrmem_inline (XDR *xdrs, unsigned int len) { - int32_t *buf = 0; - - if (xdrs->x_handy >= len) { - xdrs->x_handy -= len; - buf = (int32_t *) xdrs->x_private; - xdrs->x_private += len; - } - return (buf); + int32_t *buf = 0; + + if (xdrs->x_handy >= len) { + xdrs->x_handy -= len; + buf = (int32_t *) xdrs->x_private; + xdrs->x_private += len; + } + return (buf); } diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.c b/components/dfs/filesystems/ramfs/dfs_ramfs.c index aa85081e1e..cc58590de2 100644 --- a/components/dfs/filesystems/ramfs/dfs_ramfs.c +++ b/components/dfs/filesystems/ramfs/dfs_ramfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/ramfs/dfs_ramfs.h b/components/dfs/filesystems/ramfs/dfs_ramfs.h index 4975ecb332..87adde99a5 100644 --- a/components/dfs/filesystems/ramfs/dfs_ramfs.h +++ b/components/dfs/filesystems/ramfs/dfs_ramfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/romfs/dfs_romfs.c b/components/dfs/filesystems/romfs/dfs_romfs.c index 17dbee52f5..1b2693fc3b 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.c +++ b/components/dfs/filesystems/romfs/dfs_romfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/romfs/dfs_romfs.h b/components/dfs/filesystems/romfs/dfs_romfs.h index ba6a3d7dfa..affa4bf993 100644 --- a/components/dfs/filesystems/romfs/dfs_romfs.h +++ b/components/dfs/filesystems/romfs/dfs_romfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/romfs/romfs.c b/components/dfs/filesystems/romfs/romfs.c index cfce09a095..847fcc6e27 100644 --- a/components/dfs/filesystems/romfs/romfs.c +++ b/components/dfs/filesystems/romfs/romfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/skeleton/skeleton.c b/components/dfs/filesystems/skeleton/skeleton.c index 0c20513e82..b8dc06e9b5 100644 --- a/components/dfs/filesystems/skeleton/skeleton.c +++ b/components/dfs/filesystems/skeleton/skeleton.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/skeleton/skeleton.h b/components/dfs/filesystems/skeleton/skeleton.h index 8a783eace5..30c721d14f 100644 --- a/components/dfs/filesystems/skeleton/skeleton.h +++ b/components/dfs/filesystems/skeleton/skeleton.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/uffs/dfs_uffs.c b/components/dfs/filesystems/uffs/dfs_uffs.c index fb8caf9dd7..1ccd715800 100644 --- a/components/dfs/filesystems/uffs/dfs_uffs.c +++ b/components/dfs/filesystems/uffs/dfs_uffs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/uffs/dfs_uffs.h b/components/dfs/filesystems/uffs/dfs_uffs.h index 72f0ee9240..8e08e069e1 100644 --- a/components/dfs/filesystems/uffs/dfs_uffs.h +++ b/components/dfs/filesystems/uffs/dfs_uffs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/filesystems/uffs/uffs_rtthread.c b/components/dfs/filesystems/uffs/uffs_rtthread.c index bad456f04c..406ad35b2f 100644 --- a/components/dfs/filesystems/uffs/uffs_rtthread.c +++ b/components/dfs/filesystems/uffs/uffs_rtthread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -8,11 +8,11 @@ */ /* This file is part of UFFS, the Ultra-low-cost Flash File System. - + Copyright (C) 2005-2009 Ricky Zheng UFFS is free software; you can redistribute it and/or modify it under - the GNU Library General Public License as published by the Free Software + the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. @@ -20,7 +20,7 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License or GNU Library General Public License, as applicable, for more details. - + You should have received a copy of the GNU General Public License and GNU Library General Public License along with UFFS; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, @@ -33,7 +33,7 @@ by the GNU General Public License. However the source code for this file must still be made available in accordance with section (3) of the GNU General Public License v2. - + This exception does not invalidate any other reasons why a work based on this file might be covered by the GNU General Public License. */ @@ -53,83 +53,83 @@ int uffs_SemCreate(OSSEM *sem) { - static int count = 0; - char name [RT_NAME_MAX+1]; - struct rt_mutex *mutex = RT_NULL; - - rt_snprintf(name, sizeof(name), "usem%d", count++); - mutex = rt_mutex_create(name, RT_IPC_FLAG_FIFO); - if (mutex != RT_NULL) - { - *sem = (OSSEM *)mutex; - return 0; - } - uffs_Perror(UFFS_MSG_SERIOUS, "can't get a semphore"); - return -1; + static int count = 0; + char name [RT_NAME_MAX+1]; + struct rt_mutex *mutex = RT_NULL; + + rt_snprintf(name, sizeof(name), "usem%d", count++); + mutex = rt_mutex_create(name, RT_IPC_FLAG_FIFO); + if (mutex != RT_NULL) + { + *sem = (OSSEM *)mutex; + return 0; + } + uffs_Perror(UFFS_MSG_SERIOUS, "can't get a semphore"); + return -1; } int uffs_SemWait(OSSEM sem) { - return rt_mutex_take((struct rt_mutex *)sem, RT_WAITING_FOREVER); + return rt_mutex_take((struct rt_mutex *)sem, RT_WAITING_FOREVER); } int uffs_SemSignal(OSSEM sem) { - return rt_mutex_release((struct rt_mutex *)sem); + return rt_mutex_release((struct rt_mutex *)sem); } int uffs_SemDelete(OSSEM *sem) { - int ret = -1; - - if (sem) { - ret = rt_mutex_delete((struct rt_mutex *)(*sem)); - if (ret == RT_EOK) { - *sem = 0; - } - } - return ret; + int ret = -1; + + if (sem) { + ret = rt_mutex_delete((struct rt_mutex *)(*sem)); + if (ret == RT_EOK) { + *sem = 0; + } + } + return ret; } int uffs_OSGetTaskId(void) { - //TODO: ... return current task ID ... - return 0; + //TODO: ... return current task ID ... + return 0; } unsigned int uffs_GetCurDateTime(void) { - // FIXME: return system time, please modify this for your platform ! - // or just return 0 if you don't care about file time. + // FIXME: return system time, please modify this for your platform ! + // or just return 0 if you don't care about file time. #if 0 - time_t tvalue; + time_t tvalue; + + tvalue = time(NULL); - tvalue = time(NULL); - - return (unsigned int)tvalue; + return (unsigned int)tvalue; #endif - return 0; + return 0; } #if CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR > 0 static void * sys_malloc(struct uffs_DeviceSt *dev, unsigned int size) { - dev = dev; - uffs_Perror(UFFS_MSG_NORMAL, "system memory alloc %d bytes", size); - return rt_malloc(size); + dev = dev; + uffs_Perror(UFFS_MSG_NORMAL, "system memory alloc %d bytes", size); + return rt_malloc(size); } static URET sys_free(struct uffs_DeviceSt *dev, void *p) { - dev = dev; - rt_free(p); - return U_SUCC; + dev = dev; + rt_free(p); + return U_SUCC; } void uffs_MemSetupSystemAllocator(uffs_MemAllocator *allocator) { - allocator->malloc = sys_malloc; - allocator->free = sys_free; + allocator->malloc = sys_malloc; + allocator->free = sys_free; } #endif @@ -137,18 +137,18 @@ void uffs_MemSetupSystemAllocator(uffs_MemAllocator *allocator) /* debug message output throught 'printf' */ static void output_dbg_msg(const char *msg); static struct uffs_DebugMsgOutputSt m_dbg_ops = { - output_dbg_msg, - NULL, + output_dbg_msg, + NULL, }; static void output_dbg_msg(const char *msg) { - rt_kprintf("%s", msg); + rt_kprintf("%s", msg); } void uffs_SetupDebugOutput(void) { - uffs_InitDebugMessageOutput(&m_dbg_ops, UFFS_MSG_NOISY); + uffs_InitDebugMessageOutput(&m_dbg_ops, UFFS_MSG_NOISY); } #else diff --git a/components/dfs/include/dfs.h b/components/dfs/include/dfs.h index 1158df93cb..80dc433787 100644 --- a/components/dfs/include/dfs.h +++ b/components/dfs/include/dfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/include/dfs_file.h b/components/dfs/include/dfs_file.h index 2dfacd653e..df1013d69c 100644 --- a/components/dfs/include/dfs_file.h +++ b/components/dfs/include/dfs_file.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/include/dfs_fs.h b/components/dfs/include/dfs_fs.h index a35a513044..8dc93f9599 100644 --- a/components/dfs/include/dfs_fs.h +++ b/components/dfs/include/dfs_fs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/include/dfs_poll.h b/components/dfs/include/dfs_poll.h index d9597a4364..096a5fe712 100644 --- a/components/dfs/include/dfs_poll.h +++ b/components/dfs/include/dfs_poll.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/include/dfs_posix.h b/components/dfs/include/dfs_posix.h index 87d5f0771e..0475460d95 100644 --- a/components/dfs/include/dfs_posix.h +++ b/components/dfs/include/dfs_posix.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/include/dfs_private.h b/components/dfs/include/dfs_private.h index fccd260ac0..e602c21730 100644 --- a/components/dfs/include/dfs_private.h +++ b/components/dfs/include/dfs_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/include/dfs_select.h b/components/dfs/include/dfs_select.h index 3ac5817874..458691df20 100644 --- a/components/dfs/include/dfs_select.h +++ b/components/dfs/include/dfs_select.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index 7ace0bc160..8155b088f0 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/src/dfs_file.c b/components/dfs/src/dfs_file.c index fd205f2f3a..aa6494457a 100644 --- a/components/dfs/src/dfs_file.c +++ b/components/dfs/src/dfs_file.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/src/dfs_fs.c b/components/dfs/src/dfs_fs.c index c21b914727..53e7e385a4 100644 --- a/components/dfs/src/dfs_fs.c +++ b/components/dfs/src/dfs_fs.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -522,16 +522,16 @@ INIT_ENV_EXPORT(dfs_mount_table); int dfs_mount_device(rt_device_t dev) { int index = 0; - + if(dev == RT_NULL) { rt_kprintf("the device is NULL to be mounted.\n"); return -RT_ERROR; } - + while (1) { if (mount_table[index].path == NULL) break; - + if(strcmp(mount_table[index].device_name, dev->parent.name) == 0) { if (dfs_mount(mount_table[index].device_name, mount_table[index].path, @@ -548,10 +548,10 @@ int dfs_mount_device(rt_device_t dev) return RT_EOK; } } - + index ++; } - + rt_kprintf("can't find device:%s to be mounted.\n", dev->parent.name); return -RT_ERROR; } diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index fc603df437..a7c306366f 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/dfs/src/poll.c b/components/dfs/src/poll.c index fc48eca758..d1e0372494 100644 --- a/components/dfs/src/poll.c +++ b/components/dfs/src/poll.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -140,7 +140,7 @@ static int do_pollfd(struct pollfd *pollfd, rt_pollreq_t *req) /* dealwith the device return error -1*/ if (mask < 0) - { + { fd_put(f); pollfd->revents = 0; return mask; @@ -232,4 +232,4 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) return num; } -#endif +#endif diff --git a/components/dfs/src/select.c b/components/dfs/src/select.c index 181855bc74..c9286ca97f 100644 --- a/components/dfs/src/select.c +++ b/components/dfs/src/select.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -180,4 +180,4 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struc return ret; } -#endif +#endif diff --git a/components/drivers/audio/audio.c b/components/drivers/audio/audio.c index c3f8723db6..f9d42aeb5c 100644 --- a/components/drivers/audio/audio.c +++ b/components/drivers/audio/audio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/audio/audio_pipe.c b/components/drivers/audio/audio_pipe.c index e9de1ffb74..4dd1138610 100644 --- a/components/drivers/audio/audio_pipe.c +++ b/components/drivers/audio/audio_pipe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/audio/audio_pipe.h b/components/drivers/audio/audio_pipe.h index 3ae3bc8498..6c4719d56d 100644 --- a/components/drivers/audio/audio_pipe.h +++ b/components/drivers/audio/audio_pipe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/can/can.c b/components/drivers/can/can.c index 9f4612355b..55444c3a0e 100644 --- a/components/drivers/can/can.c +++ b/components/drivers/can/can.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/cputime/cputime.c b/components/drivers/cputime/cputime.c index 3ec860d5c5..4a9eee3a71 100644 --- a/components/drivers/cputime/cputime.c +++ b/components/drivers/cputime/cputime.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -14,7 +14,7 @@ static const struct rt_clock_cputime_ops *_cputime_ops = RT_NULL; /** - * The clock_cpu_getres() function shall return the resolution of CPU time, the + * The clock_cpu_getres() function shall return the resolution of CPU time, the * number of nanosecond per tick. * * @return the number of nanosecond per tick @@ -43,7 +43,7 @@ uint32_t clock_cpu_gettime(void) } /** - * The clock_cpu_microsecond() fucntion shall return the microsecond according to + * The clock_cpu_microsecond() fucntion shall return the microsecond according to * cpu_tick parameter. * * @param cpu_tick the cpu tick @@ -58,7 +58,7 @@ uint32_t clock_cpu_microsecond(uint32_t cpu_tick) } /** - * The clock_cpu_microsecond() fucntion shall return the millisecond according to + * The clock_cpu_microsecond() fucntion shall return the millisecond according to * cpu_tick parameter. * * @param cpu_tick the cpu tick @@ -74,7 +74,7 @@ uint32_t clock_cpu_millisecond(uint32_t cpu_tick) /** * The clock_cpu_seops() function shall set the ops of cpu time. - * + * * @return always return 0. */ int clock_cpu_setops(const struct rt_clock_cputime_ops *ops) diff --git a/components/drivers/cputime/cputime_cortexm.c b/components/drivers/cputime/cputime_cortexm.c index 05ed6ed447..071acfe9bb 100644 --- a/components/drivers/cputime/cputime_cortexm.c +++ b/components/drivers/cputime/cputime_cortexm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -19,7 +19,7 @@ static float cortexm_cputime_getres(void) { float ret = 1000 * 1000 * 1000; - + ret = ret / SystemCoreClock; return ret; } @@ -29,7 +29,7 @@ static uint32_t cortexm_cputime_gettime(void) return DWT->CYCCNT; } -const static struct rt_clock_cputime_ops _cortexm_ops = +const static struct rt_clock_cputime_ops _cortexm_ops = { cortexm_cputime_getres, cortexm_cputime_gettime @@ -38,13 +38,13 @@ const static struct rt_clock_cputime_ops _cortexm_ops = int cortexm_cputime_init(void) { /* check support bit */ - if ((DWT->CTRL & (1UL << DWT_CTRL_NOCYCCNT_Pos)) == 0) + if ((DWT->CTRL & (1UL << DWT_CTRL_NOCYCCNT_Pos)) == 0) { /* enable trace*/ CoreDebug->DEMCR |= (1UL << CoreDebug_DEMCR_TRCENA_Pos); - + /* whether cycle counter not enabled */ - if ((DWT->CTRL & (1UL << DWT_CTRL_CYCCNTENA_Pos)) == 0) + if ((DWT->CTRL & (1UL << DWT_CTRL_CYCCNTENA_Pos)) == 0) { /* enable cycle counter */ DWT->CTRL |= (1UL << DWT_CTRL_CYCCNTENA_Pos); diff --git a/components/drivers/hwcrypto/hw_bignum.c b/components/drivers/hwcrypto/hw_bignum.c index 88813566b1..0488a16f08 100644 --- a/components/drivers/hwcrypto/hw_bignum.c +++ b/components/drivers/hwcrypto/hw_bignum.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -56,7 +56,7 @@ rt_err_t rt_hwcrypto_bignum_default(struct rt_hwcrypto_device *device) /** * @brief Init bignum obj - * + * * @param n bignum obj */ void rt_hwcrypto_bignum_init(struct hw_bignum_mpi *n) @@ -87,9 +87,9 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n) /** * @brief Get length of bignum as an unsigned binary buffer - * + * * @param n bignum obj - * + * * @return binary buffer length */ int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n) @@ -112,11 +112,11 @@ int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n) /** * @brief Export n into unsigned binary data, big endian - * + * * @param n bignum obj * @param buf Buffer for the binary number * @param len Length of the buffer - * + * * @return export bin length */ int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len) @@ -139,11 +139,11 @@ int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int /** * @brief Import n from unsigned binary data, big endian - * + * * @param n bignum obj * @param buf Buffer for the binary number * @param len Length of the buffer - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len) @@ -179,11 +179,11 @@ rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, /** * @brief x = a + b - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x, @@ -206,11 +206,11 @@ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x, /** * @brief x = a - b - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x, @@ -233,11 +233,11 @@ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x, /** * @brief x = a * b - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x, @@ -260,11 +260,11 @@ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x, /** * @brief x = a * b (mod c) - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x, @@ -288,11 +288,11 @@ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x, /** * @brief x = a ^ b (mod c) - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_exptmod(struct hw_bignum_mpi *x, diff --git a/components/drivers/hwcrypto/hw_bignum.h b/components/drivers/hwcrypto/hw_bignum.h index a1f567e68f..442b28f558 100644 --- a/components/drivers/hwcrypto/hw_bignum.h +++ b/components/drivers/hwcrypto/hw_bignum.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -83,42 +83,42 @@ void rt_hwcrypto_bignum_free(struct hw_bignum_mpi *n); /** * @brief Get length of bignum as an unsigned binary buffer - * + * * @param n bignum obj - * + * * @return binary buffer Length */ int rt_hwcrypto_bignum_get_len(const struct hw_bignum_mpi *n); /** * @brief Export n into unsigned binary data, big endian - * + * * @param n bignum obj * @param buf Buffer for the binary number * @param len Length of the buffer - * + * * @return export bin length */ int rt_hwcrypto_bignum_export_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len); /** * @brief Import n from unsigned binary data, big endian - * + * * @param n bignum obj * @param buf Buffer for the binary number * @param len Length of the buffer - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_import_bin(struct hw_bignum_mpi *n, rt_uint8_t *buf, int len); /** * @brief x = a + b - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x, @@ -127,11 +127,11 @@ rt_err_t rt_hwcrypto_bignum_add(struct hw_bignum_mpi *x, /** * @brief x = a - b - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x, @@ -140,11 +140,11 @@ rt_err_t rt_hwcrypto_bignum_sub(struct hw_bignum_mpi *x, /** * @brief x = a * b - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x, @@ -153,11 +153,11 @@ rt_err_t rt_hwcrypto_bignum_mul(struct hw_bignum_mpi *x, /** * @brief x = a * b (mod c) - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x, @@ -167,11 +167,11 @@ rt_err_t rt_hwcrypto_bignum_mulmod(struct hw_bignum_mpi *x, /** * @brief x = a ^ b (mod c) - * + * * @param a bignum obj * @param b bignum obj * @param c bignum obj - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_bignum_exptmod(struct hw_bignum_mpi *x, diff --git a/components/drivers/hwcrypto/hw_crc.c b/components/drivers/hwcrypto/hw_crc.c index 20579711e2..a1d95793e2 100644 --- a/components/drivers/hwcrypto/hw_crc.c +++ b/components/drivers/hwcrypto/hw_crc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -20,7 +20,7 @@ * * @return CRC context */ -struct rt_hwcrypto_ctx *rt_hwcrypto_crc_create(struct rt_hwcrypto_device *device, +struct rt_hwcrypto_ctx *rt_hwcrypto_crc_create(struct rt_hwcrypto_device *device, hwcrypto_crc_mode mode) { struct hwcrypto_crc *crc_ctx; @@ -89,8 +89,8 @@ void rt_hwcrypto_crc_destroy(struct rt_hwcrypto_ctx *ctx) * * @return RT_EOK on success. */ -rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, - const rt_uint8_t *input, +rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, + const rt_uint8_t *input, rt_size_t length) { struct hwcrypto_crc *crc_ctx = (struct hwcrypto_crc *)ctx; @@ -107,7 +107,7 @@ rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, * @param ctx CRC context * @param cfg CRC config */ -void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx, +void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx, struct hwcrypto_crc_cfg *cfg) { if (cfg) diff --git a/components/drivers/hwcrypto/hw_crc.h b/components/drivers/hwcrypto/hw_crc.h index a6df92a2ef..8e0fcefccf 100644 --- a/components/drivers/hwcrypto/hw_crc.h +++ b/components/drivers/hwcrypto/hw_crc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -129,7 +129,7 @@ void rt_hwcrypto_crc_destroy(struct rt_hwcrypto_ctx *ctx); * * @return CRC value */ -rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, +rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, const rt_uint8_t *input, rt_size_t length); /** @@ -138,7 +138,7 @@ rt_uint32_t rt_hwcrypto_crc_update(struct rt_hwcrypto_ctx *ctx, * @param ctx CRC context * @param cfg CRC config */ -void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx, +void rt_hwcrypto_crc_cfg(struct rt_hwcrypto_ctx *ctx, struct hwcrypto_crc_cfg *cfg); #ifdef __cplusplus diff --git a/components/drivers/hwcrypto/hw_gcm.c b/components/drivers/hwcrypto/hw_gcm.c index 8d0f49149a..a8106694f9 100644 --- a/components/drivers/hwcrypto/hw_gcm.c +++ b/components/drivers/hwcrypto/hw_gcm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwcrypto/hw_gcm.h b/components/drivers/hwcrypto/hw_gcm.h index a73b2b0634..3a2f87bc30 100644 --- a/components/drivers/hwcrypto/hw_gcm.h +++ b/components/drivers/hwcrypto/hw_gcm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwcrypto/hw_hash.c b/components/drivers/hwcrypto/hw_hash.c index b20069ac0e..cf5ec8d70a 100644 --- a/components/drivers/hwcrypto/hw_hash.c +++ b/components/drivers/hwcrypto/hw_hash.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwcrypto/hw_hash.h b/components/drivers/hwcrypto/hw_hash.h index de0310e84c..41abd06c4c 100644 --- a/components/drivers/hwcrypto/hw_hash.h +++ b/components/drivers/hwcrypto/hw_hash.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwcrypto/hw_rng.c b/components/drivers/hwcrypto/hw_rng.c index 13a17cc6be..b6f62db347 100644 --- a/components/drivers/hwcrypto/hw_rng.c +++ b/components/drivers/hwcrypto/hw_rng.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -81,7 +81,7 @@ rt_err_t rt_hwcrypto_rng_default(struct rt_hwcrypto_device *device) * @brief Getting Random Numbers from RNG Context * * @param ctx RNG context - * + * * @return Random number */ rt_uint32_t rt_hwcrypto_rng_update_ctx(struct rt_hwcrypto_ctx *ctx) diff --git a/components/drivers/hwcrypto/hw_rng.h b/components/drivers/hwcrypto/hw_rng.h index fc28afdb1e..3c014f6bee 100644 --- a/components/drivers/hwcrypto/hw_rng.h +++ b/components/drivers/hwcrypto/hw_rng.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -60,7 +60,7 @@ rt_err_t rt_hwcrypto_rng_default(struct rt_hwcrypto_device *device); * @brief Getting Random Numbers from RNG Context * * @param ctx RNG context - * + * * @return Random number */ rt_uint32_t rt_hwcrypto_rng_update_ctx(struct rt_hwcrypto_ctx *ctx); diff --git a/components/drivers/hwcrypto/hw_symmetric.c b/components/drivers/hwcrypto/hw_symmetric.c index 789c5c1a2c..9398298fed 100644 --- a/components/drivers/hwcrypto/hw_symmetric.c +++ b/components/drivers/hwcrypto/hw_symmetric.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -215,7 +215,7 @@ void rt_hwcrypto_symmetric_get_ivoff(struct rt_hwcrypto_ctx *ctx, rt_int32_t *iv * * @param des The destination symmetric crypto context * @param src The symmetric crypto context to be copy - * + * * @return RT_EOK on success. */ rt_err_t rt_hwcrypto_symmetric_cpy(struct rt_hwcrypto_ctx *des, const struct rt_hwcrypto_ctx *src) diff --git a/components/drivers/hwcrypto/hw_symmetric.h b/components/drivers/hwcrypto/hw_symmetric.h index 12f4dbec30..f3f78fb21c 100644 --- a/components/drivers/hwcrypto/hw_symmetric.h +++ b/components/drivers/hwcrypto/hw_symmetric.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwcrypto/hwcrypto.c b/components/drivers/hwcrypto/hwcrypto.c index bbe1ff63fb..473b52fb9a 100644 --- a/components/drivers/hwcrypto/hwcrypto.c +++ b/components/drivers/hwcrypto/hwcrypto.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwcrypto/hwcrypto.h b/components/drivers/hwcrypto/hwcrypto.h index a428f4437d..cdf057c49d 100644 --- a/components/drivers/hwcrypto/hwcrypto.h +++ b/components/drivers/hwcrypto/hwcrypto.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/hwtimer/hwtimer.c b/components/drivers/hwtimer/hwtimer.c index 976d8bbf32..49a57be9af 100644 --- a/components/drivers/hwtimer/hwtimer.c +++ b/components/drivers/hwtimer/hwtimer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -325,7 +325,7 @@ void rt_device_hwtimer_isr(rt_hwtimer_t *timer) } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops hwtimer_ops = +const static struct rt_device_ops hwtimer_ops = { rt_hwtimer_init, rt_hwtimer_open, diff --git a/components/drivers/i2c/i2c-bit-ops.c b/components/drivers/i2c/i2c-bit-ops.c index 3a9b4efeb3..ae1f4db9c0 100644 --- a/components/drivers/i2c/i2c-bit-ops.c +++ b/components/drivers/i2c/i2c-bit-ops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/i2c/i2c_core.c b/components/drivers/i2c/i2c_core.c index f358c2b758..87178e37d5 100644 --- a/components/drivers/i2c/i2c_core.c +++ b/components/drivers/i2c/i2c_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/i2c/i2c_dev.c b/components/drivers/i2c/i2c_dev.c index 59f728be09..4f567f8227 100644 --- a/components/drivers/i2c/i2c_dev.c +++ b/components/drivers/i2c/i2c_dev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -97,9 +97,9 @@ static rt_err_t i2c_bus_device_control(rt_device_t dev, } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops i2c_ops = +const static struct rt_device_ops i2c_ops = { - RT_NULL, + RT_NULL, RT_NULL, RT_NULL, i2c_bus_device_read, diff --git a/components/drivers/include/drivers/adc.h b/components/drivers/include/drivers/adc.h index 8e3498e791..e2ce087fb9 100644 --- a/components/drivers/include/drivers/adc.h +++ b/components/drivers/include/drivers/adc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/alarm.h b/components/drivers/include/drivers/alarm.h index e59c4142c7..11637df949 100644 --- a/components/drivers/include/drivers/alarm.h +++ b/components/drivers/include/drivers/alarm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/audio.h b/components/drivers/include/drivers/audio.h index 86057e7626..45c31be2f3 100644 --- a/components/drivers/include/drivers/audio.h +++ b/components/drivers/include/drivers/audio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/can.h b/components/drivers/include/drivers/can.h index d4fcc845b4..bb05317d4f 100644 --- a/components/drivers/include/drivers/can.h +++ b/components/drivers/include/drivers/can.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/cputime.h b/components/drivers/include/drivers/cputime.h index 78c22fc1da..0141f24805 100644 --- a/components/drivers/include/drivers/cputime.h +++ b/components/drivers/include/drivers/cputime.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/crypto.h b/components/drivers/include/drivers/crypto.h index 5341d9ee48..8270a78b09 100644 --- a/components/drivers/include/drivers/crypto.h +++ b/components/drivers/include/drivers/crypto.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/dac.h b/components/drivers/include/drivers/dac.h index b6043348dc..7d5ff3592a 100644 --- a/components/drivers/include/drivers/dac.h +++ b/components/drivers/include/drivers/dac.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/hwtimer.h b/components/drivers/include/drivers/hwtimer.h index d00dbd8a13..0bf4893790 100644 --- a/components/drivers/include/drivers/hwtimer.h +++ b/components/drivers/include/drivers/hwtimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/i2c-bit-ops.h b/components/drivers/include/drivers/i2c-bit-ops.h index ddf9a36d73..0d94de114a 100644 --- a/components/drivers/include/drivers/i2c-bit-ops.h +++ b/components/drivers/include/drivers/i2c-bit-ops.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/i2c.h b/components/drivers/include/drivers/i2c.h index d93e82fc2b..50ce021d53 100644 --- a/components/drivers/include/drivers/i2c.h +++ b/components/drivers/include/drivers/i2c.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/i2c_dev.h b/components/drivers/include/drivers/i2c_dev.h index 5ef9dd1a8c..94f110c055 100644 --- a/components/drivers/include/drivers/i2c_dev.h +++ b/components/drivers/include/drivers/i2c_dev.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/mmc.h b/components/drivers/include/drivers/mmc.h index 95dce7178a..d472bbbc5d 100644 --- a/components/drivers/include/drivers/mmc.h +++ b/components/drivers/include/drivers/mmc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -22,163 +22,163 @@ extern "C" { * EXT_CSD fields */ -#define EXT_CSD_FLUSH_CACHE 32 /* W */ -#define EXT_CSD_CACHE_CTRL 33 /* R/W */ -#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ -#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */ -#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */ -#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ -#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ -#define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ -#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ -#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ -#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ -#define EXT_CSD_HPI_MGMT 161 /* R/W */ -#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ -#define EXT_CSD_BKOPS_EN 163 /* R/W */ -#define EXT_CSD_BKOPS_START 164 /* W */ -#define EXT_CSD_SANITIZE_START 165 /* W */ -#define EXT_CSD_WR_REL_PARAM 166 /* RO */ -#define EXT_CSD_RPMB_MULT 168 /* RO */ -#define EXT_CSD_BOOT_WP 173 /* R/W */ -#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ -#define EXT_CSD_PART_CONFIG 179 /* R/W */ -#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ -#define EXT_CSD_BUS_WIDTH 183 /* R/W */ -#define EXT_CSD_HS_TIMING 185 /* R/W */ -#define EXT_CSD_POWER_CLASS 187 /* R/W */ -#define EXT_CSD_REV 192 /* RO */ -#define EXT_CSD_STRUCTURE 194 /* RO */ -#define EXT_CSD_CARD_TYPE 196 /* RO */ -#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */ +#define EXT_CSD_FLUSH_CACHE 32 /* W */ +#define EXT_CSD_CACHE_CTRL 33 /* R/W */ +#define EXT_CSD_POWER_OFF_NOTIFICATION 34 /* R/W */ +#define EXT_CSD_PACKED_FAILURE_INDEX 35 /* RO */ +#define EXT_CSD_PACKED_CMD_STATUS 36 /* RO */ +#define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ +#define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ +#define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ +#define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ +#define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ +#define EXT_CSD_PARTITION_SUPPORT 160 /* RO */ +#define EXT_CSD_HPI_MGMT 161 /* R/W */ +#define EXT_CSD_RST_N_FUNCTION 162 /* R/W */ +#define EXT_CSD_BKOPS_EN 163 /* R/W */ +#define EXT_CSD_BKOPS_START 164 /* W */ +#define EXT_CSD_SANITIZE_START 165 /* W */ +#define EXT_CSD_WR_REL_PARAM 166 /* RO */ +#define EXT_CSD_RPMB_MULT 168 /* RO */ +#define EXT_CSD_BOOT_WP 173 /* R/W */ +#define EXT_CSD_ERASE_GROUP_DEF 175 /* R/W */ +#define EXT_CSD_PART_CONFIG 179 /* R/W */ +#define EXT_CSD_ERASED_MEM_CONT 181 /* RO */ +#define EXT_CSD_BUS_WIDTH 183 /* R/W */ +#define EXT_CSD_HS_TIMING 185 /* R/W */ +#define EXT_CSD_POWER_CLASS 187 /* R/W */ +#define EXT_CSD_REV 192 /* RO */ +#define EXT_CSD_STRUCTURE 194 /* RO */ +#define EXT_CSD_CARD_TYPE 196 /* RO */ +#define EXT_CSD_OUT_OF_INTERRUPT_TIME 198 /* RO */ #define EXT_CSD_PART_SWITCH_TIME 199 /* RO */ -#define EXT_CSD_PWR_CL_52_195 200 /* RO */ -#define EXT_CSD_PWR_CL_26_195 201 /* RO */ -#define EXT_CSD_PWR_CL_52_360 202 /* RO */ -#define EXT_CSD_PWR_CL_26_360 203 /* RO */ -#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ -#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ -#define EXT_CSD_REL_WR_SEC_C 222 /* RO */ -#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ -#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ -#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ -#define EXT_CSD_BOOT_MULT 226 /* RO */ -#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ -#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ -#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ -#define EXT_CSD_TRIM_MULT 232 /* RO */ -#define EXT_CSD_PWR_CL_200_195 236 /* RO */ -#define EXT_CSD_PWR_CL_200_360 237 /* RO */ -#define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */ -#define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */ -#define EXT_CSD_BKOPS_STATUS 246 /* RO */ -#define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */ -#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ -#define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ -#define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ -#define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ -#define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ -#define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */ -#define EXT_CSD_MAX_PACKED_READS 501 /* RO */ -#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ -#define EXT_CSD_HPI_FEATURES 503 /* RO */ +#define EXT_CSD_PWR_CL_52_195 200 /* RO */ +#define EXT_CSD_PWR_CL_26_195 201 /* RO */ +#define EXT_CSD_PWR_CL_52_360 202 /* RO */ +#define EXT_CSD_PWR_CL_26_360 203 /* RO */ +#define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ +#define EXT_CSD_S_A_TIMEOUT 217 /* RO */ +#define EXT_CSD_REL_WR_SEC_C 222 /* RO */ +#define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ +#define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ +#define EXT_CSD_HC_ERASE_GRP_SIZE 224 /* RO */ +#define EXT_CSD_BOOT_MULT 226 /* RO */ +#define EXT_CSD_SEC_TRIM_MULT 229 /* RO */ +#define EXT_CSD_SEC_ERASE_MULT 230 /* RO */ +#define EXT_CSD_SEC_FEATURE_SUPPORT 231 /* RO */ +#define EXT_CSD_TRIM_MULT 232 /* RO */ +#define EXT_CSD_PWR_CL_200_195 236 /* RO */ +#define EXT_CSD_PWR_CL_200_360 237 /* RO */ +#define EXT_CSD_PWR_CL_DDR_52_195 238 /* RO */ +#define EXT_CSD_PWR_CL_DDR_52_360 239 /* RO */ +#define EXT_CSD_BKOPS_STATUS 246 /* RO */ +#define EXT_CSD_POWER_OFF_LONG_TIME 247 /* RO */ +#define EXT_CSD_GENERIC_CMD6_TIME 248 /* RO */ +#define EXT_CSD_CACHE_SIZE 249 /* RO, 4 bytes */ +#define EXT_CSD_PWR_CL_DDR_200_360 253 /* RO */ +#define EXT_CSD_TAG_UNIT_SIZE 498 /* RO */ +#define EXT_CSD_DATA_TAG_SUPPORT 499 /* RO */ +#define EXT_CSD_MAX_PACKED_WRITES 500 /* RO */ +#define EXT_CSD_MAX_PACKED_READS 501 /* RO */ +#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ +#define EXT_CSD_HPI_FEATURES 503 /* RO */ /* * EXT_CSD field definitions */ -#define EXT_CSD_WR_REL_PARAM_EN (1<<2) +#define EXT_CSD_WR_REL_PARAM_EN (1<<2) -#define EXT_CSD_BOOT_WP_B_PWR_WP_DIS (0x40) -#define EXT_CSD_BOOT_WP_B_PERM_WP_DIS (0x10) -#define EXT_CSD_BOOT_WP_B_PERM_WP_EN (0x04) -#define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01) +#define EXT_CSD_BOOT_WP_B_PWR_WP_DIS (0x40) +#define EXT_CSD_BOOT_WP_B_PERM_WP_DIS (0x10) +#define EXT_CSD_BOOT_WP_B_PERM_WP_EN (0x04) +#define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01) -#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) -#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) -#define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3) -#define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4) +#define EXT_CSD_PART_CONFIG_ACC_MASK (0x7) +#define EXT_CSD_PART_CONFIG_ACC_BOOT0 (0x1) +#define EXT_CSD_PART_CONFIG_ACC_RPMB (0x3) +#define EXT_CSD_PART_CONFIG_ACC_GP0 (0x4) -#define EXT_CSD_PART_SUPPORT_PART_EN (0x1) +#define EXT_CSD_PART_SUPPORT_PART_EN (0x1) -#define EXT_CSD_CMD_SET_NORMAL (1<<0) -#define EXT_CSD_CMD_SET_SECURE (1<<1) -#define EXT_CSD_CMD_SET_CPSECURE (1<<2) +#define EXT_CSD_CMD_SET_NORMAL (1<<0) +#define EXT_CSD_CMD_SET_SECURE (1<<1) +#define EXT_CSD_CMD_SET_CPSECURE (1<<2) -#define EXT_CSD_CARD_TYPE_HS_26 (1<<0) /* Card can run at 26MHz */ -#define EXT_CSD_CARD_TYPE_HS_52 (1<<1) /* Card can run at 52MHz */ -#define EXT_CSD_CARD_TYPE_HS (EXT_CSD_CARD_TYPE_HS_26 | \ +#define EXT_CSD_CARD_TYPE_HS_26 (1<<0) /* Card can run at 26MHz */ +#define EXT_CSD_CARD_TYPE_HS_52 (1<<1) /* Card can run at 52MHz */ +#define EXT_CSD_CARD_TYPE_HS (EXT_CSD_CARD_TYPE_HS_26 | \ EXT_CSD_CARD_TYPE_HS_52) #define EXT_CSD_CARD_TYPE_DDR_1_8V (1<<2) /* Card can run at 52MHz */ /* DDR mode @1.8V or 3V I/O */ #define EXT_CSD_CARD_TYPE_DDR_1_2V (1<<3) /* Card can run at 52MHz */ - /* DDR mode @1.2V I/O */ + /* DDR mode @1.2V I/O */ #define EXT_CSD_CARD_TYPE_DDR_52 (EXT_CSD_CARD_TYPE_DDR_1_8V \ | EXT_CSD_CARD_TYPE_DDR_1_2V) -#define EXT_CSD_CARD_TYPE_HS200_1_8V (1<<4) /* Card can run at 200MHz */ -#define EXT_CSD_CARD_TYPE_HS200_1_2V (1<<5) /* Card can run at 200MHz */ - /* SDR mode @1.2V I/O */ -#define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \ - EXT_CSD_CARD_TYPE_HS200_1_2V) -#define EXT_CSD_CARD_TYPE_HS400_1_8V (1<<6) /* Card can run at 200MHz DDR, 1.8V */ -#define EXT_CSD_CARD_TYPE_HS400_1_2V (1<<7) /* Card can run at 200MHz DDR, 1.2V */ -#define EXT_CSD_CARD_TYPE_HS400 (EXT_CSD_CARD_TYPE_HS400_1_8V | \ - EXT_CSD_CARD_TYPE_HS400_1_2V) - -#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ -#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ -#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ -#define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */ -#define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */ - -#define EXT_CSD_TIMING_BC 0 /* Backwards compatility */ -#define EXT_CSD_TIMING_HS 1 /* High speed */ -#define EXT_CSD_TIMING_HS200 2 /* HS200 */ -#define EXT_CSD_TIMING_HS400 3 /* HS400 */ - -#define EXT_CSD_SEC_ER_EN BIT(0) -#define EXT_CSD_SEC_BD_BLK_EN BIT(2) -#define EXT_CSD_SEC_GB_CL_EN BIT(4) -#define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */ - -#define EXT_CSD_RST_N_EN_MASK 0x3 -#define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */ - -#define EXT_CSD_NO_POWER_NOTIFICATION 0 -#define EXT_CSD_POWER_ON 1 -#define EXT_CSD_POWER_OFF_SHORT 2 -#define EXT_CSD_POWER_OFF_LONG 3 - -#define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */ -#define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */ -#define EXT_CSD_PWR_CL_8BIT_SHIFT 4 -#define EXT_CSD_PWR_CL_4BIT_SHIFT 0 - -#define EXT_CSD_PACKED_EVENT_EN BIT(3) +#define EXT_CSD_CARD_TYPE_HS200_1_8V (1<<4) /* Card can run at 200MHz */ +#define EXT_CSD_CARD_TYPE_HS200_1_2V (1<<5) /* Card can run at 200MHz */ + /* SDR mode @1.2V I/O */ +#define EXT_CSD_CARD_TYPE_HS200 (EXT_CSD_CARD_TYPE_HS200_1_8V | \ + EXT_CSD_CARD_TYPE_HS200_1_2V) +#define EXT_CSD_CARD_TYPE_HS400_1_8V (1<<6) /* Card can run at 200MHz DDR, 1.8V */ +#define EXT_CSD_CARD_TYPE_HS400_1_2V (1<<7) /* Card can run at 200MHz DDR, 1.2V */ +#define EXT_CSD_CARD_TYPE_HS400 (EXT_CSD_CARD_TYPE_HS400_1_8V | \ + EXT_CSD_CARD_TYPE_HS400_1_2V) + +#define EXT_CSD_BUS_WIDTH_1 0 /* Card is in 1 bit mode */ +#define EXT_CSD_BUS_WIDTH_4 1 /* Card is in 4 bit mode */ +#define EXT_CSD_BUS_WIDTH_8 2 /* Card is in 8 bit mode */ +#define EXT_CSD_DDR_BUS_WIDTH_4 5 /* Card is in 4 bit DDR mode */ +#define EXT_CSD_DDR_BUS_WIDTH_8 6 /* Card is in 8 bit DDR mode */ + +#define EXT_CSD_TIMING_BC 0 /* Backwards compatility */ +#define EXT_CSD_TIMING_HS 1 /* High speed */ +#define EXT_CSD_TIMING_HS200 2 /* HS200 */ +#define EXT_CSD_TIMING_HS400 3 /* HS400 */ + +#define EXT_CSD_SEC_ER_EN BIT(0) +#define EXT_CSD_SEC_BD_BLK_EN BIT(2) +#define EXT_CSD_SEC_GB_CL_EN BIT(4) +#define EXT_CSD_SEC_SANITIZE BIT(6) /* v4.5 only */ + +#define EXT_CSD_RST_N_EN_MASK 0x3 +#define EXT_CSD_RST_N_ENABLED 1 /* RST_n is enabled on card */ + +#define EXT_CSD_NO_POWER_NOTIFICATION 0 +#define EXT_CSD_POWER_ON 1 +#define EXT_CSD_POWER_OFF_SHORT 2 +#define EXT_CSD_POWER_OFF_LONG 3 + +#define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */ +#define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */ +#define EXT_CSD_PWR_CL_8BIT_SHIFT 4 +#define EXT_CSD_PWR_CL_4BIT_SHIFT 0 + +#define EXT_CSD_PACKED_EVENT_EN BIT(3) /* * EXCEPTION_EVENT_STATUS field */ -#define EXT_CSD_URGENT_BKOPS BIT(0) -#define EXT_CSD_DYNCAP_NEEDED BIT(1) -#define EXT_CSD_SYSPOOL_EXHAUSTED BIT(2) -#define EXT_CSD_PACKED_FAILURE BIT(3) +#define EXT_CSD_URGENT_BKOPS BIT(0) +#define EXT_CSD_DYNCAP_NEEDED BIT(1) +#define EXT_CSD_SYSPOOL_EXHAUSTED BIT(2) +#define EXT_CSD_PACKED_FAILURE BIT(3) -#define EXT_CSD_PACKED_GENERIC_ERROR BIT(0) -#define EXT_CSD_PACKED_INDEXED_ERROR BIT(1) +#define EXT_CSD_PACKED_GENERIC_ERROR BIT(0) +#define EXT_CSD_PACKED_INDEXED_ERROR BIT(1) /* * BKOPS status level */ -#define EXT_CSD_BKOPS_LEVEL_2 0x2 +#define EXT_CSD_BKOPS_LEVEL_2 0x2 /* * MMC_SWITCH access modes */ -#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ -#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */ -#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */ -#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */ - +#define MMC_SWITCH_MODE_CMD_SET 0x00 /* Change the command set */ +#define MMC_SWITCH_MODE_SET_BITS 0x01 /* Set bits which are 1 in value */ +#define MMC_SWITCH_MODE_CLEAR_BITS 0x02 /* Clear bits which are 1 in value */ +#define MMC_SWITCH_MODE_WRITE_BYTE 0x03 /* Set target to value */ + /* * extern function */ diff --git a/components/drivers/include/drivers/mmcsd_card.h b/components/drivers/include/drivers/mmcsd_card.h index 3ee5a20465..511cc1167d 100644 --- a/components/drivers/include/drivers/mmcsd_card.h +++ b/components/drivers/include/drivers/mmcsd_card.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2011-07-25 weety first version + * Date Author Notes + * 2011-07-25 weety first version */ #ifndef __MMCSD_CARD_H__ @@ -17,87 +17,87 @@ extern "C" { #endif -#define SD_SCR_BUS_WIDTH_1 (1 << 0) -#define SD_SCR_BUS_WIDTH_4 (1 << 2) +#define SD_SCR_BUS_WIDTH_1 (1 << 0) +#define SD_SCR_BUS_WIDTH_4 (1 << 2) struct rt_mmcsd_cid { - rt_uint8_t mid; /* ManufacturerID */ - rt_uint8_t prv; /* Product Revision */ - rt_uint16_t oid; /* OEM/Application ID */ - rt_uint32_t psn; /* Product Serial Number */ - rt_uint8_t pnm[5]; /* Product Name */ - rt_uint8_t reserved1;/* reserved */ - rt_uint16_t mdt; /* Manufacturing Date */ - rt_uint8_t crc; /* CID CRC */ - rt_uint8_t reserved2;/* not used, always 1 */ + rt_uint8_t mid; /* ManufacturerID */ + rt_uint8_t prv; /* Product Revision */ + rt_uint16_t oid; /* OEM/Application ID */ + rt_uint32_t psn; /* Product Serial Number */ + rt_uint8_t pnm[5]; /* Product Name */ + rt_uint8_t reserved1;/* reserved */ + rt_uint16_t mdt; /* Manufacturing Date */ + rt_uint8_t crc; /* CID CRC */ + rt_uint8_t reserved2;/* not used, always 1 */ }; struct rt_mmcsd_csd { - rt_uint8_t csd_structure; /* CSD register version */ - rt_uint8_t taac; - rt_uint8_t nsac; - rt_uint8_t tran_speed; /* max data transfer rate */ - rt_uint16_t card_cmd_class; /* card command classes */ - rt_uint8_t rd_blk_len; /* max read data block length */ - rt_uint8_t rd_blk_part; - rt_uint8_t wr_blk_misalign; - rt_uint8_t rd_blk_misalign; - rt_uint8_t dsr_imp; /* DSR implemented */ - rt_uint8_t c_size_mult; /* CSD 1.0 , device size multiplier */ - rt_uint32_t c_size; /* device size */ - rt_uint8_t r2w_factor; - rt_uint8_t wr_blk_len; /* max wtire data block length */ - rt_uint8_t wr_blk_partial; - rt_uint8_t csd_crc; - + rt_uint8_t csd_structure; /* CSD register version */ + rt_uint8_t taac; + rt_uint8_t nsac; + rt_uint8_t tran_speed; /* max data transfer rate */ + rt_uint16_t card_cmd_class; /* card command classes */ + rt_uint8_t rd_blk_len; /* max read data block length */ + rt_uint8_t rd_blk_part; + rt_uint8_t wr_blk_misalign; + rt_uint8_t rd_blk_misalign; + rt_uint8_t dsr_imp; /* DSR implemented */ + rt_uint8_t c_size_mult; /* CSD 1.0 , device size multiplier */ + rt_uint32_t c_size; /* device size */ + rt_uint8_t r2w_factor; + rt_uint8_t wr_blk_len; /* max wtire data block length */ + rt_uint8_t wr_blk_partial; + rt_uint8_t csd_crc; + }; struct rt_sd_scr { - rt_uint8_t sd_version; - rt_uint8_t sd_bus_widths; + rt_uint8_t sd_version; + rt_uint8_t sd_bus_widths; }; struct rt_sdio_cccr { - rt_uint8_t sdio_version; - rt_uint8_t sd_version; - rt_uint8_t direct_cmd:1, /* Card Supports Direct Commands during data transfer - only SD mode, not used for SPI mode */ - multi_block:1, /* Card Supports Multi-Block */ - read_wait:1, /* Card Supports Read Wait - only SD mode, not used for SPI mode */ - suspend_resume:1, /* Card supports Suspend/Resume - only SD mode, not used for SPI mode */ - s4mi:1, /* generate interrupts during a 4-bit - multi-block data transfer */ - e4mi:1, /* Enable the multi-block IRQ during - 4-bit transfer for the SDIO card */ - low_speed:1, /* Card is a Low-Speed card */ - low_speed_4:1; /* 4-bit support for Low-Speed cards */ - - rt_uint8_t bus_width:1, /* Support SDIO bus width, 1:4bit, 0:1bit */ - cd_disable:1, /* Connect[0]/Disconnect[1] the 10K-90K ohm pull-up - resistor on CD/DAT[3] (pin 1) of the card */ - power_ctrl:1, /* Support Master Power Control */ - high_speed:1; /* Support High-Speed */ - - + rt_uint8_t sdio_version; + rt_uint8_t sd_version; + rt_uint8_t direct_cmd:1, /* Card Supports Direct Commands during data transfer + only SD mode, not used for SPI mode */ + multi_block:1, /* Card Supports Multi-Block */ + read_wait:1, /* Card Supports Read Wait + only SD mode, not used for SPI mode */ + suspend_resume:1, /* Card supports Suspend/Resume + only SD mode, not used for SPI mode */ + s4mi:1, /* generate interrupts during a 4-bit + multi-block data transfer */ + e4mi:1, /* Enable the multi-block IRQ during + 4-bit transfer for the SDIO card */ + low_speed:1, /* Card is a Low-Speed card */ + low_speed_4:1; /* 4-bit support for Low-Speed cards */ + + rt_uint8_t bus_width:1, /* Support SDIO bus width, 1:4bit, 0:1bit */ + cd_disable:1, /* Connect[0]/Disconnect[1] the 10K-90K ohm pull-up + resistor on CD/DAT[3] (pin 1) of the card */ + power_ctrl:1, /* Support Master Power Control */ + high_speed:1; /* Support High-Speed */ + + }; struct rt_sdio_cis { - rt_uint16_t manufacturer; - rt_uint16_t product; - rt_uint16_t func0_blk_size; - rt_uint32_t max_tran_speed; + rt_uint16_t manufacturer; + rt_uint16_t product; + rt_uint16_t func0_blk_size; + rt_uint32_t max_tran_speed; }; /* * SDIO function CIS tuple (unknown to the core) */ struct rt_sdio_function_tuple { - struct rt_sdio_function_tuple *next; - rt_uint8_t code; - rt_uint8_t size; - rt_uint8_t *data; + struct rt_sdio_function_tuple *next; + rt_uint8_t code; + rt_uint8_t size; + rt_uint8_t *data; }; struct rt_sdio_function; @@ -107,60 +107,60 @@ typedef void (rt_sdio_irq_handler_t)(struct rt_sdio_function *); * SDIO function devices */ struct rt_sdio_function { - struct rt_mmcsd_card *card; /* the card this device belongs to */ - rt_sdio_irq_handler_t *irq_handler; /* IRQ callback */ - rt_uint8_t num; /* function number */ + struct rt_mmcsd_card *card; /* the card this device belongs to */ + rt_sdio_irq_handler_t *irq_handler; /* IRQ callback */ + rt_uint8_t num; /* function number */ + + rt_uint8_t func_code; /* Standard SDIO Function interface code */ + rt_uint16_t manufacturer; /* manufacturer id */ + rt_uint16_t product; /* product id */ - rt_uint8_t func_code; /* Standard SDIO Function interface code */ - rt_uint16_t manufacturer; /* manufacturer id */ - rt_uint16_t product; /* product id */ + rt_uint32_t max_blk_size; /* maximum block size */ + rt_uint32_t cur_blk_size; /* current block size */ - rt_uint32_t max_blk_size; /* maximum block size */ - rt_uint32_t cur_blk_size; /* current block size */ + rt_uint32_t enable_timeout_val; /* max enable timeout in msec */ - rt_uint32_t enable_timeout_val; /* max enable timeout in msec */ + struct rt_sdio_function_tuple *tuples; - struct rt_sdio_function_tuple *tuples; - void *priv; }; -#define SDIO_MAX_FUNCTIONS 7 +#define SDIO_MAX_FUNCTIONS 7 struct rt_mmcsd_card { - struct rt_mmcsd_host *host; - rt_uint32_t rca; /* card addr */ - rt_uint32_t resp_cid[4]; /* card CID register */ - rt_uint32_t resp_csd[4]; /* card CSD register */ - rt_uint32_t resp_scr[2]; /* card SCR register */ - - rt_uint16_t tacc_clks; /* data access time by ns */ - rt_uint32_t tacc_ns; /* data access time by clk cycles */ - rt_uint32_t max_data_rate; /* max data transfer rate */ - rt_uint32_t card_capacity; /* card capacity, unit:KB */ - rt_uint32_t card_blksize; /* card block size */ - rt_uint32_t erase_size; /* erase size in sectors */ - rt_uint16_t card_type; + struct rt_mmcsd_host *host; + rt_uint32_t rca; /* card addr */ + rt_uint32_t resp_cid[4]; /* card CID register */ + rt_uint32_t resp_csd[4]; /* card CSD register */ + rt_uint32_t resp_scr[2]; /* card SCR register */ + + rt_uint16_t tacc_clks; /* data access time by ns */ + rt_uint32_t tacc_ns; /* data access time by clk cycles */ + rt_uint32_t max_data_rate; /* max data transfer rate */ + rt_uint32_t card_capacity; /* card capacity, unit:KB */ + rt_uint32_t card_blksize; /* card block size */ + rt_uint32_t erase_size; /* erase size in sectors */ + rt_uint16_t card_type; #define CARD_TYPE_MMC 0 /* MMC card */ #define CARD_TYPE_SD 1 /* SD card */ #define CARD_TYPE_SDIO 2 /* SDIO card */ #define CARD_TYPE_SDIO_COMBO 3 /* SD combo (IO+mem) card */ - rt_uint16_t flags; + rt_uint16_t flags; #define CARD_FLAG_HIGHSPEED (1 << 0) /* SDIO bus speed 50MHz */ #define CARD_FLAG_SDHC (1 << 1) /* SDHC card */ #define CARD_FLAG_SDXC (1 << 2) /* SDXC card */ - struct rt_sd_scr scr; - struct rt_mmcsd_csd csd; - rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */ + struct rt_sd_scr scr; + struct rt_mmcsd_csd csd; + rt_uint32_t hs_max_data_rate; /* max data transfer rate in high speed mode */ - rt_uint8_t sdio_function_num; /* totol number of SDIO functions */ - struct rt_sdio_cccr cccr; /* common card info */ - struct rt_sdio_cis cis; /* common tuple info */ - struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS + 1]; /* SDIO functions (devices) */ + rt_uint8_t sdio_function_num; /* totol number of SDIO functions */ + struct rt_sdio_cccr cccr; /* common card info */ + struct rt_sdio_cis cis; /* common tuple info */ + struct rt_sdio_function *sdio_function[SDIO_MAX_FUNCTIONS + 1]; /* SDIO functions (devices) */ }; diff --git a/components/drivers/include/drivers/mmcsd_cmd.h b/components/drivers/include/drivers/mmcsd_cmd.h index 7c2f26e892..2993fe5406 100644 --- a/components/drivers/include/drivers/mmcsd_cmd.h +++ b/components/drivers/include/drivers/mmcsd_cmd.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2011-07-25 weety first version + * Date Author Notes + * 2011-07-25 weety first version */ #ifndef __CMD_H__ @@ -85,9 +85,9 @@ extern "C" { #define SD_APP_OP_COND 41 /* bcr [31:0] OCR R3 */ #define SD_APP_SEND_SCR 51 /* adtc R1 */ -#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ -#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ -#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ +#define SCR_SPEC_VER_0 0 /* Implements system specification 1.0 - 1.01 */ +#define SCR_SPEC_VER_1 1 /* Implements system specification 1.10 */ +#define SCR_SPEC_VER_2 2 /* Implements system specification 2.00 */ /* SDIO commands type argument response */ diff --git a/components/drivers/include/drivers/mmcsd_core.h b/components/drivers/include/drivers/mmcsd_core.h index 05a5af6d79..11b1386b23 100644 --- a/components/drivers/include/drivers/mmcsd_core.h +++ b/components/drivers/include/drivers/mmcsd_core.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2011-07-25 weety first version + * Date Author Notes + * 2011-07-25 weety first version */ #ifndef __CORE_H__ @@ -27,139 +27,139 @@ extern "C" { #endif struct rt_mmcsd_data { - rt_uint32_t blksize; - rt_uint32_t blks; - rt_uint32_t *buf; - rt_int32_t err; - rt_uint32_t flags; -#define DATA_DIR_WRITE (1 << 0) -#define DATA_DIR_READ (1 << 1) -#define DATA_STREAM (1 << 2) - - unsigned int bytes_xfered; - - struct rt_mmcsd_cmd *stop; /* stop command */ - struct rt_mmcsd_req *mrq; /* associated request */ - - rt_uint32_t timeout_ns; - rt_uint32_t timeout_clks; + rt_uint32_t blksize; + rt_uint32_t blks; + rt_uint32_t *buf; + rt_int32_t err; + rt_uint32_t flags; +#define DATA_DIR_WRITE (1 << 0) +#define DATA_DIR_READ (1 << 1) +#define DATA_STREAM (1 << 2) + + unsigned int bytes_xfered; + + struct rt_mmcsd_cmd *stop; /* stop command */ + struct rt_mmcsd_req *mrq; /* associated request */ + + rt_uint32_t timeout_ns; + rt_uint32_t timeout_clks; }; struct rt_mmcsd_cmd { - rt_uint32_t cmd_code; - rt_uint32_t arg; - rt_uint32_t resp[4]; - rt_uint32_t flags; -/*rsponse types + rt_uint32_t cmd_code; + rt_uint32_t arg; + rt_uint32_t resp[4]; + rt_uint32_t flags; +/*rsponse types *bits:0~3 */ -#define RESP_MASK (0xF) -#define RESP_NONE (0) -#define RESP_R1 (1 << 0) -#define RESP_R1B (2 << 0) -#define RESP_R2 (3 << 0) -#define RESP_R3 (4 << 0) -#define RESP_R4 (5 << 0) -#define RESP_R6 (6 << 0) -#define RESP_R7 (7 << 0) -#define RESP_R5 (8 << 0) /*SDIO command response type*/ -/*command types +#define RESP_MASK (0xF) +#define RESP_NONE (0) +#define RESP_R1 (1 << 0) +#define RESP_R1B (2 << 0) +#define RESP_R2 (3 << 0) +#define RESP_R3 (4 << 0) +#define RESP_R4 (5 << 0) +#define RESP_R6 (6 << 0) +#define RESP_R7 (7 << 0) +#define RESP_R5 (8 << 0) /*SDIO command response type*/ +/*command types *bits:4~5 */ -#define CMD_MASK (3 << 4) /* command type */ -#define CMD_AC (0 << 4) -#define CMD_ADTC (1 << 4) -#define CMD_BC (2 << 4) -#define CMD_BCR (3 << 4) +#define CMD_MASK (3 << 4) /* command type */ +#define CMD_AC (0 << 4) +#define CMD_ADTC (1 << 4) +#define CMD_BC (2 << 4) +#define CMD_BCR (3 << 4) -#define resp_type(cmd) ((cmd)->flags & RESP_MASK) +#define resp_type(cmd) ((cmd)->flags & RESP_MASK) -/*spi rsponse types +/*spi rsponse types *bits:6~8 */ -#define RESP_SPI_MASK (0x7 << 6) -#define RESP_SPI_R1 (1 << 6) -#define RESP_SPI_R1B (2 << 6) -#define RESP_SPI_R2 (3 << 6) -#define RESP_SPI_R3 (4 << 6) -#define RESP_SPI_R4 (5 << 6) -#define RESP_SPI_R5 (6 << 6) -#define RESP_SPI_R7 (7 << 6) - -#define spi_resp_type(cmd) ((cmd)->flags & RESP_SPI_MASK) +#define RESP_SPI_MASK (0x7 << 6) +#define RESP_SPI_R1 (1 << 6) +#define RESP_SPI_R1B (2 << 6) +#define RESP_SPI_R2 (3 << 6) +#define RESP_SPI_R3 (4 << 6) +#define RESP_SPI_R4 (5 << 6) +#define RESP_SPI_R5 (6 << 6) +#define RESP_SPI_R7 (7 << 6) + +#define spi_resp_type(cmd) ((cmd)->flags & RESP_SPI_MASK) /* * These are the command types. */ -#define cmd_type(cmd) ((cmd)->flags & CMD_MASK) - - rt_int32_t retries; /* max number of retries */ - rt_int32_t err; +#define cmd_type(cmd) ((cmd)->flags & CMD_MASK) - struct rt_mmcsd_data *data; - struct rt_mmcsd_req *mrq; /* associated request */ + rt_int32_t retries; /* max number of retries */ + rt_int32_t err; + + struct rt_mmcsd_data *data; + struct rt_mmcsd_req *mrq; /* associated request */ }; struct rt_mmcsd_req { - struct rt_mmcsd_data *data; - struct rt_mmcsd_cmd *cmd; - struct rt_mmcsd_cmd *stop; + struct rt_mmcsd_data *data; + struct rt_mmcsd_cmd *cmd; + struct rt_mmcsd_cmd *stop; }; /*the following is response bit*/ -#define R1_OUT_OF_RANGE (1 << 31) /* er, c */ -#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */ -#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */ -#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */ -#define R1_ERASE_PARAM (1 << 27) /* ex, c */ -#define R1_WP_VIOLATION (1 << 26) /* erx, c */ -#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */ -#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */ -#define R1_COM_CRC_ERROR (1 << 23) /* er, b */ -#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */ -#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */ -#define R1_CC_ERROR (1 << 20) /* erx, c */ -#define R1_ERROR (1 << 19) /* erx, c */ -#define R1_UNDERRUN (1 << 18) /* ex, c */ -#define R1_OVERRUN (1 << 17) /* ex, c */ -#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */ -#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */ -#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */ -#define R1_ERASE_RESET (1 << 13) /* sr, c */ +#define R1_OUT_OF_RANGE (1 << 31) /* er, c */ +#define R1_ADDRESS_ERROR (1 << 30) /* erx, c */ +#define R1_BLOCK_LEN_ERROR (1 << 29) /* er, c */ +#define R1_ERASE_SEQ_ERROR (1 << 28) /* er, c */ +#define R1_ERASE_PARAM (1 << 27) /* ex, c */ +#define R1_WP_VIOLATION (1 << 26) /* erx, c */ +#define R1_CARD_IS_LOCKED (1 << 25) /* sx, a */ +#define R1_LOCK_UNLOCK_FAILED (1 << 24) /* erx, c */ +#define R1_COM_CRC_ERROR (1 << 23) /* er, b */ +#define R1_ILLEGAL_COMMAND (1 << 22) /* er, b */ +#define R1_CARD_ECC_FAILED (1 << 21) /* ex, c */ +#define R1_CC_ERROR (1 << 20) /* erx, c */ +#define R1_ERROR (1 << 19) /* erx, c */ +#define R1_UNDERRUN (1 << 18) /* ex, c */ +#define R1_OVERRUN (1 << 17) /* ex, c */ +#define R1_CID_CSD_OVERWRITE (1 << 16) /* erx, c, CID/CSD overwrite */ +#define R1_WP_ERASE_SKIP (1 << 15) /* sx, c */ +#define R1_CARD_ECC_DISABLED (1 << 14) /* sx, a */ +#define R1_ERASE_RESET (1 << 13) /* sr, c */ #define R1_STATUS(x) (x & 0xFFFFE000) -#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ -#define R1_READY_FOR_DATA (1 << 8) /* sx, a */ -#define R1_APP_CMD (1 << 5) /* sr, c */ - - -#define R1_SPI_IDLE (1 << 0) -#define R1_SPI_ERASE_RESET (1 << 1) -#define R1_SPI_ILLEGAL_COMMAND (1 << 2) -#define R1_SPI_COM_CRC (1 << 3) -#define R1_SPI_ERASE_SEQ (1 << 4) -#define R1_SPI_ADDRESS (1 << 5) -#define R1_SPI_PARAMETER (1 << 6) +#define R1_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ +#define R1_READY_FOR_DATA (1 << 8) /* sx, a */ +#define R1_APP_CMD (1 << 5) /* sr, c */ + + +#define R1_SPI_IDLE (1 << 0) +#define R1_SPI_ERASE_RESET (1 << 1) +#define R1_SPI_ILLEGAL_COMMAND (1 << 2) +#define R1_SPI_COM_CRC (1 << 3) +#define R1_SPI_ERASE_SEQ (1 << 4) +#define R1_SPI_ADDRESS (1 << 5) +#define R1_SPI_PARAMETER (1 << 6) /* R1 bit 7 is always zero */ -#define R2_SPI_CARD_LOCKED (1 << 8) -#define R2_SPI_WP_ERASE_SKIP (1 << 9) /* or lock/unlock fail */ -#define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP -#define R2_SPI_ERROR (1 << 10) -#define R2_SPI_CC_ERROR (1 << 11) -#define R2_SPI_CARD_ECC_ERROR (1 << 12) -#define R2_SPI_WP_VIOLATION (1 << 13) -#define R2_SPI_ERASE_PARAM (1 << 14) -#define R2_SPI_OUT_OF_RANGE (1 << 15) /* or CSD overwrite */ -#define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE - -#define CARD_BUSY 0x80000000 /* Card Power up status bit */ +#define R2_SPI_CARD_LOCKED (1 << 8) +#define R2_SPI_WP_ERASE_SKIP (1 << 9) /* or lock/unlock fail */ +#define R2_SPI_LOCK_UNLOCK_FAIL R2_SPI_WP_ERASE_SKIP +#define R2_SPI_ERROR (1 << 10) +#define R2_SPI_CC_ERROR (1 << 11) +#define R2_SPI_CARD_ECC_ERROR (1 << 12) +#define R2_SPI_WP_VIOLATION (1 << 13) +#define R2_SPI_ERASE_PARAM (1 << 14) +#define R2_SPI_OUT_OF_RANGE (1 << 15) /* or CSD overwrite */ +#define R2_SPI_CSD_OVERWRITE R2_SPI_OUT_OF_RANGE + +#define CARD_BUSY 0x80000000 /* Card Power up status bit */ /* R5 response bits */ -#define R5_COM_CRC_ERROR (1 << 15) -#define R5_ILLEGAL_COMMAND (1 << 14) -#define R5_ERROR (1 << 11) -#define R5_FUNCTION_NUMBER (1 << 9) -#define R5_OUT_OF_RANGE (1 << 8) -#define R5_STATUS(x) (x & 0xCB00) -#define R5_IO_CURRENT_STATE(x) ((x & 0x3000) >> 12) +#define R5_COM_CRC_ERROR (1 << 15) +#define R5_ILLEGAL_COMMAND (1 << 14) +#define R5_ERROR (1 << 11) +#define R5_FUNCTION_NUMBER (1 << 9) +#define R5_OUT_OF_RANGE (1 << 8) +#define R5_STATUS(x) (x & 0xCB00) +#define R5_IO_CURRENT_STATE(x) ((x & 0x3000) >> 12) @@ -173,36 +173,36 @@ struct rt_mmcsd_req { rt_inline rt_uint32_t __rt_fls(rt_uint32_t val) { - rt_uint32_t bit = 32; - - if (!val) - return 0; - if (!(val & 0xffff0000u)) - { - val <<= 16; - bit -= 16; - } - if (!(val & 0xff000000u)) - { - val <<= 8; - bit -= 8; - } - if (!(val & 0xf0000000u)) - { - val <<= 4; - bit -= 4; - } - if (!(val & 0xc0000000u)) - { - val <<= 2; - bit -= 2; - } - if (!(val & 0x80000000u)) - { - bit -= 1; - } - - return bit; + rt_uint32_t bit = 32; + + if (!val) + return 0; + if (!(val & 0xffff0000u)) + { + val <<= 16; + bit -= 16; + } + if (!(val & 0xff000000u)) + { + val <<= 8; + bit -= 8; + } + if (!(val & 0xf0000000u)) + { + val <<= 4; + bit -= 4; + } + if (!(val & 0xc0000000u)) + { + val <<= 2; + bit -= 2; + } + if (!(val & 0x80000000u)) + { + bit -= 1; + } + + return bit; } #define MMCSD_HOST_PLUGED 0 diff --git a/components/drivers/include/drivers/mmcsd_host.h b/components/drivers/include/drivers/mmcsd_host.h index 1253062aef..c7f673aeb1 100644 --- a/components/drivers/include/drivers/mmcsd_host.h +++ b/components/drivers/include/drivers/mmcsd_host.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: - * Date Author Notes - * 2011-07-25 weety first version + * Date Author Notes + * 2011-07-25 weety first version */ #ifndef __HOST_H__ @@ -18,33 +18,33 @@ extern "C" { #endif struct rt_mmcsd_io_cfg { - rt_uint32_t clock; /* clock rate */ - rt_uint16_t vdd; + rt_uint32_t clock; /* clock rate */ + rt_uint16_t vdd; /* vdd stores the bit number of the selected voltage range from below. */ - rt_uint8_t bus_mode; /* command output mode */ + rt_uint8_t bus_mode; /* command output mode */ -#define MMCSD_BUSMODE_OPENDRAIN 1 -#define MMCSD_BUSMODE_PUSHPULL 2 +#define MMCSD_BUSMODE_OPENDRAIN 1 +#define MMCSD_BUSMODE_PUSHPULL 2 - rt_uint8_t chip_select; /* SPI chip select */ + rt_uint8_t chip_select; /* SPI chip select */ -#define MMCSD_CS_IGNORE 0 -#define MMCSD_CS_HIGH 1 -#define MMCSD_CS_LOW 2 +#define MMCSD_CS_IGNORE 0 +#define MMCSD_CS_HIGH 1 +#define MMCSD_CS_LOW 2 - rt_uint8_t power_mode; /* power supply mode */ + rt_uint8_t power_mode; /* power supply mode */ -#define MMCSD_POWER_OFF 0 -#define MMCSD_POWER_UP 1 -#define MMCSD_POWER_ON 2 +#define MMCSD_POWER_OFF 0 +#define MMCSD_POWER_UP 1 +#define MMCSD_POWER_ON 2 - rt_uint8_t bus_width; /* data bus width */ + rt_uint8_t bus_width; /* data bus width */ -#define MMCSD_BUS_WIDTH_1 0 -#define MMCSD_BUS_WIDTH_4 2 -#define MMCSD_BUS_WIDTH_8 3 +#define MMCSD_BUS_WIDTH_1 0 +#define MMCSD_BUS_WIDTH_4 2 +#define MMCSD_BUS_WIDTH_8 3 }; @@ -52,71 +52,71 @@ struct rt_mmcsd_host; struct rt_mmcsd_req; struct rt_mmcsd_host_ops { - void (*request)(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req); - void (*set_iocfg)(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg); - rt_int32_t (*get_card_status)(struct rt_mmcsd_host *host); - void (*enable_sdio_irq)(struct rt_mmcsd_host *host, rt_int32_t en); + void (*request)(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req); + void (*set_iocfg)(struct rt_mmcsd_host *host, struct rt_mmcsd_io_cfg *io_cfg); + rt_int32_t (*get_card_status)(struct rt_mmcsd_host *host); + void (*enable_sdio_irq)(struct rt_mmcsd_host *host, rt_int32_t en); }; struct rt_mmcsd_host { - struct rt_mmcsd_card *card; - const struct rt_mmcsd_host_ops *ops; - rt_uint32_t freq_min; - rt_uint32_t freq_max; - struct rt_mmcsd_io_cfg io_cfg; - rt_uint32_t valid_ocr; /* current valid OCR */ -#define VDD_165_195 (1 << 7) /* VDD voltage 1.65 - 1.95 */ -#define VDD_20_21 (1 << 8) /* VDD voltage 2.0 ~ 2.1 */ -#define VDD_21_22 (1 << 9) /* VDD voltage 2.1 ~ 2.2 */ -#define VDD_22_23 (1 << 10) /* VDD voltage 2.2 ~ 2.3 */ -#define VDD_23_24 (1 << 11) /* VDD voltage 2.3 ~ 2.4 */ -#define VDD_24_25 (1 << 12) /* VDD voltage 2.4 ~ 2.5 */ -#define VDD_25_26 (1 << 13) /* VDD voltage 2.5 ~ 2.6 */ -#define VDD_26_27 (1 << 14) /* VDD voltage 2.6 ~ 2.7 */ -#define VDD_27_28 (1 << 15) /* VDD voltage 2.7 ~ 2.8 */ -#define VDD_28_29 (1 << 16) /* VDD voltage 2.8 ~ 2.9 */ -#define VDD_29_30 (1 << 17) /* VDD voltage 2.9 ~ 3.0 */ -#define VDD_30_31 (1 << 18) /* VDD voltage 3.0 ~ 3.1 */ -#define VDD_31_32 (1 << 19) /* VDD voltage 3.1 ~ 3.2 */ -#define VDD_32_33 (1 << 20) /* VDD voltage 3.2 ~ 3.3 */ -#define VDD_33_34 (1 << 21) /* VDD voltage 3.3 ~ 3.4 */ -#define VDD_34_35 (1 << 22) /* VDD voltage 3.4 ~ 3.5 */ -#define VDD_35_36 (1 << 23) /* VDD voltage 3.5 ~ 3.6 */ - rt_uint32_t flags; /* define device capabilities */ -#define MMCSD_BUSWIDTH_4 (1 << 0) -#define MMCSD_BUSWIDTH_8 (1 << 1) -#define MMCSD_MUTBLKWRITE (1 << 2) -#define MMCSD_HOST_IS_SPI (1 << 3) -#define controller_is_spi(host) (host->flags & MMCSD_HOST_IS_SPI) -#define MMCSD_SUP_SDIO_IRQ (1 << 4) /* support signal pending SDIO IRQs */ -#define MMCSD_SUP_HIGHSPEED (1 << 5) /* support high speed */ - - rt_uint32_t max_seg_size; /* maximum size of one dma segment */ - rt_uint32_t max_dma_segs; /* maximum number of dma segments in one request */ - rt_uint32_t max_blk_size; /* maximum block size */ - rt_uint32_t max_blk_count; /* maximum block count */ - - rt_uint32_t spi_use_crc; - struct rt_mutex bus_lock; - struct rt_semaphore sem_ack; - - rt_uint32_t sdio_irq_num; - struct rt_semaphore *sdio_irq_sem; - struct rt_thread *sdio_irq_thread; - - void *private_data; + struct rt_mmcsd_card *card; + const struct rt_mmcsd_host_ops *ops; + rt_uint32_t freq_min; + rt_uint32_t freq_max; + struct rt_mmcsd_io_cfg io_cfg; + rt_uint32_t valid_ocr; /* current valid OCR */ +#define VDD_165_195 (1 << 7) /* VDD voltage 1.65 - 1.95 */ +#define VDD_20_21 (1 << 8) /* VDD voltage 2.0 ~ 2.1 */ +#define VDD_21_22 (1 << 9) /* VDD voltage 2.1 ~ 2.2 */ +#define VDD_22_23 (1 << 10) /* VDD voltage 2.2 ~ 2.3 */ +#define VDD_23_24 (1 << 11) /* VDD voltage 2.3 ~ 2.4 */ +#define VDD_24_25 (1 << 12) /* VDD voltage 2.4 ~ 2.5 */ +#define VDD_25_26 (1 << 13) /* VDD voltage 2.5 ~ 2.6 */ +#define VDD_26_27 (1 << 14) /* VDD voltage 2.6 ~ 2.7 */ +#define VDD_27_28 (1 << 15) /* VDD voltage 2.7 ~ 2.8 */ +#define VDD_28_29 (1 << 16) /* VDD voltage 2.8 ~ 2.9 */ +#define VDD_29_30 (1 << 17) /* VDD voltage 2.9 ~ 3.0 */ +#define VDD_30_31 (1 << 18) /* VDD voltage 3.0 ~ 3.1 */ +#define VDD_31_32 (1 << 19) /* VDD voltage 3.1 ~ 3.2 */ +#define VDD_32_33 (1 << 20) /* VDD voltage 3.2 ~ 3.3 */ +#define VDD_33_34 (1 << 21) /* VDD voltage 3.3 ~ 3.4 */ +#define VDD_34_35 (1 << 22) /* VDD voltage 3.4 ~ 3.5 */ +#define VDD_35_36 (1 << 23) /* VDD voltage 3.5 ~ 3.6 */ + rt_uint32_t flags; /* define device capabilities */ +#define MMCSD_BUSWIDTH_4 (1 << 0) +#define MMCSD_BUSWIDTH_8 (1 << 1) +#define MMCSD_MUTBLKWRITE (1 << 2) +#define MMCSD_HOST_IS_SPI (1 << 3) +#define controller_is_spi(host) (host->flags & MMCSD_HOST_IS_SPI) +#define MMCSD_SUP_SDIO_IRQ (1 << 4) /* support signal pending SDIO IRQs */ +#define MMCSD_SUP_HIGHSPEED (1 << 5) /* support high speed */ + + rt_uint32_t max_seg_size; /* maximum size of one dma segment */ + rt_uint32_t max_dma_segs; /* maximum number of dma segments in one request */ + rt_uint32_t max_blk_size; /* maximum block size */ + rt_uint32_t max_blk_count; /* maximum block count */ + + rt_uint32_t spi_use_crc; + struct rt_mutex bus_lock; + struct rt_semaphore sem_ack; + + rt_uint32_t sdio_irq_num; + struct rt_semaphore *sdio_irq_sem; + struct rt_thread *sdio_irq_thread; + + void *private_data; }; rt_inline void mmcsd_delay_ms(rt_uint32_t ms) { - if (ms < 1000 / RT_TICK_PER_SECOND) - { - rt_thread_delay(1); - } - else - { - rt_thread_delay(ms/(1000 / RT_TICK_PER_SECOND)); - } + if (ms < 1000 / RT_TICK_PER_SECOND) + { + rt_thread_delay(1); + } + else + { + rt_thread_delay(ms/(1000 / RT_TICK_PER_SECOND)); + } } #ifdef __cplusplus diff --git a/components/drivers/include/drivers/mtd_nand.h b/components/drivers/include/drivers/mtd_nand.h index f7675aede6..a452da61dd 100644 --- a/components/drivers/include/drivers/mtd_nand.h +++ b/components/drivers/include/drivers/mtd_nand.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/mtd_nor.h b/components/drivers/include/drivers/mtd_nor.h index 32a952f374..5573c54920 100644 --- a/components/drivers/include/drivers/mtd_nor.h +++ b/components/drivers/include/drivers/mtd_nor.h @@ -1,11 +1,11 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes - * 2012-5-30 Bernard the first version + * 2012-5-30 Bernard the first version */ #ifndef __MTD_NOR_H__ @@ -14,54 +14,54 @@ #include struct rt_mtd_nor_driver_ops; -#define RT_MTD_NOR_DEVICE(device) ((struct rt_mtd_nor_device*)(device)) +#define RT_MTD_NOR_DEVICE(device) ((struct rt_mtd_nor_device*)(device)) struct rt_mtd_nor_device { - struct rt_device parent; + struct rt_device parent; - rt_uint32_t block_size; /* The Block size in the flash */ - rt_uint32_t block_start; /* The start of available block*/ - rt_uint32_t block_end; /* The end of available block */ + rt_uint32_t block_size; /* The Block size in the flash */ + rt_uint32_t block_start; /* The start of available block*/ + rt_uint32_t block_end; /* The end of available block */ - /* operations interface */ - const struct rt_mtd_nor_driver_ops* ops; + /* operations interface */ + const struct rt_mtd_nor_driver_ops* ops; }; struct rt_mtd_nor_driver_ops { - rt_err_t (*read_id) (struct rt_mtd_nor_device* device); + rt_err_t (*read_id) (struct rt_mtd_nor_device* device); - rt_size_t (*read) (struct rt_mtd_nor_device* device, rt_off_t offset, rt_uint8_t* data, rt_uint32_t length); - rt_size_t (*write) (struct rt_mtd_nor_device* device, rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length); + rt_size_t (*read) (struct rt_mtd_nor_device* device, rt_off_t offset, rt_uint8_t* data, rt_uint32_t length); + rt_size_t (*write) (struct rt_mtd_nor_device* device, rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length); - rt_err_t (*erase_block)(struct rt_mtd_nor_device* device, rt_off_t offset, rt_uint32_t length); + rt_err_t (*erase_block)(struct rt_mtd_nor_device* device, rt_off_t offset, rt_uint32_t length); }; rt_err_t rt_mtd_nor_register_device(const char* name, struct rt_mtd_nor_device* device); rt_inline rt_uint32_t rt_mtd_nor_read_id(struct rt_mtd_nor_device* device) { - return device->ops->read_id(device); + return device->ops->read_id(device); } rt_inline rt_size_t rt_mtd_nor_read( - struct rt_mtd_nor_device* device, - rt_off_t offset, rt_uint8_t* data, rt_uint32_t length) + struct rt_mtd_nor_device* device, + rt_off_t offset, rt_uint8_t* data, rt_uint32_t length) { - return device->ops->read(device, offset, data, length); + return device->ops->read(device, offset, data, length); } rt_inline rt_size_t rt_mtd_nor_write( - struct rt_mtd_nor_device* device, - rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length) + struct rt_mtd_nor_device* device, + rt_off_t offset, const rt_uint8_t* data, rt_uint32_t length) { - return device->ops->write(device, offset, data, length); + return device->ops->write(device, offset, data, length); } rt_inline rt_err_t rt_mtd_nor_erase_block(struct rt_mtd_nor_device* device, rt_off_t offset, rt_size_t length) { - return device->ops->erase_block(device, offset, length); + return device->ops->erase_block(device, offset, length); } #endif diff --git a/components/drivers/include/drivers/phy.h b/components/drivers/include/drivers/phy.h index 2d1ad9f91f..e1783fe328 100644 --- a/components/drivers/include/drivers/phy.h +++ b/components/drivers/include/drivers/phy.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/phy_mdio.h b/components/drivers/include/drivers/phy_mdio.h index d978ec2984..fdef455db2 100644 --- a/components/drivers/include/drivers/phy_mdio.h +++ b/components/drivers/include/drivers/phy_mdio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/pin.h b/components/drivers/include/drivers/pin.h index f5b2ded9f6..5ba1e6c8ea 100644 --- a/components/drivers/include/drivers/pin.h +++ b/components/drivers/include/drivers/pin.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/pm.h b/components/drivers/include/drivers/pm.h index f28283dcf8..51bff54ebb 100644 --- a/components/drivers/include/drivers/pm.h +++ b/components/drivers/include/drivers/pm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/pulse_encoder.h b/components/drivers/include/drivers/pulse_encoder.h index 0c7df04cd6..38ef7652b9 100644 --- a/components/drivers/include/drivers/pulse_encoder.h +++ b/components/drivers/include/drivers/pulse_encoder.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/rt_drv_pwm.h b/components/drivers/include/drivers/rt_drv_pwm.h index 7a8e17b916..72e34428e6 100644 --- a/components/drivers/include/drivers/rt_drv_pwm.h +++ b/components/drivers/include/drivers/rt_drv_pwm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/rt_inputcapture.h b/components/drivers/include/drivers/rt_inputcapture.h index 40cd55883d..813ed3157b 100644 --- a/components/drivers/include/drivers/rt_inputcapture.h +++ b/components/drivers/include/drivers/rt_inputcapture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/rtc.h b/components/drivers/include/drivers/rtc.h index 1cd88a7be3..4845937113 100644 --- a/components/drivers/include/drivers/rtc.h +++ b/components/drivers/include/drivers/rtc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/sd.h b/components/drivers/include/drivers/sd.h index e096df9372..450f23e65b 100644 --- a/components/drivers/include/drivers/sd.h +++ b/components/drivers/include/drivers/sd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/drivers/sdio.h b/components/drivers/include/drivers/sdio.h index e4bf4a048f..212d8cfb52 100644 --- a/components/drivers/include/drivers/sdio.h +++ b/components/drivers/include/drivers/sdio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -174,10 +174,10 @@ rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func, rt_int32_t op_code, rt_uint8_t *buf, rt_uint32_t len); -rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, +rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, rt_uint32_t reg, rt_int32_t *err); -rt_int32_t sdio_io_writeb(struct rt_sdio_function *func, +rt_int32_t sdio_io_writeb(struct rt_sdio_function *func, rt_uint32_t reg, rt_uint8_t data); rt_uint16_t sdio_io_readw(struct rt_sdio_function *func, @@ -192,19 +192,19 @@ rt_uint32_t sdio_io_readl(struct rt_sdio_function *func, rt_int32_t sdio_io_writel(struct rt_sdio_function *func, rt_uint32_t data, rt_uint32_t addr); -rt_int32_t sdio_io_read_multi_fifo_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_read_multi_fifo_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len); -rt_int32_t sdio_io_write_multi_fifo_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_write_multi_fifo_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len); -rt_int32_t sdio_io_read_multi_incr_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_read_multi_incr_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len); -rt_int32_t sdio_io_write_multi_incr_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_write_multi_incr_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len); diff --git a/components/drivers/include/drivers/sdio_func_ids.h b/components/drivers/include/drivers/sdio_func_ids.h index 79085a5933..76502ff6ea 100644 --- a/components/drivers/include/drivers/sdio_func_ids.h +++ b/components/drivers/include/drivers/sdio_func_ids.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -7,7 +7,7 @@ * Date Author Notes * 2012-02-26 weety first version */ - + #ifndef __SDIO_FUNC_IDS_H__ #define __SDIO_FUNC_IDS_H__ diff --git a/components/drivers/include/drivers/serial.h b/components/drivers/include/drivers/serial.h index 45095af63f..c2e951e9b1 100644 --- a/components/drivers/include/drivers/serial.h +++ b/components/drivers/include/drivers/serial.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -104,7 +104,7 @@ struct serial_configure }; /* - * Serial FIFO mode + * Serial FIFO mode */ struct rt_serial_rx_fifo { @@ -121,7 +121,7 @@ struct rt_serial_tx_fifo struct rt_completion completion; }; -/* +/* * Serial DMA mode */ struct rt_serial_rx_dma diff --git a/components/drivers/include/drivers/spi.h b/components/drivers/include/drivers/spi.h index d92518cd94..018d12139b 100644 --- a/components/drivers/include/drivers/spi.h +++ b/components/drivers/include/drivers/spi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -151,7 +151,7 @@ struct rt_qspi_configuration }; struct rt_qspi_device -{ +{ struct rt_spi_device parent; struct rt_qspi_configuration config; diff --git a/components/drivers/include/drivers/usb_common.h b/components/drivers/include/drivers/usb_common.h index 4d85a85e35..9c29a0d0df 100644 --- a/components/drivers/include/drivers/usb_common.h +++ b/components/drivers/include/drivers/usb_common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -427,14 +427,14 @@ struct usb_os_proerty }; typedef struct usb_os_proerty * usb_os_proerty_t; -// Value Description -// 1 A NULL-terminated Unicode String (REG_SZ) -// 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ) -// 3 Free-form binary (REG_BINARY) -// 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN) -// 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN) -// 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK) -// 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ) +// Value Description +// 1 A NULL-terminated Unicode String (REG_SZ) +// 2 A NULL-terminated Unicode String that includes environment variables (REG_EXPAND_SZ) +// 3 Free-form binary (REG_BINARY) +// 4 A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN) +// 5 A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN) +// 6 A NULL-terminated Unicode string that contains a symbolic link (REG_LINK) +// 7 Multiple NULL-terminated Unicode strings (REG_MULTI_SZ) #define USB_OS_PROPERTY_TYPE_REG_SZ 0x01UL #define USB_OS_PROPERTY_TYPE_REG_EXPAND_SZ 0x02UL #define USB_OS_PROPERTY_TYPE_REG_BINARY 0x03UL diff --git a/components/drivers/include/drivers/usb_device.h b/components/drivers/include/drivers/usb_device.h index 26f0c4cf4a..1e76477dbc 100644 --- a/components/drivers/include/drivers/usb_device.h +++ b/components/drivers/include/drivers/usb_device.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -62,12 +62,12 @@ struct ufunction; struct udevice; struct uendpoint; -typedef enum +typedef enum { /* request to read full count */ UIO_REQUEST_READ_FULL, /* request to read any count */ - UIO_REQUEST_READ_BEST, + UIO_REQUEST_READ_BEST, /* request to write full count */ UIO_REQUEST_WRITE, }UIO_REQUEST_TYPE; @@ -85,7 +85,7 @@ struct udcd_ops rt_size_t (*ep_write)(rt_uint8_t address, void *buffer, rt_size_t size); rt_err_t (*ep0_send_status)(void); rt_err_t (*suspend)(void); - rt_err_t (*wakeup)(void); + rt_err_t (*wakeup)(void); }; struct ep_id @@ -215,10 +215,10 @@ enum udev_msg_type USB_MSG_SETUP_NOTIFY, USB_MSG_DATA_NOTIFY, USB_MSG_EP0_OUT, - USB_MSG_EP_CLEAR_FEATURE, + USB_MSG_EP_CLEAR_FEATURE, USB_MSG_SOF, USB_MSG_RESET, - USB_MSG_PLUG_IN, + USB_MSG_PLUG_IN, /* we don't need to add a "PLUG_IN" event because after the cable is * plugged in(before any SETUP) the classed have nothing to do. If the host * is ready, it will send RESET and we will have USB_MSG_RESET. So, a RESET @@ -279,7 +279,7 @@ uintf_t rt_usbd_find_interface(udevice_t device, rt_uint8_t value, ufunction_t * uep_t rt_usbd_find_endpoint(udevice_t device, ufunction_t* pfunc, rt_uint8_t ep_addr); rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req); rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size); -rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size, +rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size, rt_err_t (*rx_ind)(udevice_t device, rt_size_t size)); int rt_usbd_vcom_class_register(void); @@ -396,7 +396,7 @@ rt_inline rt_err_t dcd_ep0_send_status(udcd_t dcd) } rt_inline rt_err_t dcd_ep_set_stall(udcd_t dcd, rt_uint8_t address) -{ +{ RT_ASSERT(dcd != RT_NULL); RT_ASSERT(dcd->ops != RT_NULL); RT_ASSERT(dcd->ops->ep_set_stall != RT_NULL); diff --git a/components/drivers/include/drivers/usb_host.h b/components/drivers/include/drivers/usb_host.h index 2a68f4edb5..2031e2cdc0 100644 --- a/components/drivers/include/drivers/usb_host.h +++ b/components/drivers/include/drivers/usb_host.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -44,10 +44,10 @@ struct uclass_driver rt_list_t list; int class_code; int subclass_code; - + rt_err_t (*enable)(void* arg); rt_err_t (*disable)(void* arg); - + void* user_data; }; typedef struct uclass_driver* ucd_t; @@ -56,9 +56,9 @@ struct uprotocal { rt_list_t list; int pro_id; - + rt_err_t (*init)(void* arg); - rt_err_t (*callback)(void* arg); + rt_err_t (*callback)(void* arg); }; typedef struct uprotocal* uprotocal_t; @@ -77,13 +77,13 @@ struct uinstance rt_uint8_t status; rt_uint8_t type; rt_uint8_t index; - rt_uint8_t address; + rt_uint8_t address; rt_uint8_t speed; - rt_uint8_t max_packet_size; + rt_uint8_t max_packet_size; rt_uint8_t port; struct uhub* parent_hub; - struct uhintf* intf[USB_MAX_INTERFACE]; + struct uhintf* intf[USB_MAX_INTERFACE]; }; typedef struct uinstance* uinst_t; @@ -113,14 +113,14 @@ struct uhub struct uhub_descriptor hub_desc; rt_uint8_t num_ports; rt_uint32_t port_status[USB_HUB_PORT_NUM]; - struct uinstance* child[USB_HUB_PORT_NUM]; + struct uinstance* child[USB_HUB_PORT_NUM]; rt_bool_t is_roothub; - rt_uint8_t buffer[8]; + rt_uint8_t buffer[8]; struct uinstance* self; struct uhcd *hcd; -}; +}; typedef struct uhub* uhub_t; struct uhcd_ops @@ -128,7 +128,7 @@ struct uhcd_ops rt_err_t (*reset_port) (rt_uint8_t port); int (*pipe_xfer) (upipe_t pipe, rt_uint8_t token, void* buffer, int nbytes, int timeout); rt_err_t (*open_pipe) (upipe_t pipe); - rt_err_t (*close_pipe) (upipe_t pipe); + rt_err_t (*close_pipe) (upipe_t pipe); }; typedef struct uhcd_ops* uhcd_ops_t; struct uhcd @@ -136,7 +136,7 @@ struct uhcd struct rt_device parent; uhcd_ops_t ops; rt_uint8_t num_ports; - uhub_t roothub; + uhub_t roothub; }; typedef struct uhcd* uhcd_t; @@ -149,11 +149,11 @@ typedef enum uhost_msg_type uhost_msg_type; struct uhost_msg { - uhost_msg_type type; + uhost_msg_type type; union { struct uhub* hub; - struct + struct { func_callback function; void *context; @@ -193,14 +193,14 @@ ucd_t rt_usbh_class_driver_storage(void); /* usb hub interface */ -rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer, +rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer, rt_size_t size); rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint32_t* buffer); -rt_err_t rt_usbh_hub_get_port_status(uhub_t uhub, rt_uint16_t port, +rt_err_t rt_usbh_hub_get_port_status(uhub_t uhub, rt_uint16_t port, rt_uint32_t* buffer); -rt_err_t rt_usbh_hub_clear_port_feature(uhub_t uhub, rt_uint16_t port, +rt_err_t rt_usbh_hub_clear_port_feature(uhub_t uhub, rt_uint16_t port, rt_uint16_t feature); -rt_err_t rt_usbh_hub_set_port_feature(uhub_t uhub, rt_uint16_t port, +rt_err_t rt_usbh_hub_set_port_feature(uhub_t uhub, rt_uint16_t port, rt_uint16_t feature); rt_err_t rt_usbh_hub_reset_port(uhub_t uhub, rt_uint16_t port); rt_err_t rt_usbh_event_signal(struct uhost_msg* msg); diff --git a/components/drivers/include/drivers/watchdog.h b/components/drivers/include/drivers/watchdog.h index f80ded58aa..1cf3dc741d 100644 --- a/components/drivers/include/drivers/watchdog.h +++ b/components/drivers/include/drivers/watchdog.h @@ -1,6 +1,6 @@ /* * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/drivers/include/drivers/wlan.h b/components/drivers/include/drivers/wlan.h index 724e61da78..b5b4f73586 100644 --- a/components/drivers/include/drivers/wlan.h +++ b/components/drivers/include/drivers/wlan.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/completion.h b/components/drivers/include/ipc/completion.h index acfcaa3995..087a9be813 100644 --- a/components/drivers/include/ipc/completion.h +++ b/components/drivers/include/ipc/completion.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/dataqueue.h b/components/drivers/include/ipc/dataqueue.h index 76203c404d..5dd94e55c0 100644 --- a/components/drivers/include/ipc/dataqueue.h +++ b/components/drivers/include/ipc/dataqueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/pipe.h b/components/drivers/include/ipc/pipe.h index 93ba95cd2c..a45e8ae002 100644 --- a/components/drivers/include/ipc/pipe.h +++ b/components/drivers/include/ipc/pipe.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/poll.h b/components/drivers/include/ipc/poll.h index 8c68a96af8..1574215c77 100644 --- a/components/drivers/include/ipc/poll.h +++ b/components/drivers/include/ipc/poll.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/ringblk_buf.h b/components/drivers/include/ipc/ringblk_buf.h index 94fc2cfff3..5b2971b800 100644 --- a/components/drivers/include/ipc/ringblk_buf.h +++ b/components/drivers/include/ipc/ringblk_buf.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/ringbuffer.h b/components/drivers/include/ipc/ringbuffer.h index 2afd2ca213..71c4801253 100644 --- a/components/drivers/include/ipc/ringbuffer.h +++ b/components/drivers/include/ipc/ringbuffer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/ipc/waitqueue.h b/components/drivers/include/ipc/waitqueue.h index e26ec1e896..fbf5f93142 100644 --- a/components/drivers/include/ipc/waitqueue.h +++ b/components/drivers/include/ipc/waitqueue.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes - * 2018/06/26 Bernard Fix the wait queue issue when wakeup a soon + * 2018/06/26 Bernard Fix the wait queue issue when wakeup a soon * to blocked thread. */ diff --git a/components/drivers/include/ipc/workqueue.h b/components/drivers/include/ipc/workqueue.h index 11fee489bd..ccbc42b226 100644 --- a/components/drivers/include/ipc/workqueue.h +++ b/components/drivers/include/ipc/workqueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h index f0fa2f5b4a..82868e5aef 100644 --- a/components/drivers/include/rtdevice.h +++ b/components/drivers/include/rtdevice.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/misc/adc.c b/components/drivers/misc/adc.c index 2d26beb243..d8f79e058b 100644 --- a/components/drivers/misc/adc.c +++ b/components/drivers/misc/adc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/misc/dac.c b/components/drivers/misc/dac.c index 336c78d018..784a503888 100644 --- a/components/drivers/misc/dac.c +++ b/components/drivers/misc/dac.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -148,7 +148,7 @@ static int dac(int argc, char **argv) int result = RT_EOK; static rt_dac_device_t dac_device = RT_NULL; char *result_str; - + if (argc > 1) { if (!strcmp(argv[1], "probe")) diff --git a/components/drivers/misc/pin.c b/components/drivers/misc/pin.c index 6f27fe516d..91bf7058dc 100644 --- a/components/drivers/misc/pin.c +++ b/components/drivers/misc/pin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -157,7 +157,7 @@ rt_base_t rt_pin_get(const char *name) { RT_ASSERT(_hw_pin.ops != RT_NULL); RT_ASSERT(name[0] == 'P'); - + if(_hw_pin.ops->pin_get == RT_NULL) { return -RT_ENOSYS; diff --git a/components/drivers/misc/pulse_encoder.c b/components/drivers/misc/pulse_encoder.c index 3145c24675..5afb12664a 100644 --- a/components/drivers/misc/pulse_encoder.c +++ b/components/drivers/misc/pulse_encoder.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/misc/rt_drv_pwm.c b/components/drivers/misc/rt_drv_pwm.c index 572580c45c..f274f509e2 100644 --- a/components/drivers/misc/rt_drv_pwm.c +++ b/components/drivers/misc/rt_drv_pwm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/misc/rt_inputcapture.c b/components/drivers/misc/rt_inputcapture.c index d1886186d7..134bbcee96 100644 --- a/components/drivers/misc/rt_inputcapture.c +++ b/components/drivers/misc/rt_inputcapture.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/mtd/mtd_nand.c b/components/drivers/mtd/mtd_nand.c index ae5aa9c172..646625ade5 100644 --- a/components/drivers/mtd/mtd_nand.c +++ b/components/drivers/mtd/mtd_nand.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/mtd/mtd_nor.c b/components/drivers/mtd/mtd_nor.c index b941f9236d..fd5ceb0d9f 100644 --- a/components/drivers/mtd/mtd_nor.c +++ b/components/drivers/mtd/mtd_nor.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: @@ -52,7 +52,7 @@ static rt_err_t _mtd_control(rt_device_t dev, int cmd, void *args) } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops mtd_nor_ops = +const static struct rt_device_ops mtd_nor_ops = { _mtd_init, _mtd_open, diff --git a/components/drivers/phy/phy.c b/components/drivers/phy/phy.c index 3ed4a1a265..6d408ce612 100644 --- a/components/drivers/phy/phy.c +++ b/components/drivers/phy/phy.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2006-2020, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -34,9 +34,9 @@ static rt_size_t phy_device_write(rt_device_t dev, rt_off_t pos, const void *buf #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops phy_ops = +const static struct rt_device_ops phy_ops = { - RT_NULL, + RT_NULL, RT_NULL, RT_NULL, phy_device_read, diff --git a/components/drivers/pm/pm.c b/components/drivers/pm/pm.c index 743a184555..80ed101498 100644 --- a/components/drivers/pm/pm.c +++ b/components/drivers/pm/pm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -54,7 +54,7 @@ static int _pm_device_suspend(rt_uint8_t mode) { ret = _pm.device_pm[index].ops->suspend(_pm.device_pm[index].device, mode); if(ret != RT_EOK) - break; + break; } } diff --git a/components/drivers/rtc/alarm.c b/components/drivers/rtc/alarm.c index d8e4e468a7..cd0a976328 100644 --- a/components/drivers/rtc/alarm.c +++ b/components/drivers/rtc/alarm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/rtc/rtc.c b/components/drivers/rtc/rtc.c index ef688ac3cd..98b60f9f95 100644 --- a/components/drivers/rtc/rtc.c +++ b/components/drivers/rtc/rtc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -164,7 +164,7 @@ int rt_rtc_ntp_sync_init(void) } init_ok = RT_TRUE; - + return RT_EOK; } INIT_COMPONENT_EXPORT(rt_rtc_ntp_sync_init); diff --git a/components/drivers/rtc/soft_rtc.c b/components/drivers/rtc/soft_rtc.c index 240301f683..9e1b7c35fd 100644 --- a/components/drivers/rtc/soft_rtc.c +++ b/components/drivers/rtc/soft_rtc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -93,7 +93,7 @@ static rt_err_t soft_rtc_control(rt_device_t dev, int cmd, void *args) } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops soft_rtc_ops = +const static struct rt_device_ops soft_rtc_ops = { RT_NULL, RT_NULL, diff --git a/components/drivers/sdio/block_dev.c b/components/drivers/sdio/block_dev.c index 602acb9aa7..f2ce09a83f 100644 --- a/components/drivers/sdio/block_dev.c +++ b/components/drivers/sdio/block_dev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -76,7 +76,7 @@ rt_int32_t mmcsd_num_wr_blocks(struct rt_mmcsd_card *card) timeout_us += data.timeout_clks * 1000 / (card->host->io_cfg.clock / 1000); - if (timeout_us > 100000) + if (timeout_us > 100000) { data.timeout_ns = 100000000; data.timeout_clks = 0; @@ -119,9 +119,9 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card, rt_memset(&data, 0, sizeof(struct rt_mmcsd_data)); req.cmd = &cmd; req.data = &data; - + cmd.arg = sector; - if (!(card->flags & CARD_FLAG_SDHC)) + if (!(card->flags & CARD_FLAG_SDHC)) { cmd.arg <<= 9; } @@ -130,7 +130,7 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card, data.blksize = SECTOR_SIZE; data.blks = blks; - if (blks > 1) + if (blks > 1) { if (!controller_is_spi(card->host) || !dir) { @@ -149,7 +149,7 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card, w_cmd = WRITE_BLOCK; } - if (!dir) + if (!dir) { cmd.cmd_code = r_cmd; data.flags |= DATA_DIR_READ; @@ -164,9 +164,9 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card, data.buf = buf; mmcsd_send_request(host, &req); - if (!controller_is_spi(card->host) && dir != 0) + if (!controller_is_spi(card->host) && dir != 0) { - do + do { rt_int32_t err; @@ -174,7 +174,7 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card, cmd.arg = card->rca << 16; cmd.flags = RESP_R1 | CMD_AC; err = mmcsd_send_cmd(card->host, &cmd, 5); - if (err) + if (err) { LOG_E("error %d requesting status", err); break; @@ -190,7 +190,7 @@ static rt_err_t rt_mmcsd_req_blk(struct rt_mmcsd_card *card, mmcsd_host_unlock(host); - if (cmd.err || data.err || stop.err) + if (cmd.err || data.err || stop.err) { LOG_E("mmcsd request blocks error"); LOG_E("%d,%d,%d, 0x%08x,0x%08x", @@ -264,7 +264,7 @@ static rt_size_t rt_mmcsd_read(rt_device_t dev, rt_sem_release(part->lock); /* the length of reading must align to SECTOR SIZE */ - if (err) + if (err) { rt_set_errno(-EIO); return 0; @@ -305,7 +305,7 @@ static rt_size_t rt_mmcsd_write(rt_device_t dev, rt_sem_release(part->lock); /* the length of reading must align to SECTOR SIZE */ - if (err) + if (err) { rt_set_errno(-EIO); @@ -330,7 +330,7 @@ static rt_int32_t mmcsd_set_blksize(struct rt_mmcsd_card *card) err = mmcsd_send_cmd(card->host, &cmd, 5); mmcsd_host_unlock(card->host); - if (err) + if (err) { LOG_E("MMCSD: unable to set block size to %d: %d", cmd.arg, err); @@ -341,7 +341,7 @@ static rt_int32_t mmcsd_set_blksize(struct rt_mmcsd_card *card) } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops mmcsd_blk_ops = +const static struct rt_device_ops mmcsd_blk_ops = { rt_mmcsd_init, rt_mmcsd_open, @@ -362,7 +362,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) struct mmcsd_blk_device *blk_dev = RT_NULL; err = mmcsd_set_blksize(card); - if(err) + if(err) { return err; } @@ -384,15 +384,15 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) for (i = 0; i < RT_MMCSD_MAX_PARTITION; i++) { blk_dev = rt_calloc(1, sizeof(struct mmcsd_blk_device)); - if (!blk_dev) + if (!blk_dev) { LOG_E("mmcsd:malloc memory failed!"); break; } - blk_dev->max_req_size = BLK_MIN((card->host->max_dma_segs * - card->host->max_seg_size) >> 9, - (card->host->max_blk_count * + blk_dev->max_req_size = BLK_MIN((card->host->max_dma_segs * + card->host->max_seg_size) >> 9, + (card->host->max_blk_count * card->host->max_blk_size) >> 9); /* get the first partition */ @@ -402,7 +402,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) rt_snprintf(dname, 4, "sd%d", i); rt_snprintf(sname, 8, "sem_sd%d", i); blk_dev->part.lock = rt_sem_create(sname, 1, RT_IPC_FLAG_FIFO); - + /* register mmcsd device */ blk_dev->dev.type = RT_Device_Class_Block; #ifdef RT_USING_DEVICE_OPS @@ -418,11 +418,11 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) blk_dev->dev.user_data = blk_dev; blk_dev->card = card; - + blk_dev->geometry.bytes_per_sector = 1<<9; blk_dev->geometry.block_size = card->card_blksize; blk_dev->geometry.sector_count = blk_dev->part.size; - + rt_device_register(&blk_dev->dev, dname, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE); rt_list_insert_after(&blk_devices, &blk_dev->list); @@ -435,7 +435,7 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) blk_dev->part.offset = 0; blk_dev->part.size = 0; blk_dev->part.lock = rt_sem_create("sem_sd0", 1, RT_IPC_FLAG_FIFO); - + /* register mmcsd device */ blk_dev->dev.type = RT_Device_Class_Block; #ifdef RT_USING_DEVICE_OPS @@ -454,9 +454,9 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) blk_dev->geometry.bytes_per_sector = 1<<9; blk_dev->geometry.block_size = card->card_blksize; - blk_dev->geometry.sector_count = + blk_dev->geometry.sector_count = card->card_capacity * (1024 / 512); - + rt_device_register(&blk_dev->dev, "sd0", RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE); rt_list_insert_after(&blk_devices, &blk_dev->list); @@ -472,9 +472,9 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) #ifdef RT_USING_DFS_MNTTABLE if (blk_dev) { - LOG_I("try to mount file system!"); - /* try to mount file system on this block device */ - dfs_mount_device(&(blk_dev->dev)); + LOG_I("try to mount file system!"); + /* try to mount file system on this block device */ + dfs_mount_device(&(blk_dev->dev)); } #endif } @@ -484,10 +484,10 @@ rt_int32_t rt_mmcsd_blk_probe(struct rt_mmcsd_card *card) LOG_E("read mmcsd first sector failed"); err = -RT_ERROR; } - + /* release sector buffer */ rt_free(sector); - + return err; } @@ -499,15 +499,15 @@ void rt_mmcsd_blk_remove(struct rt_mmcsd_card *card) for (l = (&blk_devices)->next, n = l->next; l != &blk_devices; l = n) { blk_dev = (struct mmcsd_blk_device *)rt_list_entry(l, struct mmcsd_blk_device, list); - if (blk_dev->card == card) + if (blk_dev->card == card) { - /* unmount file system */ - const char * mounted_path = dfs_filesystem_get_mounted_path(&(blk_dev->dev)); - if (mounted_path) - { + /* unmount file system */ + const char * mounted_path = dfs_filesystem_get_mounted_path(&(blk_dev->dev)); + if (mounted_path) + { dfs_unmount(mounted_path); LOG_D("unmount file system %s for device %s.\r\n", mounted_path, blk_dev->dev.parent.name); - } + } rt_sem_delete(blk_dev->part.lock); rt_device_unregister(&blk_dev->dev); rt_list_remove(&blk_dev->list); diff --git a/components/drivers/sdio/mmc.c b/components/drivers/sdio/mmc.c index c1c56d37fd..5aba3dba7a 100644 --- a/components/drivers/sdio/mmc.c +++ b/components/drivers/sdio/mmc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -45,9 +45,9 @@ static const rt_uint8_t tacc_value[] = rt_inline rt_uint32_t GET_BITS(rt_uint32_t *resp, rt_uint32_t start, rt_uint32_t size) -{ +{ const rt_int32_t __size = size; - const rt_uint32_t __mask = (__size < 32 ? 1 << __size : 0) - 1; + const rt_uint32_t __mask = (__size < 32 ? 1 << __size : 0) - 1; const rt_int32_t __off = 3 - ((start) / 32); const rt_int32_t __shft = (start) & 31; rt_uint32_t __res; @@ -67,7 +67,7 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card) rt_uint32_t a, b; struct rt_mmcsd_csd *csd = &card->csd; rt_uint32_t *resp = card->resp_csd; - + /* * We only understand CSD structure v1.1 and v1.2. * v1.2 has extra information in bits 15, 11 and 10. @@ -76,10 +76,10 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card) csd->csd_structure = GET_BITS(resp, 126, 2); if (csd->csd_structure == 0) { LOG_E("unrecognised CSD structure version %d!", csd->csd_structure); - + return -RT_ERROR; } - + csd->taac = GET_BITS(resp, 112, 8); csd->nsac = GET_BITS(resp, 104, 8); csd->tran_speed = GET_BITS(resp, 96, 8); @@ -95,7 +95,7 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card) csd->wr_blk_len = GET_BITS(resp, 22, 4); csd->wr_blk_partial = GET_BITS(resp, 21, 1); csd->csd_crc = GET_BITS(resp, 1, 7); - + card->card_blksize = 1 << csd->rd_blk_len; card->tacc_clks = csd->nsac * 100; card->tacc_ns = (tacc_uint[csd->taac&0x07] * tacc_value[(csd->taac&0x78)>>3] + 9) / 10; @@ -106,7 +106,7 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card) card->erase_size = (a + 1) * (b + 1); card->erase_size <<= csd->wr_blk_len - 9; } - + return 0; } @@ -119,12 +119,12 @@ static int mmc_get_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t **new_ext_csd) struct rt_mmcsd_req req; struct rt_mmcsd_cmd cmd; struct rt_mmcsd_data data; - + *new_ext_csd = RT_NULL; - + if (GET_BITS(card->resp_cid, 122, 4) < 4) return 0; - + /* * As the ext_csd is so large and mostly unused, we don't store the * raw block in mmc_card. @@ -134,29 +134,29 @@ static int mmc_get_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t **new_ext_csd) LOG_E("alloc memory failed when get ext csd!"); return -RT_ENOMEM; } - + rt_memset(&req, 0, sizeof(struct rt_mmcsd_req)); rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); rt_memset(&data, 0, sizeof(struct rt_mmcsd_data)); - + req.cmd = &cmd; req.data = &data; - + cmd.cmd_code = SEND_EXT_CSD; cmd.arg = 0; - + /* NOTE HACK: the RESP_SPI_R1 is always correct here, but we * rely on callers to never use this with "native" calls for reading * CSD or CID. Native versions of those commands use the R2 type, * not R1 plus a data block. */ cmd.flags = RESP_SPI_R1 | RESP_R1 | CMD_ADTC; - + data.blksize = 512; data.blks = 1; data.flags = DATA_DIR_READ; data.buf = ext_csd; - + /* * Some cards require longer data read timeout than indicated in CSD. * Address this by setting the read timeout to a "reasonably high" @@ -165,14 +165,14 @@ static int mmc_get_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t **new_ext_csd) */ data.timeout_ns = 300000000; data.timeout_clks = 0; - + mmcsd_send_request(card->host, &req); - + if (cmd.err) return cmd.err; if (data.err) return data.err; - + *new_ext_csd = ext_csd; return 0; } @@ -192,13 +192,13 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) card->flags |= CARD_FLAG_HIGHSPEED; card->hs_max_data_rate = 52000000; - + card_capacity = *((rt_uint32_t *)&ext_csd[EXT_CSD_SEC_CNT]); card_capacity *= card->card_blksize; card_capacity >>= 10; /* unit:KB */ card->card_capacity = card_capacity; LOG_I("emmc card capacity %d KB.", card->card_capacity); - + return 0; } @@ -211,41 +211,41 @@ static int mmc_parse_ext_csd(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) * * Modifies the EXT_CSD register for selected card. */ -static int mmc_switch(struct rt_mmcsd_card *card, rt_uint8_t set, +static int mmc_switch(struct rt_mmcsd_card *card, rt_uint8_t set, rt_uint8_t index, rt_uint8_t value) { int err; struct rt_mmcsd_host *host = card->host; struct rt_mmcsd_cmd cmd = {0}; - + cmd.cmd_code = SWITCH; cmd.arg = (MMC_SWITCH_MODE_WRITE_BYTE << 24) | (index << 16) | (value << 8) | set; cmd.flags = RESP_SPI_R1 | RESP_R1 | CMD_AC; - + err = mmcsd_send_cmd(host, &cmd, 3); if (err) return err; - + return 0; } -static int mmc_compare_ext_csds(struct rt_mmcsd_card *card, +static int mmc_compare_ext_csds(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd, rt_uint32_t bus_width) { rt_uint8_t *bw_ext_csd; int err; - + if (bus_width == MMCSD_BUS_WIDTH_1) return 0; - + err = mmc_get_ext_csd(card, &bw_ext_csd); - + if (err || bw_ext_csd == RT_NULL) { err = -RT_ERROR; goto out; } - + /* only compare read only fields */ err = !((ext_csd[EXT_CSD_PARTITION_SUPPORT] == bw_ext_csd[EXT_CSD_PARTITION_SUPPORT]) && (ext_csd[EXT_CSD_ERASED_MEM_CONT] == bw_ext_csd[EXT_CSD_ERASED_MEM_CONT]) && @@ -273,10 +273,10 @@ static int mmc_compare_ext_csds(struct rt_mmcsd_card *card, (ext_csd[EXT_CSD_PWR_CL_DDR_52_195] == bw_ext_csd[EXT_CSD_PWR_CL_DDR_52_195]) && (ext_csd[EXT_CSD_PWR_CL_DDR_52_360] == bw_ext_csd[EXT_CSD_PWR_CL_DDR_52_360]) && (ext_csd[EXT_CSD_PWR_CL_DDR_200_360] == bw_ext_csd[EXT_CSD_PWR_CL_DDR_200_360])); - + if (err) err = -RT_ERROR; - + out: rt_free(bw_ext_csd); return err; @@ -302,10 +302,10 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) struct rt_mmcsd_host *host = card->host; unsigned idx, bus_width = 0; int err = 0; - + if (GET_BITS(card->resp_cid, 122, 4) < 4) return 0; - + /* * Unlike SD, MMC cards dont have a configuration register to notify * supported bus width. So bus test command should be run to identify @@ -323,18 +323,18 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) * set by drivers. */ if ((!(host->flags & MMCSD_BUSWIDTH_8) && - ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_8) || + ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_8) || (!(host->flags & MMCSD_BUSWIDTH_4) && - (ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_4 || - ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_8))) - continue; + (ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_4 || + ext_csd_bits[idx] == EXT_CSD_BUS_WIDTH_8))) + continue; err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BUS_WIDTH, ext_csd_bits[idx]); if (err) continue; - + bus_width = bus_widths[idx]; mmcsd_set_bus_width(host, bus_width); mmcsd_delay_ms(20); //delay 10ms @@ -358,10 +358,10 @@ static int mmc_select_bus_width(struct rt_mmcsd_card *card, rt_uint8_t *ext_csd) } } } - + return err; } -rt_err_t mmc_send_op_cond(struct rt_mmcsd_host *host, +rt_err_t mmc_send_op_cond(struct rt_mmcsd_host *host, rt_uint32_t ocr, rt_uint32_t *rocr) { struct rt_mmcsd_cmd cmd; @@ -369,20 +369,20 @@ rt_err_t mmc_send_op_cond(struct rt_mmcsd_host *host, rt_err_t err = RT_EOK; rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); - + cmd.cmd_code = SEND_OP_COND; cmd.arg = controller_is_spi(host) ? 0 : ocr; cmd.flags = RESP_SPI_R1 | RESP_R3 | CMD_BCR; - + for (i = 100; i; i--) { err = mmcsd_send_cmd(host, &cmd, 3); if (err) break; - + /* if we're just probing, do a single pass */ if (ocr == 0) break; - + /* otherwise wait until reset completes */ if (controller_is_spi(host)) { if (!(cmd.resp[0] & R1_SPI_IDLE)) @@ -391,15 +391,15 @@ rt_err_t mmc_send_op_cond(struct rt_mmcsd_host *host, if (cmd.resp[0] & CARD_BUSY) break; } - + err = -RT_ETIMEOUT; - + mmcsd_delay_ms(10); //delay 10ms } - + if (rocr && !controller_is_spi(host)) *rocr = cmd.resp[0]; - + return err; } @@ -407,17 +407,17 @@ static rt_err_t mmc_set_card_addr(struct rt_mmcsd_host *host, rt_uint32_t rca) { rt_err_t err; struct rt_mmcsd_cmd cmd; - + rt_memset(&cmd, 0, sizeof(struct rt_mmcsd_cmd)); - + cmd.cmd_code = SET_RELATIVE_ADDR; cmd.arg = rca << 16; cmd.flags = RESP_R1 | CMD_AC; - + err = mmcsd_send_cmd(host, &cmd, 3); if (err) return err; - + return 0; } @@ -432,19 +432,19 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, struct rt_mmcsd_card *card = RT_NULL; mmcsd_go_idle(host); - + /* The extra bit indicates that we support high capacity */ err = mmc_send_op_cond(host, ocr | (1 << 30), &rocr); if (err) goto err; - - if (controller_is_spi(host)) + + if (controller_is_spi(host)) { err = mmcsd_spi_use_crc(host, 1); if (err) goto err1; } - + if (controller_is_spi(host)) err = mmcsd_get_cid(host, resp); else @@ -453,7 +453,7 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, goto err; card = rt_malloc(sizeof(struct rt_mmcsd_card)); - if (!card) + if (!card) { LOG_E("malloc card failed!"); err = -RT_ENOMEM; @@ -469,7 +469,7 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, /* * For native busses: get card RCA and quit open drain mode. */ - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { err = mmc_set_card_addr(host, card->rca); if (err) @@ -486,24 +486,24 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, if (err) goto err1; - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { err = mmcsd_select_card(card); if (err) goto err1; } - + /* * Fetch and process extended CSD. */ - + err = mmc_get_ext_csd(card, &ext_csd); if (err) goto err1; err = mmc_parse_ext_csd(card, ext_csd); if (err) goto err1; - + /* If doing byte addressing, check if required to do sector * addressing. Handle the case of <2GB cards needing sector * addressing. See section 8.1 JEDEC Standard JED84-A441; @@ -511,9 +511,9 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, */ if (!(card->flags & CARD_FLAG_SDHC) && (rocr & (1<<30))) card->flags |= CARD_FLAG_SDHC; - + /* set bus speed */ - if (card->flags & CARD_FLAG_HIGHSPEED) + if (card->flags & CARD_FLAG_HIGHSPEED) max_data_rate = card->hs_max_data_rate; else max_data_rate = card->max_data_rate; @@ -522,7 +522,7 @@ static rt_int32_t mmcsd_mmc_init_card(struct rt_mmcsd_host *host, /*switch bus width*/ mmc_select_bus_width(card, ext_csd); - + host->card = card; rt_free(ext_csd); diff --git a/components/drivers/sdio/mmcsd_core.c b/components/drivers/sdio/mmcsd_core.c index 99bc6ce744..e3bf97069c 100644 --- a/components/drivers/sdio/mmcsd_core.c +++ b/components/drivers/sdio/mmcsd_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -63,7 +63,7 @@ void mmcsd_send_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req) req->cmd->err = 0; req->cmd->mrq = req; if (req->data) - { + { req->cmd->data = req->data; req->data->err = 0; req->data->mrq = req; @@ -72,12 +72,12 @@ void mmcsd_send_request(struct rt_mmcsd_host *host, struct rt_mmcsd_req *req) req->data->stop = req->stop; req->stop->err = 0; req->stop->mrq = req; - } + } } host->ops->request(host, req); rt_sem_take(&host->sem_ack, RT_WAITING_FOREVER); - + } while(req->cmd->err && (req->cmd->retries > 0)); @@ -122,7 +122,7 @@ rt_int32_t mmcsd_go_idle(struct rt_mmcsd_host *host) mmcsd_delay_ms(1); - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { mmcsd_set_chip_select(host, MMCSD_CS_IGNORE); mmcsd_delay_ms(1); @@ -179,7 +179,7 @@ rt_int32_t mmcsd_get_cid(struct rt_mmcsd_host *host, rt_uint32_t *cid) struct rt_mmcsd_data data; rt_uint32_t *buf = RT_NULL; - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { if (!host->card) return -RT_ERROR; @@ -198,7 +198,7 @@ rt_int32_t mmcsd_get_cid(struct rt_mmcsd_host *host, rt_uint32_t *cid) } buf = (rt_uint32_t *)rt_malloc(16); - if (!buf) + if (!buf) { LOG_E("allocate memory failed!"); @@ -274,7 +274,7 @@ rt_int32_t mmcsd_get_csd(struct rt_mmcsd_card *card, rt_uint32_t *csd) } buf = (rt_uint32_t*)rt_malloc(16); - if (!buf) + if (!buf) { LOG_E("allocate memory failed!"); @@ -336,12 +336,12 @@ static rt_int32_t _mmcsd_select_card(struct rt_mmcsd_host *host, cmd.cmd_code = SELECT_CARD; - if (card) + if (card) { cmd.arg = card->rca << 16; cmd.flags = RESP_R1 | CMD_AC; - } - else + } + else { cmd.arg = 0; cmd.flags = RESP_NONE | CMD_AC; @@ -442,7 +442,7 @@ void mmcsd_set_data_timeout(struct rt_mmcsd_data *data, { rt_uint32_t mult; - if (card->card_type == CARD_TYPE_SDIO) + if (card->card_type == CARD_TYPE_SDIO) { data->timeout_ns = 1000000000; /* SDIO card 1s */ data->timeout_clks = 0; @@ -468,7 +468,7 @@ void mmcsd_set_data_timeout(struct rt_mmcsd_data *data, /* * SD cards also have an upper limit on the timeout. */ - if (card->card_type == CARD_TYPE_SD) + if (card->card_type == CARD_TYPE_SD) { rt_uint32_t timeout_us, limit_us; @@ -488,21 +488,21 @@ void mmcsd_set_data_timeout(struct rt_mmcsd_data *data, /* * SDHC cards always use these fixed values. */ - if (timeout_us > limit_us || card->flags & CARD_FLAG_SDHC) + if (timeout_us > limit_us || card->flags & CARD_FLAG_SDHC) { data->timeout_ns = limit_us * 1000; /* SDHC card fixed 250ms */ data->timeout_clks = 0; } } - if (controller_is_spi(card->host)) + if (controller_is_spi(card->host)) { - if (data->flags & DATA_DIR_WRITE) + if (data->flags & DATA_DIR_WRITE) { if (data->timeout_ns < 1000000000) data->timeout_ns = 1000000000; /* 1s */ - } - else + } + else { if (data->timeout_ns < 100000000) data->timeout_ns = 100000000; /* 100ms */ @@ -522,7 +522,7 @@ rt_uint32_t mmcsd_select_voltage(struct rt_mmcsd_host *host, rt_uint32_t ocr) ocr &= host->valid_ocr; bit = __rt_ffs(ocr); - if (bit) + if (bit) { bit -= 1; @@ -530,8 +530,8 @@ rt_uint32_t mmcsd_select_voltage(struct rt_mmcsd_host *host, rt_uint32_t ocr) host->io_cfg.vdd = bit; mmcsd_set_iocfg(host); - } - else + } + else { LOG_W("host doesn't support card's voltages!"); ocr = 0; @@ -549,7 +549,7 @@ static void mmcsd_power_up(struct rt_mmcsd_host *host) { host->io_cfg.chip_select = MMCSD_CS_HIGH; host->io_cfg.bus_mode = MMCSD_BUSMODE_PUSHPULL; - } + } else { host->io_cfg.chip_select = MMCSD_CS_IGNORE; @@ -580,7 +580,7 @@ static void mmcsd_power_off(struct rt_mmcsd_host *host) { host->io_cfg.clock = 0; host->io_cfg.vdd = 0; - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { host->io_cfg.bus_mode = MMCSD_BUSMODE_OPENDRAIN; host->io_cfg.chip_select = MMCSD_CS_IGNORE; @@ -619,7 +619,7 @@ void mmcsd_detect(void *param) rt_uint32_t ocr; rt_int32_t err; - while (1) + while (1) { if (rt_mb_recv(&mmcsd_detect_mb, (rt_ubase_t *)&host, RT_WAITING_FOREVER) == RT_EOK) { @@ -644,7 +644,7 @@ void mmcsd_detect(void *param) * detect SD card */ err = mmcsd_send_app_op_cond(host, 0, &ocr); - if (!err) + if (!err) { if (init_sd(host, ocr)) mmcsd_power_off(host); @@ -652,12 +652,12 @@ void mmcsd_detect(void *param) rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host); continue; } - + /* * detect mmc card */ err = mmc_send_op_cond(host, 0, &ocr); - if (!err) + if (!err) { if (init_mmc(host, ocr)) mmcsd_power_off(host); @@ -669,21 +669,21 @@ void mmcsd_detect(void *param) } else { - /* card removed */ - mmcsd_host_lock(host); - if (host->card->sdio_function_num != 0) - { - LOG_W("unsupport sdio card plug out!"); - } - else - { - rt_mmcsd_blk_remove(host->card); - rt_free(host->card); - - host->card = RT_NULL; - } - mmcsd_host_unlock(host); - rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host); + /* card removed */ + mmcsd_host_lock(host); + if (host->card->sdio_function_num != 0) + { + LOG_W("unsupport sdio card plug out!"); + } + else + { + rt_mmcsd_blk_remove(host->card); + rt_free(host->card); + + host->card = RT_NULL; + } + mmcsd_host_unlock(host); + rt_mb_send(&mmcsd_hotpluge_mb, (rt_ubase_t)host); } } } @@ -694,7 +694,7 @@ struct rt_mmcsd_host *mmcsd_alloc_host(void) struct rt_mmcsd_host *host; host = rt_malloc(sizeof(struct rt_mmcsd_host)); - if (!host) + if (!host) { LOG_E("alloc host failed"); @@ -736,16 +736,16 @@ int rt_mmcsd_core_init(void) &mmcsd_hotpluge_mb_pool[0], sizeof(mmcsd_hotpluge_mb_pool) / sizeof(mmcsd_hotpluge_mb_pool[0]), RT_IPC_FLAG_FIFO); RT_ASSERT(ret == RT_EOK); - ret = rt_thread_init(&mmcsd_detect_thread, "mmcsd_detect", mmcsd_detect, RT_NULL, + ret = rt_thread_init(&mmcsd_detect_thread, "mmcsd_detect", mmcsd_detect, RT_NULL, &mmcsd_stack[0], RT_MMCSD_STACK_SIZE, RT_MMCSD_THREAD_PREORITY, 20); - if (ret == RT_EOK) + if (ret == RT_EOK) { rt_thread_startup(&mmcsd_detect_thread); } rt_sdio_init(); - return 0; + return 0; } INIT_PREV_EXPORT(rt_mmcsd_core_init); diff --git a/components/drivers/sdio/sd.c b/components/drivers/sdio/sd.c index f7e4e46720..d739ee4eaf 100644 --- a/components/drivers/sdio/sd.c +++ b/components/drivers/sdio/sd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -45,9 +45,9 @@ static const rt_uint8_t tacc_value[] = rt_inline rt_uint32_t GET_BITS(rt_uint32_t *resp, rt_uint32_t start, rt_uint32_t size) -{ +{ const rt_int32_t __size = size; - const rt_uint32_t __mask = (__size < 32 ? 1 << __size : 0) - 1; + const rt_uint32_t __mask = (__size < 32 ? 1 << __size : 0) - 1; const rt_int32_t __off = 3 - ((start) / 32); const rt_int32_t __shft = (start) & 31; rt_uint32_t __res; @@ -97,7 +97,7 @@ static rt_int32_t mmcsd_parse_csd(struct rt_mmcsd_card *card) case 1: card->flags |= CARD_FLAG_SDHC; - /*This field is fixed to 0Eh, which indicates 1 ms. + /*This field is fixed to 0Eh, which indicates 1 ms. The host should not use TAAC, NSAC, and R2W_FACTOR to calculate timeout and should uses fixed timeout values for read and write operations*/ @@ -157,13 +157,13 @@ static rt_int32_t mmcsd_switch(struct rt_mmcsd_card *card) rt_uint8_t *buf; buf = (rt_uint8_t*)rt_malloc(64); - if (!buf) + if (!buf) { LOG_E("alloc memory failed!"); return -RT_ENOMEM; } - + if (card->card_type != CARD_TYPE_SD) goto err; if (card->scr.sd_version < SCR_SPEC_VER_1) @@ -191,7 +191,7 @@ static rt_int32_t mmcsd_switch(struct rt_mmcsd_card *card) mmcsd_send_request(host, &req); - if (cmd.err || data.err) + if (cmd.err || data.err) { goto err1; } @@ -221,12 +221,12 @@ static rt_int32_t mmcsd_switch(struct rt_mmcsd_card *card) mmcsd_send_request(host, &req); - if (cmd.err || data.err) + if (cmd.err || data.err) { goto err1; } - if ((buf[16] & 0xF) != 1) + if ((buf[16] & 0xF) != 1) { LOG_I("switching card to high speed failed!"); goto err; @@ -255,12 +255,12 @@ static rt_err_t mmcsd_app_cmd(struct rt_mmcsd_host *host, cmd.cmd_code = APP_CMD; - if (card) + if (card) { cmd.arg = card->rca << 16; cmd.flags = RESP_R1 | CMD_AC; - } - else + } + else { cmd.arg = 0; cmd.flags = RESP_R1 | CMD_BCR; @@ -285,7 +285,7 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, { struct rt_mmcsd_req req; - rt_uint32_t i; + rt_uint32_t i; rt_err_t err; err = -RT_ERROR; @@ -294,15 +294,15 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, * We have to resend MMC_APP_CMD for each attempt so * we cannot use the retries field in mmc_command. */ - for (i = 0;i <= retry;i++) + for (i = 0;i <= retry;i++) { rt_memset(&req, 0, sizeof(struct rt_mmcsd_req)); err = mmcsd_app_cmd(host, card); - if (err) + if (err) { /* no point in retrying; no APP commands allowed */ - if (controller_is_spi(host)) + if (controller_is_spi(host)) { if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) break; @@ -324,7 +324,7 @@ rt_err_t mmcsd_send_app_cmd(struct rt_mmcsd_host *host, break; /* no point in retrying illegal APP commands */ - if (controller_is_spi(host)) + if (controller_is_spi(host)) { if (cmd->resp[0] & R1_SPI_ILLEGAL_COMMAND) break; @@ -344,7 +344,7 @@ rt_err_t mmcsd_app_set_bus_width(struct rt_mmcsd_card *card, rt_int32_t width) cmd.cmd_code = SD_APP_SET_BUS_WIDTH; cmd.flags = RESP_R1 | CMD_AC; - switch (width) + switch (width) { case MMCSD_BUS_WIDTH_1: cmd.arg = MMCSD_BUS_WIDTH_1; @@ -380,7 +380,7 @@ rt_err_t mmcsd_send_app_op_cond(struct rt_mmcsd_host *host, cmd.arg = ocr; cmd.flags = RESP_SPI_R1 | RESP_R3 | CMD_BCR; - for (i = 100; i; i--) + for (i = 100; i; i--) { err = mmcsd_send_app_cmd(host, RT_NULL, &cmd, 3); if (err) @@ -391,12 +391,12 @@ rt_err_t mmcsd_send_app_op_cond(struct rt_mmcsd_host *host, break; /* otherwise wait until reset completes */ - if (controller_is_spi(host)) + if (controller_is_spi(host)) { if (!(cmd.resp[0] & R1_SPI_IDLE)) break; - } - else + } + else { if (cmd.resp[0] & CARD_BUSY) break; @@ -544,7 +544,7 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, goto err; card = rt_malloc(sizeof(struct rt_mmcsd_card)); - if (!card) + if (!card) { LOG_E("malloc card failed!"); err = -RT_ENOMEM; @@ -559,7 +559,7 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, /* * For native busses: get card RCA and quit open drain mode. */ - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { err = mmcsd_get_card_addr(host, &card->rca); if (err) @@ -576,7 +576,7 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, if (err) goto err1; - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { err = mmcsd_select_card(card); if (err) @@ -589,7 +589,7 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, mmcsd_parse_scr(card); - if (controller_is_spi(host)) + if (controller_is_spi(host)) { err = mmcsd_spi_use_crc(host, 1); if (err) @@ -606,12 +606,12 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, /* set bus speed */ max_data_rate = (unsigned int)-1; - if (card->flags & CARD_FLAG_HIGHSPEED) + if (card->flags & CARD_FLAG_HIGHSPEED) { if (max_data_rate > card->hs_max_data_rate) max_data_rate = card->hs_max_data_rate; - } - else if (max_data_rate > card->max_data_rate) + } + else if (max_data_rate > card->max_data_rate) { max_data_rate = card->max_data_rate; } @@ -620,7 +620,7 @@ static rt_int32_t mmcsd_sd_init_card(struct rt_mmcsd_host *host, /*switch bus width*/ if ((host->flags & MMCSD_BUSWIDTH_4) && - (card->scr.sd_bus_widths & SD_SCR_BUS_WIDTH_4)) + (card->scr.sd_bus_widths & SD_SCR_BUS_WIDTH_4)) { err = mmcsd_app_set_bus_width(card, MMCSD_BUS_WIDTH_4); if (err) diff --git a/components/drivers/sdio/sdio.c b/components/drivers/sdio/sdio.c index f0d5863a06..1263f205b5 100644 --- a/components/drivers/sdio/sdio.c +++ b/components/drivers/sdio/sdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -73,7 +73,7 @@ rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host, cmd.arg = ocr; cmd.flags = RESP_SPI_R4 | RESP_R4 | CMD_BCR; - for (i = 100; i; i--) + for (i = 100; i; i--) { err = mmcsd_send_cmd(host, &cmd, 0); if (err) @@ -84,7 +84,7 @@ rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host, break; /* otherwise wait until reset completes */ - if (controller_is_spi(host)) + if (controller_is_spi(host)) { /* * Both R1_SPI_IDLE and MMC_CARD_BUSY indicate @@ -94,8 +94,8 @@ rt_int32_t sdio_io_send_op_cond(struct rt_mmcsd_host *host, */ if (cmd.resp[1] & CARD_BUSY) break; - } - else + } + else { if (cmd.resp[0] & CARD_BUSY) break; @@ -143,7 +143,7 @@ rt_int32_t sdio_io_rw_direct(struct rt_mmcsd_card *card, if (err) return err; - if (!controller_is_spi(card->host)) + if (!controller_is_spi(card->host)) { if (cmd.resp[0] & R5_ERROR) return -RT_EIO; @@ -153,7 +153,7 @@ rt_int32_t sdio_io_rw_direct(struct rt_mmcsd_card *card, return -RT_ERROR; } - if (!rw || raw) + if (!rw || raw) { if (controller_is_spi(card->host)) *pdata = (cmd.resp[0] >> 8) & 0xFF; @@ -218,7 +218,7 @@ rt_int32_t sdio_io_rw_extended(struct rt_mmcsd_card *card, if (data.err) return data.err; - if (!controller_is_spi(card->host)) + if (!controller_is_spi(card->host)) { if (cmd.resp[0] & R5_ERROR) return -RT_EIO; @@ -270,7 +270,7 @@ rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func, blks = max_blks; len = blks * func->cur_blk_size; - ret = sdio_io_rw_extended(func->card, rw, func->num, + ret = sdio_io_rw_extended(func->card, rw, func->num, addr, op_code, buf, blks, func->cur_blk_size); if (ret) return ret; @@ -286,7 +286,7 @@ rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func, { len = MIN(left_size, sdio_max_block_size(func)); - ret = sdio_io_rw_extended(func->card, rw, func->num, + ret = sdio_io_rw_extended(func->card, rw, func->num, addr, op_code, buf, 1, len); if (ret) return ret; @@ -300,7 +300,7 @@ rt_int32_t sdio_io_rw_extended_block(struct rt_sdio_function *func, return 0; } -rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, +rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, rt_uint32_t reg, rt_int32_t *err) { @@ -317,7 +317,7 @@ rt_uint8_t sdio_io_readb(struct rt_sdio_function *func, return data; } -rt_int32_t sdio_io_writeb(struct rt_sdio_function *func, +rt_int32_t sdio_io_writeb(struct rt_sdio_function *func, rt_uint32_t reg, rt_uint8_t data) { @@ -335,7 +335,7 @@ rt_uint16_t sdio_io_readw(struct rt_sdio_function *func, *err = 0; ret = sdio_io_rw_extended_block(func, 0, addr, 1, (rt_uint8_t *)&dmabuf, 2); - if (ret) + if (ret) { if (err) *err = ret; @@ -364,7 +364,7 @@ rt_uint32_t sdio_io_readl(struct rt_sdio_function *func, *err = 0; ret = sdio_io_rw_extended_block(func, 0, addr, 1, (rt_uint8_t *)&dmabuf, 4); - if (ret) + if (ret) { if (err) *err = ret; @@ -382,7 +382,7 @@ rt_int32_t sdio_io_writel(struct rt_sdio_function *func, return sdio_io_rw_extended_block(func, 1, addr, 1, (rt_uint8_t *)&dmabuf, 4); } -rt_int32_t sdio_io_read_multi_fifo_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_read_multi_fifo_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) @@ -390,7 +390,7 @@ rt_int32_t sdio_io_read_multi_fifo_b(struct rt_sdio_function *func, return sdio_io_rw_extended_block(func, 0, addr, 0, buf, len); } -rt_int32_t sdio_io_write_multi_fifo_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_write_multi_fifo_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) @@ -398,7 +398,7 @@ rt_int32_t sdio_io_write_multi_fifo_b(struct rt_sdio_function *func, return sdio_io_rw_extended_block(func, 1, addr, 0, buf, len); } -rt_int32_t sdio_io_read_multi_incr_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_read_multi_incr_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) @@ -406,7 +406,7 @@ rt_int32_t sdio_io_read_multi_incr_b(struct rt_sdio_function *func, return sdio_io_rw_extended_block(func, 0, addr, 1, buf, len); } -rt_int32_t sdio_io_write_multi_incr_b(struct rt_sdio_function *func, +rt_int32_t sdio_io_write_multi_incr_b(struct rt_sdio_function *func, rt_uint32_t addr, rt_uint8_t *buf, rt_uint32_t len) @@ -428,7 +428,7 @@ static rt_int32_t sdio_read_cccr(struct rt_mmcsd_card *card) cccr_version = data & 0x0f; - if (cccr_version > SDIO_CCCR_REV_3_00) + if (cccr_version > SDIO_CCCR_REV_3_00) { LOG_E("unrecognised CCCR structure version %d", cccr_version); @@ -450,7 +450,7 @@ static rt_int32_t sdio_read_cccr(struct rt_mmcsd_card *card) if (data & SDIO_CCCR_CAP_4BLS) card->cccr.bus_width = 1; - if (cccr_version >= SDIO_CCCR_REV_1_10) + if (cccr_version >= SDIO_CCCR_REV_1_10) { data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_POWER_CTRL, &ret); if (ret) @@ -460,7 +460,7 @@ static rt_int32_t sdio_read_cccr(struct rt_mmcsd_card *card) card->cccr.power_ctrl = 1; } - if (cccr_version >= SDIO_CCCR_REV_1_20) + if (cccr_version >= SDIO_CCCR_REV_1_20) { data = sdio_io_readb(card->sdio_function[0], SDIO_REG_CCCR_SPEED, &ret); if (ret) @@ -531,7 +531,7 @@ static rt_int32_t sdio_read_cis(struct rt_sdio_function *func) for (i = 0; i < 3; i++) { - data = sdio_io_readb(func0, + data = sdio_io_readb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_CIS + i, &ret); if (ret) return ret; @@ -560,13 +560,13 @@ static rt_int32_t sdio_read_cis(struct rt_sdio_function *func) return -RT_ENOMEM; curr->data = (rt_uint8_t *)curr + sizeof(struct rt_sdio_function_tuple); - for (i = 0; i < tpl_link; i++) + for (i = 0; i < tpl_link; i++) { curr->data[i] = sdio_io_readb(func0, cisptr + i, &ret); if (ret) break; } - if (ret) + if (ret) { rt_free(curr); break; @@ -618,7 +618,7 @@ static rt_int32_t sdio_read_cis(struct rt_sdio_function *func) LOG_D("CISTPL_VERS_1 too short"); } break; - default: + default: /* this tuple is unknown to the core */ curr->next = RT_NULL; curr->code = tpl_code; @@ -651,7 +651,7 @@ void sdio_free_cis(struct rt_sdio_function *func) tuple = func->tuples; - while (tuple && ((tuple != card->sdio_function[0]->tuples) || (!func->num))) + while (tuple && ((tuple != card->sdio_function[0]->tuples) || (!func->num))) { tmp = tuple; tuple = tuple->next; @@ -667,16 +667,16 @@ static rt_int32_t sdio_read_fbr(struct rt_sdio_function *func) rt_uint8_t data; struct rt_sdio_function *func0 = func->card->sdio_function[0]; - data = sdio_io_readb(func0, + data = sdio_io_readb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_STD_FUNC_IF, &ret); if (ret) goto err; data &= 0x0f; - if (data == 0x0f) + if (data == 0x0f) { - data = sdio_io_readb(func0, + data = sdio_io_readb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_STD_IF_EXT, &ret); if (ret) goto err; @@ -835,7 +835,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) if (err) goto err; - if (controller_is_spi(host)) + if (controller_is_spi(host)) { err = mmcsd_spi_use_crc(host, host->spi_use_crc); if (err) @@ -845,7 +845,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) function_num = (cmd5_resp & 0x70000000) >> 28; card = rt_malloc(sizeof(struct rt_mmcsd_card)); - if (!card) + if (!card) { LOG_E("malloc card failed"); err = -RT_ENOMEM; @@ -869,7 +869,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) card->sdio_function[0]->card = card; card->sdio_function[0]->num = 0; - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { err = mmcsd_get_card_addr(host, &card->rca); if (err) @@ -878,7 +878,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) mmcsd_set_bus_mode(host, MMCSD_BUSMODE_PUSHPULL); } - if (!controller_is_spi(host)) + if (!controller_is_spi(host)) { err = mmcsd_select_card(card); if (err) @@ -897,7 +897,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) if (err) goto err2; - if (card->flags & CARD_FLAG_HIGHSPEED) + if (card->flags & CARD_FLAG_HIGHSPEED) { mmcsd_set_clock(host, card->host->freq_max > 50000000 ? 50000000 : card->host->freq_max); } @@ -910,7 +910,7 @@ static rt_int32_t sdio_init_card(struct rt_mmcsd_host *host, rt_uint32_t ocr) if (err) goto err2; - for (i = 1; i < function_num + 1; i++) + for (i = 1; i < function_num + 1; i++) { err = sdio_initialize_function(card, i); if (err) @@ -954,7 +954,7 @@ err1: } err: LOG_E("error %d while initialising SDIO card", err); - + return err; } @@ -965,13 +965,13 @@ rt_int32_t init_sdio(struct rt_mmcsd_host *host, rt_uint32_t ocr) RT_ASSERT(host != RT_NULL); - if (ocr & 0x7F) + if (ocr & 0x7F) { LOG_W("Card ocr below the defined voltage rang."); ocr &= ~0x7F; } - if (ocr & VDD_165_195) + if (ocr & VDD_165_195) { LOG_W("Can't support the low voltage SDIO card."); ocr &= ~VDD_165_195; @@ -979,7 +979,7 @@ rt_int32_t init_sdio(struct rt_mmcsd_host *host, rt_uint32_t ocr) current_ocr = mmcsd_select_voltage(host, ocr); - if (!current_ocr) + if (!current_ocr) { err = -RT_ERROR; goto err; @@ -1011,35 +1011,35 @@ static void sdio_irq_thread(void *param) card = host->card; RT_ASSERT(card != RT_NULL); - while (1) + while (1) { if (rt_sem_take(host->sdio_irq_sem, RT_WAITING_FOREVER) == RT_EOK) { mmcsd_host_lock(host); - pending = sdio_io_readb(host->card->sdio_function[0], + pending = sdio_io_readb(host->card->sdio_function[0], SDIO_REG_CCCR_INT_PEND, &ret); - if (ret) + if (ret) { mmcsd_dbg("error %d reading SDIO_REG_CCCR_INT_PEND\n", ret); goto out; } - for (i = 1; i <= 7; i++) + for (i = 1; i <= 7; i++) { - if (pending & (1 << i)) + if (pending & (1 << i)) { struct rt_sdio_function *func = card->sdio_function[i]; - if (!func) + if (!func) { mmcsd_dbg("pending IRQ for " "non-existant function %d\n", func->num); goto out; - } - else if (func->irq_handler) + } + else if (func->irq_handler) { func->irq_handler(func); - } - else + } + else { mmcsd_dbg("pending IRQ with no register handler\n"); goto out; @@ -1067,9 +1067,9 @@ static rt_int32_t sdio_irq_thread_create(struct rt_mmcsd_card *card) host->sdio_irq_sem = rt_sem_create("sdio_irq", 0, RT_IPC_FLAG_FIFO); RT_ASSERT(host->sdio_irq_sem != RT_NULL); - host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, + host->sdio_irq_thread = rt_thread_create("sdio_irq", sdio_irq_thread, host, RT_SDIO_STACK_SIZE, RT_SDIO_THREAD_PRIORITY, 20); - if (host->sdio_irq_thread != RT_NULL) + if (host->sdio_irq_thread != RT_NULL) { rt_thread_startup(host->sdio_irq_thread); } @@ -1085,7 +1085,7 @@ static rt_int32_t sdio_irq_thread_delete(struct rt_mmcsd_card *card) RT_ASSERT(host->sdio_irq_num > 0); host->sdio_irq_num--; - if (!host->sdio_irq_num) + if (!host->sdio_irq_num) { if (host->flags & MMCSD_SUP_SDIO_IRQ) host->ops->enable_sdio_irq(host, 0); @@ -1112,7 +1112,7 @@ rt_int32_t sdio_attach_irq(struct rt_sdio_function *func, mmcsd_dbg("SDIO: enabling IRQ for function %d\n", func->num); - if (func->irq_handler) + if (func->irq_handler) { mmcsd_dbg("SDIO: IRQ for already in use.\n"); @@ -1153,7 +1153,7 @@ rt_int32_t sdio_detach_irq(struct rt_sdio_function *func) mmcsd_dbg("SDIO: disabling IRQ for function %d\n", func->num); - if (func->irq_handler) + if (func->irq_handler) { func->irq_handler = RT_NULL; sdio_irq_thread_delete(func->card); @@ -1210,7 +1210,7 @@ rt_int32_t sdio_enable_func(struct rt_sdio_function *func) timeout = rt_tick_get() + func->enable_timeout_val * RT_TICK_PER_SECOND / 1000; - while (1) + while (1) { reg = sdio_io_readb(func0, SDIO_REG_CCCR_IO_RDY, &ret); if (ret) @@ -1282,17 +1282,17 @@ rt_int32_t sdio_set_block_size(struct rt_sdio_function *func, if (blksize > func->card->host->max_blk_size) return -RT_ERROR; - if (blksize == 0) + if (blksize == 0) { blksize = MIN(func->max_blk_size, func->card->host->max_blk_size); blksize = MIN(blksize, 512u); } - ret = sdio_io_writeb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_BLKSIZE, + ret = sdio_io_writeb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_BLKSIZE, blksize & 0xff); if (ret) return ret; - ret = sdio_io_writeb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_BLKSIZE + 1, + ret = sdio_io_writeb(func0, SDIO_REG_FBR_BASE(func->num) + SDIO_REG_FBR_BLKSIZE + 1, (blksize >> 8) & 0xff); if (ret) return ret; @@ -1305,14 +1305,14 @@ rt_inline rt_int32_t sdio_match_card(struct rt_mmcsd_card *card, const struct rt_sdio_device_id *id) { rt_uint8_t num = 1; - - if ((id->manufacturer != SDIO_ANY_MAN_ID) && + + if ((id->manufacturer != SDIO_ANY_MAN_ID) && (id->manufacturer != card->cis.manufacturer)) return 0; - + while (num <= card->sdio_function_num) { - if ((id->product != SDIO_ANY_PROD_ID) && + if ((id->product != SDIO_ANY_PROD_ID) && (id->product == card->sdio_function[num]->product)) return 1; num++; diff --git a/components/drivers/sensors/sensor.c b/components/drivers/sensors/sensor.c index 660b86f85b..ccc1fca34e 100644 --- a/components/drivers/sensors/sensor.c +++ b/components/drivers/sensors/sensor.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/sensors/sensor.h b/components/drivers/sensors/sensor.h index b180e36a73..f54d4e8799 100755 --- a/components/drivers/sensors/sensor.h +++ b/components/drivers/sensors/sensor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -169,7 +169,7 @@ struct rt_sensor_device const struct rt_sensor_ops *ops; /* The sensor ops */ struct rt_sensor_module *module; /* The sensor module */ - + rt_err_t (*irq_handle)(rt_sensor_t sensor); /* Called when an interrupt is generated, registered by the driver */ }; diff --git a/components/drivers/sensors/sensor_cmd.c b/components/drivers/sensors/sensor_cmd.c index cbf7d233c6..5c2d22640c 100755 --- a/components/drivers/sensors/sensor_cmd.c +++ b/components/drivers/sensors/sensor_cmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -92,7 +92,7 @@ static void sensor_fifo_rx_entry(void *parameter) struct rt_sensor_data *data = RT_NULL; struct rt_sensor_info info; rt_size_t res, i; - + rt_device_control(dev, RT_SENSOR_CTRL_GET_INFO, &info); data = (struct rt_sensor_data *)rt_malloc(sizeof(struct rt_sensor_data) * info.fifo_max); @@ -126,7 +126,7 @@ static void sensor_fifo(int argc, char **argv) return; } sensor = (rt_sensor_t)dev; - + if (rt_device_open(dev, RT_DEVICE_FLAG_FIFO_RX) != RT_EOK) { LOG_E("open device failed!"); diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c index 5743155e37..d555a0dd7e 100644 --- a/components/drivers/serial/serial.c +++ b/components/drivers/serial/serial.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -460,7 +460,7 @@ static void rt_dma_recv_update_put_index(struct rt_serial_device *serial, rt_siz rx_fifo->is_full = RT_TRUE; } } - + if(rx_fifo->is_full == RT_TRUE) { _serial_check_buffer_size(); @@ -615,7 +615,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag) /* initialize the Rx/Tx structure according to open flag */ if (serial->serial_rx == RT_NULL) - { + { if (oflag & RT_DEVICE_FLAG_INT_RX) { struct rt_serial_rx_fifo* rx_fifo; @@ -634,7 +634,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag) /* configure low level device */ serial->ops->control(serial, RT_DEVICE_CTRL_SET_INT, (void *)RT_DEVICE_FLAG_INT_RX); } -#ifdef RT_SERIAL_USING_DMA +#ifdef RT_SERIAL_USING_DMA else if (oflag & RT_DEVICE_FLAG_DMA_RX) { if (serial->config.bufsz == 0) { @@ -675,7 +675,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag) #ifdef RT_SERIAL_USING_DMA else if (oflag & RT_DEVICE_FLAG_DMA_RX) dev->open_flag |= RT_DEVICE_FLAG_DMA_RX; -#endif /* RT_SERIAL_USING_DMA */ +#endif /* RT_SERIAL_USING_DMA */ } if (serial->serial_tx == RT_NULL) @@ -723,7 +723,7 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag) #ifdef RT_SERIAL_USING_DMA else if (oflag & RT_DEVICE_FLAG_DMA_TX) dev->open_flag |= RT_DEVICE_FLAG_DMA_TX; -#endif /* RT_SERIAL_USING_DMA */ +#endif /* RT_SERIAL_USING_DMA */ } /* set stream flag */ @@ -784,7 +784,7 @@ static rt_err_t rt_serial_close(struct rt_device *dev) serial->ops->control(serial, RT_DEVICE_CTRL_CLR_INT, (void *) RT_DEVICE_FLAG_DMA_RX); } #endif /* RT_SERIAL_USING_DMA */ - + if (dev->open_flag & RT_DEVICE_FLAG_INT_TX) { struct rt_serial_tx_fifo* tx_fifo; @@ -845,7 +845,7 @@ static rt_size_t rt_serial_read(struct rt_device *dev, { return _serial_dma_rx(serial, (rt_uint8_t *)buffer, size); } -#endif /* RT_SERIAL_USING_DMA */ +#endif /* RT_SERIAL_USING_DMA */ return _serial_poll_rx(serial, (rt_uint8_t *)buffer, size); } @@ -866,7 +866,7 @@ static rt_size_t rt_serial_write(struct rt_device *dev, { return _serial_int_tx(serial, (const rt_uint8_t *)buffer, size); } -#ifdef RT_SERIAL_USING_DMA +#ifdef RT_SERIAL_USING_DMA else if (dev->open_flag & RT_DEVICE_FLAG_DMA_TX) { return _serial_dma_tx(serial, (const rt_uint8_t *)buffer, size); @@ -1142,7 +1142,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev, } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops serial_ops = +const static struct rt_device_ops serial_ops = { rt_serial_init, rt_serial_open, diff --git a/components/drivers/spi/enc28j60.c b/components/drivers/spi/enc28j60.c index a8bfe3a159..f99719245b 100644 --- a/components/drivers/spi/enc28j60.c +++ b/components/drivers/spi/enc28j60.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -747,7 +747,7 @@ static struct pbuf *enc28j60_rx(rt_device_t dev) } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops enc28j60_ops = +const static struct rt_device_ops enc28j60_ops = { enc28j60_init, enc28j60_open, diff --git a/components/drivers/spi/enc28j60.h b/components/drivers/spi/enc28j60.h index adff774748..471b71ec2d 100644 --- a/components/drivers/spi/enc28j60.h +++ b/components/drivers/spi/enc28j60.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/spi/qspi_core.c b/components/drivers/spi/qspi_core.c index c9ff6a9637..ca2cba0aba 100644 --- a/components/drivers/spi/qspi_core.c +++ b/components/drivers/spi/qspi_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -14,7 +14,7 @@ rt_err_t rt_qspi_configure(struct rt_qspi_device *device, struct rt_qspi_configu { RT_ASSERT(device != RT_NULL); RT_ASSERT(cfg != RT_NULL); - + struct rt_qspi_device *qspi_device = (struct rt_qspi_device *)device; rt_err_t result = RT_EOK; @@ -35,14 +35,14 @@ rt_err_t rt_qspi_configure(struct rt_qspi_device *device, struct rt_qspi_configu rt_err_t rt_qspi_bus_register(struct rt_spi_bus *bus, const char *name, const struct rt_spi_ops *ops) { rt_err_t result = RT_EOK; - + result = rt_spi_bus_register(bus, name, ops); if(result == RT_EOK) { /* set SPI bus to qspi modes */ bus->mode = RT_SPI_BUS_MODE_QSPI; } - + return result; } @@ -243,7 +243,7 @@ rt_err_t rt_qspi_send(struct rt_qspi_device *device, const void *send_buf, rt_si message.qspi_data_lines = 0; } - + /* set send buf and send size */ message.parent.send_buf = ptr + count; message.parent.recv_buf = RT_NULL; diff --git a/components/drivers/spi/sfud/inc/sfud_def.h b/components/drivers/spi/sfud/inc/sfud_def.h index fe7876618b..c06f9b1295 100644 --- a/components/drivers/spi/sfud/inc/sfud_def.h +++ b/components/drivers/spi/sfud/inc/sfud_def.h @@ -118,11 +118,11 @@ if (!(EXPR)) \ #define SFUD_CMD_READ_DATA 0x03 #endif -#ifndef SFUD_CMD_DUAL_OUTPUT_READ_DATA +#ifndef SFUD_CMD_DUAL_OUTPUT_READ_DATA #define SFUD_CMD_DUAL_OUTPUT_READ_DATA 0x3B #endif -#ifndef SFUD_CMD_DUAL_IO_READ_DATA +#ifndef SFUD_CMD_DUAL_IO_READ_DATA #define SFUD_CMD_DUAL_IO_READ_DATA 0xBB #endif diff --git a/components/drivers/spi/sfud/src/sfud_sfdp.c b/components/drivers/spi/sfud/src/sfud_sfdp.c index 0c81e073e6..5d95fa2b79 100644 --- a/components/drivers/spi/sfud/src/sfud_sfdp.c +++ b/components/drivers/spi/sfud/src/sfud_sfdp.c @@ -223,7 +223,7 @@ static bool read_basic_table(sfud_flash *flash, sfdp_para_header *basic_header) return false; } /* get write granularity */ - //TODO ĿǰΪ 1.0 ËùÌṩµÄ·½Ê½£¬ºóÆÚÖ§³Ö V1.5 ¼°ÒÔÉϵķ½Ê½¶ÁÈ¡ page size + //TODO ç›®å‰ä¸º 1.0 所æ供的方å¼ï¼ŒåŽæœŸæ”¯æŒ V1.5 åŠä»¥ä¸Šçš„æ–¹å¼è¯»å– page size switch ((table[0] & (0x01 << 2)) >> 2) { case 0: sfdp->write_gran = 1; diff --git a/components/drivers/spi/spi_core.c b/components/drivers/spi/spi_core.c index 64b0d2e496..7b6b7a0763 100644 --- a/components/drivers/spi/spi_core.c +++ b/components/drivers/spi/spi_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/spi/spi_dev.c b/components/drivers/spi/spi_dev.c index e334e7aeb5..264f5d1856 100644 --- a/components/drivers/spi/spi_dev.c +++ b/components/drivers/spi/spi_dev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -48,7 +48,7 @@ static rt_err_t _spi_bus_device_control(rt_device_t dev, { case 0: /* set device */ break; - case 1: + case 1: break; } @@ -56,7 +56,7 @@ static rt_err_t _spi_bus_device_control(rt_device_t dev, } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops spi_bus_ops = +const static struct rt_device_ops spi_bus_ops = { RT_NULL, RT_NULL, @@ -129,7 +129,7 @@ static rt_err_t _spidev_device_control(rt_device_t dev, { case 0: /* set device */ break; - case 1: + case 1: break; } @@ -137,7 +137,7 @@ static rt_err_t _spidev_device_control(rt_device_t dev, } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops spi_device_ops = +const static struct rt_device_ops spi_device_ops = { RT_NULL, RT_NULL, diff --git a/components/drivers/spi/spi_flash.h b/components/drivers/spi/spi_flash.h index 82b1ab2ecd..9083a40a1c 100644 --- a/components/drivers/spi/spi_flash.h +++ b/components/drivers/spi/spi_flash.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -28,10 +28,10 @@ typedef struct spi_flash_device *rt_spi_flash_device_t; #ifdef RT_USING_MTD_NOR struct spi_flash_mtd { - struct rt_mtd_nor_device mtd_device; - struct rt_spi_device * rt_spi_device; - struct rt_mutex lock; - void * user_data; + struct rt_mtd_nor_device mtd_device; + struct rt_spi_device * rt_spi_device; + struct rt_mutex lock; + void * user_data; }; #endif diff --git a/components/drivers/spi/spi_flash_sfud.c b/components/drivers/spi/spi_flash_sfud.c index 2333c9ccb3..ba673edf62 100644 --- a/components/drivers/spi/spi_flash_sfud.c +++ b/components/drivers/spi/spi_flash_sfud.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/spi/spi_flash_sfud.h b/components/drivers/spi/spi_flash_sfud.h index 932b7f879c..0d5a751d0c 100644 --- a/components/drivers/spi/spi_flash_sfud.h +++ b/components/drivers/spi/spi_flash_sfud.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/spi/spi_msd.c b/components/drivers/spi/spi_msd.c index 191933e421..875ae3c486 100644 --- a/components/drivers/spi/spi_msd.c +++ b/components/drivers/spi/spi_msd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -435,7 +435,7 @@ static rt_err_t _write_block(struct rt_spi_device *device, const void *buffer, u } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops msd_ops = +const static struct rt_device_ops msd_ops = { rt_msd_init, rt_msd_open, @@ -445,7 +445,7 @@ const static struct rt_device_ops msd_ops = rt_msd_control }; -const static struct rt_device_ops msd_sdhc_ops = +const static struct rt_device_ops msd_sdhc_ops = { rt_msd_init, rt_msd_open, diff --git a/components/drivers/spi/spi_msd.h b/components/drivers/spi/spi_msd.h index 6370170923..e9febca781 100644 --- a/components/drivers/spi/spi_msd.h +++ b/components/drivers/spi/spi_msd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -93,12 +93,12 @@ */ typedef enum { - MSD_CARD_TYPE_UNKNOWN = 0, /**< unknown */ - MSD_CARD_TYPE_MMC, /**< MultiMedia Card */ - MSD_CARD_TYPE_SD_V1_X, /**< Ver 1.X Standard Capacity SD Memory Card */ - MSD_CARD_TYPE_SD_V2_X, /**< Ver 2.00 or later Standard Capacity SD Memory Card */ - MSD_CARD_TYPE_SD_SDHC, /**< High Capacity SD Memory Card */ - MSD_CARD_TYPE_SD_SDXC, /**< later Extended Capacity SD Memory Card */ + MSD_CARD_TYPE_UNKNOWN = 0, /**< unknown */ + MSD_CARD_TYPE_MMC, /**< MultiMedia Card */ + MSD_CARD_TYPE_SD_V1_X, /**< Ver 1.X Standard Capacity SD Memory Card */ + MSD_CARD_TYPE_SD_V2_X, /**< Ver 2.00 or later Standard Capacity SD Memory Card */ + MSD_CARD_TYPE_SD_SDHC, /**< High Capacity SD Memory Card */ + MSD_CARD_TYPE_SD_SDXC, /**< later Extended Capacity SD Memory Card */ }msd_card_type; typedef enum diff --git a/components/drivers/spi/spi_wifi_rw009.c b/components/drivers/spi/spi_wifi_rw009.c index 4ddd18ca12..84da212077 100644 --- a/components/drivers/spi/spi_wifi_rw009.c +++ b/components/drivers/spi/spi_wifi_rw009.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/drivers/spi/spi_wifi_rw009.h b/components/drivers/spi/spi_wifi_rw009.h index 049b0a8486..a0d8ec437d 100644 --- a/components/drivers/spi/spi_wifi_rw009.h +++ b/components/drivers/spi/spi_wifi_rw009.h @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/drivers/src/completion.c b/components/drivers/src/completion.c index 9e461e49ce..b91ae3d6dc 100644 --- a/components/drivers/src/completion.c +++ b/components/drivers/src/completion.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/src/dataqueue.c b/components/drivers/src/dataqueue.c index 1651417bb9..f32efa1849 100644 --- a/components/drivers/src/dataqueue.c +++ b/components/drivers/src/dataqueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -62,7 +62,7 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue, rt_ubase_t level; rt_thread_t thread; rt_err_t result; - + RT_ASSERT(queue != RT_NULL); RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); @@ -85,7 +85,7 @@ rt_err_t rt_data_queue_push(struct rt_data_queue *queue, /* reset thread error number */ thread->error = RT_EOK; - + /* suspend thread on the push list */ rt_thread_suspend(thread); rt_list_insert_before(&(queue->suspended_push_list), &(thread->tlist)); @@ -155,13 +155,13 @@ RTM_EXPORT(rt_data_queue_push); rt_err_t rt_data_queue_pop(struct rt_data_queue *queue, const void** data_ptr, - rt_size_t *size, + rt_size_t *size, rt_int32_t timeout) { rt_ubase_t level; rt_thread_t thread; rt_err_t result; - + RT_ASSERT(queue != RT_NULL); RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); RT_ASSERT(data_ptr != RT_NULL); @@ -185,7 +185,7 @@ rt_err_t rt_data_queue_pop(struct rt_data_queue *queue, /* reset thread error number */ thread->error = RT_EOK; - + /* suspend thread on the pop list */ rt_thread_suspend(thread); rt_list_insert_before(&(queue->suspended_pop_list), &(thread->tlist)); @@ -269,11 +269,11 @@ rt_err_t rt_data_queue_peek(struct rt_data_queue *queue, rt_size_t *size) { rt_ubase_t level; - + RT_ASSERT(queue != RT_NULL); RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); - if (queue->is_empty) + if (queue->is_empty) { return -RT_EEMPTY; } @@ -293,7 +293,7 @@ void rt_data_queue_reset(struct rt_data_queue *queue) { rt_ubase_t level; struct rt_thread *thread; - + RT_ASSERT(queue != RT_NULL); RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); @@ -303,9 +303,9 @@ void rt_data_queue_reset(struct rt_data_queue *queue) queue->put_index = 0; queue->is_empty = 1; queue->is_full = 0; - + rt_hw_interrupt_enable(level); - + rt_enter_critical(); /* wakeup all suspend threads */ @@ -375,7 +375,7 @@ rt_err_t rt_data_queue_deinit(struct rt_data_queue *queue) level = rt_hw_interrupt_disable(); queue->magic = 0; rt_hw_interrupt_enable(level); - + rt_free(queue->queue); return RT_EOK; @@ -386,7 +386,7 @@ rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue) { rt_ubase_t level; rt_int16_t len; - + RT_ASSERT(queue != RT_NULL); RT_ASSERT(queue->magic == DATAQUEUE_MAGIC); @@ -405,7 +405,7 @@ rt_uint16_t rt_data_queue_len(struct rt_data_queue *queue) { len = queue->size + queue->put_index - queue->get_index; } - + rt_hw_interrupt_enable(level); return len; diff --git a/components/drivers/src/pipe.c b/components/drivers/src/pipe.c index bd392cba2b..10b880ff7a 100644 --- a/components/drivers/src/pipe.c +++ b/components/drivers/src/pipe.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -330,7 +330,7 @@ rt_err_t rt_pipe_open (rt_device_t device, rt_uint16_t oflag) ret = -RT_EINVAL; goto __exit; } - + rt_mutex_take(&(pipe->lock), RT_WAITING_FOREVER); if (pipe->fifo == RT_NULL) @@ -428,7 +428,7 @@ rt_err_t rt_pipe_control(rt_device_t dev, int cmd, void *args) } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops pipe_ops = +const static struct rt_device_ops pipe_ops = { RT_NULL, rt_pipe_open, @@ -507,7 +507,7 @@ int rt_pipe_delete(const char *name) rt_device_unregister(device); /* close fifo ringbuffer */ - if (pipe->fifo) + if (pipe->fifo) { rt_ringbuffer_destroy(pipe->fifo); pipe->fifo = RT_NULL; @@ -564,7 +564,7 @@ int pipe(int fildes[2]) int mkfifo(const char *path, mode_t mode) { rt_pipe_t *pipe; - + pipe = rt_pipe_create(path, PIPE_BUFSZ); if (pipe == RT_NULL) { diff --git a/components/drivers/src/ringblk_buf.c b/components/drivers/src/ringblk_buf.c index 7d83149c5e..c9631b9d4a 100644 --- a/components/drivers/src/ringblk_buf.c +++ b/components/drivers/src/ringblk_buf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index 88afd19506..29de20b087 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -320,8 +320,8 @@ rt_size_t rt_ringbuffer_getchar(struct rt_ringbuffer *rb, rt_uint8_t *ch) } RTM_EXPORT(rt_ringbuffer_getchar); -/** - * get the size of data in rb +/** + * get the size of data in rb */ rt_size_t rt_ringbuffer_data_len(struct rt_ringbuffer *rb) { @@ -341,8 +341,8 @@ rt_size_t rt_ringbuffer_data_len(struct rt_ringbuffer *rb) } RTM_EXPORT(rt_ringbuffer_data_len); -/** - * empty the rb +/** + * empty the rb */ void rt_ringbuffer_reset(struct rt_ringbuffer *rb) { @@ -362,7 +362,7 @@ struct rt_ringbuffer* rt_ringbuffer_create(rt_uint16_t size) struct rt_ringbuffer *rb; rt_uint8_t *pool; - RT_ASSERT(size > 0); + RT_ASSERT(size > 0); size = RT_ALIGN_DOWN(size, RT_ALIGN_SIZE); diff --git a/components/drivers/src/waitqueue.c b/components/drivers/src/waitqueue.c index 02240edbdf..f9a6d6e120 100644 --- a/components/drivers/src/waitqueue.c +++ b/components/drivers/src/waitqueue.c @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes - * 2018/06/26 Bernard Fix the wait queue issue when wakeup a soon + * 2018/06/26 Bernard Fix the wait queue issue when wakeup a soon * to blocked thread. */ diff --git a/components/drivers/src/workqueue.c b/components/drivers/src/workqueue.c index 7aea647703..f195dad927 100644 --- a/components/drivers/src/workqueue.c +++ b/components/drivers/src/workqueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/touch/touch.c b/components/drivers/touch/touch.c index e9595e9f8f..abe2c0fe24 100644 --- a/components/drivers/touch/touch.c +++ b/components/drivers/touch/touch.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/touch/touch.h b/components/drivers/touch/touch.h index be12c24206..3d2e885e13 100644 --- a/components/drivers/touch/touch.h +++ b/components/drivers/touch/touch.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbdevice/class/audio_mic.c b/components/drivers/usb/usbdevice/class/audio_mic.c index 23ade2d9b6..760c055d10 100644 --- a/components/drivers/usb/usbdevice/class/audio_mic.c +++ b/components/drivers/usb/usbdevice/class/audio_mic.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbdevice/class/audio_speaker.c b/components/drivers/usb/usbdevice/class/audio_speaker.c index e9a3ffaf40..c8bbb9cb5e 100644 --- a/components/drivers/usb/usbdevice/class/audio_speaker.c +++ b/components/drivers/usb/usbdevice/class/audio_speaker.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbdevice/class/cdc.h b/components/drivers/usb/usbdevice/class/cdc.h index 4e07f16266..a4616a956b 100644 --- a/components/drivers/usb/usbdevice/class/cdc.h +++ b/components/drivers/usb/usbdevice/class/cdc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -8,7 +8,7 @@ * 2012-10-03 Yi Qiu first version * 2012-12-12 heyuanjie87 add CDC endpoints collection */ - + #ifndef __CDC_H__ #define __CDC_H__ @@ -96,7 +96,7 @@ struct ucdc_header_descriptor rt_uint8_t length; rt_uint8_t type; rt_uint8_t subtype; - rt_uint16_t bcd; + rt_uint16_t bcd; }; typedef struct ucdc_header_descriptor* ucdc_hdr_desc_t; @@ -114,7 +114,7 @@ struct ucdc_call_mgmt_descriptor rt_uint8_t length; rt_uint8_t type; rt_uint8_t subtype; - rt_uint8_t capabilties; + rt_uint8_t capabilties; rt_uint8_t data_interface; }; typedef struct ucdc_call_mgmt_descriptor* ucdc_call_mgmt_desc_t; @@ -136,9 +136,9 @@ struct ucdc_comm_descriptor #endif struct uinterface_descriptor intf_desc; struct ucdc_header_descriptor hdr_desc; - struct ucdc_call_mgmt_descriptor call_mgmt_desc; - struct ucdc_acm_descriptor acm_desc; - struct ucdc_union_descriptor union_desc; + struct ucdc_call_mgmt_descriptor call_mgmt_desc; + struct ucdc_acm_descriptor acm_desc; + struct ucdc_union_descriptor union_desc; struct uendpoint_descriptor ep_desc; }; typedef struct ucdc_comm_descriptor* ucdc_comm_desc_t; @@ -170,7 +170,7 @@ typedef struct ucdc_eth_descriptor* ucdc_eth_desc_t; struct ucdc_data_descriptor { struct uinterface_descriptor intf_desc; - struct uendpoint_descriptor ep_out_desc; + struct uendpoint_descriptor ep_out_desc; struct uendpoint_descriptor ep_in_desc; }; typedef struct ucdc_data_descriptor* ucdc_data_desc_t; diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c index f9ea466bd5..996a12c308 100644 --- a/components/drivers/usb/usbdevice/class/cdc_vcom.c +++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2012-10-02 Yi Qiu first version - * 2012-12-12 heyuanjie87 change endpoints and function handler + * 2012-12-12 heyuanjie87 change endpoints and function handler * 2013-06-25 heyuanjie87 remove SOF mechinism * 2013-07-20 Yi Qiu do more test * 2016-02-01 Urey Fix some error @@ -146,23 +146,23 @@ const static struct ucdc_comm_descriptor _comm_desc = USB_DESC_LENGTH_INTERFACE, USB_DESC_TYPE_INTERFACE, USB_DYNAMIC, - 0x00, + 0x00, 0x01, USB_CDC_CLASS_COMM, USB_CDC_SUBCLASS_ACM, USB_CDC_PROTOCOL_V25TER, 0x00, }, - /* Header Functional Descriptor */ + /* Header Functional Descriptor */ { - 0x05, + 0x05, USB_CDC_CS_INTERFACE, USB_CDC_SCS_HEADER, 0x0110, }, - /* Call Management Functional Descriptor */ + /* Call Management Functional Descriptor */ { - 0x05, + 0x05, USB_CDC_CS_INTERFACE, USB_CDC_SCS_CALL_MGMT, 0x00, @@ -175,7 +175,7 @@ const static struct ucdc_comm_descriptor _comm_desc = USB_CDC_SCS_ACM, 0x02, }, - /* Union Functional Descriptor */ + /* Union Functional Descriptor */ { 0x05, USB_CDC_CS_INTERFACE, @@ -183,7 +183,7 @@ const static struct ucdc_comm_descriptor _comm_desc = USB_DYNAMIC, USB_DYNAMIC, }, - /* Endpoint Descriptor */ + /* Endpoint Descriptor */ { USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, @@ -204,27 +204,27 @@ const static struct ucdc_data_descriptor _data_desc = USB_DESC_TYPE_INTERFACE, USB_DYNAMIC, 0x00, - 0x02, + 0x02, USB_CDC_CLASS_DATA, - 0x00, - 0x00, - 0x00, + 0x00, + 0x00, + 0x00, }, /* endpoint, bulk out */ { - USB_DESC_LENGTH_ENDPOINT, + USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_OUT, - USB_EP_ATTR_BULK, + USB_EP_ATTR_BULK, USB_CDC_BUFSIZE, - 0x00, + 0x00, }, /* endpoint, bulk in */ { USB_DESC_LENGTH_ENDPOINT, USB_DESC_TYPE_ENDPOINT, USB_DYNAMIC | USB_DIR_IN, - USB_EP_ATTR_BULK, + USB_EP_ATTR_BULK, USB_CDC_BUFSIZE, 0x00, }, @@ -253,11 +253,11 @@ static void _vcom_reset_state(ufunction_t func) { struct vcom* data; int lvl; - + RT_ASSERT(func != RT_NULL) data = (struct vcom*)func->user_data; - + lvl = rt_hw_interrupt_disable(); data->connected = RT_FALSE; data->in_sending = RT_FALSE; @@ -299,9 +299,9 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size) return RT_EOK; } - + rt_completion_done(&data->wait); - + return RT_EOK; } @@ -396,7 +396,7 @@ static rt_err_t _cdc_set_line_coding_callback(udevice_t device, rt_size_t size) RT_DEBUG_LOG(RT_DEBUG_USB, ("_cdc_set_line_coding_callback\n")); dcd_ep0_send_status(device->dcd); - + return RT_EOK; } @@ -438,7 +438,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup) RT_ASSERT(setup != RT_NULL); data = (struct vcom*)func->user_data; - + switch(setup->bRequest) { case CDC_SEND_ENCAPSULATED_COMMAND: @@ -488,17 +488,17 @@ static rt_err_t _function_enable(ufunction_t func) RT_DEBUG_LOG(RT_DEBUG_USB, ("cdc function enable\n")); _vcom_reset_state(func); - + data = (struct vcom*)func->user_data; data->ep_out->buffer = rt_malloc(CDC_RX_BUFSIZE); RT_ASSERT(data->ep_out->buffer != RT_NULL); data->ep_out->request.buffer = data->ep_out->buffer; data->ep_out->request.size = EP_MAXPACKET(data->ep_out); - + data->ep_out->request.req_type = UIO_REQUEST_READ_BEST; rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request); - + return RT_EOK; } @@ -523,7 +523,7 @@ static rt_err_t _function_disable(ufunction_t func) if(data->ep_out->buffer != RT_NULL) { rt_free(data->ep_out->buffer); - data->ep_out->buffer = RT_NULL; + data->ep_out->buffer = RT_NULL; } return RT_EOK; @@ -544,7 +544,7 @@ static struct ufunction_ops ops = * * @return RT_EOK on successful. */ -static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, +static rt_err_t _cdc_descriptor_config(ucdc_comm_desc_t comm, rt_uint8_t cintf_nr, ucdc_data_desc_t data, rt_uint8_t dintf_nr) { comm->call_mgmt_desc.data_interface = dintf_nr; @@ -584,19 +584,19 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device) } /* set usb device string description */ rt_usbd_device_set_string(device, _ustring); - + /* create a cdc function */ func = rt_usbd_function_new(device, &dev_desc, &ops); - + /* support HS */ rt_usbd_device_set_qualifier(device, &dev_qualifier); - + /* allocate memory for cdc vcom data */ data = (struct vcom*)rt_malloc(sizeof(struct vcom)); RT_ASSERT(data != RT_NULL); rt_memset(data, 0, sizeof(struct vcom)); func->user_data = (void*)data; - + /* initilize vcom */ rt_usb_vcom_init(func); @@ -646,7 +646,7 @@ ufunction_t rt_usbd_function_cdc_create(udevice_t device) /* add the cdc data interface to cdc function */ rt_usbd_function_add_interface(func, intf_data); - + return func; } @@ -682,7 +682,7 @@ static int _vcom_getc(struct rt_serial_device *serial) rt_uint32_t level; struct ufunction *func; struct vcom *data; - + func = (struct ufunction*)serial->parent.user_data; data = (struct vcom*)func->user_data; @@ -918,7 +918,7 @@ static void rt_usb_vcom_init(struct ufunction *func) rt_err_t result = RT_EOK; struct serial_configure config; struct vcom *data = (struct vcom*)func->user_data; - + /* initialize ring buffer */ rt_ringbuffer_init(&data->rx_ringbuffer, data->rx_rbp, CDC_RX_BUFSIZE); rt_ringbuffer_init(&data->tx_ringbuffer, data->tx_rbp, CDC_TX_BUFSIZE); @@ -952,9 +952,9 @@ static void rt_usb_vcom_init(struct ufunction *func) vcom_thread_stack, VCOM_TASK_STK_SIZE, 16, 20); result = rt_thread_startup(&vcom_thread); - RT_ASSERT(result == RT_EOK); + RT_ASSERT(result == RT_EOK); } -struct udclass vcom_class = +struct udclass vcom_class = { .rt_usbd_function_create = rt_usbd_function_cdc_create }; diff --git a/components/drivers/usb/usbdevice/class/ecm.c b/components/drivers/usb/usbdevice/class/ecm.c index 36557dad74..1550f8e1e2 100644 --- a/components/drivers/usb/usbdevice/class/ecm.c +++ b/components/drivers/usb/usbdevice/class/ecm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -44,9 +44,9 @@ struct rt_ecm_eth ALIGN(4) char rx_buffer[USB_ETH_MTU]; char tx_buffer[USB_ETH_MTU]; - + struct rt_semaphore tx_buffer_free; - + }; typedef struct rt_ecm_eth * rt_ecm_eth_t; @@ -207,7 +207,7 @@ static rt_err_t _cdc_send_notifi(ufunction_t func,ucdc_notification_code_t notif _notifi.bNotificatinCode = notifi; _notifi.wValue = wValue; _notifi.wLength = wLength; - + eps->ep_cmd->request.buffer = (void *)&_notifi; eps->ep_cmd->request.size = 8; eps->ep_cmd->request.req_type = UIO_REQUEST_WRITE; @@ -220,7 +220,7 @@ static rt_err_t _ecm_set_eth_packet_filter(ufunction_t func, ureq_t setup) { rt_ecm_eth_t _ecm_eth = (rt_ecm_eth_t)func->user_data; dcd_ep0_send_status(func->device->dcd); - + /* send link up. */ eth_device_linkchange(&_ecm_eth->parent, RT_TRUE); _cdc_send_notifi(func, UCDC_NOTIFI_NETWORK_CONNECTION, 1, 0); @@ -292,7 +292,7 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) ecm_device->rx_size = ecm_device->rx_offset; ecm_device->rx_offset = 0; eth_device_ready(&ecm_device->parent); - + }else { ecm_device->eps.ep_out->request.buffer = ecm_device->eps.ep_out->buffer; @@ -427,7 +427,7 @@ rt_err_t rt_ecm_eth_tx(rt_device_t dev, struct pbuf* p) rt_sem_release(&ecm_eth_dev->tx_buffer_free); return result; } - + pbuffer = (char *)&ecm_eth_dev->tx_buffer; for (q = p; q != NULL; q = q->next) { @@ -480,7 +480,7 @@ static rt_err_t _function_enable(ufunction_t func) /* reset eth rx tx */ ecm_device->rx_size = 0; ecm_device->rx_offset = 0; - + eps->ep_out->request.buffer = (void *)eps->ep_out->buffer; eps->ep_out->request.size = EP_MAXPACKET(eps->ep_out); eps->ep_out->request.req_type = UIO_REQUEST_READ_BEST; @@ -555,7 +555,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device) ualtsetting_t comm_setting, data_setting; ucdc_data_desc_t data_desc; ucdc_eth_desc_t comm_desc; - + /* parameter check */ RT_ASSERT(device != RT_NULL); @@ -600,7 +600,7 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device) rt_usbd_set_altsetting(intf_comm, 0); /* add the communication interface to the cdc class */ rt_usbd_function_add_interface(cdc, intf_comm); - + /* create a bulk in and a bulk out endpoint */ data_desc = (ucdc_data_desc_t)data_setting->desc; eps->ep_out = rt_usbd_endpoint_new(&data_desc->ep_out_desc, _ep_out_handler); @@ -648,14 +648,14 @@ ufunction_t rt_usbd_function_ecm_create(udevice_t device) _ecm_eth->parent.eth_tx = rt_ecm_eth_tx; /* register eth device */ eth_device_init(&_ecm_eth->parent, "u0"); - + /* send link up. */ eth_device_linkchange(&_ecm_eth->parent, RT_FALSE); - + return cdc; } -struct udclass ecm_class = +struct udclass ecm_class = { .rt_usbd_function_create = rt_usbd_function_ecm_create }; diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c index 52e50296a4..5023be46eb 100644 --- a/components/drivers/usb/usbdevice/class/hid.c +++ b/components/drivers/usb/usbdevice/class/hid.c @@ -1,9 +1,9 @@ /* * File : hid.c - * COPYRIGHT (C) 2008 - 2018, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2017-03-13 Urey the first version @@ -621,12 +621,12 @@ static void hid_thread_entry(void* parameter) struct hid_report report; struct hid_s *hiddev; hiddev = (struct hid_s *)parameter; - while(1) - { - if(rt_mq_recv(&hiddev->hid_mq, &report, sizeof(report),RT_WAITING_FOREVER) != RT_EOK ) + while(1) + { + if(rt_mq_recv(&hiddev->hid_mq, &report, sizeof(report),RT_WAITING_FOREVER) != RT_EOK ) continue; - HID_Report_Received(&report); - } + HID_Report_Received(&report); + } } #ifdef RT_USING_DEVICE_OPS @@ -658,7 +658,7 @@ static void rt_usb_hid_init(struct ufunction *func) rt_device_register(&hiddev->parent, "hidd", RT_DEVICE_FLAG_RDWR); rt_mq_init(&hiddev->hid_mq, "hiddmq", hid_mq_pool, sizeof(struct hid_report), sizeof(hid_mq_pool), RT_IPC_FLAG_FIFO); - + rt_thread_init(&hid_thread, "hidd", hid_thread_entry, hiddev, hid_thread_stack, sizeof(hid_thread_stack), RT_USBD_THREAD_PRIO, 20); rt_thread_startup(&hid_thread); @@ -689,7 +689,7 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device) /* create a cdc function */ func = rt_usbd_function_new(device, &_dev_desc, &ops); - + /* For high speed mode supporting */ rt_usbd_device_set_qualifier(device, &dev_qualifier); @@ -730,7 +730,7 @@ ufunction_t rt_usbd_function_hid_create(udevice_t device) rt_usb_hid_init(func); return func; } -struct udclass hid_class = +struct udclass hid_class = { .rt_usbd_function_create = rt_usbd_function_hid_create }; diff --git a/components/drivers/usb/usbdevice/class/hid.h b/components/drivers/usb/usbdevice/class/hid.h index 4d0f314a11..2b6a4ad90a 100644 --- a/components/drivers/usb/usbdevice/class/hid.h +++ b/components/drivers/usb/usbdevice/class/hid.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c index 6991d97eae..f14f6b0c24 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.c +++ b/components/drivers/usb/usbdevice/class/mstorage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -7,7 +7,7 @@ * Date Author Notes * 2012-10-01 Yi Qiu first version * 2012-11-25 Heyuanjie87 reduce the memory consumption - * 2012-12-09 Heyuanjie87 change function and endpoint handler + * 2012-12-09 Heyuanjie87 change function and endpoint handler * 2013-07-25 Yi Qiu update for USB CV test */ @@ -24,10 +24,10 @@ enum STAT { STAT_CBW, - STAT_CMD, + STAT_CMD, STAT_CSW, STAT_RECEIVE, - STAT_SEND, + STAT_SEND, }; typedef enum @@ -49,7 +49,7 @@ typedef rt_size_t (*cbw_handler)(ufunction_t func, ustorage_cbw_t cbw); struct scsi_cmd { rt_uint16_t cmd; - cbw_handler handler; + cbw_handler handler; rt_size_t cmd_len; CB_SIZE_TYPE type; rt_size_t data_size; @@ -57,10 +57,10 @@ struct scsi_cmd }; struct mstorage -{ +{ struct ustorage_csw csw_response; uep_t ep_in; - uep_t ep_out; + uep_t ep_out; int status; rt_uint32_t cb_data_size; rt_device_t disk; @@ -68,7 +68,7 @@ struct mstorage rt_int32_t count; rt_int32_t size; struct scsi_cmd* processing; - struct rt_device_blk_geometry geometry; + struct rt_device_blk_geometry geometry; }; ALIGN(4) @@ -183,9 +183,9 @@ static struct scsi_cmd cmd_data[] = {SCSI_REQUEST_SENSE, _request_sense, 6, COUNT, 0, DIR_IN}, {SCSI_INQUIRY_CMD, _inquiry_cmd, 6, COUNT, 0, DIR_IN}, {SCSI_ALLOW_REMOVAL, _allow_removal, 6, FIXED, 0, DIR_NONE}, - {SCSI_MODE_SENSE_6, _mode_sense_6, 6, COUNT, 0, DIR_IN}, - {SCSI_START_STOP, _start_stop, 6, FIXED, 0, DIR_NONE}, - {SCSI_READ_CAPACITIES, _read_capacities, 10, COUNT, 0, DIR_NONE}, + {SCSI_MODE_SENSE_6, _mode_sense_6, 6, COUNT, 0, DIR_IN}, + {SCSI_START_STOP, _start_stop, 6, FIXED, 0, DIR_NONE}, + {SCSI_READ_CAPACITIES, _read_capacities, 10, COUNT, 0, DIR_NONE}, {SCSI_READ_CAPACITY, _read_capacity, 10, FIXED, 8, DIR_IN}, {SCSI_READ_10, _read_10, 10, BLOCK_COUNT, 0, DIR_IN}, {SCSI_WRITE_10, _write_10, 10, BLOCK_COUNT, 0, DIR_OUT}, @@ -200,9 +200,9 @@ static void _send_status(ufunction_t func) RT_DEBUG_LOG(RT_DEBUG_USB, ("_send_status\n")); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; data->ep_in->request.buffer = (rt_uint8_t*)&data->csw_response; - data->ep_in->request.size = SIZEOF_CSW; + data->ep_in->request.size = SIZEOF_CSW; data->ep_in->request.req_type = UIO_REQUEST_WRITE; rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request); data->status = STAT_CSW; @@ -213,13 +213,13 @@ static rt_size_t _test_unit_ready(ufunction_t func, ustorage_cbw_t cbw) struct mstorage *data; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_test_unit_ready\n")); data = (struct mstorage*)func->user_data; data->csw_response.status = 0; - + return 0; } @@ -228,7 +228,7 @@ static rt_size_t _allow_removal(ufunction_t func, ustorage_cbw_t cbw) struct mstorage *data; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_allow_removal\n")); @@ -241,7 +241,7 @@ static rt_size_t _allow_removal(ufunction_t func, ustorage_cbw_t cbw) /** * This function will handle inquiry command request. * - * @param func the usb function object. + * @param func the usb function object. * @param cbw the command block wrapper. * * @return RT_EOK on successful. @@ -253,12 +253,12 @@ static rt_size_t _inquiry_cmd(ufunction_t func, ustorage_cbw_t cbw) rt_uint8_t *buf; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_inquiry_cmd\n")); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; buf = data->ep_in->buffer; *(rt_uint32_t*)&buf[0] = 0x0 | (0x80 << 8); @@ -281,7 +281,7 @@ static rt_size_t _inquiry_cmd(ufunction_t func, ustorage_cbw_t cbw) /** * This function will handle sense request. * - * @param func the usb function object. + * @param func the usb function object. * @param cbw the command block wrapper. * * @return RT_EOK on successful. @@ -292,12 +292,12 @@ static rt_size_t _request_sense(ufunction_t func, ustorage_cbw_t cbw) struct request_sense_data *buf; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_request_sense\n")); - - data = (struct mstorage*)func->user_data; + + data = (struct mstorage*)func->user_data; buf = (struct request_sense_data *)data->ep_in->buffer; buf->ErrorCode = 0x70; @@ -325,7 +325,7 @@ static rt_size_t _request_sense(ufunction_t func, ustorage_cbw_t cbw) * This function will handle mode_sense_6 request. * * @param func the usb function object. - * @param cbw the command block wrapper. + * @param cbw the command block wrapper. * * @return RT_EOK on successful. */ @@ -335,12 +335,12 @@ static rt_size_t _mode_sense_6(ufunction_t func, ustorage_cbw_t cbw) rt_uint8_t *buf; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_mode_sense_6\n")); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; buf = data->ep_in->buffer; buf[0] = 3; buf[1] = 0; @@ -360,7 +360,7 @@ static rt_size_t _mode_sense_6(ufunction_t func, ustorage_cbw_t cbw) /** * This function will handle read_capacities request. * - * @param func the usb function object. + * @param func the usb function object. * @param cbw the command block wrapper. * * @return RT_EOK on successful. @@ -372,12 +372,12 @@ static rt_size_t _read_capacities(ufunction_t func, ustorage_cbw_t cbw) rt_uint32_t sector_count, sector_size; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacities\n")); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; buf = data->ep_in->buffer; sector_count = data->geometry.sector_count; sector_size = data->geometry.bytes_per_sector; @@ -405,7 +405,7 @@ static rt_size_t _read_capacities(ufunction_t func, ustorage_cbw_t cbw) /** * This function will handle read_capacity request. * - * @param func the usb function object. + * @param func the usb function object. * @param cbw the command block wapper. * * @return RT_EOK on successful. @@ -418,13 +418,13 @@ static rt_size_t _read_capacity(ufunction_t func, ustorage_cbw_t cbw) rt_uint32_t sector_count, sector_size; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_read_capacity\n")); - data = (struct mstorage*)func->user_data; - buf = data->ep_in->buffer; + data = (struct mstorage*)func->user_data; + buf = data->ep_in->buffer; sector_count = data->geometry.sector_count - 1; /* Last Logical Block Address */ sector_size = data->geometry.bytes_per_sector; @@ -459,19 +459,19 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw) { struct mstorage *data; rt_size_t size; - + RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; data->block = cbw->cb[2]<<24 | cbw->cb[3]<<16 | cbw->cb[4]<<8 | cbw->cb[5]<<0; data->count = cbw->cb[7]<<8 | cbw->cb[8]<<0; RT_ASSERT(data->count < data->geometry.sector_count); - data->csw_response.data_reside = data->cb_data_size; + data->csw_response.data_reside = data->cb_data_size; size = rt_device_read(data->disk, data->block, data->ep_in->buffer, 1); if(size == 0) { @@ -479,11 +479,11 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw) } data->ep_in->request.buffer = data->ep_in->buffer; - data->ep_in->request.size = data->geometry.bytes_per_sector; - data->ep_in->request.req_type = UIO_REQUEST_WRITE; + data->ep_in->request.size = data->geometry.bytes_per_sector; + data->ep_in->request.req_type = UIO_REQUEST_WRITE; rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request); data->status = STAT_SEND; - + return data->geometry.bytes_per_sector; } @@ -503,7 +503,7 @@ static rt_size_t _write_10(ufunction_t func, ustorage_cbw_t cbw) RT_ASSERT(func->device != RT_NULL); RT_ASSERT(cbw != RT_NULL); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; data->block = cbw->cb[2]<<24 | cbw->cb[3]<<16 | cbw->cb[4]<<8 | cbw->cb[5]<<0; @@ -515,13 +515,13 @@ static rt_size_t _write_10(ufunction_t func, ustorage_cbw_t cbw) data->count, data->block, data->geometry.sector_count)); data->csw_response.data_reside = data->cb_data_size; - + data->ep_out->request.buffer = data->ep_out->buffer; - data->ep_out->request.size = data->geometry.bytes_per_sector; + data->ep_out->request.size = data->geometry.bytes_per_sector; data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request); data->status = STAT_RECEIVE; - + return data->geometry.bytes_per_sector; } @@ -537,42 +537,42 @@ static rt_size_t _verify_10(ufunction_t func, ustorage_cbw_t cbw) struct mstorage *data; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_verify_10\n")); data = (struct mstorage*)func->user_data; data->csw_response.status = 0; - + return 0; } -static rt_size_t _start_stop(ufunction_t func, +static rt_size_t _start_stop(ufunction_t func, ustorage_cbw_t cbw) { struct mstorage *data; RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_start_stop\n")); data = (struct mstorage*)func->user_data; data->csw_response.status = 0; - + return 0; } static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size) { struct mstorage *data; - + RT_ASSERT(func != RT_NULL); RT_ASSERT(func->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_in_handler\n")); - - data = (struct mstorage*)func->user_data; + + data = (struct mstorage*)func->user_data; switch(data->status) { @@ -580,15 +580,15 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size) if(data->ep_in->request.size != SIZEOF_CSW) { rt_kprintf("Size of csw command error\n"); - rt_usbd_ep_set_stall(func->device, data->ep_in); + rt_usbd_ep_set_stall(func->device, data->ep_in); } else { RT_DEBUG_LOG(RT_DEBUG_USB, ("return to cbw status\n")); data->ep_out->request.buffer = data->ep_out->buffer; data->ep_out->request.size = SIZEOF_CBW; - data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; - rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request); + data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; + rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request); data->status = STAT_CBW; } break; @@ -601,47 +601,47 @@ static rt_err_t _ep_in_handler(ufunction_t func, rt_size_t size) { data->csw_response.data_reside -= data->ep_in->request.size; if(data->csw_response.data_reside != 0) - { - RT_DEBUG_LOG(RT_DEBUG_USB, ("data_reside %d, request %d\n", + { + RT_DEBUG_LOG(RT_DEBUG_USB, ("data_reside %d, request %d\n", data->csw_response.data_reside, data->ep_in->request.size)); if(data->processing->dir == DIR_OUT) { rt_usbd_ep_set_stall(func->device, data->ep_out); } else - { + { //rt_kprintf("warning:in stall path but not stall\n"); - + /* FIXME: Disable the operation or the disk cannot work. */ - //rt_usbd_ep_set_stall(func->device, data->ep_in); + //rt_usbd_ep_set_stall(func->device, data->ep_in); } data->csw_response.data_reside = 0; } } _send_status(func); break; - case STAT_SEND: + case STAT_SEND: data->csw_response.data_reside -= data->ep_in->request.size; - data->count--; - data->block++; + data->count--; + data->block++; if(data->count > 0 && data->csw_response.data_reside > 0) { if(rt_device_read(data->disk, data->block, data->ep_in->buffer, 1) == 0) { rt_kprintf("disk read error\n"); rt_usbd_ep_set_stall(func->device, data->ep_in); - return -RT_ERROR; + return -RT_ERROR; } data->ep_in->request.buffer = data->ep_in->buffer; - data->ep_in->request.size = data->geometry.bytes_per_sector; - data->ep_in->request.req_type = UIO_REQUEST_WRITE; - rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request); + data->ep_in->request.size = data->geometry.bytes_per_sector; + data->ep_in->request.req_type = UIO_REQUEST_WRITE; + rt_usbd_io_request(func->device, data->ep_in, &data->ep_in->request); } else { - _send_status(func); - } + _send_status(func); + } break; } @@ -671,7 +671,7 @@ static struct scsi_cmd* _find_cbw_command(rt_uint16_t cmd) { if(cmd_data[i].cmd == cmd) return &cmd_data[i]; - } + } return RT_NULL; } @@ -685,7 +685,7 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd, RT_ASSERT(cmd != RT_NULL); RT_ASSERT(cbw != RT_NULL); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; if(cmd->cmd_len == 6) { switch(cmd->type) @@ -699,9 +699,9 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd, case FIXED: data->cb_data_size = cmd->data_size; break; - default: + default: break; - } + } } else if(cmd->cmd_len == 10) { @@ -711,32 +711,32 @@ static void _cb_len_calc(ufunction_t func, struct scsi_cmd* cmd, data->cb_data_size = cbw->cb[7]<<8 | cbw->cb[8]; break; case BLOCK_COUNT: - data->cb_data_size = (cbw->cb[7]<<8 | cbw->cb[8]) * + data->cb_data_size = (cbw->cb[7]<<8 | cbw->cb[8]) * data->geometry.bytes_per_sector; break; case FIXED: data->cb_data_size = cmd->data_size; break; - default: + default: break; } } - + //workaround: for stability in full-speed mode else if(cmd->cmd_len == 12) { switch(cmd->type) { case COUNT: - data->cb_data_size = cbw->cb[4]; + data->cb_data_size = cbw->cb[4]; break; - default: + default: break; } } else { - rt_kprintf("cmd_len error %d\n", cmd->cmd_len); + rt_kprintf("cmd_len error %d\n", cmd->cmd_len); } } @@ -749,7 +749,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd, RT_ASSERT(cbw != RT_NULL); RT_ASSERT(func != RT_NULL); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; if(cmd->cmd_len != cbw->cb_len) { rt_kprintf("cb_len error\n"); @@ -780,7 +780,7 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd, rt_kprintf("xfer_len > data_size\n"); return RT_FALSE; } - + if(cbw->xfer_len < data->cb_data_size) { rt_kprintf("xfer_len < data_size\n"); @@ -788,18 +788,18 @@ static rt_bool_t _cbw_verify(ufunction_t func, struct scsi_cmd* cmd, data->csw_response.status = 1; } - return RT_TRUE; + return RT_TRUE; } static rt_size_t _cbw_handler(ufunction_t func, struct scsi_cmd* cmd, ustorage_cbw_t cbw) -{ +{ struct mstorage *data; RT_ASSERT(func != RT_NULL); RT_ASSERT(cbw != RT_NULL); RT_ASSERT(cmd->handler != RT_NULL); - + data = (struct mstorage*)func->user_data; data->processing = cmd; return cmd->handler(func, cbw); @@ -819,21 +819,21 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) struct scsi_cmd* cmd; rt_size_t len; struct ustorage_cbw* cbw; - + RT_ASSERT(func != RT_NULL); RT_ASSERT(func->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size)); - + data = (struct mstorage*)func->user_data; - cbw = (struct ustorage_cbw*)data->ep_out->buffer; + cbw = (struct ustorage_cbw*)data->ep_out->buffer; if(data->status == STAT_CBW) { /* dump cbw information */ if(cbw->signature != CBW_SIGNATURE || size != SIZEOF_CBW) { goto exit; - } + } data->csw_response.signature = CSW_SIGNATURE; data->csw_response.tag = cbw->tag; @@ -841,33 +841,33 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) data->csw_response.status = 0; RT_DEBUG_LOG(RT_DEBUG_USB, ("ep_out reside %d\n", data->csw_response.data_reside)); - + cmd = _find_cbw_command(cbw->cb[0]); if(cmd == RT_NULL) { rt_kprintf("can't find cbw command\n"); goto exit; - } + } _cb_len_calc(func, cmd, cbw); if(!_cbw_verify(func, cmd, cbw)) { goto exit; } - + len = _cbw_handler(func, cmd, cbw); if(len == 0) { _send_status(func); - } - - return RT_EOK; + } + + return RT_EOK; } else if(data->status == STAT_RECEIVE) { RT_DEBUG_LOG(RT_DEBUG_USB, ("\nwrite size %d block 0x%x oount 0x%x\n", size, data->block, data->size)); - + data->size -= size; data->csw_response.data_reside -= size; @@ -876,10 +876,10 @@ static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size) if(data->csw_response.data_reside != 0) { data->ep_out->request.buffer = data->ep_out->buffer; - data->ep_out->request.size = data->geometry.bytes_per_sector; - data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; + data->ep_out->request.size = data->geometry.bytes_per_sector; + data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request); - data->block ++; + data->block ++; } else { @@ -904,7 +904,7 @@ exit: } data->csw_response.status = 1; _send_status(func); - + return -RT_ERROR; } @@ -919,21 +919,21 @@ exit: static rt_err_t _interface_handler(ufunction_t func, ureq_t setup) { rt_uint8_t lun = 0; - + RT_ASSERT(func != RT_NULL); - RT_ASSERT(func->device != RT_NULL); + RT_ASSERT(func->device != RT_NULL); RT_ASSERT(setup != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("mstorage_interface_handler\n")); switch(setup->bRequest) { - case USBREQ_GET_MAX_LUN: - + case USBREQ_GET_MAX_LUN: + RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_GET_MAX_LUN\n")); - + if(setup->wValue || setup->wLength != 1) - { + { rt_usbd_ep0_set_stall(func->device); } else @@ -944,14 +944,14 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup) case USBREQ_MASS_STORAGE_RESET: RT_DEBUG_LOG(RT_DEBUG_USB, ("USBREQ_MASS_STORAGE_RESET\n")); - + if(setup->wValue || setup->wLength != 0) { rt_usbd_ep0_set_stall(func->device); } else - { - dcd_ep0_send_status(func->device->dcd); + { + dcd_ep0_send_status(func->device->dcd); } break; default: @@ -992,14 +992,14 @@ static rt_err_t _function_enable(ufunction_t func) rt_kprintf("disk open error\n"); return -RT_ERROR; } - - if(rt_device_control(data->disk, RT_DEVICE_CTRL_BLK_GETGEOME, + + if(rt_device_control(data->disk, RT_DEVICE_CTRL_BLK_GETGEOME, (void*)&data->geometry) != RT_EOK) { rt_kprintf("get disk info error\n"); return -RT_ERROR; } - + data->ep_in->buffer = (rt_uint8_t*)rt_malloc(data->geometry.bytes_per_sector); if(data->ep_in->buffer == RT_NULL) { @@ -1012,14 +1012,14 @@ static rt_err_t _function_enable(ufunction_t func) rt_free(data->ep_in->buffer); rt_kprintf("no memory\n"); return -RT_ENOMEM; - } - + } + /* prepare to read CBW request */ data->ep_out->request.buffer = data->ep_out->buffer; - data->ep_out->request.size = SIZEOF_CBW; - data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; + data->ep_out->request.size = SIZEOF_CBW; + data->ep_out->request.req_type = UIO_REQUEST_READ_FULL; rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request); - + return RT_EOK; } @@ -1037,11 +1037,11 @@ static rt_err_t _function_disable(ufunction_t func) RT_DEBUG_LOG(RT_DEBUG_USB, ("Mass storage function disabled\n")); - data = (struct mstorage*)func->user_data; + data = (struct mstorage*)func->user_data; if(data->ep_in->buffer != RT_NULL) { rt_free(data->ep_in->buffer); - data->ep_in->buffer = RT_NULL; + data->ep_in->buffer = RT_NULL; } if(data->ep_out->buffer != RT_NULL) @@ -1057,9 +1057,9 @@ static rt_err_t _function_disable(ufunction_t func) #endif data->disk = RT_NULL; } - + data->status = STAT_CBW; - + return RT_EOK; } @@ -1098,11 +1098,11 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device) /* set usb device string description */ rt_usbd_device_set_string(device, _ustring); - + /* create a mass storage function */ func = rt_usbd_function_new(device, &dev_desc, &ops); device->dev_qualifier = &dev_qualifier; - + /* allocate memory for mass storage function data */ data = (struct mstorage*)rt_malloc(sizeof(struct mstorage)); rt_memset(data, 0, sizeof(struct mstorage)); @@ -1113,7 +1113,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device) /* create an alternate setting object */ setting = rt_usbd_altsetting_new(sizeof(struct umass_descriptor)); - + /* config desc in alternate setting */ rt_usbd_altsetting_config_descriptor(setting, &_mass_desc, (rt_off_t)&((umass_desc_t)0)->intf_desc); @@ -1138,7 +1138,7 @@ ufunction_t rt_usbd_function_mstorage_create(udevice_t device) return func; } -struct udclass msc_class = +struct udclass msc_class = { .rt_usbd_function_create = rt_usbd_function_mstorage_create }; diff --git a/components/drivers/usb/usbdevice/class/mstorage.h b/components/drivers/usb/usbdevice/class/mstorage.h index 254038195b..6c81809ef2 100644 --- a/components/drivers/usb/usbdevice/class/mstorage.h +++ b/components/drivers/usb/usbdevice/class/mstorage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -8,7 +8,7 @@ * 2012-10-01 Yi Qiu first version * 2012-12-12 heyuanjie87 add MASS endpoints collection */ - + #ifndef __MSTORAGE_H__ #define __MSTORAGE_H__ @@ -23,7 +23,7 @@ struct umass_descriptor #endif struct uinterface_descriptor intf_desc; struct uendpoint_descriptor ep_out_desc; - struct uendpoint_descriptor ep_in_desc; + struct uendpoint_descriptor ep_in_desc; }; typedef struct umass_descriptor* umass_desc_t; diff --git a/components/drivers/usb/usbdevice/class/ndis.h b/components/drivers/usb/usbdevice/class/ndis.h index 6d6943366e..b83f3c78ec 100644 --- a/components/drivers/usb/usbdevice/class/ndis.h +++ b/components/drivers/usb/usbdevice/class/ndis.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -7,14 +7,14 @@ * Date Author Notes */ /* - * ndis.h - * + * ndis.h + * * Modified by Colin O'Flynn * ntddndis.h modified by Benedikt Spranger - * - * Thanks to the cygwin development team, + * + * Thanks to the cygwin development team, * espacially to Casper S. Hornstrup - * + * * THIS SOFTWARE IS NOT COPYRIGHTED * * This source code is offered for use in the public domain. You may @@ -30,7 +30,7 @@ #ifndef __NDIS_H__ #define __NDIS_H__ -#define NDIS_STATUS_MULTICAST_FULL 0xC0010009 +#define NDIS_STATUS_MULTICAST_FULL 0xC0010009 #define NDIS_STATUS_MULTICAST_EXISTS 0xC001000A #define NDIS_STATUS_MULTICAST_NOT_FOUND 0xC001000B @@ -42,21 +42,21 @@ #define OID_PNP_REMOVE_WAKE_UP_PATTERN 0xFD010104 #define OID_PNP_ENABLE_WAKE_UP 0xFD010106 -enum NDIS_DEVICE_POWER_STATE +enum NDIS_DEVICE_POWER_STATE { - NdisDeviceStateUnspecified = 0, - NdisDeviceStateD0, - NdisDeviceStateD1, - NdisDeviceStateD2, - NdisDeviceStateD3, - NdisDeviceStateMaximum + NdisDeviceStateUnspecified = 0, + NdisDeviceStateD0, + NdisDeviceStateD1, + NdisDeviceStateD2, + NdisDeviceStateD3, + NdisDeviceStateMaximum }; struct NDIS_PM_WAKE_UP_CAPABILITIES { - enum NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp; - enum NDIS_DEVICE_POWER_STATE MinPatternWakeUp; - enum NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp; + enum NDIS_DEVICE_POWER_STATE MinMagicPacketWakeUp; + enum NDIS_DEVICE_POWER_STATE MinPatternWakeUp; + enum NDIS_DEVICE_POWER_STATE MinLinkChangeWakeUp; }; /* NDIS_PNP_CAPABILITIES.Flags constants */ @@ -194,36 +194,36 @@ struct NDIS_PM_WAKE_UP_CAPABILITIES #define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS 0x00800000 #define NDIS_MINIPORT_64BITS_DMA 0x01000000 -#define NDIS_MEDIUM_802_3 0x00000000 -#define NDIS_MEDIUM_802_5 0x00000001 -#define NDIS_MEDIUM_FDDI 0x00000002 -#define NDIS_MEDIUM_WAN 0x00000003 -#define NDIS_MEDIUM_LOCAL_TALK 0x00000004 -#define NDIS_MEDIUM_DIX 0x00000005 +#define NDIS_MEDIUM_802_3 0x00000000 +#define NDIS_MEDIUM_802_5 0x00000001 +#define NDIS_MEDIUM_FDDI 0x00000002 +#define NDIS_MEDIUM_WAN 0x00000003 +#define NDIS_MEDIUM_LOCAL_TALK 0x00000004 +#define NDIS_MEDIUM_DIX 0x00000005 #define NDIS_MEDIUM_ARCENT_RAW 0x00000006 #define NDIS_MEDIUM_ARCENT_878_2 0x00000007 -#define NDIS_MEDIUM_ATM 0x00000008 +#define NDIS_MEDIUM_ATM 0x00000008 #define NDIS_MEDIUM_WIRELESS_LAN 0x00000009 -#define NDIS_MEDIUM_IRDA 0x0000000A -#define NDIS_MEDIUM_BPC 0x0000000B -#define NDIS_MEDIUM_CO_WAN 0x0000000C -#define NDIS_MEDIUM_1394 0x0000000D - -#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 -#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 -#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 -#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 -#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 -#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 -#define NDIS_PACKET_TYPE_SMT 0x00000040 -#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 -#define NDIS_PACKET_TYPE_GROUP 0x00000100 -#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200 -#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400 -#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800 - -#define NDIS_MEDIA_STATE_CONNECTED 0x00000000 -#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001 +#define NDIS_MEDIUM_IRDA 0x0000000A +#define NDIS_MEDIUM_BPC 0x0000000B +#define NDIS_MEDIUM_CO_WAN 0x0000000C +#define NDIS_MEDIUM_1394 0x0000000D + +#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 +#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 +#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 +#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 +#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 +#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 +#define NDIS_PACKET_TYPE_SMT 0x00000040 +#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 +#define NDIS_PACKET_TYPE_GROUP 0x00000100 +#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00000200 +#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00000400 +#define NDIS_PACKET_TYPE_MAC_FRAME 0x00000800 + +#define NDIS_MEDIA_STATE_CONNECTED 0x00000000 +#define NDIS_MEDIA_STATE_DISCONNECTED 0x00000001 #define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001 #define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002 diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c index 93e0ba6ae2..391924dba0 100644 --- a/components/drivers/usb/usbdevice/class/rndis.c +++ b/components/drivers/usb/usbdevice/class/rndis.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -215,7 +215,7 @@ const static char* _ustring[] = }; ALIGN(4) -struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc = +struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc = { .bFirstInterfaceNumber = USB_DYNAMIC, .reserved1 = 0x01, @@ -347,7 +347,7 @@ static rt_err_t _rndis_init_response(ufunction_t func, rndis_init_msg_t msg) rt_list_insert_before(&((rt_rndis_eth_t)func->user_data)->response_list, &response->list); rt_hw_interrupt_enable(level); } - + return RT_EOK; } @@ -764,7 +764,7 @@ static rt_err_t send_encapsulated_command_done(udevice_t device, rt_size_t size) } //#error here have bug ep 0x82 send failed static rt_err_t _rndis_send_encapsulated_command(ufunction_t func, ureq_t setup) -{ +{ RT_ASSERT(setup->wLength <= sizeof(rndis_message_buffer)); function = func; rt_usbd_ep0_read(func->device,rndis_message_buffer,setup->wLength,send_encapsulated_command_done); @@ -808,7 +808,7 @@ static rt_err_t _rndis_get_encapsulated_response(ufunction_t func, ureq_t setup) data[1] = 0; ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.buffer = ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->buffer; ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.size = 8; - ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.req_type = UIO_REQUEST_WRITE; + ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request.req_type = UIO_REQUEST_WRITE; rt_usbd_io_request(func->device, ((rt_rndis_eth_t)func->user_data)->eps.ep_cmd, &((rt_rndis_eth_t)func->user_data)->eps.ep_cmd->request); } else @@ -983,7 +983,7 @@ static rt_err_t _function_enable(ufunction_t func) ((rt_rndis_eth_t)func->user_data)->need_notify = RT_TRUE; rt_hw_interrupt_enable(level); } - + return RT_EOK; } @@ -1022,7 +1022,7 @@ static rt_err_t _function_disable(ufunction_t func) rt_hw_interrupt_enable(level); } - + /* link down. */ eth_device_linkchange(&((rt_rndis_eth_t)func->user_data)->parent, RT_FALSE); @@ -1323,7 +1323,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device) /* create a cdc class */ cdc = rt_usbd_function_new(device, &_dev_desc, &ops); rt_usbd_device_set_qualifier(device, &dev_qualifier); - _rndis= rt_malloc(sizeof(struct rt_rndis_eth)); + _rndis= rt_malloc(sizeof(struct rt_rndis_eth)); rt_memset(_rndis, 0, sizeof(struct rt_rndis_eth)); cdc->user_data = _rndis; @@ -1357,7 +1357,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device) rt_usbd_set_altsetting(intf_comm, 0); /* add the communication interface to the cdc class */ rt_usbd_function_add_interface(cdc, intf_comm); - + /* create a bulk in and a bulk out endpoint */ data_desc = (ucdc_data_desc_t)data_setting->desc; eps->ep_out = rt_usbd_endpoint_new(&data_desc->ep_out_desc, _ep_out_handler); @@ -1434,7 +1434,7 @@ ufunction_t rt_usbd_function_rndis_create(udevice_t device) return cdc; } -struct udclass rndis_class = +struct udclass rndis_class = { .rt_usbd_function_create = rt_usbd_function_rndis_create }; diff --git a/components/drivers/usb/usbdevice/class/rndis.h b/components/drivers/usb/usbdevice/class/rndis.h index fcdd249984..f25ae4931c 100644 --- a/components/drivers/usb/usbdevice/class/rndis.h +++ b/components/drivers/usb/usbdevice/class/rndis.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -13,43 +13,43 @@ #include -#define USB_ETH_MTU 1500+14 +#define USB_ETH_MTU 1500+14 #define RNDIS_MESSAGE_BUFFER_SIZE 128 #define RESPONSE_AVAILABLE 0x00000001 /* Remote NDIS version numbers */ -#define RNDIS_MAJOR_VERSION 1 +#define RNDIS_MAJOR_VERSION 1 #define RNDIS_MINOR_VERSION 0 /* common status values */ -#define RNDIS_STATUS_SUCCESS 0X00000000 -#define RNDIS_STATUS_FAILURE 0XC0000001 -#define RNDIS_STATUS_INVALID_DATA 0XC0010015 -#define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB -#define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B -#define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C +#define RNDIS_STATUS_SUCCESS 0X00000000 +#define RNDIS_STATUS_FAILURE 0XC0000001 +#define RNDIS_STATUS_INVALID_DATA 0XC0010015 +#define RNDIS_STATUS_NOT_SUPPORTED 0XC00000BB +#define RNDIS_STATUS_MEDIA_CONNECT 0X4001000B +#define RNDIS_STATUS_MEDIA_DISCONNECT 0X4001000C /* Remote NDIS message types */ -#define REMOTE_NDIS_PACKET_MSG 0x00000001 -#define REMOTE_NDIS_INITIALIZE_MSG 0X00000002 -#define REMOTE_NDIS_HALT_MSG 0X00000003 -#define REMOTE_NDIS_QUERY_MSG 0X00000004 -#define REMOTE_NDIS_SET_MSG 0X00000005 -#define REMOTE_NDIS_RESET_MSG 0X00000006 +#define REMOTE_NDIS_PACKET_MSG 0x00000001 +#define REMOTE_NDIS_INITIALIZE_MSG 0X00000002 +#define REMOTE_NDIS_HALT_MSG 0X00000003 +#define REMOTE_NDIS_QUERY_MSG 0X00000004 +#define REMOTE_NDIS_SET_MSG 0X00000005 +#define REMOTE_NDIS_RESET_MSG 0X00000006 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0X00000007 -#define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008 -#define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002 -#define REMOTE_NDIS_QUERY_CMPLT 0X80000004 -#define REMOTE_NDIS_SET_CMPLT 0X80000005 -#define REMOTE_NDIS_RESET_CMPLT 0X80000006 -#define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008 +#define REMOTE_NDIS_KEEPALIVE_MSG 0X00000008 +#define REMOTE_NDIS_INITIALIZE_CMPLT 0X80000002 +#define REMOTE_NDIS_QUERY_CMPLT 0X80000004 +#define REMOTE_NDIS_SET_CMPLT 0X80000005 +#define REMOTE_NDIS_RESET_CMPLT 0X80000006 +#define REMOTE_NDIS_KEEPALIVE_CMPLT 0X80000008 /* device flags */ -#define RNDIS_DF_CONNECTIONLESS 0x00000001 -#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 +#define RNDIS_DF_CONNECTIONLESS 0x00000001 +#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002 /* mediums */ -#define RNDIS_MEDIUM_802_3 0x00000000 +#define RNDIS_MEDIUM_802_3 0x00000000 struct ucls_rndis { @@ -64,24 +64,24 @@ struct ucls_rndis /* Remote NDIS generic message type */ struct rndis_gen_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; }; typedef struct rndis_gen_msg* rndis_gen_msg_t; struct rndis_packet_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t DataOffset; - rt_uint32_t DataLength; - rt_uint32_t OOBDataOffset; - rt_uint32_t OOBDataLength; - rt_uint32_t NumOOBDataElements; - rt_uint32_t PerPacketInfoOffset; - rt_uint32_t PerPacketInfoLength; - rt_uint32_t VcHandle; - rt_uint32_t Reserved; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t DataOffset; + rt_uint32_t DataLength; + rt_uint32_t OOBDataOffset; + rt_uint32_t OOBDataLength; + rt_uint32_t NumOOBDataElements; + rt_uint32_t PerPacketInfoOffset; + rt_uint32_t PerPacketInfoLength; + rt_uint32_t VcHandle; + rt_uint32_t Reserved; }; typedef struct rndis_packet_msg* rndis_packet_msg_t; @@ -89,132 +89,132 @@ typedef struct rndis_packet_msg* rndis_packet_msg_t; struct rndis_init_msg { rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t MajorVersion; - rt_uint32_t MinorVersion; - rt_uint32_t MaxTransferSize; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t MajorVersion; + rt_uint32_t MinorVersion; + rt_uint32_t MaxTransferSize; }; typedef struct rndis_init_msg* rndis_init_msg_t; /* Response */ struct rndis_init_cmplt { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t Status; - rt_uint32_t MajorVersion; - rt_uint32_t MinorVersion; - rt_uint32_t DeviceFlags; - rt_uint32_t Medium; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t Status; + rt_uint32_t MajorVersion; + rt_uint32_t MinorVersion; + rt_uint32_t DeviceFlags; + rt_uint32_t Medium; rt_uint32_t MaxPacketsPerTransfer; - rt_uint32_t MaxTransferSize; + rt_uint32_t MaxTransferSize; rt_uint32_t PacketAlignmentFactor; - rt_uint32_t AfListOffset; - rt_uint32_t AfListSize; + rt_uint32_t AfListOffset; + rt_uint32_t AfListSize; }; typedef struct rndis_init_cmplt* rndis_init_cmplt_t; /* Remote NDIS Halt Message */ struct rndis_halt_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; }; /* Remote NDIS Query Message */ struct rndis_query_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t Oid; - rt_uint32_t InformationBufferLength; - rt_uint32_t InformationBufferOffset; - rt_uint32_t DeviceVcHandle; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t Oid; + rt_uint32_t InformationBufferLength; + rt_uint32_t InformationBufferOffset; + rt_uint32_t DeviceVcHandle; }; typedef struct rndis_query_msg* rndis_query_msg_t; /* Response */ struct rndis_query_cmplt { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t Status; - rt_uint32_t InformationBufferLength; - rt_uint32_t InformationBufferOffset; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t Status; + rt_uint32_t InformationBufferLength; + rt_uint32_t InformationBufferOffset; }; typedef struct rndis_query_cmplt* rndis_query_cmplt_t; /* Remote NDIS Set Message */ struct rndis_set_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t Oid; - rt_uint32_t InformationBufferLength; - rt_uint32_t InformationBufferOffset; - rt_uint32_t DeviceVcHandle; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t Oid; + rt_uint32_t InformationBufferLength; + rt_uint32_t InformationBufferOffset; + rt_uint32_t DeviceVcHandle; }; typedef struct rndis_set_msg* rndis_set_msg_t; /* Response */ struct rndis_set_cmplt { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t Status; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t Status; }; typedef struct rndis_set_cmplt* rndis_set_cmplt_t; /* Remote NDIS Soft Reset Message */ struct rndis_reset_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t Reserved; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t Reserved; }; /* Remote NDIS Soft Reset Response */ struct rndis_reset_cmplt { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t Status; - rt_uint32_t AddressingReset; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t Status; + rt_uint32_t AddressingReset; }; /* Remote NDIS Indicate Status Message */ struct rndis_indicate_status_msg { rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t Status; - rt_uint32_t StatusBufferLength; - rt_uint32_t StatusBufferOffset; + rt_uint32_t MessageLength; + rt_uint32_t Status; + rt_uint32_t StatusBufferLength; + rt_uint32_t StatusBufferOffset; }; typedef struct rndis_indicate_status_msg* rndis_indicate_status_msg_t; struct rndis_keepalive_msg { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestID; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestID; }; typedef struct rndis_keepalive_msg* rndis_keepalive_msg_t; /* Response: */ struct rndis_keepalive_cmplt { - rt_uint32_t MessageType; - rt_uint32_t MessageLength; - rt_uint32_t RequestId; - rt_uint32_t Status; + rt_uint32_t MessageType; + rt_uint32_t MessageLength; + rt_uint32_t RequestId; + rt_uint32_t Status; }; typedef struct rndis_keepalive_cmplt* rndis_keepalive_cmplt_t; diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c index 4af6dba3cf..0db3de794a 100644 --- a/components/drivers/usb/usbdevice/class/winusb.c +++ b/components/drivers/usb/usbdevice/class/winusb.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -57,7 +57,7 @@ static struct usb_qualifier_descriptor dev_qualifier = }; ALIGN(4) -struct winusb_descriptor _winusb_desc = +struct winusb_descriptor _winusb_desc = { #ifdef RT_USB_DEVICE_COMPOSITE /* Interface Association Descriptor */ @@ -117,13 +117,13 @@ const static char* _ustring[] = }; ALIGN(4) -struct usb_os_proerty winusb_proerty[] = +struct usb_os_proerty winusb_proerty[] = { USB_OS_PROPERTY_DESC(USB_OS_PROPERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID), }; ALIGN(4) -struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc = +struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc = { .bFirstInterfaceNumber = USB_DYNAMIC, .reserved1 = 0x01, @@ -155,7 +155,7 @@ static ufunction_t cmd_func = RT_NULL; static rt_err_t _ep0_cmd_handler(udevice_t device, rt_size_t size) { winusb_device_t winusb_device; - + if(cmd_func != RT_NULL) { winusb_device = (winusb_device_t)cmd_func->user_data; @@ -191,7 +191,7 @@ static rt_err_t _interface_handler(ufunction_t func, ureq_t setup) _ep0_cmd_read(func, setup); break; } - + return RT_EOK; } static rt_err_t _function_enable(ufunction_t func) @@ -291,7 +291,7 @@ static rt_err_t rt_usb_winusb_init(ufunction_t func) winusb_device->parent.user_data = func; - + return rt_device_register(&winusb_device->parent, "winusb", RT_DEVICE_FLAG_RDWR); } @@ -352,7 +352,7 @@ ufunction_t rt_usbd_function_winusb_create(udevice_t device) return func; } -struct udclass winusb_class = +struct udclass winusb_class = { .rt_usbd_function_create = rt_usbd_function_winusb_create }; diff --git a/components/drivers/usb/usbdevice/class/winusb.h b/components/drivers/usb/usbdevice/class/winusb.h index b5f87b4e56..43fec34b6a 100644 --- a/components/drivers/usb/usbdevice/class/winusb.h +++ b/components/drivers/usb/usbdevice/class/winusb.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbdevice/core/usbdevice.c b/components/drivers/usb/usbdevice/core/usbdevice.c index 2455bd8017..0891c0bd26 100644 --- a/components/drivers/usb/usbdevice/core/usbdevice.c +++ b/components/drivers/usb/usbdevice/core/usbdevice.c @@ -1,9 +1,9 @@ /* * File : hid.c - * COPYRIGHT (C) 2008 - 2018, RT-Thread Development Team + * COPYRIGHT (C) 2006 - 2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2012-10-02 Yi Qiu first version @@ -62,7 +62,7 @@ static struct usb_qualifier_descriptor dev_qualifier = }; #endif -struct usb_os_comp_id_descriptor usb_comp_id_desc = +struct usb_os_comp_id_descriptor usb_comp_id_desc = { //head section { diff --git a/components/drivers/usb/usbdevice/core/usbdevice_core.c b/components/drivers/usb/usbdevice/core/usbdevice_core.c index ef569d7bf2..fd205ad37f 100644 --- a/components/drivers/usb/usbdevice/core/usbdevice_core.c +++ b/components/drivers/usb/usbdevice/core/usbdevice_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -238,7 +238,7 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup) rt_uint8_t value; uintf_t intf; ufunction_t func; - + /* parameter check */ RT_ASSERT(device != RT_NULL); RT_ASSERT(setup != RT_NULL); @@ -262,7 +262,7 @@ static rt_err_t _get_interface(struct udevice* device, ureq_t setup) { intf->handler(func, setup); } - + return RT_EOK; } @@ -293,7 +293,7 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup) rt_usbd_ep0_set_stall(device); return -RT_ERROR; } - + /* find the specified interface */ intf = rt_usbd_find_interface(device, setup->wIndex & 0xFF, &func); @@ -309,12 +309,12 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup) dcd_ep_enable(device->dcd, ep); } dcd_ep0_send_status(device->dcd); - + if (intf->handler) { intf->handler(func, setup); } - + return RT_EOK; } @@ -336,7 +336,7 @@ static rt_err_t _get_config(struct udevice* device, ureq_t setup) RT_ASSERT(device->curr_cfg != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("_get_config\n")); - + if (device->state == USB_STATE_CONFIGURED) { /* get current configuration */ @@ -443,7 +443,7 @@ static rt_err_t _set_address(struct udevice* device, ureq_t setup) dcd_ep0_send_status(device->dcd); RT_DEBUG_LOG(RT_DEBUG_USB, ("_set_address\n")); - + device->state = USB_STATE_ADDRESS; return RT_EOK; @@ -479,7 +479,7 @@ static rt_err_t _request_interface(struct udevice* device, ureq_t setup) { ret = -RT_ERROR; } - + return ret; } @@ -564,9 +564,9 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup) case USB_REQ_GET_STATUS: { uep_t ep; - + ep = rt_usbd_find_endpoint(device, RT_NULL, setup->wIndex); - value = ep->stalled; + value = ep->stalled; rt_usbd_ep0_write(device, &value, 2); } break; @@ -581,13 +581,13 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup) { rt_usbd_clear_feature(device, setup->wValue, setup->wIndex); dcd_ep0_send_status(dcd); - ep->stalled = RT_FALSE; + ep->stalled = RT_FALSE; for (node = ep->request_list.next; node != &ep->request_list; node = node->next) { - req = (uio_request_t)rt_list_entry(node, struct uio_request, list); + req = (uio_request_t)rt_list_entry(node, struct uio_request, list); rt_usbd_io_request(device, ep, req); - RT_DEBUG_LOG(RT_DEBUG_USB, ("fired a request\n")); + RT_DEBUG_LOG(RT_DEBUG_USB, ("fired a request\n")); } rt_list_init(&ep->request_list); @@ -601,10 +601,10 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup) if(USB_EP_HALT == setup->wValue) { ep = rt_usbd_find_endpoint(device, RT_NULL, setup->wIndex); - ep->stalled = RT_TRUE; + ep->stalled = RT_TRUE; rt_usbd_set_feature(device, setup->wValue, setup->wIndex); dcd_ep0_send_status(dcd); - } + } } break; case USB_REQ_SYNCH_FRAME: @@ -698,7 +698,7 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup) { rt_uint8_t * pusb_comp_id_desc; rt_list_t *p; - usb_comp_id_desc_size = sizeof(struct usb_os_header_comp_id_descriptor) + + usb_comp_id_desc_size = sizeof(struct usb_os_header_comp_id_descriptor) + (sizeof(struct usb_os_function_comp_id_descriptor)-sizeof(rt_list_t))*rt_list_len(&device->os_comp_id_desc->func_desc); usb_comp_id_desc = (rt_uint8_t *)rt_malloc(usb_comp_id_desc_size); @@ -707,7 +707,7 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup) pusb_comp_id_desc = usb_comp_id_desc; rt_memcpy((void *)pusb_comp_id_desc,(void *)&device->os_comp_id_desc->head_desc,sizeof(struct usb_os_header_comp_id_descriptor)); pusb_comp_id_desc += sizeof(struct usb_os_header_comp_id_descriptor); - + for (p = device->os_comp_id_desc->func_desc.next; p != &device->os_comp_id_desc->func_desc; p = p->next) { func_comp_id_desc = rt_list_entry(p,struct usb_os_function_comp_id_descriptor,list); @@ -726,7 +726,7 @@ static rt_err_t _vendor_request(udevice_t device, ureq_t setup) } break; } - + break; } return RT_EOK; @@ -784,7 +784,7 @@ static rt_err_t _setup_request(udevice_t device, ureq_t setup) /** * This function will hanle data notify event. * - * @param device the usb device object. + * @param device the usb device object. * @param ep_msg the endpoint message. * * @return RT_EOK. @@ -794,18 +794,18 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg) uep_t ep; ufunction_t func; rt_size_t size = 0; - + RT_ASSERT(device != RT_NULL); RT_ASSERT(ep_msg != RT_NULL); - + if (device->state != USB_STATE_CONFIGURED) { return -RT_ERROR; } - + ep = rt_usbd_find_endpoint(device, &func, ep_msg->ep_addr); if(ep == RT_NULL) - { + { rt_kprintf("invalid endpoint\n"); return -RT_ERROR; } @@ -817,7 +817,7 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg) { dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer, EP_MAXPACKET(ep)); ep->request.remain_size -= EP_MAXPACKET(ep); - ep->request.buffer += EP_MAXPACKET(ep); + ep->request.buffer += EP_MAXPACKET(ep); } else if(ep->request.remain_size > 0) { @@ -834,9 +834,9 @@ static rt_err_t _data_notify(udevice_t device, struct ep_msg* ep_msg) size = ep_msg->size; if(ep->request.remain_size == 0) { - return RT_EOK; + return RT_EOK; } - + if(size == 0) { size = dcd_ep_read(device->dcd, EP_ADDRESS(ep), ep->request.buffer); @@ -865,9 +865,9 @@ static rt_err_t _ep0_out_notify(udevice_t device, struct ep_msg* ep_msg) { uep_t ep0; rt_size_t size; - + RT_ASSERT(device != RT_NULL); - RT_ASSERT(ep_msg != RT_NULL); + RT_ASSERT(ep_msg != RT_NULL); RT_ASSERT(device->dcd != RT_NULL); ep0 = &device->dcd->ep0; @@ -875,18 +875,18 @@ static rt_err_t _ep0_out_notify(udevice_t device, struct ep_msg* ep_msg) if(ep0->request.remain_size == 0) { - return RT_EOK; - } + return RT_EOK; + } if(size == 0) { size = dcd_ep_read(device->dcd, EP0_OUT_ADDR, ep0->request.buffer); if(size == 0) { return RT_EOK; - } + } } - ep0->request.remain_size -= size; + ep0->request.remain_size -= size; ep0->request.buffer += size; if(ep0->request.remain_size == 0) { @@ -894,7 +894,7 @@ static rt_err_t _ep0_out_notify(udevice_t device, struct ep_msg* ep_msg) if(ep0->rx_indicate != RT_NULL) { ep0->rx_indicate(device, size); - } + } } else { @@ -959,10 +959,10 @@ static rt_err_t _stop_notify(udevice_t device) static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_size_t size) { rt_uint16_t maxpacket; - - RT_ASSERT(device != RT_NULL); + + RT_ASSERT(device != RT_NULL); RT_ASSERT(device->dcd != RT_NULL); - RT_ASSERT(ep != RT_NULL); + RT_ASSERT(ep != RT_NULL); rt_enter_critical(); maxpacket = EP_MAXPACKET(ep); @@ -970,11 +970,11 @@ static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_s { dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer, maxpacket); ep->request.remain_size -= maxpacket; - ep->request.buffer += maxpacket; + ep->request.buffer += maxpacket; } else { - dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer, + dcd_ep_write(device->dcd, EP_ADDRESS(ep), ep->request.buffer, ep->request.remain_size); ep->request.remain_size = 0; } @@ -984,9 +984,9 @@ static rt_size_t rt_usbd_ep_write(udevice_t device, uep_t ep, void *buffer, rt_s static rt_size_t rt_usbd_ep_read_prepare(udevice_t device, uep_t ep, void *buffer, rt_size_t size) { - RT_ASSERT(device != RT_NULL); + RT_ASSERT(device != RT_NULL); RT_ASSERT(device->dcd != RT_NULL); - RT_ASSERT(ep != RT_NULL); + RT_ASSERT(ep != RT_NULL); RT_ASSERT(buffer != RT_NULL); RT_ASSERT(ep->ep_desc != RT_NULL); @@ -1705,7 +1705,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value) device->curr_cfg = cfg; dcd_set_config(device->dcd, value); - + return RT_TRUE; } @@ -1713,7 +1713,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value) * This function will bRequest an IO transaction. * * @param device the usb device object. - * @param ep the endpoint object. + * @param ep the endpoint object. * @param req IO bRequest. * * @return RT_EOK. @@ -1721,7 +1721,7 @@ rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value) rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req) { rt_size_t size = 0; - + RT_ASSERT(device != RT_NULL); RT_ASSERT(req != RT_NULL); @@ -1747,7 +1747,7 @@ rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req) { rt_list_insert_before(&ep->request_list, &req->list); RT_DEBUG_LOG(RT_DEBUG_USB, ("suspend a request\n")); - } + } return size; } @@ -1770,10 +1770,10 @@ rt_err_t rt_usbd_set_feature(udevice_t device, rt_uint16_t value, rt_uint16_t in } else if (value == USB_FEATURE_ENDPOINT_HALT) { - RT_DEBUG_LOG(RT_DEBUG_USB, ("set feature stall\n")); + RT_DEBUG_LOG(RT_DEBUG_USB, ("set feature stall\n")); dcd_ep_set_stall(device->dcd, (rt_uint32_t)(index & 0xFF)); } - + return RT_EOK; } @@ -1798,38 +1798,38 @@ rt_err_t rt_usbd_clear_feature(udevice_t device, rt_uint16_t value, rt_uint16_t RT_DEBUG_LOG(RT_DEBUG_USB, ("clear feature stall\n")); dcd_ep_clear_stall(device->dcd, (rt_uint32_t)(index & 0xFF)); } - + return RT_EOK; } rt_err_t rt_usbd_ep0_set_stall(udevice_t device) { RT_ASSERT(device != RT_NULL); - + return dcd_ep_set_stall(device->dcd, 0); } rt_err_t rt_usbd_ep0_clear_stall(udevice_t device) { RT_ASSERT(device != RT_NULL); - + return dcd_ep_clear_stall(device->dcd, 0); } rt_err_t rt_usbd_ep_set_stall(udevice_t device, uep_t ep) { rt_err_t ret; - + RT_ASSERT(device != RT_NULL); RT_ASSERT(ep != RT_NULL); - RT_ASSERT(ep->ep_desc != RT_NULL); + RT_ASSERT(ep->ep_desc != RT_NULL); ret = dcd_ep_set_stall(device->dcd, EP_ADDRESS(ep)); if(ret == RT_EOK) { ep->stalled = RT_TRUE; } - + return ret; } @@ -1846,44 +1846,44 @@ rt_err_t rt_usbd_ep_clear_stall(udevice_t device, uep_t ep) { ep->stalled = RT_FALSE; } - + return ret; } static rt_err_t rt_usbd_ep_assign(udevice_t device, uep_t ep) { int i = 0; - + RT_ASSERT(device != RT_NULL); - RT_ASSERT(device->dcd != RT_NULL); - RT_ASSERT(device->dcd->ep_pool != RT_NULL); + RT_ASSERT(device->dcd != RT_NULL); + RT_ASSERT(device->dcd->ep_pool != RT_NULL); RT_ASSERT(ep != RT_NULL); RT_ASSERT(ep->ep_desc != RT_NULL); while(device->dcd->ep_pool[i].addr != 0xFF) { - if(device->dcd->ep_pool[i].status == ID_UNASSIGNED && + if(device->dcd->ep_pool[i].status == ID_UNASSIGNED && ep->ep_desc->bmAttributes == device->dcd->ep_pool[i].type && (EP_ADDRESS(ep) & 0x80) == device->dcd->ep_pool[i].dir) { EP_ADDRESS(ep) |= device->dcd->ep_pool[i].addr; ep->id = &device->dcd->ep_pool[i]; device->dcd->ep_pool[i].status = ID_ASSIGNED; - RT_DEBUG_LOG(RT_DEBUG_USB, ("assigned %d\n", device->dcd->ep_pool[i].addr)); + RT_DEBUG_LOG(RT_DEBUG_USB, ("assigned %d\n", device->dcd->ep_pool[i].addr)); return RT_EOK; } - + i++; } - + return -RT_ERROR; } rt_err_t rt_usbd_ep_unassign(udevice_t device, uep_t ep) { RT_ASSERT(device != RT_NULL); - RT_ASSERT(device->dcd != RT_NULL); - RT_ASSERT(device->dcd->ep_pool != RT_NULL); + RT_ASSERT(device->dcd != RT_NULL); + RT_ASSERT(device->dcd->ep_pool != RT_NULL); RT_ASSERT(ep != RT_NULL); RT_ASSERT(ep->ep_desc != RT_NULL); @@ -1911,8 +1911,8 @@ rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct urequest* setup) else { rt_memcpy((void*)&msg.content.setup, (void*)setup, sizeof(struct urequest)); - } - + } + msg.type = USB_MSG_SETUP_NOTIFY; msg.dcd = dcd; rt_usbd_event_signal(&msg); @@ -2011,7 +2011,7 @@ rt_err_t rt_usbd_reset_handler(udcd_t dcd) struct udev_msg msg; RT_ASSERT(dcd != RT_NULL); - + msg.type = USB_MSG_RESET; msg.dcd = dcd; rt_usbd_event_signal(&msg); @@ -2024,7 +2024,7 @@ rt_err_t rt_usbd_connect_handler(udcd_t dcd) struct udev_msg msg; RT_ASSERT(dcd != RT_NULL); - + msg.type = USB_MSG_PLUG_IN; msg.dcd = dcd; rt_usbd_event_signal(&msg); @@ -2037,7 +2037,7 @@ rt_err_t rt_usbd_disconnect_handler(udcd_t dcd) struct udev_msg msg; RT_ASSERT(dcd != RT_NULL); - + msg.type = USB_MSG_PLUG_OUT; msg.dcd = dcd; rt_usbd_event_signal(&msg); @@ -2050,7 +2050,7 @@ rt_err_t rt_usbd_sof_handler(udcd_t dcd) struct udev_msg msg; RT_ASSERT(dcd != RT_NULL); - + msg.type = USB_MSG_SOF; msg.dcd = dcd; rt_usbd_event_signal(&msg); @@ -2063,7 +2063,7 @@ rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size) uep_t ep0; rt_size_t sent_size = 0; - RT_ASSERT(device != RT_NULL); + RT_ASSERT(device != RT_NULL); RT_ASSERT(device->dcd != RT_NULL); RT_ASSERT(buffer != RT_NULL); RT_ASSERT(size > 0); @@ -2085,7 +2085,7 @@ rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size) return dcd_ep_write(device->dcd, EP0_IN_ADDR, ep0->request.buffer, sent_size); } -rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size, +rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size, rt_err_t (*rx_ind)(udevice_t device, rt_size_t size)) { uep_t ep0; @@ -2096,7 +2096,7 @@ rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size, RT_ASSERT(buffer != RT_NULL); ep0 = &device->dcd->ep0; - ep0->request.buffer = (rt_uint8_t *)buffer; + ep0->request.buffer = (rt_uint8_t *)buffer; ep0->request.remain_size = size; ep0->rx_indicate = rx_ind; if(size >= ep0->id->maxpacket) @@ -2143,7 +2143,7 @@ static void rt_usbd_thread_entry(void* parameter) } RT_DEBUG_LOG(RT_DEBUG_USB, ("message type %d\n", msg.type)); - + switch (msg.type) { case USB_MSG_SOF: @@ -2160,7 +2160,7 @@ static void rt_usbd_thread_entry(void* parameter) case USB_MSG_EP0_OUT: _ep0_out_notify(device, &msg.content.ep_msg); break; - case USB_MSG_RESET: + case USB_MSG_RESET: RT_DEBUG_LOG(RT_DEBUG_USB, ("reset %d\n", device->state)); if (device->state == USB_STATE_ADDRESS || device->state == USB_STATE_CONFIGURED) _stop_notify(device); @@ -2170,7 +2170,7 @@ static void rt_usbd_thread_entry(void* parameter) device->state = USB_STATE_ATTACHED; break; case USB_MSG_PLUG_OUT: - device->state = USB_STATE_NOTATTACHED; + device->state = USB_STATE_NOTATTACHED; _stop_notify(device); break; default: diff --git a/components/drivers/usb/usbhost/class/adk.c b/components/drivers/usb/usbhost/class/adk.c index 2425de7bba..492a2f9bb7 100644 --- a/components/drivers/usb/usbhost/class/adk.c +++ b/components/drivers/usb/usbhost/class/adk.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbhost/class/adk.h b/components/drivers/usb/usbhost/class/adk.h index c582ad7f17..aebe7de705 100644 --- a/components/drivers/usb/usbhost/class/adk.h +++ b/components/drivers/usb/usbhost/class/adk.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -19,7 +19,7 @@ struct uadkinst upipe_t pipe_out; struct rt_device device; -}; +}; typedef struct uadkinst* uadk_t; #define USB_ACCESSORY_VENDOR_ID 0x18D1 diff --git a/components/drivers/usb/usbhost/class/hid.c b/components/drivers/usb/usbhost/class/hid.c index b097b01679..eaf413a2a6 100644 --- a/components/drivers/usb/usbhost/class/hid.c +++ b/components/drivers/usb/usbhost/class/hid.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -24,22 +24,22 @@ static rt_list_t _protocal_list; * @param intf the interface instance. * @duration the idle period of requesting data. * @report_id the report id - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hid_set_idle(struct uhintf* intf, int duration, int report_id) { struct urequest setup; - struct uinstance* device; + struct uinstance* device; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(intf != RT_NULL); RT_ASSERT(intf->device != RT_NULL); device = intf->device; - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE; setup.bRequest = USB_REQ_SET_IDLE; setup.wIndex = 0; @@ -49,7 +49,7 @@ rt_err_t rt_usbh_hid_set_idle(struct uhintf* intf, int duration, int report_id) if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8) return RT_EOK; else - return -RT_FALSE; + return -RT_FALSE; } /** @@ -58,23 +58,23 @@ rt_err_t rt_usbh_hid_set_idle(struct uhintf* intf, int duration, int report_id) * @param intf the interface instance. * @buffer the data buffer to save usb report descriptor. * @param nbytes the size of buffer - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_hid_get_report(struct uhintf* intf, rt_uint8_t type, +rt_err_t rt_usbh_hid_get_report(struct uhintf* intf, rt_uint8_t type, rt_uint8_t id, rt_uint8_t *buffer, rt_size_t size) { struct urequest setup; struct uinstance* device; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(intf != RT_NULL); RT_ASSERT(intf->device != RT_NULL); device = intf->device; - setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE; setup.bRequest = USB_REQ_GET_REPORT; setup.wIndex = intf->intf_desc->bInterfaceNumber; @@ -93,7 +93,7 @@ rt_err_t rt_usbh_hid_get_report(struct uhintf* intf, rt_uint8_t type, } else return -RT_FALSE; - return -RT_FALSE; + return -RT_FALSE; } /** @@ -102,22 +102,22 @@ rt_err_t rt_usbh_hid_get_report(struct uhintf* intf, rt_uint8_t type, * @param intf the interface instance. * @buffer the data buffer to save usb report descriptor. * @param nbytes the size of buffer - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hid_set_report(struct uhintf* intf, rt_uint8_t *buffer, rt_size_t size) { struct urequest setup; - struct uinstance* device; + struct uinstance* device; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(intf != RT_NULL); RT_ASSERT(intf->device != RT_NULL); - + device = intf->device; - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE; setup.bRequest = USB_REQ_SET_REPORT; setup.wIndex = intf->intf_desc->bInterfaceNumber; @@ -127,7 +127,7 @@ rt_err_t rt_usbh_hid_set_report(struct uhintf* intf, rt_uint8_t *buffer, rt_size if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8) return RT_EOK; else - return -RT_FALSE; + return -RT_FALSE; } /** @@ -135,7 +135,7 @@ rt_err_t rt_usbh_hid_set_report(struct uhintf* intf, rt_uint8_t *buffer, rt_size * * @param intf the interface instance. * @param protocol the protocol id. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hid_set_protocal(struct uhintf* intf, int protocol) @@ -143,14 +143,14 @@ rt_err_t rt_usbh_hid_set_protocal(struct uhintf* intf, int protocol) struct urequest setup; struct uinstance* device; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(intf != RT_NULL); RT_ASSERT(intf->device != RT_NULL); - + device = intf->device; - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE; setup.bRequest = USB_REQ_SET_PROTOCOL; setup.wIndex = 0; @@ -160,33 +160,33 @@ rt_err_t rt_usbh_hid_set_protocal(struct uhintf* intf, int protocol) if (rt_usb_hcd_setup_xfer(device->hcd, device->pipe_ep0_out, &setup, timeout) == 8) return RT_EOK; else - return -RT_FALSE; + return -RT_FALSE; } /** - * This function will do USB_REQ_GET_DESCRIPTOR request for the device instance + * This function will do USB_REQ_GET_DESCRIPTOR request for the device instance * to set feature of the hub port. * * @param intf the interface instance. * @buffer the data buffer to save usb report descriptor. * @param nbytes the size of buffer - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_hid_get_report_descriptor(struct uhintf* intf, +rt_err_t rt_usbh_hid_get_report_descriptor(struct uhintf* intf, rt_uint8_t *buffer, rt_size_t size) { struct urequest setup; - struct uinstance* device; + struct uinstance* device; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(intf != RT_NULL); RT_ASSERT(intf->device != RT_NULL); - + device = intf->device; - setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD| + setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD| USB_REQ_TYPE_INTERFACE; setup.bRequest = USB_REQ_GET_DESCRIPTOR; setup.wIndex = 0; @@ -212,7 +212,7 @@ rt_err_t rt_usbh_hid_get_report_descriptor(struct uhintf* intf, * This function will register specified hid protocal to protocal list * * @param protocal the specified protocal. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hid_protocal_register(uprotocal_t protocal) @@ -223,26 +223,26 @@ rt_err_t rt_usbh_hid_protocal_register(uprotocal_t protocal) /* insert class driver into driver list */ rt_list_insert_after(&_protocal_list, &(protocal->list)); - - return RT_EOK; + + return RT_EOK; } /** * This function is the callback function of hid's int endpoint, it is invoked when data comes. * * @param context the context of the callback function. - * + * * @return none. */ static void rt_usbh_hid_callback(void* context) { - upipe_t pipe; + upipe_t pipe; struct uhid* hid; int timeout = USB_TIMEOUT_LONG; /* parameter check */ RT_ASSERT(context != RT_NULL); - + pipe = (upipe_t)context; hid = (struct uhid*)((struct uhintf*)pipe->inst)->user_data; @@ -252,7 +252,7 @@ static void rt_usbh_hid_callback(void* context) /* parameter check */ RT_ASSERT(((struct uhintf*)pipe->inst)->device->hcd != RT_NULL); - rt_usb_hcd_pipe_xfer(((struct uhintf*)pipe->inst)->device->hcd, pipe, + rt_usb_hcd_pipe_xfer(((struct uhintf*)pipe->inst)->device->hcd, pipe, hid->buffer, pipe->ep.wMaxPacketSize, timeout); } @@ -260,7 +260,7 @@ static void rt_usbh_hid_callback(void* context) * This function will find specified hid protocal from protocal list * * @param pro_id the protocal id. - * + * * @return the found protocal or RT_NULL if there is no this protocal. */ static uprotocal_t rt_usbh_hid_protocal_find(int pro_id) @@ -270,7 +270,7 @@ static uprotocal_t rt_usbh_hid_protocal_find(int pro_id) /* try to find protocal object */ for (node = _protocal_list.next; node != &_protocal_list; node = node->next) { - uprotocal_t protocal = + uprotocal_t protocal = (uprotocal_t)rt_list_entry(node, struct uprotocal, list); if (protocal->pro_id == pro_id) return protocal; } @@ -284,16 +284,16 @@ static uprotocal_t rt_usbh_hid_protocal_find(int pro_id) * as a hid class device, it will continue the enumulate process. * * @param arg the argument. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t rt_usbh_hid_enable(void* arg) { int i = 0, pro_id; - uprotocal_t protocal; + uprotocal_t protocal; struct uhid* hid; struct uhintf* intf = (struct uhintf*)arg; - + /* parameter check */ if(intf == RT_NULL) { @@ -304,43 +304,43 @@ static rt_err_t rt_usbh_hid_enable(void* arg) pro_id = intf->intf_desc->bInterfaceProtocol; RT_DEBUG_LOG(RT_DEBUG_USB, - ("HID device enable, protocal id %d\n", pro_id)); + ("HID device enable, protocal id %d\n", pro_id)); - protocal = rt_usbh_hid_protocal_find(pro_id); + protocal = rt_usbh_hid_protocal_find(pro_id); if(protocal == RT_NULL) { rt_kprintf("can't find hid protocal %d\n", pro_id); - intf->user_data = RT_NULL; + intf->user_data = RT_NULL; return -RT_ERROR; } - + hid = rt_malloc(sizeof(struct uhid)); RT_ASSERT(hid != RT_NULL); - /* initilize the data structure */ + /* initilize the data structure */ rt_memset(hid, 0, sizeof(struct uhid)); intf->user_data = (void*)hid; hid->protocal = protocal; - + for(i=0; iintf_desc->bNumEndpoints; i++) - { + { rt_err_t ret; uep_desc_t ep_desc; - /* get endpoint descriptor */ + /* get endpoint descriptor */ rt_usbh_get_endpoint_descriptor(intf->intf_desc, i, &ep_desc); if(ep_desc == RT_NULL) { rt_kprintf("rt_usbh_get_endpoint_descriptor error\n"); return -RT_ERROR; } - - if(USB_EP_ATTR(ep_desc->bmAttributes) != USB_EP_ATTR_INT) + + if(USB_EP_ATTR(ep_desc->bmAttributes) != USB_EP_ATTR_INT) continue; - + if(!(ep_desc->bEndpointAddress & USB_DIR_IN)) continue; - ret = rt_usb_hcd_alloc_pipe(intf->device->hcd, &hid->pipe_in, + ret = rt_usb_hcd_alloc_pipe(intf->device->hcd, &hid->pipe_in, intf, ep_desc); if(ret != RT_EOK) return ret; } @@ -352,11 +352,11 @@ static rt_err_t rt_usbh_hid_enable(void* arg) } /** - * This function will be invoked when usb device plug out is detected and it would clean + * This function will be invoked when usb device plug out is detected and it would clean * and release all hub class related resources. * * @param arg the argument. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t rt_usbh_hid_disable(void* arg) @@ -377,7 +377,7 @@ static rt_err_t rt_usbh_hid_disable(void* arg) rt_usb_hcd_free_pipe(intf->device->hcd, hid->pipe_in); } - /* free the hid instance */ + /* free the hid instance */ rt_free(hid); } @@ -387,7 +387,7 @@ static rt_err_t rt_usbh_hid_disable(void* arg) /** * This function will register hid class driver to the usb class driver manager. * and it should be invoked in the usb system initialization. - * + * * @return the error code, RT_EOK on successfully. */ ucd_t rt_usbh_class_driver_hid(void) @@ -395,7 +395,7 @@ ucd_t rt_usbh_class_driver_hid(void) rt_list_init(&_protocal_list); hid_driver.class_code = USB_CLASS_HID; - + hid_driver.enable = rt_usbh_hid_enable; hid_driver.disable = rt_usbh_hid_disable; diff --git a/components/drivers/usb/usbhost/class/hid.h b/components/drivers/usb/usbhost/class/hid.h index dbef84abbe..19b2b09855 100644 --- a/components/drivers/usb/usbhost/class/hid.h +++ b/components/drivers/usb/usbhost/class/hid.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -18,7 +18,7 @@ struct uhid upipe_t pipe_in; rt_uint8_t buffer[8]; uprotocal_t protocal; -}; +}; typedef struct uhid uhid_t; #define USB_REQ_GET_REPORT 0x01 @@ -28,7 +28,7 @@ typedef struct uhid uhid_t; #define USB_REQ_SET_IDLE 0x0a #define USB_REQ_SET_PROTOCOL 0x0b -#define USB_HID_KEYBOARD 1 +#define USB_HID_KEYBOARD 1 #define USB_HID_MOUSE 2 rt_err_t rt_usbh_hid_set_idle(struct uhintf* intf, int duration, int report_id); @@ -38,4 +38,4 @@ rt_err_t rt_usbh_hid_set_protocal(struct uhintf* intf, int protocol); rt_err_t rt_usbh_hid_get_report_descriptor(struct uhintf* intf, rt_uint8_t *buffer, rt_size_t size); rt_err_t rt_usbh_hid_protocal_register(uprotocal_t protocal); -#endif \ No newline at end of file +#endif diff --git a/components/drivers/usb/usbhost/class/mass.c b/components/drivers/usb/usbhost/class/mass.c index 20048873f5..abd89a5efc 100644 --- a/components/drivers/usb/usbhost/class/mass.c +++ b/components/drivers/usb/usbhost/class/mass.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -24,29 +24,29 @@ static struct uclass_driver storage_driver; * * @param intf the interface instance. * @param max_lun the buffer to save max_lun. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe) { - struct uinstance* device; + struct uinstance* device; rt_err_t ret; ustor_t stor; - int size = 0; + int size = 0; struct ustorage_csw csw; if(intf == RT_NULL || pipe == RT_NULL) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } + } - /* get usb device instance from the interface instance */ - device = intf->device; + /* get usb device instance from the interface instance */ + device = intf->device; - /* get storage instance from the interface instance */ + /* get storage instance from the interface instance */ stor = (ustor_t)intf->user_data; - + /* check pipe status */ if(pipe->status == UPIPE_STATUS_OK) return RT_EOK; @@ -58,11 +58,11 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe) if(pipe->status == UPIPE_STATUS_STALL) { /* clear the pipe stall status */ - ret = rt_usbh_clear_feature(device, pipe->ep.bEndpointAddress, + ret = rt_usbh_clear_feature(device, pipe->ep.bEndpointAddress, USB_FEATURE_ENDPOINT_HALT); if(ret != RT_EOK) return ret; } - + rt_thread_delay(50); @@ -73,14 +73,14 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe) RT_DEBUG_LOG(RT_DEBUG_USB, ("clean storage in pipe stall\n")); /* it should receive csw after clear the stall feature */ - size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd, + size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd, stor->pipe_in, &csw, SIZEOF_CSW, 100); - if(size != SIZEOF_CSW) + if(size != SIZEOF_CSW) { rt_kprintf("receive the csw after stall failed\n"); return -RT_EIO; } - + return -RT_ERROR; } @@ -89,35 +89,35 @@ static rt_err_t _pipe_check(struct uhintf* intf, upipe_t pipe) * * @param intf the interface instance. * @param max_lun the buffer to save max_lun. - * + * * @return the error code, RT_EOK on successfully. */ -static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf, +static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf, ustorage_cbw_t cmd, rt_uint8_t* buffer, int timeout) { rt_size_t size; - rt_err_t ret; + rt_err_t ret; upipe_t pipe; struct ustorage_csw csw; ustor_t stor; - RT_ASSERT(cmd != RT_NULL); + RT_ASSERT(cmd != RT_NULL); if(intf == RT_NULL) { rt_kprintf("the interface is not available\n"); return -RT_EIO; } - - /* get storage instance from the interface instance */ + + /* get storage instance from the interface instance */ stor = (ustor_t)intf->user_data; do { /* send the cbw */ - size = rt_usb_hcd_pipe_xfer(stor->pipe_out->inst->hcd, stor->pipe_out, + size = rt_usb_hcd_pipe_xfer(stor->pipe_out->inst->hcd, stor->pipe_out, cmd, SIZEOF_CBW, timeout); - if(size != SIZEOF_CBW) + if(size != SIZEOF_CBW) { rt_kprintf("CBW size error\n"); return -RT_EIO; @@ -126,20 +126,20 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf, { pipe = (cmd->dflags == CBWFLAGS_DIR_IN) ? stor->pipe_in : stor->pipe_out; - size = rt_usb_hcd_pipe_xfer(pipe->inst->hcd, pipe, (void*)buffer, + size = rt_usb_hcd_pipe_xfer(pipe->inst->hcd, pipe, (void*)buffer, cmd->xfer_len, timeout); if(size != cmd->xfer_len) { - rt_kprintf("request size %d, transfer size %d\n", + rt_kprintf("request size %d, transfer size %d\n", cmd->xfer_len, size); break; - } + } } - + /* receive the csw */ - size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd, stor->pipe_in, + size = rt_usb_hcd_pipe_xfer(stor->pipe_in->inst->hcd, stor->pipe_in, &csw, SIZEOF_CSW, timeout); - if(size != SIZEOF_CSW) + if(size != SIZEOF_CSW) { rt_kprintf("csw size error\n"); return -RT_EIO; @@ -148,12 +148,12 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf, /* check in pipes status */ ret = _pipe_check(intf, stor->pipe_in); - if(ret != RT_EOK) + if(ret != RT_EOK) { rt_kprintf("in pipe error\n"); return ret; } - + /* check out pipes status */ ret = _pipe_check(intf, stor->pipe_out); if(ret != RT_EOK) @@ -161,20 +161,20 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf, rt_kprintf("out pipe error\n"); return ret; } - + /* check csw status */ if(csw.signature != CSW_SIGNATURE || csw.tag != CBW_TAG_VALUE) { rt_kprintf("csw signature error\n"); return -RT_EIO; } - + if(csw.status != 0) { //rt_kprintf("csw status error:%d\n",csw.status); return -RT_ERROR; } - + return RT_EOK; } @@ -183,12 +183,12 @@ static rt_err_t rt_usb_bulk_only_xfer(struct uhintf* intf, * * @param intf the interface instance. * @param max_lun the buffer to save max_lun. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun) { - struct uinstance* device; + struct uinstance* device; struct urequest setup; int timeout = USB_TIMEOUT_BASIC; @@ -196,17 +196,17 @@ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } + } /* parameter check */ RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_get_max_lun\n")); - /* get usb device instance from the interface instance */ - device = intf->device; + /* get usb device instance from the interface instance */ + device = intf->device; /* construct the request */ - setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE; setup.bRequest = USBREQ_GET_MAX_LUN; setup.wValue = intf->intf_desc->bInterfaceNumber; @@ -233,13 +233,13 @@ rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun) * This function will do USBREQ_MASS_STORAGE_RESET request for the usb interface instance. * * @param intf the interface instance. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_storage_reset(struct uhintf* intf) { struct urequest setup; - struct uinstance* device; + struct uinstance* device; int timeout = USB_TIMEOUT_BASIC; /* parameter check */ @@ -247,16 +247,16 @@ rt_err_t rt_usbh_storage_reset(struct uhintf* intf) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } + } RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_reset\n")); - /* get usb device instance from the interface instance */ - device = intf->device; + /* get usb device instance from the interface instance */ + device = intf->device; /* construct the request */ - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE; setup.bRequest = USBREQ_MASS_STORAGE_RESET; setup.wIndex = intf->intf_desc->bInterfaceNumber; @@ -279,12 +279,12 @@ rt_err_t rt_usbh_storage_reset(struct uhintf* intf) * * @param intf the interface instance. * @param buffer the data buffer to save read data - * @param sector the start sector address to read. + * @param sector the start sector address to read. * @param sector the sector count to read. - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer, +rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer, rt_uint32_t sector, rt_size_t count, int timeout) { struct ustorage_cbw cmd; @@ -294,8 +294,8 @@ rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer, { rt_kprintf("interface is not available\n"); return -RT_EIO; - } - + } + RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_read10\n")); @@ -325,12 +325,12 @@ rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer, * * @param intf the interface instance. * @param buffer the data buffer to save write data - * @param sector the start sector address to write. + * @param sector the start sector address to write. * @param sector the sector count to write. - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer, +rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer, rt_uint32_t sector, rt_size_t count, int timeout) { struct ustorage_cbw cmd; @@ -340,8 +340,8 @@ rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer, { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } - + } + RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_write10\n")); @@ -371,7 +371,7 @@ rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer, * * @param intf the interface instance. * @param buffer the data buffer to save sense data - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer) @@ -384,12 +384,12 @@ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } - + } + RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_request_sense\n")); - /* construct the command block wrapper */ + /* construct the command block wrapper */ rt_memset(&cmd, 0, sizeof(struct ustorage_cbw)); cmd.signature = CBW_SIGNATURE; cmd.tag = CBW_TAG_VALUE; @@ -407,7 +407,7 @@ rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer) * This function will execute SCSI_TEST_UNIT_READY command to get unit ready status. * * @param intf the interface instance. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf) @@ -420,8 +420,8 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } - + } + RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_test_unit_ready\n")); @@ -434,7 +434,7 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf) cmd.lun = 0; cmd.cb_len = 12; cmd.cb[0] = SCSI_TEST_UNIT_READY; - + return rt_usb_bulk_only_xfer(intf, &cmd, RT_NULL, timeout); } @@ -443,21 +443,21 @@ rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf) * * @param intf the interface instance. * @param buffer the data buffer to save inquiry data - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_storage_inquiry(struct uhintf* intf, rt_uint8_t* buffer) { struct ustorage_cbw cmd; int timeout = USB_TIMEOUT_LONG; - + /* parameter check */ if(intf == RT_NULL) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } - + } + RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_inquiry\n")); @@ -480,7 +480,7 @@ rt_err_t rt_usbh_storage_inquiry(struct uhintf* intf, rt_uint8_t* buffer) * * @param intf the interface instance. * @param buffer the data buffer to save capacity data - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer) @@ -493,7 +493,7 @@ rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer) { rt_kprintf("the interface is not available\n"); return -RT_EIO; - } + } RT_ASSERT(intf->device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_get_capacity\n")); @@ -513,17 +513,17 @@ rt_err_t rt_usbh_storage_get_capacity(struct uhintf* intf, rt_uint8_t* buffer) /** * This function will run mass storage class driver when usb device is detected - * and identified as a mass storage class device, it will continue to do the enumulate + * and identified as a mass storage class device, it will continue to do the enumulate * process. * * @param arg the argument. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t rt_usbh_storage_enable(void* arg) { int i = 0; - rt_err_t ret; + rt_err_t ret; ustor_t stor; struct uhintf* intf = (struct uhintf*)arg; @@ -534,25 +534,25 @@ static rt_err_t rt_usbh_storage_enable(void* arg) return -RT_EIO; } - RT_DEBUG_LOG(RT_DEBUG_USB, ("subclass %d, protocal %d\n", + RT_DEBUG_LOG(RT_DEBUG_USB, ("subclass %d, protocal %d\n", intf->intf_desc->bInterfaceSubClass, intf->intf_desc->bInterfaceProtocol)); - + RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_storage_run\n")); /* only support SCSI subclass and bulk only protocal */ - + stor = rt_malloc(sizeof(struct ustor)); RT_ASSERT(stor != RT_NULL); /* initilize the data structure */ - rt_memset(stor, 0, sizeof(struct ustor)); + rt_memset(stor, 0, sizeof(struct ustor)); intf->user_data = (void*)stor; for(i=0; iintf_desc->bNumEndpoints; i++) - { + { uep_desc_t ep_desc; - + /* get endpoint descriptor from interface descriptor */ rt_usbh_get_endpoint_descriptor(intf->intf_desc, i, &ep_desc); if(ep_desc == RT_NULL) @@ -560,11 +560,11 @@ static rt_err_t rt_usbh_storage_enable(void* arg) rt_kprintf("rt_usb_get_endpoint_descriptor error\n"); return -RT_ERROR; } - - /* the endpoint type of mass storage class should be BULK */ + + /* the endpoint type of mass storage class should be BULK */ if((ep_desc->bmAttributes & USB_EP_ATTR_TYPE_MASK) != USB_EP_ATTR_BULK) continue; - + /* allocate pipes according to the endpoint type */ if(ep_desc->bEndpointAddress & USB_DIR_IN) { @@ -572,7 +572,7 @@ static rt_err_t rt_usbh_storage_enable(void* arg) stor->pipe_in = rt_usb_instance_find_pipe(intf->device,ep_desc->bEndpointAddress); } else - { + { /* alloc an output pipe for the storage instance */ stor->pipe_out = rt_usb_instance_find_pipe(intf->device,ep_desc->bEndpointAddress); } @@ -583,8 +583,8 @@ static rt_err_t rt_usbh_storage_enable(void* arg) { rt_kprintf("pipe error, unsupported device\n"); return -RT_ERROR; - } - + } + /* should implement as callback */ ret = rt_udisk_run(intf); if(ret != RT_EOK) return ret; @@ -593,11 +593,11 @@ static rt_err_t rt_usbh_storage_enable(void* arg) } /** - * This function will be invoked when usb device plug out is detected and it would clean + * This function will be invoked when usb device plug out is detected and it would clean * and release all mass storage class related resources. * * @param arg the argument. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t rt_usbh_storage_disable(void* arg) @@ -617,7 +617,7 @@ static rt_err_t rt_usbh_storage_disable(void* arg) rt_udisk_stop(intf); - + /* free storage instance */ if(stor != RT_NULL) rt_free(stor); return RT_EOK; @@ -626,13 +626,13 @@ static rt_err_t rt_usbh_storage_disable(void* arg) /** * This function will register mass storage class driver to the usb class driver manager. * and it should be invoked in the usb system initialization. - * + * * @return the error code, RT_EOK on successfully. */ ucd_t rt_usbh_class_driver_storage(void) { storage_driver.class_code = USB_CLASS_MASS_STORAGE; - + storage_driver.enable = rt_usbh_storage_enable; storage_driver.disable = rt_usbh_storage_disable; diff --git a/components/drivers/usb/usbhost/class/mass.h b/components/drivers/usb/usbhost/class/mass.h index 770e64a03f..2578fb54c7 100644 --- a/components/drivers/usb/usbhost/class/mass.h +++ b/components/drivers/usb/usbhost/class/mass.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -30,17 +30,17 @@ struct ustor upipe_t pipe_in; upipe_t pipe_out; rt_uint32_t capicity[2]; - + struct rt_device dev[MAX_PARTITION_COUNT]; rt_uint8_t dev_cnt; -}; +}; typedef struct ustor* ustor_t; rt_err_t rt_usbh_storage_get_max_lun(struct uhintf* intf, rt_uint8_t* max_lun); rt_err_t rt_usbh_storage_reset(struct uhintf* intf); -rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer, +rt_err_t rt_usbh_storage_read10(struct uhintf* intf, rt_uint8_t *buffer, rt_uint32_t sector, rt_size_t count, int timeout); -rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer, +rt_err_t rt_usbh_storage_write10(struct uhintf* intf, rt_uint8_t *buffer, rt_uint32_t sector, rt_size_t count, int timeout); rt_err_t rt_usbh_storage_request_sense(struct uhintf* intf, rt_uint8_t* buffer); rt_err_t rt_usbh_storage_test_unit_ready(struct uhintf* intf); diff --git a/components/drivers/usb/usbhost/class/udisk.c b/components/drivers/usb/usbhost/class/udisk.c index 6c8030b29a..8be311e657 100644 --- a/components/drivers/usb/usbhost/class/udisk.c +++ b/components/drivers/usb/usbhost/class/udisk.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbhost/class/ukbd.c b/components/drivers/usb/usbhost/class/ukbd.c index 7d608de259..c89d60cd36 100644 --- a/components/drivers/usb/usbhost/class/ukbd.c +++ b/components/drivers/usb/usbhost/class/ukbd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -14,13 +14,13 @@ #if defined(RT_USBH_HID) && defined(RT_USBH_HID_KEYBOARD) -static struct uprotocal kbd_protocal; +static struct uprotocal kbd_protocal; static rt_err_t rt_usbh_hid_kbd_callback(void* arg) { int int1, int2; - struct uhid* hid; - + struct uhid* hid; + hid = (struct uhid*)arg; int1 = *(rt_uint32_t*)hid->buffer; @@ -28,9 +28,9 @@ static rt_err_t rt_usbh_hid_kbd_callback(void* arg) if(int1 != 0 || int2 != 0) { - RT_DEBUG_LOG(RT_DEBUG_USB, ("key down 0x%x, 0x%x\n", int1, int2)); + RT_DEBUG_LOG(RT_DEBUG_USB, ("key down 0x%x, 0x%x\n", int1, int2)); } - + return RT_EOK; } @@ -38,20 +38,20 @@ static rt_err_t rt_usbh_hid_kbd_init(void* arg) { struct uintf* intf = (struct uintf*)arg; - RT_ASSERT(intf != RT_NULL); - + RT_ASSERT(intf != RT_NULL); + rt_usbh_hid_set_protocal(intf, 0); rt_usbh_hid_set_idle(intf, 10, 0); - //RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb keyboard\n")); + //RT_DEBUG_LOG(RT_DEBUG_USB, ("start usb keyboard\n")); return RT_EOK; } /** * This function will define the hid keyboard protocal, it will be register to the protocal list. - * + * * @return the keyboard protocal structure. */ uprotocal_t rt_usbh_hid_protocal_kbd(void) diff --git a/components/drivers/usb/usbhost/class/umouse.c b/components/drivers/usb/usbhost/class/umouse.c index 7f50c0451f..ae14cba22c 100644 --- a/components/drivers/usb/usbhost/class/umouse.c +++ b/components/drivers/usb/usbhost/class/umouse.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/usb/usbhost/core/driver.c b/components/drivers/usb/usbhost/core/driver.c index 37327108c1..6dad1409a0 100644 --- a/components/drivers/usb/usbhost/core/driver.c +++ b/components/drivers/usb/usbhost/core/driver.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -17,21 +17,21 @@ static rt_list_t _driver_list; /** * This function will initilize the usb class driver related data structure, * and it should be invoked in the usb system initialization. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_class_driver_init(void) { rt_list_init(&_driver_list); - return RT_EOK; + return RT_EOK; } /** * This function will register an usb class driver to the class driver manager. * * @param drv the pointer of the usb class driver. - * + * * @return the error code, RT_EOK on successfully. */ @@ -41,15 +41,15 @@ rt_err_t rt_usbh_class_driver_register(ucd_t drv) /* insert class driver into driver list */ rt_list_insert_after(&_driver_list, &(drv->list)); - - return RT_EOK; + + return RT_EOK; } /** * This function will removes a previously registed usb class driver. * * @param drv the pointer of the usb class driver structure. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_class_driver_unregister(ucd_t drv) @@ -67,7 +67,7 @@ rt_err_t rt_usbh_class_driver_unregister(ucd_t drv) * * @param drv the pointer of usb class driver. * @param args the parameter of run function. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_class_driver_enable(ucd_t drv, void* args) @@ -85,7 +85,7 @@ rt_err_t rt_usbh_class_driver_enable(ucd_t drv, void* args) * * @param drv the pointer of usb class driver structure. * @param args the argument of the stop function. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_class_driver_disable(ucd_t drv, void* args) @@ -102,7 +102,7 @@ rt_err_t rt_usbh_class_driver_disable(ucd_t drv, void* args) /** * This function finds a usb class driver by specified class code and subclass code. * - * @param class_code the usb class driver's class code. + * @param class_code the usb class driver's class code. * @param subclass_code the usb class driver's sub class code. * * @return the registered usb class driver on successful, or RT_NULL on failure. @@ -118,7 +118,7 @@ ucd_t rt_usbh_class_driver_find(int class_code, int subclass_code) /* try to find driver object */ for (node = _driver_list.next; node != &_driver_list; node = node->next) { - ucd_t drv = + ucd_t drv = (ucd_t)rt_list_entry(node, struct uclass_driver, list); if (drv->class_code == class_code) { diff --git a/components/drivers/usb/usbhost/core/hub.c b/components/drivers/usb/usbhost/core/hub.c index eefa571472..b6381ec300 100644 --- a/components/drivers/usb/usbhost/core/hub.c +++ b/components/drivers/usb/usbhost/core/hub.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -77,7 +77,7 @@ static rt_err_t root_hub_ctrl(struct uhcd *hcd, rt_uint16_t port, rt_uint8_t cmd return RT_ERROR; } return RT_EOK; -} +} void rt_usbh_root_hub_connect_handler(struct uhcd *hcd, rt_uint8_t port, rt_bool_t isHS) { struct uhost_msg msg; @@ -106,23 +106,23 @@ void rt_usbh_root_hub_disconnect_handler(struct uhcd *hcd, rt_uint8_t port) } /** - * This function will do USB_REQ_GET_DESCRIPTOR bRequest for the device instance + * This function will do USB_REQ_GET_DESCRIPTOR bRequest for the device instance * to get usb hub descriptor. * * @param intf the interface instance. * @buffer the data buffer to save usb hub descriptor. * @param nbytes the size of buffer - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer, rt_size_t nbytes) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(device != RT_NULL); - + setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_DEVICE; setup.bRequest = USB_REQ_GET_DESCRIPTOR; setup.wIndex = 0; @@ -135,24 +135,24 @@ rt_err_t rt_usbh_hub_get_descriptor(struct uinstance* device, rt_uint8_t *buffer { return RT_EOK; } - } - return -RT_FALSE; + } + return -RT_FALSE; } /** - * This function will do USB_REQ_GET_STATUS bRequest for the device instance + * This function will do USB_REQ_GET_STATUS bRequest for the device instance * to get usb hub status. * * @param intf the interface instance. * @buffer the data buffer to save usb hub status. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint32_t* buffer) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(device != RT_NULL); @@ -168,31 +168,31 @@ rt_err_t rt_usbh_hub_get_status(struct uinstance* device, rt_uint32_t* buffer) return RT_EOK; } } - return -RT_FALSE; + return -RT_FALSE; } /** - * This function will do USB_REQ_GET_STATUS bRequest for the device instance + * This function will do USB_REQ_GET_STATUS bRequest for the device instance * to get hub port status. * * @param intf the interface instance. * @port the hub port to get status. * @buffer the data buffer to save usb hub status. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port, rt_uint32_t* buffer) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(hub != RT_NULL); /* get roothub port status */ if(hub->is_roothub) { - root_hub_ctrl(hub->hcd, port, RH_GET_PORT_STATUS, + root_hub_ctrl(hub->hcd, port, RH_GET_PORT_STATUS, (void*)buffer); return RT_EOK; } @@ -210,36 +210,36 @@ rt_err_t rt_usbh_hub_get_port_status(uhub_t hub, rt_uint16_t port, rt_uint32_t* return RT_EOK; } } - return -RT_FALSE; + return -RT_FALSE; } /** - * This function will do USB_REQ_CLEAR_FEATURE bRequest for the device instance + * This function will do USB_REQ_CLEAR_FEATURE bRequest for the device instance * to clear feature of the hub port. * * @param intf the interface instance. * @port the hub port. * @feature feature to be cleared. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_t feature) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(hub != RT_NULL); /* clear roothub feature */ if(hub->is_roothub) { - root_hub_ctrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE, + root_hub_ctrl(hub->hcd, port, RH_CLEAR_PORT_FEATURE, (void*)(rt_uint32_t)feature); return RT_EOK; } - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_OTHER; setup.bRequest = USB_REQ_CLEAR_FEATURE; setup.wIndex = port; @@ -250,37 +250,37 @@ rt_err_t rt_usbh_hub_clear_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_ { return RT_EOK; } - return -RT_FALSE; + return -RT_FALSE; } /** - * This function will do USB_REQ_SET_FEATURE bRequest for the device instance + * This function will do USB_REQ_SET_FEATURE bRequest for the device instance * to set feature of the hub port. * * @param intf the interface instance. * @port the hub port. * @feature feature to be set. - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port, +rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port, rt_uint16_t feature) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + /* parameter check */ RT_ASSERT(hub != RT_NULL); /* clear roothub feature */ if(hub->is_roothub) { - root_hub_ctrl(hub->hcd, port, RH_SET_PORT_FEATURE, + root_hub_ctrl(hub->hcd, port, RH_SET_PORT_FEATURE, (void*)(rt_uint32_t)feature); return RT_EOK; } - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_OTHER; setup.bRequest = USB_REQ_SET_FEATURE; setup.wIndex = port; @@ -291,7 +291,7 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port, { return RT_EOK; } - else return -RT_FALSE; + else return -RT_FALSE; } /** @@ -299,17 +299,17 @@ rt_err_t rt_usbh_hub_set_port_feature(uhub_t hub, rt_uint16_t port, * * @param intf the interface instance. * @param port the hub port. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hub_reset_port(uhub_t hub, rt_uint16_t port) { rt_err_t ret; rt_uint32_t pstatus; - + /* parameter check */ RT_ASSERT(hub != RT_NULL); - + rt_thread_delay(50); /* reset hub port */ @@ -321,12 +321,12 @@ rt_err_t rt_usbh_hub_reset_port(uhub_t hub, rt_uint16_t port) ret = rt_usbh_hub_get_port_status(hub, port, &pstatus); if(!(pstatus & PORT_PRS)) break; } - + /* clear port reset feature */ - ret = rt_usbh_hub_clear_port_feature(hub, port, PORT_FEAT_C_RESET); + ret = rt_usbh_hub_clear_port_feature(hub, port, PORT_FEAT_C_RESET); if(ret != RT_EOK) return ret; - rt_thread_delay(50); + rt_thread_delay(50); return RT_EOK; } @@ -336,7 +336,7 @@ rt_err_t rt_usbh_hub_reset_port(uhub_t hub, rt_uint16_t port) * * @param device the usb instance. * @param port the hub port. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port) @@ -356,15 +356,15 @@ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port) { ret = rt_usbh_hub_get_port_status(hub, port, &pstatus); if(ret != RT_EOK) return ret; - - if(!(pstatus & PORT_CCS)) + + if(!(pstatus & PORT_CCS)) { connect = RT_FALSE; break; } - + rt_thread_delay(delayticks); - } + } if(connect) return RT_EOK; else return -RT_ERROR; @@ -375,7 +375,7 @@ rt_err_t rt_usbh_hub_port_debounce(uhub_t hub, rt_uint16_t port) * disconnect events. * * @param intf the interface instance. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) @@ -386,7 +386,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) /* parameter check */ RT_ASSERT(hub != RT_NULL); - /* get usb device instance */ + /* get usb device instance */ for (i = 0; i < hub->num_ports; i++) { rt_err_t ret; @@ -394,7 +394,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) rt_uint32_t pstatus = 0; reconnect = RT_FALSE; - + /* get hub port status */ ret = rt_usbh_hub_get_port_status(hub, i + 1, &pstatus); if(ret != RT_EOK) continue; @@ -402,8 +402,8 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) RT_DEBUG_LOG(RT_DEBUG_USB, ("port %d status 0x%x\n", i + 1, pstatus)); /* check port status change */ - if (pstatus & PORT_CCSC) - { + if (pstatus & PORT_CCSC) + { /* clear port status change feature */ rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_CONNECTION); reconnect = RT_TRUE; @@ -411,39 +411,39 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) if(pstatus & PORT_PESC) { - rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_ENABLE); + rt_usbh_hub_clear_port_feature(hub, i + 1, PORT_FEAT_C_ENABLE); reconnect = RT_TRUE; } - + if(reconnect) - { + { if(hub->child[i] != RT_NULL && hub->child[i]->status != DEV_STATUS_IDLE) - { + { rt_usbh_detach_instance(hub->child[i]); /* Child device have been detach. Set hub->child[i] to NULL. */ hub->child[i] = RT_NULL; } - + ret = rt_usbh_hub_port_debounce(hub, i + 1); if(ret != RT_EOK) continue; - + /* allocate an usb instance for new connected device */ device = rt_usbh_alloc_instance(hub->hcd); if(device == RT_NULL) break; - + /* set usb device speed */ device->speed = (pstatus & PORT_LSDA) ? 1 : 0; - device->parent_hub = hub; + device->parent_hub = hub; device->hcd = hub->hcd; device->port = i + 1; hub->child[i] = device; /* reset usb roothub port */ rt_usbh_hub_reset_port(hub, i + 1); - + /* attatch the usb instance to the hcd */ - rt_usbh_attatch_instance(device); + rt_usbh_attatch_instance(device); } } @@ -454,7 +454,7 @@ static rt_err_t rt_usbh_hub_port_change(uhub_t hub) * This function is the callback function of hub's int endpoint, it is invoked when data comes. * * @param context the context of the callback function. - * + * * @return none. */ static void rt_usbh_hub_irq(void* context) @@ -462,9 +462,9 @@ static void rt_usbh_hub_irq(void* context) upipe_t pipe; uhub_t hub; int timeout = USB_TIMEOUT_BASIC; - + RT_ASSERT(context != RT_NULL); - + pipe = (upipe_t)context; hub = (uhub_t)pipe->user_data; @@ -473,14 +473,14 @@ static void rt_usbh_hub_irq(void* context) RT_DEBUG_LOG(RT_DEBUG_USB,("hub irq error\n")); return; } - + rt_usbh_hub_port_change(hub); RT_DEBUG_LOG(RT_DEBUG_USB,("hub int xfer...\n")); /* parameter check */ RT_ASSERT(pipe->inst->hcd != RT_NULL); - + rt_usb_hcd_pipe_xfer(hub->self->hcd, pipe, hub->buffer, pipe->ep.wMaxPacketSize, timeout); } @@ -489,7 +489,7 @@ static void rt_usbh_hub_irq(void* context) * as a hub class device, it will continue to do the enumulate process. * * @param arg the argument. - * + * * @return the error code, RT_EOK on successfully. */ @@ -505,7 +505,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg) int timeout = USB_TIMEOUT_LONG; /* paremeter check */ RT_ASSERT(intf != RT_NULL); - + RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usbh_hub_run\n")); /* get usb device instance */ @@ -515,7 +515,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg) hub = rt_malloc(sizeof(struct uhub)); RT_ASSERT(hub != RT_NULL); rt_memset(hub, 0, sizeof(struct uhub)); - + /* make interface instance's user data point to hub instance */ intf->user_data = (void*)hub; @@ -524,17 +524,17 @@ static rt_err_t rt_usbh_hub_enable(void *arg) if(ret != RT_EOK) { rt_kprintf("get hub descriptor failed\n"); - return -RT_ERROR; + return -RT_ERROR; } /* get full hub descriptor */ - ret = rt_usbh_hub_get_descriptor(device, (rt_uint8_t*)&hub->hub_desc, + ret = rt_usbh_hub_get_descriptor(device, (rt_uint8_t*)&hub->hub_desc, hub->hub_desc.length); if(ret != RT_EOK) { rt_kprintf("get hub descriptor again failed\n"); - return -RT_ERROR; - } + return -RT_ERROR; + } /* get hub ports number */ /* If hub device supported ports over USB_HUB_PORT_NUM(Ex: 8 port hub). Set hub->num_ports to USB_HUB_PORT_NUM */ @@ -554,7 +554,7 @@ static rt_err_t rt_usbh_hub_enable(void *arg) * 2 * RT_TICK_PER_SECOND / 1000 ); } - if(intf->intf_desc->bNumEndpoints != 1) + if(intf->intf_desc->bNumEndpoints != 1) return -RT_ERROR; /* get endpoint descriptor from interface descriptor */ @@ -565,12 +565,12 @@ static rt_err_t rt_usbh_hub_enable(void *arg) return -RT_ERROR; } - /* the endpoint type of hub class should be interrupt */ + /* the endpoint type of hub class should be interrupt */ if( USB_EP_ATTR(ep_desc->bmAttributes) == USB_EP_ATTR_INT) { /* the endpoint direction of hub class should be in */ if(ep_desc->bEndpointAddress & USB_DIR_IN) - { + { /* allocate a pipe according to the endpoint type */ pipe_in = rt_usb_instance_find_pipe(device,ep_desc->bEndpointAddress); if(pipe_in == RT_NULL) @@ -585,17 +585,17 @@ static rt_err_t rt_usbh_hub_enable(void *arg) /* parameter check */ RT_ASSERT(device->hcd != RT_NULL); pipe_in->user_data = hub; - rt_usb_hcd_pipe_xfer(hub->hcd, pipe_in, hub->buffer, + rt_usb_hcd_pipe_xfer(hub->hcd, pipe_in, hub->buffer, pipe_in->ep.wMaxPacketSize, timeout); return RT_EOK; } /** - * This function will be invoked when usb hub plug out is detected and it would clean + * This function will be invoked when usb hub plug out is detected and it would clean * and release all hub class related resources. * * @param arg the argument. - * + * * @return the error code, RT_EOK on successfully. */ static rt_err_t rt_usbh_hub_disable(void* arg) @@ -615,7 +615,7 @@ static rt_err_t rt_usbh_hub_disable(void* arg) if(hub->child[i] != RT_NULL) rt_usbh_detach_instance(hub->child[i]); } - + if(hub != RT_NULL) rt_free(hub); return RT_EOK; @@ -624,13 +624,13 @@ static rt_err_t rt_usbh_hub_disable(void* arg) /** * This function will register hub class driver to the usb class driver manager. * and it should be invoked in the usb system initialization. - * + * * @return the error code, RT_EOK on successfully. */ ucd_t rt_usbh_class_driver_hub(void) -{ +{ hub_driver.class_code = USB_CLASS_HUB; - + hub_driver.enable = rt_usbh_hub_enable; hub_driver.disable = rt_usbh_hub_disable; @@ -638,27 +638,27 @@ ucd_t rt_usbh_class_driver_hub(void) } /** - * This function is the main entry of usb hub thread, it is in charge of - * processing all messages received from the usb message buffer. + * This function is the main entry of usb hub thread, it is in charge of + * processing all messages received from the usb message buffer. * * @param parameter the parameter of the usb host thread. - * + * * @return none. */ static void rt_usbh_hub_thread_entry(void* parameter) -{ +{ while(1) - { + { struct uhost_msg msg; - + /* receive message */ - if(rt_mq_recv(usb_mq, &msg, sizeof(struct uhost_msg), RT_WAITING_FOREVER) + if(rt_mq_recv(usb_mq, &msg, sizeof(struct uhost_msg), RT_WAITING_FOREVER) != RT_EOK ) continue; //RT_DEBUG_LOG(RT_DEBUG_USB, ("msg type %d\n", msg.type)); - + switch (msg.type) - { + { case USB_MSG_CONNECT_CHANGE: rt_usbh_hub_port_change(msg.content.hub); break; @@ -668,7 +668,7 @@ static void rt_usbh_hub_thread_entry(void* parameter) break; default: break; - } + } } } @@ -676,8 +676,8 @@ static void rt_usbh_hub_thread_entry(void* parameter) * This function will post an message to the usb message queue, * * @param msg the message to be posted - * - * @return the error code, RT_EOK on successfully. + * + * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_event_signal(struct uhost_msg* msg) { @@ -693,7 +693,7 @@ rt_err_t rt_usbh_event_signal(struct uhost_msg* msg) * This function will initialize usb hub thread. * * @return none. - * + * */ void rt_usbh_hub_init(uhcd_t hcd) { @@ -705,9 +705,9 @@ void rt_usbh_hub_init(uhcd_t hcd) root_hub.num_ports = hcd->num_ports; /* create usb message queue */ usb_mq = rt_mq_create("usbh", 32, 16, RT_IPC_FLAG_FIFO); - + /* create usb hub thread */ - thread = rt_thread_create("usbh", rt_usbh_hub_thread_entry, RT_NULL, + thread = rt_thread_create("usbh", rt_usbh_hub_thread_entry, RT_NULL, USB_THREAD_STACK_SIZE, 8, 20); if(thread != RT_NULL) { diff --git a/components/drivers/usb/usbhost/core/usbhost.c b/components/drivers/usb/usbhost/core/usbhost.c index f0294238c4..a76f6d4586 100644 --- a/components/drivers/usb/usbhost/core/usbhost.c +++ b/components/drivers/usb/usbhost/core/usbhost.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -19,13 +19,13 @@ /** * This function will initialize the usb host stack, all the usb class driver and * host controller driver are also be initialized here. - * + * * @return none. */ rt_err_t rt_usb_host_init(void) { ucd_t drv; - rt_device_t uhc; + rt_device_t uhc; uhc = rt_device_find(USB_HOST_CONTROLLER_NAME); if(uhc == RT_NULL) diff --git a/components/drivers/usb/usbhost/core/usbhost_core.c b/components/drivers/usb/usbhost/core/usbhost_core.c index d72dca82f2..71fe3b8b3f 100644 --- a/components/drivers/usb/usbhost/core/usbhost_core.c +++ b/components/drivers/usb/usbhost/core/usbhost_core.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -27,28 +27,28 @@ uinst_t rt_usbh_alloc_instance(uhcd_t uhcd) /* lock scheduler */ rt_enter_critical(); - + for(i=0; idev_desc; - + /* alloc address 0 ep0 pipe*/ ep0_out_desc.wMaxPacketSize = 8; ep0_in_desc.wMaxPacketSize = 8; @@ -106,7 +106,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_in, device, &ep0_in_desc); RT_DEBUG_LOG(RT_DEBUG_USB, ("start enumnation\n")); - + /* get device descriptor head */ ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_DEVICE, (void*)dev_desc, 8); if(ret != RT_EOK) @@ -114,7 +114,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) rt_kprintf("get device descriptor head failed\n"); return ret; } - + /* reset bus */ rt_usbh_hub_reset_port(device->parent_hub, device->port); rt_thread_delay(2); @@ -127,20 +127,20 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) return ret; } /* free address 0 ep0 pipe*/ - + rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_out); rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_in); - + /* set device max packet size */ ep0_out_desc.wMaxPacketSize = device->dev_desc.bMaxPacketSize0; ep0_in_desc.wMaxPacketSize = device->dev_desc.bMaxPacketSize0; - + /* alloc true address ep0 pipe*/ rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_out, device, &ep0_out_desc); rt_usb_hcd_alloc_pipe(device->hcd, &device->pipe_ep0_in, device, &ep0_in_desc); RT_DEBUG_LOG(RT_DEBUG_USB, ("get device descriptor length %d\n", dev_desc->bLength)); - + /* get full device descriptor again */ ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_DEVICE, (void*)dev_desc, dev_desc->bLength); if(ret != RT_EOK) @@ -169,7 +169,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) rt_memset(device->cfg_desc, 0, cfg_desc.wTotalLength); /* get full configuration descriptor */ - ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_CONFIGURATION, + ret = rt_usbh_get_descriptor(device, USB_DESC_TYPE_CONFIGURATION, device->cfg_desc, cfg_desc.wTotalLength); if(ret != RT_EOK) { @@ -179,12 +179,12 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) /* set configuration */ ret = rt_usbh_set_configure(device, 1); - if(ret != RT_EOK) + if(ret != RT_EOK) { return ret; } for(i=0; icfg_desc->bNumInterfaces; i++) - { + { /* get interface descriptor through configuration descriptor */ ret = rt_usbh_get_interface_descriptor(device->cfg_desc, i, &intf_desc); if(ret != RT_EOK) @@ -193,7 +193,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) return -RT_ERROR; } - RT_DEBUG_LOG(RT_DEBUG_USB, ("interface class 0x%x, subclass 0x%x\n", + RT_DEBUG_LOG(RT_DEBUG_USB, ("interface class 0x%x, subclass 0x%x\n", intf_desc->bInterfaceClass, intf_desc->bInterfaceSubClass)); /* alloc pipe*/ @@ -216,9 +216,9 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) } } /* find driver by class code found in interface descriptor */ - drv = rt_usbh_class_driver_find(intf_desc->bInterfaceClass, + drv = rt_usbh_class_driver_find(intf_desc->bInterfaceClass, intf_desc->bInterfaceSubClass); - + if(drv != RT_NULL) { /* allocate memory for interface device */ @@ -245,7 +245,7 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) continue; } } - + return RT_EOK; } @@ -254,19 +254,19 @@ rt_err_t rt_usbh_attatch_instance(uinst_t device) * and release all resource. * * @param device the usb device instance. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_detach_instance(uinst_t device) { int i = 0; rt_list_t * l; - if(device == RT_NULL) + if(device == RT_NULL) { rt_kprintf("no usb instance to detach\n"); return -RT_ERROR; } - + /* free configration descriptor */ if (device->cfg_desc) { for (i = 0; i < device->cfg_desc->bNumInterfaces; i++) @@ -282,10 +282,10 @@ rt_err_t rt_usbh_detach_instance(uinst_t device) } rt_free(device->cfg_desc); } - + rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_out); rt_usb_hcd_free_pipe(device->hcd,device->pipe_ep0_in); - + while(device->pipe.next!= &device->pipe) { l = device->pipe.next; @@ -293,29 +293,29 @@ rt_err_t rt_usbh_detach_instance(uinst_t device) rt_usb_hcd_free_pipe(device->hcd,rt_list_entry(l,struct upipe,list)); } rt_memset(device, 0, sizeof(struct uinstance)); - + return RT_EOK; } /** * This function will do USB_REQ_GET_DESCRIPTO' bRequest for the usb device instance, * - * @param device the usb device instance. + * @param device the usb device instance. * @param type the type of descriptor bRequest. * @param buffer the data buffer to save requested data * @param nbytes the size of buffer - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer, +rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer, int nbytes) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + RT_ASSERT(device != RT_NULL); - setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD | + setup.request_type = USB_REQ_TYPE_DIR_IN | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE; setup.bRequest = USB_REQ_GET_DESCRIPTOR; setup.wIndex = 0; @@ -339,19 +339,19 @@ rt_err_t rt_usbh_get_descriptor(uinst_t device, rt_uint8_t type, void* buffer, * This function will set an address to the usb device. * * @param device the usb device instance. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_set_address(uinst_t device) { struct urequest setup; int timeout = USB_TIMEOUT_BASIC; - + RT_ASSERT(device != RT_NULL); RT_DEBUG_LOG(RT_DEBUG_USB, ("rt_usb_set_address\n")); - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE; setup.bRequest = USB_REQ_SET_ADDRESS; setup.wIndex = 0; @@ -375,7 +375,7 @@ rt_err_t rt_usbh_set_address(uinst_t device) * * @param device the usb device instance. * @param config the configuration number. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_set_configure(uinst_t device, int config) @@ -386,7 +386,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config) /* check parameter */ RT_ASSERT(device != RT_NULL); - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE; setup.bRequest = USB_REQ_SET_CONFIGURATION; setup.wIndex = 0; @@ -401,7 +401,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config) { return RT_ERROR; } - return RT_EOK; + return RT_EOK; } /** @@ -409,7 +409,7 @@ rt_err_t rt_usbh_set_configure(uinst_t device, int config) * * @param device the usb device instance. * @param intf the interface number. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_set_interface(uinst_t device, int intf) @@ -420,7 +420,7 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf) /* check parameter */ RT_ASSERT(device != RT_NULL); - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE; setup.bRequest = USB_REQ_SET_INTERFACE; setup.wIndex = 0; @@ -431,8 +431,8 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf) { return RT_ERROR; } - - return RT_EOK; + + return RT_EOK; } /** @@ -440,7 +440,7 @@ rt_err_t rt_usbh_set_interface(uinst_t device, int intf) * * @param device the usb device instance. * @param endpoint the endpoint number of the usb device. - * + * * @return the error code, RT_EOK on successfully. */ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature) @@ -451,7 +451,7 @@ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature) /* check parameter */ RT_ASSERT(device != RT_NULL); - setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | + setup.request_type = USB_REQ_TYPE_DIR_OUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_ENDPOINT; setup.bRequest = USB_REQ_CLEAR_FEATURE; setup.wIndex = endpoint; @@ -462,8 +462,8 @@ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature) { return RT_ERROR; } - - return RT_EOK; + + return RT_EOK; } /** @@ -472,10 +472,10 @@ rt_err_t rt_usbh_clear_feature(uinst_t device, int endpoint, int feature) * @param cfg_desc the point of configuration descriptor structure. * @param num the number of interface descriptor. * @intf_desc the point of interface descriptor point. - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num, +rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num, uintf_desc_t* intf_desc) { rt_uint32_t ptr, depth = 0; @@ -487,9 +487,9 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num, ptr = (rt_uint32_t)cfg_desc + cfg_desc->bLength; while(ptr < (rt_uint32_t)cfg_desc + cfg_desc->wTotalLength) { - if(depth++ > 0x20) + if(depth++ > 0x20) { - *intf_desc = RT_NULL; + *intf_desc = RT_NULL; return -RT_EIO; } desc = (udesc_t)ptr; @@ -500,10 +500,10 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num, *intf_desc = (uintf_desc_t)desc; RT_DEBUG_LOG(RT_DEBUG_USB, - ("rt_usb_get_interface_descriptor: %d\n", num)); + ("rt_usb_get_interface_descriptor: %d\n", num)); return RT_EOK; } - } + } ptr = (rt_uint32_t)desc + desc->bLength; } @@ -517,14 +517,14 @@ rt_err_t rt_usbh_get_interface_descriptor(ucfg_desc_t cfg_desc, int num, * @param intf_desc the point of interface descriptor structure. * @param num the number of endpoint descriptor. * @param ep_desc the point of endpoint descriptor point. - * + * * @return the error code, RT_EOK on successfully. */ -rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num, +rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num, uep_desc_t* ep_desc) { int count = 0, depth = 0; - rt_uint32_t ptr; + rt_uint32_t ptr; udesc_t desc; /* check parameter */ @@ -535,15 +535,15 @@ rt_err_t rt_usbh_get_endpoint_descriptor(uintf_desc_t intf_desc, int num, ptr = (rt_uint32_t)intf_desc + intf_desc->bLength; while(count < intf_desc->bNumEndpoints) { - if(depth++ > 0x20) + if(depth++ > 0x20) { - *ep_desc = RT_NULL; + *ep_desc = RT_NULL; return -RT_EIO; } - desc = (udesc_t)ptr; + desc = (udesc_t)ptr; if(desc->type == USB_DESC_TYPE_ENDPOINT) { - if(num == count) + if(num == count) { *ep_desc = (uep_desc_t)desc; diff --git a/components/drivers/watchdog/watchdog.c b/components/drivers/watchdog/watchdog.c index 09a6bf4fad..9108d834c6 100644 --- a/components/drivers/watchdog/watchdog.c +++ b/components/drivers/watchdog/watchdog.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: @@ -65,7 +65,7 @@ static rt_err_t rt_watchdog_control(struct rt_device *dev, } #ifdef RT_USING_DEVICE_OPS -const static struct rt_device_ops wdt_ops = +const static struct rt_device_ops wdt_ops = { rt_watchdog_init, rt_watchdog_open, diff --git a/components/drivers/wlan/wlan_cfg.c b/components/drivers/wlan/wlan_cfg.c index 7fa9ecb2da..0befe6e7da 100644 --- a/components/drivers/wlan/wlan_cfg.c +++ b/components/drivers/wlan/wlan_cfg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_cfg.h b/components/drivers/wlan/wlan_cfg.h index 3fae3f3e98..4d0e73729d 100644 --- a/components/drivers/wlan/wlan_cfg.h +++ b/components/drivers/wlan/wlan_cfg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_cmd.c b/components/drivers/wlan/wlan_cmd.c index fead6a8bf2..fde9065428 100644 --- a/components/drivers/wlan/wlan_cmd.c +++ b/components/drivers/wlan/wlan_cmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c index 53b6138e99..4db8d5e43d 100644 --- a/components/drivers/wlan/wlan_dev.c +++ b/components/drivers/wlan/wlan_dev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_dev.h b/components/drivers/wlan/wlan_dev.h index 3019afb19d..9fce22b7c9 100644 --- a/components/drivers/wlan/wlan_dev.h +++ b/components/drivers/wlan/wlan_dev.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -589,7 +589,7 @@ rt_err_t rt_wlan_dev_report_data(struct rt_wlan_device *device, void *buff, int /* * wlan device register interface */ -rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, +rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, const struct rt_wlan_dev_ops *ops, rt_uint32_t flag, void *user_data); #ifdef __cplusplus diff --git a/components/drivers/wlan/wlan_lwip.c b/components/drivers/wlan/wlan_lwip.c index 3c4e4dd598..30205ac332 100644 --- a/components/drivers/wlan/wlan_lwip.c +++ b/components/drivers/wlan/wlan_lwip.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_mgnt.c b/components/drivers/wlan/wlan_mgnt.c index fefe700acc..6abac5691c 100644 --- a/components/drivers/wlan/wlan_mgnt.c +++ b/components/drivers/wlan/wlan_mgnt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_mgnt.h b/components/drivers/wlan/wlan_mgnt.h index df0827bb7b..38d5c31da2 100644 --- a/components/drivers/wlan/wlan_mgnt.h +++ b/components/drivers/wlan/wlan_mgnt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_prot.c b/components/drivers/wlan/wlan_prot.c index b1a1b5de99..5c32a3fbda 100644 --- a/components/drivers/wlan/wlan_prot.c +++ b/components/drivers/wlan/wlan_prot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_prot.h b/components/drivers/wlan/wlan_prot.h index 2df979270f..5f8930f452 100644 --- a/components/drivers/wlan/wlan_prot.h +++ b/components/drivers/wlan/wlan_prot.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_workqueue.c b/components/drivers/wlan/wlan_workqueue.c index 4cd98346d2..76b95e66b0 100644 --- a/components/drivers/wlan/wlan_workqueue.c +++ b/components/drivers/wlan/wlan_workqueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/drivers/wlan/wlan_workqueue.h b/components/drivers/wlan/wlan_workqueue.h index 49bc4a5f9f..7a68a27e03 100644 --- a/components/drivers/wlan/wlan_workqueue.h +++ b/components/drivers/wlan/wlan_workqueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index afbda59e90..8b51896cde 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -27,9 +27,9 @@ * 2012-10-22 Bernard add MS VC++ patch. * 2016-06-02 armink beautify the list_thread command * 2018-11-22 Jesven list_thread add smp support - * 2018-12-27 Jesven Fix the problem that disable interrupt too long in list_thread + * 2018-12-27 Jesven Fix the problem that disable interrupt too long in list_thread * Provide protection for the "first layer of objects" when list_* - * 2020-04-07 chenhui add clear + * 2020-04-07 chenhui add clear */ #include @@ -156,7 +156,7 @@ static rt_list_t *list_get_next(rt_list_t *current, list_get_next_t *arg) break; } } - + rt_hw_interrupt_enable(level); arg->nr_out = nr; return node; diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index 7276ea7ce1..dd5e27dea5 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_api.h b/components/finsh/finsh_api.h index db2c175cb5..fd9e6a773e 100644 --- a/components/finsh/finsh_api.h +++ b/components/finsh/finsh_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_compiler.c b/components/finsh/finsh_compiler.c index f81409bf9a..1cb4ff00a5 100644 --- a/components/finsh/finsh_compiler.c +++ b/components/finsh/finsh_compiler.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_error.c b/components/finsh/finsh_error.c index bdd0108f98..a5cf2eb514 100644 --- a/components/finsh/finsh_error.c +++ b/components/finsh/finsh_error.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_error.h b/components/finsh/finsh_error.h index 614e02a350..8dfafd013c 100644 --- a/components/finsh/finsh_error.h +++ b/components/finsh/finsh_error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_heap.c b/components/finsh/finsh_heap.c index 0d185db474..9f64d108dd 100644 --- a/components/finsh/finsh_heap.c +++ b/components/finsh/finsh_heap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_heap.h b/components/finsh/finsh_heap.h index 9c04e5c22f..f320c2771a 100644 --- a/components/finsh/finsh_heap.h +++ b/components/finsh/finsh_heap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_init.c b/components/finsh/finsh_init.c index 72f5aa5e9a..76302a0516 100644 --- a/components/finsh/finsh_init.c +++ b/components/finsh/finsh_init.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_node.c b/components/finsh/finsh_node.c index 0de82c189d..82a4c03f1e 100644 --- a/components/finsh/finsh_node.c +++ b/components/finsh/finsh_node.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_node.h b/components/finsh/finsh_node.h index c7ce099636..ff4333df13 100644 --- a/components/finsh/finsh_node.h +++ b/components/finsh/finsh_node.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_ops.c b/components/finsh/finsh_ops.c index 2eafb50c69..ec8b8cb58a 100644 --- a/components/finsh/finsh_ops.c +++ b/components/finsh/finsh_ops.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_ops.h b/components/finsh/finsh_ops.h index 95a8b001fb..0cc945f078 100644 --- a/components/finsh/finsh_ops.h +++ b/components/finsh/finsh_ops.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -25,90 +25,90 @@ * OP [op1] */ -#define FINSH_OP_NOOP 0x00 +#define FINSH_OP_NOOP 0x00 /* add @ r1 = r2 + r3 */ -#define FINSH_OP_ADD_BYTE 0x01 -#define FINSH_OP_ADD_WORD 0x02 -#define FINSH_OP_ADD_DWORD 0x03 +#define FINSH_OP_ADD_BYTE 0x01 +#define FINSH_OP_ADD_WORD 0x02 +#define FINSH_OP_ADD_DWORD 0x03 /* sub @ r1 = r2 - r3 */ -#define FINSH_OP_SUB_BYTE 0x04 -#define FINSH_OP_SUB_WORD 0x05 -#define FINSH_OP_SUB_DWORD 0x06 +#define FINSH_OP_SUB_BYTE 0x04 +#define FINSH_OP_SUB_WORD 0x05 +#define FINSH_OP_SUB_DWORD 0x06 /* div @ r1 = r2 / r3 */ -#define FINSH_OP_DIV_BYTE 0x07 -#define FINSH_OP_DIV_WORD 0x08 -#define FINSH_OP_DIV_DWORD 0x09 +#define FINSH_OP_DIV_BYTE 0x07 +#define FINSH_OP_DIV_WORD 0x08 +#define FINSH_OP_DIV_DWORD 0x09 /* mod @ r1 = r2 % r3 */ -#define FINSH_OP_MOD_BYTE 0x0A -#define FINSH_OP_MOD_WORD 0x0B -#define FINSH_OP_MOD_DWORD 0x0C +#define FINSH_OP_MOD_BYTE 0x0A +#define FINSH_OP_MOD_WORD 0x0B +#define FINSH_OP_MOD_DWORD 0x0C /* mul @ r1 = r2 * r3 */ -#define FINSH_OP_MUL_BYTE 0x0D -#define FINSH_OP_MUL_WORD 0x0E -#define FINSH_OP_MUL_DWORD 0x0F +#define FINSH_OP_MUL_BYTE 0x0D +#define FINSH_OP_MUL_WORD 0x0E +#define FINSH_OP_MUL_DWORD 0x0F /* and @ r1 = r2 & r3 */ -#define FINSH_OP_AND_BYTE 0x10 -#define FINSH_OP_AND_WORD 0x11 -#define FINSH_OP_AND_DWORD 0x12 +#define FINSH_OP_AND_BYTE 0x10 +#define FINSH_OP_AND_WORD 0x11 +#define FINSH_OP_AND_DWORD 0x12 /* or @ r1 = r2 | r3 */ -#define FINSH_OP_OR_BYTE 0x13 -#define FINSH_OP_OR_WORD 0x14 -#define FINSH_OP_OR_DWORD 0x15 +#define FINSH_OP_OR_BYTE 0x13 +#define FINSH_OP_OR_WORD 0x14 +#define FINSH_OP_OR_DWORD 0x15 /* xor @ r1 = r2 ^ r3 */ -#define FINSH_OP_XOR_BYTE 0x16 -#define FINSH_OP_XOR_WORD 0x17 -#define FINSH_OP_XOR_DWORD 0x18 +#define FINSH_OP_XOR_BYTE 0x16 +#define FINSH_OP_XOR_WORD 0x17 +#define FINSH_OP_XOR_DWORD 0x18 /* bw @ r1 = ~r2 */ -#define FINSH_OP_BITWISE_BYTE 0x19 -#define FINSH_OP_BITWISE_WORD 0x1A -#define FINSH_OP_BITWISE_DWORD 0x1B +#define FINSH_OP_BITWISE_BYTE 0x19 +#define FINSH_OP_BITWISE_WORD 0x1A +#define FINSH_OP_BITWISE_DWORD 0x1B /* shl @ r1 = r2 << r3 */ -#define FINSH_OP_SHL_BYTE 0x1C -#define FINSH_OP_SHL_WORD 0x1D -#define FINSH_OP_SHL_DWORD 0x1E +#define FINSH_OP_SHL_BYTE 0x1C +#define FINSH_OP_SHL_WORD 0x1D +#define FINSH_OP_SHL_DWORD 0x1E /* shr @ r1 = r2 >> r3 */ -#define FINSH_OP_SHR_BYTE 0x1F -#define FINSH_OP_SHR_WORD 0x20 -#define FINSH_OP_SHR_DWORD 0x21 +#define FINSH_OP_SHR_BYTE 0x1F +#define FINSH_OP_SHR_WORD 0x20 +#define FINSH_OP_SHR_DWORD 0x21 /* ld @ r1 = [r2] */ -#define FINSH_OP_LD_BYTE 0x22 -#define FINSH_OP_LD_WORD 0x23 -#define FINSH_OP_LD_DWORD 0x24 +#define FINSH_OP_LD_BYTE 0x22 +#define FINSH_OP_LD_WORD 0x23 +#define FINSH_OP_LD_DWORD 0x24 -#define FINSH_OP_LD_VALUE_BYTE 0x25 -#define FINSH_OP_LD_VALUE_WORD 0x26 -#define FINSH_OP_LD_VALUE_DWORD 0x27 +#define FINSH_OP_LD_VALUE_BYTE 0x25 +#define FINSH_OP_LD_VALUE_WORD 0x26 +#define FINSH_OP_LD_VALUE_DWORD 0x27 /* st @ [r2] = r1 */ -#define FINSH_OP_ST_BYTE 0x28 -#define FINSH_OP_ST_WORD 0x29 -#define FINSH_OP_ST_DWORD 0x2A +#define FINSH_OP_ST_BYTE 0x28 +#define FINSH_OP_ST_WORD 0x29 +#define FINSH_OP_ST_DWORD 0x2A /* pop */ -#define FINSH_OP_POP 0x2B +#define FINSH_OP_POP 0x2B /* call r1 @ [r1](stack) */ -#define FINSH_OP_SYSCALL 0x2C +#define FINSH_OP_SYSCALL 0x2C /* load value from stack */ -#define FINSH_OP_LD_VALUE_BYTE_STACK 0x2D -#define FINSH_OP_LD_VALUE_WORD_STACK 0x2E -#define FINSH_OP_LD_VALUE_DWORD_STACK 0x2F +#define FINSH_OP_LD_VALUE_BYTE_STACK 0x2D +#define FINSH_OP_LD_VALUE_WORD_STACK 0x2E +#define FINSH_OP_LD_VALUE_DWORD_STACK 0x2F /* halt */ -#define FINSH_OP_HALT 0xFF +#define FINSH_OP_HALT 0xFF typedef void (*op_func)(); extern const op_func op_table[]; diff --git a/components/finsh/finsh_parser.c b/components/finsh/finsh_parser.c index 0e7617003c..4b8b4af7e4 100644 --- a/components/finsh/finsh_parser.c +++ b/components/finsh/finsh_parser.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_parser.h b/components/finsh/finsh_parser.h index 8e149a7e00..2d0148093a 100644 --- a/components/finsh/finsh_parser.h +++ b/components/finsh/finsh_parser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_token.c b/components/finsh/finsh_token.c index 5fb593d816..dfd613da5b 100644 --- a/components/finsh/finsh_token.c +++ b/components/finsh/finsh_token.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_token.h b/components/finsh/finsh_token.h index 0ce98c0f14..9845357b8e 100644 --- a/components/finsh/finsh_token.h +++ b/components/finsh/finsh_token.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_var.c b/components/finsh/finsh_var.c index 6a27bf1fab..2e3df30c6d 100644 --- a/components/finsh/finsh_var.c +++ b/components/finsh/finsh_var.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_var.h b/components/finsh/finsh_var.h index 8d7ee6a201..796f979441 100644 --- a/components/finsh/finsh_var.h +++ b/components/finsh/finsh_var.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_vm.c b/components/finsh/finsh_vm.c index 7c56407084..e56cedbdfb 100644 --- a/components/finsh/finsh_vm.c +++ b/components/finsh/finsh_vm.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/finsh_vm.h b/components/finsh/finsh_vm.h index fc515418e4..15d5da1ef8 100644 --- a/components/finsh/finsh_vm.h +++ b/components/finsh/finsh_vm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 79f1e3c87f..73a5197dcd 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/msh.h b/components/finsh/msh.h index b7153107ea..17c7a39ef1 100644 --- a/components/finsh/msh.h +++ b/components/finsh/msh.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/msh_file.c b/components/finsh/msh_file.c index aa182ff9b3..459d77af4e 100644 --- a/components/finsh/msh_file.c +++ b/components/finsh/msh_file.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 61f0b9562e..0d41625184 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -844,7 +844,7 @@ int finsh_system_init(void) finsh_system_var_init(&__vsymtab_start, &__vsymtab_end); #elif defined(_MSC_VER) unsigned int *ptr_begin, *ptr_end; - + if(shell) { rt_kprintf("finsh shell already init.\n"); diff --git a/components/finsh/shell.h b/components/finsh/shell.h index 8f94e23e8b..6a4dfff113 100644 --- a/components/finsh/shell.h +++ b/components/finsh/shell.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/finsh/symbol.c b/components/finsh/symbol.c index 78df9fac5c..c6623e2d82 100644 --- a/components/finsh/symbol.c +++ b/components/finsh/symbol.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -7,7 +7,7 @@ * Date Author Notes * 2010-03-22 Bernard first version */ - + #include #if defined(RT_USING_FINSH) && !defined(FINSH_USING_SYMTAB) diff --git a/components/libc/aio/posix_aio.c b/components/libc/aio/posix_aio.c index 3eb7634495..66f15e4c57 100644 --- a/components/libc/aio/posix_aio.c +++ b/components/libc/aio/posix_aio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -22,25 +22,25 @@ struct rt_workqueue* aio_queue = NULL; /** - * The aio_cancel() function shall attempt to cancel one or more asynchronous I/O - * requests currently outstanding against file descriptor fildes. The aiocbp - * argument points to the asynchronous I/O control block for a particular request - * to be canceled. If aiocbp is NULL, then all outstanding cancelable asynchronous + * The aio_cancel() function shall attempt to cancel one or more asynchronous I/O + * requests currently outstanding against file descriptor fildes. The aiocbp + * argument points to the asynchronous I/O control block for a particular request + * to be canceled. If aiocbp is NULL, then all outstanding cancelable asynchronous * I/O requests against fildes shall be canceled. - * - * Normal asynchronous notification shall occur for asynchronous I/O operations - * that are successfully canceled. If there are requests that cannot be canceled, - * then the normal asynchronous completion process shall take place for those + * + * Normal asynchronous notification shall occur for asynchronous I/O operations + * that are successfully canceled. If there are requests that cannot be canceled, + * then the normal asynchronous completion process shall take place for those * requests when they are completed. - * - * For requested operations that are successfully canceled, the associated error - * status shall be set to [ECANCELED] and the return status shall be -1. For - * requested operations that are not successfully canceled, the aiocbp shall not + * + * For requested operations that are successfully canceled, the associated error + * status shall be set to [ECANCELED] and the return status shall be -1. For + * requested operations that are not successfully canceled, the aiocbp shall not * be modified by aio_cancel(). - * - * If aiocbp is not NULL, then if fildes does not have the same value as the file + * + * If aiocbp is not NULL, then if fildes does not have the same value as the file * descriptor with which the asynchronous operation was initiated, unspecified results occur. - * + * * Which operations are cancelable is implementation-defined. */ int aio_cancel(int fd, struct aiocb *cb) @@ -61,9 +61,9 @@ int aio_cancel(int fd, struct aiocb *cb) } /** - * The aio_error() function shall return the error status associated with the - * aiocb structure referenced by the aiocbp argument. The error status for an - * asynchronous I/O operation is the errno value that would be set by the corresponding + * The aio_error() function shall return the error status associated with the + * aiocb structure referenced by the aiocbp argument. The error status for an + * asynchronous I/O operation is the errno value that would be set by the corresponding * read(), write(), */ int aio_error (const struct aiocb *cb) @@ -77,44 +77,44 @@ int aio_error (const struct aiocb *cb) } /** - * The aio_fsync() function shall asynchronously perform a file synchronization - * operation, as specified by the op argument, for I/O operations associated with - * the file indicated by the file descriptor aio_fildes member of the aiocb - * structure referenced by the aiocbp argument and queued at the time of the - * call to aio_fsync(). The function call shall return when the synchronization - * request has been initiated or queued to the file or device (even when the data + * The aio_fsync() function shall asynchronously perform a file synchronization + * operation, as specified by the op argument, for I/O operations associated with + * the file indicated by the file descriptor aio_fildes member of the aiocb + * structure referenced by the aiocbp argument and queued at the time of the + * call to aio_fsync(). The function call shall return when the synchronization + * request has been initiated or queued to the file or device (even when the data * cannot be synchronized immediately). - * - * option: If op is O_DSYNC, all currently queued I/O operations shall be completed - * as if by a call to fdatasync(); that is, as defined for synchronized I/O data + * + * option: If op is O_DSYNC, all currently queued I/O operations shall be completed + * as if by a call to fdatasync(); that is, as defined for synchronized I/O data * integrity completion. - * - * option: If op is O_SYNC, all currently queued I/O operations shall be completed - * as if by a call to fsync(); that is, as defined for synchronized I/O file integrity - * completion. If the aio_fsync() function fails, or if the operation queued by - * aio_fsync() fails, then outstanding I/O operations are not guaranteed to have + * + * option: If op is O_SYNC, all currently queued I/O operations shall be completed + * as if by a call to fsync(); that is, as defined for synchronized I/O file integrity + * completion. If the aio_fsync() function fails, or if the operation queued by + * aio_fsync() fails, then outstanding I/O operations are not guaranteed to have * been completed. - * - * If aio_fsync() succeeds, then it is only the I/O that was queued at the time - * of the call to aio_fsync() that is guaranteed to be forced to the relevant + * + * If aio_fsync() succeeds, then it is only the I/O that was queued at the time + * of the call to aio_fsync() that is guaranteed to be forced to the relevant * completion state. The completion of subsequent I/O on the file descriptor is * not guaranteed to be completed in a synchronized fashion. - * - * The aiocbp argument refers to an asynchronous I/O control block. The aiocbp - * value may be used as an argument to aio_error() and aio_return() in order to - * determine the error status and return status, respectively, of the asynchronous - * operation while it is proceeding. When the request is queued, the error status - * for the operation is [EINPROGRESS]. When all data has been successfully transferred, - * the error status shall be reset to reflect the success or failure of the operation. - * If the operation does not complete successfully, the error status for the - * operation shall be set to indicate the error. The aio_sigevent member determines - * the asynchronous notification to occur as specified in Signal Generation and - * Delivery when all operations have achieved synchronized I/O completion. All - * other members of the structure referenced by aiocbp are ignored. If the control - * block referenced by aiocbp becomes an illegal address prior to asynchronous + * + * The aiocbp argument refers to an asynchronous I/O control block. The aiocbp + * value may be used as an argument to aio_error() and aio_return() in order to + * determine the error status and return status, respectively, of the asynchronous + * operation while it is proceeding. When the request is queued, the error status + * for the operation is [EINPROGRESS]. When all data has been successfully transferred, + * the error status shall be reset to reflect the success or failure of the operation. + * If the operation does not complete successfully, the error status for the + * operation shall be set to indicate the error. The aio_sigevent member determines + * the asynchronous notification to occur as specified in Signal Generation and + * Delivery when all operations have achieved synchronized I/O completion. All + * other members of the structure referenced by aiocbp are ignored. If the control + * block referenced by aiocbp becomes an illegal address prior to asynchronous * I/O completion, then the behavior is undefined. - * - * If the aio_fsync() function fails or aiocbp indicates an error condition, + * + * If the aio_fsync() function fails or aiocbp indicates an error condition, * data is not guaranteed to have been successfully transferred. */ static void aio_fync_work(struct rt_work* work, void* work_data) @@ -169,7 +169,7 @@ static void aio_read_work(struct rt_work* work, void* work_data) level = rt_hw_interrupt_disable(); if (len <= 0) cb->aio_result = errno; - else + else cb->aio_result = len; rt_hw_interrupt_enable(level); @@ -177,51 +177,51 @@ static void aio_read_work(struct rt_work* work, void* work_data) } /** - * The aio_read() function shall read aiocbp->aio_nbytes from the file associated - * with aiocbp->aio_fildes into the buffer pointed to by aiocbp->aio_buf. The - * function call shall return when the read request has been initiated or queued + * The aio_read() function shall read aiocbp->aio_nbytes from the file associated + * with aiocbp->aio_fildes into the buffer pointed to by aiocbp->aio_buf. The + * function call shall return when the read request has been initiated or queued * to the file or device (even when the data cannot be delivered immediately). - * - * If prioritized I/O is supported for this file, then the asynchronous operation - * shall be submitted at a priority equal to a base scheduling priority minus - * aiocbp->aio_reqprio. If Thread Execution Scheduling is not supported, then + * + * If prioritized I/O is supported for this file, then the asynchronous operation + * shall be submitted at a priority equal to a base scheduling priority minus + * aiocbp->aio_reqprio. If Thread Execution Scheduling is not supported, then * the base scheduling priority is that of the calling process; - * - * otherwise, the base scheduling priority is that of the calling thread. - * - * The aiocbp value may be used as an argument to aio_error() and aio_return() - * in order to determine the error status and return status, respectively, of - * the asynchronous operation while it is proceeding. If an error condition is - * encountered during queuing, the function call shall return without having - * initiated or queued the request. The requested operation takes place at the - * absolute position in the file as given by aio_offset, as if lseek() were called - * immediately prior to the operation with an offset equal to aio_offset and a - * whence equal to SEEK_SET. After a successful call to enqueue an asynchronous + * + * otherwise, the base scheduling priority is that of the calling thread. + * + * The aiocbp value may be used as an argument to aio_error() and aio_return() + * in order to determine the error status and return status, respectively, of + * the asynchronous operation while it is proceeding. If an error condition is + * encountered during queuing, the function call shall return without having + * initiated or queued the request. The requested operation takes place at the + * absolute position in the file as given by aio_offset, as if lseek() were called + * immediately prior to the operation with an offset equal to aio_offset and a + * whence equal to SEEK_SET. After a successful call to enqueue an asynchronous * I/O operation, the value of the file offset for the file is unspecified. * - * The aio_sigevent member specifies the notification which occurs when the + * The aio_sigevent member specifies the notification which occurs when the * request is completed. * * The aiocbp->aio_lio_opcode field shall be ignored by aio_read(). - * - * The aiocbp argument points to an aiocb structure. If the buffer pointed to by - * aiocbp->aio_buf or the control block pointed to by aiocbp becomes an illegal + * + * The aiocbp argument points to an aiocb structure. If the buffer pointed to by + * aiocbp->aio_buf or the control block pointed to by aiocbp becomes an illegal * address prior to asynchronous I/O completion, then the behavior is undefined. - * - * Simultaneous asynchronous operations using the same aiocbp produce undefined + * + * Simultaneous asynchronous operations using the same aiocbp produce undefined * results. - * + * * If synchronized I/O is enabled on the file associated with aiocbp->aio_fildes, - * the behavior of this function shall be according to the definitions of synchronized - * I/O data integrity completion and synchronized I/O file integrity completion. - * - * For any system action that changes the process memory space while an asynchronous - * I/O is outstanding to the address range being changed, the result of that action + * the behavior of this function shall be according to the definitions of synchronized + * I/O data integrity completion and synchronized I/O file integrity completion. + * + * For any system action that changes the process memory space while an asynchronous + * I/O is outstanding to the address range being changed, the result of that action * is undefined. - * - * For regular files, no data transfer shall occur past the offset maximum + * + * For regular files, no data transfer shall occur past the offset maximum * established in the open file description associated with aiocbp->aio_fildes. - * + * */ int aio_read(struct aiocb *cb) { @@ -242,16 +242,16 @@ int aio_read(struct aiocb *cb) } /** - * The aio_return() function shall return the return status associated with the - * aiocb structure referenced by the aiocbp argument. The return status for an - * asynchronous I/O operation is the value that would be returned by the corresponding - * read(), write(), or fsync() function call. If the error status for the operation - * is equal to [EINPROGRESS], then the return status for the operation is undefined. - * The aio_return() function may be called exactly once to retrieve the return - * status of a given asynchronous operation; thereafter, if the same aiocb structure - * is used in a call to aio_return() or aio_error(), an error may be returned. - * When the aiocb structure referred to by aiocbp is used to submit another asynchronous - * operation, then aio_return() may be successfully used to retrieve the return + * The aio_return() function shall return the return status associated with the + * aiocb structure referenced by the aiocbp argument. The return status for an + * asynchronous I/O operation is the value that would be returned by the corresponding + * read(), write(), or fsync() function call. If the error status for the operation + * is equal to [EINPROGRESS], then the return status for the operation is undefined. + * The aio_return() function may be called exactly once to retrieve the return + * status of a given asynchronous operation; thereafter, if the same aiocb structure + * is used in a call to aio_return() or aio_error(), an error may be returned. + * When the aiocb structure referred to by aiocbp is used to submit another asynchronous + * operation, then aio_return() may be successfully used to retrieve the return * status of that operation. */ ssize_t aio_return(struct aiocb *cb) @@ -268,23 +268,23 @@ ssize_t aio_return(struct aiocb *cb) } /** - * The aio_suspend() function shall suspend the calling thread until at least - * one of the asynchronous I/O operations referenced by the list argument has - * completed, until a signal interrupts the function, or, if timeout is not NULL, - * until the time interval specified by timeout has passed. If any of the aiocb - * structures in the list correspond to completed asynchronous I/O operations - * (that is, the error status for the operation is not equal to [EINPROGRESS]) - * at the time of the call, the function shall return without suspending the - * calling thread. The list argument is an array of pointers to asynchronous I/O - * control blocks. The nent argument indicates the number of elements in the - * array. Each aiocb structure pointed to has been used in initiating an asynchronous - * I/O request via aio_read(), aio_write(), or lio_listio(). This array may - * contain null pointers, which are ignored. If this array contains pointers - * that refer to aiocb structures that have not been used in submitting asynchronous + * The aio_suspend() function shall suspend the calling thread until at least + * one of the asynchronous I/O operations referenced by the list argument has + * completed, until a signal interrupts the function, or, if timeout is not NULL, + * until the time interval specified by timeout has passed. If any of the aiocb + * structures in the list correspond to completed asynchronous I/O operations + * (that is, the error status for the operation is not equal to [EINPROGRESS]) + * at the time of the call, the function shall return without suspending the + * calling thread. The list argument is an array of pointers to asynchronous I/O + * control blocks. The nent argument indicates the number of elements in the + * array. Each aiocb structure pointed to has been used in initiating an asynchronous + * I/O request via aio_read(), aio_write(), or lio_listio(). This array may + * contain null pointers, which are ignored. If this array contains pointers + * that refer to aiocb structures that have not been used in submitting asynchronous * I/O, the effect is undefined. - * - * If the time interval indicated in the timespec structure pointed to by timeout - * passes before any of the I/O operations referenced by list are completed, then + * + * If the time interval indicated in the timespec structure pointed to by timeout + * passes before any of the I/O operations referenced by list are completed, then * aio_suspend() shall return with an error. */ int aio_suspend(const struct aiocb *const list[], int nent, @@ -315,7 +315,7 @@ static void aio_write_work(struct rt_work* work, void* work_data) level = rt_hw_interrupt_disable(); if (len <= 0) cb->aio_result = errno; - else + else cb->aio_result = len; rt_hw_interrupt_enable(level); @@ -323,42 +323,42 @@ static void aio_write_work(struct rt_work* work, void* work_data) } /** - * The aio_write() function shall write aiocbp->aio_nbytes to the file associated - * with aiocbp->aio_fildes from the buffer pointed to by aiocbp->aio_buf. The - * function shall return when the write request has been initiated or, at a minimum, + * The aio_write() function shall write aiocbp->aio_nbytes to the file associated + * with aiocbp->aio_fildes from the buffer pointed to by aiocbp->aio_buf. The + * function shall return when the write request has been initiated or, at a minimum, * queued to the file or device. - * - * The aiocbp argument may be used as an argument to aio_error() and aio_return() - * in order to determine the error status and return status, respectively, of the + * + * The aiocbp argument may be used as an argument to aio_error() and aio_return() + * in order to determine the error status and return status, respectively, of the * asynchronous operation while it is proceeding. - * - * The aiocbp argument points to an aiocb structure. If the buffer pointed to by - * aiocbp->aio_buf or the control block pointed to by aiocbp becomes an illegal + * + * The aiocbp argument points to an aiocb structure. If the buffer pointed to by + * aiocbp->aio_buf or the control block pointed to by aiocbp becomes an illegal * address prior to asynchronous I/O completion, then the behavior is undefined. - * - * If O_APPEND is not set for the file descriptor aio_fildes, then the requested - * operation shall take place at the absolute position in the file as given by - * aio_offset, as if lseek() were called immediately prior to the operation with - * an offset equal to aio_offset and a whence equal to SEEK_SET. If O_APPEND is - * set for the file descriptor, or if aio_fildes is associated with a device that - * is incapable of seeking, write operations append to the file in the same order - * as the calls were made, except under circumstances described in Asynchronous - * I/O. After a successful call to enqueue an asynchronous I/O operation, the value + * + * If O_APPEND is not set for the file descriptor aio_fildes, then the requested + * operation shall take place at the absolute position in the file as given by + * aio_offset, as if lseek() were called immediately prior to the operation with + * an offset equal to aio_offset and a whence equal to SEEK_SET. If O_APPEND is + * set for the file descriptor, or if aio_fildes is associated with a device that + * is incapable of seeking, write operations append to the file in the same order + * as the calls were made, except under circumstances described in Asynchronous + * I/O. After a successful call to enqueue an asynchronous I/O operation, the value * of the file offset for the file is unspecified. - * - * The aio_sigevent member specifies the notification which occurs when the request + * + * The aio_sigevent member specifies the notification which occurs when the request * is completed. - * + * * The aiocbp->aio_lio_opcode field shall be ignored by aio_write(). - * - * Simultaneous asynchronous operations using the same aiocbp produce undefined + * + * Simultaneous asynchronous operations using the same aiocbp produce undefined * results. - * - * If synchronized I/O is enabled on the file associated with aiocbp->aio_fildes, - * the behavior of this function shall be according to the definitions of synchronized + * + * If synchronized I/O is enabled on the file associated with aiocbp->aio_fildes, + * the behavior of this function shall be according to the definitions of synchronized * I/O data integrity completion, and synchronized I/O file integrity completion. - * - * For regular files, no data transfer shall occur past the offset maximum established + * + * For regular files, no data transfer shall occur past the offset maximum established * in the open file description associated with aiocbp->aio_fildes. */ int aio_write(struct aiocb *cb) @@ -385,69 +385,69 @@ int aio_write(struct aiocb *cb) } /** - * The lio_listio() function shall initiate a list of I/O requests with a single + * The lio_listio() function shall initiate a list of I/O requests with a single * function call. - * - * The mode argument takes one of the values LIO_WAIT or LIO_NOWAIT declared in - * and determines whether the function returns when the I/O operations - * have been completed, or as soon as the operations have been queued. If the - * mode argument is LIO_WAIT, the function shall wait until all I/O is complete + * + * The mode argument takes one of the values LIO_WAIT or LIO_NOWAIT declared in + * and determines whether the function returns when the I/O operations + * have been completed, or as soon as the operations have been queued. If the + * mode argument is LIO_WAIT, the function shall wait until all I/O is complete * and the sig argument shall be ignored. - * - * If the mode argument is LIO_NOWAIT, the function shall return immediately, and - * asynchronous notification shall occur, according to the sig argument, when all - * the I/O operations complete. If sig is NULL, then no asynchronous notification - * shall occur. If sig is not NULL, asynchronous notification occurs as specified + * + * If the mode argument is LIO_NOWAIT, the function shall return immediately, and + * asynchronous notification shall occur, according to the sig argument, when all + * the I/O operations complete. If sig is NULL, then no asynchronous notification + * shall occur. If sig is not NULL, asynchronous notification occurs as specified * in Signal Generation and Delivery when all the requests in list have completed. - * + * * The I/O requests enumerated by list are submitted in an unspecified order. - * - * The list argument is an array of pointers to aiocb structures. The array contains + * + * The list argument is an array of pointers to aiocb structures. The array contains * nent elements. The array may contain NULL elements, which shall be ignored. - * - * If the buffer pointed to by list or the aiocb structures pointed to by the - * elements of the array list become illegal addresses before all asynchronous I/O - * completed and, if necessary, the notification is sent, then the behavior is - * undefined. If the buffers pointed to by the aio_buf member of the aiocb structure - * pointed to by the elements of the array list become illegal addresses prior to - * the asynchronous I/O associated with that aiocb structure being completed, the + * + * If the buffer pointed to by list or the aiocb structures pointed to by the + * elements of the array list become illegal addresses before all asynchronous I/O + * completed and, if necessary, the notification is sent, then the behavior is + * undefined. If the buffers pointed to by the aio_buf member of the aiocb structure + * pointed to by the elements of the array list become illegal addresses prior to + * the asynchronous I/O associated with that aiocb structure being completed, the * behavior is undefined. - * - * The aio_lio_opcode field of each aiocb structure specifies the operation to be - * performed. The supported operations are LIO_READ, LIO_WRITE, and LIO_NOP; these - * symbols are defined in . The LIO_NOP operation causes the list entry to - * be ignored. If the aio_lio_opcode element is equal to LIO_READ, then an I/O operation - * is submitted as if by a call to aio_read() with the aiocbp equal to the address - * of the aiocb structure. If the aio_lio_opcode element is equal to LIO_WRITE, then - * an I/O operation is submitted as if by a call to aio_write() with the aiocbp equal + * + * The aio_lio_opcode field of each aiocb structure specifies the operation to be + * performed. The supported operations are LIO_READ, LIO_WRITE, and LIO_NOP; these + * symbols are defined in . The LIO_NOP operation causes the list entry to + * be ignored. If the aio_lio_opcode element is equal to LIO_READ, then an I/O operation + * is submitted as if by a call to aio_read() with the aiocbp equal to the address + * of the aiocb structure. If the aio_lio_opcode element is equal to LIO_WRITE, then + * an I/O operation is submitted as if by a call to aio_write() with the aiocbp equal * to the address of the aiocb structure. - * - * The aio_fildes member specifies the file descriptor on which the operation is to + * + * The aio_fildes member specifies the file descriptor on which the operation is to * be performed. - * - * The aio_buf member specifies the address of the buffer to or from which the data + * + * The aio_buf member specifies the address of the buffer to or from which the data * is transferred. - * + * * The aio_nbytes member specifies the number of bytes of data to be transferred. - * - * The members of the aiocb structure further describe the I/O operation to be - * performed, in a manner identical to that of the corresponding aiocb structure + * + * The members of the aiocb structure further describe the I/O operation to be + * performed, in a manner identical to that of the corresponding aiocb structure * when used by the aio_read() and aio_write() functions. - * - * The nent argument specifies how many elements are members of the list; that is, + * + * The nent argument specifies how many elements are members of the list; that is, * the length of the array. - * - * The behavior of this function is altered according to the definitions of synchronized - * I/O data integrity completion and synchronized I/O file integrity completion if + * + * The behavior of this function is altered according to the definitions of synchronized + * I/O data integrity completion and synchronized I/O file integrity completion if * synchronized I/O is enabled on the file associated with aio_fildes. - * - * For regular files, no data transfer shall occur past the offset maximum established + * + * For regular files, no data transfer shall occur past the offset maximum established * in the open file description associated with aiocbp->aio_fildes. - * - * If sig->sigev_notify is SIGEV_THREAD and sig->sigev_notify_attributes is a - * non-null pointer and the block pointed to by this pointer becomes an illegal - * address prior to all asynchronous I/O being completed, then the behavior is - * undefined. + * + * If sig->sigev_notify is SIGEV_THREAD and sig->sigev_notify_attributes is a + * non-null pointer and the block pointed to by this pointer becomes an illegal + * address prior to all asynchronous I/O being completed, then the behavior is + * undefined. */ int lio_listio(int mode, struct aiocb * const list[], int nent, struct sigevent *sig) diff --git a/components/libc/aio/posix_aio.h b/components/libc/aio/posix_aio.h index f20ed48cb3..de11738515 100644 --- a/components/libc/aio/posix_aio.h +++ b/components/libc/aio/posix_aio.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/dirent.h b/components/libc/compilers/armlibc/dirent.h index d3bc58cbc5..2c0521d2e3 100644 --- a/components/libc/compilers/armlibc/dirent.h +++ b/components/libc/compilers/armlibc/dirent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -18,32 +18,32 @@ */ /* File types */ -#define FT_REGULAR 0 /* regular file */ -#define FT_SOCKET 1 /* socket file */ -#define FT_DIRECTORY 2 /* directory */ -#define FT_USER 3 /* user defined */ +#define FT_REGULAR 0 /* regular file */ +#define FT_SOCKET 1 /* socket file */ +#define FT_DIRECTORY 2 /* directory */ +#define FT_USER 3 /* user defined */ #ifdef __cplusplus extern "C" { #endif #ifndef HAVE_DIR_STRUCTURE -typedef struct +typedef struct { - int fd; /* directory file */ - char buf[512]; - int num; - int cur; + int fd; /* directory file */ + char buf[512]; + int num; + int cur; } DIR; #endif #ifndef HAVE_DIRENT_STRUCTURE struct dirent { - rt_uint8_t d_type; /* The type of the file */ - rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ - rt_uint16_t d_reclen; /* length of this record */ - char d_name[256]; /* The null-terminated file name */ + rt_uint8_t d_type; /* The type of the file */ + rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ + rt_uint16_t d_reclen; /* length of this record */ + char d_name[256]; /* The null-terminated file name */ }; #endif diff --git a/components/libc/compilers/armlibc/fcntl.h b/components/libc/compilers/armlibc/fcntl.h index 3e650a8471..f247b926e9 100644 --- a/components/libc/compilers/armlibc/fcntl.h +++ b/components/libc/compilers/armlibc/fcntl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/libc.c b/components/libc/compilers/armlibc/libc.c index fee390d4b4..971ddb8d49 100644 --- a/components/libc/compilers/armlibc/libc.c +++ b/components/libc/compilers/armlibc/libc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/libc.h b/components/libc/compilers/armlibc/libc.h index b9b1b6212d..aecf8cdc50 100644 --- a/components/libc/compilers/armlibc/libc.h +++ b/components/libc/compilers/armlibc/libc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/libc_syms.c b/components/libc/compilers/armlibc/libc_syms.c index a2e8af17f1..829d57b559 100644 --- a/components/libc/compilers/armlibc/libc_syms.c +++ b/components/libc/compilers/armlibc/libc_syms.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/mem_std.c b/components/libc/compilers/armlibc/mem_std.c index e160104a25..c350aa68fa 100644 --- a/components/libc/compilers/armlibc/mem_std.c +++ b/components/libc/compilers/armlibc/mem_std.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/stdio.c b/components/libc/compilers/armlibc/stdio.c index 5262a4dd92..c786c78aa5 100644 --- a/components/libc/compilers/armlibc/stdio.c +++ b/components/libc/compilers/armlibc/stdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/sys/errno.h b/components/libc/compilers/armlibc/sys/errno.h index 9c4307ebfb..74cc986f7c 100644 --- a/components/libc/compilers/armlibc/sys/errno.h +++ b/components/libc/compilers/armlibc/sys/errno.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/sys/ioctl.h b/components/libc/compilers/armlibc/sys/ioctl.h index 033a57014a..df17b19a61 100644 --- a/components/libc/compilers/armlibc/sys/ioctl.h +++ b/components/libc/compilers/armlibc/sys/ioctl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/sys/mman.h b/components/libc/compilers/armlibc/sys/mman.h index 8c61b32b7c..6a260ccd70 100644 --- a/components/libc/compilers/armlibc/sys/mman.h +++ b/components/libc/compilers/armlibc/sys/mman.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/sys/stat.h b/components/libc/compilers/armlibc/sys/stat.h index ce95230e88..c4b42083c4 100644 --- a/components/libc/compilers/armlibc/sys/stat.h +++ b/components/libc/compilers/armlibc/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/sys/types.h b/components/libc/compilers/armlibc/sys/types.h index 491445d72b..a6b245b81c 100644 --- a/components/libc/compilers/armlibc/sys/types.h +++ b/components/libc/compilers/armlibc/sys/types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/sys/unistd.h b/components/libc/compilers/armlibc/sys/unistd.h index ee1e1c4db9..7752a1caf7 100644 --- a/components/libc/compilers/armlibc/sys/unistd.h +++ b/components/libc/compilers/armlibc/sys/unistd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c index 8addb3e163..1efbfd37d5 100644 --- a/components/libc/compilers/armlibc/syscalls.c +++ b/components/libc/compilers/armlibc/syscalls.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -9,7 +9,7 @@ * 2013-11-24 aozima fixed _sys_read()/_sys_write() issues. * 2014-08-03 bernard If using msh, use system() implementation * in msh. - * 2020-08-05 Meco Man fixed _sys_flen() compiling-warning when + * 2020-08-05 Meco Man fixed _sys_flen() compiling-warning when * RT_USING_DFS is not defined * 2020-02-13 Meco Man re-implement exit() and abort() * 2020-02-14 Meco Man implement _sys_tmpnam() @@ -346,7 +346,7 @@ int system(const char *string) #ifdef __MICROLIB #include -int fputc(int c, FILE *f) +int fputc(int c, FILE *f) { char ch[2] = {0}; @@ -355,7 +355,7 @@ int fputc(int c, FILE *f) return 1; } -int fgetc(FILE *f) +int fgetc(FILE *f) { #ifdef RT_USING_POSIX char ch; diff --git a/components/libc/compilers/armlibc/unistd.h b/components/libc/compilers/armlibc/unistd.h index 736fc219a8..cd77a12e3b 100644 --- a/components/libc/compilers/armlibc/unistd.h +++ b/components/libc/compilers/armlibc/unistd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/common/stdlib.c b/components/libc/compilers/common/stdlib.c index 48a86098cd..9d8952e99e 100644 --- a/components/libc/compilers/common/stdlib.c +++ b/components/libc/compilers/common/stdlib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index e4d60d2d11..76e6636d13 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/common/termios.h b/components/libc/compilers/common/termios.h index 414d0c0cb3..2960d52c58 100644 --- a/components/libc/compilers/common/termios.h +++ b/components/libc/compilers/common/termios.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index ed72cc1f3f..0bad6bdf8e 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -181,7 +181,7 @@ RTM_EXPORT(ctime); * * @param time_t * t the timestamp pointer, if not used, keep NULL. * - * @return The value ((time_t)-1) is returned if the calendar time is not available. + * @return The value ((time_t)-1) is returned if the calendar time is not available. * If timer is not a NULL pointer, the return value is also stored in timer. * */ @@ -366,7 +366,7 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz) RTM_EXPORT(settimeofday); /* inherent in the toolchain */ -RTM_EXPORT(difftime); +RTM_EXPORT(difftime); RTM_EXPORT(strftime); #ifdef RT_USING_POSIX diff --git a/components/libc/compilers/common/unistd.c b/components/libc/compilers/common/unistd.c index 0966242e55..20130cbb8a 100644 --- a/components/libc/compilers/common/unistd.c +++ b/components/libc/compilers/common/unistd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/dirent.h b/components/libc/compilers/dlib/dirent.h index 4c897cc550..2c0521d2e3 100644 --- a/components/libc/compilers/dlib/dirent.h +++ b/components/libc/compilers/dlib/dirent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/environ.c b/components/libc/compilers/dlib/environ.c index ac19758838..84b04fda55 100644 --- a/components/libc/compilers/dlib/environ.c +++ b/components/libc/compilers/dlib/environ.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/fcntl.h b/components/libc/compilers/dlib/fcntl.h index ce95230e88..c4b42083c4 100644 --- a/components/libc/compilers/dlib/fcntl.h +++ b/components/libc/compilers/dlib/fcntl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/libc.c b/components/libc/compilers/dlib/libc.c index 8b42411a6b..d0dca7c5f6 100644 --- a/components/libc/compilers/dlib/libc.c +++ b/components/libc/compilers/dlib/libc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/libc.h b/components/libc/compilers/dlib/libc.h index 5b46bee0c8..fc3cafca78 100644 --- a/components/libc/compilers/dlib/libc.h +++ b/components/libc/compilers/dlib/libc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/rmtx.c b/components/libc/compilers/dlib/rmtx.c index 69405c8f6a..66c3f9377d 100644 --- a/components/libc/compilers/dlib/rmtx.c +++ b/components/libc/compilers/dlib/rmtx.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -22,7 +22,7 @@ void _Mtxinit(_Rmtx *m) rt_mutex_t mutex; RT_ASSERT(m != RT_NULL); - + mutex = (rt_mutex_t)m; rt_mutex_init(mutex, "iarMtx", RT_IPC_FLAG_FIFO); } diff --git a/components/libc/compilers/dlib/stdio.c b/components/libc/compilers/dlib/stdio.c index b35ade7a38..c11157d759 100644 --- a/components/libc/compilers/dlib/stdio.c +++ b/components/libc/compilers/dlib/stdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/sys/errno.h b/components/libc/compilers/dlib/sys/errno.h index 1ad4c8acc0..54a1d33cd0 100644 --- a/components/libc/compilers/dlib/sys/errno.h +++ b/components/libc/compilers/dlib/sys/errno.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/sys/mman.h b/components/libc/compilers/dlib/sys/mman.h index 8c61b32b7c..6a260ccd70 100644 --- a/components/libc/compilers/dlib/sys/mman.h +++ b/components/libc/compilers/dlib/sys/mman.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/sys/signal.h b/components/libc/compilers/dlib/sys/signal.h index 22adb1228b..a30235f2b2 100644 --- a/components/libc/compilers/dlib/sys/signal.h +++ b/components/libc/compilers/dlib/sys/signal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/sys/stat.h b/components/libc/compilers/dlib/sys/stat.h index ce95230e88..c4b42083c4 100644 --- a/components/libc/compilers/dlib/sys/stat.h +++ b/components/libc/compilers/dlib/sys/stat.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/sys/types.h b/components/libc/compilers/dlib/sys/types.h index 7e14bbbee3..6e2d1ce839 100644 --- a/components/libc/compilers/dlib/sys/types.h +++ b/components/libc/compilers/dlib/sys/types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/sys/unistd.h b/components/libc/compilers/dlib/sys/unistd.h index 5b86822635..14966a2bad 100644 --- a/components/libc/compilers/dlib/sys/unistd.h +++ b/components/libc/compilers/dlib/sys/unistd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -21,22 +21,22 @@ #include #else -#define _FREAD 0x0001 /* read enabled */ -#define _FWRITE 0x0002 /* write enabled */ -#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ -#define _FMARK 0x0010 /* internal; mark during gc() */ -#define _FDEFER 0x0020 /* internal; defer for next gc pass */ -#define _FASYNC 0x0040 /* signal pgrp when data ready */ -#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ -#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ -#define _FCREAT 0x0200 /* open with file create */ -#define _FTRUNC 0x0400 /* open with truncation */ -#define _FEXCL 0x0800 /* error on open if file exists */ -#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ -#define _FSYNC 0x2000 /* do all writes synchronously */ -#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ -#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ -#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ +#define _FREAD 0x0001 /* read enabled */ +#define _FWRITE 0x0002 /* write enabled */ +#define _FAPPEND 0x0008 /* append (writes guaranteed at the end) */ +#define _FMARK 0x0010 /* internal; mark during gc() */ +#define _FDEFER 0x0020 /* internal; defer for next gc pass */ +#define _FASYNC 0x0040 /* signal pgrp when data ready */ +#define _FSHLOCK 0x0080 /* BSD flock() shared lock present */ +#define _FEXLOCK 0x0100 /* BSD flock() exclusive lock present */ +#define _FCREAT 0x0200 /* open with file create */ +#define _FTRUNC 0x0400 /* open with truncation */ +#define _FEXCL 0x0800 /* error on open if file exists */ +#define _FNBIO 0x1000 /* non blocking I/O (sys5 style) */ +#define _FSYNC 0x2000 /* do all writes synchronously */ +#define _FNONBLOCK 0x4000 /* non blocking I/O (POSIX style) */ +#define _FNDELAY _FNONBLOCK /* non blocking I/O (4.2 style) */ +#define _FNOCTTY 0x8000 /* don't assign a ctty on this open */ #endif diff --git a/components/libc/compilers/dlib/syscall_close.c b/components/libc/compilers/dlib/syscall_close.c index f46162deb7..7ed1cc2f2d 100644 --- a/components/libc/compilers/dlib/syscall_close.c +++ b/components/libc/compilers/dlib/syscall_close.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscall_lseek.c b/components/libc/compilers/dlib/syscall_lseek.c index b79cc410b7..47a069bf0a 100644 --- a/components/libc/compilers/dlib/syscall_lseek.c +++ b/components/libc/compilers/dlib/syscall_lseek.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscall_mem.c b/components/libc/compilers/dlib/syscall_mem.c index 236ef1c12d..9c6de64455 100644 --- a/components/libc/compilers/dlib/syscall_mem.c +++ b/components/libc/compilers/dlib/syscall_mem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscall_open.c b/components/libc/compilers/dlib/syscall_open.c index 96e02dc32a..37bfcecb47 100644 --- a/components/libc/compilers/dlib/syscall_open.c +++ b/components/libc/compilers/dlib/syscall_open.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscall_read.c b/components/libc/compilers/dlib/syscall_read.c index e248211486..afb661bd93 100644 --- a/components/libc/compilers/dlib/syscall_read.c +++ b/components/libc/compilers/dlib/syscall_read.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscall_remove.c b/components/libc/compilers/dlib/syscall_remove.c index f7e64d1997..7d74236f4c 100644 --- a/components/libc/compilers/dlib/syscall_remove.c +++ b/components/libc/compilers/dlib/syscall_remove.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscall_write.c b/components/libc/compilers/dlib/syscall_write.c index 85c0da22c3..de464530b8 100644 --- a/components/libc/compilers/dlib/syscall_write.c +++ b/components/libc/compilers/dlib/syscall_write.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/syscalls.c b/components/libc/compilers/dlib/syscalls.c index 007ea76bd1..e1c9562b3a 100644 --- a/components/libc/compilers/dlib/syscalls.c +++ b/components/libc/compilers/dlib/syscalls.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/dlib/unistd.h b/components/libc/compilers/dlib/unistd.h index a07d8409c2..72b9d538ec 100644 --- a/components/libc/compilers/dlib/unistd.h +++ b/components/libc/compilers/dlib/unistd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/newlib/libc.c b/components/libc/compilers/newlib/libc.c index 2234c36f98..9834a9a015 100644 --- a/components/libc/compilers/newlib/libc.c +++ b/components/libc/compilers/newlib/libc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -19,7 +19,7 @@ #include #endif -int _EXFUN(putenv,(char *__string)); +int _EXFUN(putenv,(char *__string)); int libc_system_init(void) { diff --git a/components/libc/compilers/newlib/libc.h b/components/libc/compilers/newlib/libc.h index 9a76ffb79f..c1f76d7605 100644 --- a/components/libc/compilers/newlib/libc.h +++ b/components/libc/compilers/newlib/libc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/newlib/libc_syms.c b/components/libc/compilers/newlib/libc_syms.c index 4b0ee355f0..aaf6980d6b 100644 --- a/components/libc/compilers/newlib/libc_syms.c +++ b/components/libc/compilers/newlib/libc_syms.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/newlib/machine/time.h b/components/libc/compilers/newlib/machine/time.h index d46533eb39..ff754d2473 100644 --- a/components/libc/compilers/newlib/machine/time.h +++ b/components/libc/compilers/newlib/machine/time.h @@ -9,4 +9,4 @@ int nanosleep (const struct timespec *, struct timespec *); #endif -#endif /* _MACHTIME_H_ */ +#endif /* _MACHTIME_H_ */ diff --git a/components/libc/compilers/newlib/minilib.c b/components/libc/compilers/newlib/minilib.c index ca1bea0f91..f6df38f67b 100644 --- a/components/libc/compilers/newlib/minilib.c +++ b/components/libc/compilers/newlib/minilib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/newlib/stdio.c b/components/libc/compilers/newlib/stdio.c index 233a447396..ce5bdb75cb 100644 --- a/components/libc/compilers/newlib/stdio.c +++ b/components/libc/compilers/newlib/stdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -15,7 +15,7 @@ #define STDIO_DEVICE_NAME_MAX 32 -int _EXFUN(fileno, (FILE *)); +int _EXFUN(fileno, (FILE *)); static FILE* std_console = NULL; @@ -48,7 +48,7 @@ int libc_stdio_set_console(const char* device_name, int mode) { _GLOBAL_REENT->_stdin = std_console; } - else + else { _GLOBAL_REENT->_stdin = NULL; } diff --git a/components/libc/compilers/newlib/sys/dirent.h b/components/libc/compilers/newlib/sys/dirent.h index db8c0655a1..bfba586093 100644 --- a/components/libc/compilers/newlib/sys/dirent.h +++ b/components/libc/compilers/newlib/sys/dirent.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -17,36 +17,36 @@ */ /* File types */ -#define FT_REGULAR 0 /* regular file */ -#define FT_SOCKET 1 /* socket file */ -#define FT_DIRECTORY 2 /* directory */ -#define FT_USER 3 /* user defined */ +#define FT_REGULAR 0 /* regular file */ +#define FT_SOCKET 1 /* socket file */ +#define FT_DIRECTORY 2 /* directory */ +#define FT_USER 3 /* user defined */ -#define DT_UNKNOWN 0x00 -#define DT_REG 0x01 -#define DT_DIR 0x02 +#define DT_UNKNOWN 0x00 +#define DT_REG 0x01 +#define DT_DIR 0x02 #ifdef __cplusplus extern "C" { #endif #ifndef HAVE_DIR_STRUCTURE -typedef struct +typedef struct { - int fd; /* directory file */ - char buf[512]; - int num; - int cur; + int fd; /* directory file */ + char buf[512]; + int num; + int cur; } DIR; #endif #ifndef HAVE_DIRENT_STRUCTURE struct dirent { - rt_uint8_t d_type; /* The type of the file */ - rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ - rt_uint16_t d_reclen; /* length of this record */ - char d_name[256]; /* The null-terminated file name */ + rt_uint8_t d_type; /* The type of the file */ + rt_uint8_t d_namlen; /* The length of the not including the terminating null file name */ + rt_uint16_t d_reclen; /* length of this record */ + char d_name[256]; /* The null-terminated file name */ }; #endif diff --git a/components/libc/compilers/newlib/sys/mman.h b/components/libc/compilers/newlib/sys/mman.h index 8c61b32b7c..6a260ccd70 100644 --- a/components/libc/compilers/newlib/sys/mman.h +++ b/components/libc/compilers/newlib/sys/mman.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/newlib/sys/statfs.h b/components/libc/compilers/newlib/sys/statfs.h index 3c923a21f9..0996af9a18 100644 --- a/components/libc/compilers/newlib/sys/statfs.h +++ b/components/libc/compilers/newlib/sys/statfs.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -13,9 +13,9 @@ struct statfs { - rt_size_t f_bsize; /* block size */ - rt_size_t f_blocks; /* total data blocks in file system */ - rt_size_t f_bfree; /* free blocks in file system */ + rt_size_t f_bsize; /* block size */ + rt_size_t f_blocks; /* total data blocks in file system */ + rt_size_t f_bfree; /* free blocks in file system */ }; #endif diff --git a/components/libc/compilers/newlib/sys/termios.h b/components/libc/compilers/newlib/sys/termios.h index ce95230e88..c4b42083c4 100644 --- a/components/libc/compilers/newlib/sys/termios.h +++ b/components/libc/compilers/newlib/sys/termios.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/compilers/newlib/syscalls.c b/components/libc/compilers/newlib/syscalls.c index e54d7583cb..6cbc11fd6a 100644 --- a/components/libc/compilers/newlib/syscalls.c +++ b/components/libc/compilers/newlib/syscalls.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/getline/posix_getline.c b/components/libc/getline/posix_getline.c index 99bcf5363e..794ac3a07d 100644 --- a/components/libc/getline/posix_getline.c +++ b/components/libc/getline/posix_getline.c @@ -1,11 +1,11 @@ /* posix_getline.c * RT-Thread POSIX * getdelim(), getline() - read a delimited record from stream, ersatz implementation - * This code is unlicensed -- free and released into the public domain. + * This code is unlicensed -- free and released into the public domain. * https://man7.org/linux/man-pages/man3/getline.3.html * Authors: * https://github.com/ivanrad/getline - * + * * Meco Man 2020-09-03 porting to RT-Thread */ diff --git a/components/libc/getline/posix_getline.h b/components/libc/getline/posix_getline.h index e9e0bf9c2b..13a4487d7f 100644 --- a/components/libc/getline/posix_getline.h +++ b/components/libc/getline/posix_getline.h @@ -1,7 +1,7 @@ /* posix_getline.h * RT-Thread POSIX * getdelim(), getline() - read a delimited record from stream, ersatz implementation - * This code is unlicensed -- free and released into the public domain. + * This code is unlicensed -- free and released into the public domain. * https://man7.org/linux/man-pages/man3/getline.3.html * Authors: * https://github.com/ivanrad/getline diff --git a/components/libc/libdl/arch/arm.c b/components/libc/libdl/arch/arm.c index a53c04f0bc..6a884bdb54 100644 --- a/components/libc/libdl/arch/arm.c +++ b/components/libc/libdl/arch/arm.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2018/08/29 Bernard first version diff --git a/components/libc/libdl/arch/x86.c b/components/libc/libdl/arch/x86.c index 16f2322fb4..e7ad714a03 100644 --- a/components/libc/libdl/arch/x86.c +++ b/components/libc/libdl/arch/x86.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2018/09/15 parai first version @@ -13,9 +13,9 @@ #ifdef __i386__ -#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ -#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ -#define R_X86_64_RELATIVE 8 /* Adjust by program base */ +#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ +#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ +#define R_X86_64_RELATIVE 8 /* Adjust by program base */ int dlmodule_relocate(struct rt_dlmodule *module, Elf32_Rel *rel, Elf32_Addr sym_val) { Elf32_Addr *where, tmp; diff --git a/components/libc/libdl/dlclose.c b/components/libc/libdl/dlclose.c index 1202e13f2c..876a1576c8 100644 --- a/components/libc/libdl/dlclose.c +++ b/components/libc/libdl/dlclose.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/libdl/dlelf.c b/components/libc/libdl/dlelf.c index 55ef0d8951..f573122a48 100644 --- a/components/libc/libdl/dlelf.c +++ b/components/libc/libdl/dlelf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -172,7 +172,7 @@ rt_err_t dlmodule_load_shared_object(struct rt_dlmodule* module, void *module_pt rel ++; } - if (unsolved) + if (unsolved) return -RT_ERROR; } @@ -335,7 +335,7 @@ rt_err_t dlmodule_load_relocated_object(struct rt_dlmodule* module, void *module (rt_uint8_t *)elf_module + shdr[index].sh_offset, shdr[index].sh_size); rodata_addr = (rt_uint32_t)ptr; - LOG_D("load rodata 0x%x, size %d, rodata 0x%x", ptr, + LOG_D("load rodata 0x%x, size %d, rodata 0x%x", ptr, shdr[index].sh_size, *(rt_uint32_t *)data_addr); ptr += shdr[index].sh_size; } @@ -347,7 +347,7 @@ rt_err_t dlmodule_load_relocated_object(struct rt_dlmodule* module, void *module (rt_uint8_t *)elf_module + shdr[index].sh_offset, shdr[index].sh_size); data_addr = (rt_uint32_t)ptr; - LOG_D("load data 0x%x, size %d, data 0x%x", ptr, + LOG_D("load data 0x%x, size %d, data 0x%x", ptr, shdr[index].sh_size, *(rt_uint32_t *)data_addr); ptr += shdr[index].sh_size; } @@ -396,7 +396,7 @@ rt_err_t dlmodule_load_relocated_object(struct rt_dlmodule* module, void *module if (sym->st_shndx != STN_UNDEF) { Elf32_Addr addr = 0; - + if ((ELF_ST_TYPE(sym->st_info) == STT_SECTION) || (ELF_ST_TYPE(sym->st_info) == STT_OBJECT)) { diff --git a/components/libc/libdl/dlelf.h b/components/libc/libdl/dlelf.h index 014ebe85c8..ad9e2cdade 100644 --- a/components/libc/libdl/dlelf.h +++ b/components/libc/libdl/dlelf.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2018/08/29 Bernard first version diff --git a/components/libc/libdl/dlerror.c b/components/libc/libdl/dlerror.c index ad9b630e4c..de948eb16b 100644 --- a/components/libc/libdl/dlerror.c +++ b/components/libc/libdl/dlerror.c @@ -1,8 +1,8 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2010-11-17 yi.qiu first version @@ -13,6 +13,6 @@ const char *dlerror(void) { - return "TODO"; + return "TODO"; } RTM_EXPORT(dlerror) diff --git a/components/libc/libdl/dlfcn.h b/components/libc/libdl/dlfcn.h index 55273a41eb..f5c9063f2f 100644 --- a/components/libc/libdl/dlfcn.h +++ b/components/libc/libdl/dlfcn.h @@ -1,8 +1,8 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 - * + * * Change Logs: * Date Author Notes * 2010-11-17 yi.qiu first version diff --git a/components/libc/libdl/dlmodule.c b/components/libc/libdl/dlmodule.c index 314cf52709..c4bbb26b37 100644 --- a/components/libc/libdl/dlmodule.c +++ b/components/libc/libdl/dlmodule.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -547,7 +547,7 @@ struct rt_dlmodule* dlmodule_exec(const char* pgname, const char* cmd, int cmd_s if (module->priority > RT_THREAD_PRIORITY_MAX) module->priority = RT_THREAD_PRIORITY_MAX - 1; if (module->stack_size < 2048 || module->stack_size > (1024 * 32)) module->stack_size = 2048; - tid = rt_thread_create(module->parent.name, _dlmodule_thread_entry, (void*)module, + tid = rt_thread_create(module->parent.name, _dlmodule_thread_entry, (void*)module, module->stack_size, module->priority, 10); if (tid) { @@ -724,7 +724,7 @@ struct rt_dlmodule* dlmodule_exec_custom(const char* pgname, const char* cmd, in if (module->priority > RT_THREAD_PRIORITY_MAX) module->priority = RT_THREAD_PRIORITY_MAX - 1; if (module->stack_size < 2048 || module->stack_size > (1024 * 32)) module->stack_size = 2048; - tid = rt_thread_create(module->parent.name, _dlmodule_thread_entry, (void*)module, + tid = rt_thread_create(module->parent.name, _dlmodule_thread_entry, (void*)module, module->stack_size, module->priority, 10); if (tid) { @@ -758,7 +758,7 @@ void dlmodule_exit(int ret_code) rt_enter_critical(); /* module is not running */ - if (module->stat != RT_DLMODULE_STAT_RUNNING) + if (module->stat != RT_DLMODULE_STAT_RUNNING) { /* restore scheduling */ rt_exit_critical(); diff --git a/components/libc/libdl/dlmodule.h b/components/libc/libdl/dlmodule.h index b366c7603e..183faca159 100644 --- a/components/libc/libdl/dlmodule.h +++ b/components/libc/libdl/dlmodule.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/libdl/dlopen.c b/components/libc/libdl/dlopen.c index a8202ec607..bcb57d78f0 100644 --- a/components/libc/libdl/dlopen.c +++ b/components/libc/libdl/dlopen.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -43,12 +43,12 @@ void* dlopen(const char *filename, int flags) /* find in module list */ module = dlmodule_find(fullpath); - if(module != RT_NULL) + if(module != RT_NULL) { rt_exit_critical(); module->nref++; } - else + else { rt_exit_critical(); module = dlmodule_load(fullpath); diff --git a/components/libc/libdl/dlsym.c b/components/libc/libdl/dlsym.c index ed0f183d83..f7c1c901fd 100644 --- a/components/libc/libdl/dlsym.c +++ b/components/libc/libdl/dlsym.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -17,7 +17,7 @@ void* dlsym(void *handle, const char* symbol) { int i; struct rt_dlmodule *module; - + RT_ASSERT(handle != RT_NULL); module = (struct rt_dlmodule *)handle; diff --git a/components/libc/mmap/posix_mmap.c b/components/libc/mmap/posix_mmap.c index a16ace8306..e68b82e640 100644 --- a/components/libc/mmap/posix_mmap.c +++ b/components/libc/mmap/posix_mmap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/mqueue.c b/components/libc/pthreads/mqueue.c index 003b49b9a0..1af0ab2919 100644 --- a/components/libc/pthreads/mqueue.c +++ b/components/libc/pthreads/mqueue.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/mqueue.h b/components/libc/pthreads/mqueue.h index 5cadde3ae8..5152bfad29 100644 --- a/components/libc/pthreads/mqueue.h +++ b/components/libc/pthreads/mqueue.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/posix_types.h b/components/libc/pthreads/posix_types.h index ca20464bb5..f2d806cc9a 100644 --- a/components/libc/pthreads/posix_types.h +++ b/components/libc/pthreads/posix_types.h @@ -1,11 +1,11 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes - * 2013-12-23 Bernard Add the checking for ESHUTDOWN + * 2013-12-23 Bernard Add the checking for ESHUTDOWN */ #ifndef __POSIX_TYPES_H__ diff --git a/components/libc/pthreads/pthread.c b/components/libc/pthreads/pthread.c index 7430510bf2..8a728c4e99 100644 --- a/components/libc/pthreads/pthread.c +++ b/components/libc/pthreads/pthread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -201,7 +201,7 @@ int pthread_create(pthread_t *pid, /* allocate posix thread data */ pth_id = _pthread_data_create(); - if (pth_id == PTHREAD_NUM_MAX) + if (pth_id == PTHREAD_NUM_MAX) { ret = ENOMEM; goto __exit; diff --git a/components/libc/pthreads/pthread.h b/components/libc/pthreads/pthread.h index 7bb72b726c..8639c1604b 100644 --- a/components/libc/pthreads/pthread.h +++ b/components/libc/pthreads/pthread.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -161,7 +161,7 @@ int pthread_attr_getguardsize(pthread_attr_t const *attr, size_t *guard_size); int pthread_attr_setscope(pthread_attr_t *attr, int scope); int pthread_attr_getscope(pthread_attr_t const *attr); int pthread_system_init(void); -int pthread_create (pthread_t *tid, const pthread_attr_t *attr, +int pthread_create (pthread_t *tid, const pthread_attr_t *attr, void *(*start) (void *), void *arg); int pthread_detach (pthread_t thread); diff --git a/components/libc/pthreads/pthread_attr.c b/components/libc/pthreads/pthread_attr.c index 2294599bf3..4aedf5a90d 100644 --- a/components/libc/pthreads/pthread_attr.c +++ b/components/libc/pthreads/pthread_attr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -16,7 +16,7 @@ #define DEFAULT_STACK_SIZE 2048 #define DEFAULT_PRIORITY (RT_THREAD_PRIORITY_MAX/2 + RT_THREAD_PRIORITY_MAX/4) -const pthread_attr_t pthread_default_attr = +const pthread_attr_t pthread_default_attr = { 0, /* stack base */ DEFAULT_STACK_SIZE, /* stack size */ diff --git a/components/libc/pthreads/pthread_barrier.c b/components/libc/pthreads/pthread_barrier.c index d76fe7f13f..1a5b7fa3f9 100644 --- a/components/libc/pthreads/pthread_barrier.c +++ b/components/libc/pthreads/pthread_barrier.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/pthread_cond.c b/components/libc/pthreads/pthread_cond.c index 38dc697469..59c271bf6e 100644 --- a/components/libc/pthreads/pthread_cond.c +++ b/components/libc/pthreads/pthread_cond.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -84,10 +84,10 @@ int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) rt_snprintf(cond_name, sizeof(cond_name), "cond%02d", cond_num++); - if (attr == RT_NULL) /* use default value */ - cond->attr = PTHREAD_PROCESS_PRIVATE; - else - cond->attr = *attr; + if (attr == RT_NULL) /* use default value */ + cond->attr = PTHREAD_PROCESS_PRIVATE; + else + cond->attr = *attr; result = rt_sem_init(&cond->sem, cond_name, 0, RT_IPC_FLAG_FIFO); if (result != RT_EOK) diff --git a/components/libc/pthreads/pthread_internal.h b/components/libc/pthreads/pthread_internal.h index 240741e21a..1fce29f636 100644 --- a/components/libc/pthreads/pthread_internal.h +++ b/components/libc/pthreads/pthread_internal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/pthread_mutex.c b/components/libc/pthreads/pthread_mutex.c index 8f96531782..a681380b11 100644 --- a/components/libc/pthreads/pthread_mutex.c +++ b/components/libc/pthreads/pthread_mutex.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -211,7 +211,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) result = rt_mutex_release(&(mutex->lock)); if (result == RT_EOK) return 0; - + return EINVAL; } RTM_EXPORT(pthread_mutex_unlock); diff --git a/components/libc/pthreads/pthread_rwlock.c b/components/libc/pthreads/pthread_rwlock.c index 64a0e221b4..1c2fe19f5f 100644 --- a/components/libc/pthreads/pthread_rwlock.c +++ b/components/libc/pthreads/pthread_rwlock.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -60,7 +60,7 @@ int pthread_rwlock_init(pthread_rwlock_t *rwlock, pthread_mutex_init(&(rwlock->rw_mutex), NULL); pthread_cond_init(&(rwlock->rw_condreaders), NULL); pthread_cond_init(&(rwlock->rw_condwriters), NULL); - + rwlock->rw_nwaitwriters = 0; rwlock->rw_nwaitreaders = 0; rwlock->rw_refcount = 0; @@ -117,7 +117,7 @@ int pthread_rwlock_destroy (pthread_rwlock_t *rwlock) pthread_mutex_unlock(&rwlock->rw_mutex); if (result == 0) pthread_mutex_destroy(&rwlock->rw_mutex); - + return result; } RTM_EXPORT(pthread_rwlock_destroy); @@ -234,7 +234,7 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, result = pthread_cond_timedwait(&rwlock->rw_condwriters, &rwlock->rw_mutex, abstime); /* rw_mutex should have been taken again when returned from waiting */ rwlock->rw_nwaitwriters--; - + if (result != 0) break; } @@ -324,7 +324,7 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) result = pthread_cond_wait(&rwlock->rw_condwriters, &rwlock->rw_mutex); /* rw_mutex should have been taken again when returned from waiting */ rwlock->rw_nwaitwriters--; - + if (result != 0) break; } diff --git a/components/libc/pthreads/pthread_spin.c b/components/libc/pthreads/pthread_spin.c index b31f4f6393..3f3dc1593c 100644 --- a/components/libc/pthreads/pthread_spin.c +++ b/components/libc/pthreads/pthread_spin.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/pthread_tls.c b/components/libc/pthreads/pthread_tls.c index 4b97d796d9..d48df7f2dd 100644 --- a/components/libc/pthreads/pthread_tls.c +++ b/components/libc/pthreads/pthread_tls.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/sched.c b/components/libc/pthreads/sched.c index a1bf50985e..5f2a53c01f 100644 --- a/components/libc/pthreads/sched.c +++ b/components/libc/pthreads/sched.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/sched.h b/components/libc/pthreads/sched.h index dbaf66edc2..07e2c0c6a8 100644 --- a/components/libc/pthreads/sched.h +++ b/components/libc/pthreads/sched.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/semaphore.c b/components/libc/pthreads/semaphore.c index 2ed93e99b6..398cdf1f49 100644 --- a/components/libc/pthreads/semaphore.c +++ b/components/libc/pthreads/semaphore.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/pthreads/semaphore.h b/components/libc/pthreads/semaphore.h index d135ae9261..872226e385 100644 --- a/components/libc/pthreads/semaphore.h +++ b/components/libc/pthreads/semaphore.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/signal/posix_signal.c b/components/libc/signal/posix_signal.c index c0dd90e637..b06fe12685 100644 --- a/components/libc/signal/posix_signal.c +++ b/components/libc/signal/posix_signal.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/signal/posix_signal.h b/components/libc/signal/posix_signal.h index 896d6b6da4..fa8ad38fa6 100644 --- a/components/libc/signal/posix_signal.h +++ b/components/libc/signal/posix_signal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/termios/posix_termios.c b/components/libc/termios/posix_termios.c index 9c736c3184..01ba010c86 100644 --- a/components/libc/termios/posix_termios.c +++ b/components/libc/termios/posix_termios.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/libc/termios/posix_termios.h b/components/libc/termios/posix_termios.h index c61191b7dc..5bd1999b0a 100644 --- a/components/libc/termios/posix_termios.h +++ b/components/libc/termios/posix_termios.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp.c b/components/lwp/lwp.c index 7881fcc68f..9789595ee7 100644 --- a/components/lwp/lwp.c +++ b/components/lwp/lwp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp.h b/components/lwp/lwp.h index f013f36768..3607f89b17 100644 --- a/components/lwp/lwp.h +++ b/components/lwp/lwp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp_mem.c b/components/lwp/lwp_mem.c index 63fd5c89e1..2063fbb983 100644 --- a/components/lwp/lwp_mem.c +++ b/components/lwp/lwp_mem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -98,7 +98,7 @@ void rt_lwp_mem_init(struct rt_lwp *lwp) void rt_lwp_mem_deinit(struct rt_lwp *lwp) { struct rt_list_node *node; - + RT_ASSERT(lwp != RT_NULL); node = lwp->hlist.next; @@ -161,7 +161,7 @@ void rt_lwp_mem_free(void *addr) /* get memory item */ header_ptr = (struct rt_lwp_memheap_item *)((rt_uint8_t *)addr - RT_MEMHEAP_SIZE); RT_ASSERT(header_ptr); - + lwp_heap = header_ptr->pool_ptr; RT_ASSERT(lwp_heap); diff --git a/components/lwp/lwp_mem.h b/components/lwp/lwp_mem.h index 8d333cfe4f..7ef1c2293c 100644 --- a/components/lwp/lwp_mem.h +++ b/components/lwp/lwp_mem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp_memheap.c b/components/lwp/lwp_memheap.c index 7d512a503f..7516fa0a30 100644 --- a/components/lwp/lwp_memheap.c +++ b/components/lwp/lwp_memheap.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp_memheap.h b/components/lwp/lwp_memheap.h index d0c09dfd01..845feb8594 100644 --- a/components/lwp/lwp_memheap.h +++ b/components/lwp/lwp_memheap.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp_syscall.c b/components/lwp/lwp_syscall.c index be95c5fb89..02915ab1cc 100644 --- a/components/lwp/lwp_syscall.c +++ b/components/lwp/lwp_syscall.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/lwp/lwp_syscall.h b/components/lwp/lwp_syscall.h index a2809059f0..ba1b34a648 100644 --- a/components/lwp/lwp_syscall.h +++ b/components/lwp/lwp_syscall.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -23,12 +23,12 @@ typedef uint32_t id_t; /* may contain pid, uid or gid */ /* * Process priority specifications to get/setpriority. */ -#define PRIO_MIN (-20) -#define PRIO_MAX 20 +#define PRIO_MIN (-20) +#define PRIO_MAX 20 -#define PRIO_PROCESS 0 /* only support lwp process */ -#define PRIO_PGRP 1 -#define PRIO_USER 2 +#define PRIO_PROCESS 0 /* only support lwp process */ +#define PRIO_PGRP 1 +#define PRIO_USER 2 #ifndef TIMEVAL_TO_TIMESPEC #define TIMEVAL_TO_TIMESPEC(tv, ts) { \ diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index ce8559f129..6d4c040856 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -70,8 +70,8 @@ struct at_socket *at_get_socket(int socket) return at_sock; } } - } - + } + rt_hw_interrupt_enable(level); return RT_NULL; @@ -289,7 +289,7 @@ static int alloc_empty_socket(rt_slist_t *l) rt_slist_for_each(node, &_socket_list) { at_sock = rt_slist_entry(node, struct at_socket, list); - if(at_sock->socket != idx) + if(at_sock->socket != idx) break; idx++; pre_node = node; @@ -337,7 +337,7 @@ static struct at_socket *alloc_socket_by_device(struct at_device *device, enum a { goto __err; } - + sock = &(device->sockets[idx]); /* the socket descriptor is the number of sockte lists */ sock->socket = alloc_empty_socket(&(sock->list)); @@ -508,7 +508,7 @@ int at_closesocket(int socket) /* deal with TCP server actively disconnect */ rt_thread_delay(rt_tick_from_millisecond(100)); - + sock = at_get_socket(socket); if (sock == RT_NULL) { @@ -529,7 +529,7 @@ int at_closesocket(int socket) } } - free_socket(sock); + free_socket(sock); return 0; } @@ -603,7 +603,7 @@ int at_bind(int socket, const struct sockaddr *name, socklen_t namelen) /* input ip address is different from device ip address */ if (ip_addr_cmp(&input_ipaddr, &local_ipaddr) == 0) - { + { struct at_socket *new_sock = RT_NULL; struct at_device *new_device = RT_NULL; enum at_socket_type type = sock->type; @@ -613,7 +613,7 @@ int at_bind(int socket, const struct sockaddr *name, socklen_t namelen) { return -1; } - + extern struct at_device *at_device_get_by_ipaddr(ip_addr_t *ip_addr); new_device = at_device_get_by_ipaddr(&input_ipaddr); if (new_device == RT_NULL) @@ -649,7 +649,7 @@ static void at_recv_notice_cb(struct at_socket *sock, at_socket_evt_t event, con { RT_ASSERT(buff); RT_ASSERT(event == AT_SOCKET_EVT_RECV); - + /* check the socket object status */ if (sock->magic != AT_SOCKET_MAGIC) { @@ -675,7 +675,7 @@ static void at_closed_notice_cb(struct at_socket *sock, at_socket_evt_t event, c { return; } - + at_do_event_changes(sock, AT_EVENT_RECV, RT_TRUE); at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); @@ -731,7 +731,7 @@ __exit: { at_do_event_changes(sock, AT_EVENT_SEND, RT_TRUE); } - + return result; } @@ -780,7 +780,7 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f goto __exit; } rt_mutex_release(sock->recv_lock); - + /* socket passively closed, receive function return 0 */ if (sock->state == AT_SOCKET_CLOSED) { @@ -821,7 +821,7 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f goto __exit; } else - { + { /* get receive buffer to receiver ring buffer */ rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER); @@ -945,7 +945,7 @@ __exit: { if (sock != RT_NULL) { - at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); + at_do_event_changes(sock, AT_EVENT_ERROR, RT_TRUE); } } else @@ -1138,13 +1138,13 @@ struct hostent *at_gethostbyname(const char *name) #if NETDEV_IPV4 && NETDEV_IPV6 addr.u_addr.ip4.addr = ipstr_to_u32(ipstr); - addr.type = IPADDR_TYPE_V4; + addr.type = IPADDR_TYPE_V4; #elif NETDEV_IPV4 addr.addr = ipstr_to_u32(ipstr); #elif NETDEV_IPV6 #error "not support IPV6." #endif /* NETDEV_IPV4 && NETDEV_IPV6 */ - + /* fill hostent structure */ s_hostent_addr = addr; s_phostent_addr[0] = &s_hostent_addr; @@ -1243,8 +1243,8 @@ int at_getaddrinfo(const char *nodename, const char *servname, { strncpy(ip_str, nodename, strlen(nodename)); } - - #if NETDEV_IPV4 && NETDEV_IPV6 + + #if NETDEV_IPV4 && NETDEV_IPV6 addr.type = IPADDR_TYPE_V4; if ((addr.u_addr.ip4.addr = ipstr_to_u32(ip_str)) == 0) { @@ -1254,7 +1254,7 @@ int at_getaddrinfo(const char *nodename, const char *servname, addr.addr = ipstr_to_u32(ip_str); #elif NETDEV_IPV6 #error "not support IPV6." - #endif /* NETDEV_IPV4 && NETDEV_IPV6 */ + #endif /* NETDEV_IPV4 && NETDEV_IPV6 */ } } else diff --git a/components/net/at/at_socket/at_socket.h b/components/net/at/at_socket/at_socket.h index 3317579f05..caac6d2d5d 100644 --- a/components/net/at/at_socket/at_socket.h +++ b/components/net/at/at_socket/at_socket.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/at/include/at.h b/components/net/at/include/at.h index 7be821c21d..c6d0e3a5ce 100644 --- a/components/net/at/include/at.h +++ b/components/net/at/include/at.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/at/include/at_log.h b/components/net/at/include/at_log.h index 9e133561f7..acb5b34ecc 100644 --- a/components/net/at/include/at_log.h +++ b/components/net/at/include/at_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/at/src/at_base_cmd.c b/components/net/at/src/at_base_cmd.c index b182477f9b..00720c87b2 100644 --- a/components/net/at/src/at_base_cmd.c +++ b/components/net/at/src/at_base_cmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/at/src/at_cli.c b/components/net/at/src/at_cli.c index e39a913357..25fbb708f4 100644 --- a/components/net/at/src/at_cli.c +++ b/components/net/at/src/at_cli.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -27,7 +27,7 @@ static rt_err_t (*odev_rx_ind)(rt_device_t dev, rt_size_t size) = RT_NULL; #ifdef AT_USING_CLIENT static struct rt_semaphore client_rx_notice; static struct rt_ringbuffer *client_rx_fifo = RT_NULL; -#endif +#endif static char console_getchar(void) { diff --git a/components/net/at/src/at_client.c b/components/net/at/src/at_client.c index f46abd5cd4..5e077512ae 100644 --- a/components/net/at/src/at_client.c +++ b/components/net/at/src/at_client.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -577,7 +577,7 @@ int at_obj_set_urc_table(at_client_t client, const struct at_urc *urc_table, rt_ client->urc_table[client->urc_table_size].urc = urc_table; client->urc_table[client->urc_table_size].urc_size = table_sz; client->urc_table_size++; - + rt_free(old_urc_table); } diff --git a/components/net/at/src/at_server.c b/components/net/at/src/at_server.c index 81d00951f5..bfbbbae2d3 100644 --- a/components/net/at/src/at_server.c +++ b/components/net/at/src/at_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/at/src/at_utils.c b/components/net/at/src/at_utils.c index 7d26425f56..8d8887fe5e 100644 --- a/components/net/at/src/at_utils.c +++ b/components/net/at/src/at_utils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/lwip-1.4.1/src/api/api_lib.c b/components/net/lwip-1.4.1/src/api/api_lib.c index 4bdf08edfc..9cf93d4a19 100644 --- a/components/net/lwip-1.4.1/src/api/api_lib.c +++ b/components/net/lwip-1.4.1/src/api/api_lib.c @@ -3,12 +3,12 @@ * Sequential API External module * */ - + /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/api/api_msg.c b/components/net/lwip-1.4.1/src/api/api_msg.c index 7c58a77bde..5bb78cd698 100644 --- a/components/net/lwip-1.4.1/src/api/api_msg.c +++ b/components/net/lwip-1.4.1/src/api/api_msg.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -332,7 +332,7 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len) API_EVENT(conn, NETCONN_EVT_SENDPLUS, len); } } - + return ERR_OK; } @@ -1255,7 +1255,7 @@ do_writemore(struct netconn *conn) if (available < len) { /* don't try to write more than sendbuf */ len = available; - if (dontblock){ + if (dontblock){ if (!len) { err = ERR_WOULDBLOCK; goto err_mem; @@ -1491,7 +1491,7 @@ do_close(struct api_msg_msg *msg) */ void do_join_leave_group(struct api_msg_msg *msg) -{ +{ if (ERR_IS_FATAL(msg->conn->last_err)) { msg->err = msg->conn->last_err; } else { diff --git a/components/net/lwip-1.4.1/src/api/err.c b/components/net/lwip-1.4.1/src/api/err.c index 92fa8b7dba..78a576f354 100644 --- a/components/net/lwip-1.4.1/src/api/err.c +++ b/components/net/lwip-1.4.1/src/api/err.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/api/netbuf.c b/components/net/lwip-1.4.1/src/api/netbuf.c index 9390c9ee98..cea0fa3ba8 100644 --- a/components/net/lwip-1.4.1/src/api/netbuf.c +++ b/components/net/lwip-1.4.1/src/api/netbuf.c @@ -3,12 +3,12 @@ * Network buffer management * */ - + /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/api/netdb.c b/components/net/lwip-1.4.1/src/api/netdb.c index 6a4bac561c..3454004345 100644 --- a/components/net/lwip-1.4.1/src/api/netdb.c +++ b/components/net/lwip-1.4.1/src/api/netdb.c @@ -5,7 +5,7 @@ */ /* - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -14,21 +14,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ @@ -258,7 +258,7 @@ lwip_freeaddrinfo(struct addrinfo *ai) * * @param nodename descriptive name or address string of the host * (may be NULL -> local address) - * @param servname port number as string of NULL + * @param servname port number as string of NULL * @param hints structure containing input values that set socktype and protocol * @param res pointer to a pointer where to store the result (set to NULL on failure) * @return 0 on success, non-zero on failure diff --git a/components/net/lwip-1.4.1/src/api/netifapi.c b/components/net/lwip-1.4.1/src/api/netifapi.c index 43e47203a9..ba0e1eea81 100644 --- a/components/net/lwip-1.4.1/src/api/netifapi.c +++ b/components/net/lwip-1.4.1/src/api/netifapi.c @@ -5,7 +5,7 @@ */ /* - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -14,21 +14,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * */ #include "lwip/opt.h" diff --git a/components/net/lwip-1.4.1/src/api/sockets.c b/components/net/lwip-1.4.1/src/api/sockets.c index c5bcf8b4a2..a81d3fc34f 100644 --- a/components/net/lwip-1.4.1/src/api/sockets.c +++ b/components/net/lwip-1.4.1/src/api/sockets.c @@ -75,7 +75,7 @@ struct lwip_sock { tested by select */ u16_t sendevent; /** error happened for this socket, set by event_callback(), tested by select */ - u16_t errevent; + u16_t errevent; /** last error that occurred on this socket */ int err; /** counter of how many threads are waiting for this socket using select */ @@ -593,7 +593,7 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags, buf = sock->lastdata; } else { /* If this is non-blocking call, then check first */ - if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) && + if (((flags & MSG_DONTWAIT) || netconn_is_nonblocking(sock->conn)) && (sock->rcvevent <= 0)) { if (off > 0) { /* update receive window */ @@ -665,9 +665,9 @@ lwip_recvfrom(int s, void *mem, size_t len, int flags, if (netconn_type(sock->conn) == NETCONN_TCP) { LWIP_ASSERT("invalid copylen, len would underflow", len >= copylen); len -= copylen; - if ( (len <= 0) || - (p->flags & PBUF_FLAG_PUSH) || - (sock->rcvevent <= 0) || + if ( (len <= 0) || + (p->flags & PBUF_FLAG_PUSH) || + (sock->rcvevent <= 0) || ((flags & MSG_PEEK)!=0)) { done = 1; } @@ -898,7 +898,7 @@ lwip_sendto(int s, const void *data, size_t size, int flags, #endif /* LWIP_UDP */ } UNLOCK_TCPIP_CORE(); - + pbuf_free(p); } else { err = ERR_MEM; @@ -1482,11 +1482,11 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) /* Do length and type checks for the various options first, to keep it readable. */ switch (level) { - + /* Level: SOL_SOCKET */ case SOL_SOCKET: switch (optname) { - + case SO_ACCEPTCONN: case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ @@ -1537,7 +1537,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) err = ENOPROTOOPT; } /* switch (optname) */ break; - + /* Level: IPPROTO_IP */ case IPPROTO_IP: switch (optname) { @@ -1577,7 +1577,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) err = ENOPROTOOPT; } /* switch (optname) */ break; - + #if LWIP_TCP /* Level: IPPROTO_TCP */ case IPPROTO_TCP: @@ -1585,7 +1585,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) err = EINVAL; break; } - + /* If this is no TCP socket, ignore any options. */ if (sock->conn->type != NETCONN_TCP) return 0; @@ -1599,7 +1599,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) case TCP_KEEPCNT: #endif /* LWIP_TCP_KEEPALIVE */ break; - + default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", s, optname)); @@ -1614,7 +1614,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) err = EINVAL; break; } - + /* If this is no UDP lite socket, ignore any options. */ if (sock->conn->type != NETCONN_UDPLITE) { return 0; @@ -1624,7 +1624,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) case UDPLITE_SEND_CSCOV: case UDPLITE_RECV_CSCOV: break; - + default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UNIMPL: optname=0x%x, ..)\n", s, optname)); @@ -1639,7 +1639,7 @@ lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen) err = ENOPROTOOPT; } /* switch */ - + if (err != ERR_OK) { sock_set_errno(sock, err); return -1; @@ -1734,7 +1734,7 @@ lwip_getsockopt_internal(void *arg) /* only overwrite ERR_OK or tempoary errors */ if ((sock->err == 0) || (sock->err == EINPROGRESS)) { sock_set_errno(sock, err_to_errno(sock->conn->last_err)); - } + } *(int *)optval = sock->err; sock->err = 0; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", diff --git a/components/net/lwip-1.4.1/src/api/tcpip.c b/components/net/lwip-1.4.1/src/api/tcpip.c index 18d5f679f4..4b73bb5986 100644 --- a/components/net/lwip-1.4.1/src/api/tcpip.c +++ b/components/net/lwip-1.4.1/src/api/tcpip.c @@ -310,7 +310,7 @@ tcpip_apimsg(struct api_msg *apimsg) /* catch functions that don't set err */ apimsg->msg.err = ERR_VAL; #endif - + if (sys_mbox_valid(&mbox)) { msg.type = TCPIP_MSG_API; msg.msg.apimsg = apimsg; @@ -360,14 +360,14 @@ err_t tcpip_netifapi(struct netifapi_msg* netifapimsg) { struct tcpip_msg msg; - + if (sys_mbox_valid(&mbox)) { err_t err = sys_sem_new(&netifapimsg->msg.sem, 0); if (err != ERR_OK) { netifapimsg->msg.err = err; return err; } - + msg.type = TCPIP_MSG_NETIFAPI; msg.msg.netifapimsg = netifapimsg; sys_mbox_post(&mbox, &msg); @@ -389,7 +389,7 @@ tcpip_netifapi(struct netifapi_msg* netifapimsg) err_t tcpip_netifapi_lock(struct netifapi_msg* netifapimsg) { - LOCK_TCPIP_CORE(); + LOCK_TCPIP_CORE(); netifapimsg->function(&(netifapimsg->msg)); UNLOCK_TCPIP_CORE(); return netifapimsg->msg.err; diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h index ecf22177ac..8dd59e8dee 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/cc.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/cc.h @@ -60,17 +60,17 @@ typedef uintptr_t mem_ptr_t; /* some errno not defined in newlib */ #define ENSRNOTFOUND 163 /* Domain name not found */ /* WARNING: ESHUTDOWN also not defined in newlib. We chose - 180 here because the number "108" which is used - in arch.h has been assigned to another error code. */ + 180 here because the number "108" which is used + in arch.h has been assigned to another error code. */ #define ESHUTDOWN 180 #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif #if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include -#define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_TIMEVAL_PRIVATE 0 #else -#define LWIP_TIMEVAL_PRIVATE 1 +#define LWIP_TIMEVAL_PRIVATE 1 #endif #if defined(__CC_ARM) /* ARMCC compiler */ @@ -102,14 +102,14 @@ typedef uintptr_t mem_ptr_t; #endif void sys_arch_assert(const char* file, int line); -#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) +#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) #define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0) #include "string.h" -#define SYS_ARCH_DECL_PROTECT(level) -#define SYS_ARCH_PROTECT(level) rt_enter_critical() -#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() +#define SYS_ARCH_DECL_PROTECT(level) +#define SYS_ARCH_PROTECT(level) rt_enter_critical() +#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() #endif /* __ARCH_CC_H__ */ diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/perf.h b/components/net/lwip-1.4.1/src/arch/include/arch/perf.h index 675f1f65dc..4b7720ef40 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/perf.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/perf.h @@ -1,33 +1,33 @@ /* * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * * $Id: perf.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $ @@ -42,8 +42,8 @@ /* void perf_print(unsigned long c1l, unsigned long c1h, - unsigned long c2l, unsigned long c2h, - char *key); + unsigned long c2l, unsigned long c2h, + char *key); void perf_print_times(struct tms *start, struct tms *end, char *key); diff --git a/components/net/lwip-1.4.1/src/arch/include/arch/sys_arch.h b/components/net/lwip-1.4.1/src/arch/include/arch/sys_arch.h index 72814aa25c..9dbf3bf284 100644 --- a/components/net/lwip-1.4.1/src/arch/include/arch/sys_arch.h +++ b/components/net/lwip-1.4.1/src/arch/include/arch/sys_arch.h @@ -1,33 +1,33 @@ /* * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * * $Id: sys_arch.h,v 1.3 2005/03/13 16:03:23 bear Exp $ diff --git a/components/net/lwip-1.4.1/src/arch/sys_arch.c b/components/net/lwip-1.4.1/src/arch/sys_arch.c index 2f6dbb4143..0bdce1e075 100644 --- a/components/net/lwip-1.4.1/src/arch/sys_arch.c +++ b/components/net/lwip-1.4.1/src/arch/sys_arch.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (C) 2006-2018, RT-Thread Development Team + * COPYRIGHT (C) 2006-2021, RT-Thread Development Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -195,9 +195,9 @@ int lwip_system_init(void) netifapi_netif_set_addr(netif_default, &ipaddr, &netmask, &gw); } #endif - rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION); + rt_kprintf("lwIP-%d.%d.%d initialized!\n", LWIP_VERSION_MAJOR, LWIP_VERSION_MINOR, LWIP_VERSION_REVISION); - return 0; + return 0; } INIT_PREV_EXPORT(lwip_system_init); diff --git a/components/net/lwip-1.4.1/src/core/def.c b/components/net/lwip-1.4.1/src/core/def.c index 352b55241a..bb4b8e01fc 100644 --- a/components/net/lwip-1.4.1/src/core/def.c +++ b/components/net/lwip-1.4.1/src/core/def.c @@ -44,7 +44,7 @@ * Again with the aim of being simple, correct and fully portable. * Byte swapping is the second thing you would want to optimize. You will * need to port it to your architecture and in your cc.h: - * + * * #define LWIP_PLATFORM_BYTESWAP 1 * #define LWIP_PLATFORM_HTONS(x) * #define LWIP_PLATFORM_HTONL(x) diff --git a/components/net/lwip-1.4.1/src/core/dhcp.c b/components/net/lwip-1.4.1/src/core/dhcp.c index eb12c55021..4f71b88897 100644 --- a/components/net/lwip-1.4.1/src/core/dhcp.c +++ b/components/net/lwip-1.4.1/src/core/dhcp.c @@ -197,14 +197,14 @@ static void dhcp_handle_nak(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; - LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", + LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* Set the interface down since the address must no longer be used, as per RFC2131 */ netif_set_down(netif); /* remove IP address from interface */ netif_set_ipaddr(netif, IP_ADDR_ANY); netif_set_gw(netif, IP_ADDR_ANY); - netif_set_netmask(netif, IP_ADDR_ANY); + netif_set_netmask(netif, IP_ADDR_ANY); /* Change to a defined state */ dhcp_set_state(dhcp, DHCP_BACKING_OFF); /* We can immediately restart discovery */ @@ -373,7 +373,7 @@ dhcp_fine_tmr() while (netif != NULL) { /* only act on DHCP configured interfaces */ if (netif->dhcp != NULL) { - /* timer is active (non zero), and is about to trigger now */ + /* timer is active (non zero), and is about to trigger now */ if (netif->dhcp->request_timeout > 1) { netif->dhcp->request_timeout--; } @@ -564,7 +564,7 @@ dhcp_handle_ack(struct netif *netif) if (dhcp_option_given(dhcp, DHCP_OPTION_IDX_ROUTER)) { ip4_addr_set_u32(&dhcp->offered_gw_addr, htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_ROUTER))); } - + #if LWIP_DNS /* DNS servers */ n = 0; @@ -670,7 +670,7 @@ dhcp_start(struct netif *netif) LWIP_ASSERT("pbuf p_out wasn't freed", dhcp->p_out == NULL); LWIP_ASSERT("reply wasn't freed", dhcp->msg_in == NULL ); } - + /* clear data structure */ memset(dhcp, 0, sizeof(struct dhcp)); /* dhcp_set_state(&dhcp, DHCP_OFF); */ @@ -1183,7 +1183,7 @@ dhcp_release(struct netif *netif) ip_addr_set_zero(&dhcp->offered_si_addr); #endif /* LWIP_DHCP_BOOTP_FILE */ dhcp->offered_t0_lease = dhcp->offered_t1_renew = dhcp->offered_t2_rebind = 0; - + /* create and initialize the DHCP message header */ result = dhcp_create_msg(netif, dhcp, DHCP_RELEASE); if (result == ERR_OK) { @@ -1207,7 +1207,7 @@ dhcp_release(struct netif *netif) netif_set_ipaddr(netif, IP_ADDR_ANY); netif_set_gw(netif, IP_ADDR_ANY); netif_set_netmask(netif, IP_ADDR_ANY); - + return result; } diff --git a/components/net/lwip-1.4.1/src/core/dns.c b/components/net/lwip-1.4.1/src/core/dns.c index 2e1356ca97..3aa5047043 100644 --- a/components/net/lwip-1.4.1/src/core/dns.c +++ b/components/net/lwip-1.4.1/src/core/dns.c @@ -49,13 +49,13 @@ * The lwIP version of the resolver also adds a non-blocking version of * gethostbyname() that will work with a raw API application. This function * checks for an IP address string first and converts it if it is valid. - * gethostbyname() then does a dns_lookup() to see if the name is - * already in the table. If so, the IP is returned. If not, a query is + * gethostbyname() then does a dns_lookup() to see if the name is + * already in the table. If so, the IP is returned. If not, a query is * issued and the function returns with a ERR_INPROGRESS status. The app * using the dns client must then go into a waiting state. * * Once a hostname has been resolved (or found to be non-existent), - * the resolver code calls a specified callback function (which + * the resolver code calls a specified callback function (which * must be implemented by the module that uses the resolver). */ @@ -236,7 +236,7 @@ dns_init() ip_addr_t dnsserver; dns_payload = (u8_t *)LWIP_MEM_ALIGN(dns_payload_buffer); - + /* initialize default DNS server address */ DNS_SERVER_ADDRESS(&dnsserver); @@ -277,7 +277,7 @@ dns_setserver(u8_t numdns, ip_addr_t *dnsserver) if ((numdns < DNS_MAX_SERVERS) && (dns_pcb != NULL) && (dnsserver != NULL) && !ip_addr_isany(dnsserver)) { dns_servers[numdns] = (*dnsserver); - + #ifdef RT_USING_NETDEV extern struct netif *netif_list; extern struct netdev *netdev_get_by_name(const char *name); @@ -662,7 +662,7 @@ dns_check_entry(u8_t i) pEntry->numdns = 0; pEntry->tmr = 1; pEntry->retries = 0; - + /* send DNS packet for this entry */ err = dns_send(pEntry->numdns, pEntry->name, i); if (err != ERR_OK) { @@ -772,7 +772,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *addr, u16_t goto memerr; } - /* copy dns payload inside static buffer for processing */ + /* copy dns payload inside static buffer for processing */ if (pbuf_copy_partial(p, dns_payload, p->tot_len, 0) == p->tot_len) { /* The ID in the DNS header should be our entry into the name table. */ hdr = (struct dns_hdr*)dns_payload; diff --git a/components/net/lwip-1.4.1/src/core/init.c b/components/net/lwip-1.4.1/src/core/init.c index a7b15a776a..95bb706f76 100644 --- a/components/net/lwip-1.4.1/src/core/init.c +++ b/components/net/lwip-1.4.1/src/core/init.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -191,7 +191,7 @@ #if NETCONN_MORE != TCP_WRITE_FLAG_MORE #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" #endif -#endif /* LWIP_NETCONN && LWIP_TCP */ +#endif /* LWIP_NETCONN && LWIP_TCP */ #if LWIP_SOCKET /* Check that the SO_* socket options and SOF_* lwIP-internal flags match */ #if SO_ACCEPTCONN != SOF_ACCEPTCONN diff --git a/components/net/lwip-1.4.1/src/core/ipv4/autoip.c b/components/net/lwip-1.4.1/src/core/ipv4/autoip.c index b122da27e3..70684cf771 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/autoip.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/autoip.c @@ -43,9 +43,9 @@ /******************************************************************************* * USAGE: - * + * * define LWIP_AUTOIP 1 in your lwipopts.h - * + * * If you don't use tcpip.c (so, don't call, you don't call tcpip_init): * - First, call autoip_init(). * - call autoip_tmr() all AUTOIP_TMR_INTERVAL msces, @@ -55,7 +55,7 @@ * * Without DHCP: * - Call autoip_start() after netif_add(). - * + * * With DHCP: * - define LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h. * - Configure your DHCP Client. @@ -202,7 +202,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr) u32_t addr = ntohl(LWIP_AUTOIP_CREATE_SEED_ADDR(netif)); addr += netif->autoip->tried_llipaddr; addr = AUTOIP_NET | (addr & 0xffff); - /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */ + /* Now, 169.254.0.0 <= addr <= 169.254.255.255 */ if (addr < AUTOIP_RANGE_START) { addr += AUTOIP_RANGE_END - AUTOIP_RANGE_START + 1; @@ -213,7 +213,7 @@ autoip_create_addr(struct netif *netif, ip_addr_t *ipaddr) LWIP_ASSERT("AUTOIP address not in range", (addr >= AUTOIP_RANGE_START) && (addr <= AUTOIP_RANGE_END)); ip4_addr_set_u32(ipaddr, htonl(addr)); - + LWIP_DEBUGF(AUTOIP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("autoip_create_addr(): tried_llipaddr=%"U16_F", %"U16_F".%"U16_F".%"U16_F".%"U16_F"\n", (u16_t)(netif->autoip->tried_llipaddr), ip4_addr1_16(ipaddr), ip4_addr2_16(ipaddr), @@ -268,7 +268,7 @@ autoip_bind(struct netif *netif) netif_set_ipaddr(netif, &autoip->llipaddr); netif_set_netmask(netif, &sn_mask); - netif_set_gw(netif, &gw_addr); + netif_set_gw(netif, &gw_addr); /* bring the interface up */ netif_set_up(netif); @@ -493,7 +493,7 @@ autoip_arp_reply(struct netif *netif, struct etharp_hdr *hdr) */ IPADDR2_COPY(&sipaddr, &hdr->sipaddr); IPADDR2_COPY(&dipaddr, &hdr->dipaddr); - + if ((netif->autoip->state == AUTOIP_STATE_PROBING) || ((netif->autoip->state == AUTOIP_STATE_ANNOUNCING) && (netif->autoip->sent_num == 0))) { diff --git a/components/net/lwip-1.4.1/src/core/ipv4/icmp.c b/components/net/lwip-1.4.1/src/core/ipv4/icmp.c index 47ba857138..aaf39c357e 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/icmp.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/icmp.c @@ -103,7 +103,7 @@ icmp_input(struct pbuf *p, struct netif *inp) case ICMP_ER: /* This is OK, echo reply might have been parsed by a raw PCB (as obviously, an echo request has been sent, too). */ - break; + break; case ICMP_ECHO: #if !LWIP_MULTICAST_PING || !LWIP_BROADCAST_PING { @@ -227,7 +227,7 @@ icmp_input(struct pbuf *p, struct netif *inp) } break; default: - LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", + LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %"S16_F" code %"S16_F" not supported.\n", (s16_t)type, (s16_t)code)); ICMP_STATS_INC(icmp.proterr); ICMP_STATS_INC(icmp.drop); diff --git a/components/net/lwip-1.4.1/src/core/ipv4/igmp.c b/components/net/lwip-1.4.1/src/core/ipv4/igmp.c index 45bb5d95c2..0382e5b04d 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/igmp.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/igmp.c @@ -8,29 +8,29 @@ * Copyright (c) 2002 CITEL Technologies Ltd. * 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. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES 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 CITEL TECHNOLOGIES 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. + * 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 CITEL TECHNOLOGIES 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. * * This file is a contribution to the lwIP TCP/IP stack. * The Swedish Institute of Computer Science and Adam Dunkels @@ -70,7 +70,7 @@ Steve Reynolds * RFC 2236 - Internet Group Management Protocol, Version 2 - V2 <- this code is based on this RFC (it's the "de facto" standard) * RFC 3376 - Internet Group Management Protocol, Version 3 - V3 * RFC 4604 - Using Internet Group Management Protocol Version 3... - V3+ - * RFC 2113 - IP Router Alert Option - + * RFC 2113 - IP Router Alert Option - *----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------- @@ -95,7 +95,7 @@ Steve Reynolds #include "string.h" -/* +/* * IGMP constants */ #define IGMP_TTL 1 @@ -167,7 +167,7 @@ igmp_init(void) */ void igmp_dump_group_list() -{ +{ struct igmp_group *group = igmp_group_list; while (group != NULL) { @@ -316,7 +316,7 @@ struct igmp_group * igmp_lookup_group(struct netif *ifp, ip_addr_t *addr) { struct igmp_group *group = igmp_group_list; - + /* Search if the group already exists */ group = igmp_lookfor_group(ifp, addr); if (group != NULL) { @@ -334,7 +334,7 @@ igmp_lookup_group(struct netif *ifp, ip_addr_t *addr) group->last_reporter_flag = 0; group->use = 0; group->next = igmp_group_list; - + igmp_group_list = group; } @@ -395,7 +395,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) IGMP_STATS_INC(igmp.recv); - /* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */ + /* Note that the length CAN be greater than 8 but only 8 are used - All are included in the checksum */ iphdr = (struct ip_hdr *)p->payload; if (pbuf_header(p, -(s16_t)(IPH_HL(iphdr) * 4)) || (p->len < IGMP_MINLEN)) { pbuf_free(p); @@ -421,7 +421,7 @@ igmp_input(struct pbuf *p, struct netif *inp, ip_addr_t *dest) /* Packet is ok so find an existing group */ group = igmp_lookfor_group(inp, dest); /* use the destination IP address of incoming packet */ - + /* If group can be found or create... */ if (!group) { pbuf_free(p); @@ -614,7 +614,7 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) IGMP_STATS_INC(igmp.tx_leave); igmp_send(group, IGMP_LEAVE_GROUP); } - + /* Disable the group at the MAC level */ if (netif->igmp_mac_filter != NULL) { LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL ")); @@ -622,11 +622,11 @@ igmp_leavegroup(ip_addr_t *ifaddr, ip_addr_t *groupaddr) LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif)); netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER); } - + LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: remove group: ")); ip_addr_debug_print(IGMP_DEBUG, groupaddr); - LWIP_DEBUGF(IGMP_DEBUG, ("\n")); - + LWIP_DEBUGF(IGMP_DEBUG, ("\n")); + /* Free the group */ igmp_remove_group(group); } else { @@ -768,13 +768,13 @@ igmp_send(struct igmp_group *group, u8_t type) /* IP header + "router alert" option + IGMP header */ p = pbuf_alloc(PBUF_TRANSPORT, IGMP_MINLEN, PBUF_RAM); - + if (p) { igmp = (struct igmp_msg *)p->payload; LWIP_ASSERT("igmp_send: check that first pbuf can hold struct igmp_msg", (p->len >= sizeof(struct igmp_msg))); ip_addr_copy(src, group->netif->ip_addr); - + if (type == IGMP_V2_MEMB_REPORT) { dest = &(group->group_address); ip_addr_copy(igmp->igmp_group_address, group->group_address); diff --git a/components/net/lwip-1.4.1/src/core/ipv4/inet_chksum.c b/components/net/lwip-1.4.1/src/core/ipv4/inet_chksum.c index 960252f64f..014b891eed 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/inet_chksum.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/inet_chksum.c @@ -48,8 +48,8 @@ * aim of being simple, correct and fully portable. Checksumming is the * first thing you would want to optimize for your platform. If you create * your own version, link it in and in your cc.h put: - * - * #define LWIP_CHKSUM + * + * #define LWIP_CHKSUM * * Or you can select from the implementations below by defining * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. @@ -72,7 +72,7 @@ * * @param dataptr points to start of data to be summed at any boundary * @param len length of data to be summed - * @return host order (!) lwip checksum (non-inverted Internet sum) + * @return host order (!) lwip checksum (non-inverted Internet sum) * * @note accumulator size limits summable length to 64k * @note host endianess is irrelevant (p3 RFC1071) @@ -128,7 +128,7 @@ lwip_standard_chksum(void *dataptr, u16_t len) * * @param dataptr points to start of data to be summed at any boundary * @param len length of data to be summed - * @return host order (!) lwip checksum (non-inverted Internet sum) + * @return host order (!) lwip checksum (non-inverted Internet sum) */ static u16_t @@ -178,12 +178,12 @@ lwip_standard_chksum(void *dataptr, int len) /** * An optimized checksum routine. Basically, it uses loop-unrolling on * the checksum loop, treating the head and tail bytes specially, whereas - * the inner loop acts on 8 bytes at a time. + * the inner loop acts on 8 bytes at a time. * * @arg start of buffer to be checksummed. May be an odd byte address. * @len number of bytes in the buffer to be checksummed. - * @return host order (!) lwip checksum (non-inverted Internet sum) - * + * @return host order (!) lwip checksum (non-inverted Internet sum) + * * by Curt McDowell, Broadcom Corp. December 8th, 2005 */ diff --git a/components/net/lwip-1.4.1/src/core/ipv4/ip.c b/components/net/lwip-1.4.1/src/core/ipv4/ip.c index 17bcd3929a..fff25f1fb3 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/ip.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/ip.c @@ -1,7 +1,7 @@ /** * @file * This is the IPv4 layer implementation for incoming and outgoing IP traffic. - * + * * @see ip_frag.c * */ @@ -295,7 +295,7 @@ return_noroute: * forwarded (using ip_forward). The IP checksum is always checked. * * Finally, the packet is sent to the upper layer protocol input function. - * + * * @param p the received IP packet (p->payload points to IP header) * @param inp the netif on which this packet was received * @return ERR_OK if the packet was processed (could return ERR_* if it wasn't diff --git a/components/net/lwip-1.4.1/src/core/ipv4/ip_addr.c b/components/net/lwip-1.4.1/src/core/ipv4/ip_addr.c index 8f633ff231..bbd78534a5 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/ip_addr.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/ip_addr.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -45,8 +45,8 @@ const ip_addr_t ip_addr_any = { IPADDR_ANY }; const ip_addr_t ip_addr_broadcast = { IPADDR_BROADCAST }; /** - * Determine if an address is a broadcast address on a network interface - * + * Determine if an address is a broadcast address on a network interface + * * @param addr address to be checked * @param netif the network interface against which the address is checked * @return returns non-zero if the address is a broadcast address diff --git a/components/net/lwip-1.4.1/src/core/ipv4/ip_frag.c b/components/net/lwip-1.4.1/src/core/ipv4/ip_frag.c index 8d184345df..e1bda3f079 100644 --- a/components/net/lwip-1.4.1/src/core/ipv4/ip_frag.c +++ b/components/net/lwip-1.4.1/src/core/ipv4/ip_frag.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,25 +17,25 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * - * Author: Jani Monoses + * + * Author: Jani Monoses * Simon Goldschmidt * original reassembly code by Adam Dunkels - * + * */ #include "lwip/opt.h" @@ -185,7 +185,7 @@ ip_reass_free_complete_datagram(struct ip_reassdata *ipr, struct ip_reassdata *p } #endif /* LWIP_ICMP */ - /* First, free all received pbufs. The individual pbufs need to be released + /* First, free all received pbufs. The individual pbufs need to be released separately as they have not yet been chained */ p = ipr->p; while (p != NULL) { @@ -303,7 +303,7 @@ ip_reass_enqueue_new_datagram(struct ip_hdr *fraghdr, int clen) static void ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev) { - + /* dequeue the reass struct */ if (reassdatagrams == ipr) { /* it was the first in the list */ @@ -337,7 +337,7 @@ ip_reass_chain_frag_into_datagram_and_validate(struct ip_reassdata *ipr, struct int valid = 1; /* Extract length and fragment offset from current fragment */ - fraghdr = (struct ip_hdr*)new_p->payload; + fraghdr = (struct ip_hdr*)new_p->payload; len = ntohs(IPH_LEN(fraghdr)) - IPH_HL(fraghdr) * 4; offset = (ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) * 8; @@ -538,7 +538,7 @@ ip_reass(struct pbuf *p) goto nullreturn; } } else { - if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && + if (((ntohs(IPH_OFFSET(fraghdr)) & IP_OFFMASK) == 0) && ((ntohs(IPH_OFFSET(&ipr->iphdr)) & IP_OFFMASK) != 0)) { /* ipr->iphdr is not the header from the first fragment, but fraghdr is * -> copy fraghdr into ipr->iphdr since we want to have the header @@ -547,11 +547,11 @@ ip_reass(struct pbuf *p) SMEMCPY(&ipr->iphdr, fraghdr, IP_HLEN); } } - /* Track the current number of pbufs current 'in-flight', in order to limit + /* Track the current number of pbufs current 'in-flight', in order to limit the number of fragments that may be enqueued at any one time */ ip_reass_pbufcount += clen; - /* At this point, we have either created a new entry or pointing + /* At this point, we have either created a new entry or pointing * to an existing one */ /* check for 'no more fragments', and update queue entry*/ @@ -663,7 +663,7 @@ ipfrag_free_pbuf_custom(struct pbuf *p) * * @return ERR_OK if sent successfully, err_t otherwise */ -err_t +err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) { struct pbuf *rambuf; @@ -818,8 +818,8 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) pbuf_realloc(rambuf, left + IP_HLEN); } - /* This part is ugly: we alloc a RAM based pbuf for - * the link level header for each chunk and then + /* This part is ugly: we alloc a RAM based pbuf for + * the link level header for each chunk and then * free it.A PBUF_ROM style pbuf for which pbuf_header * worked would make things simpler. */ @@ -848,7 +848,7 @@ ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest) * will have already sent the packet, the free will really free, and * there will be zero memory penalty. */ - + pbuf_free(rambuf); #endif /* IP_FRAG_USES_STATIC_BUF */ left -= cop; diff --git a/components/net/lwip-1.4.1/src/core/ipv6/inet6.c b/components/net/lwip-1.4.1/src/core/ipv6/inet6.c index c3de85c093..fa38158320 100644 --- a/components/net/lwip-1.4.1/src/core/ipv6/inet6.c +++ b/components/net/lwip-1.4.1/src/core/ipv6/inet6.c @@ -7,9 +7,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -18,21 +18,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -56,8 +56,8 @@ chksum(void *dataptr, u16_t len) { u16_t *sdataptr = dataptr; u32_t acc; - - + + for(acc = 0; len > 1; len -= 2) { acc += *sdataptr++; } @@ -87,7 +87,7 @@ inet_chksum_pseudo(struct pbuf *p, acc = 0; swapped = 0; - for(q = p; q != NULL; q = q->next) { + for(q = p; q != NULL; q = q->next) { acc += chksum(q->payload, q->len); while (acc >> 16) { acc = (acc & 0xffff) + (acc >> 16); @@ -101,7 +101,7 @@ inet_chksum_pseudo(struct pbuf *p, if (swapped) { acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); } - + for(i = 0; i < 8; i++) { acc += ((u16_t *)src->addr)[i] & 0xffff; acc += ((u16_t *)dest->addr)[i] & 0xffff; @@ -142,20 +142,20 @@ inet_chksum_pbuf(struct pbuf *p) u32_t acc; struct pbuf *q; u8_t swapped; - + acc = 0; swapped = 0; for(q = p; q != NULL; q = q->next) { acc += chksum(q->payload, q->len); while (acc >> 16) { acc = (acc & 0xffff) + (acc >> 16); - } + } if (q->len % 2 != 0) { swapped = 1 - swapped; acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8); } } - + if (swapped) { acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); } diff --git a/components/net/lwip-1.4.1/src/core/ipv6/ip6_addr.c b/components/net/lwip-1.4.1/src/core/ipv6/ip6_addr.c index 2da6cea427..a74bc31375 100644 --- a/components/net/lwip-1.4.1/src/core/ipv6/ip6_addr.c +++ b/components/net/lwip-1.4.1/src/core/ipv6/ip6_addr.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -42,7 +42,7 @@ ip_addr_netcmp(struct ip_addr *addr1, struct ip_addr *addr2, (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) && (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) && (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3])); - + } u8_t diff --git a/components/net/lwip-1.4.1/src/core/mem.c b/components/net/lwip-1.4.1/src/core/mem.c index 1659a2c7a4..66016917a1 100644 --- a/components/net/lwip-1.4.1/src/core/mem.c +++ b/components/net/lwip-1.4.1/src/core/mem.c @@ -471,7 +471,7 @@ mem_trim(void *rmem, mem_size_t newsize) /* else { next struct mem is used but size between mem and mem2 is not big enough to create another struct mem - -> don't do anyhting. + -> don't do anyhting. -> the remaining space stays unused since it is too small } */ #if LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT diff --git a/components/net/lwip-1.4.1/src/core/memp.c b/components/net/lwip-1.4.1/src/core/memp.c index 9f680e244f..8f31a07edd 100644 --- a/components/net/lwip-1.4.1/src/core/memp.c +++ b/components/net/lwip-1.4.1/src/core/memp.c @@ -8,9 +8,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -19,21 +19,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -155,19 +155,19 @@ static const char *memp_desc[MEMP_MAX] = { * extern u8_t __attribute__((section(".onchip_mem"))) memp_memory_UDP_PCB_base[]; */ #define LWIP_MEMPOOL(name,num,size,desc) u8_t memp_memory_ ## name ## _base \ - [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; + [((num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size)))]; #include "lwip/memp_std.h" /** This array holds the base of each memory pool. */ -static u8_t *const memp_bases[] = { -#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, +static u8_t *const memp_bases[] = { +#define LWIP_MEMPOOL(name,num,size,desc) memp_memory_ ## name ## _base, #include "lwip/memp_std.h" }; #else /* MEMP_SEPARATE_POOLS */ /** This is the actual memory used by the pools (all pools in one big block). */ -static u8_t memp_memory[MEM_ALIGNMENT - 1 +static u8_t memp_memory[MEM_ALIGNMENT - 1 #define LWIP_MEMPOOL(name,num,size,desc) + ( (num) * (MEMP_SIZE + MEMP_ALIGN_SIZE(size) ) ) #include "lwip/memp_std.h" ]; @@ -331,7 +331,7 @@ memp_overflow_init(void) /** * Initialize this module. - * + * * Carves out memp_memory into linked lists for each pool-type. */ void @@ -394,7 +394,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line) { struct memp *memp; SYS_ARCH_DECL_PROTECT(old_level); - + LWIP_ERROR("memp_malloc: type < MEMP_MAX", (type < MEMP_MAX), return NULL;); SYS_ARCH_PROTECT(old_level); @@ -403,7 +403,7 @@ memp_malloc_fn(memp_t type, const char* file, const int line) #endif /* MEMP_OVERFLOW_CHECK >= 2 */ memp = memp_tab[type]; - + if (memp != NULL) { memp_tab[type] = memp->next; #if MEMP_OVERFLOW_CHECK @@ -455,9 +455,9 @@ memp_free(memp_t type, void *mem) #endif /* MEMP_OVERFLOW_CHECK >= 2 */ #endif /* MEMP_OVERFLOW_CHECK */ - MEMP_STATS_DEC(used, type); - - memp->next = memp_tab[type]; + MEMP_STATS_DEC(used, type); + + memp->next = memp_tab[type]; memp_tab[type] = memp; #if MEMP_SANITY_CHECK diff --git a/components/net/lwip-1.4.1/src/core/netif.c b/components/net/lwip-1.4.1/src/core/netif.c index 9c3e32b33f..416c118c82 100644 --- a/components/net/lwip-1.4.1/src/core/netif.c +++ b/components/net/lwip-1.4.1/src/core/netif.c @@ -71,13 +71,13 @@ #define NETIF_STATUS_CALLBACK(n) do{ if (n->status_callback) { (n->status_callback)(n); }}while(0) #else #define NETIF_STATUS_CALLBACK(n) -#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#endif /* LWIP_NETIF_STATUS_CALLBACK */ #if LWIP_NETIF_LINK_CALLBACK #define NETIF_LINK_CALLBACK(n) do{ if (n->link_callback) { (n->link_callback)(n); }}while(0) #else #define NETIF_LINK_CALLBACK(n) -#endif /* LWIP_NETIF_LINK_CALLBACK */ +#endif /* LWIP_NETIF_LINK_CALLBACK */ struct netif *netif_list; struct netif *netif_default; @@ -466,17 +466,17 @@ netif_set_default(struct netif *netif) /** * Bring an interface up, available for processing * traffic. - * + * * @note: Enabling DHCP on a down interface will make it come * up once configured. - * + * * @see dhcp_start() - */ + */ void netif_set_up(struct netif *netif) { if (!(netif->flags & NETIF_FLAG_UP)) { netif->flags |= NETIF_FLAG_UP; - + #if LWIP_SNMP snmp_get_sysuptime(&netif->ts); #endif /* LWIP_SNMP */ @@ -485,7 +485,7 @@ void netif_set_up(struct netif *netif) if (netif->flags & NETIF_FLAG_LINK_UP) { #if LWIP_ARP - /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ + /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ if (netif->flags & (NETIF_FLAG_ETHARP)) { etharp_gratuitous(netif); } @@ -511,9 +511,9 @@ void netif_set_up(struct netif *netif) * * @note: Enabling DHCP on a down interface will make it come * up once configured. - * + * * @see dhcp_start() - */ + */ void netif_set_down(struct netif *netif) { if (netif->flags & NETIF_FLAG_UP) { @@ -583,7 +583,7 @@ void netif_set_link_up(struct netif *netif ) if (netif->flags & NETIF_FLAG_UP) { #if LWIP_ARP - /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ + /* For Ethernet network interfaces, we would like to send a "gratuitous ARP" */ if (netif->flags & NETIF_FLAG_ETHARP) { etharp_gratuitous(netif); } diff --git a/components/net/lwip-1.4.1/src/core/pbuf.c b/components/net/lwip-1.4.1/src/core/pbuf.c index 1e5e53b12a..0c3e91f1f1 100644 --- a/components/net/lwip-1.4.1/src/core/pbuf.c +++ b/components/net/lwip-1.4.1/src/core/pbuf.c @@ -12,13 +12,13 @@ * * Multiple packets may be queued, also using this singly linked list. * This is called a "packet queue". - * + * * So, a packet queue consists of one or more pbuf chains, each of * which consist of one or more pbufs. CURRENTLY, PACKET QUEUES ARE * NOT SUPPORTED!!! Use helper structs to queue multiple packets. - * + * * The differences between a pbuf chain and a packet queue are very - * precise but subtle. + * precise but subtle. * * The last pbuf of a packet has a ->tot_len field that equals the * ->len field. It can be found by traversing the list. If the last @@ -518,7 +518,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) if ((header_size_increment == 0) || (p == NULL)) { return 0; } - + if (header_size_increment < 0){ increment_magnitude = -header_size_increment; /* Check that we aren't going to move off the end of the pbuf */ @@ -529,7 +529,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) /* Can't assert these as some callers speculatively call pbuf_header() to see if it's OK. Will return 1 below instead. */ /* Check that we've got the correct type of pbuf to work with */ - LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL", + LWIP_ASSERT("p->type == PBUF_RAM || p->type == PBUF_POOL", p->type == PBUF_RAM || p->type == PBUF_POOL); /* Check that we aren't going to move off the beginning of the pbuf */ LWIP_ASSERT("p->payload - increment_magnitude >= p + SIZEOF_STRUCT_PBUF", @@ -606,7 +606,7 @@ pbuf_header(struct pbuf *p, s16_t header_size_increment) * * Assuming existing chains a->b->c with the following reference * counts, calling pbuf_free(a) results in: - * + * * 1->2->3 becomes ...1->3 * 3->3->3 becomes 2->3->3 * 1->1->2 becomes ......1 @@ -734,10 +734,10 @@ pbuf_ref(struct pbuf *p) /** * Concatenate two pbufs (each may be a pbuf chain) and take over * the caller's reference of the tail pbuf. - * + * * @note The caller MAY NOT reference the tail pbuf afterwards. * Use pbuf_chain() for that purpose. - * + * * @see pbuf_chain() */ @@ -768,10 +768,10 @@ pbuf_cat(struct pbuf *h, struct pbuf *t) /** * Chain two pbufs (or pbuf chains) together. - * + * * The caller MUST call pbuf_free(t) once it has stopped * using it. Use pbuf_cat() instead if you no longer use t. - * + * * @param h head pbuf (chain) * @param t tail pbuf (chain) * @note The pbufs MUST belong to the same packet. @@ -909,7 +909,7 @@ pbuf_copy(struct pbuf *p_to, struct pbuf *p_from) * * @param buf the pbuf from which to copy data * @param dataptr the application supplied buffer - * @param len length of data to copy (dataptr must be big enough). No more + * @param len length of data to copy (dataptr must be big enough). No more * than buf->tot_len will be copied, irrespective of len * @param offset offset into the packet buffer from where to begin copying len bytes * @return the number of bytes copied, or 0 on failure diff --git a/components/net/lwip-1.4.1/src/core/raw.c b/components/net/lwip-1.4.1/src/core/raw.c index 7160c0fbd9..e9dcda3237 100644 --- a/components/net/lwip-1.4.1/src/core/raw.c +++ b/components/net/lwip-1.4.1/src/core/raw.c @@ -168,14 +168,14 @@ raw_connect(struct raw_pcb *pcb, ip_addr_t *ipaddr) /** * Set the callback function for received packets that match the - * raw PCB's protocol and binding. - * + * raw PCB's protocol and binding. + * * The callback function MUST either * - eat the packet by calling pbuf_free() and returning non-zero. The * packet will not be passed to other raw PCBs or other protocol layers. * - not free the packet, and return zero. The packet will be matched * against further PCBs and/or forwarded to another protocol layers. - * + * * @return non-zero if the packet was free()d, zero if the packet remains * available for others. */ @@ -206,9 +206,9 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr) struct netif *netif; ip_addr_t *src_ip; struct pbuf *q; /* q will be sent down the stack */ - + LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\n")); - + /* not enough space to add an IP header to first pbuf in given p chain? */ if (pbuf_header(p, IP_HLEN)) { /* allocate header in new pbuf */ diff --git a/components/net/lwip-1.4.1/src/core/stats.c b/components/net/lwip-1.4.1/src/core/stats.c index 8ea8249767..6aa59e0930 100644 --- a/components/net/lwip-1.4.1/src/core/stats.c +++ b/components/net/lwip-1.4.1/src/core/stats.c @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -72,18 +72,18 @@ void stats_display_proto(struct stats_proto *proto, const char *name) { LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); - LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); - LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); - LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); - LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); - LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); - LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); - LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); - LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); - LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); + LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", proto->xmit)); + LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", proto->recv)); + LWIP_PLATFORM_DIAG(("fw: %"STAT_COUNTER_F"\n\t", proto->fw)); + LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", proto->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", proto->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", proto->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", proto->memerr)); + LWIP_PLATFORM_DIAG(("rterr: %"STAT_COUNTER_F"\n\t", proto->rterr)); + LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", proto->proterr)); + LWIP_PLATFORM_DIAG(("opterr: %"STAT_COUNTER_F"\n\t", proto->opterr)); + LWIP_PLATFORM_DIAG(("err: %"STAT_COUNTER_F"\n\t", proto->err)); + LWIP_PLATFORM_DIAG(("cachehit: %"STAT_COUNTER_F"\n", proto->cachehit)); } #if IGMP_STATS @@ -91,20 +91,20 @@ void stats_display_igmp(struct stats_igmp *igmp) { LWIP_PLATFORM_DIAG(("\nIGMP\n\t")); - LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); - LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); - LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); - LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); - LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); - LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); - LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); - LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); + LWIP_PLATFORM_DIAG(("xmit: %"STAT_COUNTER_F"\n\t", igmp->xmit)); + LWIP_PLATFORM_DIAG(("recv: %"STAT_COUNTER_F"\n\t", igmp->recv)); + LWIP_PLATFORM_DIAG(("drop: %"STAT_COUNTER_F"\n\t", igmp->drop)); + LWIP_PLATFORM_DIAG(("chkerr: %"STAT_COUNTER_F"\n\t", igmp->chkerr)); + LWIP_PLATFORM_DIAG(("lenerr: %"STAT_COUNTER_F"\n\t", igmp->lenerr)); + LWIP_PLATFORM_DIAG(("memerr: %"STAT_COUNTER_F"\n\t", igmp->memerr)); + LWIP_PLATFORM_DIAG(("proterr: %"STAT_COUNTER_F"\n\t", igmp->proterr)); + LWIP_PLATFORM_DIAG(("rx_v1: %"STAT_COUNTER_F"\n\t", igmp->rx_v1)); LWIP_PLATFORM_DIAG(("rx_group: %"STAT_COUNTER_F"\n", igmp->rx_group)); LWIP_PLATFORM_DIAG(("rx_general: %"STAT_COUNTER_F"\n", igmp->rx_general)); - LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); - LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); - LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); - LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); + LWIP_PLATFORM_DIAG(("rx_report: %"STAT_COUNTER_F"\n\t", igmp->rx_report)); + LWIP_PLATFORM_DIAG(("tx_join: %"STAT_COUNTER_F"\n\t", igmp->tx_join)); + LWIP_PLATFORM_DIAG(("tx_leave: %"STAT_COUNTER_F"\n\t", igmp->tx_leave)); + LWIP_PLATFORM_DIAG(("tx_report: %"STAT_COUNTER_F"\n\t", igmp->tx_report)); } #endif /* IGMP_STATS */ @@ -113,9 +113,9 @@ void stats_display_mem(struct stats_mem *mem, const char *name) { LWIP_PLATFORM_DIAG(("\nMEM %s\n\t", name)); - LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); - LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); - LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); + LWIP_PLATFORM_DIAG(("avail: %"U32_F"\n\t", (u32_t)mem->avail)); + LWIP_PLATFORM_DIAG(("used: %"U32_F"\n\t", (u32_t)mem->used)); + LWIP_PLATFORM_DIAG(("max: %"U32_F"\n\t", (u32_t)mem->max)); LWIP_PLATFORM_DIAG(("err: %"U32_F"\n", (u32_t)mem->err)); } @@ -139,15 +139,15 @@ void stats_display_sys(struct stats_sys *sys) { LWIP_PLATFORM_DIAG(("\nSYS\n\t")); - LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); - LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); - LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); - LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); - LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); - LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); - LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); - LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); - LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); + LWIP_PLATFORM_DIAG(("sem.used: %"U32_F"\n\t", (u32_t)sys->sem.used)); + LWIP_PLATFORM_DIAG(("sem.max: %"U32_F"\n\t", (u32_t)sys->sem.max)); + LWIP_PLATFORM_DIAG(("sem.err: %"U32_F"\n\t", (u32_t)sys->sem.err)); + LWIP_PLATFORM_DIAG(("mutex.used: %"U32_F"\n\t", (u32_t)sys->mutex.used)); + LWIP_PLATFORM_DIAG(("mutex.max: %"U32_F"\n\t", (u32_t)sys->mutex.max)); + LWIP_PLATFORM_DIAG(("mutex.err: %"U32_F"\n\t", (u32_t)sys->mutex.err)); + LWIP_PLATFORM_DIAG(("mbox.used: %"U32_F"\n\t", (u32_t)sys->mbox.used)); + LWIP_PLATFORM_DIAG(("mbox.max: %"U32_F"\n\t", (u32_t)sys->mbox.max)); + LWIP_PLATFORM_DIAG(("mbox.err: %"U32_F"\n\t", (u32_t)sys->mbox.err)); } #endif /* SYS_STATS */ diff --git a/components/net/lwip-1.4.1/src/core/tcp.c b/components/net/lwip-1.4.1/src/core/tcp.c index b710d2e2a4..105b68e74c 100644 --- a/components/net/lwip-1.4.1/src/core/tcp.c +++ b/components/net/lwip-1.4.1/src/core/tcp.c @@ -10,9 +10,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -21,21 +21,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -72,17 +72,17 @@ #endif /* LWIP_TCP_KEEPALIVE */ const char * const tcp_state_str[] = { - "CLOSED", - "LISTEN", - "SYN_SENT", - "SYN_RCVD", - "ESTABLISHED", - "FIN_WAIT_1", - "FIN_WAIT_2", - "CLOSE_WAIT", - "CLOSING", - "LAST_ACK", - "TIME_WAIT" + "CLOSED", + "LISTEN", + "SYN_SENT", + "SYN_RCVD", + "ESTABLISHED", + "FIN_WAIT_1", + "FIN_WAIT_2", + "CLOSE_WAIT", + "CLOSING", + "LAST_ACK", + "TIME_WAIT" }; /* last local TCP port */ @@ -118,7 +118,7 @@ struct tcp_pcb *tcp_tmp_pcb; u8_t tcp_active_pcbs_changed; -/** Timer counter to handle calling slow-timer from tcp_tmr() */ +/** Timer counter to handle calling slow-timer from tcp_tmr() */ static u8_t tcp_timer; static u8_t tcp_timer_ctr; static u16_t tcp_new_port(void); @@ -202,7 +202,7 @@ tcp_close_shutdown(struct tcp_pcb *pcb, u8_t rst_on_unacked_data) * however, it is in this state once allocated and as yet unused * and the user needs some way to free it should the need arise. * Calling tcp_close() with a pcb that has already been closed, (i.e. twice) - * or for a pcb that has been used and then entered the CLOSED state + * or for a pcb that has been used and then entered the CLOSED state * is erroneous, but this should never happen as the pcb has in those cases * been freed, and so any remaining handles are bogus. */ err = ERR_OK; @@ -357,7 +357,7 @@ void tcp_abandon(struct tcp_pcb *pcb, int reset) { u32_t seqno, ackno; -#if LWIP_CALLBACK_API +#if LWIP_CALLBACK_API tcp_err_fn errf; #endif /* LWIP_CALLBACK_API */ void *errf_arg; @@ -385,7 +385,7 @@ tcp_abandon(struct tcp_pcb *pcb, int reset) if (pcb->unsent != NULL) { tcp_segs_free(pcb->unsent); } -#if TCP_QUEUE_OOSEQ +#if TCP_QUEUE_OOSEQ if (pcb->ooseq != NULL) { tcp_segs_free(pcb->ooseq); } @@ -570,7 +570,7 @@ tcp_listen_with_backlog(struct tcp_pcb *pcb, u8_t backlog) return (struct tcp_pcb *)lpcb; } -/** +/** * Update the state that tracks the available window space to advertise. * * Returns how much extra window would be advertised if we sent an @@ -649,7 +649,7 @@ tcp_new_port(void) u8_t i; u16_t n = 0; struct tcp_pcb *pcb; - + again: if (tcp_port++ == TCP_LOCAL_PORT_RANGE_END) { tcp_port = TCP_LOCAL_PORT_RANGE_START; @@ -757,7 +757,7 @@ tcp_connect(struct tcp_pcb *pcb, ip_addr_t *ipaddr, u16_t port, pcb->ssthresh = pcb->mss * 10; #if LWIP_CALLBACK_API pcb->connected = connected; -#else /* LWIP_CALLBACK_API */ +#else /* LWIP_CALLBACK_API */ LWIP_UNUSED_ARG(connected); #endif /* LWIP_CALLBACK_API */ @@ -870,7 +870,7 @@ tcp_slowtmr_start: LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %"U16_F " ssthresh %"U16_F"\n", pcb->cwnd, pcb->ssthresh)); - + /* The following needs to be called AFTER cwnd is set to one mss - STJ */ tcp_rexmit_rto(pcb); @@ -901,11 +901,11 @@ tcp_slowtmr_start: LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %"U16_F".%"U16_F".%"U16_F".%"U16_F".\n", ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); - + ++pcb_remove; ++pcb_reset; } - else if((u32_t)(tcp_ticks - pcb->tmr) > + else if((u32_t)(tcp_ticks - pcb->tmr) > (pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb)) / TCP_SLOW_INTERVAL) { @@ -998,7 +998,7 @@ tcp_slowtmr_start: } } - + /* Steps through all of the TIME-WAIT PCBs. */ prev = NULL; pcb = tcp_tw_pcbs; @@ -1010,7 +1010,7 @@ tcp_slowtmr_start: if ((u32_t)(tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { ++pcb_remove; } - + /* If the PCB should be removed, do it. */ @@ -1172,7 +1172,7 @@ tcp_setprio(struct tcp_pcb *pcb, u8_t prio) * * @param seg the old tcp_seg * @return a copy of seg - */ + */ struct tcp_seg * tcp_seg_copy(struct tcp_seg *seg) { @@ -1182,7 +1182,7 @@ tcp_seg_copy(struct tcp_seg *seg) if (cseg == NULL) { return NULL; } - SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); + SMEMCPY((u8_t *)cseg, (const u8_t *)seg, sizeof(struct tcp_seg)); pbuf_ref(cseg->p); return cseg; } @@ -1222,7 +1222,7 @@ tcp_kill_prio(u8_t prio) mprio = TCP_PRIO_MAX; - + /* We kill the oldest active connection that has lower priority than prio. */ inactivity = 0; inactive = NULL; @@ -1279,7 +1279,7 @@ tcp_alloc(u8_t prio) { struct tcp_pcb *pcb; u32_t iss; - + pcb = (struct tcp_pcb *)memp_malloc(MEMP_TCP_PCB); if (pcb == NULL) { /* Try killing oldest connection in TIME-WAIT. */ @@ -1324,7 +1324,7 @@ tcp_alloc(u8_t prio) pcb->snd_wl2 = iss; pcb->snd_nxt = iss; pcb->lastack = iss; - pcb->snd_lbb = iss; + pcb->snd_lbb = iss; pcb->tmr = tcp_ticks; pcb->last_timer = tcp_timer_ctr; @@ -1332,11 +1332,11 @@ tcp_alloc(u8_t prio) #if LWIP_CALLBACK_API pcb->recv = tcp_recv_null; -#endif /* LWIP_CALLBACK_API */ - +#endif /* LWIP_CALLBACK_API */ + /* Init KEEPALIVE timer */ pcb->keep_idle = TCP_KEEPIDLE_DEFAULT; - + #if LWIP_TCP_KEEPALIVE pcb->keep_intvl = TCP_KEEPINTVL_DEFAULT; pcb->keep_cnt = TCP_KEEPCNT_DEFAULT; @@ -1371,7 +1371,7 @@ tcp_new(void) * * @param pcb tcp_pcb to set the callback argument * @param arg void pointer argument to pass to callback functions - */ + */ void tcp_arg(struct tcp_pcb *pcb, void *arg) { @@ -1387,7 +1387,7 @@ tcp_arg(struct tcp_pcb *pcb, void *arg) * * @param pcb tcp_pcb to set the recv callback * @param recv callback function to call for this pcb when data is received - */ + */ void tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) { @@ -1401,7 +1401,7 @@ tcp_recv(struct tcp_pcb *pcb, tcp_recv_fn recv) * * @param pcb tcp_pcb to set the sent callback * @param sent callback function to call for this pcb when data is successfully sent - */ + */ void tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) { @@ -1416,7 +1416,7 @@ tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) * @param pcb tcp_pcb to set the err callback * @param err callback function to call for this pcb when a fatal error * has occured on the connection - */ + */ void tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) { @@ -1431,7 +1431,7 @@ tcp_err(struct tcp_pcb *pcb, tcp_err_fn err) * @param pcb tcp_pcb to set the accept callback * @param accept callback function to call for this pcb when LISTENing * connection has been connected to another host - */ + */ void tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) { @@ -1447,16 +1447,16 @@ tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) * from TCP. The interval is specified in terms of the TCP coarse * timer interval, which is called twice a second. * - */ + */ void tcp_poll(struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval) { LWIP_ASSERT("invalid socket state for poll", pcb->state != LISTEN); #if LWIP_CALLBACK_API pcb->poll = poll; -#else /* LWIP_CALLBACK_API */ +#else /* LWIP_CALLBACK_API */ LWIP_UNUSED_ARG(poll); -#endif /* LWIP_CALLBACK_API */ +#endif /* LWIP_CALLBACK_API */ pcb->pollinterval = interval; } @@ -1540,7 +1540,7 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) TCP_RMV(pcblist, pcb); tcp_pcb_purge(pcb); - + /* if there is an outstanding delayed ACKs, send it */ if (pcb->state != TIME_WAIT && pcb->state != LISTEN && @@ -1571,7 +1571,7 @@ u32_t tcp_next_iss(void) { static u32_t iss = 6510; - + iss += tcp_ticks; /* XXX */ return iss; } @@ -1703,21 +1703,21 @@ tcp_debug_print_pcbs(void) pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); - } + } LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); for(pcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); - } + } LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_DEBUGF(TCP_DEBUG, ("Local port %"U16_F", foreign port %"U16_F" snd_nxt %"U32_F" rcv_nxt %"U32_F" ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); - } + } } /** diff --git a/components/net/lwip-1.4.1/src/core/tcp_in.c b/components/net/lwip-1.4.1/src/core/tcp_in.c index 4ec971ac0f..051869ff96 100644 --- a/components/net/lwip-1.4.1/src/core/tcp_in.c +++ b/components/net/lwip-1.4.1/src/core/tcp_in.c @@ -6,7 +6,7 @@ * * These functions are generally called in the order (ip_input() ->) * tcp_input() -> * tcp_process() -> tcp_receive() (-> application). - * + * */ /* @@ -166,7 +166,7 @@ tcp_input(struct pbuf *p, struct netif *inp) for an active connection. */ prev = NULL; - + for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); @@ -253,7 +253,7 @@ tcp_input(struct pbuf *p, struct netif *inp) /* put this listening pcb at the head of the listening list */ tcp_listen_pcbs.listen_pcbs = lpcb; } - + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); tcp_listen_input(lpcb); pbuf_free(p); @@ -588,7 +588,7 @@ tcp_process(struct tcp_pcb *pcb) acceptable = 1; } } else { - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) { acceptable = 1; } @@ -609,12 +609,12 @@ tcp_process(struct tcp_pcb *pcb) } } - if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) { + if ((flags & TCP_SYN) && (pcb->state != SYN_SENT && pcb->state != SYN_RCVD)) { /* Cope with new connection attempt after remote end crashed */ tcp_ack_now(pcb); return ERR_OK; } - + if ((pcb->flags & TF_RXCLOSED) == 0) { /* Update the PCB (in)activity timer unless rx is closed (see tcp_shutdown) */ pcb->tmr = tcp_ticks; @@ -892,7 +892,7 @@ tcp_receive(struct tcp_pcb *pcb) #if TCP_WND_DEBUG } else { if (pcb->snd_wnd != tcphdr->wnd) { - LWIP_DEBUGF(TCP_WND_DEBUG, + LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %"U32_F" ackno %" U32_F" wl1 %"U32_F" seqno %"U32_F" wl2 %"U32_F"\n", pcb->lastack, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); @@ -902,17 +902,17 @@ tcp_receive(struct tcp_pcb *pcb) /* (From Stevens TCP/IP Illustrated Vol II, p970.) Its only a * duplicate ack if: - * 1) It doesn't ACK new data - * 2) length of received packet is zero (i.e. no payload) - * 3) the advertised window hasn't changed + * 1) It doesn't ACK new data + * 2) length of received packet is zero (i.e. no payload) + * 3) the advertised window hasn't changed * 4) There is outstanding unacknowledged data (retransmission timer running) * 5) The ACK is == biggest ACK sequence number so far seen (snd_una) - * - * If it passes all five, should process as a dupack: - * a) dupacks < 3: do nothing - * b) dupacks == 3: fast retransmit - * c) dupacks > 3: increase cwnd - * + * + * If it passes all five, should process as a dupack: + * a) dupacks < 3: do nothing + * b) dupacks == 3: fast retransmit + * c) dupacks > 3: increase cwnd + * * If it only passes 1-3, should reset dupack counter (and add to * stats, which we don't do in lwIP) * @@ -1053,7 +1053,7 @@ tcp_receive(struct tcp_pcb *pcb) ->unsent list after a retransmission, so these segments may in fact have been sent once. */ while (pcb->unsent != NULL && - TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + + TCP_SEQ_BETWEEN(ackno, ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent), pcb->snd_nxt)) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %"U32_F":%"U32_F" from pcb->unsent\n", ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + @@ -1065,7 +1065,7 @@ tcp_receive(struct tcp_pcb *pcb) if (pcb->unsent == NULL) { pcb->unsent_oversize = 0; } -#endif /* TCP_OVERSIZE */ +#endif /* TCP_OVERSIZE */ LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %"U16_F" ... ", (u16_t)pcb->snd_queuelen)); LWIP_ASSERT("pcb->snd_queuelen >= pbuf_clen(next->p)", (pcb->snd_queuelen >= pbuf_clen(next->p))); /* Prevent ACK for FIN to generate a sent event */ @@ -1211,7 +1211,7 @@ tcp_receive(struct tcp_pcb *pcb) /* The sequence number must be within the window (above rcv_nxt and below rcv_nxt + rcv_wnd) in order to be further processed. */ - if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, + if (TCP_SEQ_BETWEEN(seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd - 1)){ if (pcb->rcv_nxt == seqno) { /* The incoming segment is the next in sequence. We check if @@ -1220,12 +1220,12 @@ tcp_receive(struct tcp_pcb *pcb) tcplen = TCP_TCPLEN(&inseg); if (tcplen > pcb->rcv_wnd) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: other end overran receive window" "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - /* Must remove the FIN from the header as we're trimming + /* Must remove the FIN from the header as we're trimming * that byte of sequence-space from the packet */ TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN); } @@ -1245,7 +1245,7 @@ tcp_receive(struct tcp_pcb *pcb) - inseq overlaps with ooseq */ if (pcb->ooseq != NULL) { if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received in-order FIN, binning ooseq queue\n")); /* Received in-order FIN means anything that was received * out of order must now have been received in-order, so @@ -1352,7 +1352,7 @@ tcp_receive(struct tcp_pcb *pcb) recv_flags |= TF_GOT_FIN; if (pcb->state == ESTABLISHED) { /* force passive close or we can move to active close */ pcb->state = CLOSE_WAIT; - } + } } pcb->ooseq = cseg->next; @@ -1465,12 +1465,12 @@ tcp_receive(struct tcp_pcb *pcb) } /* check if the remote side overruns our receive window */ if ((u32_t)tcplen + seqno > pcb->rcv_nxt + (u32_t)pcb->rcv_wnd) { - LWIP_DEBUGF(TCP_INPUT_DEBUG, + LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: other end overran receive window" "seqno %"U32_F" len %"U16_F" right edge %"U32_F"\n", seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd)); if (TCPH_FLAGS(next->next->tcphdr) & TCP_FIN) { - /* Must remove the FIN from the header as we're trimming + /* Must remove the FIN from the header as we're trimming * that byte of sequence-space from the packet */ TCPH_FLAGS_SET(next->next->tcphdr, TCPH_FLAGS(next->next->tcphdr) &~ TCP_FIN); } @@ -1531,7 +1531,7 @@ tcp_receive(struct tcp_pcb *pcb) } /** - * Parses the options contained in the incoming segment. + * Parses the options contained in the incoming segment. * * Called from tcp_listen_input() and tcp_process(). * Currently, only the MSS option is supported! @@ -1588,7 +1588,7 @@ tcp_parseopt(struct tcp_pcb *pcb) return; } /* TCP timestamp option with valid length */ - tsval = (opts[c+2]) | (opts[c+3] << 8) | + tsval = (opts[c+2]) | (opts[c+3] << 8) | (opts[c+4] << 16) | (opts[c+5] << 24); if (flags & TCP_SYN) { pcb->ts_recent = ntohl(tsval); diff --git a/components/net/lwip-1.4.1/src/core/tcp_out.c b/components/net/lwip-1.4.1/src/core/tcp_out.c index 1db3fae03f..da9d72d531 100644 --- a/components/net/lwip-1.4.1/src/core/tcp_out.c +++ b/components/net/lwip-1.4.1/src/core/tcp_out.c @@ -197,7 +197,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, /* wnd and chksum are set in tcp_output */ seg->tcphdr->urgp = 0; return seg; -} +} /** * Allocate a PBUF_RAM pbuf, perhaps with extra space at the end. @@ -212,7 +212,7 @@ tcp_create_segment(struct tcp_pcb *pcb, struct pbuf *p, u8_t flags, u32_t seqno, * @param pcb The TCP connection that willo enqueue the pbuf. * @param apiflags API flags given to tcp_write. * @param first_seg true when this pbuf will be used in the first enqueued segment. - * @param + * @param */ #if TCP_OVERSIZE static struct pbuf * @@ -379,7 +379,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t apiflags) LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, data=%p, len=%"U16_F", apiflags=%"U16_F")\n", (void *)pcb, arg, len, (u16_t)apiflags)); - LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)", + LWIP_ERROR("tcp_write: arg == NULL (programmer violates API)", arg != NULL, return ERR_ARG;); err = tcp_write_checks(pcb, len); @@ -857,7 +857,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) return ERR_BUF; } tcphdr = (struct tcp_hdr *)p->payload; - LWIP_DEBUGF(TCP_OUTPUT_DEBUG, + LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: sending ACK for %"U32_F"\n", pcb->rcv_nxt)); /* remove ACK flags from the PCB, as we send an empty ACK now */ pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); @@ -869,7 +869,7 @@ tcp_send_empty_ack(struct tcp_pcb *pcb) if (pcb->flags & TF_TIMESTAMP) { tcp_build_timestamp_option(pcb, (u32_t *)(tcphdr + 1)); } -#endif +#endif #if CHECKSUM_GEN_TCP tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip), @@ -950,7 +950,7 @@ tcp_output(struct tcp_pcb *pcb) ", seg == NULL, ack %"U32_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); } else { - LWIP_DEBUGF(TCP_CWND_DEBUG, + LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %"U16_F", cwnd %"U16_F", wnd %"U32_F ", effwnd %"U32_F", seq %"U32_F", ack %"U32_F"\n", pcb->snd_wnd, pcb->cwnd, wnd, @@ -961,7 +961,7 @@ tcp_output(struct tcp_pcb *pcb) /* data available and window allows it to be sent? */ while (seg != NULL && ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { - LWIP_ASSERT("RST not expected here!", + LWIP_ASSERT("RST not expected here!", (TCPH_FLAGS(seg->tcphdr) & TCP_RST) == 0); /* Stop sending if the nagle algorithm would prevent it * Don't stop: @@ -1086,7 +1086,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) } #endif - /* Set retransmission timer running if it is not currently enabled + /* Set retransmission timer running if it is not currently enabled This must be set before checking the route. */ if (pcb->rtime == -1) { pcb->rtime = 0; @@ -1251,7 +1251,7 @@ tcp_rexmit_rto(struct tcp_pcb *pcb) #if TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK /* if last unsent changed, we need to update unsent_oversize */ if (pcb->unsent == NULL) { - pcb->unsent_oversize = seg->oversize_left; + pcb->unsent_oversize = seg->oversize_left; } #endif /* TCP_OVERSIZE && TCP_OVERSIZE_DBGCHECK*/ /* unsent queue is the concatenated queue (of unacked, unsent) */ @@ -1323,12 +1323,12 @@ tcp_rexmit(struct tcp_pcb *pcb) * * @param pcb the tcp_pcb for which to retransmit the first unacked segment */ -void +void tcp_rexmit_fast(struct tcp_pcb *pcb) { if (pcb->unacked != NULL && !(pcb->flags & TF_INFR)) { /* This is fast retransmit. Retransmit the first unacked segment. */ - LWIP_DEBUGF(TCP_FR_DEBUG, + LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %"U16_F" (%"U32_F "), fast retransmit %"U32_F"\n", (u16_t)pcb->dupacks, pcb->lastack, @@ -1342,19 +1342,19 @@ tcp_rexmit_fast(struct tcp_pcb *pcb) } else { pcb->ssthresh = pcb->cwnd / 2; } - + /* The minimum value for ssthresh should be 2 MSS */ if (pcb->ssthresh < 2*pcb->mss) { - LWIP_DEBUGF(TCP_FR_DEBUG, + LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: The minimum value for ssthresh %"U16_F " should be min 2 mss %"U16_F"...\n", pcb->ssthresh, 2*pcb->mss)); pcb->ssthresh = 2*pcb->mss; } - + pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; pcb->flags |= TF_INFR; - } + } } @@ -1376,12 +1376,12 @@ tcp_keepalive(struct tcp_pcb *pcb) ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); - LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %"U32_F" pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); - + p = tcp_output_alloc_header(pcb, 0, 0, htonl(pcb->snd_nxt - 1)); if(p == NULL) { - LWIP_DEBUGF(TCP_DEBUG, + LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: could not allocate memory for pbuf\n")); return; } @@ -1425,15 +1425,15 @@ tcp_zero_window_probe(struct tcp_pcb *pcb) u16_t len; u8_t is_fin; - LWIP_DEBUGF(TCP_DEBUG, + LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: sending ZERO WINDOW probe to %" U16_F".%"U16_F".%"U16_F".%"U16_F"\n", ip4_addr1_16(&pcb->remote_ip), ip4_addr2_16(&pcb->remote_ip), ip4_addr3_16(&pcb->remote_ip), ip4_addr4_16(&pcb->remote_ip))); - LWIP_DEBUGF(TCP_DEBUG, + LWIP_DEBUGF(TCP_DEBUG, ("tcp_zero_window_probe: tcp_ticks %"U32_F - " pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", + " pcb->tmr %"U32_F" pcb->keep_cnt_sent %"U16_F"\n", tcp_ticks, pcb->tmr, pcb->keep_cnt_sent)); seg = pcb->unacked; diff --git a/components/net/lwip-1.4.1/src/core/udp.c b/components/net/lwip-1.4.1/src/core/udp.c index 32c7d38403..ae91c8622d 100644 --- a/components/net/lwip-1.4.1/src/core/udp.c +++ b/components/net/lwip-1.4.1/src/core/udp.c @@ -100,7 +100,7 @@ udp_new_port(void) { u16_t n = 0; struct udp_pcb *pcb; - + again: if (udp_port++ == UDP_LOCAL_PORT_RANGE_END) { udp_port = UDP_LOCAL_PORT_RANGE_START; @@ -207,7 +207,7 @@ udp_input(struct pbuf *p, struct netif *inp) /* all packets for DHCP_CLIENT_PORT not coming from DHCP_SERVER_PORT are dropped! */ if (src == DHCP_SERVER_PORT) { if ((inp->dhcp != NULL) && (inp->dhcp->pcb != NULL)) { - /* accept the packe if + /* accept the packe if (- broadcast or directed to us) -> DHCP is link-layer-addressed, local ip is always ANY! - inp->dhcp->pcb->remote == ANY or iphdr->src */ if ((ip_addr_isany(&inp->dhcp->pcb->remote_ip) || @@ -253,9 +253,9 @@ udp_input(struct pbuf *p, struct netif *inp) (broadcast && (ip_addr_isany(&pcb->local_ip) || ip_addr_netcmp(&pcb->local_ip, ip_current_dest_addr(), &inp->netmask)))) { -#endif /* IP_SOF_BROADCAST_RECV */ +#endif /* IP_SOF_BROADCAST_RECV */ local_match = 1; - if ((uncon_pcb == NULL) && + if ((uncon_pcb == NULL) && ((pcb->flags & UDP_FLAGS_CONNECTED) == 0)) { /* the first unconnected matching PCB */ uncon_pcb = pcb; @@ -482,7 +482,7 @@ udp_send_chksum(struct udp_pcb *pcb, struct pbuf *p, * * If the PCB already has a remote address association, it will * be restored after the data is sent. - * + * * @return lwIP error code (@see udp_send for possible error codes) * * @see udp_disconnect() udp_send() @@ -613,7 +613,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *dst_ip, udphdr->src = htons(pcb->local_port); udphdr->dest = htons(dst_port); /* in UDP, 0 checksum means 'no checksum' */ - udphdr->chksum = 0x0000; + udphdr->chksum = 0x0000; /* Multicast Loop? */ #if LWIP_IGMP diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/autoip.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/autoip.h index e62b72e8cd..d00aa2ef3e 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/autoip.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/autoip.h @@ -40,7 +40,7 @@ * Please coordinate changes and requests with Dominik Spies * */ - + #ifndef __LWIP_AUTOIP_H__ #define __LWIP_AUTOIP_H__ diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/icmp.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/icmp.h index d47a7d8a2e..15641463ae 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/icmp.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/icmp.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/igmp.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/igmp.h index 8aabac2481..57038f4fca 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/igmp.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/igmp.h @@ -2,29 +2,29 @@ * Copyright (c) 2002 CITEL Technologies Ltd. * 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. Neither the name of CITEL Technologies Ltd nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of CITEL Technologies Ltd nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY CITEL TECHNOLOGIES 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 CITEL TECHNOLOGIES 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. + * 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 CITEL TECHNOLOGIES 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. * * This file is a contribution to the lwIP TCP/IP stack. * The Swedish Institute of Computer Science and Adam Dunkels @@ -64,8 +64,8 @@ extern "C" { * these should really be linked from the interface, but * if we keep them separate we will not affect the lwip original code * too much - * - * There will be a group for the all systems group address but this + * + * There will be a group for the all systems group address but this * will not run the state machine as it is used to kick off reports * from all the other groups */ diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet.h index 7bff49b59e..213d47a6be 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet_chksum.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet_chksum.h index 79a2d90f2f..7c5d17e309 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet_chksum.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/inet_chksum.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip.h index 00c83a0a12..d88ab8a107 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -136,7 +136,7 @@ struct ip_hdr { PACK_STRUCT_FIELD(u16_t _chksum); /* source and destination IP addresses */ PACK_STRUCT_FIELD(ip_addr_p_t src); - PACK_STRUCT_FIELD(ip_addr_p_t dest); + PACK_STRUCT_FIELD(ip_addr_p_t dest); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip_frag.h b/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip_frag.h index 77b5eb1eef..d6f1b77d37 100644 --- a/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip_frag.h +++ b/components/net/lwip-1.4.1/src/include/ipv4/lwip/ip_frag.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Jani Monoses * */ diff --git a/components/net/lwip-1.4.1/src/include/ipv6/lwip/icmp.h b/components/net/lwip-1.4.1/src/include/ipv6/lwip/icmp.h index 87e9ffd964..4397d2e87a 100644 --- a/components/net/lwip-1.4.1/src/include/ipv6/lwip/icmp.h +++ b/components/net/lwip-1.4.1/src/include/ipv6/lwip/icmp.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/ipv6/lwip/inet.h b/components/net/lwip-1.4.1/src/include/ipv6/lwip/inet.h index de1a0b6361..32a5261bde 100644 --- a/components/net/lwip-1.4.1/src/include/ipv6/lwip/inet.h +++ b/components/net/lwip-1.4.1/src/include/ipv6/lwip/inet.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip.h b/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip.h index a01cfc65b3..73a1c5cc9e 100644 --- a/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip.h +++ b/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -84,7 +84,7 @@ extern "C" { struct ip_hdr { #if BYTE_ORDER == LITTLE_ENDIAN u8_t tclass1:4, v:4; - u8_t flow1:4, tclass2:4; + u8_t flow1:4, tclass2:4; #else u8_t v:4, tclass1:4; u8_t tclass2:8, flow1:4; diff --git a/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip_addr.h b/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip_addr.h index b2d8ae566d..f5b606a860 100644 --- a/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip_addr.h +++ b/components/net/lwip-1.4.1/src/include/ipv6/lwip/ip_addr.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/api.h b/components/net/lwip-1.4.1/src/include/lwip/api.h index 7a9fa9366c..63d99bf292 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/api.h +++ b/components/net/lwip-1.4.1/src/include/lwip/api.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/api_msg.h b/components/net/lwip-1.4.1/src/include/lwip/api_msg.h index f9e1c7d295..3f063e2a64 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/api_msg.h +++ b/components/net/lwip-1.4.1/src/include/lwip/api_msg.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/arch.h b/components/net/lwip-1.4.1/src/include/lwip/arch.h index 4d6df773fc..2c3eb47384 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/arch.h +++ b/components/net/lwip-1.4.1/src/include/lwip/arch.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -71,7 +71,7 @@ extern "C" { #ifndef LWIP_UNUSED_ARG #define LWIP_UNUSED_ARG(x) (void)x -#endif /* LWIP_UNUSED_ARG */ +#endif /* LWIP_UNUSED_ARG */ #ifdef LWIP_PROVIDE_ERRNO diff --git a/components/net/lwip-1.4.1/src/include/lwip/debug.h b/components/net/lwip-1.4.1/src/include/lwip/debug.h index 0fe041396f..aa96d1aebb 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/debug.h +++ b/components/net/lwip-1.4.1/src/include/lwip/debug.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -66,7 +66,7 @@ #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ LWIP_PLATFORM_ASSERT(message); } while(0) #else /* LWIP_NOASSERT */ -#define LWIP_ASSERT(message, assertion) +#define LWIP_ASSERT(message, assertion) #endif /* LWIP_NOASSERT */ /** if "expression" isn't true, then print "message" and execute "handler" expression */ @@ -92,7 +92,7 @@ } while(0) #else /* LWIP_DEBUG */ -#define LWIP_DEBUGF(debug, message) +#define LWIP_DEBUGF(debug, message) #endif /* LWIP_DEBUG */ #endif /* __LWIP_DEBUG_H__ */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/def.h b/components/net/lwip-1.4.1/src/include/lwip/def.h index 73a1b560b3..e695ed7ccd 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/def.h +++ b/components/net/lwip-1.4.1/src/include/lwip/def.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -52,7 +52,7 @@ extern "C" { #define LWIP_MAKE_U16(a, b) ((a << 8) | b) #else #define LWIP_MAKE_U16(a, b) ((b << 8) | a) -#endif +#endif #ifndef LWIP_PLATFORM_BYTESWAP #define LWIP_PLATFORM_BYTESWAP 0 diff --git a/components/net/lwip-1.4.1/src/include/lwip/dhcp.h b/components/net/lwip-1.4.1/src/include/lwip/dhcp.h index 32d93381d1..ca1c1de3db 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/dhcp.h +++ b/components/net/lwip-1.4.1/src/include/lwip/dhcp.h @@ -16,11 +16,11 @@ extern "C" { #endif /** period (in seconds) of the application calling dhcp_coarse_tmr() */ -#define DHCP_COARSE_TIMER_SECS 60 +#define DHCP_COARSE_TIMER_SECS 60 /** period (in milliseconds) of the application calling dhcp_coarse_tmr() */ #define DHCP_COARSE_TIMER_MSECS (DHCP_COARSE_TIMER_SECS * 1000UL) /** period (in milliseconds) of the application calling dhcp_fine_tmr() */ -#define DHCP_FINE_TIMER_MSECS 500 +#define DHCP_FINE_TIMER_MSECS 500 #define DHCP_CHADDR_LEN 16U #define DHCP_SNAME_LEN 64U @@ -28,9 +28,9 @@ extern "C" { struct dhcp { - /** transaction identifier of last sent request */ + /** transaction identifier of last sent request */ u32_t xid; - /** our connection to the DHCP server */ + /** our connection to the DHCP server */ struct udp_pcb *pcb; /** incoming msg */ struct dhcp_msg *msg_in; @@ -53,7 +53,7 @@ struct dhcp ip_addr_t offered_ip_addr; ip_addr_t offered_sn_mask; ip_addr_t offered_gw_addr; - + u32_t offered_t0_lease; /* lease period (in seconds) */ u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */ @@ -131,7 +131,7 @@ void dhcp_arp_reply(struct netif *netif, ip_addr_t *addr); void dhcp_coarse_tmr(void); /** to be called every half second */ void dhcp_fine_tmr(void); - + /** DHCP message item offsets and length */ #define DHCP_OP_OFS 0 #define DHCP_HTYPE_OFS 1 @@ -152,7 +152,7 @@ void dhcp_fine_tmr(void); #define DHCP_COOKIE_OFS DHCP_MSG_LEN #define DHCP_OPTIONS_OFS (DHCP_MSG_LEN + 4) -#define DHCP_CLIENT_PORT 68 +#define DHCP_CLIENT_PORT 68 #define DHCP_SERVER_PORT 67 /** DHCP client states */ @@ -173,7 +173,7 @@ void dhcp_fine_tmr(void); /** AUTOIP cooperatation flags */ #define DHCP_AUTOIP_COOP_STATE_OFF 0 #define DHCP_AUTOIP_COOP_STATE_ON 1 - + #define DHCP_BOOTREQUEST 1 #define DHCP_BOOTREPLY 2 @@ -198,7 +198,7 @@ void dhcp_fine_tmr(void); #define DHCP_OPTION_PAD 0 #define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ #define DHCP_OPTION_ROUTER 3 -#define DHCP_OPTION_DNS_SERVER 6 +#define DHCP_OPTION_DNS_SERVER 6 #define DHCP_OPTION_HOSTNAME 12 #define DHCP_OPTION_IP_TTL 23 #define DHCP_OPTION_MTU 26 diff --git a/components/net/lwip-1.4.1/src/include/lwip/dns.h b/components/net/lwip-1.4.1/src/include/lwip/dns.h index 6c7d9b0739..5d7945a739 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/dns.h +++ b/components/net/lwip-1.4.1/src/include/lwip/dns.h @@ -1,7 +1,7 @@ /** * lwip DNS resolver header file. - * Author: Jim Pettinato + * Author: Jim Pettinato * April 2007 * ported from uIP resolv.c Copyright (c) 2002-2003, Adam Dunkels. diff --git a/components/net/lwip-1.4.1/src/include/lwip/err.h b/components/net/lwip-1.4.1/src/include/lwip/err.h index ac907729fc..1a5af39463 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/err.h +++ b/components/net/lwip-1.4.1/src/include/lwip/err.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/init.h b/components/net/lwip-1.4.1/src/include/lwip/init.h index 3238534542..e5833e55c3 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/init.h +++ b/components/net/lwip-1.4.1/src/include/lwip/init.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/mem.h b/components/net/lwip-1.4.1/src/include/lwip/mem.h index 5bb906b63f..fec03bc8ab 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/mem.h +++ b/components/net/lwip-1.4.1/src/include/lwip/mem.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/memp.h b/components/net/lwip-1.4.1/src/include/lwip/memp.h index f0d0739943..efad238a93 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/memp.h +++ b/components/net/lwip-1.4.1/src/include/lwip/memp.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/memp_std.h b/components/net/lwip-1.4.1/src/include/lwip/memp_std.h index 461ed1acf8..7304e2c62e 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/memp_std.h +++ b/components/net/lwip-1.4.1/src/include/lwip/memp_std.h @@ -15,7 +15,7 @@ #define LWIP_MALLOC_MEMPOOL(num, size) LWIP_MEMPOOL(POOL_##size, num, (size + sizeof(struct memp_malloc_helper)), "MALLOC_"#size) #define LWIP_MALLOC_MEMPOOL_START #define LWIP_MALLOC_MEMPOOL_END -#endif /* LWIP_MALLOC_MEMPOOL */ +#endif /* LWIP_MALLOC_MEMPOOL */ #ifndef LWIP_PBUF_MEMPOOL /* This treats "pbuf pools" just like any other pool. diff --git a/components/net/lwip-1.4.1/src/include/lwip/netbuf.h b/components/net/lwip-1.4.1/src/include/lwip/netbuf.h index 7d247d71b6..ddee0273e0 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/netbuf.h +++ b/components/net/lwip-1.4.1/src/include/lwip/netbuf.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/netdb.h b/components/net/lwip-1.4.1/src/include/lwip/netdb.h index 7587e2f2d1..80040bbfcd 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/netdb.h +++ b/components/net/lwip-1.4.1/src/include/lwip/netdb.h @@ -1,5 +1,5 @@ /* - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -8,21 +8,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/netif.h b/components/net/lwip-1.4.1/src/include/lwip/netif.h index f7e4937453..bd93112f8f 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/netif.h +++ b/components/net/lwip-1.4.1/src/include/lwip/netif.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -290,7 +290,7 @@ void netif_set_remove_callback(struct netif *netif, netif_status_callback_fn rem void netif_set_link_up(struct netif *netif); void netif_set_link_down(struct netif *netif); -/** Ask if a link is up */ +/** Ask if a link is up */ #define netif_is_link_up(netif) (((netif)->flags & NETIF_FLAG_LINK_UP) ? (u8_t)1 : (u8_t)0) #if LWIP_NETIF_LINK_CALLBACK diff --git a/components/net/lwip-1.4.1/src/include/lwip/netifapi.h b/components/net/lwip-1.4.1/src/include/lwip/netifapi.h index 33318efaf6..6ac16f3b5a 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/netifapi.h +++ b/components/net/lwip-1.4.1/src/include/lwip/netifapi.h @@ -1,5 +1,5 @@ /* - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -8,23 +8,23 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * */ - + #ifndef __LWIP_NETIFAPI_H__ #define __LWIP_NETIFAPI_H__ diff --git a/components/net/lwip-1.4.1/src/include/lwip/opt.h b/components/net/lwip-1.4.1/src/include/lwip/opt.h index b8ebec86b1..76490a1d28 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/opt.h +++ b/components/net/lwip-1.4.1/src/include/lwip/opt.h @@ -6,9 +6,9 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -17,21 +17,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -60,7 +60,7 @@ #define SYS_LIGHTWEIGHT_PROT 0 #endif -/** +/** * NO_SYS==1: Provides VERY minimal functionality. Otherwise, * use lwIP facilities. */ @@ -183,8 +183,8 @@ /** * MEMP_USE_CUSTOM_POOLS==1: whether to include a user file lwippools.h * that defines additional pools beyond the "standard" ones required - * by lwIP. If you set this to 1, you must have lwippools.h in your - * inlude path somewhere. + * by lwIP. If you set this to 1, you must have lwippools.h in your + * inlude path somewhere. */ #ifndef MEMP_USE_CUSTOM_POOLS #define MEMP_USE_CUSTOM_POOLS 0 @@ -334,7 +334,7 @@ /** * MEMP_NUM_TCPIP_MSG_API: the number of struct tcpip_msg, which are used - * for callback/timeout API communication. + * for callback/timeout API communication. * (only needed if you use tcpip.c) */ #ifndef MEMP_NUM_TCPIP_MSG_API @@ -343,7 +343,7 @@ /** * MEMP_NUM_TCPIP_MSG_INPKT: the number of struct tcpip_msg, which are used - * for incoming packets. + * for incoming packets. * (only needed if you use tcpip.c) */ #ifndef MEMP_NUM_TCPIP_MSG_INPKT @@ -408,7 +408,7 @@ #endif /** - * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. + * PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ #ifndef PBUF_POOL_SIZE #define PBUF_POOL_SIZE 16 @@ -751,7 +751,7 @@ #endif /** - * SNMP_PRIVATE_MIB: + * SNMP_PRIVATE_MIB: * When using a private MIB, you have to create a file 'private_mib.h' that contains * a 'struct mib_array_node mib_private' which contains your MIB. */ @@ -799,7 +799,7 @@ ---------------------------------- */ /** - * LWIP_IGMP==1: Turn on IGMP module. + * LWIP_IGMP==1: Turn on IGMP module. */ #ifndef LWIP_IGMP #define LWIP_IGMP 0 @@ -916,12 +916,12 @@ #endif /** - * TCP_WND: The size of a TCP window. This must be at least + * TCP_WND: The size of a TCP window. This must be at least * (2 * TCP_MSS) for things to work well */ #ifndef TCP_WND #define TCP_WND (4 * TCP_MSS) -#endif +#endif /** * TCP_MAXRTX: Maximum number of retransmissions of data segments. @@ -1790,14 +1790,14 @@ #ifndef CHECKSUM_GEN_IP #define CHECKSUM_GEN_IP 1 #endif - + /** * CHECKSUM_GEN_UDP==1: Generate checksums in software for outgoing UDP packets. */ #ifndef CHECKSUM_GEN_UDP #define CHECKSUM_GEN_UDP 1 #endif - + /** * CHECKSUM_GEN_TCP==1: Generate checksums in software for outgoing TCP packets. */ @@ -1811,14 +1811,14 @@ #ifndef CHECKSUM_GEN_ICMP #define CHECKSUM_GEN_ICMP 1 #endif - + /** * CHECKSUM_CHECK_IP==1: Check checksums in software for incoming IP packets. */ #ifndef CHECKSUM_CHECK_IP #define CHECKSUM_CHECK_IP 1 #endif - + /** * CHECKSUM_CHECK_UDP==1: Check checksums in software for incoming UDP packets. */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/pbuf.h b/components/net/lwip-1.4.1/src/include/lwip/pbuf.h index 99d5443bf3..7602869740 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/pbuf.h +++ b/components/net/lwip-1.4.1/src/include/lwip/pbuf.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -149,11 +149,11 @@ struct pbuf *pbuf_alloced_custom(pbuf_layer l, u16_t length, pbuf_type type, struct pbuf_custom *p, void *payload_mem, u16_t payload_mem_len); #endif /* LWIP_SUPPORT_CUSTOM_PBUF */ -void pbuf_realloc(struct pbuf *p, u16_t size); +void pbuf_realloc(struct pbuf *p, u16_t size); u8_t pbuf_header(struct pbuf *p, s16_t header_size); void pbuf_ref(struct pbuf *p); u8_t pbuf_free(struct pbuf *p); -u8_t pbuf_clen(struct pbuf *p); +u8_t pbuf_clen(struct pbuf *p); void pbuf_cat(struct pbuf *head, struct pbuf *tail); void pbuf_chain(struct pbuf *head, struct pbuf *tail); struct pbuf *pbuf_dechain(struct pbuf *p); diff --git a/components/net/lwip-1.4.1/src/include/lwip/sio.h b/components/net/lwip-1.4.1/src/include/lwip/sio.h index 28ae2f225d..dca34794c6 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/sio.h +++ b/components/net/lwip-1.4.1/src/include/lwip/sio.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,17 +11,17 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. @@ -53,7 +53,7 @@ typedef void * sio_fd_t; #ifndef sio_open /** * Opens a serial device for communication. - * + * * @param devnum device number * @return handle to serial device if successful, NULL otherwise */ @@ -63,10 +63,10 @@ sio_fd_t sio_open(u8_t devnum); #ifndef sio_send /** * Sends a single character to the serial device. - * + * * @param c character to send * @param fd serial device handle - * + * * @note This function will block until the character can be sent. */ void sio_send(u8_t c, sio_fd_t fd); @@ -75,9 +75,9 @@ void sio_send(u8_t c, sio_fd_t fd); #ifndef sio_recv /** * Receives a single character from the serial device. - * + * * @param fd serial device handle - * + * * @note This function will block until a character is received. */ u8_t sio_recv(sio_fd_t fd); @@ -86,12 +86,12 @@ u8_t sio_recv(sio_fd_t fd); #ifndef sio_read /** * Reads from the serial device. - * + * * @param fd serial device handle * @param data pointer to data buffer for receiving * @param len maximum length (in bytes) of data to receive * @return number of bytes actually received - may be 0 if aborted by sio_read_abort - * + * * @note This function will block until data can be received. The blocking * can be cancelled by calling sio_read_abort(). */ @@ -102,7 +102,7 @@ u32_t sio_read(sio_fd_t fd, u8_t *data, u32_t len); /** * Tries to read from the serial device. Same as sio_read but returns * immediately if no data is available and never blocks. - * + * * @param fd serial device handle * @param data pointer to data buffer for receiving * @param len maximum length (in bytes) of data to receive @@ -114,12 +114,12 @@ u32_t sio_tryread(sio_fd_t fd, u8_t *data, u32_t len); #ifndef sio_write /** * Writes to the serial device. - * + * * @param fd serial device handle * @param data pointer to data to send * @param len length (in bytes) of data to send * @return number of bytes actually sent - * + * * @note This function will block until all data can be sent. */ u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); @@ -128,7 +128,7 @@ u32_t sio_write(sio_fd_t fd, u8_t *data, u32_t len); #ifndef sio_read_abort /** * Aborts a blocking sio_read() call. - * + * * @param fd serial device handle */ void sio_read_abort(sio_fd_t fd); diff --git a/components/net/lwip-1.4.1/src/include/lwip/snmp.h b/components/net/lwip-1.4.1/src/include/lwip/snmp.h index 2ed043dd5f..fbd2c5a85b 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/snmp.h +++ b/components/net/lwip-1.4.1/src/include/lwip/snmp.h @@ -2,8 +2,8 @@ * Copyright (c) 2001, 2002 Leon Woestenberg * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * + * 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, @@ -12,21 +12,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Leon Woestenberg * */ @@ -109,7 +109,7 @@ void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen); void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen); /* network interface */ -void snmp_add_ifinoctets(struct netif *ni, u32_t value); +void snmp_add_ifinoctets(struct netif *ni, u32_t value); void snmp_inc_ifinucastpkts(struct netif *ni); void snmp_inc_ifinnucastpkts(struct netif *ni); void snmp_inc_ifindiscards(struct netif *ni); @@ -167,7 +167,7 @@ void snmp_inc_icmpoutdestunreachs(void); void snmp_inc_icmpouttimeexcds(void); void snmp_inc_icmpoutparmprobs(void); void snmp_inc_icmpoutsrcquenchs(void); -void snmp_inc_icmpoutredirects(void); +void snmp_inc_icmpoutredirects(void); void snmp_inc_icmpoutechos(void); void snmp_inc_icmpoutechoreps(void); void snmp_inc_icmpouttimestamps(void); @@ -242,7 +242,7 @@ void snmp_get_snmpenableauthentraps(u8_t *value); #define snmp_set_syslocation(ocstr, ocstrlen); /* network interface */ -#define snmp_add_ifinoctets(ni,value) +#define snmp_add_ifinoctets(ni,value) #define snmp_inc_ifinucastpkts(ni) #define snmp_inc_ifinnucastpkts(ni) #define snmp_inc_ifindiscards(ni) @@ -282,26 +282,26 @@ void snmp_get_snmpenableauthentraps(u8_t *value); /* ICMP */ #define snmp_inc_icmpinmsgs() -#define snmp_inc_icmpinerrors() -#define snmp_inc_icmpindestunreachs() +#define snmp_inc_icmpinerrors() +#define snmp_inc_icmpindestunreachs() #define snmp_inc_icmpintimeexcds() -#define snmp_inc_icmpinparmprobs() -#define snmp_inc_icmpinsrcquenchs() -#define snmp_inc_icmpinredirects() -#define snmp_inc_icmpinechos() +#define snmp_inc_icmpinparmprobs() +#define snmp_inc_icmpinsrcquenchs() +#define snmp_inc_icmpinredirects() +#define snmp_inc_icmpinechos() #define snmp_inc_icmpinechoreps() -#define snmp_inc_icmpintimestamps() +#define snmp_inc_icmpintimestamps() #define snmp_inc_icmpintimestampreps() #define snmp_inc_icmpinaddrmasks() #define snmp_inc_icmpinaddrmaskreps() #define snmp_inc_icmpoutmsgs() #define snmp_inc_icmpouterrors() -#define snmp_inc_icmpoutdestunreachs() -#define snmp_inc_icmpouttimeexcds() +#define snmp_inc_icmpoutdestunreachs() +#define snmp_inc_icmpouttimeexcds() #define snmp_inc_icmpoutparmprobs() #define snmp_inc_icmpoutsrcquenchs() -#define snmp_inc_icmpoutredirects() -#define snmp_inc_icmpoutechos() +#define snmp_inc_icmpoutredirects() +#define snmp_inc_icmpoutechos() #define snmp_inc_icmpoutechoreps() #define snmp_inc_icmpouttimestamps() #define snmp_inc_icmpouttimestampreps() diff --git a/components/net/lwip-1.4.1/src/include/lwip/snmp_asn1.h b/components/net/lwip-1.4.1/src/include/lwip/snmp_asn1.h index 605fa3f16c..a231d03288 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/snmp_asn1.h +++ b/components/net/lwip-1.4.1/src/include/lwip/snmp_asn1.h @@ -2,7 +2,7 @@ * @file * Abstract Syntax Notation One (ISO 8824, 8825) codec. */ - + /* * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. * All rights reserved. diff --git a/components/net/lwip-1.4.1/src/include/lwip/snmp_structs.h b/components/net/lwip-1.4.1/src/include/lwip/snmp_structs.h index 0d3b46a928..e9bd9d379f 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/snmp_structs.h +++ b/components/net/lwip-1.4.1/src/include/lwip/snmp_structs.h @@ -54,7 +54,7 @@ extern "C" { #endif /* MIB object instance */ -#define MIB_OBJECT_NONE 0 +#define MIB_OBJECT_NONE 0 #define MIB_OBJECT_SCALAR 1 #define MIB_OBJECT_TAB 2 @@ -113,7 +113,7 @@ struct mib_node /** tests length and/or range BEFORE setting */ u8_t (*set_test)(struct obj_def *od, u16_t len, void *value); /** sets object value, only to be called when set_test() */ - void (*set_value)(struct obj_def *od, u16_t len, void *value); + void (*set_value)(struct obj_def *od, u16_t len, void *value); /** One out of MIB_NODE_AR, MIB_NODE_LR or MIB_NODE_EX */ u8_t node_type; /* array or max list length */ @@ -161,7 +161,7 @@ struct mib_ram_array_node struct mib_list_node { - struct mib_list_node *prev; + struct mib_list_node *prev; struct mib_list_node *next; s32_t objid; struct mib_node *nptr; @@ -223,7 +223,7 @@ struct mib_external_node void (*get_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); u8_t (*set_test_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); void (*set_value_a)(u8_t rid, struct obj_def *od, u16_t len, void *value); - /** async Panic Close (agent returns error reply, + /** async Panic Close (agent returns error reply, e.g. used for external transaction cleanup) */ void (*get_object_def_pc)(u8_t rid, u8_t ident_len, s32_t *ident); void (*get_value_pc)(u8_t rid, struct obj_def *od); diff --git a/components/net/lwip-1.4.1/src/include/lwip/sockets.h b/components/net/lwip-1.4.1/src/include/lwip/sockets.h index 3ea32f13fb..a1003b04f4 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/sockets.h +++ b/components/net/lwip-1.4.1/src/include/lwip/sockets.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -304,7 +304,7 @@ typedef struct ip_mreq { #endif /* FD_SET */ /** LWIP_TIMEVAL_PRIVATE: if you want to use the struct timeval provided - * by your system, set this to 0 and include in cc.h */ + * by your system, set this to 0 and include in cc.h */ #ifndef LWIP_TIMEVAL_PRIVATE #define LWIP_TIMEVAL_PRIVATE 1 #endif diff --git a/components/net/lwip-1.4.1/src/include/lwip/stats.h b/components/net/lwip-1.4.1/src/include/lwip/stats.h index 1f5152a949..d828980a9b 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/stats.h +++ b/components/net/lwip-1.4.1/src/include/lwip/stats.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -53,7 +53,7 @@ extern "C" { #else #define STAT_COUNTER u16_t #define STAT_COUNTER_F U16_F -#endif +#endif struct stats_proto { STAT_COUNTER xmit; /* Transmitted packets. */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/sys.h b/components/net/lwip-1.4.1/src/include/lwip/sys.h index dc9351335a..b25b8c6e62 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/sys.h +++ b/components/net/lwip-1.4.1/src/include/lwip/sys.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -80,7 +80,7 @@ typedef u8_t sys_mbox_t; /** sys_mbox_tryfetch() returns SYS_MBOX_EMPTY if appropriate. * For now we use the same magic value, but we allow this to change in future. */ -#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT +#define SYS_MBOX_EMPTY SYS_ARCH_TIMEOUT #include "lwip/err.h" #include "arch/sys_arch.h" @@ -119,7 +119,7 @@ void sys_mutex_lock(sys_mutex_t *mutex); void sys_mutex_unlock(sys_mutex_t *mutex); /** Delete a semaphore * @param mutex the mutex to delete */ -void sys_mutex_free(sys_mutex_t *mutex); +void sys_mutex_free(sys_mutex_t *mutex); #ifndef sys_mutex_valid /** Check if a mutex is valid/allocated: return 1 for valid, 0 for invalid */ int sys_mutex_valid(sys_mutex_t *mutex); diff --git a/components/net/lwip-1.4.1/src/include/lwip/tcp.h b/components/net/lwip-1.4.1/src/include/lwip/tcp.h index c6e61ad1f1..8d8995103a 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/tcp.h +++ b/components/net/lwip-1.4.1/src/include/lwip/tcp.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -173,7 +173,7 @@ struct tcp_pcb { /* ports are in host byte order */ u16_t remote_port; - + u8_t flags; #define TF_ACK_DELAY ((u8_t)0x01U) /* Delayed ACK. */ #define TF_ACK_NOW ((u8_t)0x02U) /* Immediate ACK. */ @@ -236,12 +236,12 @@ struct tcp_pcb { #if TCP_OVERSIZE /* Extra bytes available at the end of the last pbuf in unsent. */ u16_t unsent_oversize; -#endif /* TCP_OVERSIZE */ +#endif /* TCP_OVERSIZE */ /* These are ordered by sequence number: */ struct tcp_seg *unsent; /* Unsent (queued) segments. */ struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ -#if TCP_QUEUE_OOSEQ +#if TCP_QUEUE_OOSEQ struct tcp_seg *ooseq; /* Received out of sequence segments. */ #endif /* TCP_QUEUE_OOSEQ */ @@ -271,7 +271,7 @@ struct tcp_pcb { u32_t keep_intvl; u32_t keep_cnt; #endif /* LWIP_TCP_KEEPALIVE */ - + /* Persist timer counter */ u8_t persist_cnt; /* Persist timer back-off */ @@ -281,7 +281,7 @@ struct tcp_pcb { u8_t keep_cnt_sent; }; -struct tcp_pcb_listen { +struct tcp_pcb_listen { /* Common members of all PCB types */ IP_PCB; /* Protocol specific PCB members */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/tcp_impl.h b/components/net/lwip-1.4.1/src/include/lwip/tcp_impl.h index 173de44e44..7c1655a24f 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/tcp_impl.h +++ b/components/net/lwip-1.4.1/src/include/lwip/tcp_impl.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -282,7 +282,7 @@ struct tcp_seg { u16_t oversize_left; /* Extra bytes available at the end of the last pbuf in unsent (used for asserting vs. tcp_pcb.unsent_oversized only) */ -#endif /* TCP_OVERSIZE_DBGCHECK */ +#endif /* TCP_OVERSIZE_DBGCHECK */ #if TCP_CHECKSUM_ON_COPY u16_t chksum; u8_t chksum_swapped; @@ -309,7 +309,7 @@ extern u8_t tcp_active_pcbs_changed; /* The TCP PCB lists. */ union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ - struct tcp_pcb_listen *listen_pcbs; + struct tcp_pcb_listen *listen_pcbs; struct tcp_pcb *pcbs; }; extern struct tcp_pcb *tcp_bound_pcbs; @@ -321,7 +321,7 @@ extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. * extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */ -/* Axioms about the above lists: +/* Axioms about the above lists: 1) Every TCP PCB that is not CLOSED is in one of the lists. 2) A PCB is only in one of the lists. 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. diff --git a/components/net/lwip-1.4.1/src/include/lwip/tcpip.h b/components/net/lwip-1.4.1/src/include/lwip/tcpip.h index 637476e1a9..f98340aefd 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/tcpip.h +++ b/components/net/lwip-1.4.1/src/include/lwip/tcpip.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/lwip/timers.h b/components/net/lwip-1.4.1/src/include/lwip/timers.h index 04e78e0fea..bcf9369c5d 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/timers.h +++ b/components/net/lwip-1.4.1/src/include/lwip/timers.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * Simon Goldschmidt * diff --git a/components/net/lwip-1.4.1/src/include/lwip/udp.h b/components/net/lwip-1.4.1/src/include/lwip/udp.h index f1e6d3f1e4..5282b0640d 100644 --- a/components/net/lwip-1.4.1/src/include/lwip/udp.h +++ b/components/net/lwip-1.4.1/src/include/lwip/udp.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -113,7 +113,7 @@ struct udp_pcb { /** receive callback function */ udp_recv_fn recv; /** user-supplied argument for the recv callback */ - void *recv_arg; + void *recv_arg; }; /* udp_pcbs export for exernal reference (e.g. SNMP agent) */ extern struct udp_pcb *udp_pcbs; diff --git a/components/net/lwip-1.4.1/src/include/netif/etharp.h b/components/net/lwip-1.4.1/src/include/netif/etharp.h index 872f48b10b..411284fed4 100644 --- a/components/net/lwip-1.4.1/src/include/netif/etharp.h +++ b/components/net/lwip-1.4.1/src/include/netif/etharp.h @@ -2,9 +2,9 @@ * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * Copyright (c) 2003-2004 Leon Woestenberg * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -13,21 +13,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h index 1c969e6e25..fb7d4b963c 100644 --- a/components/net/lwip-1.4.1/src/include/netif/ethernetif.h +++ b/components/net/lwip-1.4.1/src/include/netif/ethernetif.h @@ -4,16 +4,16 @@ #include "lwip/netif.h" #include -#define NIOCTL_GADDR 0x01 +#define NIOCTL_GADDR 0x01 #ifndef RT_LWIP_ETH_MTU -#define ETHERNET_MTU 1500 +#define ETHERNET_MTU 1500 #else -#define ETHERNET_MTU RT_LWIP_ETH_MTU +#define ETHERNET_MTU RT_LWIP_ETH_MTU #endif /* eth flag with auto_linkup or phy_linkup */ -#define ETHIF_LINK_AUTOUP 0x0000 -#define ETHIF_LINK_PHYUP 0x0100 +#define ETHIF_LINK_AUTOUP 0x0000 +#define ETHIF_LINK_PHYUP 0x0100 struct eth_device { diff --git a/components/net/lwip-1.4.1/src/include/netif/ppp_oe.h b/components/net/lwip-1.4.1/src/include/netif/ppp_oe.h index e1cdfa5199..e0897a35e5 100644 --- a/components/net/lwip-1.4.1/src/include/netif/ppp_oe.h +++ b/components/net/lwip-1.4.1/src/include/netif/ppp_oe.h @@ -6,13 +6,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/include/netif/slipif.h b/components/net/lwip-1.4.1/src/include/netif/slipif.h index 7b6ce5e28f..cfd0933945 100644 --- a/components/net/lwip-1.4.1/src/include/netif/slipif.h +++ b/components/net/lwip-1.4.1/src/include/netif/slipif.h @@ -1,33 +1,33 @@ /* * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ @@ -76,6 +76,6 @@ void slipif_received_bytes(struct netif *netif, u8_t *data, u8_t len); #ifdef __cplusplus } #endif - -#endif + +#endif diff --git a/components/net/lwip-1.4.1/src/include/posix/netdb.h b/components/net/lwip-1.4.1/src/include/posix/netdb.h index 7134032d2d..12d4c7f566 100644 --- a/components/net/lwip-1.4.1/src/include/posix/netdb.h +++ b/components/net/lwip-1.4.1/src/include/posix/netdb.h @@ -4,7 +4,7 @@ */ /* - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -13,17 +13,17 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. diff --git a/components/net/lwip-1.4.1/src/include/posix/sys/socket.h b/components/net/lwip-1.4.1/src/include/posix/sys/socket.h index f7c7066e6f..0ed9baf3d9 100644 --- a/components/net/lwip-1.4.1/src/include/posix/sys/socket.h +++ b/components/net/lwip-1.4.1/src/include/posix/sys/socket.h @@ -4,7 +4,7 @@ */ /* - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -13,17 +13,17 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. diff --git a/components/net/lwip-1.4.1/src/netif/etharp.c b/components/net/lwip-1.4.1/src/netif/etharp.c index 5e382d1d60..1228c4d00a 100644 --- a/components/net/lwip-1.4.1/src/netif/etharp.c +++ b/components/net/lwip-1.4.1/src/netif/etharp.c @@ -42,7 +42,7 @@ * This file is part of the lwIP TCP/IP stack. * */ - + #include "lwip/opt.h" #if LWIP_ARP || LWIP_ETHERNET @@ -84,7 +84,7 @@ const struct eth_addr ethzero = {{0,0,0,0,0,0}}; /** the time an ARP entry stays pending after first request, * for ARP_TMR_INTERVAL = 5000, this is * (2 * 5) seconds = 10 seconds. - * + * * @internal Keep this number at least 2, otherwise it might * run out instantly if the timeout occurs directly after a request. */ @@ -243,14 +243,14 @@ etharp_tmr(void) /** * Search the ARP table for a matching or new entry. - * + * * If an IP address is given, return a pending or stable ARP entry that matches * the address. If no match is found, create a new entry with this address set, * but in state ETHARP_EMPTY. The caller must check and possibly change the * state of the returned entry. - * + * * If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY. - * + * * In all cases, attempt to create new entries from an empty entry. If no * empty entries are available and ETHARP_FLAG_TRY_HARD flag is set, recycle * old entries. Heuristic choose the least important entry for recycling. @@ -258,7 +258,7 @@ etharp_tmr(void) * @param ipaddr IP address to find in ARP cache, or to add if not found. * @param flags @see definition of ETHARP_FLAG_* * @param netif netif related to this address (used for NETIF_HWADDRHINT) - * + * * @return The ARP entry index that matched or is created, ERR_MEM if no * entry is found or could be recycled. */ @@ -337,7 +337,7 @@ etharp_find_entry(ip_addr_t *ipaddr, u8_t flags) } } /* { we have no match } => try to create a new entry */ - + /* don't create new entry, only search? */ if (((flags & ETHARP_FLAG_FIND_ONLY) != 0) || /* or no empty entry found and not allowed to recycle? */ @@ -345,15 +345,15 @@ etharp_find_entry(ip_addr_t *ipaddr, u8_t flags) LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_find_entry: no empty entry found and not allowed to recycle\n")); return (s8_t)ERR_MEM; } - + /* b) choose the least destructive entry to recycle: * 1) empty entry * 2) oldest stable entry * 3) oldest pending entry without queued packets * 4) oldest pending entry with queued packets - * + * * { ETHARP_FLAG_TRY_HARD is set at this point } - */ + */ /* 1) empty entry available? */ if (empty < ARP_TABLE_SIZE) { @@ -431,7 +431,7 @@ etharp_send_ip(struct netif *netif, struct pbuf *p, struct eth_addr *src, struct * * If a pending entry is resolved, any queued packets will be sent * at this point. - * + * * @param netif netif related to this entry (used for NETIF_ADDRHINT) * @param ipaddr IP address of the inserted ARP entry. * @param ethaddr Ethernet address of the inserted ARP entry. @@ -670,7 +670,7 @@ etharp_ip_input(struct netif *netif, struct pbuf *p) #endif /* ETHARP_TRUST_IP_MAC */ /** - * Responds to ARP requests to us. Upon ARP replies to us, add entry to cache + * Responds to ARP requests to us. Upon ARP replies to us, add entry to cache * send out queued IP packets. Updates cache with snooped address pairs. * * Should be called for incoming ARP packets. The pbuf in the argument @@ -846,13 +846,13 @@ etharp_output_to_arp_index(struct netif *netif, struct pbuf *q, u8_t arp_idx) /* if arp table entry is about to expire: re-request it, but only if its state is ETHARP_STATE_STABLE to prevent flooding the network with ARP requests if this address is used frequently. */ - if ((arp_table[arp_idx].state == ETHARP_STATE_STABLE) && + if ((arp_table[arp_idx].state == ETHARP_STATE_STABLE) && (arp_table[arp_idx].ctime >= ARP_AGE_REREQUEST_USED)) { if (etharp_request(netif, &arp_table[arp_idx].ipaddr) == ERR_OK) { arp_table[arp_idx].state = ETHARP_STATE_STABLE_REREQUESTING; } } - + return etharp_send_ip(netif, q, (struct eth_addr*)(netif->hwaddr), &arp_table[arp_idx].ethaddr); } @@ -990,11 +990,11 @@ etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) * is sent for the given address. The packet is queued on this entry. * * If the IP address was already stable in the cache, and a packet is - * given, it is directly sent and no ARP request is sent out. - * + * given, it is directly sent and no ARP request is sent out. + * * If the IP address was already stable in the cache, and no packet is * given, an ARP request is sent out. - * + * * @param netif The lwIP network interface on which ipaddr * must be queried for. * @param ipaddr The IP address to be resolved. @@ -1079,7 +1079,7 @@ etharp_query(struct netif *netif, ip_addr_t *ipaddr, struct pbuf *q) struct pbuf *p; int copy_needed = 0; /* IF q includes a PBUF_REF, PBUF_POOL or PBUF_RAM, we have no choice but - * to copy the whole queue into a new PBUF_RAM (see bug #11400) + * to copy the whole queue into a new PBUF_RAM (see bug #11400) * PBUF_ROMs can be left as they are, since ROM must not get changed. */ p = q; while (p) { @@ -1224,7 +1224,7 @@ etharp_raw(struct netif *netif, const struct eth_addr *ethsrc_addr, #endif /* LWIP_AUTOIP */ ETHADDR16_COPY(ðhdr->src, ethsrc_addr); /* Copy struct ip_addr2 to aligned ip_addr, to support compilers without - * structure packing. */ + * structure packing. */ IPADDR2_COPY(&hdr->sipaddr, ipsrc_addr); IPADDR2_COPY(&hdr->dipaddr, ipdst_addr); @@ -1363,7 +1363,7 @@ ethernet_input(struct pbuf *p, struct netif *netif) ip_input(p, netif); } break; - + case PP_HTONS(ETHTYPE_ARP): if (!(netif->flags & NETIF_FLAG_ETHARP)) { goto free_and_return; diff --git a/components/net/lwip-1.4.1/src/netif/ethernetif.c b/components/net/lwip-1.4.1/src/netif/ethernetif.c index f2570f9e2b..5fb9c42464 100644 --- a/components/net/lwip-1.4.1/src/netif/ethernetif.c +++ b/components/net/lwip-1.4.1/src/netif/ethernetif.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * COPYRIGHT (C) 2006-2010, RT-Thread Development Team + * COPYRIGHT (C) 2006-2021, RT-Thread Development Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -59,9 +59,9 @@ #define netifapi_netif_set_link_down(n) netifapi_netif_common(n, netif_set_link_down, NULL) #ifndef RT_LWIP_ETHTHREAD_PRIORITY -#define RT_ETHERNETIF_THREAD_PREORITY 0x90 +#define RT_ETHERNETIF_THREAD_PREORITY 0x90 #else -#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY +#define RT_ETHERNETIF_THREAD_PREORITY RT_LWIP_ETHTHREAD_PRIORITY #endif #ifndef LWIP_NO_TX_THREAD @@ -70,8 +70,8 @@ */ struct eth_tx_msg { - struct netif *netif; - struct pbuf *buf; + struct netif *netif; + struct pbuf *buf; }; static struct rt_mailbox eth_tx_thread_mb; @@ -156,16 +156,16 @@ static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) { netdev_low_level_set_dhcp_status(netif, is_enabled); - + if(RT_TRUE == is_enabled) { dhcp_start((struct netif *)netif->user_data); } else { - dhcp_stop((struct netif *)netif->user_data); + dhcp_stop((struct netif *)netif->user_data); } - + return ERR_OK; } #endif /* RT_LWIP_DHCP */ @@ -368,7 +368,7 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p) struct eth_tx_msg msg; struct eth_device* enetif; - RT_ASSERT(netif != RT_NULL); + RT_ASSERT(netif != RT_NULL); enetif = (struct eth_device*)netif->state; /* send a message to eth tx thread */ @@ -382,13 +382,13 @@ static err_t ethernetif_linkoutput(struct netif *netif, struct pbuf *p) #else struct eth_device* enetif; - RT_ASSERT(netif != RT_NULL); + RT_ASSERT(netif != RT_NULL); enetif = (struct eth_device*)netif->state; - if (enetif->eth_tx(&(enetif->parent), p) != RT_EOK) - { - return ERR_IF; - } + if (enetif->eth_tx(&(enetif->parent), p) != RT_EOK) + { + return ERR_IF; + } #endif return ERR_OK; } @@ -479,16 +479,16 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ netif->name[1] = name[1]; /* set hw address to 6 */ - netif->hwaddr_len = 6; + netif->hwaddr_len = 6; /* maximum transfer unit */ - netif->mtu = ETHERNET_MTU; + netif->mtu = ETHERNET_MTU; /* get hardware MAC address */ rt_device_control(&(dev->parent), NIOCTL_GADDR, netif->hwaddr); /* set output */ - netif->output = etharp_output; - netif->linkoutput = ethernetif_linkoutput; + netif->output = etharp_output; + netif->linkoutput = ethernetif_linkoutput; #if LWIP_NETIF_HOSTNAME /* Initialize interface hostname */ @@ -577,12 +577,12 @@ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) /* NOTE: please not use it in interrupt when no RxThread exist */ rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up) { - if (up == RT_TRUE) - netifapi_netif_set_link_up(dev->netif); - else - netifapi_netif_set_link_down(dev->netif); + if (up == RT_TRUE) + netifapi_netif_set_link_up(dev->netif); + else + netifapi_netif_set_link_down(dev->netif); - return RT_EOK; + return RT_EOK; } #endif @@ -650,7 +650,7 @@ static void eth_rx_thread_entry(void* parameter) /* receive all of buffer */ while (1) { - if(device->eth_rx == RT_NULL) break; + if(device->eth_rx == RT_NULL) break; p = device->eth_rx(&(device->parent)); if (p != RT_NULL) diff --git a/components/net/lwip-1.4.1/src/netif/ppp/auth.c b/components/net/lwip-1.4.1/src/netif/ppp/auth.c index 0fd87a3796..f99763cd78 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/auth.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/auth.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -479,7 +479,7 @@ link_established(int unit) if (go->neg_chap) { ChapAuthPeer(unit, ppp_settings.our_name, go->chap_mdtype); auth |= CHAP_PEER; - } + } #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT && CHAP_SUPPORT else @@ -610,7 +610,7 @@ auth_peer_success(int unit, u16_t protocol, char *name, int namelen) } BCOPY(name, peer_authname, namelen); peer_authname[namelen] = 0; - + /* * If there is no more authentication still to be done, * proceed to the network (or callback) phase. @@ -749,7 +749,7 @@ check_idle(void *arg) { struct ppp_idle idle; u_short itime; - + LWIP_UNUSED_ARG(arg); if (!get_idle_time(0, &idle)) { return; @@ -802,7 +802,7 @@ auth_check_options(void) wo->neg_chap = 1; wo->neg_upap = 1; } - + /* * Check whether we have appropriate secrets to use * to authenticate the peer. @@ -876,7 +876,7 @@ check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, char passwd[256], user[256]; char secret[MAXWORDLEN]; static u_short attempts = 0; - + /* * Make copies of apasswd and auser, then null-terminate them. */ @@ -888,7 +888,7 @@ check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, /* XXX Validate user name and password. */ ret = UPAP_AUTHACK; /* XXX Assume all entries OK. */ - + if (ret == UPAP_AUTHNAK) { if (*msg == (char *) 0) { *msg = "Login incorrect"; @@ -963,7 +963,7 @@ plogin(char *user, char *passwd, char **msg, int *msglen) LWIP_UNUSED_ARG(msglen); - /* The new lines are here align the file when + /* The new lines are here align the file when * compared against the pppd 2.3.11 code */ @@ -1101,7 +1101,7 @@ get_secret(int unit, char *client, char *server, char *secret, int *secret_len, int ret = 0, len; struct wordlist *addrs; char secbuf[MAXWORDLEN]; - + addrs = NULL; secbuf[0] = 0; @@ -1152,7 +1152,7 @@ set_allowed_addrs(int unit, struct wordlist *addrs) struct ipcp_options *wo = &ipcp_wantoptions[unit]; u32_t a; struct hostent *hp; - + if (wo->hisaddr == 0 && *p != '!' && *p != '-' && strchr(p, '/') == NULL) { hp = gethostbyname(p); if (hp != NULL && hp->h_addrtype == AF_INET) { diff --git a/components/net/lwip-1.4.1/src/netif/ppp/auth.h b/components/net/lwip-1.4.1/src/netif/ppp/auth.h index a8069ec464..8af17ac5cf 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/auth.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/auth.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/chap.c b/components/net/lwip-1.4.1/src/netif/ppp/chap.c index f10e27d2ea..892cefadf3 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/chap.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/chap.c @@ -8,13 +8,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -190,7 +190,7 @@ ChapAuthWithPeer(int unit, char *our_name, u_char digest) /* * We get here as a result of LCP coming up. - * So even if CHAP was open before, we will + * So even if CHAP was open before, we will * have to re-authenticate ourselves. */ cstate->clientstate = CHAPCS_LISTEN; @@ -207,7 +207,7 @@ ChapAuthPeer(int unit, char *our_name, u_char digest) cstate->chal_name = our_name; cstate->chal_type = digest; - + if (cstate->serverstate == CHAPSS_INITIAL || cstate->serverstate == CHAPSS_PENDING) { /* lower layer isn't up - wait until later */ @@ -272,7 +272,7 @@ static void ChapRechallenge(void *arg) { chap_state *cstate = (chap_state *) arg; - + /* if we aren't sending a response, don't worry. */ if (cstate->serverstate != CHAPSS_OPEN) { return; @@ -343,7 +343,7 @@ static void ChapProtocolReject(int unit) { chap_state *cstate = &chap[unit]; - + if (cstate->serverstate != CHAPSS_INITIAL && cstate->serverstate != CHAPSS_CLOSED) { auth_peer_fail(unit, PPP_CHAP); @@ -366,7 +366,7 @@ ChapInput(int unit, u_char *inpacket, int packet_len) u_char *inp; u_char code, id; int len; - + /* * Parse header (code, id and length). * If packet too short, drop it. @@ -388,7 +388,7 @@ ChapInput(int unit, u_char *inpacket, int packet_len) return; } len -= CHAP_HEADERLEN; - + /* * Action depends on code (as in fact it usually does :-). */ @@ -396,19 +396,19 @@ ChapInput(int unit, u_char *inpacket, int packet_len) case CHAP_CHALLENGE: ChapReceiveChallenge(cstate, inp, id, len); break; - + case CHAP_RESPONSE: ChapReceiveResponse(cstate, inp, id, len); break; - + case CHAP_FAILURE: ChapReceiveFailure(cstate, inp, id, len); break; - + case CHAP_SUCCESS: ChapReceiveSuccess(cstate, inp, id, len); break; - + default: /* Need code reject? */ CHAPDEBUG(LOG_WARNING, ("Unknown CHAP code (%d) received.\n", code)); break; @@ -486,7 +486,7 @@ ChapReceiveChallenge(chap_state *cstate, u_char *inp, u_char id, int len) cstate->resp_transmits = 0; /* generate MD based on negotiated type */ - switch (cstate->resp_type) { + switch (cstate->resp_type) { case CHAP_DIGEST_MD5: MD5Init(&mdContext); @@ -497,7 +497,7 @@ ChapReceiveChallenge(chap_state *cstate, u_char *inp, u_char id, int len) BCOPY(hash, cstate->response, MD5_SIGNATURE_SIZE); cstate->resp_length = MD5_SIGNATURE_SIZE; break; - + #if MSCHAP_SUPPORT case CHAP_MICROSOFT: ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len); @@ -529,7 +529,7 @@ ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) u_char hash[MD5_SIGNATURE_SIZE]; CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: Rcvd id %d.\n", id)); - + if (cstate->serverstate == CHAPSS_CLOSED || cstate->serverstate == CHAPSS_PENDING) { CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: in state %d\n", @@ -554,7 +554,7 @@ ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) ChapSendStatus(cstate, CHAP_FAILURE); return; } - + if (len < 2) { CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: rcvd short packet.\n")); return; @@ -562,7 +562,7 @@ ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) GETCHAR(remmd_len, inp); /* get length of MD */ remmd = inp; /* get pointer to MD */ INCPTR(remmd_len, inp); - + len -= sizeof (u_char) + remmd_len; if (len < 0) { CHAPDEBUG(LOG_INFO, ("ChapReceiveResponse: rcvd short packet.\n")); @@ -570,7 +570,7 @@ ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) } UNTIMEOUT(ChapChallengeTimeout, cstate); - + if (len >= (int)sizeof(rhostname)) { len = sizeof(rhostname) - 1; } @@ -601,19 +601,19 @@ ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) MD5Update(&mdContext, &cstate->chal_id, 1); MD5Update(&mdContext, (u_char*)secret, secret_len); MD5Update(&mdContext, cstate->challenge, cstate->chal_len); - MD5Final(hash, &mdContext); - + MD5Final(hash, &mdContext); + /* compare local and remote MDs and send the appropriate status */ if (memcmp (hash, remmd, MD5_SIGNATURE_SIZE) == 0) { code = CHAP_SUCCESS; /* they are the same! */ } break; - + default: CHAPDEBUG(LOG_INFO, ("unknown digest type %d\n", cstate->chal_type)); } } - + BZERO(secret, sizeof(secret)); ChapSendStatus(cstate, code); @@ -655,9 +655,9 @@ ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len) cstate->clientstate)); return; } - + UNTIMEOUT(ChapResponseTimeout, cstate); - + /* * Print message. */ @@ -712,7 +712,7 @@ ChapSendChallenge(chap_state *cstate) u_char *outp; int chal_len, name_len; int outlen; - + chal_len = cstate->chal_len; name_len = (int)strlen(cstate->chal_name); outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len; @@ -729,11 +729,11 @@ ChapSendChallenge(chap_state *cstate) INCPTR(chal_len, outp); BCOPY(cstate->chal_name, outp, name_len); /* append hostname */ - + pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); CHAPDEBUG(LOG_INFO, ("ChapSendChallenge: Sent id %d.\n", cstate->chal_id)); - + TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime); ++cstate->chal_transmits; } @@ -760,7 +760,7 @@ ChapSendStatus(chap_state *cstate, int code) outp = outpacket_buf[cstate->unit]; MAKEHEADER(outp, PPP_CHAP); /* paste in a header */ - + PUTCHAR(code, outp); PUTCHAR(cstate->chal_id, outp); PUTSHORT(outlen, outp); @@ -785,8 +785,8 @@ ChapGenChallenge(chap_state *cstate) u_char *ptr = cstate->challenge; int i; - /* pick a random challenge length between MIN_CHALLENGE_LENGTH and - MAX_CHALLENGE_LENGTH */ + /* pick a random challenge length between MIN_CHALLENGE_LENGTH and + MAX_CHALLENGE_LENGTH */ chal_len = (unsigned) ((((magic() >> 16) * (MAX_CHALLENGE_LENGTH - MIN_CHALLENGE_LENGTH)) >> 16) @@ -819,11 +819,11 @@ ChapSendResponse(chap_state *cstate) outp = outpacket_buf[cstate->unit]; MAKEHEADER(outp, PPP_CHAP); - + PUTCHAR(CHAP_RESPONSE, outp); /* we are a response */ PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */ PUTSHORT(outlen, outp); /* packet length */ - + PUTCHAR(md_len, outp); /* length of MD */ BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */ INCPTR(md_len, outp); diff --git a/components/net/lwip-1.4.1/src/netif/ppp/chap.h b/components/net/lwip-1.4.1/src/netif/ppp/chap.h index fedcab8da1..517b774965 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/chap.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/chap.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/chpms.c b/components/net/lwip-1.4.1/src/netif/ppp/chpms.c index 81a887b83a..f177f828a1 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/chpms.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/chpms.c @@ -11,13 +11,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -288,11 +288,11 @@ MakeKey( u_char *key, /* IN 56 bit DES key missing parity bits */ des_key[5] = Get7Bits(key, 35); des_key[6] = Get7Bits(key, 42); des_key[7] = Get7Bits(key, 49); - + #ifndef USE_CRYPT des_set_odd_parity((des_cblock *)des_key); #endif - + #if 0 CHAPDEBUG(LOG_INFO, ("MakeKey: 56-bit input : %02X%02X%02X%02X%02X%02X%02X\n", key[0], key[1], key[2], key[3], key[4], key[5], key[6])); @@ -350,7 +350,7 @@ ChapMS_LANMan( char *rchallenge, int i; u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ u_char PasswordHash[16]; - + /* LANMan password is case insensitive */ BZERO(UcasePassword, sizeof(UcasePassword)); for (i = 0; i < secret_len; i++) { diff --git a/components/net/lwip-1.4.1/src/netif/ppp/chpms.h b/components/net/lwip-1.4.1/src/netif/ppp/chpms.h index df070fb356..d09e782c70 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/chpms.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/chpms.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/fsm.c b/components/net/lwip-1.4.1/src/netif/ppp/fsm.c index e8a254ede5..2dc86e16d4 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/fsm.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/fsm.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -230,7 +230,7 @@ fsm_open(fsm *f) f->state = LS_REQSENT; } break; - + case LS_CLOSING: f->state = LS_STOPPING; /* fall through */ @@ -422,28 +422,28 @@ fsm_input(fsm *f, u_char *inpacket, int l) 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: FSMDEBUG(LOG_INFO, ("fsm_input(%s): default: \n", PROTO_NAME(f))); if( !f->callbacks->extcode || @@ -463,7 +463,7 @@ fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { int code, reject_if_disagree; - FSMDEBUG(LOG_INFO, ("fsm_rconfreq(%s): Rcvd id %d state=%d (%s)\n", + FSMDEBUG(LOG_INFO, ("fsm_rconfreq(%s): Rcvd id %d state=%d (%s)\n", PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); switch( f->state ) { case LS_CLOSED: @@ -488,7 +488,7 @@ fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) f->state = LS_REQSENT; break; } - + /* * Pass the requested configuration options * to protocol-specific code for checking. @@ -501,10 +501,10 @@ fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) } else { code = CONFACK; } - + /* send the Ack, Nak or Rej to the peer */ fsm_sdata(f, (u_char)code, id, inp, len); - + if (code == CONFACK) { if (f->state == LS_ACKRCVD) { UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ @@ -536,7 +536,7 @@ fsm_rconfack(fsm *f, int id, u_char *inp, int len) { FSMDEBUG(LOG_INFO, ("fsm_rconfack(%s): Rcvd id %d state=%d (%s)\n", PROTO_NAME(f), id, f->state, ppperr_strerr[f->state])); - + if (id != f->reqid || f->seen_ack) { /* Expected id? */ return; /* Nope, toss... */ } @@ -547,25 +547,25 @@ fsm_rconfack(fsm *f, int id, u_char *inp, int len) return; } f->seen_ack = 1; - + switch (f->state) { case LS_CLOSED: case LS_STOPPED: fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); break; - + case LS_REQSENT: f->state = LS_ACKRCVD; f->retransmits = f->maxconfreqtransmits; break; - + case LS_ACKRCVD: /* Huh? an extra valid Ack? oh well... */ UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ fsm_sconfreq(f, 0); f->state = LS_REQSENT; break; - + case LS_ACKSENT: UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ f->state = LS_OPENED; @@ -574,7 +574,7 @@ fsm_rconfack(fsm *f, int id, u_char *inp, int len) (*f->callbacks->up)(f); /* Inform upper layers */ } break; - + case LS_OPENED: /* Go down and restart negotiation */ if (f->callbacks->down) { @@ -616,7 +616,7 @@ fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) case LS_STOPPED: fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); break; - + case LS_REQSENT: case LS_ACKSENT: /* They didn't agree to what we wanted - try another request */ @@ -627,14 +627,14 @@ fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) fsm_sconfreq(f, 0); /* Send Configure-Request */ } break; - + case LS_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 = LS_REQSENT; break; - + case LS_OPENED: /* Go down and restart negotiation */ if (f->callbacks->down) { @@ -689,9 +689,9 @@ fsm_rtermreq(fsm *f, int id, u_char *p, int len) static void fsm_rtermack(fsm *f) { - FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): state=%d (%s)\n", + FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): state=%d (%s)\n", PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - + switch (f->state) { case LS_CLOSING: UNTIMEOUT(fsm_timeout, f); @@ -708,11 +708,11 @@ fsm_rtermack(fsm *f) (*f->callbacks->finished)(f); } break; - + case LS_ACKRCVD: f->state = LS_REQSENT; break; - + case LS_OPENED: if (f->callbacks->down) { (*f->callbacks->down)(f); /* Inform upper layers */ @@ -720,7 +720,7 @@ fsm_rtermack(fsm *f) fsm_sconfreq(f, 0); break; default: - FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): UNHANDLED state=%d (%s)!!!\n", + FSMDEBUG(LOG_INFO, ("fsm_rtermack(%s): UNHANDLED state=%d (%s)!!!\n", PROTO_NAME(f), f->state, ppperr_strerr[f->state])); } } @@ -733,10 +733,10 @@ static void fsm_rcoderej(fsm *f, u_char *inp, int len) { u_char code, id; - - FSMDEBUG(LOG_INFO, ("fsm_rcoderej(%s): state=%d (%s)\n", + + FSMDEBUG(LOG_INFO, ("fsm_rcoderej(%s): state=%d (%s)\n", PROTO_NAME(f), f->state, ppperr_strerr[f->state])); - + if (len < HEADERLEN) { FSMDEBUG(LOG_INFO, ("fsm_rcoderej: Rcvd short Code-Reject packet!\n")); return; @@ -745,7 +745,7 @@ fsm_rcoderej(fsm *f, u_char *inp, int len) GETCHAR(id, inp); FSMDEBUG(LOG_WARNING, ("%s: Rcvd Code-Reject for code %d, id %d\n", PROTO_NAME(f), code, id)); - + if( f->state == LS_ACKRCVD ) { f->state = LS_REQSENT; } @@ -783,7 +783,7 @@ fsm_protreject(fsm *f) (*f->callbacks->finished)(f); } break; - + case LS_OPENED: if( f->callbacks->down ) { (*f->callbacks->down)(f); @@ -797,7 +797,7 @@ fsm_protreject(fsm *f) f->state = LS_STOPPING; break; - + default: FSMDEBUG(LOG_INFO, ("%s: Protocol-reject event in state %d (%s)!\n", PROTO_NAME(f), f->state, ppperr_strerr[f->state])); @@ -813,7 +813,7 @@ fsm_sconfreq(fsm *f, int retransmit) { u_char *outp; int cilen; - + if( f->state != LS_REQSENT && f->state != LS_ACKRCVD && f->state != LS_ACKSENT ) { /* Not currently negotiating - reset options */ if( f->callbacks->resetci ) { @@ -821,15 +821,15 @@ fsm_sconfreq(fsm *f, int retransmit) } f->nakloops = 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 */ @@ -848,11 +848,11 @@ fsm_sconfreq(fsm *f, int retransmit) /* 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); - + FSMDEBUG(LOG_INFO, ("%s: sending Configure-Request, id %d\n", PROTO_NAME(f), f->reqid)); } diff --git a/components/net/lwip-1.4.1/src/netif/ppp/fsm.h b/components/net/lwip-1.4.1/src/netif/ppp/fsm.h index 8d41b5f511..0057cf3f51 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/fsm.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/fsm.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/ipcp.c b/components/net/lwip-1.4.1/src/netif/ppp/ipcp.c index f0ab2e0e17..aef7fb0af2 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/ipcp.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/ipcp.c @@ -9,13 +9,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -280,7 +280,7 @@ static void ipcp_resetci(fsm *f) { ipcp_options *wo = &ipcp_wantoptions[f->unit]; - + wo->req_addr = wo->neg_addr && ipcp_allowoptions[f->unit].neg_addr; if (wo->ouraddr == 0) { wo->accept_local = 1; @@ -462,7 +462,7 @@ ipcp_ackci(fsm *f, u_char *p, int len) } \ } \ } - + #define ACKCIADDR(opt, neg, old, val1, val2) \ if (neg) { \ int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ @@ -591,7 +591,7 @@ ipcp_nakci(fsm *f, u_char *p, int len) no.neg = 1; \ code \ } - + #define NAKCIDNS(opt, neg, code) \ if (go->neg && \ ((cilen = p[1]) == CILEN_ADDR) && \ @@ -1091,7 +1091,7 @@ ipcp_reqci(fsm *f, u_char *inp/* Requested CIs */,int *len/* Length of requested ho->vj_protocol = cishort; if (cilen == CILEN_VJ) { GETCHAR(maxslotindex, p); - if (maxslotindex > ao->maxslotindex) { + if (maxslotindex > ao->maxslotindex) { IPCPDEBUG(LOG_INFO, ("ipcp_reqci: Naking VJ max slot %d\n", maxslotindex)); orc = CONFNAK; if (!reject_if_disagree) { @@ -1152,7 +1152,7 @@ endswitch: rc = CONFREJ; ucp = inp; /* Backup */ } - + /* Need to move CI? */ if (ucp != cip) { BCOPY(cip, ucp, cilen); /* Move it */ diff --git a/components/net/lwip-1.4.1/src/netif/ppp/ipcp.h b/components/net/lwip-1.4.1/src/netif/ppp/ipcp.h index de03f460ec..bcfd25caa1 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/ipcp.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/ipcp.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -73,7 +73,7 @@ #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 */ + /* compression option */ typedef struct ipcp_options { u_int neg_addr : 1; /* Negotiate IP Address? */ diff --git a/components/net/lwip-1.4.1/src/netif/ppp/lcp.c b/components/net/lwip-1.4.1/src/netif/ppp/lcp.c index 54f758aa64..06b426a3d4 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/lcp.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/lcp.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -49,7 +49,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "lwip/opt.h" @@ -107,7 +107,7 @@ static u32_t lcp_echo_number = 0; /* ID number of next ech static u32_t lcp_echo_timer_running = 0; /* TRUE if a timer is running */ /* @todo: do we really need such a large buffer? The typical 1500 bytes seem too much. */ -static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ +static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ /* * Callbacks for fsm code. (CI = Configuration Information) @@ -278,7 +278,7 @@ lcp_init(int unit) ao->neg_lqr = 0; /* no LQR implementation yet */ ao->neg_cbcp = (CBCP_SUPPORT != 0); - /* + /* * Set transmit escape for the flag and escape characters plus anything * set for the allowable options. */ @@ -293,7 +293,7 @@ lcp_init(int unit) xmit_accm[unit][1], xmit_accm[unit][2], xmit_accm[unit][3])); - + lcp_phase[unit] = PHASE_INITIALIZE; } @@ -412,7 +412,7 @@ lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len) case PROTREJ: lcp_rprotrej(f, inp, len); break; - + case ECHOREQ: if (f->state != LS_OPENED) { break; @@ -892,7 +892,7 @@ lcp_nakci(fsm *f, u_char *p, int len) goto bad; } try.neg_chap = 0; - + } else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { GETCHAR(cichar, p); if (go->neg_chap) { @@ -910,7 +910,7 @@ lcp_nakci(fsm *f, u_char *p, int len) */ try.neg_upap = 0; } - + } else { /* * We don't recognize what they're suggesting. @@ -1179,7 +1179,7 @@ lcp_rejci(fsm *f, u_char *p, int len) try.neg = 0; \ LCPDEBUG(LOG_INFO, ("lcp_rejci: Callback opt %d rejected\n", opt)); \ } - + REJCISHORT(CI_MRU, neg_mru, go->mru); REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap); REJCICHAP(CI_AUTHTYPE, neg_chap, PPP_CHAP, go->chap_mdtype); @@ -1191,7 +1191,7 @@ lcp_rejci(fsm *f, u_char *p, int len) REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber); REJCIVOID(CI_PCOMPRESSION, neg_pcompression); REJCIVOID(CI_ACCOMPRESSION, neg_accompression); - + /* * If there are any remaining CIs, then this packet is bad. */ @@ -1205,7 +1205,7 @@ lcp_rejci(fsm *f, u_char *p, int len) *go = try; } return 1; - + bad: LCPDEBUG(LOG_WARNING, ("lcp_rejci: received bad Reject!\n")); return 0; @@ -1220,7 +1220,7 @@ bad: * CONFNAK; returns CONFREJ if it can't return CONFACK. */ static int -lcp_reqci(fsm *f, +lcp_reqci(fsm *f, u_char *inp, /* Requested CIs */ int *lenp, /* Length of requested CIs */ int reject_if_disagree) @@ -1318,13 +1318,13 @@ lcp_reqci(fsm *f, break; } GETLONG(cilong, p); - + /* * Asyncmap must have set at least the bits * which are set in lcp_allowoptions[unit].asyncmap. */ if ((ao->asyncmap & ~cilong) != 0) { - LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak ASYNCMAP %lX missing %lX\n", + LCPDEBUG(LOG_INFO, ("lcp_reqci: Nak ASYNCMAP %lX missing %lX\n", cilong, ao->asyncmap)); orc = CONFNAK; PUTCHAR(CI_ASYNCMAP, nakp); @@ -1354,7 +1354,7 @@ lcp_reqci(fsm *f, break; } GETSHORT(cishort, p); - + /* * Authtype must be UPAP or CHAP. * @@ -1365,7 +1365,7 @@ lcp_reqci(fsm *f, * Whether we end up doing CHAP or UPAP depends then on * the ordering of the CIs in the peer's Configure-Request. */ - + if (cishort == PPP_PAP) { if (ho->neg_chap) { /* we've already accepted CHAP */ LCPDEBUG(LOG_WARNING, ("lcp_reqci: Reject AUTHTYPE PAP already accepted\n")); @@ -1432,7 +1432,7 @@ lcp_reqci(fsm *f, ho->neg_chap = 1; break; } - + /* * We don't recognize the protocol they're asking for. * Nak it with something we're willing to do. @@ -1451,7 +1451,7 @@ lcp_reqci(fsm *f, PUTSHORT(PPP_PAP, nakp); } break; - + case CI_QUALITY: GETSHORT(cishort, p); GETLONG(cilong, p); @@ -1465,7 +1465,7 @@ lcp_reqci(fsm *f, orc = CONFREJ; break; } - + /* * Check the protocol and the reporting period. * XXX When should we Nak this, and what with? @@ -1479,7 +1479,7 @@ lcp_reqci(fsm *f, break; } break; - + case CI_MAGICNUMBER: if (!(ao->neg_magicnumber || go->neg_magicnumber) || cilen != CILEN_LONG) { @@ -1507,8 +1507,8 @@ lcp_reqci(fsm *f, ho->neg_magicnumber = 1; ho->magicnumber = cilong; break; - - + + case CI_PCOMPRESSION: #if TRACELCP > 0 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " PCOMPRESSION"); @@ -1521,7 +1521,7 @@ lcp_reqci(fsm *f, } ho->neg_pcompression = 1; break; - + case CI_ACCOMPRESSION: #if TRACELCP > 0 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " ACCOMPRESSION"); @@ -1534,7 +1534,7 @@ lcp_reqci(fsm *f, } ho->neg_accompression = 1; break; - + case CI_MRRU: #if TRACELCP > 0 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_MRRU"); @@ -1542,7 +1542,7 @@ lcp_reqci(fsm *f, #endif orc = CONFREJ; break; - + case CI_SSNHF: #if TRACELCP > 0 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_SSNHF"); @@ -1550,7 +1550,7 @@ lcp_reqci(fsm *f, #endif orc = CONFREJ; break; - + case CI_EPDISC: #if TRACELCP > 0 snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " CI_EPDISC"); @@ -1558,7 +1558,7 @@ lcp_reqci(fsm *f, #endif orc = CONFREJ; break; - + default: #if TRACELCP snprintf(&traceBuf[traceNdx], sizeof(traceBuf), " unknown %d", citype); @@ -1730,7 +1730,7 @@ static void print_string( char *p, int len, void (*printer) (void *, char *, ...), void *arg) { int c; - + printer(arg, "\""); for (; len > 0; --len) { c = *p++; @@ -1897,7 +1897,7 @@ lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void * printer(arg, ">"); } break; - + case TERMACK: case TERMREQ: if (len > 0 && *p >= ' ' && *p < 0x7f) { @@ -1907,7 +1907,7 @@ lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void * len = 0; } break; - + case ECHOREQ: case ECHOREP: case DISCREQ: diff --git a/components/net/lwip-1.4.1/src/netif/ppp/lcp.h b/components/net/lwip-1.4.1/src/netif/ppp/lcp.h index b9201eeb50..92f45bb341 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/lcp.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/lcp.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/magic.c b/components/net/lwip-1.4.1/src/netif/ppp/magic.c index 3732a42417..1a9d16dd44 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/magic.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/magic.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/magic.h b/components/net/lwip-1.4.1/src/netif/ppp/magic.h index eba70d20b0..183643947e 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/magic.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/magic.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/md5.c b/components/net/lwip-1.4.1/src/netif/ppp/md5.c index dc3cc751b7..be49f1fc12 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/md5.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/md5.c @@ -141,7 +141,7 @@ MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) PPPDEBUG(LOG_INFO, ("MD5Update: %u:%.*H\n", inLen, LWIP_MIN(inLen, 20) * 2, inBuf)); PPPDEBUG(LOG_INFO, ("MD5Update: %u:%s\n", inLen, inBuf)); #endif - + /* compute number of bytes mod 64 */ mdi = (int)((mdContext->i[0] >> 3) & 0x3F); diff --git a/components/net/lwip-1.4.1/src/netif/ppp/pap.c b/components/net/lwip-1.4.1/src/netif/ppp/pap.c index 5fb9f886c0..aa806dcac5 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/pap.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/pap.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -214,7 +214,7 @@ upap_timeout(void *arg) { upap_state *u = (upap_state *) arg; - UPAPDEBUG(LOG_INFO, ("upap_timeout: %d timeout %d expired s=%d\n", + UPAPDEBUG(LOG_INFO, ("upap_timeout: %d timeout %d expired s=%d\n", u->us_unit, u->us_timeouttime, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) { @@ -552,7 +552,7 @@ upap_sauthreq(upap_state *u) u_char *outp; int outlen; - outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + u->us_userlen + u->us_passwdlen; outp = outpacket_buf[u->us_unit]; diff --git a/components/net/lwip-1.4.1/src/netif/ppp/pap.h b/components/net/lwip-1.4.1/src/netif/ppp/pap.h index c99a204019..b48cbac347 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/pap.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/pap.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/ppp.c b/components/net/lwip-1.4.1/src/netif/ppp/ppp.c index 8e8fae9f9f..affc2405d8 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/ppp.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/ppp.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -566,9 +566,9 @@ pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatus vj_compress_init(&pc->vjComp); #endif /* VJ_SUPPORT */ - /* + /* * Default the in and out accm so that escape and flag characters - * are always escaped. + * are always escaped. */ pc->rx.inACCM[15] = 0x60; /* no need to protect since RX is not running */ pc->outACCM[15] = 0x60; @@ -655,7 +655,7 @@ int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const cha #endif /* PPPOE_SUPPORT */ -/* Close a PPP connection and release the descriptor. +/* Close a PPP connection and release the descriptor. * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ int @@ -723,7 +723,7 @@ nPut(PPPControl *pc, struct pbuf *nb) LINK_STATS_INC(link.xmit); } -/* +/* * pppAppend - append given character to end of given pbuf. If outACCM * is not NULL and the character needs to be escaped, do so. * If pbuf is full, append another. @@ -733,7 +733,7 @@ static struct pbuf * pppAppend(u_char c, struct pbuf *nb, ext_accm *outACCM) { struct pbuf *tb = nb; - + /* Make sure there is room for the character and an escape code. * Sure we don't quite fill the buffer if the character doesn't * get escaped but is one character worth complicating this? */ @@ -859,9 +859,9 @@ pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) } #if VJ_SUPPORT - /* + /* * Attempt Van Jacobson header compression if VJ is configured and - * this is an IP packet. + * this is an IP packet. */ if (protocol == PPP_IP && pc->vjEnabled) { switch (vj_compress_tcp(&pc->vjComp, pb)) { @@ -921,7 +921,7 @@ pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) /* Update FCS before checking for special characters. */ fcsOut = PPP_FCS(fcsOut, c); - + /* Copy to output buffer escaping special characters. */ tailMB = pppAppend(c, tailMB, &pc->outACCM); } @@ -937,7 +937,7 @@ pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) /* If we failed to complete the packet, throw it away. */ if (!tailMB) { PPPDEBUG(LOG_WARNING, - ("pppifOutput[%d]: Alloc err - dropping proto=%d\n", + ("pppifOutput[%d]: Alloc err - dropping proto=%d\n", pd, protocol)); pbuf_free(headMB); LINK_STATS_INC(link.memerr); @@ -1114,7 +1114,7 @@ pppWrite(int pd, const u_char *s, int n) /* Copy to output buffer escaping special characters. */ tailMB = pppAppend(c, tailMB, &pc->outACCM); } - + /* Add FCS and trailing flag. */ c = ~fcsOut & 0xFF; tailMB = pppAppend(c, tailMB, &pc->outACCM); @@ -1152,11 +1152,11 @@ ppp_send_config( int unit, u16_t mtu, u32_t asyncmap, int pcomp, int accomp) { PPPControl *pc = &pppControl[unit]; int i; - + pc->mtu = mtu; pc->pcomp = pcomp; pc->accomp = accomp; - + /* Load the ACCM bits for the 32 control codes. */ for (i = 0; i < 32/8; i++) { pc->outACCM[i] = (u_char)((asyncmap >> (8 * i)) & 0xFF); @@ -1277,13 +1277,13 @@ GetMask(u32_t addr) nmask = IP_CLASSA_NET; } else if (IP_CLASSB(addr)) { nmask = IP_CLASSB_NET; - } else { + } else { nmask = IP_CLASSC_NET; } /* class D nets are disallowed by bad_ip_adrs */ mask = subnetMask | htonl(nmask); - + /* XXX * Scan through the system's network interfaces. * Get each netmask and OR them into our mask. @@ -1300,7 +1300,7 @@ sifvjcomp(int pd, int vjcomp, u8_t cidcomp, u8_t maxcid) { #if PPPOS_SUPPORT && VJ_SUPPORT PPPControl *pc = &pppControl[pd]; - + pc->vjEnabled = vjcomp; pc->vjComp.compressSlot = cidcomp; pc->vjComp.maxSlotIndex = maxcid; @@ -1343,7 +1343,7 @@ sifup(int pd) { PPPControl *pc = &pppControl[pd]; int st = 1; - + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); @@ -1388,7 +1388,7 @@ sifdown(int pd) { PPPControl *pc = &pppControl[pd]; int st = 1; - + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG(LOG_WARNING, ("sifdown[%d]: bad parms\n", pd)); @@ -1419,7 +1419,7 @@ sifaddr( int pd, u32_t o, u32_t h, u32_t m, u32_t ns1, u32_t ns2) { PPPControl *pc = &pppControl[pd]; int st = 1; - + if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG(LOG_WARNING, ("sifup[%d]: bad parms\n", pd)); @@ -1445,7 +1445,7 @@ cifaddr( int pd, u32_t o, u32_t h) { PPPControl *pc = &pppControl[pd]; int st = 1; - + LWIP_UNUSED_ARG(o); LWIP_UNUSED_ARG(h); if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { @@ -1608,7 +1608,7 @@ pppInput(void *arg) pd = ((struct pppInputHeader *)nb->payload)->unit; protocol = ((struct pppInputHeader *)nb->payload)->proto; - + if(pbuf_header(nb, -(int)sizeof(struct pppInputHeader))) { LWIP_ASSERT("pbuf_header failed\n", 0); goto drop; @@ -1667,7 +1667,7 @@ pppInput(void *arg) #else /* PPPOS_SUPPORT && VJ_SUPPORT */ /* No handler for this protocol so drop the packet. */ PPPDEBUG(LOG_INFO, - ("pppInput[%d]: drop VJ UnComp in %d:.*H\n", + ("pppInput[%d]: drop VJ UnComp in %d:.*H\n", pd, nb->len, LWIP_MIN(nb->len * 2, 40), nb->payload)); #endif /* PPPOS_SUPPORT && VJ_SUPPORT */ break; @@ -1809,14 +1809,14 @@ pppInProc(PPPControlRx *pcrx, u_char *s, int l) /* If we haven't received the packet header, drop what has come in. */ } else if (pcrx->inState < PDDATA) { PPPDEBUG(LOG_WARNING, - ("pppInProc[%d]: Dropping incomplete packet %d\n", + ("pppInProc[%d]: Dropping incomplete packet %d\n", pcrx->pd, pcrx->inState)); LINK_STATS_INC(link.lenerr); pppDrop(pcrx); /* If the fcs is invalid, drop the packet. */ } else if (pcrx->inFCS != PPP_GOODFCS) { PPPDEBUG(LOG_INFO, - ("pppInProc[%d]: Dropping bad fcs 0x%"X16_F" proto=0x%"X16_F"\n", + ("pppInProc[%d]: Dropping bad fcs 0x%"X16_F" proto=0x%"X16_F"\n", pcrx->pd, pcrx->inFCS, pcrx->inProtocol)); /* Note: If you get lots of these, check for UART frame errors or try different baud rate */ LINK_STATS_INC(link.chkerr); @@ -2023,7 +2023,7 @@ drop: void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) { - netif_set_status_callback(&pppControl[pd].netif, status_callback); + netif_set_status_callback(&pppControl[pd].netif, status_callback); } #endif /* LWIP_NETIF_STATUS_CALLBACK */ @@ -2038,7 +2038,7 @@ ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback) { - netif_set_link_callback(&pppControl[pd].netif, link_callback); + netif_set_link_callback(&pppControl[pd].netif, link_callback); } #endif /* LWIP_NETIF_LINK_CALLBACK */ diff --git a/components/net/lwip-1.4.1/src/netif/ppp/ppp.h b/components/net/lwip-1.4.1/src/netif/ppp/ppp.h index 08d6e62d87..7866478d9a 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/ppp.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/ppp.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -138,7 +138,7 @@ typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg); * This initializes the PPP control block but does not * attempt to negotiate the LCP session. * Return a new PPP connection descriptor on success or - * an error code (negative) on failure. + * an error code (negative) on failure. */ int pppOverSerialOpen(sio_fd_t fd, pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx); #endif /* PPPOS_SUPPORT */ @@ -155,9 +155,9 @@ int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const cha #define pppOpen(fd,cb,ls) pppOverSerialOpen(fd,cb,ls) /* - * Close a PPP connection and release the descriptor. + * Close a PPP connection and release the descriptor. * Any outstanding packets in the queues are dropped. - * Return 0 on success, an error code on failure. + * Return 0 on success, an error code on failure. */ int pppClose(int pd); @@ -168,7 +168,7 @@ void pppSigHUP(int pd); /* * Get and set parameters for the given connection. - * Return 0 on success, an error code on failure. + * Return 0 on success, an error code on failure. */ int pppIOCtl(int pd, int cmd, void *arg); diff --git a/components/net/lwip-1.4.1/src/netif/ppp/ppp_impl.h b/components/net/lwip-1.4.1/src/netif/ppp/ppp_impl.h index 89aea60be1..14bac5d811 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/ppp_impl.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/ppp_impl.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -356,7 +356,7 @@ int sifdefaultroute (int, u32_t, u32_t); int cifdefaultroute (int, u32_t, u32_t); /* Get appropriate netmask for address */ -u32_t GetMask (u32_t); +u32_t GetMask (u32_t); #endif /* PPP_SUPPORT */ diff --git a/components/net/lwip-1.4.1/src/netif/ppp/ppp_oe.c b/components/net/lwip-1.4.1/src/netif/ppp/ppp_oe.c index 35d192e412..414e058fb3 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/ppp_oe.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/ppp_oe.c @@ -6,13 +6,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -575,7 +575,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header failed\n")); LINK_STATS_INC(link.lenerr); goto drop; - } + } pb = pppSingleBuf (pb); @@ -615,7 +615,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n")); LINK_STATS_INC(link.lenerr); goto drop; - } + } PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: %c%c%"U16_F": pkthdr.len=%d, pppoe.len=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, @@ -1071,7 +1071,7 @@ pppoe_xmit(struct pppoe_softc *sc, struct pbuf *pb) LINK_STATS_INC(link.lenerr); pbuf_free(pb); return ERR_BUF; - } + } p = (u8_t*)pb->payload + sizeof(struct eth_hdr); PPPOE_ADD_HEADER(p, 0, sc->sc_session, len); diff --git a/components/net/lwip-1.4.1/src/netif/ppp/pppdebug.h b/components/net/lwip-1.4.1/src/netif/ppp/pppdebug.h index 81349971db..15c113ec6d 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/pppdebug.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/pppdebug.h @@ -8,13 +8,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/randm.c b/components/net/lwip-1.4.1/src/netif/ppp/randm.c index b736091fc5..94dc49494d 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/randm.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/randm.c @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -233,7 +233,7 @@ avRandomize(void) * Return a new random number. * Here we use the Borland rand() function to supply a pseudo random * number which we make truely random by combining it with our own - * seed which is randomized by truely random events. + * seed which is randomized by truely random events. * Thus the numbers will be truely random unless there have been no * operator or network events in which case it will be pseudo random * seeded by the real time clock. diff --git a/components/net/lwip-1.4.1/src/netif/ppp/randm.h b/components/net/lwip-1.4.1/src/netif/ppp/randm.h index a0984b0202..468f001626 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/randm.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/randm.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-1.4.1/src/netif/ppp/vj.c b/components/net/lwip-1.4.1/src/netif/ppp/vj.c index 40fdad13d0..eaa4617fda 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/vj.c +++ b/components/net/lwip-1.4.1/src/netif/ppp/vj.c @@ -52,7 +52,7 @@ vj_compress_init(struct vjcompress *comp) { register u_char i; register struct cstate *tstate = comp->tstate; - + #if MAX_SLOTS == 0 memset((char *)comp, 0, sizeof(*comp)); #endif @@ -148,7 +148,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) u_char new_seq[16]; register u_char *cp = new_seq; - /* + /* * Check that the packet is IP proto TCP. */ if (IPH_PROTO(ip) != IP_PROTO_TCP) { @@ -158,7 +158,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) /* * Bail if this is an IP fragment or if the TCP packet isn't * `compressible' (i.e., ACK isn't set or some other control bit is - * set). + * set). */ if ((IPH_OFFSET(ip) & PP_HTONS(0x3fff)) || pb->tot_len < 40) { return (TYPE_IP); @@ -192,7 +192,7 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) */ register struct cstate *lcs; register struct cstate *lastcs = comp->last_cs; - + do { lcs = cs; cs = cs->cs_next; INCR(vjs_searches); @@ -255,11 +255,11 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb) * different between the previous & current datagram, we send the * current datagram `uncompressed'. */ - if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] - || ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] - || ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] - || TCPH_HDRLEN(th) != TCPH_HDRLEN(oth) - || (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) + if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] + || ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] + || ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] + || TCPH_HDRLEN(th) != TCPH_HDRLEN(oth) + || (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) || (TCPH_HDRLEN(th) > 5 && BCMP(th + 1, oth + 1, (TCPH_HDRLEN(th) - 5) << 2))) { goto uncompressed; } @@ -429,7 +429,7 @@ vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) register u_int hlen; register struct cstate *cs; register struct ip_hdr *ip; - + ip = (struct ip_hdr *)nb->payload; hlen = IPH_HL(ip) << 2; if (IPH_PROTO(ip) >= MAX_SLOTS @@ -437,7 +437,7 @@ vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) || (hlen += TCPH_HDRLEN(((struct tcp_hdr *)&((char *)ip)[hlen])) << 2) > nb->len || hlen > MAX_HDR) { - PPPDEBUG(LOG_INFO, ("vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n", + PPPDEBUG(LOG_INFO, ("vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n", IPH_PROTO(ip), hlen, nb->len)); comp->flags |= VJF_TOSS; INCR(vjs_errorin); @@ -456,7 +456,7 @@ vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp) * Uncompress a packet of type TYPE_COMPRESSED_TCP. * The packet is composed of a buffer chain and the first buffer * must contain an accurate chain length. - * The first buffer must include the entire compressed TCP/IP header. + * The first buffer must include the entire compressed TCP/IP header. * This procedure replaces the compressed header with the uncompressed * header and returns the length of the VJ header. */ @@ -475,9 +475,9 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) cp = (u_char *)n0->payload; changes = *cp++; if (changes & NEW_C) { - /* + /* * Make sure the state index is in range, then grab the state. - * If we have a good state index, clear the 'discard' flag. + * If we have a good state index, clear the 'discard' flag. */ if (*cp >= MAX_SLOTS) { PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: bad cid=%d\n", *cp)); @@ -487,10 +487,10 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) comp->flags &=~ VJF_TOSS; comp->last_recv = *cp++; } else { - /* + /* * this packet has an implicit state index. If we've * had a line error since the last time we got an - * explicit state index, we have to toss the packet. + * explicit state index, we have to toss the packet. */ if (comp->flags & VJF_TOSS) { PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: tossing\n")); @@ -559,11 +559,11 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) */ vjlen = (u_short)(cp - (u_char*)n0->payload); if (n0->len < vjlen) { - /* + /* * We must have dropped some characters (crc should detect - * this but the old slip framing won't) + * this but the old slip framing won't) */ - PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: head buffer %d too short %d\n", + PPPDEBUG(LOG_INFO, ("vj_uncompress_tcp: head buffer %d too short %d\n", n0->len, vjlen)); goto bad; } @@ -584,7 +584,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp) tmp = (tmp & 0xffff) + (tmp >> 16); tmp = (tmp & 0xffff) + (tmp >> 16); IPH_CHKSUM_SET(&cs->cs_ip, (u_short)(~tmp)); - + /* Remove the compressed header and prepend the uncompressed header. */ if(pbuf_header(n0, -((s16_t)(vjlen)))) { /* Can we cope with this failing? Just assert for now */ diff --git a/components/net/lwip-1.4.1/src/netif/ppp/vj.h b/components/net/lwip-1.4.1/src/netif/ppp/vj.h index fad1213646..139297d32e 100644 --- a/components/net/lwip-1.4.1/src/netif/ppp/vj.h +++ b/components/net/lwip-1.4.1/src/netif/ppp/vj.h @@ -43,7 +43,7 @@ * 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 diff --git a/components/net/lwip-1.4.1/src/netif/slipif.c b/components/net/lwip-1.4.1/src/netif/slipif.c index 2777630902..a7301430e1 100644 --- a/components/net/lwip-1.4.1/src/netif/slipif.c +++ b/components/net/lwip-1.4.1/src/netif/slipif.c @@ -6,35 +6,35 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is built upon the file: src/arch/rtxc/netif/sioslip.c * - * Author: Magnus Ivarsson + * Author: Magnus Ivarsson * Simon Goldschmidt * * Usage: This netif can be used in three ways: @@ -47,10 +47,10 @@ * packets and puts completed packets on a queue which is fed into * the stack from the main loop (needs SYS_LIGHTWEIGHT_PROT for * pbuf_alloc to work on ISR level!). - * + * */ -/* +/* * This is an arch independent SLIP netif. The specific serial hooks must be * provided by another file. They are sio_open, sio_read/sio_tryread and sio_send */ diff --git a/components/net/lwip-1.4.1/test/unit/lwipopts.h b/components/net/lwip-1.4.1/test/unit/lwipopts.h index 88e76d7a56..5d60cf0819 100644 --- a/components/net/lwip-1.4.1/test/unit/lwipopts.h +++ b/components/net/lwip-1.4.1/test/unit/lwipopts.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-1.4.1/test/unit/tcp/test_tcp.c b/components/net/lwip-1.4.1/test/unit/tcp/test_tcp.c index 6fd5be5068..51ef5a8f22 100644 --- a/components/net/lwip-1.4.1/test/unit/tcp/test_tcp.c +++ b/components/net/lwip-1.4.1/test/unit/tcp/test_tcp.c @@ -207,7 +207,7 @@ START_TEST(test_tcp_fast_retx_recover) EXPECT_RET(pcb->dupacks == 3); memset(&txcounters, 0, sizeof(txcounters)); /* TODO: check expected data?*/ - + /* send data5, not output yet */ err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); EXPECT_RET(err == ERR_OK); diff --git a/components/net/lwip-2.0.2/doc/NO_SYS_SampleCode.c b/components/net/lwip-2.0.2/doc/NO_SYS_SampleCode.c index f5c6c10b61..ff59788889 100644 --- a/components/net/lwip-2.0.2/doc/NO_SYS_SampleCode.c +++ b/components/net/lwip-2.0.2/doc/NO_SYS_SampleCode.c @@ -72,7 +72,7 @@ void main(void) netif_set_status_callback(&netif, netif_status_callback); netif_set_default(&netif); netif_set_up(&netif); - + /* Start DHCP and HTTPD */ dhcp_init(); httpd_init(); @@ -94,7 +94,7 @@ void main(void) if(p != NULL) { LINK_STATS_INC(link.recv); - + /* Update SNMP stats (only if you use SNMP) */ MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len); int unicast = ((p->payload[0] & 0x01) == 0); @@ -108,10 +108,10 @@ void main(void) pbuf_free(p); } } - + /* Cyclic lwIP timers check */ sys_check_timeouts(); - + /* your application goes here */ } } diff --git a/components/net/lwip-2.0.2/doc/doxygen/main_page.h b/components/net/lwip-2.0.2/doc/doxygen/main_page.h index d35d16e1c9..684a5111b1 100644 --- a/components/net/lwip-2.0.2/doc/doxygen/main_page.h +++ b/components/net/lwip-2.0.2/doc/doxygen/main_page.h @@ -1,4 +1,4 @@ -/** +/** * @defgroup lwip lwIP * * @defgroup infrastructure Infrastructure @@ -6,13 +6,13 @@ * @defgroup callbackstyle_api Callback-style APIs * Non thread-safe APIs, callback style for maximum performance and minimum * memory footprint. - * + * * @defgroup sequential_api Sequential-style APIs * Sequential-style APIs, blocking functions. More overhead, but can be called * from any thread except TCPIP thread. - * + * * @defgroup addons Addons - * + * * @defgroup apps Applications */ @@ -44,19 +44,19 @@ * * The most common source of lwIP problems is to have multiple execution contexts * inside the lwIP code. - * - * lwIP can be used in two basic modes: @ref lwip_nosys (no OS/RTOS + * + * lwIP can be used in two basic modes: @ref lwip_nosys (no OS/RTOS * running on target system) or @ref lwip_os (there is an OS running * on the target system). * * Mainloop Mode * ------------- * In mainloop mode, only @ref callbackstyle_api can be used. - * The user has two possibilities to ensure there is only one + * The user has two possibilities to ensure there is only one * exection context at a time in lwIP: * * 1) Deliver RX ethernet packets directly in interrupt context to lwIP - * by calling netif->input directly in interrupt. This implies all lwIP + * by calling netif->input directly in interrupt. This implies all lwIP * callback functions are called in IRQ context, which may cause further * problems in application code: IRQ is blocked for a long time, multiple * execution contexts in application code etc. When the application wants @@ -82,7 +82,7 @@ * implemented in tcpip_input().​​ * Again, ensure lwIP is _NEVER_ called from an interrupt, e.g. * some SPI IRQ wants to forward data to udp_send() or tcp_write()! - * + * * 1) tcpip_callback() can be used get called back from TCPIP thread, * it is safe to call any @ref callbackstyle_api from there. * @@ -108,7 +108,7 @@ * *not* *from* *interrupt* *context*. You can allocate a @ref pbuf in interrupt * context and put them into a queue which is processed from mainloop.\n * Call sys_check_timeouts() periodically in the mainloop.\n - * Porting: implement all functions in @ref sys_time, @ref sys_prot and + * Porting: implement all functions in @ref sys_time, @ref sys_prot and * @ref compiler_abstraction.\n * You can only use @ref callbackstyle_api in this mode.\n * Sample code:\n @@ -130,3 +130,4 @@ * @page raw_api lwIP API * @verbinclude "rawapi.txt" */ +/ diff --git a/components/net/lwip-2.0.2/src/api/api_lib.c b/components/net/lwip-2.0.2/src/api/api_lib.c index 7d9c12768d..85e62ea9fd 100644 --- a/components/net/lwip-2.0.2/src/api/api_lib.c +++ b/components/net/lwip-2.0.2/src/api/api_lib.c @@ -1,21 +1,21 @@ /** * @file * Sequential API External module - * + * * @defgroup netconn Netconn API * @ingroup sequential_api * Thread-safe, to be called from non-TCPIP threads only. * TX/RX handling based on @ref netbuf (containing @ref pbuf) * to avoid copying data around. - * + * * @defgroup netconn_common Common functions * @ingroup netconn * For use with TCP and UDP - * + * * @defgroup netconn_tcp TCP only * @ingroup netconn * TCP only functions - * + * * @defgroup netconn_udp UDP only * @ingroup netconn * UDP only functions @@ -241,7 +241,7 @@ netconn_getaddr(struct netconn *conn, ip_addr_t *addr, u16_t *port, u8_t local) * Binding one netconn twice might not always be checked correctly! * * @param conn the netconn to bind - * @param addr the local IP address to bind the netconn to + * @param addr the local IP address to bind the netconn to * (use IP4_ADDR_ANY/IP6_ADDR_ANY to bind to all addresses) * @param port the local port to bind the netconn to (not used for RAW) * @return ERR_OK if bound, any other err_t on failure @@ -251,7 +251,7 @@ netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port) { API_MSG_VAR_DECLARE(msg); err_t err; - + LWIP_ERROR("netconn_bind: invalid conn", (conn != NULL), return ERR_ARG;); #if LWIP_IPV4 @@ -260,7 +260,7 @@ netconn_bind(struct netconn *conn, const ip_addr_t *addr, u16_t port) addr = IP4_ADDR_ANY; } #endif /* LWIP_IPV4 */ - + #if LWIP_IPV4 && LWIP_IPV6 /* "Socket API like" dual-stack support: If IP to bind to is IP6_ADDR_ANY, * and NETCONN_FLAG_IPV6_V6ONLY is 0, use IP_ANY_TYPE to bind diff --git a/components/net/lwip-2.0.2/src/api/api_msg.c b/components/net/lwip-2.0.2/src/api/api_msg.c index dd99c1e01b..caef885f40 100644 --- a/components/net/lwip-2.0.2/src/api/api_msg.c +++ b/components/net/lwip-2.0.2/src/api/api_msg.c @@ -548,14 +548,14 @@ pcb_new(struct api_msg *msg) enum lwip_ip_addr_type iptype = IPADDR_TYPE_V4; LWIP_ASSERT("pcb_new: pcb already allocated", msg->conn->pcb.tcp == NULL); - + #if LWIP_IPV6 && LWIP_IPV4 /* IPv6: Dual-stack by default, unless netconn_set_ipv6only() is called */ if(NETCONNTYPE_ISIPV6(netconn_type(msg->conn))) { iptype = IPADDR_TYPE_ANY; } #endif - + /* Allocate a PCB for this connection */ switch(NETCONNTYPE_GROUP(msg->conn->type)) { #if LWIP_RAW diff --git a/components/net/lwip-2.0.2/src/api/netifapi.c b/components/net/lwip-2.0.2/src/api/netifapi.c index fef05a34dc..3215d4e9cd 100644 --- a/components/net/lwip-2.0.2/src/api/netifapi.c +++ b/components/net/lwip-2.0.2/src/api/netifapi.c @@ -5,10 +5,10 @@ * @defgroup netifapi NETIF API * @ingroup sequential_api * Thread-safe functions to be called from non-TCPIP threads - * + * * @defgroup netifapi_netif NETIF related * @ingroup netifapi - * To be called from non-TCPIP threads + * To be called from non-TCPIP threads */ /* @@ -57,10 +57,10 @@ static err_t netifapi_do_netif_add(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct netifapi_msg */ struct netifapi_msg *msg = (struct netifapi_msg*)(void*)m; - + if (!netif_add( msg->netif, #if LWIP_IPV4 API_EXPR_REF(msg->msg.add.ipaddr), @@ -83,7 +83,7 @@ netifapi_do_netif_add(struct tcpip_api_call_data *m) static err_t netifapi_do_netif_set_addr(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct netifapi_msg */ struct netifapi_msg *msg = (struct netifapi_msg*)(void*)m; @@ -102,7 +102,7 @@ netifapi_do_netif_set_addr(struct tcpip_api_call_data *m) static err_t netifapi_do_netif_common(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct netifapi_msg */ struct netifapi_msg *msg = (struct netifapi_msg*)(void*)m; diff --git a/components/net/lwip-2.0.2/src/api/sockets.c b/components/net/lwip-2.0.2/src/api/sockets.c index dc2477b611..e7c8413c9e 100644 --- a/components/net/lwip-2.0.2/src/api/sockets.c +++ b/components/net/lwip-2.0.2/src/api/sockets.c @@ -407,7 +407,7 @@ tryget_socket(int s) struct lwip_sock * lwip_tryget_socket(int s) { - return tryget_socket(s); + return tryget_socket(s); } /** diff --git a/components/net/lwip-2.0.2/src/api/tcpip.c b/components/net/lwip-2.0.2/src/api/tcpip.c index 07b2f98434..7d59f6f55f 100644 --- a/components/net/lwip-2.0.2/src/api/tcpip.c +++ b/components/net/lwip-2.0.2/src/api/tcpip.c @@ -354,7 +354,7 @@ tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t* sem) /** * Synchronously calls function in TCPIP thread and waits for its completion. * It is recommended to use LWIP_TCPIP_CORE_LOCKING (preferred) or - * LWIP_NETCONN_SEM_PER_THREAD. + * LWIP_NETCONN_SEM_PER_THREAD. * If not, a semaphore is created and destroyed on every call which is usually * an expensive/slow operation. * @param fn Function to call diff --git a/components/net/lwip-2.0.2/src/apps/httpd/fs.c b/components/net/lwip-2.0.2/src/apps/httpd/fs.c index 35b5e31038..1afb5f61e2 100644 --- a/components/net/lwip-2.0.2/src/apps/httpd/fs.c +++ b/components/net/lwip-2.0.2/src/apps/httpd/fs.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-2.0.2/src/apps/httpd/fsdata.h b/components/net/lwip-2.0.2/src/apps/httpd/fsdata.h index ac4548c785..1bee2d00fa 100644 --- a/components/net/lwip-2.0.2/src/apps/httpd/fsdata.h +++ b/components/net/lwip-2.0.2/src/apps/httpd/fsdata.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-2.0.2/src/apps/httpd/httpd.c b/components/net/lwip-2.0.2/src/apps/httpd/httpd.c index 43195d7c54..83ff1d2bc2 100644 --- a/components/net/lwip-2.0.2/src/apps/httpd/httpd.c +++ b/components/net/lwip-2.0.2/src/apps/httpd/httpd.c @@ -548,7 +548,7 @@ http_write(struct tcp_pcb *pcb, const void* ptr, u16_t *length, u8_t apiflags) } else { len /= 2; } - LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, + LWIP_DEBUGF(HTTPD_DEBUG | LWIP_DBG_TRACE, ("Send failed, trying less (%d bytes)\n", len)); } } while ((err == ERR_MEM) && (len > 1)); @@ -871,7 +871,7 @@ get_http_headers(struct http_state *hs, const char *uri) hs->hdrs[HDR_STRINGS_IDX_HTTP_STATUS] = g_psHTTPHeaderStrings[HTTP_HDR_OK]; } - /* Determine if the URI has any variables and, if so, temporarily remove + /* Determine if the URI has any variables and, if so, temporarily remove them. */ vars = strchr(uri, '?'); if(vars) { diff --git a/components/net/lwip-2.0.2/src/apps/lwiperf/lwiperf.c b/components/net/lwip-2.0.2/src/apps/lwiperf/lwiperf.c index efabe478e3..0256555154 100644 --- a/components/net/lwip-2.0.2/src/apps/lwiperf/lwiperf.c +++ b/components/net/lwip-2.0.2/src/apps/lwiperf/lwiperf.c @@ -566,7 +566,7 @@ lwiperf_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err) return ERR_OK; } -/** +/** * @ingroup iperf * Start a TCP iperf server on the default TCP port (5001) and listen for * incoming connections from iperf clients. diff --git a/components/net/lwip-2.0.2/src/apps/mdns/mdns.c b/components/net/lwip-2.0.2/src/apps/mdns/mdns.c index 14334fc856..1fdf607236 100644 --- a/components/net/lwip-2.0.2/src/apps/mdns/mdns.c +++ b/components/net/lwip-2.0.2/src/apps/mdns/mdns.c @@ -7,9 +7,9 @@ * * RFC 6762 - Multicast DNS\n * RFC 6763 - DNS-Based Service Discovery\n - * + * * @verbinclude mdns.txt - * + * * Things left to implement: * ------------------------- * diff --git a/components/net/lwip-2.0.2/src/apps/mqtt/mqtt.c b/components/net/lwip-2.0.2/src/apps/mqtt/mqtt.c index a0e77b9719..61c83fe37d 100644 --- a/components/net/lwip-2.0.2/src/apps/mqtt/mqtt.c +++ b/components/net/lwip-2.0.2/src/apps/mqtt/mqtt.c @@ -142,7 +142,7 @@ static const char * const mqtt_message_type_str[15] = /** * Message type value to string * @param msg_type see enum mqtt_message_type - * + * * @return Control message type text string */ static const char * diff --git a/components/net/lwip-2.0.2/src/apps/netbiosns/netbiosns.c b/components/net/lwip-2.0.2/src/apps/netbiosns/netbiosns.c index 2dfbe65901..3aa9505e34 100644 --- a/components/net/lwip-2.0.2/src/apps/netbiosns/netbiosns.c +++ b/components/net/lwip-2.0.2/src/apps/netbiosns/netbiosns.c @@ -315,7 +315,7 @@ netbiosns_recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t } /** - * @ingroup netbiosns + * @ingroup netbiosns * Init netbios responder */ void @@ -336,7 +336,7 @@ netbiosns_init(void) #ifndef NETBIOS_LWIP_NAME /** - * @ingroup netbiosns + * @ingroup netbiosns * Set netbios name. ATTENTION: the hostname must be less than 15 characters! */ void @@ -352,7 +352,7 @@ netbiosns_set_name(const char* hostname) #endif /** - * @ingroup netbiosns + * @ingroup netbiosns * Stop netbios responder */ void diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_core.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_core.c index c041833617..3fe28490c3 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_core.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_core.c @@ -48,7 +48,7 @@ * * 0 Agent Capabilities * ==================== - * + * * Features: * --------- * - SNMPv2c support. @@ -66,7 +66,7 @@ * - Simplified thread sync support for MIBs - useful when MIBs * need to access variables shared with other threads where no locking is * possible. Used in MIB2 to access lwIP stats from lwIP thread. - * + * * MIB compiler (code generator): * ------------------------------ * - Provided in lwIP contrib repository. @@ -78,92 +78,92 @@ * - MIB parser, C file generation framework and LWIP code generation are cleanly * separated, which means the code may be useful as a base for code generation * of other SNMP agents. - * + * * Notes: * ------ * - Stack and MIB compiler were used to implement a Profinet device. * Compiled/implemented MIBs: LLDP-MIB, LLDP-EXT-DOT3-MIB, LLDP-EXT-PNO-MIB. - * + * * SNMPv1 per RFC1157 and SNMPv2c per RFC 3416 * ------------------------------------------- * Note the S in SNMP stands for "Simple". Note that "Simple" is * relative. SNMP is simple compared to the complex ISO network * management protocols CMIP (Common Management Information Protocol) * and CMOT (CMip Over Tcp). - * + * * MIB II * ------ * The standard lwIP stack management information base. * This is a required MIB, so this is always enabled. * The groups EGP, CMOT and transmission are disabled by default. - * + * * Most mib-2 objects are not writable except: * sysName, sysLocation, sysContact, snmpEnableAuthenTraps. * Writing to or changing the ARP and IP address and route * tables is not possible. - * + * * Note lwIP has a very limited notion of IP routing. It currently * doen't have a route table and doesn't have a notion of the U,G,H flags. * Instead lwIP uses the interface list with only one default interface * acting as a single gateway interface (G) for the default route. - * + * * The agent returns a "virtual table" with the default route 0.0.0.0 * for the default interface and network routes (no H) for each * network interface in the netif_list. * All routes are considered to be up (U). - * + * * Loading additional MIBs * ----------------------- * MIBs can only be added in compile-time, not in run-time. - * - * + * + * * 1 Building the Agent * ==================== * First of all you'll need to add the following define * to your local lwipopts.h: * \#define LWIP_SNMP 1 - * + * * and add the source files your makefile. - * + * * Note you'll might need to adapt you network driver to update * the mib2 variables for your interface. - * + * * 2 Running the Agent * =================== * The following function calls must be made in your program to * actually get the SNMP agent running. - * + * * Before starting the agent you should supply pointers * for sysContact, sysLocation, and snmpEnableAuthenTraps. * You can do this by calling - * + * * - snmp_mib2_set_syscontact() * - snmp_mib2_set_syslocation() * - snmp_set_auth_traps_enabled() - * - * You can register a callback which is called on successful write access: + * + * You can register a callback which is called on successful write access: * snmp_set_write_callback(). - * + * * Additionally you may want to set - * + * * - snmp_mib2_set_sysdescr() * - snmp_set_device_enterprise_oid() * - snmp_mib2_set_sysname() - * + * * Also before starting the agent you need to setup * one or more trap destinations using these calls: - * + * * - snmp_trap_dst_enable() * - snmp_trap_dst_ip_set() - * + * * If you need more than MIB2, set the MIBs you want to use * by snmp_set_mibs(). - * + * * Finally, enable the agent by calling snmp_init() * * @defgroup snmp_core Core * @ingroup snmp - * + * * @defgroup snmp_traps Traps * @ingroup snmp */ @@ -232,7 +232,7 @@ snmp_set_mibs(const struct snmp_mib **mibs, u8_t num_mibs) * The 'device enterprise oid' shall point to an OID located under 'private-enterprises' branch (1.3.6.1.4.1.XXX). If a vendor * wants to provide a custom object there, he has to get its own enterprise oid from IANA (http://www.iana.org). It * is not allowed to use LWIP enterprise ID! - * In order to identify a specific device it is recommended to create a dedicated OID for each device type under its own + * In order to identify a specific device it is recommended to create a dedicated OID for each device type under its own * enterprise oid. * e.g. * device a > 1.3.6.1.4.1.XXX(ent-oid).1(devices).1(device a) @@ -250,7 +250,7 @@ void snmp_set_device_enterprise_oid(const struct snmp_obj_id* device_enterprise_ /** * @ingroup snmp_core - * Get 'device enterprise oid' + * Get 'device enterprise oid' */ const struct snmp_obj_id* snmp_get_device_enterprise_oid(void) { @@ -521,7 +521,7 @@ snmp_oid_to_ip_port(const u32_t *oid, u8_t oid_len, ip_addr_t *ip, u16_t *port) /** * Assign an OID to struct snmp_obj_id - * @param target Assignment target + * @param target Assignment target * @param oid OID * @param oid_len OID length */ @@ -906,7 +906,7 @@ snmp_get_next_node_instance_from_oid(const u32_t *oid, u8_t oid_len, snmp_valida /* we found a suitable next node, now we have to check if a inner MIB is located between the searched OID and the resulting OID. - this is possible because MIB's may be located anywhere in the global tree, that means also in + this is possible because MIB's may be located anywhere in the global tree, that means also in the subtree of another MIB (e.g. if searched OID is .2 and resulting OID is .4, then another MIB having .3 as root node may exist) */ diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_system.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_system.c index 90e57805d2..157902033b 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_system.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_system.c @@ -351,7 +351,7 @@ system_set_value(const struct snmp_scalar_array_node_def *node, u16_t len, void /* no need to check size of target buffer, this was already done in set_test method */ LWIP_ASSERT("", var_wr != NULL); MEMCPY(var_wr, value, len); - + if (var_wr_len == NULL) { /* add terminating 0 */ var_wr[len] = 0; diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_udp.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_udp.c index 6a983df20b..7db2204d6f 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_udp.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_mib2_udp.c @@ -135,7 +135,7 @@ udp_endpointTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t if (row_oid[idx] != 0) { return SNMP_ERR_NOSUCHINSTANCE; } - + /* find udp_pcb with requested ip and port*/ pcb = udp_pcbs; while (pcb != NULL) { @@ -153,7 +153,7 @@ udp_endpointTable_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t return SNMP_ERR_NOSUCHINSTANCE; } -static snmp_err_t +static snmp_err_t udp_endpointTable_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len) { struct udp_pcb *pcb; @@ -181,12 +181,12 @@ udp_endpointTable_get_next_cell_instance_and_value(const u32_t* column, struct s /* udpEndpointRemoteAddressType + udpEndpointRemoteAddress + udpEndpointRemotePort */ idx += snmp_ip_port_to_oid(&pcb->remote_ip, pcb->remote_port, &test_oid[idx]); - test_oid[idx] = 0; /* udpEndpointInstance */ + test_oid[idx] = 0; /* udpEndpointInstance */ idx++; - + /* check generated OID: is it a candidate for the next one? */ snmp_next_oid_check(&state, test_oid, idx, NULL); - + pcb = pcb->next; } @@ -214,7 +214,7 @@ static const struct snmp_oid_range udp_Table_oid_ranges[] = { { 1, 0xffff } /* Port */ }; -static snmp_err_t +static snmp_err_t udp_Table_get_cell_value_core(struct udp_pcb *pcb, const u32_t* column, union snmp_variant_value* value, u32_t* value_len) { LWIP_UNUSED_ARG(value_len); @@ -235,7 +235,7 @@ udp_Table_get_cell_value_core(struct udp_pcb *pcb, const u32_t* column, union sn return SNMP_ERR_NOERROR; } -static snmp_err_t +static snmp_err_t udp_Table_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid_len, union snmp_variant_value* value, u32_t* value_len) { ip4_addr_t ip; @@ -267,7 +267,7 @@ udp_Table_get_cell_value(const u32_t* column, const u32_t* row_oid, u8_t row_oid return SNMP_ERR_NOSUCHINSTANCE; } -static snmp_err_t +static snmp_err_t udp_Table_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_id* row_oid, union snmp_variant_value* value, u32_t* value_len) { struct udp_pcb *pcb; @@ -289,7 +289,7 @@ udp_Table_get_next_cell_instance_and_value(const u32_t* column, struct snmp_obj_ /* check generated OID: is it a candidate for the next one? */ snmp_next_oid_check(&state, test_oid, LWIP_ARRAYSIZE(udp_Table_oid_ranges), pcb); } - + pcb = pcb->next; } @@ -322,13 +322,13 @@ static const struct snmp_table_simple_node udp_Table = SNMP_TABLE_CREATE_SIMPLE( #endif /* LWIP_IPV4 */ static const struct snmp_table_simple_col_def udp_endpointTable_columns[] = { - /* all items except udpEndpointProcess are declared as not-accessible */ + /* all items except udpEndpointProcess are declared as not-accessible */ { 8, SNMP_ASN1_TYPE_UNSIGNED32, SNMP_VARIANT_VALUE_TYPE_U32 } /* udpEndpointProcess */ }; static const struct snmp_table_simple_node udp_endpointTable = SNMP_TABLE_CREATE_SIMPLE(7, udp_endpointTable_columns, udp_endpointTable_get_cell_value, udp_endpointTable_get_next_cell_instance_and_value); -/* the following nodes access variables in LWIP stack from SNMP worker thread and must therefore be synced to LWIP (TCPIP) thread */ +/* the following nodes access variables in LWIP stack from SNMP worker thread and must therefore be synced to LWIP (TCPIP) thread */ CREATE_LWIP_SYNC_NODE(1, udp_inDatagrams) CREATE_LWIP_SYNC_NODE(2, udp_noPorts) CREATE_LWIP_SYNC_NODE(3, udp_inErrors) diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.c index 0cb7ca997c..1485d7069f 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.c @@ -149,7 +149,7 @@ snmp_set_community_trap(const char * const community) * @ingroup snmp_core * Callback fired on every successful write access */ -void +void snmp_set_write_callback(snmp_write_callback_fct write_callback, void* callback_arg) { snmp_write_callback = write_callback; @@ -180,7 +180,7 @@ snmp_receive(void *handle, struct pbuf *p, const ip_addr_t *source_ip, u16_t por { err_t err; struct snmp_request request; - + memset(&request, 0, sizeof(request)); request.handle = handle; request.source_ip = source_ip; @@ -209,12 +209,12 @@ snmp_receive(void *handle, struct pbuf *p, const ip_addr_t *source_ip, u16_t por if (err == ERR_OK) { err = snmp_complete_outbound_frame(&request); - + if (err == ERR_OK) { err = snmp_sendto(request.handle, request.outbound_pbuf, request.source_ip, request.source_port); - if ((request.request_type == SNMP_ASN1_CONTEXT_PDU_SET_REQ) - && (request.error_status == SNMP_ERR_NOERROR) + if ((request.request_type == SNMP_ASN1_CONTEXT_PDU_SET_REQ) + && (request.error_status == SNMP_ERR_NOERROR) && (snmp_write_callback != NULL)) { /* raise write notification for all written objects */ snmp_execute_write_callbacks(&request); @@ -222,7 +222,7 @@ snmp_receive(void *handle, struct pbuf *p, const ip_addr_t *source_ip, u16_t por } } } - + if (request.outbound_pbuf != NULL) { pbuf_free(request.outbound_pbuf); } @@ -244,7 +244,7 @@ snmp_msg_getnext_validate_node_inst(struct snmp_node_instance* node_instance, vo return SNMP_ERR_NOERROR; } -static void +static void snmp_process_varbind(struct snmp_request *request, struct snmp_varbind *vb, u8_t get_next) { err_t err; @@ -388,7 +388,7 @@ snmp_process_getnext_request(struct snmp_request *request) request->error_status = SNMP_ERR_GENERROR; } } - + return ERR_OK; } @@ -447,7 +447,7 @@ snmp_process_getbulk_request(struct snmp_request *request) while ((request->error_status == SNMP_ERR_NOERROR) && (repetitions > 0) && (request->outbound_pbuf_stream.offset != repetition_offset)) { u8_t all_endofmibview = 1; - + snmp_vb_enumerator_init(&repetition_varbind_enumerator, request->outbound_pbuf, repetition_offset, request->outbound_pbuf_stream.offset - repetition_offset); repetition_offset = request->outbound_pbuf_stream.offset; /* for next loop */ @@ -478,7 +478,7 @@ snmp_process_getbulk_request(struct snmp_request *request) /* stop when all varbinds in a loop return EndOfMibView */ break; } - + repetitions--; } @@ -510,7 +510,7 @@ snmp_process_set_request(struct snmp_request *request) if (err == SNMP_VB_ENUMERATOR_ERR_OK) { struct snmp_node_instance node_instance; memset(&node_instance, 0, sizeof(node_instance)); - + request->error_status = snmp_get_node_instance_from_oid(vb.oid.id, vb.oid.len, &node_instance); if (request->error_status == SNMP_ERR_NOERROR) { if (node_instance.asn1_type != vb.type) { @@ -617,7 +617,7 @@ snmp_parse_inbound_frame(struct snmp_request *request) err_t err; IF_PARSE_EXEC(snmp_pbuf_stream_init(&pbuf_stream, request->inbound_pbuf, 0, request->inbound_pbuf->tot_len)); - + /* decode main container consisting of version, community and PDU */ IF_PARSE_EXEC(snmp_asn1_dec_tlv(&pbuf_stream, &tlv)); IF_PARSE_ASSERT((tlv.type == SNMP_ASN1_TYPE_SEQUENCE) && (tlv.value_len == pbuf_stream.length)); @@ -628,7 +628,7 @@ snmp_parse_inbound_frame(struct snmp_request *request) IF_PARSE_ASSERT(tlv.type == SNMP_ASN1_TYPE_INTEGER); parent_tlv_value_len -= SNMP_ASN1_TLV_LENGTH(tlv); IF_PARSE_ASSERT(parent_tlv_value_len > 0); - + IF_PARSE_EXEC(snmp_asn1_dec_s32t(&pbuf_stream, tlv.value_len, &s32_value)); if ((s32_value != SNMP_VERSION_1) && (s32_value != SNMP_VERSION_2c) @@ -921,7 +921,7 @@ snmp_parse_inbound_frame(struct snmp_request *request) snmp_authfail_trap(); return ERR_ARG; } - } else { + } else { if (strncmp(snmp_community, (const char*)request->community, SNMP_MAX_COMMUNITY_STR_LEN) != 0) { /* community name does not match */ snmp_stats.inbadcommunitynames++; @@ -929,13 +929,13 @@ snmp_parse_inbound_frame(struct snmp_request *request) return ERR_ARG; } } - + /* decode request ID */ IF_PARSE_EXEC(snmp_asn1_dec_tlv(&pbuf_stream, &tlv)); IF_PARSE_ASSERT(tlv.type == SNMP_ASN1_TYPE_INTEGER); parent_tlv_value_len -= SNMP_ASN1_TLV_LENGTH(tlv); IF_PARSE_ASSERT(parent_tlv_value_len > 0); - + IF_PARSE_EXEC(snmp_asn1_dec_s32t(&pbuf_stream, tlv.value_len, &request->request_id)); /* decode error status / non-repeaters */ @@ -976,7 +976,7 @@ snmp_parse_inbound_frame(struct snmp_request *request) /* decode varbind-list type (next container level) */ IF_PARSE_EXEC(snmp_asn1_dec_tlv(&pbuf_stream, &tlv)); IF_PARSE_ASSERT((tlv.type == SNMP_ASN1_TYPE_SEQUENCE) && (tlv.value_len <= pbuf_stream.length)); - + request->inbound_varbind_offset = pbuf_stream.offset; request->inbound_varbind_len = pbuf_stream.length - request->inbound_padding_len; snmp_vb_enumerator_init(&(request->inbound_varbind_enumerator), request->inbound_pbuf, request->inbound_varbind_offset, request->inbound_varbind_len); @@ -1327,8 +1327,8 @@ snmp_complete_outbound_frame(struct snmp_request *request) if (request->error_status != SNMP_ERR_NOERROR) { /* map v2c error codes to v1 compliant error code (according to RFC 2089) */ switch (request->error_status) { - /* mapping of implementation specific "virtual" error codes - * (during processing of frame we already stored them in error_status field, + /* mapping of implementation specific "virtual" error codes + * (during processing of frame we already stored them in error_status field, * so no need to check all varbinds here for those exceptions as suggested by RFC) */ case SNMP_ERR_NOSUCHINSTANCE: case SNMP_ERR_NOSUCHOBJECT: @@ -1549,7 +1549,7 @@ snmp_complete_outbound_frame(struct snmp_request *request) return ERR_OK; } -static void +static void snmp_execute_write_callbacks(struct snmp_request *request) { struct snmp_varbind_enumerator inbound_varbind_enumerator; @@ -1584,7 +1584,7 @@ snmp_vb_enumerator_get_next(struct snmp_varbind_enumerator* enumerator, struct s struct snmp_asn1_tlv tlv; u16_t varbind_len; err_t err; - + if (enumerator->pbuf_stream.length == 0) { return SNMP_VB_ENUMERATOR_ERR_EOVB; @@ -1599,7 +1599,7 @@ snmp_vb_enumerator_get_next(struct snmp_varbind_enumerator* enumerator, struct s /* decode varbind name (object id) */ VB_PARSE_EXEC(snmp_asn1_dec_tlv(&(enumerator->pbuf_stream), &tlv)); VB_PARSE_ASSERT((tlv.type == SNMP_ASN1_TYPE_OBJECT_ID) && (SNMP_ASN1_TLV_LENGTH(tlv) < varbind_len) && (tlv.value_len < enumerator->pbuf_stream.length)); - + VB_PARSE_EXEC(snmp_asn1_dec_oid(&(enumerator->pbuf_stream), tlv.value_len, varbind->oid.id, &(varbind->oid.len), SNMP_MAX_OBJ_ID_LEN)); varbind_len -= SNMP_ASN1_TLV_LENGTH(tlv); diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.h b/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.h index 2d01ef36eb..0c27b45868 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.h +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_msg.h @@ -115,7 +115,7 @@ struct snmp_request s32_t non_repeaters; /* max-repetitions (getBulkRequest (SNMPv2c)) */ s32_t max_repetitions; - + #if LWIP_SNMP_V3 s32_t msg_id; s32_t msg_max_size; diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_netconn.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_netconn.c index 24c3e26531..1b406ef9d7 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_netconn.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_netconn.c @@ -51,7 +51,7 @@ snmp_netconn_thread(void *arg) struct netbuf *buf; err_t err; LWIP_UNUSED_ARG(arg); - + /* Bind to SNMP port with default IP address */ #if LWIP_IPV6 conn = netconn_new(NETCONN_UDP_IPV6); @@ -61,7 +61,7 @@ snmp_netconn_thread(void *arg) netconn_bind(conn, IP4_ADDR_ANY, SNMP_IN_PORT); #endif /* LWIP_IPV6 */ LWIP_ERROR("snmp_netconn: invalid conn", (conn != NULL), return;); - + snmp_traps_handle = conn; do { @@ -77,16 +77,16 @@ snmp_netconn_thread(void *arg) } while(1); } -err_t +err_t snmp_sendto(void *handle, struct pbuf *p, const ip_addr_t *dst, u16_t port) { err_t result; struct netbuf buf; - + memset(&buf, 0, sizeof(buf)); buf.p = p; result = netconn_sendto((struct netconn*)handle, &buf, dst, port); - + return result; } diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_raw.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_raw.c index 4a40864fc9..834a0496f6 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_raw.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_raw.c @@ -52,7 +52,7 @@ snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, pbuf_free(p); } -err_t +err_t snmp_sendto(void *handle, struct pbuf *p, const ip_addr_t *dst, u16_t port) { return udp_sendto((struct udp_pcb*)handle, p, dst, port); @@ -86,7 +86,7 @@ void snmp_init(void) { err_t err; - + struct udp_pcb *snmp_pcb = udp_new_ip_type(IPADDR_TYPE_ANY); LWIP_ERROR("snmp_raw: no PCB", (snmp_pcb != NULL), return;); diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_scalar.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_scalar.c index 136c9eccd0..776e0a3224 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_scalar.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_scalar.c @@ -46,7 +46,7 @@ static s16_t snmp_scalar_array_get_value(struct snmp_node_instance* instance, vo static snmp_err_t snmp_scalar_array_set_test(struct snmp_node_instance* instance, u16_t value_len, void* value); static snmp_err_t snmp_scalar_array_set_value(struct snmp_node_instance* instance, u16_t value_len, void* value); -snmp_err_t +snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { const struct snmp_scalar_node* scalar_node = (const struct snmp_scalar_node*)(const void*)instance->node; @@ -67,7 +67,7 @@ snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_n return SNMP_ERR_NOERROR; } -snmp_err_t +snmp_err_t snmp_scalar_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { /* because our only instance is .0 we can only return a next instance if no instance oid is passed */ @@ -130,7 +130,7 @@ snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, st if ((instance->instance_oid.len == 0) && (array_node->array_node_count > 0)) { /* return node with lowest OID */ u16_t i = 0; - + result = array_node_def; array_node_def++; @@ -142,7 +142,7 @@ snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, st } } else if (instance->instance_oid.len >= 1) { if (instance->instance_oid.len == 1) { - /* if we have the requested OID we return its instance, otherwise we search for the next available */ + /* if we have the requested OID we return its instance, otherwise we search for the next available */ u16_t i = 0; while (i < array_node->array_node_count) { if (array_node_def->oid == instance->instance_oid.id[0]) { @@ -179,7 +179,7 @@ snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, st instance->instance_oid.len = 2; instance->instance_oid.id[0] = result->oid; instance->instance_oid.id[1] = 0; - + instance->access = result->access; instance->asn1_type = result->asn1_type; instance->get_value = snmp_scalar_array_get_value; diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_table.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_table.c index 63ca595633..ef5612ca28 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_table.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_table.c @@ -61,7 +61,7 @@ snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, str if (col_def->index == instance->instance_oid.id[1]) { break; } - + col_def++; i--; } @@ -212,13 +212,13 @@ snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_l default: LWIP_DEBUGF(SNMP_DEBUG, ("snmp_table_simple_get_instance(): unknown column data_type: %d\n", col_def->data_type)); return SNMP_ERR_GENERROR; - } + } ret = SNMP_ERR_NOERROR; } else { ret = SNMP_ERR_NOSUCHINSTANCE; } - } + } } return ret; diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_threadsync.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_threadsync.c index 204f265dc8..b0ee89d3dc 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_threadsync.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_threadsync.c @@ -40,7 +40,7 @@ #include "lwip/apps/snmp_core.h" #include "lwip/sys.h" #include - + static void call_synced_function(struct threadsync_data *call_data, snmp_threadsync_called_fn fn) { @@ -111,7 +111,7 @@ threadsync_set_value(struct snmp_node_instance* instance, u16_t len, void *value call_data->arg1.value = value; call_data->arg2.len = len; call_synced_function(call_data, threadsync_set_value_synced); - + return call_data->retval.err; } @@ -119,7 +119,7 @@ static void threadsync_release_instance_synced(void* ctx) { struct threadsync_data *call_data = (struct threadsync_data*)ctx; - + call_data->proxy_instance.release_instance(&call_data->proxy_instance); sys_sem_signal(&call_data->threadsync_node->instance->sem); @@ -129,7 +129,7 @@ static void threadsync_release_instance(struct snmp_node_instance *instance) { struct threadsync_data *call_data = (struct threadsync_data*)instance->reference.ptr; - + if (call_data->proxy_instance.release_instance != NULL) { call_synced_function(call_data, threadsync_release_instance_synced); } diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmp_traps.c b/components/net/lwip-2.0.2/src/apps/snmp/snmp_traps.c index 0d2df64991..2135a6478a 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmp_traps.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmp_traps.c @@ -228,7 +228,7 @@ snmp_send_trap(const struct snmp_obj_id* eoid, s32_t generic_trap, s32_t specifi * @ingroup snmp_traps * Send generic SNMP trap */ -err_t +err_t snmp_send_trap_generic(s32_t generic_trap) { static const struct snmp_obj_id oid = { 7, { 1, 3, 6, 1, 2, 1, 11 } }; @@ -257,7 +257,7 @@ snmp_coldstart_trap(void) /** * @ingroup snmp_traps - * Send authentication failure trap (used internally by agent) + * Send authentication failure trap (used internally by agent) */ void snmp_authfail_trap(void) diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_dummy.c b/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_dummy.c index bdfe844994..f2268f1d3c 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_dummy.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_dummy.c @@ -52,17 +52,17 @@ snmpv3_get_user(const char* username, u8_t *auth_algo, u8_t *auth_key, u8_t *pri { const char* engine_id; u8_t engine_id_len; - + if(strlen(username) == 0) { return ERR_OK; } - + if(memcmp(username, "lwip", 4) != 0) { return ERR_VAL; } - + snmpv3_get_engine_id(&engine_id, &engine_id_len); - + if(auth_key != NULL) { snmpv3_password_to_key_sha((const u8_t*)"maplesyrup", 10, (const u8_t*)engine_id, engine_id_len, @@ -105,7 +105,7 @@ snmpv3_set_engine_id(const char *id, u8_t len) /** * Get engine boots from persistence. Must be increased on each boot. - * @return + * @return */ u32_t snmpv3_get_engine_boots(void) @@ -117,7 +117,7 @@ snmpv3_get_engine_boots(void) * Store engine boots in persistence * @param boots */ -void +void snmpv3_set_engine_boots(u32_t boots) { LWIP_UNUSED_ARG(boots); diff --git a/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_mbedtls.c b/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_mbedtls.c index 0b1eefb87e..b48829bae8 100644 --- a/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_mbedtls.c +++ b/components/net/lwip-2.0.2/src/apps/snmp/snmpv3_mbedtls.c @@ -73,7 +73,7 @@ snmpv3_auth(struct snmp_pbuf_stream* stream, u16_t length, if(mbedtls_md_setup(&ctx, md_info, 1) != 0) { return ERR_ARG; } - + if (mbedtls_md_hmac_starts(&ctx, key, key_len) != 0) { goto free_md; } @@ -96,7 +96,7 @@ snmpv3_auth(struct snmp_pbuf_stream* stream, u16_t length, mbedtls_md_free(&ctx); return ERR_OK; - + free_md: mbedtls_md_free(&ctx); return ERR_ARG; @@ -140,7 +140,7 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, goto error; } - /* Prepare IV */ + /* Prepare IV */ for (i = 0; i < LWIP_ARRAYSIZE(iv_local); i++) { iv_local[i] = priv_param[i] ^ key[i + 8]; } @@ -152,7 +152,7 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, size_t j; u8_t in_bytes[8]; out_len = LWIP_ARRAYSIZE(out_bytes) ; - + for (j = 0; j < LWIP_ARRAYSIZE(in_bytes); j++) { snmp_pbuf_stream_read(&read_stream, &in_bytes[j]); } @@ -163,7 +163,7 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, snmp_pbuf_stream_writebuf(&write_stream, out_bytes, out_len); } - + out_len = LWIP_ARRAYSIZE(out_bytes); if(mbedtls_cipher_finish(&ctx, out_bytes, &out_len) != 0) { goto error; @@ -201,7 +201,7 @@ snmpv3_crypt(struct snmp_pbuf_stream* stream, u16_t length, u8_t in_byte; u8_t out_byte; size_t out_len = sizeof(out_byte); - + snmp_pbuf_stream_read(&read_stream, &in_byte); if(mbedtls_cipher_update(&ctx, &in_byte, sizeof(in_byte), &out_byte, &out_len) != 0) { goto error; @@ -223,7 +223,7 @@ error: #endif /* LWIP_SNMP_V3_CRYPTO */ /* A.2.1. Password to Key Sample Code for MD5 */ -void +void snmpv3_password_to_key_md5( const u8_t *password, /* IN */ u8_t passwordlen, /* IN */ @@ -276,7 +276,7 @@ snmpv3_password_to_key_md5( } /* A.2.2. Password to Key Sample Code for SHA */ -void +void snmpv3_password_to_key_sha( const u8_t *password, /* IN */ u8_t passwordlen, /* IN */ @@ -323,7 +323,7 @@ snmpv3_password_to_key_sha( mbedtls_sha1_starts(&SH); mbedtls_sha1_update(&SH, password_buf, 40 + engineLength); mbedtls_sha1_finish(&SH, key); - + mbedtls_sha1_free(&SH); return; } diff --git a/components/net/lwip-2.0.2/src/apps/tftp/tftp_server.c b/components/net/lwip-2.0.2/src/apps/tftp/tftp_server.c index afaa3bb08d..a4c74f99e4 100644 --- a/components/net/lwip-2.0.2/src/apps/tftp/tftp_server.c +++ b/components/net/lwip-2.0.2/src/apps/tftp/tftp_server.c @@ -12,7 +12,7 @@ * ********************************************************************/ -/* +/* * Redistribution and use in source and binary forms, with or without * modification,are permitted provided that the following conditions are met: * @@ -106,7 +106,7 @@ close_handle(void) } sys_untimeout(tftp_tmr, NULL); - + if (tftp_state.handle) { tftp_state.ctx->close(tftp_state.handle); tftp_state.handle = NULL; @@ -120,7 +120,7 @@ send_error(const ip_addr_t *addr, u16_t port, enum tftp_error code, const char * int str_length = strlen(str); struct pbuf* p; u16_t* payload; - + p = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(TFTP_HEADER_LENGTH + str_length + 1), PBUF_RAM); if(p == NULL) { return; @@ -140,13 +140,13 @@ send_ack(u16_t blknum) { struct pbuf* p; u16_t* payload; - + p = pbuf_alloc(PBUF_TRANSPORT, TFTP_HEADER_LENGTH, PBUF_RAM); if(p == NULL) { return; } payload = (u16_t*) p->payload; - + payload[0] = PP_HTONS(TFTP_ACK); payload[1] = lwip_htons(blknum); udp_sendto(tftp_state.upcb, p, &tftp_state.addr, tftp_state.port); @@ -165,7 +165,7 @@ resend_data(void) pbuf_free(p); return; } - + udp_sendto(tftp_state.upcb, p, &tftp_state.addr, tftp_state.port); pbuf_free(p); } @@ -179,7 +179,7 @@ send_data(void) if(tftp_state.last_data != NULL) { pbuf_free(tftp_state.last_data); } - + tftp_state.last_data = pbuf_alloc(PBUF_TRANSPORT, TFTP_HEADER_LENGTH + TFTP_MAX_PAYLOAD_SIZE, PBUF_RAM); if(tftp_state.last_data == NULL) { return; @@ -208,7 +208,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 LWIP_UNUSED_ARG(arg); LWIP_UNUSED_ARG(upcb); - + if (((tftp_state.port != 0) && (port != tftp_state.port)) || (!ip_addr_isany_val(tftp_state.addr) && !ip_addr_cmp(&tftp_state.addr, addr))) { send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "Only one connection at a time is supported"); @@ -235,7 +235,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "Only one connection at a time is supported"); break; } - + sys_timeout(TFTP_TIMER_MSECS, tftp_tmr, NULL); /* find \0 in pbuf -> end of filename string */ @@ -253,7 +253,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 break; } pbuf_copy_partial(p, mode, mode_end_offset-filename_end_offset, filename_end_offset+1); - + tftp_state.handle = tftp_state.ctx->open(filename, mode, opcode == PP_HTONS(TFTP_WRQ)); tftp_state.blknum = 1; @@ -279,12 +279,12 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 break; } - + case PP_HTONS(TFTP_DATA): { int ret; u16_t blknum; - + if (tftp_state.handle == NULL) { send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "No connection"); break; @@ -348,7 +348,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16 break; } - + default: send_error(addr, port, TFTP_ERROR_ILLEGAL_OPERATION, "Unknown operation"); break; @@ -361,7 +361,7 @@ static void tftp_tmr(void* arg) { LWIP_UNUSED_ARG(arg); - + tftp_state.timer++; if (tftp_state.handle == NULL) { @@ -386,7 +386,7 @@ tftp_tmr(void* arg) * Initialize TFTP server. * @param ctx TFTP callback struct */ -err_t +err_t tftp_init(const struct tftp_context *ctx) { err_t ret; diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h index 51b06f1a7f..e3014f552c 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/cc.h @@ -47,9 +47,9 @@ #if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include -#define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_TIMEVAL_PRIVATE 0 #else -#define LWIP_TIMEVAL_PRIVATE 1 +#define LWIP_TIMEVAL_PRIVATE 1 #endif #if defined(__CC_ARM) /* ARMCC compiler */ @@ -81,14 +81,14 @@ #endif void sys_arch_assert(const char* file, int line); -#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) +#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) #define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0) #include "string.h" -#define SYS_ARCH_DECL_PROTECT(level) -#define SYS_ARCH_PROTECT(level) rt_enter_critical() -#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() +#define SYS_ARCH_DECL_PROTECT(level) +#define SYS_ARCH_PROTECT(level) rt_enter_critical() +#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() #endif /* __ARCH_CC_H__ */ diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/perf.h b/components/net/lwip-2.0.2/src/arch/include/arch/perf.h index 675f1f65dc..4b7720ef40 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/perf.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/perf.h @@ -1,33 +1,33 @@ /* * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * * $Id: perf.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $ @@ -42,8 +42,8 @@ /* void perf_print(unsigned long c1l, unsigned long c1h, - unsigned long c2l, unsigned long c2h, - char *key); + unsigned long c2l, unsigned long c2h, + char *key); void perf_print_times(struct tms *start, struct tms *end, char *key); diff --git a/components/net/lwip-2.0.2/src/arch/include/arch/sys_arch.h b/components/net/lwip-2.0.2/src/arch/include/arch/sys_arch.h index 8637cc9263..f83188407b 100644 --- a/components/net/lwip-2.0.2/src/arch/include/arch/sys_arch.h +++ b/components/net/lwip-2.0.2/src/arch/include/arch/sys_arch.h @@ -1,33 +1,33 @@ /* * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * * $Id: sys_arch.h,v 1.3 2005/03/13 16:03:23 bear Exp $ diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index fbf02cad0a..4d0c57eff9 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (C) 2006-2018, RT-Thread Development Team + * COPYRIGHT (C) 2006-2021, RT-Thread Development Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/components/net/lwip-2.0.2/src/core/def.c b/components/net/lwip-2.0.2/src/core/def.c index 8125313f41..171c5c7d48 100644 --- a/components/net/lwip-2.0.2/src/core/def.c +++ b/components/net/lwip-2.0.2/src/core/def.c @@ -11,7 +11,7 @@ * \#define lwip_htonl(x) your_htonl * * Note lwip_ntohs() and lwip_ntohl() are merely references to the htonx counterparts. - * + * * If you \#define them to htons() and htonl(), you should * \#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS to prevent lwIP from * defining htonx/ntohx compatibility macros. diff --git a/components/net/lwip-2.0.2/src/core/dns.c b/components/net/lwip-2.0.2/src/core/dns.c index cd4de06229..6d5b7e6da3 100644 --- a/components/net/lwip-2.0.2/src/core/dns.c +++ b/components/net/lwip-2.0.2/src/core/dns.c @@ -23,14 +23,14 @@ * Once a hostname has been resolved (or found to be non-existent), * the resolver code calls a specified callback function (which * must be implemented by the module that uses the resolver). - * + * * Multicast DNS queries are supported for names ending on ".local". * However, only "One-Shot Multicast DNS Queries" are supported (RFC 6762 * chapter 5.1), this is not a fully compliant implementation of continuous * mDNS querying! * * All functions must be called from TCPIP thread. - * + * * @see @ref netconn_common for thread-safe access. */ @@ -368,7 +368,7 @@ dns_setserver(u8_t numdns, const ip_addr_t *dnsserver) if (numdns < DNS_MAX_SERVERS) { if (dnsserver != NULL) { dns_servers[numdns] = (*dnsserver); - + #ifdef RT_USING_NETDEV extern struct netif *netif_list; extern struct netdev *netdev_get_by_name(const char *name); diff --git a/components/net/lwip-2.0.2/src/core/inet_chksum.c b/components/net/lwip-2.0.2/src/core/inet_chksum.c index 917f3e4f1a..cc2db13a94 100644 --- a/components/net/lwip-2.0.2/src/core/inet_chksum.c +++ b/components/net/lwip-2.0.2/src/core/inet_chksum.c @@ -8,7 +8,7 @@ * your own version, link it in and in your cc.h put: * * \#define LWIP_CHKSUM your_checksum_routine - * + * * Or you can select from the implementations below by defining * LWIP_CHKSUM_ALGORITHM to 1, 2 or 3. */ diff --git a/components/net/lwip-2.0.2/src/core/init.c b/components/net/lwip-2.0.2/src/core/init.c index 313146133d..8c5a05f6ab 100644 --- a/components/net/lwip-2.0.2/src/core/init.c +++ b/components/net/lwip-2.0.2/src/core/init.c @@ -378,7 +378,7 @@ lwip_init(void) #if PPP_SUPPORT ppp_init(); #endif - + #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ diff --git a/components/net/lwip-2.0.2/src/core/ip.c b/components/net/lwip-2.0.2/src/core/ip.c index 2e0240851f..804799470a 100644 --- a/components/net/lwip-2.0.2/src/core/ip.c +++ b/components/net/lwip-2.0.2/src/core/ip.c @@ -4,19 +4,19 @@ * * @defgroup ip IP * @ingroup callbackstyle_api - * + * * @defgroup ip4 IPv4 * @ingroup ip * * @defgroup ip6 IPv6 * @ingroup ip - * + * * @defgroup ipaddr IP address handling * @ingroup infrastructure - * + * * @defgroup ip4addr IPv4 only * @ingroup ipaddr - * + * * @defgroup ip6addr IPv6 only * @ingroup ipaddr */ diff --git a/components/net/lwip-2.0.2/src/core/ipv4/autoip.c b/components/net/lwip-2.0.2/src/core/ipv4/autoip.c index 10db8a3444..79d7615bba 100644 --- a/components/net/lwip-2.0.2/src/core/ipv4/autoip.c +++ b/components/net/lwip-2.0.2/src/core/ipv4/autoip.c @@ -22,7 +22,7 @@ * With DHCP: * - define @ref LWIP_DHCP_AUTOIP_COOP 1 in your lwipopts.h. * - Configure your DHCP Client. - * + * * @see netifapi_autoip */ @@ -95,7 +95,7 @@ static err_t autoip_arp_announce(struct netif *netif); static void autoip_start_probing(struct netif *netif); /** - * @ingroup autoip + * @ingroup autoip * Set a statically allocated struct autoip to work with. * Using this prevents autoip_start to allocate it using mem_malloc. * @@ -245,7 +245,7 @@ autoip_bind(struct netif *netif) } /** - * @ingroup autoip + * @ingroup autoip * Start AutoIP client * * @param netif network interface on which start the AutoIP client @@ -339,7 +339,7 @@ autoip_network_changed(struct netif *netif) } /** - * @ingroup autoip + * @ingroup autoip * Stop AutoIP client * * @param netif network interface on which stop the AutoIP client diff --git a/components/net/lwip-2.0.2/src/core/ipv4/igmp.c b/components/net/lwip-2.0.2/src/core/ipv4/igmp.c index 74a6c37731..57ddc75fbd 100644 --- a/components/net/lwip-2.0.2/src/core/ipv4/igmp.c +++ b/components/net/lwip-2.0.2/src/core/ipv4/igmp.c @@ -199,7 +199,7 @@ igmp_report_groups(struct netif *netif) if(group != NULL) { group = group->next; } - + while (group != NULL) { igmp_delaying_member(group, IGMP_JOIN_DELAYING_MEMBER_TMR); group = group->next; @@ -252,7 +252,7 @@ igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr) /* Group already exists. */ return group; } - + /* Group doesn't exist yet, create a new one */ group = (struct igmp_group *)memp_malloc(MEMP_IGMP_GROUP); if (group != NULL) { @@ -262,7 +262,7 @@ igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr) group->last_reporter_flag = 0; group->use = 0; - /* Ensure allsystems group is always first in list */ + /* Ensure allsystems group is always first in list */ if (list_head == NULL) { /* this is the first entry in linked list */ LWIP_ASSERT("igmp_lookup_group: first group must be allsystems", @@ -379,7 +379,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest) } groupref = netif_igmp_data(inp); - + /* Do not send messages on the all systems group address! */ /* Skip the first group in the list, it is always the allsystems group added in igmp_start() */ if(groupref != NULL) { @@ -674,7 +674,7 @@ igmp_timeout(struct netif *netif, struct igmp_group *group) LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)netif)); group->group_state = IGMP_GROUP_IDLE_MEMBER; - + IGMP_STATS_INC(igmp.tx_report); igmp_send(netif, group, IGMP_V2_MEMB_REPORT); } diff --git a/components/net/lwip-2.0.2/src/core/ipv6/nd6.c b/components/net/lwip-2.0.2/src/core/ipv6/nd6.c index 0b367181b2..22078ea776 100644 --- a/components/net/lwip-2.0.2/src/core/ipv6/nd6.c +++ b/components/net/lwip-2.0.2/src/core/ipv6/nd6.c @@ -159,7 +159,7 @@ nd6_input(struct pbuf *p, struct netif *inp) /* Unsolicited NA?*/ if (ip6_addr_ismulticast(ip6_current_dest_addr())) { ip6_addr_t target_address; - + /* This is an unsolicited NA. * link-layer changed? * part of DAD mechanism? */ @@ -335,7 +335,7 @@ nd6_input(struct pbuf *p, struct netif *inp) } } else { ip6_addr_t target_address; - + /* Sender is trying to resolve our address. */ /* Verify that they included their own link-layer address. */ if (lladdr_opt == NULL) { @@ -1517,9 +1517,9 @@ nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif) for (router_index = LWIP_ND6_NUM_ROUTERS - 1; router_index >= 0; router_index--) { /* check if router already exists (this is a special case for 2 netifs on the same subnet - e.g. wifi and cable) */ - if(default_router_list[router_index].neighbor_entry == &(neighbor_cache[neighbor_index])){ - return router_index; - } + if(default_router_list[router_index].neighbor_entry == &(neighbor_cache[neighbor_index])){ + return router_index; + } if (default_router_list[router_index].neighbor_entry == NULL) { /* remember lowest free index to create a new entry */ free_router_index = router_index; diff --git a/components/net/lwip-2.0.2/src/core/netif.c b/components/net/lwip-2.0.2/src/core/netif.c index ee57bb9a9d..89c0a678b9 100644 --- a/components/net/lwip-2.0.2/src/core/netif.c +++ b/components/net/lwip-2.0.2/src/core/netif.c @@ -1,16 +1,16 @@ /** * @file * lwIP network interface abstraction - * + * * @defgroup netif Network interface (NETIF) * @ingroup callbackstyle_api - * + * * @defgroup netif_ip4 IPv4 address handling * @ingroup netif - * + * * @defgroup netif_ip6 IPv6 address handling * @ingroup netif - * + * * @defgroup netif_cd Client data handling * Store data (void*) on a netif for application usage. * @see @ref LWIP_NUM_NETIF_CLIENT_DATA @@ -203,7 +203,7 @@ netif_init(void) * ethernet_input() or ip_input() depending on netif flags. * Don't call directly, pass to netif_add() and call * netif->input(). - * Only works if the netif driver correctly sets + * Only works if the netif driver correctly sets * NETIF_FLAG_ETHARP and/or NETIF_FLAG_ETHERNET flag! */ err_t @@ -236,12 +236,12 @@ netif_input(struct pbuf *p, struct netif *inp) * to decide whether to forward to ethernet_input() or ip_input(). * In other words, the functions only work when the netif * driver is implemented correctly!\n - * Most members of struct netif should be be initialized by the + * Most members of struct netif should be be initialized by the * netif init function = netif driver (init parameter of this function).\n * IPv6: Don't forget to call netif_create_ip6_linklocal_address() after * setting the MAC address in struct netif.hwaddr * (IPv6 requires a link-local address). - * + * * @return netif, or NULL if failed. */ struct netif * diff --git a/components/net/lwip-2.0.2/src/core/pbuf.c b/components/net/lwip-2.0.2/src/core/pbuf.c index 059f83a571..34b2939bf4 100644 --- a/components/net/lwip-2.0.2/src/core/pbuf.c +++ b/components/net/lwip-2.0.2/src/core/pbuf.c @@ -62,7 +62,7 @@ void eth_rx_irq() my_pbuf->dma_descriptor = dma_desc; invalidate_cpu_cache(dma_desc->rx_data, dma_desc->rx_length); - + struct pbuf* p = pbuf_alloced_custom(PBUF_RAW, dma_desc->rx_length, PBUF_REF, @@ -352,12 +352,12 @@ pbuf_alloc(pbuf_layer layer, u16_t length, pbuf_type type) case PBUF_RAM: { mem_size_t alloc_len = LWIP_MEM_ALIGN_SIZE(SIZEOF_STRUCT_PBUF + offset) + LWIP_MEM_ALIGN_SIZE(length); - + /* bug #50040: Check for integer overflow when calculating alloc_len */ if (alloc_len < LWIP_MEM_ALIGN_SIZE(length)) { return NULL; } - + /* If pbuf is to be allocated in RAM, allocate memory for it. */ p = (struct pbuf*)mem_malloc(alloc_len); } @@ -1364,18 +1364,18 @@ pbuf_memcmp(const struct pbuf* p, u16_t offset, const void* s2, u16_t n) u16_t start = offset; const struct pbuf* q = p; u16_t i; - + /* pbuf long enough to perform check? */ if(p->tot_len < (offset + n)) { return 0xffff; } - + /* get the correct pbuf from chain. We know it succeeds because of p->tot_len check above. */ while ((q != NULL) && (q->len <= start)) { start -= q->len; q = q->next; } - + /* return requested data if pbuf is OK */ for (i = 0; i < n; i++) { /* We know pbuf_get_at() succeeds because of p->tot_len check above. */ diff --git a/components/net/lwip-2.0.2/src/core/raw.c b/components/net/lwip-2.0.2/src/core/raw.c index 80cf9ec64b..45b559db43 100644 --- a/components/net/lwip-2.0.2/src/core/raw.c +++ b/components/net/lwip-2.0.2/src/core/raw.c @@ -4,7 +4,7 @@ * different types of protocols besides (or overriding) those * already available in lwIP.\n * See also @ref raw_raw - * + * * @defgroup raw_raw RAW * @ingroup callbackstyle_api * Implementation of raw protocol PCBs for low-level handling of diff --git a/components/net/lwip-2.0.2/src/core/tcp.c b/components/net/lwip-2.0.2/src/core/tcp.c index ec2e1f92ce..a30dc23581 100644 --- a/components/net/lwip-2.0.2/src/core/tcp.c +++ b/components/net/lwip-2.0.2/src/core/tcp.c @@ -1,5 +1,5 @@ /** - * @file + * @file * Transmission Control Protocol for IP * See also @ref tcp_raw * @@ -1743,7 +1743,7 @@ tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) * has occurred on the connection. * * @note The corresponding pcb is already freed when this callback is called! - * + * * @param pcb tcp_pcb to set the err callback * @param err callback function to call for this pcb when a fatal error * has occurred on the connection diff --git a/components/net/lwip-2.0.2/src/core/udp.c b/components/net/lwip-2.0.2/src/core/udp.c index ce2e3d295f..0cbf25edaa 100644 --- a/components/net/lwip-2.0.2/src/core/udp.c +++ b/components/net/lwip-2.0.2/src/core/udp.c @@ -3,7 +3,7 @@ * User Datagram Protocol module\n * The code for the User Datagram Protocol UDP & UDPLite (RFC 3828).\n * See also @ref udp_raw - * + * * @defgroup udp_raw UDP * @ingroup callbackstyle_api * User Datagram Protocol module\n diff --git a/components/net/lwip-2.0.2/src/include/lwip/api.h b/components/net/lwip-2.0.2/src/include/lwip/api.h index 516bd163dd..5f37d2ec1f 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/api.h +++ b/components/net/lwip-2.0.2/src/include/lwip/api.h @@ -140,27 +140,27 @@ enum netconn_state { }; /** Used to inform the callback function about changes - * + * * Event explanation: - * + * * In the netconn implementation, there are three ways to block a client: - * + * * - accept mbox (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, 0); in netconn_accept()) * - receive mbox (sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); in netconn_recv_data()) * - send queue is full (sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0); in lwip_netconn_do_write()) - * + * * The events have to be seen as events signaling the state of these mboxes/semaphores. For non-blocking * connections, you need to know in advance whether a call to a netconn function call would block or not, * and these events tell you about that. - * - * RCVPLUS events say: Safe to perform a potentially blocking call call once more. + * + * RCVPLUS events say: Safe to perform a potentially blocking call call once more. * They are counted in sockets - three RCVPLUS events for accept mbox means you are safe * to call netconn_accept 3 times without being blocked. * Same thing for receive mbox. - * + * * RCVMINUS events say: Your call to to a possibly blocking function is "acknowledged". * Socket implementation decrements the counter. - * + * * For TX, there is no need to count, its merely a flag. SENDPLUS means you may send something. * SENDPLUS occurs when enough data was delivered to peer so netconn_send() can be called again. * A SENDMINUS event occurs when the next call to a netconn_send() would be blocking. diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/fs.h b/components/net/lwip-2.0.2/src/include/lwip/apps/fs.h index bb176fa010..a06d4c977c 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/fs.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/fs.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/httpd.h b/components/net/lwip-2.0.2/src/include/lwip/apps/httpd.h index 40f1811e57..35a01e29d6 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/httpd.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/httpd.h @@ -102,7 +102,7 @@ void http_set_cgi_handlers(const tCGI *pCGIs, int iNumHandlers); #if LWIP_HTTPD_CGI_SSI /** Define this generic CGI handler in your application. * It is called once for every URI with parameters. - * The parameters can be stored to + * The parameters can be stored to */ extern void httpd_cgi_handler(const char* uri, int iNumParams, char **pcParam, char **pcValue #if defined(LWIP_HTTPD_FILE_STATE) && LWIP_HTTPD_FILE_STATE diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/httpd_opts.h b/components/net/lwip-2.0.2/src/include/lwip/apps/httpd_opts.h index 340db15f66..cbe493c848 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/httpd_opts.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/httpd_opts.h @@ -120,7 +120,7 @@ #define HTTPD_DEBUG LWIP_DBG_OFF #endif -/** Set this to 1 to use a memp pool for allocating +/** Set this to 1 to use a memp pool for allocating * struct http_state instead of the heap. */ #if !defined HTTPD_USE_MEM_POOL || defined __DOXYGEN__ diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt.h b/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt.h index 34b230b888..3adeb0510b 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt.h @@ -110,7 +110,7 @@ enum { MQTT_DATA_FLAG_LAST = 1 }; -/** +/** * @ingroup mqtt * Function prototype for MQTT incoming publish data callback function. Called when data * arrives to a subscribed topic @see mqtt_subscribe @@ -125,7 +125,7 @@ enum { typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags); -/** +/** * @ingroup mqtt * Function prototype for MQTT incoming publish function. Called when an incoming publish * arrives to a subscribed topic @see mqtt_subscribe diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt_opts.h b/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt_opts.h index ffefacd259..90eef1555d 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt_opts.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/mqtt_opts.h @@ -39,7 +39,7 @@ #include "lwip/opt.h" -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/snmp_core.h b/components/net/lwip-2.0.2/src/include/lwip/apps/snmp_core.h index e781c532b3..d20a988365 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/snmp_core.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/snmp_core.h @@ -99,7 +99,7 @@ extern "C" { /** error codes predefined by SNMP prot. */ typedef enum { SNMP_ERR_NOERROR = 0, -/* +/* outdated v1 error codes. do not use anmore! #define SNMP_ERR_NOSUCHNAME 2 use SNMP_ERR_NOSUCHINSTANCE instead #define SNMP_ERR_BADVALUE 3 use SNMP_ERR_WRONGTYPE,SNMP_ERR_WRONGLENGTH,SNMP_ERR_WRONGENCODING or SNMP_ERR_WRONGVALUE instead diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_opts.h b/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_opts.h index 6968a803b4..357eb2e63c 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_opts.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_opts.h @@ -11,7 +11,7 @@ * ********************************************************************/ -/* +/* * Redistribution and use in source and binary forms, with or without * modification,are permitted provided that the following conditions are met: * diff --git a/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_server.h b/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_server.h index 3fbe701e0a..387162da8e 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_server.h +++ b/components/net/lwip-2.0.2/src/include/lwip/apps/tftp_server.h @@ -11,7 +11,7 @@ * ********************************************************************/ -/* +/* * Redistribution and use in source and binary forms, with or without * modification,are permitted provided that the following conditions are met: * @@ -67,7 +67,7 @@ struct tftp_context { */ void (*close)(void* handle); /** - * Read from file + * Read from file * @param handle File handle returned by open() * @param buf Target buffer to copy read data to * @param bytes Number of bytes to copy to buf diff --git a/components/net/lwip-2.0.2/src/include/lwip/arch.h b/components/net/lwip-2.0.2/src/include/lwip/arch.h index 42f47778ae..f468ce8b2b 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/arch.h +++ b/components/net/lwip-2.0.2/src/include/lwip/arch.h @@ -72,7 +72,7 @@ /** Platform specific diagnostic output.\n * Note the default implementation pulls in printf, which may - * in turn pull in a lot of standard libary code. In resource-constrained + * in turn pull in a lot of standard libary code. In resource-constrained * systems, this should be defined to something less resource-consuming. */ #ifndef LWIP_PLATFORM_DIAG @@ -83,7 +83,7 @@ /** Platform specific assertion handling.\n * Note the default implementation pulls in printf, fflush and abort, which may - * in turn pull in a lot of standard libary code. In resource-constrained + * in turn pull in a lot of standard libary code. In resource-constrained * systems, this should be defined to something less resource-consuming. */ #ifndef LWIP_PLATFORM_ASSERT diff --git a/components/net/lwip-2.0.2/src/include/lwip/igmp.h b/components/net/lwip-2.0.2/src/include/lwip/igmp.h index ffd80e680c..0a16db0397 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/igmp.h +++ b/components/net/lwip-2.0.2/src/include/lwip/igmp.h @@ -99,7 +99,7 @@ err_t igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr); err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr); void igmp_tmr(void); -/** @ingroup igmp +/** @ingroup igmp * Get list head of IGMP groups for netif. * Note: The allsystems group IP is contained in the list as first entry. * @see @ref netif_set_igmp_mac_filter() diff --git a/components/net/lwip-2.0.2/src/include/lwip/ip_addr.h b/components/net/lwip-2.0.2/src/include/lwip/ip_addr.h index 11f65d25bd..07571af12a 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/ip_addr.h +++ b/components/net/lwip-2.0.2/src/include/lwip/ip_addr.h @@ -373,7 +373,7 @@ extern const ip_addr_t ip_addr_broadcast; extern const ip_addr_t ip6_addr_any; -/** +/** * @ingroup ip6addr * IP6_ADDR_ANY can be used as a fixed ip_addr_t * for the IPv6 wildcard address diff --git a/components/net/lwip-2.0.2/src/include/lwip/mld6.h b/components/net/lwip-2.0.2/src/include/lwip/mld6.h index 7fa0797f27..2764fdd42d 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/mld6.h +++ b/components/net/lwip-2.0.2/src/include/lwip/mld6.h @@ -84,7 +84,7 @@ err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); /** @ingroup mld6 * Get list head of MLD6 groups for netif. - * Note: The allnodes group IP is NOT in the list, since it must always + * Note: The allnodes group IP is NOT in the list, since it must always * be received for correct IPv6 operation. * @see @ref netif_set_mld_mac_filter() */ diff --git a/components/net/lwip-2.0.2/src/include/lwip/opt.h b/components/net/lwip-2.0.2/src/include/lwip/opt.h index fd459af144..8c46408a3d 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/opt.h +++ b/components/net/lwip-2.0.2/src/include/lwip/opt.h @@ -2564,8 +2564,8 @@ * - src: source eth address * - dst: destination eth address * - eth_type: ethernet type to packet to be sent\n - * - * + * + * * Return values: * - <0: Packet shall not contain VLAN header. * - 0 <= return value <= 0xFFFF: Packet shall contain VLAN header. Return value is prio_vid in host byte order. diff --git a/components/net/lwip-2.0.2/src/include/lwip/prot/ethernet.h b/components/net/lwip-2.0.2/src/include/lwip/prot/ethernet.h index fae4570479..ea7188175d 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/prot/ethernet.h +++ b/components/net/lwip-2.0.2/src/include/lwip/prot/ethernet.h @@ -109,7 +109,7 @@ enum eth_type { /** Internet protocol v4 */ ETHTYPE_IP = 0x0800U, /** Address resolution protocol */ - ETHTYPE_ARP = 0x0806U, + ETHTYPE_ARP = 0x0806U, /** Wake on lan */ ETHTYPE_WOL = 0x0842U, /** RARP */ diff --git a/components/net/lwip-2.0.2/src/include/lwip/prot/ip6.h b/components/net/lwip-2.0.2/src/include/lwip/prot/ip6.h index 6e1e2632bf..6b5641d809 100644 --- a/components/net/lwip-2.0.2/src/include/lwip/prot/ip6.h +++ b/components/net/lwip-2.0.2/src/include/lwip/prot/ip6.h @@ -43,7 +43,7 @@ #ifdef __cplusplus extern "C" { #endif - + /** This is the packed version of ip6_addr_t, used in network headers that are itself packed */ #ifdef PACK_STRUCT_USE_INCLUDES diff --git a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h index 244bafdd1b..09c6d9a56f 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ethernetif.h +++ b/components/net/lwip-2.0.2/src/include/netif/ethernetif.h @@ -4,16 +4,16 @@ #include "lwip/netif.h" #include -#define NIOCTL_GADDR 0x01 +#define NIOCTL_GADDR 0x01 #ifndef RT_LWIP_ETH_MTU -#define ETHERNET_MTU 1500 +#define ETHERNET_MTU 1500 #else -#define ETHERNET_MTU RT_LWIP_ETH_MTU +#define ETHERNET_MTU RT_LWIP_ETH_MTU #endif /* eth flag with auto_linkup or phy_linkup */ -#define ETHIF_LINK_AUTOUP 0x0000 -#define ETHIF_LINK_PHYUP 0x0100 +#define ETHIF_LINK_AUTOUP 0x0000 +#define ETHIF_LINK_PHYUP 0x0100 struct eth_device { diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/ccp.h b/components/net/lwip-2.0.2/src/include/netif/ppp/ccp.h index 14dd65962c..1e4e602052 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/ccp.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/ccp.h @@ -40,48 +40,48 @@ * 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 +#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 +#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_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 +#define CCP_OPT_CODE(dp) ((dp)[0]) +#define CCP_OPT_LENGTH(dp) ((dp)[1]) +#define CCP_OPT_MINLEN 2 #if BSDCOMPRESS_SUPPORT /* * Definitions for BSD-Compress. */ -#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */ -#define CILEN_BSD_COMPRESS 3 /* length of config. option */ +#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_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 */ +#define BSD_MIN_BITS 9 /* smallest code size supported */ +#define BSD_MAX_BITS 15 /* largest code size supported */ #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT @@ -89,17 +89,17 @@ * 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 9 -#define DEFLATE_MAX_SIZE 15 -#define DEFLATE_METHOD_VAL 8 -#define DEFLATE_SIZE(x) (((x) >> 4) + 8) -#define DEFLATE_METHOD(x) ((x) & 0x0F) -#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) -#define DEFLATE_CHK_SEQUENCE 0 +#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 9 +#define DEFLATE_MAX_SIZE 15 +#define DEFLATE_METHOD_VAL 8 +#define DEFLATE_SIZE(x) (((x) >> 4) + 8) +#define DEFLATE_METHOD(x) ((x) & 0x0F) +#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) +#define DEFLATE_CHK_SEQUENCE 0 #endif /* DEFLATE_SUPPORT */ #if MPPE_SUPPORT @@ -116,10 +116,10 @@ * 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 */ +#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 /* PREDICTOR_SUPPORT */ typedef struct ccp_options { @@ -137,15 +137,15 @@ typedef struct ccp_options { #endif /* PREDICTOR_SUPPORT */ #if MPPE_SUPPORT - u8_t mppe; /* MPPE bitfield */ + u8_t mppe; /* MPPE bitfield */ #endif /* MPPE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - u_short bsd_bits; /* # bits/code for BSD Compress */ + u_short bsd_bits; /* # bits/code for BSD Compress */ #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT - u_short deflate_size; /* lg(window size) for Deflate */ + u_short deflate_size; /* lg(window size) for Deflate */ #endif /* DEFLATE_SUPPORT */ - u8_t method; /* code for chosen compression method */ + u8_t method; /* code for chosen compression method */ } ccp_options; extern const struct protent ccp_protent; diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/chap-new.h b/components/net/lwip-2.0.2/src/include/netif/ppp/chap-new.h index 64eae32202..6a37c8e6ff 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/chap-new.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/chap-new.h @@ -39,45 +39,45 @@ /* * CHAP packets begin with a standard header with code, id, len (2 bytes). */ -#define CHAP_HDRLEN 4 +#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 +#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_MD5 5 #if MSCHAP_SUPPORT -#define CHAP_MICROSOFT 0x80 -#define CHAP_MICROSOFT_V2 0x81 +#define CHAP_MICROSOFT 0x80 +#define CHAP_MICROSOFT_V2 0x81 #endif /* MSCHAP_SUPPORT */ /* * Semi-arbitrary limits on challenge and response fields. */ -#define MAX_CHALLENGE_LEN 64 -#define MAX_RESPONSE_LEN 64 +#define MAX_CHALLENGE_LEN 64 +#define MAX_RESPONSE_LEN 64 /* * 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) +#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) /* bitmask of supported algorithms */ #if MSCHAP_SUPPORT -#define MDTYPE_MICROSOFT_V2 0x1 -#define MDTYPE_MICROSOFT 0x2 +#define MDTYPE_MICROSOFT_V2 0x1 +#define MDTYPE_MICROSOFT 0x2 #endif /* MSCHAP_SUPPORT */ -#define MDTYPE_MD5 0x4 -#define MDTYPE_NONE 0 +#define MDTYPE_MD5 0x4 +#define MDTYPE_NONE 0 #if MSCHAP_SUPPORT /* Return the digest alg. ID for the most preferred digest type. */ @@ -125,24 +125,24 @@ * The code for each digest type has to supply one of these. */ struct chap_digest_type { - int code; + int code; #if PPP_SERVER - /* - * Note: challenge and response arguments below are formatted as - * a length byte followed by the actual challenge/response data. - */ - void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge); - int (*verify_response)(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space); + /* + * Note: challenge and response arguments below are formatted as + * a length byte followed by the actual challenge/response data. + */ + void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge); + int (*verify_response)(ppp_pcb *pcb, int id, const char *name, + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space); #endif /* PPP_SERVER */ - void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *priv); - int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); - void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); + void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *priv); + int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); + void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); }; /* @@ -150,21 +150,21 @@ struct chap_digest_type { */ #if CHAP_SUPPORT typedef struct chap_client_state { - u8_t flags; - const char *name; - const struct chap_digest_type *digest; - unsigned char priv[64]; /* private area for digest's use */ + u8_t flags; + const char *name; + const struct chap_digest_type *digest; + unsigned char priv[64]; /* private area for digest's use */ } chap_client_state; #if PPP_SERVER typedef struct chap_server_state { - u8_t flags; - u8_t id; - const char *name; - const struct chap_digest_type *digest; - int challenge_xmits; - int challenge_pktlen; - unsigned char challenge[CHAL_MAX_PKTLEN]; + u8_t flags; + u8_t id; + const char *name; + const struct chap_digest_type *digest; + int challenge_xmits; + int challenge_pktlen; + unsigned char challenge[CHAL_MAX_PKTLEN]; } chap_server_state; #endif /* PPP_SERVER */ #endif /* CHAP_SUPPORT */ @@ -172,9 +172,9 @@ typedef struct chap_server_state { #if 0 /* UNUSED */ /* Hook for a plugin to validate CHAP challenge */ extern int (*chap_verify_hook)(char *name, char *ourname, int id, - const struct chap_digest_type *digest, - unsigned char *challenge, unsigned char *response, - char *message, int message_space); + const struct chap_digest_type *digest, + unsigned char *challenge, unsigned char *response, + char *message, int message_space); #endif /* UNUSED */ #if PPP_SERVER diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/eap.h b/components/net/lwip-2.0.2/src/include/netif/ppp/eap.h index 3ee9aaf81a..491e52ab11 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/eap.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/eap.h @@ -24,135 +24,135 @@ #if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef PPP_EAP_H -#define PPP_EAP_H +#define PPP_EAP_H #include "ppp.h" -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif /* * Packet header = Code, id, length. */ -#define EAP_HEADERLEN 4 +#define EAP_HEADERLEN 4 /* EAP message codes. */ -#define EAP_REQUEST 1 -#define EAP_RESPONSE 2 -#define EAP_SUCCESS 3 -#define EAP_FAILURE 4 +#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 */ +#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 */ +#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 EAP_MIN_CHALLENGE_LENGTH 17 -#define EAP_MAX_CHALLENGE_LENGTH 24 +#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 EAP_MIN_CHALLENGE_LENGTH 17 +#define EAP_MAX_CHALLENGE_LENGTH 24 #define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */ -#define EAP_STATES \ - "Initial", "Pending", "Closed", "Listen", "Identify", \ - "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth" +#define EAP_STATES \ + "Initial", "Pending", "Closed", "Listen", "Identify", \ + "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth" -#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen) +#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen) #if PPP_SERVER -#define eap_server_active(pcb) \ - ((pcb)->eap.es_server.ea_state >= eapIdentify && \ - (pcb)->eap.es_server.ea_state <= eapMD5Chall) +#define eap_server_active(pcb) \ + ((pcb)->eap.es_server.ea_state >= eapIdentify && \ + (pcb)->eap.es_server.ea_state <= eapMD5Chall) #endif /* PPP_SERVER */ /* * Complete EAP state for one PPP session. */ 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 */ + 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 */ }; struct eap_auth { - const char *ea_name; /* Our name */ - char ea_peer[MAXNAMELEN +1]; /* Peer's name */ - void *ea_session; /* Authentication library linkage */ - u_char *ea_skey; /* Shared encryption key */ - 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_* */ - u32_t ea_keyflags; /* SRP shared key usage flags */ + const char *ea_name; /* Our name */ + char ea_peer[MAXNAMELEN +1]; /* Peer's name */ + void *ea_session; /* Authentication library linkage */ + u_char *ea_skey; /* Shared encryption key */ + 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_* */ + u32_t ea_keyflags; /* SRP shared key usage flags */ }; #ifndef EAP_MAX_CHALLENGE_LENGTH -#define EAP_MAX_CHALLENGE_LENGTH 24 +#define EAP_MAX_CHALLENGE_LENGTH 24 #endif typedef struct eap_state { - struct eap_auth es_client; /* Client (authenticatee) data */ + struct eap_auth es_client; /* Client (authenticatee) data */ #if PPP_SERVER - struct eap_auth es_server; /* Server (authenticator) data */ + struct eap_auth es_server; /* Server (authenticator) data */ #endif /* PPP_SERVER */ - int es_savedtime; /* Saved timeout */ - int es_rechallenge; /* EAP rechallenge interval */ - int es_lwrechallenge; /* SRP lightweight rechallenge inter */ - u8_t 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[EAP_MAX_CHALLENGE_LENGTH]; + int es_savedtime; /* Saved timeout */ + int es_rechallenge; /* EAP rechallenge interval */ + int es_lwrechallenge; /* SRP lightweight rechallenge inter */ + u8_t 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[EAP_MAX_CHALLENGE_LENGTH]; } eap_state; /* * Timeouts. */ #if 0 /* moved to ppp_opts.h */ -#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 */ +#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 */ #endif /* moved to ppp_opts.h */ void eap_authwithpeer(ppp_pcb *pcb, const char *localname); @@ -160,7 +160,7 @@ void eap_authpeer(ppp_pcb *pcb, const char *localname); extern const struct protent eap_protent; -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/ecp.h b/components/net/lwip-2.0.2/src/include/netif/ppp/ecp.h index 5cdce29d5b..d1d43dc683 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/ecp.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/ecp.h @@ -35,8 +35,8 @@ #if PPP_SUPPORT && ECP_SUPPORT /* don't build if not configured for use in lwipopts.h */ typedef struct ecp_options { - bool required; /* Is ECP required? */ - unsigned enctype; /* Encryption type */ + bool required; /* Is ECP required? */ + unsigned enctype; /* Encryption type */ } ecp_options; extern fsm ecp_fsm[]; diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/eui64.h b/components/net/lwip-2.0.2/src/include/netif/ppp/eui64.h index 20ac22eede..69b2b238c0 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/eui64.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/eui64.h @@ -53,42 +53,42 @@ typedef union u32_t e32[2]; } eui64_t; -#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_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_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_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_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_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] = lwip_htonl(l); \ - } while (0) -#define eui64_setlo32(e, l) eui64_set32(e, l) +#define eui64_set32(e, l) do { \ + (e).e32[0] = 0; \ + (e).e32[1] = lwip_htonl(l); \ + } while (0) +#define eui64_setlo32(e, l) eui64_set32(e, l) -char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ +char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ #endif /* EUI64_H */ #endif /* PPP_SUPPORT && PPP_IPV6_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/fsm.h b/components/net/lwip-2.0.2/src/include/netif/ppp/fsm.h index b6915d3b80..9f128beae5 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/fsm.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/fsm.h @@ -46,115 +46,115 @@ #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef FSM_H -#define FSM_H +#define FSM_H #include "ppp.h" /* * Packet header = Code, id, length. */ -#define HEADERLEN 4 +#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 */ +#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 { - ppp_pcb *pcb; /* PPP Interface */ - const struct fsm_callbacks *callbacks; /* Callback routines */ - const char *term_reason; /* Reason for closing protocol */ - u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */ - /* -- This is our only flag, we might use u_int :1 if we have more flags */ - u16_t protocol; /* Data Link Layer Protocol field value */ - u8_t state; /* State */ - u8_t flags; /* Contains option bits */ - u8_t id; /* Current id */ - u8_t reqid; /* Current request id */ - u8_t retransmits; /* Number of retransmissions left */ - u8_t nakloops; /* Number of nak loops since last ack */ - u8_t rnakloops; /* Number of naks received */ - u8_t maxnakloops; /* Maximum number of nak loops tolerated - (necessary because IPCP require a custom large max nak loops value) */ - u8_t term_reason_len; /* Length of term_reason */ + ppp_pcb *pcb; /* PPP Interface */ + const struct fsm_callbacks *callbacks; /* Callback routines */ + const char *term_reason; /* Reason for closing protocol */ + u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */ + /* -- This is our only flag, we might use u_int :1 if we have more flags */ + u16_t protocol; /* Data Link Layer Protocol field value */ + u8_t state; /* State */ + u8_t flags; /* Contains option bits */ + u8_t id; /* Current id */ + u8_t reqid; /* Current request id */ + u8_t retransmits; /* Number of retransmissions left */ + u8_t nakloops; /* Number of nak loops since last ack */ + u8_t rnakloops; /* Number of naks received */ + u8_t maxnakloops; /* Maximum number of nak loops tolerated + (necessary because IPCP require a custom large max nak loops value) */ + u8_t term_reason_len; /* Length of term_reason */ } fsm; typedef struct fsm_callbacks { - void (*resetci) /* Reset our Configuration Information */ - (fsm *); - int (*cilen) /* Length of our Configuration Information */ - (fsm *); - void (*addci) /* Add our Configuration Information */ - (fsm *, u_char *, int *); - int (*ackci) /* ACK our Configuration Information */ - (fsm *, u_char *, int); - int (*nakci) /* NAK our Configuration Information */ - (fsm *, u_char *, int, int); - int (*rejci) /* Reject our Configuration Information */ - (fsm *, u_char *, int); - int (*reqci) /* Request peer's Configuration Information */ - (fsm *, u_char *, int *, int); - void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */ - (fsm *); - void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */ - (fsm *); - void (*starting) /* Called when we want the lower layer */ - (fsm *); - void (*finished) /* Called when we don't want the lower layer */ - (fsm *); - void (*protreject) /* Called when Protocol-Reject received */ - (int); - void (*retransmit) /* Retransmission is necessary */ - (fsm *); - int (*extcode) /* Called when unknown code received */ - (fsm *, int, int, u_char *, int); - const char *proto_name; /* String name for protocol (for messages) */ + void (*resetci) /* Reset our Configuration Information */ + (fsm *); + int (*cilen) /* Length of our Configuration Information */ + (fsm *); + void (*addci) /* Add our Configuration Information */ + (fsm *, u_char *, int *); + int (*ackci) /* ACK our Configuration Information */ + (fsm *, u_char *, int); + int (*nakci) /* NAK our Configuration Information */ + (fsm *, u_char *, int, int); + int (*rejci) /* Reject our Configuration Information */ + (fsm *, u_char *, int); + int (*reqci) /* Request peer's Configuration Information */ + (fsm *, u_char *, int *, int); + void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */ + (fsm *); + void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */ + (fsm *); + void (*starting) /* Called when we want the lower layer */ + (fsm *); + void (*finished) /* Called when we don't want the lower layer */ + (fsm *); + void (*protreject) /* Called when Protocol-Reject received */ + (int); + void (*retransmit) /* Retransmission is necessary */ + (fsm *); + int (*extcode) /* Called when unknown code received */ + (fsm *, int, int, u_char *, int); + const char *proto_name; /* String name for protocol (for messages) */ } fsm_callbacks; /* * Link states. */ -#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */ -#define PPP_FSM_STARTING 1 /* Down, been opened */ -#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */ -#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */ -#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */ -#define PPP_FSM_STOPPING 5 /* Terminating, but open */ -#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */ -#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */ -#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */ -#define PPP_FSM_OPENED 9 /* Connection available */ +#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */ +#define PPP_FSM_STARTING 1 /* Down, been opened */ +#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */ +#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */ +#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */ +#define PPP_FSM_STOPPING 5 /* Terminating, but open */ +#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */ +#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */ +#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */ +#define PPP_FSM_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 */ +#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. */ #if 0 /* moved to ppp_opts.h */ -#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 */ +#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 */ #endif /* moved to ppp_opts.h */ diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/ipcp.h b/components/net/lwip-2.0.2/src/include/netif/ppp/ipcp.h index 45f46b31ff..38d1b6e18b 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/ipcp.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/ipcp.h @@ -46,37 +46,37 @@ #if PPP_SUPPORT && PPP_IPV4_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef IPCP_H -#define IPCP_H +#define IPCP_H /* * Options. */ -#define CI_ADDRS 1 /* IP Addresses */ +#define CI_ADDRS 1 /* IP Addresses */ #if VJ_SUPPORT -#define CI_COMPRESSTYPE 2 /* Compression Type */ +#define CI_COMPRESSTYPE 2 /* Compression Type */ #endif /* VJ_SUPPORT */ -#define CI_ADDR 3 +#define CI_ADDR 3 #if LWIP_DNS -#define CI_MS_DNS1 129 /* Primary DNS value */ +#define CI_MS_DNS1 129 /* Primary DNS value */ #define CI_MS_DNS2 131 /* Secondary DNS value */ #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define CI_MS_WINS1 130 /* Primary WINS value */ -#define CI_MS_WINS2 132 /* Secondary WINS value */ +#define CI_MS_WINS2 132 /* Secondary WINS value */ #endif /* UNUSED - WINS */ #if VJ_SUPPORT -#define MAX_STATES 16 /* from slcompress.h */ +#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, */ +#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*/ +#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*/ #endif /* VJ_SUPPORT */ typedef struct ipcp_options { @@ -102,17 +102,17 @@ typedef struct ipcp_options { unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */ #endif /* LWIP_DNS */ - u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ + u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ #if LWIP_DNS - u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ + u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ + u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ #endif /* UNUSED - WINS */ #if VJ_SUPPORT - u16_t vj_protocol; /* protocol value to use in VJ option */ - u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */ + u16_t vj_protocol; /* protocol value to use in VJ option */ + u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */ #endif /* VJ_SUPPORT */ } ipcp_options; diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/ipv6cp.h b/components/net/lwip-2.0.2/src/include/netif/ppp/ipv6cp.h index 07d1ae3186..e99c80a835 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/ipv6cp.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/ipv6cp.h @@ -73,7 +73,7 @@ between BULL S.A. and INRIA). This software is available with usual "research" terms - with the aim of retain credits of the software. + 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, @@ -142,20 +142,20 @@ #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef IPV6CP_H -#define IPV6CP_H +#define IPV6CP_H #include "eui64.h" /* * Options. */ -#define CI_IFACEID 1 /* Interface Identifier */ +#define CI_IFACEID 1 /* Interface Identifier */ #ifdef IPV6CP_COMP -#define CI_COMPRESSTYPE 2 /* Compression Type */ +#define CI_COMPRESSTYPE 2 /* Compression Type */ #endif /* IPV6CP_COMP */ /* No compression types yet defined. - *#define IPV6CP_COMP 0x004f + *#define IPV6CP_COMP 0x004f */ typedef struct ipv6cp_options { unsigned int neg_ifaceid :1; /* Negotiate interface identifier? */ diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/lcp.h b/components/net/lwip-2.0.2/src/include/netif/ppp/lcp.h index 12e2a05fc9..e1e108d856 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/lcp.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/lcp.h @@ -46,62 +46,62 @@ #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef LCP_H -#define LCP_H +#define LCP_H #include "ppp.h" /* * Options. */ -#define CI_VENDOR 0 /* Vendor Specific */ -#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_FCSALTERN 9 /* FCS-Alternatives */ -#define CI_SDP 10 /* Self-Describing-Pad */ -#define CI_NUMBERED 11 /* Numbered-Mode */ -#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 */ -#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */ -#define CI_LDISC 23 /* Link-Discriminator */ -#define CI_LCPAUTH 24 /* LCP Authentication */ -#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */ -#define CI_PREFELIS 26 /* Prefix Elision */ -#define CI_MPHDRFMT 27 /* MP Header Format */ -#define CI_I18N 28 /* Internationalization */ -#define CI_SDL 29 /* Simple Data Link */ +#define CI_VENDOR 0 /* Vendor Specific */ +#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_FCSALTERN 9 /* FCS-Alternatives */ +#define CI_SDP 10 /* Self-Describing-Pad */ +#define CI_NUMBERED 11 /* Numbered-Mode */ +#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 */ +#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */ +#define CI_LDISC 23 /* Link-Discriminator */ +#define CI_LCPAUTH 24 /* LCP Authentication */ +#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */ +#define CI_PREFELIS 26 /* Prefix Elision */ +#define CI_MPHDRFMT 27 /* MP Header Format */ +#define CI_I18N 28 /* Internationalization */ +#define CI_SDL 29 /* Simple Data Link */ /* * LCP-specific packet types (code numbers). */ -#define PROTREJ 8 /* Protocol Reject */ -#define ECHOREQ 9 /* Echo Request */ -#define ECHOREP 10 /* Echo Reply */ -#define DISCREQ 11 /* Discard Request */ -#define IDENTIF 12 /* Identification */ -#define TIMEREM 13 /* Time Remaining */ +#define PROTREJ 8 /* Protocol Reject */ +#define ECHOREQ 9 /* Echo Request */ +#define ECHOREP 10 /* Echo Reply */ +#define DISCREQ 11 /* Discard Request */ +#define IDENTIF 12 /* Identification */ +#define TIMEREM 13 /* Time Remaining */ /* Value used as data for CI_CALLBACK option */ -#define CBCP_OPT 6 /* Use callback control protocol */ +#define CBCP_OPT 6 /* Use callback control protocol */ #if 0 /* moved to ppp_opts.h */ -#define DEFMRU 1500 /* Try for this */ -#define MINMRU 128 /* No MRUs below this */ -#define MAXMRU 16384 /* Normally limit MRU to this */ +#define DEFMRU 1500 /* Try for this */ +#define MINMRU 128 /* No MRUs below this */ +#define MAXMRU 16384 /* Normally limit MRU to this */ #endif /* moved to ppp_opts.h */ /* An endpoint discriminator, used with multilink. */ -#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */ +#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */ struct epdisc { - unsigned char class_; /* -- The word "class" is reserved in C++. */ - unsigned char length; - unsigned char value[MAX_ENDP_LEN]; + unsigned char class_; /* -- The word "class" is reserved in C++. */ + unsigned char length; + unsigned char value[MAX_ENDP_LEN]; }; /* @@ -137,20 +137,20 @@ typedef struct lcp_options { unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */ unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */ - u16_t mru; /* Value of MRU */ + u16_t mru; /* Value of MRU */ #ifdef HAVE_MULTILINK - u16_t mrru; /* Value of MRRU, and multilink enable */ + u16_t mrru; /* Value of MRRU, and multilink enable */ #endif /* MULTILINK */ #if CHAP_SUPPORT - u8_t chap_mdtype; /* which MD types (hashing algorithm) */ + u8_t chap_mdtype; /* which MD types (hashing algorithm) */ #endif /* CHAP_SUPPORT */ - u32_t asyncmap; /* Value of async map */ + u32_t asyncmap; /* Value of async map */ u32_t magicnumber; - u8_t numloops; /* Number of loops during magic number neg. */ + u8_t numloops; /* Number of loops during magic number neg. */ #if LQR_SUPPORT - u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ + u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ #endif /* LQR_SUPPORT */ - struct epdisc endpoint; /* endpoint discriminator */ + struct epdisc endpoint; /* endpoint discriminator */ } lcp_options; void lcp_open(ppp_pcb *pcb); @@ -164,7 +164,7 @@ extern const struct protent lcp_protent; #if 0 /* moved to ppp_opts.h */ /* Default number of times we receive our magic number from the peer before deciding the link is looped-back. */ -#define DEFLOOPBACKFAIL 10 +#define DEFLOOPBACKFAIL 10 #endif /* moved to ppp_opts.h */ #endif /* LCP_H */ diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/magic.h b/components/net/lwip-2.0.2/src/include/netif/ppp/magic.h index a2a9b530e5..cc581d405c 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/magic.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/magic.h @@ -98,7 +98,7 @@ void magic_randomize(void); /* * Return a new random number. */ -u32_t magic(void); /* Returns the next magic number */ +u32_t magic(void); /* Returns the next magic number */ /* * Fill buffer with random bytes diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/mppe.h b/components/net/lwip-2.0.2/src/include/netif/ppp/mppe.h index 1ae8a5d924..1a3aa01c37 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/mppe.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/mppe.h @@ -41,19 +41,19 @@ #include "netif/ppp/pppcrypt.h" -#define MPPE_PAD 4 /* MPPE growth per frame */ -#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ +#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 */ +#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_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 */ +#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */ /* * This is not nice ... the alternative is a bitfield struct though. @@ -62,70 +62,70 @@ * but then we have to do a lwip_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) */ +#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 */ \ +#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 { \ - const 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; \ +#define MPPE_CI_TO_OPTS(ci, opts) \ + do { \ + const 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) /* Shared MPPE padding between MSCHAP and MPPE */ @@ -148,18 +148,18 @@ static const u8_t mppe_sha1_pad2[SHA1_PAD_SIZE] = { * State for an MPPE (de)compressor. */ typedef struct ppp_mppe_state { - lwip_arc4_context arc4; - u8_t master_key[MPPE_MAX_KEY_LEN]; - u8_t session_key[MPPE_MAX_KEY_LEN]; - u8_t keylen; /* key length in bytes */ - /* NB: 128-bit == 16, 40-bit == 8! - * If we want to support 56-bit, the unit has to change to bits - */ - u8_t bits; /* MPPE control bits */ - u16_t ccount; /* 12-bit coherency count (seqno) */ - u16_t sanity_errors; /* take down LCP if too many */ - unsigned int stateful :1; /* stateful mode flag */ - unsigned int discard :1; /* stateful mode packet loss flag */ + lwip_arc4_context arc4; + u8_t master_key[MPPE_MAX_KEY_LEN]; + u8_t session_key[MPPE_MAX_KEY_LEN]; + u8_t keylen; /* key length in bytes */ + /* NB: 128-bit == 16, 40-bit == 8! + * If we want to support 56-bit, the unit has to change to bits + */ + u8_t bits; /* MPPE control bits */ + u16_t ccount; /* 12-bit coherency count (seqno) */ + u16_t sanity_errors; /* take down LCP if too many */ + unsigned int stateful :1; /* stateful mode flag */ + unsigned int discard :1; /* stateful mode packet loss flag */ } ppp_mppe_state; void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key); diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/arc4.h b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/arc4.h index 4af724cd90..91b08e6779 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/arc4.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/arc4.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/des.h b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/des.h index e893890ed7..5e3a085165 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/des.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/des.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md4.h b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md4.h index 570445687e..a4aa1dcc83 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md4.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md4.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md5.h b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md5.h index 1244011890..4d7b04d8d0 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md5.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/md5.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/sha1.h b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/sha1.h index a4c53e07c5..d8f347c64e 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/sha1.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/polarssl/sha1.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/ppp.h b/components/net/lwip-2.0.2/src/include/netif/ppp/ppp.h index d9ea097efd..5c4c32357f 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/ppp.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/ppp.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -103,8 +103,8 @@ /* * The basic PPP frame. */ -#define PPP_HDRLEN 4 /* octets for standard ppp header */ -#define PPP_FCSLEN 2 /* octets for FCS */ +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ /* * Values for phase. diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/ppp_impl.h b/components/net/lwip-2.0.2/src/include/netif/ppp/ppp_impl.h index 1d4c7742f3..e017af2ceb 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/ppp_impl.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/ppp_impl.h @@ -70,66 +70,66 @@ /* * The basic PPP frame. */ -#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]) +#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]) /* * 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 */ +#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_IP 0x21 /* Internet Protocol */ #if 0 /* UNUSED */ -#define PPP_AT 0x29 /* AppleTalk Protocol */ -#define PPP_IPX 0x2b /* IPX protocol */ +#define PPP_AT 0x29 /* AppleTalk Protocol */ +#define PPP_IPX 0x2b /* IPX protocol */ #endif /* UNUSED */ #if VJ_SUPPORT -#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ -#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ #endif /* VJ_SUPPORT */ #if PPP_IPV6_SUPPORT -#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ +#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ #endif /* PPP_IPV6_SUPPORT */ #if CCP_SUPPORT -#define PPP_COMP 0xfd /* compressed packet */ +#define PPP_COMP 0xfd /* compressed packet */ #endif /* CCP_SUPPORT */ -#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_IPCP 0x8021 /* IP Control Protocol */ #if 0 /* UNUSED */ -#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ -#define PPP_IPXCP 0x802b /* IPX Control Protocol */ +#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ +#define PPP_IPXCP 0x802b /* IPX Control Protocol */ #endif /* UNUSED */ #if PPP_IPV6_SUPPORT -#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ +#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ #endif /* PPP_IPV6_SUPPORT */ #if CCP_SUPPORT -#define PPP_CCP 0x80fd /* Compression Control Protocol */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ #endif /* CCP_SUPPORT */ #if ECP_SUPPORT -#define PPP_ECP 0x8053 /* Encryption Control Protocol */ +#define PPP_ECP 0x8053 /* Encryption Control Protocol */ #endif /* ECP_SUPPORT */ -#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ #if PAP_SUPPORT -#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ #endif /* PAP_SUPPORT */ #if LQR_SUPPORT -#define PPP_LQR 0xc025 /* Link Quality Report protocol */ +#define PPP_LQR 0xc025 /* Link Quality Report protocol */ #endif /* LQR_SUPPORT */ #if CHAP_SUPPORT -#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ +#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ #endif /* CHAP_SUPPORT */ #if CBCP_SUPPORT -#define PPP_CBCP 0xc029 /* Callback Control Protocol */ +#define PPP_CBCP 0xc029 /* Callback Control Protocol */ #endif /* CBCP_SUPPORT */ #if EAP_SUPPORT -#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ +#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ #endif /* EAP_SUPPORT */ /* @@ -161,59 +161,59 @@ struct link_callbacks { * What to do with network protocol (NP) packets. */ 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. */ + 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. */ #if PPP_STATS_SUPPORT -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 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 */ }; #if VJ_SUPPORT struct vjstat { - unsigned int vjs_packets; /* outbound packets */ + 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_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 */ + unsigned int vjs_errorin; /* inbound unknown type packets */ + unsigned int vjs_tossed; /* inbound packets tossed because of error */ }; #endif /* VJ_SUPPORT */ struct ppp_stats { - struct pppstat p; /* basic PPP statistics */ + struct pppstat p; /* basic PPP statistics */ #if VJ_SUPPORT - struct vjstat vj; /* VJ header compression statistics */ + struct vjstat vj; /* VJ header compression statistics */ #endif /* VJ_SUPPORT */ }; #if CCP_SUPPORT 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 */ + 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 */ + struct compstat c; /* packet compression statistics */ + struct compstat d; /* packet decompression statistics */ }; #endif /* CCP_SUPPORT */ @@ -225,37 +225,37 @@ struct ppp_comp_stats { * 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 */ + time_t xmit_idle; /* time since last NP packet sent */ + time_t recv_idle; /* time since last NP packet received */ }; #endif /* PPP_IDLETIMELIMIT */ /* values for epdisc.class */ -#define EPD_NULL 0 /* null discriminator, no data */ -#define EPD_LOCAL 1 -#define EPD_IP 2 -#define EPD_MAC 3 -#define EPD_MAGIC 4 -#define EPD_PHONENUM 5 +#define EPD_NULL 0 /* null discriminator, no data */ +#define EPD_LOCAL 1 +#define EPD_IP 2 +#define EPD_MAC 3 +#define EPD_MAGIC 4 +#define EPD_PHONENUM 5 /* * Global variables. */ #ifdef HAVE_MULTILINK -extern u8_t multilink; /* enable multilink operation */ -extern u8_t doing_multilink; -extern u8_t multilink_master; -extern u8_t bundle_eof; -extern u8_t bundle_terminating; +extern u8_t multilink; /* enable multilink operation */ +extern u8_t doing_multilink; +extern u8_t multilink_master; +extern u8_t bundle_eof; +extern u8_t bundle_terminating; #endif #ifdef MAXOCTETS -extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ +extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ extern int maxoctets_dir; /* Direction : - 0 - in+out (default) - 1 - in - 2 - out - 3 - max(in,out) */ + 0 - in+out (default) + 1 - in + 2 - out + 3 - max(in,out) */ extern int maxoctets_timeout; /* Timeout for check of octets limit */ #define PPP_OCTETS_DIRECTION_SUM 0 #define PPP_OCTETS_DIRECTION_IN 1 @@ -275,7 +275,7 @@ extern int maxoctets_timeout; /* Timeout for check of octets limit */ * for a particular protocol. */ struct protent { - u_short protocol; /* PPP protocol number */ + u_short protocol; /* PPP protocol number */ /* Initialization procedure */ void (*init) (ppp_pcb *pcb); /* Process a received packet */ @@ -293,19 +293,19 @@ struct protent { #if PRINTPKT_SUPPORT /* Print a packet in readable form */ int (*printpkt) (const u_char *pkt, int len, - void (*printer) (void *, const char *, ...), - void *arg); + void (*printer) (void *, const char *, ...), + void *arg); #endif /* PRINTPKT_SUPPORT */ #if PPP_DATAINPUT /* Process a received data packet */ void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len); #endif /* PPP_DATAINPUT */ #if PRINTPKT_SUPPORT - const char *name; /* Text name of protocol */ - const char *data_name; /* Text name of corresponding data protocol */ + const char *name; /* Text name of protocol */ + const char *data_name; /* Text name of corresponding data protocol */ #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS - option_t *options; /* List of command-line options */ + option_t *options; /* List of command-line options */ /* Check requested options, assign defaults */ void (*check_options) (void); #endif /* PPP_OPTIONS */ @@ -323,28 +323,28 @@ extern const struct protent* const protocols[]; /* Values for auth_pending, auth_done */ #if PAP_SUPPORT -#define PAP_WITHPEER 0x1 -#define PAP_PEER 0x2 +#define PAP_WITHPEER 0x1 +#define PAP_PEER 0x2 #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT -#define CHAP_WITHPEER 0x4 -#define CHAP_PEER 0x8 +#define CHAP_WITHPEER 0x4 +#define CHAP_PEER 0x8 #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT -#define EAP_WITHPEER 0x10 -#define EAP_PEER 0x20 +#define EAP_WITHPEER 0x10 +#define EAP_PEER 0x20 #endif /* EAP_SUPPORT */ /* Values for auth_done only */ #if CHAP_SUPPORT -#define CHAP_MD5_WITHPEER 0x40 -#define CHAP_MD5_PEER 0x80 +#define CHAP_MD5_WITHPEER 0x40 +#define CHAP_MD5_PEER 0x80 #if MSCHAP_SUPPORT -#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */ -#define CHAP_MS_WITHPEER 0x100 -#define CHAP_MS_PEER 0x200 -#define CHAP_MS2_WITHPEER 0x400 -#define CHAP_MS2_PEER 0x800 +#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */ +#define CHAP_MS_WITHPEER 0x100 +#define CHAP_MS_PEER 0x200 +#define CHAP_MS2_WITHPEER 0x400 +#define CHAP_MS2_PEER 0x800 #endif /* MSCHAP_SUPPORT */ #endif /* CHAP_SUPPORT */ @@ -366,10 +366,10 @@ extern const struct protent* const protocols[]; * PPP statistics structure */ struct pppd_stats { - unsigned int bytes_in; - unsigned int bytes_out; - unsigned int pkts_in; - unsigned int pkts_out; + unsigned int bytes_in; + unsigned int bytes_out; + unsigned int pkts_in; + unsigned int pkts_out; }; #endif /* PPP_STATS_SUPPORT */ @@ -378,7 +378,7 @@ struct pppd_stats { * PPP private functions */ - + /* * Functions called from lwIP core. */ @@ -499,34 +499,34 @@ void update_link_stats(int u); /* Get stats at link termination */ * cp MUST be u_char *. */ #define GETCHAR(c, cp) { \ - (c) = *(cp)++; \ + (c) = *(cp)++; \ } #define PUTCHAR(c, cp) { \ - *(cp)++ = (u_char) (c); \ + *(cp)++ = (u_char) (c); \ } #define GETSHORT(s, cp) { \ - (s) = *(cp)++ << 8; \ - (s) |= *(cp)++; \ + (s) = *(cp)++ << 8; \ + (s) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ - *(cp)++ = (u_char) ((s) >> 8); \ - *(cp)++ = (u_char) (s); \ + *(cp)++ = (u_char) ((s) >> 8); \ + *(cp)++ = (u_char) (s); \ } #define GETLONG(l, cp) { \ - (l) = *(cp)++ << 8; \ - (l) |= *(cp)++; (l) <<= 8; \ - (l) |= *(cp)++; (l) <<= 8; \ - (l) |= *(cp)++; \ + (l) = *(cp)++ << 8; \ + (l) |= *(cp)++; (l) <<= 8; \ + (l) |= *(cp)++; (l) <<= 8; \ + (l) |= *(cp)++; \ } #define PUTLONG(l, cp) { \ - *(cp)++ = (u_char) ((l) >> 24); \ - *(cp)++ = (u_char) ((l) >> 16); \ - *(cp)++ = (u_char) ((l) >> 8); \ - *(cp)++ = (u_char) (l); \ + *(cp)++ = (u_char) ((l) >> 24); \ + *(cp)++ = (u_char) ((l) >> 16); \ + *(cp)++ = (u_char) ((l) >> 8); \ + *(cp)++ = (u_char) (l); \ } -#define INCPTR(n, cp) ((cp) += (n)) -#define DECPTR(n, cp) ((cp) -= (n)) +#define INCPTR(n, cp) ((cp) += (n)) +#define DECPTR(n, cp) ((cp) -= (n)) /* * System dependent definitions for user-level 4.3BSD UNIX implementation. @@ -535,10 +535,10 @@ void update_link_stats(int u); /* Get stats at link termination */ #define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0) #define UNTIMEOUT(f, a) sys_untimeout((f), (a)) -#define BZERO(s, n) memset(s, 0, n) -#define BCMP(s1, s2, l) memcmp(s1, s2, l) +#define BZERO(s, n) memset(s, 0, n) +#define BCMP(s1, s2, l) memcmp(s1, s2, l) -#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); } +#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); } /* * MAKEHEADER - Add Header fields to a packet. @@ -551,7 +551,7 @@ void update_link_stats(int u); /* Get stats at link termination */ /* Procedures exported from auth.c */ void link_required(ppp_pcb *pcb); /* we are starting to use the link */ void link_terminated(ppp_pcb *pcb); /* we are finished with the link */ -void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */ +void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */ void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */ void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */ void start_networks(ppp_pcb *pcb); /* start all the network control protos */ @@ -561,21 +561,21 @@ void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos int auth_check_passwd(ppp_pcb *pcb, char *auser, int userlen, char *apasswd, int passwdlen, const char **msg, int *msglen); /* check the user name and passwd against configuration */ void auth_peer_fail(ppp_pcb *pcb, int protocol); - /* peer failed to authenticate itself */ + /* peer failed to authenticate itself */ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char *name, int namelen); - /* peer successfully authenticated itself */ + /* peer successfully authenticated itself */ #endif /* PPP_SERVER */ void auth_withpeer_fail(ppp_pcb *pcb, int protocol); - /* we failed to authenticate ourselves */ + /* we failed to authenticate ourselves */ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor); - /* we successfully authenticated ourselves */ + /* we successfully authenticated ourselves */ #endif /* PPP_AUTH_SUPPORT */ void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */ void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */ void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */ #if PPP_AUTH_SUPPORT int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secret, int *secret_len, int am_server); - /* get "secret" for chap */ + /* get "secret" for chap */ #endif /* PPP_AUTH_SUPPORT */ /* Procedures exported from ipcp.c */ @@ -583,8 +583,8 @@ int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secre /* Procedures exported from demand.c */ #if DEMAND_SUPPORT -void demand_conf (void); /* config interface(s) for demand-dial */ -void demand_block (void); /* set all NPs to queue up packets */ +void demand_conf (void); /* config interface(s) for demand-dial */ +void demand_block (void); /* set all NPs to queue up packets */ void demand_unblock (void); /* set all NPs to pass packets */ void demand_discard (void); /* set all NPs to discard packets */ void demand_rexmit (int, u32_t); /* retransmit saved frames for an NP*/ @@ -601,10 +601,10 @@ void mp_bundle_terminated (void); char *epdisc_to_str (struct epdisc *); /* string from endpoint discrim. */ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */ #else -#define mp_bundle_terminated() /* nothing */ -#define mp_exit_bundle() /* nothing */ -#define doing_multilink 0 -#define multilink_master 0 +#define mp_bundle_terminated() /* nothing */ +#define mp_exit_bundle() /* nothing */ +#define doing_multilink 0 +#define multilink_master 0 #endif /* Procedures exported from utils.c. */ diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/pppcrypt.h b/components/net/lwip-2.0.2/src/include/netif/ppp/pppcrypt.h index a7b2099f25..e1823a2e06 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/pppcrypt.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/pppcrypt.h @@ -36,7 +36,7 @@ /* This header file is included in all PPP modules needing hashes and/or ciphers */ #ifndef PPPCRYPT_H -#define PPPCRYPT_H +#define PPPCRYPT_H /* * If included PolarSSL copy is not used, user is expected to include diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/pppdebug.h b/components/net/lwip-2.0.2/src/include/netif/ppp/pppdebug.h index 7ead045910..1cd6e292c9 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/pppdebug.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/pppdebug.h @@ -8,13 +8,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/pppoe.h b/components/net/lwip-2.0.2/src/include/netif/ppp/pppoe.h index 9f8f2892b4..de4ef62455 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/pppoe.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/pppoe.h @@ -6,13 +6,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-2.0.2/src/include/netif/ppp/upap.h b/components/net/lwip-2.0.2/src/include/netif/ppp/upap.h index 7da792ecc7..7131e8679d 100644 --- a/components/net/lwip-2.0.2/src/include/netif/ppp/upap.h +++ b/components/net/lwip-2.0.2/src/include/netif/ppp/upap.h @@ -53,44 +53,44 @@ /* * Packet header = Code, id, length. */ -#define UPAP_HEADERLEN 4 +#define UPAP_HEADERLEN 4 /* * UPAP codes. */ -#define UPAP_AUTHREQ 1 /* Authenticate-Request */ -#define UPAP_AUTHACK 2 /* Authenticate-Ack */ -#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ +#define UPAP_AUTHREQ 1 /* Authenticate-Request */ +#define UPAP_AUTHACK 2 /* Authenticate-Ack */ +#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ /* * Client states. */ -#define UPAPCS_INITIAL 0 /* Connection down */ -#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ -#define UPAPCS_OPEN 4 /* We've received an Ack */ -#define UPAPCS_BADAUTH 5 /* We've received a Nak */ +#define UPAPCS_INITIAL 0 /* Connection down */ +#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ +#define UPAPCS_OPEN 4 /* We've received an Ack */ +#define UPAPCS_BADAUTH 5 /* We've received a Nak */ /* * Server states. */ -#define UPAPSS_INITIAL 0 /* Connection down */ -#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ -#define UPAPSS_OPEN 4 /* We've sent an Ack */ -#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ +#define UPAPSS_INITIAL 0 /* Connection down */ +#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ +#define UPAPSS_OPEN 4 /* We've sent an Ack */ +#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ /* * Timeouts. */ #if 0 /* moved to ppp_opts.h */ -#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ -#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ +#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ +#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ #endif /* moved to ppp_opts.h */ /* @@ -98,16 +98,16 @@ */ #if PAP_SUPPORT typedef struct upap_state { - const char *us_user; /* User */ - u8_t us_userlen; /* User length */ - const char *us_passwd; /* Password */ - u8_t us_passwdlen; /* Password length */ - u8_t us_clientstate; /* Client state */ + const char *us_user; /* User */ + u8_t us_userlen; /* User length */ + const char *us_passwd; /* Password */ + u8_t us_passwdlen; /* Password length */ + u8_t us_clientstate; /* Client state */ #if PPP_SERVER - u8_t us_serverstate; /* Server state */ + u8_t us_serverstate; /* Server state */ #endif /* PPP_SERVER */ - u8_t us_id; /* Current id */ - u8_t us_transmits; /* Number of auth-reqs sent */ + u8_t us_id; /* Current id */ + u8_t us_transmits; /* Number of auth-reqs sent */ } upap_state; #endif /* PAP_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ethernet.c b/components/net/lwip-2.0.2/src/netif/ethernet.c index 52ea4236d5..988b997040 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernet.c +++ b/components/net/lwip-2.0.2/src/netif/ethernet.c @@ -1,7 +1,7 @@ /** * @file * Ethernet common functions - * + * * @defgroup ethernet Ethernet * @ingroup callbackstyle_api */ @@ -72,7 +72,7 @@ const struct eth_addr ethzero = {{0,0,0,0,0,0}}; * * @param p the received packet, p->payload pointing to the ethernet header * @param netif the network interface on which the packet was received - * + * * @see LWIP_HOOK_UNKNOWN_ETH_PROTOCOL * @see ETHARP_SUPPORT_VLAN * @see LWIP_HOOK_VLAN_CHECK diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index b93acb1fcf..ee339c2dd7 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * COPYRIGHT (C) 2006-2018, RT-Thread Development Team + * COPYRIGHT (C) 2006-2021, RT-Thread Development Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -173,7 +173,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) } else { - dhcp_stop((struct netif *)netif->user_data); + dhcp_stop((struct netif *)netif->user_data); } return ERR_OK; } @@ -868,27 +868,27 @@ void list_if(void) rt_kprintf("gw address: %s\n", ipaddr_ntoa(&(netif->gw))); rt_kprintf("net mask : %s\n", ipaddr_ntoa(&(netif->netmask))); #if LWIP_IPV6 - { - ip6_addr_t *addr; - int addr_state; - int i; + { + ip6_addr_t *addr; + int addr_state; + int i; - addr = (ip6_addr_t *)&netif->ip6_addr[0]; - addr_state = netif->ip6_addr_state[0]; + addr = (ip6_addr_t *)&netif->ip6_addr[0]; + addr_state = netif->ip6_addr_state[0]; - rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr), - addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); + rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr), + addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); - for(i=1; iip6_addr[i]; - addr_state = netif->ip6_addr_state[i]; + for(i=1; iip6_addr[i]; + addr_state = netif->ip6_addr_state[i]; - rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr), - addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); - } + rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr), + addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); + } - } + } rt_kprintf("\r\n"); #endif /* LWIP_IPV6 */ netif = netif->next; diff --git a/components/net/lwip-2.0.2/src/netif/ppp/auth.c b/components/net/lwip-2.0.2/src/netif/ppp/auth.c index c8673ad0fb..480a653ddd 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/auth.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/auth.c @@ -133,10 +133,10 @@ #if 0 /* UNUSED */ /* Bits in scan_authfile return value */ -#define NONWILD_SERVER 1 -#define NONWILD_CLIENT 2 +#define NONWILD_SERVER 1 +#define NONWILD_CLIENT 2 -#define ISWILD(word) (word[0] == '*' && word[1] == 0) +#define ISWILD(word) (word[0] == '*' && word[1] == 0) #endif /* UNUSED */ #if 0 /* UNUSED */ @@ -169,8 +169,8 @@ int (*pap_check_hook) (void) = NULL; /* Hook for a plugin to check the PAP user and password */ int (*pap_auth_hook) (char *user, char *passwd, char **msgp, - struct wordlist **paddrs, - struct wordlist **popts) = NULL; + struct wordlist **paddrs, + struct wordlist **popts) = NULL; /* Hook for a plugin to know about the PAP user logout */ void (*pap_logout_hook) (void) = NULL; @@ -187,7 +187,7 @@ int (*chap_passwd_hook) (char *user, char *passwd) = NULL; /* Hook for a plugin to say whether it is OK if the peer refuses to authenticate. */ int (*null_auth_hook) (struct wordlist **paddrs, - struct wordlist **popts) = NULL; + struct wordlist **popts) = NULL; int (*allowed_address_hook) (u32_t addr) = NULL; #endif /* UNUSED */ @@ -210,27 +210,27 @@ struct notifier *link_down_notifier = NULL; * Option variables. */ #if 0 /* MOVED TO ppp_settings */ -bool uselogin = 0; /* Use /etc/passwd for checking PAP */ -bool session_mgmt = 0; /* Do session management (login records) */ -bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ -bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ -bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ -bool refuse_eap = 0; /* Don't wanna auth. ourselves with EAP */ +bool uselogin = 0; /* Use /etc/passwd for checking PAP */ +bool session_mgmt = 0; /* Do session management (login records) */ +bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ +bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ +bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ +bool refuse_eap = 0; /* Don't wanna auth. ourselves with EAP */ #if MSCHAP_SUPPORT -bool refuse_mschap = 0; /* Don't wanna auth. ourselves with MS-CHAP */ -bool refuse_mschap_v2 = 0; /* Don't wanna auth. ourselves with MS-CHAPv2 */ +bool refuse_mschap = 0; /* Don't wanna auth. ourselves with MS-CHAP */ +bool refuse_mschap_v2 = 0; /* Don't wanna auth. ourselves with MS-CHAPv2 */ #else /* MSCHAP_SUPPORT */ -bool refuse_mschap = 1; /* Don't wanna auth. ourselves with MS-CHAP */ -bool refuse_mschap_v2 = 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ +bool refuse_mschap = 1; /* Don't wanna auth. ourselves with MS-CHAP */ +bool refuse_mschap_v2 = 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ #endif /* MSCHAP_SUPPORT */ -bool usehostname = 0; /* Use hostname for our_name */ -bool auth_required = 0; /* Always require authentication from peer */ -bool allow_any_ip = 0; /* Allow peer to use any IP address */ -bool explicit_remote = 0; /* User specified explicit remote name */ -bool explicit_user = 0; /* Set if "user" option supplied */ -bool explicit_passwd = 0; /* Set if "password" option supplied */ -char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ -static char *uafname; /* name of most recent +ua file */ +bool usehostname = 0; /* Use hostname for our_name */ +bool auth_required = 0; /* Always require authentication from peer */ +bool allow_any_ip = 0; /* Allow peer to use any IP address */ +bool explicit_remote = 0; /* User specified explicit remote name */ +bool explicit_user = 0; /* Set if "user" option supplied */ +bool explicit_passwd = 0; /* Set if "password" option supplied */ +char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ +static char *uafname; /* name of most recent +ua file */ extern char *crypt (const char *, const char *); #endif /* UNUSED */ @@ -252,8 +252,8 @@ static int have_srp_secret (char *client, char *server, int need_ip, int *lacks_ipp); static int ip_addr_check (u32_t, struct permitted_ip *); static int scan_authfile (FILE *, char *, char *, char *, - struct wordlist **, struct wordlist **, - char *, int); + struct wordlist **, struct wordlist **, + char *, int); static void free_wordlist (struct wordlist *); static void set_allowed_addrs (int, struct wordlist *, struct wordlist *); static int some_ip_ok (struct wordlist *); @@ -427,46 +427,46 @@ setupapfile(argv) /* open user info file */ fname = strdup(*argv); if (fname == NULL) - novm("+ua file name"); + novm("+ua file name"); euid = geteuid(); if (seteuid(getuid()) == -1) { - option_error("unable to reset uid before opening %s: %m", fname); - return 0; + option_error("unable to reset uid before opening %s: %m", fname); + return 0; } ufile = fopen(fname, "r"); if (seteuid(euid) == -1) - fatal("unable to regain privileges: %m"); + fatal("unable to regain privileges: %m"); if (ufile == NULL) { - option_error("unable to open user login data file %s", fname); - return 0; + option_error("unable to open user login data file %s", fname); + return 0; } check_access(ufile, fname); uafname = fname; /* get username */ if (fgets(u, MAXNAMELEN - 1, ufile) == NULL - || fgets(p, MAXSECRETLEN - 1, ufile) == NULL) { - fclose(ufile); - option_error("unable to read user login data file %s", fname); - return 0; + || fgets(p, MAXSECRETLEN - 1, ufile) == NULL) { + fclose(ufile); + option_error("unable to read user login data file %s", fname); + return 0; } fclose(ufile); /* get rid of newlines */ l = strlen(u); if (l > 0 && u[l-1] == '\n') - u[l-1] = 0; + u[l-1] = 0; l = strlen(p); if (l > 0 && p[l-1] == '\n') - p[l-1] = 0; + p[l-1] = 0; if (override_value("user", option_priority, fname)) { - strlcpy(ppp_settings.user, u, sizeof(ppp_settings.user)); - explicit_user = 1; + strlcpy(ppp_settings.user, u, sizeof(ppp_settings.user)); + explicit_user = 1; } if (override_value("passwd", option_priority, fname)) { - strlcpy(ppp_settings.passwd, p, sizeof(ppp_settings.passwd)); - explicit_passwd = 1; + strlcpy(ppp_settings.passwd, p, sizeof(ppp_settings.passwd)); + explicit_passwd = 1; } return (1); @@ -484,14 +484,14 @@ privgroup(argv) g = getgrnam(*argv); if (g == 0) { - option_error("group %s is unknown", *argv); - return 0; + option_error("group %s is unknown", *argv); + return 0; } for (i = 0; i < ngroups; ++i) { - if (groups[i] == g->gr_gid) { - privileged = 1; - break; - } + if (groups[i] == g->gr_gid) { + privileged = 1; + break; + } } return 1; } @@ -511,7 +511,7 @@ set_noauth_addr(argv) wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l); if (wp == NULL) - novm("allow-ip argument"); + novm("allow-ip argument"); wp->word = (char *) (wp + 1); wp->next = noauth_addrs; MEMCPY(wp->word, addr, l); @@ -533,7 +533,7 @@ set_permitted_number(argv) wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l); if (wp == NULL) - novm("allow-number argument"); + novm("allow-number argument"); wp->word = (char *) (wp + 1); wp->next = permitted_numbers; MEMCPY(wp->word, number, l); @@ -566,7 +566,7 @@ void start_link(unit) devfd = the_channel->connect(); msg = "Connect script failed"; if (devfd < 0) - goto fail; + goto fail; /* set up the serial device as a ppp interface */ /* @@ -579,21 +579,21 @@ void start_link(unit) fd_ppp = the_channel->establish_ppp(devfd); msg = "ppp establishment failed"; if (fd_ppp < 0) { - status = EXIT_FATAL_ERROR; - goto disconnect; + status = EXIT_FATAL_ERROR; + goto disconnect; } if (!demand && ifunit >= 0) - set_ifunit(1); + set_ifunit(1); /* * Start opening the connection and wait for * incoming events (reply, timeout, etc.). */ if (ifunit >= 0) - ppp_notice("Connect: %s <--> %s", ifname, ppp_devnam); + ppp_notice("Connect: %s <--> %s", ifname, ppp_devnam); else - ppp_notice("Starting negotiation on %s", ppp_devnam); + ppp_notice("Starting negotiation on %s", ppp_devnam); add_fd(fd_ppp); new_phase(pcb, PPP_PHASE_ESTABLISH); @@ -604,12 +604,12 @@ void start_link(unit) disconnect: new_phase(pcb, PPP_PHASE_DISCONNECT); if (the_channel->disconnect) - the_channel->disconnect(); + the_channel->disconnect(); fail: new_phase(pcb, PPP_PHASE_DEAD); if (the_channel->cleanup) - (*the_channel->cleanup)(); + (*the_channel->cleanup)(); } #endif @@ -623,23 +623,23 @@ void link_terminated(ppp_pcb *pcb) { || pcb->phase == PPP_PHASE_MASTER #endif /* HAVE_MULTILINK */ ) - return; + return; new_phase(pcb, PPP_PHASE_DISCONNECT); #if 0 /* UNUSED */ if (pap_logout_hook) { - pap_logout_hook(); + pap_logout_hook(); } session_end(devnam); #endif /* UNUSED */ if (!doing_multilink) { - ppp_notice("Connection terminated."); + ppp_notice("Connection terminated."); #if PPP_STATS_SUPPORT - print_link_stats(); + print_link_stats(); #endif /* PPP_STATS_SUPPORT */ } else - ppp_notice("Link terminated."); + ppp_notice("Link terminated."); lcp_lowerdown(pcb); @@ -651,7 +651,7 @@ void link_terminated(ppp_pcb *pcb) { * we delete its pid file. */ if (!doing_multilink && !demand) - remove_pidfiles(); + remove_pidfiles(); /* * If we may want to bring the link up again, transfer @@ -659,36 +659,36 @@ void link_terminated(ppp_pcb *pcb) { * real serial device back to its normal mode of operation. */ if (fd_ppp >= 0) { - remove_fd(fd_ppp); - clean_check(); - the_channel->disestablish_ppp(devfd); - if (doing_multilink) - mp_exit_bundle(); - fd_ppp = -1; + remove_fd(fd_ppp); + clean_check(); + the_channel->disestablish_ppp(devfd); + if (doing_multilink) + mp_exit_bundle(); + fd_ppp = -1; } if (!hungup) - lcp_lowerdown(pcb); + lcp_lowerdown(pcb); if (!doing_multilink && !demand) - script_unsetenv("IFNAME"); + script_unsetenv("IFNAME"); /* * Run disconnector script, if requested. * XXX we may not be able to do this if the line has hung up! */ if (devfd >= 0 && the_channel->disconnect) { - the_channel->disconnect(); - devfd = -1; + the_channel->disconnect(); + devfd = -1; } if (the_channel->cleanup) - (*the_channel->cleanup)(); + (*the_channel->cleanup)(); if (doing_multilink && multilink_master) { - if (!bundle_terminating) - new_phase(pcb, PPP_PHASE_MASTER); - else - mp_bundle_terminated(); + if (!bundle_terminating) + new_phase(pcb, PPP_PHASE_MASTER); + else + mp_bundle_terminated(); } else - new_phase(pcb, PPP_PHASE_DEAD); + new_phase(pcb, PPP_PHASE_DEAD); #endif } @@ -701,13 +701,13 @@ void link_down(ppp_pcb *pcb) { #endif /* PPP_NOTIFY */ if (!doing_multilink) { - upper_layers_down(pcb); - if (pcb->phase != PPP_PHASE_DEAD + upper_layers_down(pcb); + if (pcb->phase != PPP_PHASE_DEAD #ifdef HAVE_MULTILINK - && pcb->phase != PPP_PHASE_MASTER + && pcb->phase != PPP_PHASE_MASTER #endif /* HAVE_MULTILINK */ - ) - new_phase(pcb, PPP_PHASE_ESTABLISH); + ) + new_phase(pcb, PPP_PHASE_ESTABLISH); } /* XXX if doing_multilink, should do something to stop network-layer traffic on the link */ @@ -719,9 +719,9 @@ void upper_layers_down(ppp_pcb *pcb) { for (i = 0; (protp = protocols[i]) != NULL; ++i) { if (protp->protocol != PPP_LCP && protp->lowerdown != NULL) - (*protp->lowerdown)(pcb); + (*protp->lowerdown)(pcb); if (protp->protocol < 0xC000 && protp->close != NULL) - (*protp->close)(pcb, "LCP down"); + (*protp->close)(pcb, "LCP down"); } pcb->num_np_open = 0; pcb->num_np_up = 0; @@ -749,56 +749,56 @@ void link_established(ppp_pcb *pcb) { * Tell higher-level protocols that LCP is up. */ if (!doing_multilink) { - for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->protocol != PPP_LCP - && protp->lowerup != NULL) - (*protp->lowerup)(pcb); + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (protp->protocol != PPP_LCP + && protp->lowerup != NULL) + (*protp->lowerup)(pcb); } #if PPP_AUTH_SUPPORT #if PPP_SERVER #if PPP_ALLOWED_ADDRS if (!auth_required && noauth_addrs != NULL) - set_allowed_addrs(unit, NULL, NULL); + set_allowed_addrs(unit, NULL, NULL); #endif /* PPP_ALLOWED_ADDRS */ if (pcb->settings.auth_required && !(0 #if PAP_SUPPORT - || go->neg_upap + || go->neg_upap #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - || go->neg_chap + || go->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || go->neg_eap + || go->neg_eap #endif /* EAP_SUPPORT */ - )) { + )) { #if PPP_ALLOWED_ADDRS - /* - * We wanted the peer to authenticate itself, and it refused: - * if we have some address(es) it can use without auth, fine, - * otherwise treat it as though it authenticated with PAP using - * a username of "" and a password of "". If that's not OK, - * boot it out. - */ - if (noauth_addrs != NULL) { - set_allowed_addrs(unit, NULL, NULL); - } else + /* + * We wanted the peer to authenticate itself, and it refused: + * if we have some address(es) it can use without auth, fine, + * otherwise treat it as though it authenticated with PAP using + * a username of "" and a password of "". If that's not OK, + * boot it out. + */ + if (noauth_addrs != NULL) { + set_allowed_addrs(unit, NULL, NULL); + } else #endif /* PPP_ALLOWED_ADDRS */ - if (!pcb->settings.null_login + if (!pcb->settings.null_login #if PAP_SUPPORT - || !wo->neg_upap + || !wo->neg_upap #endif /* PAP_SUPPORT */ - ) { - ppp_warn("peer refused to authenticate: terminating link"); + ) { + ppp_warn("peer refused to authenticate: terminating link"); #if 0 /* UNUSED */ - status = EXIT_PEER_AUTH_FAILED; + status = EXIT_PEER_AUTH_FAILED; #endif /* UNUSED */ - pcb->err_code = PPPERR_AUTHFAIL; - lcp_close(pcb, "peer refused to authenticate"); - return; - } + pcb->err_code = PPPERR_AUTHFAIL; + lcp_close(pcb, "peer refused to authenticate"); + return; + } } #endif /* PPP_SERVER */ @@ -807,20 +807,20 @@ void link_established(ppp_pcb *pcb) { #if PPP_SERVER #if EAP_SUPPORT if (go->neg_eap) { - eap_authpeer(pcb, PPP_OUR_NAME); - auth |= EAP_PEER; + eap_authpeer(pcb, PPP_OUR_NAME); + auth |= EAP_PEER; } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT if (go->neg_chap) { - chap_auth_peer(pcb, PPP_OUR_NAME, CHAP_DIGEST(go->chap_mdtype)); - auth |= CHAP_PEER; + chap_auth_peer(pcb, PPP_OUR_NAME, CHAP_DIGEST(go->chap_mdtype)); + auth |= CHAP_PEER; } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT if (go->neg_upap) { - upap_authpeer(pcb); - auth |= PAP_PEER; + upap_authpeer(pcb); + auth |= PAP_PEER; } else #endif /* PAP_SUPPORT */ {} @@ -828,20 +828,20 @@ void link_established(ppp_pcb *pcb) { #if EAP_SUPPORT if (ho->neg_eap) { - eap_authwithpeer(pcb, pcb->settings.user); - auth |= EAP_WITHPEER; + eap_authwithpeer(pcb, pcb->settings.user); + auth |= EAP_WITHPEER; } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT if (ho->neg_chap) { - chap_auth_with_peer(pcb, pcb->settings.user, CHAP_DIGEST(ho->chap_mdtype)); - auth |= CHAP_WITHPEER; + chap_auth_with_peer(pcb, pcb->settings.user, CHAP_DIGEST(ho->chap_mdtype)); + auth |= CHAP_WITHPEER; } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT if (ho->neg_upap) { - upap_authwithpeer(pcb, pcb->settings.user, pcb->settings.passwd); - auth |= PAP_WITHPEER; + upap_authwithpeer(pcb, pcb->settings.user, pcb->settings.passwd); + auth |= PAP_WITHPEER; } else #endif /* PAP_SUPPORT */ {} @@ -851,7 +851,7 @@ void link_established(ppp_pcb *pcb) { if (!auth) #endif /* PPP_AUTH_SUPPORT */ - network_phase(pcb); + network_phase(pcb); } /* @@ -868,7 +868,7 @@ static void network_phase(ppp_pcb *pcb) { #if 0 /* UNUSED */ /* Log calling number. */ if (*remote_number) - ppp_notice("peer from calling number %q authorized", remote_number); + ppp_notice("peer from calling number %q authorized", remote_number); #endif /* UNUSED */ #if PPP_NOTIFY @@ -877,16 +877,16 @@ static void network_phase(ppp_pcb *pcb) { */ if (0 #if CHAP_SUPPORT - || go->neg_chap + || go->neg_chap #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - || go->neg_upap + || go->neg_upap #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - || go->neg_eap + || go->neg_eap #endif /* EAP_SUPPORT */ - ) { - notify(auth_up_notifier, 0); + ) { + notify(auth_up_notifier, 0); } #endif /* PPP_NOTIFY */ @@ -895,9 +895,9 @@ static void network_phase(ppp_pcb *pcb) { * If we negotiated callback, do it now. */ if (go->neg_cbcp) { - new_phase(pcb, PPP_PHASE_CALLBACK); - (*cbcp_protent.open)(pcb); - return; + new_phase(pcb, PPP_PHASE_CALLBACK); + (*cbcp_protent.open)(pcb); + return; } #endif @@ -906,9 +906,9 @@ static void network_phase(ppp_pcb *pcb) { * Process extra options from the secrets file */ if (extra_options) { - options_from_list(extra_options, 1); - free_wordlist(extra_options); - extra_options = 0; + options_from_list(extra_options, 1); + free_wordlist(extra_options); + extra_options = 0; } #endif /* PPP_OPTIONS */ start_networks(pcb); @@ -924,34 +924,34 @@ void start_networks(ppp_pcb *pcb) { #ifdef HAVE_MULTILINK if (multilink) { - if (mp_join_bundle()) { - if (multilink_join_hook) - (*multilink_join_hook)(); - if (updetach && !nodetach) - detach(); - return; - } + if (mp_join_bundle()) { + if (multilink_join_hook) + (*multilink_join_hook)(); + if (updetach && !nodetach) + detach(); + return; + } } #endif /* HAVE_MULTILINK */ #ifdef PPP_FILTER if (!demand) - set_filters(&pass_filter, &active_filter); + set_filters(&pass_filter, &active_filter); #endif #if CCP_SUPPORT || ECP_SUPPORT /* Start CCP and ECP */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if ( - (0 + if ( + (0 #if ECP_SUPPORT - || protp->protocol == PPP_ECP + || protp->protocol == PPP_ECP #endif /* ECP_SUPPORT */ #if CCP_SUPPORT - || protp->protocol == PPP_CCP + || protp->protocol == PPP_CCP #endif /* CCP_SUPPORT */ - ) - && protp->open != NULL) - (*protp->open)(pcb); + ) + && protp->open != NULL) + (*protp->open)(pcb); #endif /* CCP_SUPPORT || ECP_SUPPORT */ /* @@ -965,7 +965,7 @@ void start_networks(ppp_pcb *pcb) { && !pcb->ccp_gotoptions.mppe #endif /* MPPE_SUPPORT */ ) - continue_networks(pcb); + continue_networks(pcb); } void continue_networks(ppp_pcb *pcb) { @@ -976,21 +976,21 @@ void continue_networks(ppp_pcb *pcb) { * Start the "real" network protocols. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->protocol < 0xC000 + if (protp->protocol < 0xC000 #if CCP_SUPPORT - && protp->protocol != PPP_CCP + && protp->protocol != PPP_CCP #endif /* CCP_SUPPORT */ #if ECP_SUPPORT - && protp->protocol != PPP_ECP + && protp->protocol != PPP_ECP #endif /* ECP_SUPPORT */ - && protp->open != NULL) { - (*protp->open)(pcb); - ++pcb->num_np_open; - } + && protp->open != NULL) { + (*protp->open)(pcb); + ++pcb->num_np_open; + } if (pcb->num_np_open == 0) - /* nothing to do */ - lcp_close(pcb, "No network protocols running"); + /* nothing to do */ + lcp_close(pcb, "No network protocols running"); } #if PPP_AUTH_SUPPORT @@ -1053,37 +1053,37 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char * switch (protocol) { #if CHAP_SUPPORT case PPP_CHAP: - bit = CHAP_PEER; - switch (prot_flavor) { - case CHAP_MD5: - bit |= CHAP_MD5_PEER; - break; + bit = CHAP_PEER; + switch (prot_flavor) { + case CHAP_MD5: + bit |= CHAP_MD5_PEER; + break; #if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - bit |= CHAP_MS_PEER; - break; - case CHAP_MICROSOFT_V2: - bit |= CHAP_MS2_PEER; - break; + case CHAP_MICROSOFT: + bit |= CHAP_MS_PEER; + break; + case CHAP_MICROSOFT_V2: + bit |= CHAP_MS2_PEER; + break; #endif /* MSCHAP_SUPPORT */ - default: - break; - } - break; + default: + break; + } + break; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT case PPP_PAP: - bit = PAP_PEER; - break; + bit = PAP_PEER; + break; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT case PPP_EAP: - bit = EAP_PEER; - break; + bit = EAP_PEER; + break; #endif /* EAP_SUPPORT */ default: - ppp_warn("auth_peer_success: unknown protocol %x", protocol); - return; + ppp_warn("auth_peer_success: unknown protocol %x", protocol); + return; } #ifdef HAVE_MULTILINK @@ -1091,7 +1091,7 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char * * Save the authenticated name of the peer for later. */ if (namelen > (int)sizeof(pcb->peer_authname) - 1) - namelen = (int)sizeof(pcb->peer_authname) - 1; + namelen = (int)sizeof(pcb->peer_authname) - 1; MEMCPY(pcb->peer_authname, name, namelen); pcb->peer_authname[namelen] = 0; #endif /* HAVE_MULTILINK */ @@ -1140,41 +1140,41 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) { switch (protocol) { #if CHAP_SUPPORT case PPP_CHAP: - bit = CHAP_WITHPEER; - prot = "CHAP"; - switch (prot_flavor) { - case CHAP_MD5: - bit |= CHAP_MD5_WITHPEER; - break; + bit = CHAP_WITHPEER; + prot = "CHAP"; + switch (prot_flavor) { + case CHAP_MD5: + bit |= CHAP_MD5_WITHPEER; + break; #if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - bit |= CHAP_MS_WITHPEER; - break; - case CHAP_MICROSOFT_V2: - bit |= CHAP_MS2_WITHPEER; - break; + case CHAP_MICROSOFT: + bit |= CHAP_MS_WITHPEER; + break; + case CHAP_MICROSOFT_V2: + bit |= CHAP_MS2_WITHPEER; + break; #endif /* MSCHAP_SUPPORT */ - default: - break; - } - break; + default: + break; + } + break; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT case PPP_PAP: - bit = PAP_WITHPEER; - prot = "PAP"; - break; + bit = PAP_WITHPEER; + prot = "PAP"; + break; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT case PPP_EAP: - bit = EAP_WITHPEER; - prot = "EAP"; - break; + bit = EAP_WITHPEER; + prot = "EAP"; + break; #endif /* EAP_SUPPORT */ default: - ppp_warn("auth_withpeer_success: unknown protocol %x", protocol); - bit = 0; - /* no break */ + ppp_warn("auth_withpeer_success: unknown protocol %x", protocol); + bit = 0; + /* no break */ } ppp_notice("%s authentication succeeded", prot); @@ -1187,7 +1187,7 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) { * proceed to the network (or callback) phase. */ if ((pcb->auth_pending &= ~bit) == 0) - network_phase(pcb); + network_phase(pcb); } #endif /* PPP_AUTH_SUPPORT */ @@ -1202,42 +1202,42 @@ void np_up(ppp_pcb *pcb, int proto) { LWIP_UNUSED_ARG(proto); if (pcb->num_np_up == 0) { - /* - * At this point we consider that the link has come up successfully. - */ - new_phase(pcb, PPP_PHASE_RUNNING); + /* + * At this point we consider that the link has come up successfully. + */ + new_phase(pcb, PPP_PHASE_RUNNING); #if PPP_IDLETIMELIMIT #if 0 /* UNUSED */ - if (idle_time_hook != 0) - tlim = (*idle_time_hook)(NULL); - else + if (idle_time_hook != 0) + tlim = (*idle_time_hook)(NULL); + else #endif /* UNUSED */ - tlim = pcb->settings.idle_time_limit; - if (tlim > 0) - TIMEOUT(check_idle, (void*)pcb, tlim); + tlim = pcb->settings.idle_time_limit; + if (tlim > 0) + TIMEOUT(check_idle, (void*)pcb, tlim); #endif /* PPP_IDLETIMELIMIT */ #if PPP_MAXCONNECT - /* - * Set a timeout to close the connection once the maximum - * connect time has expired. - */ - if (pcb->settings.maxconnect > 0) - TIMEOUT(connect_time_expired, (void*)pcb, pcb->settings.maxconnect); + /* + * Set a timeout to close the connection once the maximum + * connect time has expired. + */ + if (pcb->settings.maxconnect > 0) + TIMEOUT(connect_time_expired, (void*)pcb, pcb->settings.maxconnect); #endif /* PPP_MAXCONNECT */ #ifdef MAXOCTETS - if (maxoctets > 0) - TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); + if (maxoctets > 0) + TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); #endif #if 0 /* Unused */ - /* - * Detach now, if the updetach option was given. - */ - if (updetach && !nodetach) - detach(); + /* + * Detach now, if the updetach option was given. + */ + if (updetach && !nodetach) + detach(); #endif /* Unused */ } ++pcb->num_np_up; @@ -1250,15 +1250,15 @@ void np_down(ppp_pcb *pcb, int proto) { LWIP_UNUSED_ARG(proto); if (--pcb->num_np_up == 0) { #if PPP_IDLETIMELIMIT - UNTIMEOUT(check_idle, (void*)pcb); + UNTIMEOUT(check_idle, (void*)pcb); #endif /* PPP_IDLETIMELIMIT */ #if PPP_MAXCONNECT - UNTIMEOUT(connect_time_expired, NULL); + UNTIMEOUT(connect_time_expired, NULL); #endif /* PPP_MAXCONNECT */ #ifdef MAXOCTETS - UNTIMEOUT(check_maxoctets, NULL); + UNTIMEOUT(check_maxoctets, NULL); #endif - new_phase(pcb, PPP_PHASE_NETWORK); + new_phase(pcb, PPP_PHASE_NETWORK); } } @@ -1268,8 +1268,8 @@ void np_down(ppp_pcb *pcb, int proto) { void np_finished(ppp_pcb *pcb, int proto) { LWIP_UNUSED_ARG(proto); if (--pcb->num_np_open <= 0) { - /* no further use for the link: shut up shop. */ - lcp_close(pcb, "No network protocols running"); + /* no further use for the link: shut up shop. */ + lcp_close(pcb, "No network protocols running"); } } @@ -1285,26 +1285,26 @@ check_maxoctets(arg) link_stats_valid=0; switch(maxoctets_dir) { - case PPP_OCTETS_DIRECTION_IN: - used = link_stats.bytes_in; - break; - case PPP_OCTETS_DIRECTION_OUT: - used = link_stats.bytes_out; - break; - case PPP_OCTETS_DIRECTION_MAXOVERAL: - case PPP_OCTETS_DIRECTION_MAXSESSION: - used = (link_stats.bytes_in > link_stats.bytes_out) ? link_stats.bytes_in : link_stats.bytes_out; - break; - default: - used = link_stats.bytes_in+link_stats.bytes_out; - break; + case PPP_OCTETS_DIRECTION_IN: + used = link_stats.bytes_in; + break; + case PPP_OCTETS_DIRECTION_OUT: + used = link_stats.bytes_out; + break; + case PPP_OCTETS_DIRECTION_MAXOVERAL: + case PPP_OCTETS_DIRECTION_MAXSESSION: + used = (link_stats.bytes_in > link_stats.bytes_out) ? link_stats.bytes_in : link_stats.bytes_out; + break; + default: + used = link_stats.bytes_in+link_stats.bytes_out; + break; } if (used > maxoctets) { - ppp_notice("Traffic limit reached. Limit: %u Used: %u", maxoctets, used); - status = EXIT_TRAFFIC_LIMIT; - lcp_close(pcb, "Traffic limit"); + ppp_notice("Traffic limit reached. Limit: %u Used: %u", maxoctets, used); + status = EXIT_TRAFFIC_LIMIT; + lcp_close(pcb, "Traffic limit"); #if 0 /* UNUSED */ - need_holdoff = 0; + need_holdoff = 0; #endif /* UNUSED */ } else { TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); @@ -1325,27 +1325,27 @@ static void check_idle(void *arg) { int tlim; if (!get_idle_time(pcb, &idle)) - return; + return; #if 0 /* UNUSED */ if (idle_time_hook != 0) { - tlim = idle_time_hook(&idle); + tlim = idle_time_hook(&idle); } else { #endif /* UNUSED */ - itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); - tlim = pcb->settings.idle_time_limit - itime; + itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); + tlim = pcb->settings.idle_time_limit - itime; #if 0 /* UNUSED */ } #endif /* UNUSED */ if (tlim <= 0) { - /* link is idle: shut it down. */ - ppp_notice("Terminating connection due to lack of activity."); - pcb->err_code = PPPERR_IDLETIMEOUT; - lcp_close(pcb, "Link inactive"); + /* link is idle: shut it down. */ + ppp_notice("Terminating connection due to lack of activity."); + pcb->err_code = PPPERR_IDLETIMEOUT; + lcp_close(pcb, "Link inactive"); #if 0 /* UNUSED */ - need_holdoff = 0; + need_holdoff = 0; #endif /* UNUSED */ } else { - TIMEOUT(check_idle, (void*)pcb, tlim); + TIMEOUT(check_idle, (void*)pcb, tlim); } } #endif /* PPP_IDLETIMELIMIT */ @@ -1358,7 +1358,7 @@ static void connect_time_expired(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; ppp_info("Connect time expired"); pcb->err_code = PPPERR_CONNECTTIME; - lcp_close(pcb, "Connect time expired"); /* Close connection */ + lcp_close(pcb, "Connect time expired"); /* Close connection */ } #endif /* PPP_MAXCONNECT */ @@ -1375,62 +1375,62 @@ auth_check_options() /* Default our_name to hostname, and user to our_name */ if (our_name[0] == 0 || usehostname) - strlcpy(our_name, hostname, sizeof(our_name)); + strlcpy(our_name, hostname, sizeof(our_name)); /* If a blank username was explicitly given as an option, trust the user and don't use our_name */ if (ppp_settings.user[0] == 0 && !explicit_user) - strlcpy(ppp_settings.user, our_name, sizeof(ppp_settings.user)); + strlcpy(ppp_settings.user, our_name, sizeof(ppp_settings.user)); /* * If we have a default route, require the peer to authenticate * unless the noauth option was given or the real user is root. */ if (!auth_required && !allow_any_ip && have_route_to(0) && !privileged) { - auth_required = 1; - default_auth = 1; + auth_required = 1; + default_auth = 1; } #if CHAP_SUPPORT /* If we selected any CHAP flavors, we should probably negotiate it. :-) */ if (wo->chap_mdtype) - wo->neg_chap = 1; + wo->neg_chap = 1; #endif /* CHAP_SUPPORT */ /* If authentication is required, ask peer for CHAP, PAP, or EAP. */ if (auth_required) { - allow_any_ip = 0; - if (1 + allow_any_ip = 0; + if (1 #if CHAP_SUPPORT - && !wo->neg_chap + && !wo->neg_chap #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - && !wo->neg_upap + && !wo->neg_upap #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - && !wo->neg_eap + && !wo->neg_eap #endif /* EAP_SUPPORT */ - ) { + ) { #if CHAP_SUPPORT - wo->neg_chap = CHAP_MDTYPE_SUPPORTED != MDTYPE_NONE; - wo->chap_mdtype = CHAP_MDTYPE_SUPPORTED; + wo->neg_chap = CHAP_MDTYPE_SUPPORTED != MDTYPE_NONE; + wo->chap_mdtype = CHAP_MDTYPE_SUPPORTED; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - wo->neg_upap = 1; + wo->neg_upap = 1; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - wo->neg_eap = 1; + wo->neg_eap = 1; #endif /* EAP_SUPPORT */ - } + } } else { #if CHAP_SUPPORT - wo->neg_chap = 0; - wo->chap_mdtype = MDTYPE_NONE; + wo->neg_chap = 0; + wo->chap_mdtype = MDTYPE_NONE; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - wo->neg_upap = 0; + wo->neg_upap = 0; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - wo->neg_eap = 0; + wo->neg_eap = 0; #endif /* EAP_SUPPORT */ } @@ -1447,56 +1447,56 @@ auth_check_options() #endif /* PAP_SUPPORT */ if (!can_auth && (0 #if CHAP_SUPPORT - || wo->neg_chap + || wo->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || wo->neg_eap + || wo->neg_eap #endif /* EAP_SUPPORT */ - )) { + )) { #if CHAP_SUPPORT - can_auth = have_chap_secret((explicit_remote? remote_name: NULL), - our_name, 1, &lacks_ip); + can_auth = have_chap_secret((explicit_remote? remote_name: NULL), + our_name, 1, &lacks_ip); #else - can_auth = 0; + can_auth = 0; #endif } if (!can_auth #if EAP_SUPPORT - && wo->neg_eap + && wo->neg_eap #endif /* EAP_SUPPORT */ - ) { - can_auth = have_srp_secret((explicit_remote? remote_name: NULL), - our_name, 1, &lacks_ip); + ) { + can_auth = have_srp_secret((explicit_remote? remote_name: NULL), + our_name, 1, &lacks_ip); } if (auth_required && !can_auth && noauth_addrs == NULL) { - if (default_auth) { - option_error( + if (default_auth) { + option_error( "By default the remote system is required to authenticate itself"); - option_error( + option_error( "(because this system has a default route to the internet)"); - } else if (explicit_remote) - option_error( + } else if (explicit_remote) + option_error( "The remote system (%s) is required to authenticate itself", - remote_name); - else - option_error( + remote_name); + else + option_error( "The remote system is required to authenticate itself"); - option_error( + option_error( "but I couldn't find any suitable secret (password) for it to use to do so."); - if (lacks_ip) - option_error( + if (lacks_ip) + option_error( "(None of the available passwords would let it use an IP address.)"); - exit(1); + exit(1); } /* * Early check for remote number authorization. */ if (!auth_number()) { - ppp_warn("calling number %q is not authorized", remote_number); - exit(EXIT_CNID_AUTH_FAILED); + ppp_warn("calling number %q is not authorized", remote_number); + exit(EXIT_CNID_AUTH_FAILED); } } #endif /* PPP_OPTIONS */ @@ -1518,30 +1518,30 @@ auth_reset(unit) hadchap = -1; ao->neg_upap = !refuse_pap && (passwd[0] != 0 || get_pap_passwd(NULL)); ao->neg_chap = (!refuse_chap || !refuse_mschap || !refuse_mschap_v2) - && (passwd[0] != 0 || - (hadchap = have_chap_secret(user, (explicit_remote? remote_name: - NULL), 0, NULL))); + && (passwd[0] != 0 || + (hadchap = have_chap_secret(user, (explicit_remote? remote_name: + NULL), 0, NULL))); ao->neg_eap = !refuse_eap && ( - passwd[0] != 0 || - (hadchap == 1 || (hadchap == -1 && have_chap_secret(user, - (explicit_remote? remote_name: NULL), 0, NULL))) || - have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL)); + passwd[0] != 0 || + (hadchap == 1 || (hadchap == -1 && have_chap_secret(user, + (explicit_remote? remote_name: NULL), 0, NULL))) || + have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL)); hadchap = -1; if (go->neg_upap && !uselogin && !have_pap_secret(NULL)) - go->neg_upap = 0; + go->neg_upap = 0; if (go->neg_chap) { - if (!(hadchap = have_chap_secret((explicit_remote? remote_name: NULL), - our_name, 1, NULL))) - go->neg_chap = 0; + if (!(hadchap = have_chap_secret((explicit_remote? remote_name: NULL), + our_name, 1, NULL))) + go->neg_chap = 0; } if (go->neg_eap && - (hadchap == 0 || (hadchap == -1 && - !have_chap_secret((explicit_remote? remote_name: NULL), our_name, - 1, NULL))) && - !have_srp_secret((explicit_remote? remote_name: NULL), our_name, 1, - NULL)) - go->neg_eap = 0; + (hadchap == 0 || (hadchap == -1 && + !have_chap_secret((explicit_remote? remote_name: NULL), our_name, + 1, NULL))) && + !have_srp_secret((explicit_remote? remote_name: NULL), our_name, 1, + NULL)) + go->neg_eap = 0; } /* @@ -1550,8 +1550,8 @@ auth_reset(unit) * and login the user if OK. * * returns: - * UPAP_AUTHNAK: Authentication failed. - * UPAP_AUTHACK: Authentication succeeded. + * UPAP_AUTHNAK: Authentication failed. + * UPAP_AUTHACK: Authentication succeeded. * In either case, msg points to an appropriate message. */ int @@ -1585,19 +1585,19 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg) * Check if a plugin wants to handle this. */ if (pap_auth_hook) { - ret = (*pap_auth_hook)(ppp_settings.user, ppp_settings.passwd, msg, &addrs, &opts); - if (ret >= 0) { - /* note: set_allowed_addrs() saves opts (but not addrs): - don't free it! */ - if (ret) - set_allowed_addrs(unit, addrs, opts); - else if (opts != 0) - free_wordlist(opts); - if (addrs != 0) - free_wordlist(addrs); - BZERO(ppp_settings.passwd, sizeof(ppp_settings.passwd)); - return ret? UPAP_AUTHACK: UPAP_AUTHNAK; - } + ret = (*pap_auth_hook)(ppp_settings.user, ppp_settings.passwd, msg, &addrs, &opts); + if (ret >= 0) { + /* note: set_allowed_addrs() saves opts (but not addrs): + don't free it! */ + if (ret) + set_allowed_addrs(unit, addrs, opts); + else if (opts != 0) + free_wordlist(opts); + if (addrs != 0) + free_wordlist(addrs); + BZERO(ppp_settings.passwd, sizeof(ppp_settings.passwd)); + return ret? UPAP_AUTHACK: UPAP_AUTHNAK; + } } /* @@ -1609,67 +1609,67 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg) ret = UPAP_AUTHNAK; f = fopen(filename, "r"); if (f == NULL) { - ppp_error("Can't open PAP password file %s: %m", filename); + ppp_error("Can't open PAP password file %s: %m", filename); } else { - check_access(f, filename); - if (scan_authfile(f, ppp_settings.user, our_name, secret, &addrs, &opts, filename, 0) < 0) { - ppp_warn("no PAP secret found for %s", user); - } else { - /* - * If the secret is "@login", it means to check - * the password against the login database. - */ - int login_secret = strcmp(secret, "@login") == 0; - ret = UPAP_AUTHACK; - if (uselogin || login_secret) { - /* login option or secret is @login */ - if (session_full(ppp_settings.user, ppp_settings.passwd, devnam, msg) == 0) { - ret = UPAP_AUTHNAK; - } - } else if (session_mgmt) { - if (session_check(ppp_settings.user, NULL, devnam, NULL) == 0) { - ppp_warn("Peer %q failed PAP Session verification", user); - ret = UPAP_AUTHNAK; - } - } - if (secret[0] != 0 && !login_secret) { - /* password given in pap-secrets - must match */ - if ((cryptpap || strcmp(ppp_settings.passwd, secret) != 0) - && strcmp(crypt(ppp_settings.passwd, secret), secret) != 0) - ret = UPAP_AUTHNAK; - } - } - fclose(f); + check_access(f, filename); + if (scan_authfile(f, ppp_settings.user, our_name, secret, &addrs, &opts, filename, 0) < 0) { + ppp_warn("no PAP secret found for %s", user); + } else { + /* + * If the secret is "@login", it means to check + * the password against the login database. + */ + int login_secret = strcmp(secret, "@login") == 0; + ret = UPAP_AUTHACK; + if (uselogin || login_secret) { + /* login option or secret is @login */ + if (session_full(ppp_settings.user, ppp_settings.passwd, devnam, msg) == 0) { + ret = UPAP_AUTHNAK; + } + } else if (session_mgmt) { + if (session_check(ppp_settings.user, NULL, devnam, NULL) == 0) { + ppp_warn("Peer %q failed PAP Session verification", user); + ret = UPAP_AUTHNAK; + } + } + if (secret[0] != 0 && !login_secret) { + /* password given in pap-secrets - must match */ + if ((cryptpap || strcmp(ppp_settings.passwd, secret) != 0) + && strcmp(crypt(ppp_settings.passwd, secret), secret) != 0) + ret = UPAP_AUTHNAK; + } + } + fclose(f); } if (ret == UPAP_AUTHNAK) { if (**msg == 0) - *msg = "Login incorrect"; - /* - * XXX can we ever get here more than once?? - * Frustrate passwd stealer programs. - * Allow 10 tries, but start backing off after 3 (stolen from login). - * On 10'th, drop the connection. - */ - if (attempts++ >= 10) { - ppp_warn("%d LOGIN FAILURES ON %s, %s", attempts, devnam, user); - lcp_close(pcb, "login failed"); - } - if (attempts > 3) - sleep((u_int) (attempts - 3) * 5); - if (opts != NULL) - free_wordlist(opts); + *msg = "Login incorrect"; + /* + * XXX can we ever get here more than once?? + * Frustrate passwd stealer programs. + * Allow 10 tries, but start backing off after 3 (stolen from login). + * On 10'th, drop the connection. + */ + if (attempts++ >= 10) { + ppp_warn("%d LOGIN FAILURES ON %s, %s", attempts, devnam, user); + lcp_close(pcb, "login failed"); + } + if (attempts > 3) + sleep((u_int) (attempts - 3) * 5); + if (opts != NULL) + free_wordlist(opts); } else { - attempts = 0; /* Reset count */ - if (**msg == 0) - *msg = "Login ok"; - set_allowed_addrs(unit, addrs, opts); + attempts = 0; /* Reset count */ + if (**msg == 0) + *msg = "Login ok"; + set_allowed_addrs(unit, addrs, opts); } if (addrs != NULL) - free_wordlist(addrs); + free_wordlist(addrs); BZERO(ppp_settings.passwd, sizeof(ppp_settings.passwd)); BZERO(secret, sizeof(secret)); @@ -1696,31 +1696,31 @@ null_login(unit) */ ret = -1; if (null_auth_hook) - ret = (*null_auth_hook)(&addrs, &opts); + ret = (*null_auth_hook)(&addrs, &opts); /* * Open the file of pap secrets and scan for a suitable secret. */ if (ret <= 0) { - filename = _PATH_UPAPFILE; - addrs = NULL; - f = fopen(filename, "r"); - if (f == NULL) - return 0; - check_access(f, filename); + filename = _PATH_UPAPFILE; + addrs = NULL; + f = fopen(filename, "r"); + if (f == NULL) + return 0; + check_access(f, filename); - i = scan_authfile(f, "", our_name, secret, &addrs, &opts, filename, 0); - ret = i >= 0 && secret[0] == 0; - BZERO(secret, sizeof(secret)); - fclose(f); + i = scan_authfile(f, "", our_name, secret, &addrs, &opts, filename, 0); + ret = i >= 0 && secret[0] == 0; + BZERO(secret, sizeof(secret)); + fclose(f); } if (ret) - set_allowed_addrs(unit, addrs, opts); + set_allowed_addrs(unit, addrs, opts); else if (opts != 0) - free_wordlist(opts); + free_wordlist(opts); if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret; } @@ -1744,24 +1744,24 @@ get_pap_passwd(passwd) * Check whether a plugin wants to supply this. */ if (pap_passwd_hook) { - ret = (*pap_passwd_hook)(ppp_settings,user, ppp_settings.passwd); - if (ret >= 0) - return ret; + ret = (*pap_passwd_hook)(ppp_settings,user, ppp_settings.passwd); + if (ret >= 0) + return ret; } filename = _PATH_UPAPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; check_access(f, filename); ret = scan_authfile(f, user, - (remote_name[0]? remote_name: NULL), - secret, NULL, NULL, filename, 0); + (remote_name[0]? remote_name: NULL), + secret, NULL, NULL, filename, 0); fclose(f); if (ret < 0) - return 0; + return 0; if (passwd != NULL) - strlcpy(passwd, secret, MAXSECRETLEN); + strlcpy(passwd, secret, MAXSECRETLEN); BZERO(secret, sizeof(secret)); return 1; } @@ -1781,26 +1781,26 @@ have_pap_secret(lacks_ipp) /* let the plugin decide, if there is one */ if (pap_check_hook) { - ret = (*pap_check_hook)(); - if (ret >= 0) - return ret; + ret = (*pap_check_hook)(); + if (ret >= 0) + return ret; } filename = _PATH_UPAPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; ret = scan_authfile(f, (explicit_remote? remote_name: NULL), our_name, - NULL, &addrs, NULL, filename, 0); + NULL, &addrs, NULL, filename, 0); fclose(f); if (ret >= 0 && !some_ip_ok(addrs)) { - if (lacks_ipp != 0) - *lacks_ipp = 1; - ret = -1; + if (lacks_ipp != 0) + *lacks_ipp = 1; + ret = -1; } if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret >= 0; } @@ -1824,31 +1824,31 @@ have_chap_secret(client, server, need_ip, lacks_ipp) struct wordlist *addrs; if (chap_check_hook) { - ret = (*chap_check_hook)(); - if (ret >= 0) { - return ret; - } + ret = (*chap_check_hook)(); + if (ret >= 0) { + return ret; + } } filename = _PATH_CHAPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; if (client != NULL && client[0] == 0) - client = NULL; + client = NULL; else if (server != NULL && server[0] == 0) - server = NULL; + server = NULL; ret = scan_authfile(f, client, server, NULL, &addrs, NULL, filename, 0); fclose(f); if (ret >= 0 && need_ip && !some_ip_ok(addrs)) { - if (lacks_ipp != 0) - *lacks_ipp = 1; - ret = -1; + if (lacks_ipp != 0) + *lacks_ipp = 1; + ret = -1; } if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret >= 0; } @@ -1874,22 +1874,22 @@ have_srp_secret(client, server, need_ip, lacks_ipp) filename = _PATH_SRPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; if (client != NULL && client[0] == 0) - client = NULL; + client = NULL; else if (server != NULL && server[0] == 0) - server = NULL; + server = NULL; ret = scan_authfile(f, client, server, NULL, &addrs, NULL, filename, 0); fclose(f); if (ret >= 0 && need_ip && !some_ip_ok(addrs)) { - if (lacks_ipp != 0) - *lacks_ipp = 1; - ret = -1; + if (lacks_ipp != 0) + *lacks_ipp = 1; + ret = -1; } if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret >= 0; } @@ -1930,42 +1930,42 @@ int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secre addrs = NULL; if (!am_server && ppp_settings.passwd[0] != 0) { - strlcpy(secbuf, ppp_settings.passwd, sizeof(secbuf)); + strlcpy(secbuf, ppp_settings.passwd, sizeof(secbuf)); } else if (!am_server && chap_passwd_hook) { - if ( (*chap_passwd_hook)(client, secbuf) < 0) { - ppp_error("Unable to obtain CHAP password for %s on %s from plugin", - client, server); - return 0; - } + if ( (*chap_passwd_hook)(client, secbuf) < 0) { + ppp_error("Unable to obtain CHAP password for %s on %s from plugin", + client, server); + return 0; + } } else { - filename = _PATH_CHAPFILE; - addrs = NULL; - secbuf[0] = 0; - - f = fopen(filename, "r"); - if (f == NULL) { - ppp_error("Can't open chap secret file %s: %m", filename); - return 0; - } - check_access(f, filename); - - ret = scan_authfile(f, client, server, secbuf, &addrs, &opts, filename, 0); - fclose(f); - if (ret < 0) - return 0; - - if (am_server) - set_allowed_addrs(unit, addrs, opts); - else if (opts != 0) - free_wordlist(opts); - if (addrs != 0) - free_wordlist(addrs); + filename = _PATH_CHAPFILE; + addrs = NULL; + secbuf[0] = 0; + + f = fopen(filename, "r"); + if (f == NULL) { + ppp_error("Can't open chap secret file %s: %m", filename); + return 0; + } + check_access(f, filename); + + ret = scan_authfile(f, client, server, secbuf, &addrs, &opts, filename, 0); + fclose(f); + if (ret < 0) + return 0; + + if (am_server) + set_allowed_addrs(unit, addrs, opts); + else if (opts != 0) + free_wordlist(opts); + if (addrs != 0) + free_wordlist(addrs); } len = strlen(secbuf); if (len > MAXSECRETLEN) { - ppp_error("Secret for %s on %s is too long", client, server); - len = MAXSECRETLEN; + ppp_error("Secret for %s on %s is too long", client, server); + len = MAXSECRETLEN; } MEMCPY(secret, secbuf, len); BZERO(secbuf, sizeof(secbuf)); @@ -1997,31 +1997,31 @@ get_srp_secret(unit, client, server, secret, am_server) struct wordlist *addrs, *opts; if (!am_server && ppp_settings.passwd[0] != '\0') { - strlcpy(secret, ppp_settings.passwd, MAXWORDLEN); + strlcpy(secret, ppp_settings.passwd, MAXWORDLEN); } else { - filename = _PATH_SRPFILE; - addrs = NULL; - - fp = fopen(filename, "r"); - if (fp == NULL) { - ppp_error("Can't open srp secret file %s: %m", filename); - return 0; - } - check_access(fp, filename); - - secret[0] = '\0'; - ret = scan_authfile(fp, client, server, secret, &addrs, &opts, - filename, am_server); - fclose(fp); - if (ret < 0) - return 0; - - if (am_server) - set_allowed_addrs(unit, addrs, opts); - else if (opts != NULL) - free_wordlist(opts); - if (addrs != NULL) - free_wordlist(addrs); + filename = _PATH_SRPFILE; + addrs = NULL; + + fp = fopen(filename, "r"); + if (fp == NULL) { + ppp_error("Can't open srp secret file %s: %m", filename); + return 0; + } + check_access(fp, filename); + + secret[0] = '\0'; + ret = scan_authfile(fp, client, server, secret, &addrs, &opts, + filename, am_server); + fclose(fp); + if (ret < 0) + return 0; + + if (am_server) + set_allowed_addrs(unit, addrs, opts); + else if (opts != NULL) + free_wordlist(opts); + if (addrs != NULL) + free_wordlist(addrs); } return 1; @@ -2049,10 +2049,10 @@ set_allowed_addrs(unit, addrs, opts) u32_t suggested_ip = 0; if (addresses[unit] != NULL) - free(addresses[unit]); + free(addresses[unit]); addresses[unit] = NULL; if (extra_options != NULL) - free_wordlist(extra_options); + free_wordlist(extra_options); extra_options = opts; /* @@ -2060,109 +2060,109 @@ set_allowed_addrs(unit, addrs, opts) */ n = wordlist_count(addrs) + wordlist_count(noauth_addrs); if (n == 0) - return; + return; ip = (struct permitted_ip *) malloc((n + 1) * sizeof(struct permitted_ip)); if (ip == 0) - return; + return; /* temporarily append the noauth_addrs list to addrs */ for (plink = &addrs; *plink != NULL; plink = &(*plink)->next) - ; + ; *plink = noauth_addrs; n = 0; for (ap = addrs; ap != NULL; ap = ap->next) { - /* "-" means no addresses authorized, "*" means any address allowed */ - ptr_word = ap->word; - if (strcmp(ptr_word, "-") == 0) - break; - if (strcmp(ptr_word, "*") == 0) { - ip[n].permit = 1; - ip[n].base = ip[n].mask = 0; - ++n; - break; - } - - ip[n].permit = 1; - if (*ptr_word == '!') { - ip[n].permit = 0; - ++ptr_word; - } - - mask = ~ (u32_t) 0; - offset = 0; - ptr_mask = strchr (ptr_word, '/'); - if (ptr_mask != NULL) { - int bit_count; - char *endp; - - bit_count = (int) strtol (ptr_mask+1, &endp, 10); - if (bit_count <= 0 || bit_count > 32) { - ppp_warn("invalid address length %v in auth. address list", - ptr_mask+1); - continue; - } - bit_count = 32 - bit_count; /* # bits in host part */ - if (*endp == '+') { - offset = ifunit + 1; - ++endp; - } - if (*endp != 0) { - ppp_warn("invalid address length syntax: %v", ptr_mask+1); - continue; - } - *ptr_mask = '\0'; - mask <<= bit_count; - } - - hp = gethostbyname(ptr_word); - if (hp != NULL && hp->h_addrtype == AF_INET) { - a = *(u32_t *)hp->h_addr; - } else { - np = getnetbyname (ptr_word); - if (np != NULL && np->n_addrtype == AF_INET) { - a = lwip_htonl ((u32_t)np->n_net); - if (ptr_mask == NULL) { - /* calculate appropriate mask for net */ - ah = lwip_ntohl(a); - if (IN_CLASSA(ah)) - mask = IN_CLASSA_NET; - else if (IN_CLASSB(ah)) - mask = IN_CLASSB_NET; - else if (IN_CLASSC(ah)) - mask = IN_CLASSC_NET; - } - } else { - a = inet_addr (ptr_word); - } - } - - if (ptr_mask != NULL) - *ptr_mask = '/'; - - if (a == (u32_t)-1L) { - ppp_warn("unknown host %s in auth. address list", ap->word); - continue; - } - if (offset != 0) { - if (offset >= ~mask) { - ppp_warn("interface unit %d too large for subnet %v", - ifunit, ptr_word); - continue; - } - a = lwip_htonl((lwip_ntohl(a) & mask) + offset); - mask = ~(u32_t)0; - } - ip[n].mask = lwip_htonl(mask); - ip[n].base = a & ip[n].mask; - ++n; - if (~mask == 0 && suggested_ip == 0) - suggested_ip = a; + /* "-" means no addresses authorized, "*" means any address allowed */ + ptr_word = ap->word; + if (strcmp(ptr_word, "-") == 0) + break; + if (strcmp(ptr_word, "*") == 0) { + ip[n].permit = 1; + ip[n].base = ip[n].mask = 0; + ++n; + break; + } + + ip[n].permit = 1; + if (*ptr_word == '!') { + ip[n].permit = 0; + ++ptr_word; + } + + mask = ~ (u32_t) 0; + offset = 0; + ptr_mask = strchr (ptr_word, '/'); + if (ptr_mask != NULL) { + int bit_count; + char *endp; + + bit_count = (int) strtol (ptr_mask+1, &endp, 10); + if (bit_count <= 0 || bit_count > 32) { + ppp_warn("invalid address length %v in auth. address list", + ptr_mask+1); + continue; + } + bit_count = 32 - bit_count; /* # bits in host part */ + if (*endp == '+') { + offset = ifunit + 1; + ++endp; + } + if (*endp != 0) { + ppp_warn("invalid address length syntax: %v", ptr_mask+1); + continue; + } + *ptr_mask = '\0'; + mask <<= bit_count; + } + + hp = gethostbyname(ptr_word); + if (hp != NULL && hp->h_addrtype == AF_INET) { + a = *(u32_t *)hp->h_addr; + } else { + np = getnetbyname (ptr_word); + if (np != NULL && np->n_addrtype == AF_INET) { + a = lwip_htonl ((u32_t)np->n_net); + if (ptr_mask == NULL) { + /* calculate appropriate mask for net */ + ah = lwip_ntohl(a); + if (IN_CLASSA(ah)) + mask = IN_CLASSA_NET; + else if (IN_CLASSB(ah)) + mask = IN_CLASSB_NET; + else if (IN_CLASSC(ah)) + mask = IN_CLASSC_NET; + } + } else { + a = inet_addr (ptr_word); + } + } + + if (ptr_mask != NULL) + *ptr_mask = '/'; + + if (a == (u32_t)-1L) { + ppp_warn("unknown host %s in auth. address list", ap->word); + continue; + } + if (offset != 0) { + if (offset >= ~mask) { + ppp_warn("interface unit %d too large for subnet %v", + ifunit, ptr_word); + continue; + } + a = lwip_htonl((lwip_ntohl(a) & mask) + offset); + mask = ~(u32_t)0; + } + ip[n].mask = lwip_htonl(mask); + ip[n].base = a & ip[n].mask; + ++n; + if (~mask == 0 && suggested_ip == 0) + suggested_ip = a; } *plink = NULL; - ip[n].permit = 0; /* make the last entry forbid all addresses */ - ip[n].base = 0; /* to terminate the list */ + ip[n].permit = 0; /* make the last entry forbid all addresses */ + ip[n].base = 0; /* to terminate the list */ ip[n].mask = 0; addresses[unit] = ip; @@ -2173,14 +2173,14 @@ set_allowed_addrs(unit, addrs, opts) * which is a single host, then use that if we find one. */ if (suggested_ip != 0 - && (wo->hisaddr == 0 || !auth_ip_addr(unit, wo->hisaddr))) { - wo->hisaddr = suggested_ip; - /* - * Do we insist on this address? No, if there are other - * addresses authorized than the suggested one. - */ - if (n > 1) - wo->accept_remote = 1; + && (wo->hisaddr == 0 || !auth_ip_addr(unit, wo->hisaddr))) { + wo->hisaddr = suggested_ip; + /* + * Do we insist on this address? No, if there are other + * addresses authorized than the suggested one. + */ + if (n > 1) + wo->accept_remote = 1; } } @@ -2197,21 +2197,21 @@ auth_ip_addr(unit, addr) /* don't allow loopback or multicast address */ if (bad_ip_adrs(addr)) - return 0; + return 0; if (allowed_address_hook) { - ok = allowed_address_hook(addr); - if (ok >= 0) return ok; + ok = allowed_address_hook(addr); + if (ok >= 0) return ok; } if (addresses[unit] != NULL) { - ok = ip_addr_check(addr, addresses[unit]); - if (ok >= 0) - return ok; + ok = ip_addr_check(addr, addresses[unit]); + if (ok >= 0) + return ok; } if (auth_required) - return 0; /* no addresses authorized */ + return 0; /* no addresses authorized */ return allow_any_ip || privileged || !have_route_to(addr); } @@ -2221,8 +2221,8 @@ ip_addr_check(addr, addrs) struct permitted_ip *addrs; { for (; ; ++addrs) - if ((addr & addrs->mask) == addrs->base) - return addrs->permit; + if ((addr & addrs->mask) == addrs->base) + return addrs->permit; } /* @@ -2236,7 +2236,7 @@ bad_ip_adrs(addr) { addr = lwip_ntohl(addr); return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET - || IN_MULTICAST(addr) || IN_BADCLASS(addr); + || IN_MULTICAST(addr) || IN_BADCLASS(addr); } /* @@ -2248,10 +2248,10 @@ some_ip_ok(addrs) struct wordlist *addrs; { for (; addrs != 0; addrs = addrs->next) { - if (addrs->word[0] == '-') - break; - if (addrs->word[0] != '!') - return 1; /* some IP address is allowed */ + if (addrs->word[0] == '-') + break; + if (addrs->word[0] != '!') + return 1; /* some IP address is allowed */ } return 0; } @@ -2268,17 +2268,17 @@ auth_number() /* Allow all if no authorization list. */ if (!wp) - return 1; + return 1; /* Allow if we have a match in the authorization list. */ while (wp) { - /* trailing '*' wildcard */ - l = strlen(wp->word); - if ((wp->word)[l - 1] == '*') - l--; - if (!strncasecmp(wp->word, remote_number, l)) - return 1; - wp = wp->next; + /* trailing '*' wildcard */ + l = strlen(wp->word); + if ((wp->word)[l - 1] == '*') + l--; + if (!strncasecmp(wp->word, remote_number, l)) + return 1; + wp = wp->next; } return 0; @@ -2295,10 +2295,10 @@ check_access(f, filename) struct stat sbuf; if (fstat(fileno(f), &sbuf) < 0) { - ppp_warn("cannot stat secret file %s: %m", filename); + ppp_warn("cannot stat secret file %s: %m", filename); } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) { - ppp_warn("Warning - secret file %s has world and/or group access", - filename); + ppp_warn("Warning - secret file %s has world and/or group access", + filename); } } @@ -2337,141 +2337,141 @@ scan_authfile(f, client, server, secret, addrs, opts, filename, flags) char *cp; if (addrs != NULL) - *addrs = NULL; + *addrs = NULL; if (opts != NULL) - *opts = NULL; + *opts = NULL; addr_list = NULL; if (!getword(f, word, &newline, filename)) - return -1; /* file is empty??? */ + return -1; /* file is empty??? */ newline = 1; best_flag = -1; for (;;) { - /* - * Skip until we find a word at the start of a line. - */ - while (!newline && getword(f, word, &newline, filename)) - ; - if (!newline) - break; /* got to end of file */ - - /* - * Got a client - check if it's a match or a wildcard. - */ - got_flag = 0; - if (client != NULL && strcmp(word, client) != 0 && !ISWILD(word)) { - newline = 0; - continue; - } - if (!ISWILD(word)) - got_flag = NONWILD_CLIENT; - - /* - * Now get a server and check if it matches. - */ - if (!getword(f, word, &newline, filename)) - break; - if (newline) - continue; - if (!ISWILD(word)) { - if (server != NULL && strcmp(word, server) != 0) - continue; - got_flag |= NONWILD_SERVER; - } - - /* - * Got some sort of a match - see if it's better than what - * we have already. - */ - if (got_flag <= best_flag) - continue; - - /* - * Get the secret. - */ - if (!getword(f, word, &newline, filename)) - break; - if (newline) - continue; - - /* - * SRP-SHA1 authenticator should never be reading secrets from - * a file. (Authenticatee may, though.) - */ - if (flags && ((cp = strchr(word, ':')) == NULL || - strchr(cp + 1, ':') == NULL)) - continue; - - if (secret != NULL) { - /* - * Special syntax: @/pathname means read secret from file. - */ - if (word[0] == '@' && word[1] == '/') { - strlcpy(atfile, word+1, sizeof(atfile)); - if ((sf = fopen(atfile, "r")) == NULL) { - ppp_warn("can't open indirect secret file %s", atfile); - continue; - } - check_access(sf, atfile); - if (!getword(sf, word, &xxx, atfile)) { - ppp_warn("no secret in indirect secret file %s", atfile); - fclose(sf); - continue; - } - fclose(sf); - } - strlcpy(lsecret, word, sizeof(lsecret)); - } - - /* - * Now read address authorization info and make a wordlist. - */ - app = &alist; - for (;;) { - if (!getword(f, word, &newline, filename) || newline) - break; - ap = (struct wordlist *) - malloc(sizeof(struct wordlist) + strlen(word) + 1); - if (ap == NULL) - novm("authorized addresses"); - ap->word = (char *) (ap + 1); - strcpy(ap->word, word); - *app = ap; - app = &ap->next; - } - *app = NULL; - - /* - * This is the best so far; remember it. - */ - best_flag = got_flag; - if (addr_list) - free_wordlist(addr_list); - addr_list = alist; - if (secret != NULL) - strlcpy(secret, lsecret, MAXWORDLEN); - - if (!newline) - break; + /* + * Skip until we find a word at the start of a line. + */ + while (!newline && getword(f, word, &newline, filename)) + ; + if (!newline) + break; /* got to end of file */ + + /* + * Got a client - check if it's a match or a wildcard. + */ + got_flag = 0; + if (client != NULL && strcmp(word, client) != 0 && !ISWILD(word)) { + newline = 0; + continue; + } + if (!ISWILD(word)) + got_flag = NONWILD_CLIENT; + + /* + * Now get a server and check if it matches. + */ + if (!getword(f, word, &newline, filename)) + break; + if (newline) + continue; + if (!ISWILD(word)) { + if (server != NULL && strcmp(word, server) != 0) + continue; + got_flag |= NONWILD_SERVER; + } + + /* + * Got some sort of a match - see if it's better than what + * we have already. + */ + if (got_flag <= best_flag) + continue; + + /* + * Get the secret. + */ + if (!getword(f, word, &newline, filename)) + break; + if (newline) + continue; + + /* + * SRP-SHA1 authenticator should never be reading secrets from + * a file. (Authenticatee may, though.) + */ + if (flags && ((cp = strchr(word, ':')) == NULL || + strchr(cp + 1, ':') == NULL)) + continue; + + if (secret != NULL) { + /* + * Special syntax: @/pathname means read secret from file. + */ + if (word[0] == '@' && word[1] == '/') { + strlcpy(atfile, word+1, sizeof(atfile)); + if ((sf = fopen(atfile, "r")) == NULL) { + ppp_warn("can't open indirect secret file %s", atfile); + continue; + } + check_access(sf, atfile); + if (!getword(sf, word, &xxx, atfile)) { + ppp_warn("no secret in indirect secret file %s", atfile); + fclose(sf); + continue; + } + fclose(sf); + } + strlcpy(lsecret, word, sizeof(lsecret)); + } + + /* + * Now read address authorization info and make a wordlist. + */ + app = &alist; + for (;;) { + if (!getword(f, word, &newline, filename) || newline) + break; + ap = (struct wordlist *) + malloc(sizeof(struct wordlist) + strlen(word) + 1); + if (ap == NULL) + novm("authorized addresses"); + ap->word = (char *) (ap + 1); + strcpy(ap->word, word); + *app = ap; + app = &ap->next; + } + *app = NULL; + + /* + * This is the best so far; remember it. + */ + best_flag = got_flag; + if (addr_list) + free_wordlist(addr_list); + addr_list = alist; + if (secret != NULL) + strlcpy(secret, lsecret, MAXWORDLEN); + + if (!newline) + break; } /* scan for a -- word indicating the start of options */ for (app = &addr_list; (ap = *app) != NULL; app = &ap->next) - if (strcmp(ap->word, "--") == 0) - break; + if (strcmp(ap->word, "--") == 0) + break; /* ap = start of options */ if (ap != NULL) { - ap = ap->next; /* first option */ - free(*app); /* free the "--" word */ - *app = NULL; /* terminate addr list */ + ap = ap->next; /* first option */ + free(*app); /* free the "--" word */ + *app = NULL; /* terminate addr list */ } if (opts != NULL) - *opts = ap; + *opts = ap; else if (ap != NULL) - free_wordlist(ap); + free_wordlist(ap); if (addrs != NULL) - *addrs = addr_list; + *addrs = addr_list; else if (addr_list != NULL) - free_wordlist(addr_list); + free_wordlist(addr_list); return best_flag; } @@ -2486,7 +2486,7 @@ wordlist_count(wp) int n; for (n = 0; wp != NULL; wp = wp->next) - ++n; + ++n; return n; } @@ -2500,9 +2500,9 @@ free_wordlist(wp) struct wordlist *next; while (wp != NULL) { - next = wp->next; - free(wp); - wp = next; + next = wp->next; + free(wp); + wp = next; } } #endif /* UNUSED */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/ccp.c b/components/net/lwip-2.0.2/src/netif/ppp/ccp.c index f8519ebece..5e5b75c361 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/ccp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/ccp.c @@ -40,8 +40,8 @@ #include "netif/ppp/ccp.h" #if MPPE_SUPPORT -#include "netif/ppp/lcp.h" /* lcp_close(), lcp_fsm */ -#include "netif/ppp/mppe.h" /* mppe_init() */ +#include "netif/ppp/lcp.h" /* lcp_close(), lcp_fsm */ +#include "netif/ppp/mppe.h" /* mppe_init() */ #endif /* MPPE_SUPPORT */ /* @@ -51,7 +51,7 @@ * Until this is fixed we only accept sizes in the range 9 .. 15. * Thanks to James Carlson for pointing this out. */ -#define DEFLATE_MIN_WORKS 9 +#define DEFLATE_MIN_WORKS 9 /* * Command-line options. @@ -66,7 +66,7 @@ static char deflate_value[8]; * Option variables. */ #if MPPE_SUPPORT -bool refuse_mppe_stateful = 1; /* Allow stateful mode? */ +bool refuse_mppe_stateful = 1; /* Allow stateful mode? */ #endif /* MPPE_SUPPORT */ static option_t ccp_option_list[] = { @@ -248,27 +248,27 @@ static const fsm_callbacks ccp_callbacks = { static int ccp_anycompress(ccp_options *opt) { return (0 #if DEFLATE_SUPPORT - || (opt)->deflate + || (opt)->deflate #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - || (opt)->bsd_compress + || (opt)->bsd_compress #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - || (opt)->predictor_1 || (opt)->predictor_2 + || (opt)->predictor_1 || (opt)->predictor_2 #endif /* PREDICTOR_SUPPORT */ #if MPPE_SUPPORT - || (opt)->mppe + || (opt)->mppe #endif /* MPPE_SUPPORT */ - ); + ); } /* * Local state (mainly for handling reset-reqs and reset-acks). */ -#define RACK_PENDING 1 /* waiting for reset-ack */ -#define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */ +#define RACK_PENDING 1 /* waiting for reset-ack */ +#define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */ -#define RACKTIMEOUT 1 /* second */ +#define RACKTIMEOUT 1 /* second */ #if PPP_OPTIONS /* @@ -284,31 +284,31 @@ setbsdcomp(argv) str = *argv; abits = rbits = strtol(str, &endp, 0); if (endp != str && *endp == ',') { - str = endp + 1; - abits = strtol(str, &endp, 0); + str = endp + 1; + abits = strtol(str, &endp, 0); } if (*endp != 0 || endp == str) { - option_error("invalid parameter '%s' for bsdcomp option", *argv); - return 0; + option_error("invalid parameter '%s' for bsdcomp option", *argv); + return 0; } if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS)) - || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) { - option_error("bsdcomp option values must be 0 or %d .. %d", - BSD_MIN_BITS, BSD_MAX_BITS); - return 0; + || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) { + option_error("bsdcomp option values must be 0 or %d .. %d", + BSD_MIN_BITS, BSD_MAX_BITS); + return 0; } if (rbits > 0) { - ccp_wantoptions[0].bsd_compress = 1; - ccp_wantoptions[0].bsd_bits = rbits; + ccp_wantoptions[0].bsd_compress = 1; + ccp_wantoptions[0].bsd_bits = rbits; } else - ccp_wantoptions[0].bsd_compress = 0; + ccp_wantoptions[0].bsd_compress = 0; if (abits > 0) { - ccp_allowoptions[0].bsd_compress = 1; - ccp_allowoptions[0].bsd_bits = abits; + ccp_allowoptions[0].bsd_compress = 1; + ccp_allowoptions[0].bsd_bits = abits; } else - ccp_allowoptions[0].bsd_compress = 0; + ccp_allowoptions[0].bsd_compress = 0; ppp_slprintf(bsd_value, sizeof(bsd_value), - rbits == abits? "%d": "%d,%d", rbits, abits); + rbits == abits? "%d": "%d,%d", rbits, abits); return 1; } @@ -323,40 +323,40 @@ setdeflate(argv) str = *argv; abits = rbits = strtol(str, &endp, 0); if (endp != str && *endp == ',') { - str = endp + 1; - abits = strtol(str, &endp, 0); + str = endp + 1; + abits = strtol(str, &endp, 0); } if (*endp != 0 || endp == str) { - option_error("invalid parameter '%s' for deflate option", *argv); - return 0; + option_error("invalid parameter '%s' for deflate option", *argv); + return 0; } if ((rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE)) - || (abits != 0 && (abits < DEFLATE_MIN_SIZE - || abits > DEFLATE_MAX_SIZE))) { - option_error("deflate option values must be 0 or %d .. %d", - DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE); - return 0; + || (abits != 0 && (abits < DEFLATE_MIN_SIZE + || abits > DEFLATE_MAX_SIZE))) { + option_error("deflate option values must be 0 or %d .. %d", + DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE); + return 0; } if (rbits == DEFLATE_MIN_SIZE || abits == DEFLATE_MIN_SIZE) { - if (rbits == DEFLATE_MIN_SIZE) - rbits = DEFLATE_MIN_WORKS; - if (abits == DEFLATE_MIN_SIZE) - abits = DEFLATE_MIN_WORKS; - warn("deflate option value of %d changed to %d to avoid zlib bug", - DEFLATE_MIN_SIZE, DEFLATE_MIN_WORKS); + if (rbits == DEFLATE_MIN_SIZE) + rbits = DEFLATE_MIN_WORKS; + if (abits == DEFLATE_MIN_SIZE) + abits = DEFLATE_MIN_WORKS; + warn("deflate option value of %d changed to %d to avoid zlib bug", + DEFLATE_MIN_SIZE, DEFLATE_MIN_WORKS); } if (rbits > 0) { - ccp_wantoptions[0].deflate = 1; - ccp_wantoptions[0].deflate_size = rbits; + ccp_wantoptions[0].deflate = 1; + ccp_wantoptions[0].deflate_size = rbits; } else - ccp_wantoptions[0].deflate = 0; + ccp_wantoptions[0].deflate = 0; if (abits > 0) { - ccp_allowoptions[0].deflate = 1; - ccp_allowoptions[0].deflate_size = abits; + ccp_allowoptions[0].deflate = 1; + ccp_allowoptions[0].deflate_size = abits; } else - ccp_allowoptions[0].deflate = 0; + ccp_allowoptions[0].deflate = 0; ppp_slprintf(deflate_value, sizeof(deflate_value), - rbits == abits? "%d": "%d,%d", rbits, abits); + rbits == abits? "%d": "%d,%d", rbits, abits); return 1; } @@ -411,7 +411,7 @@ static void ccp_open(ppp_pcb *pcb) { ccp_options *go = &pcb->ccp_gotoptions; if (f->state != PPP_FSM_OPENED) - ccp_set(pcb, 1, 0, 0, 0); + ccp_set(pcb, 1, 0, 0, 0); /* * Find out which compressors the kernel supports before @@ -419,7 +419,7 @@ static void ccp_open(ppp_pcb *pcb) { */ ccp_resetci(f); if (!ccp_anycompress(go)) - f->flags |= OPT_SILENT; + f->flags |= OPT_SILENT; fsm_open(f); } @@ -463,12 +463,12 @@ static void ccp_input(ppp_pcb *pcb, u_char *p, int len) { oldstate = f->state; fsm_input(f, p, len); if (oldstate == PPP_FSM_OPENED && p[0] == TERMREQ && f->state != PPP_FSM_OPENED) { - ppp_notice("Compression disabled by peer."); + ppp_notice("Compression disabled by peer."); #if MPPE_SUPPORT - if (go->mppe) { - ppp_error("MPPE disabled, closing LCP"); - lcp_close(pcb, "MPPE disabled by peer"); - } + if (go->mppe) { + ppp_error("MPPE disabled, closing LCP"); + lcp_close(pcb, "MPPE disabled by peer"); + } #endif /* MPPE_SUPPORT */ } @@ -477,8 +477,8 @@ static void ccp_input(ppp_pcb *pcb, u_char *p, int len) { * close CCP. */ if (oldstate == PPP_FSM_REQSENT && p[0] == TERMACK - && !ccp_anycompress(go)) - ccp_close(pcb, "No compression negotiated"); + && !ccp_anycompress(go)) + ccp_close(pcb, "No compression negotiated"); } /* @@ -491,24 +491,24 @@ static int ccp_extcode(fsm *f, int code, int id, u_char *p, int len) { switch (code) { case CCP_RESETREQ: - if (f->state != PPP_FSM_OPENED) - break; - ccp_reset_comp(pcb); - /* send a reset-ack, which the transmitter will see and - reset its compression state. */ - fsm_sdata(f, CCP_RESETACK, id, NULL, 0); - break; + if (f->state != PPP_FSM_OPENED) + break; + ccp_reset_comp(pcb); + /* send a reset-ack, which the transmitter will see and + reset its compression state. */ + fsm_sdata(f, CCP_RESETACK, id, NULL, 0); + break; case CCP_RESETACK: - if ((pcb->ccp_localstate & RACK_PENDING) && id == f->reqid) { - pcb->ccp_localstate &= ~(RACK_PENDING | RREQ_REPEAT); - UNTIMEOUT(ccp_rack_timeout, f); - ccp_reset_decomp(pcb); - } - break; + if ((pcb->ccp_localstate & RACK_PENDING) && id == f->reqid) { + pcb->ccp_localstate &= ~(RACK_PENDING | RREQ_REPEAT); + UNTIMEOUT(ccp_rack_timeout, f); + ccp_reset_decomp(pcb); + } + break; default: - return 0; + return 0; } return 1; @@ -528,8 +528,8 @@ static void ccp_protrej(ppp_pcb *pcb) { #if MPPE_SUPPORT if (go->mppe) { - ppp_error("MPPE required but peer negotiation failed"); - lcp_close(pcb, "MPPE required but peer negotiation failed"); + ppp_error("MPPE required but peer negotiation failed"); + lcp_close(pcb, "MPPE required but peer negotiation failed"); } #endif /* MPPE_SUPPORT */ @@ -554,9 +554,9 @@ static void ccp_resetci(fsm *f) { #if MPPE_SUPPORT if (pcb->settings.require_mppe) { - wo->mppe = ao->mppe = - (pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40) - | (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128); + wo->mppe = ao->mppe = + (pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40) + | (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128); } #endif /* MPPE_SUPPORT */ @@ -565,78 +565,78 @@ static void ccp_resetci(fsm *f) { #if MPPE_SUPPORT if (go->mppe) { - int auth_mschap_bits = pcb->auth_done; - int numbits; - - /* - * Start with a basic sanity check: mschap[v2] auth must be in - * exactly one direction. RFC 3079 says that the keys are - * 'derived from the credentials of the peer that initiated the call', - * however the PPP protocol doesn't have such a concept, and pppd - * cannot get this info externally. Instead we do the best we can. - * NB: If MPPE is required, all other compression opts are invalid. - * So, we return right away if we can't do it. - */ - - /* Leave only the mschap auth bits set */ - auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER | - CHAP_MS2_WITHPEER | CHAP_MS2_PEER); - /* Count the mschap auths */ - auth_mschap_bits >>= CHAP_MS_SHIFT; - numbits = 0; - do { - numbits += auth_mschap_bits & 1; - auth_mschap_bits >>= 1; - } while (auth_mschap_bits); - if (numbits > 1) { - ppp_error("MPPE required, but auth done in both directions."); - lcp_close(pcb, "MPPE required but not available"); - return; - } - if (!numbits) { - ppp_error("MPPE required, but MS-CHAP[v2] auth not performed."); - lcp_close(pcb, "MPPE required but not available"); - return; - } - - /* A plugin (eg radius) may not have obtained key material. */ - if (!pcb->mppe_keys_set) { - ppp_error("MPPE required, but keys are not available. " - "Possible plugin problem?"); - lcp_close(pcb, "MPPE required but not available"); - return; - } - - /* LM auth not supported for MPPE */ - if (pcb->auth_done & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) { - /* This might be noise */ - if (go->mppe & MPPE_OPT_40) { - ppp_notice("Disabling 40-bit MPPE; MS-CHAP LM not supported"); - go->mppe &= ~MPPE_OPT_40; - wo->mppe &= ~MPPE_OPT_40; - } - } - - /* Last check: can we actually negotiate something? */ - if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) { - /* Could be misconfig, could be 40-bit disabled above. */ - ppp_error("MPPE required, but both 40-bit and 128-bit disabled."); - lcp_close(pcb, "MPPE required but not available"); - return; - } - - /* sync options */ - ao->mppe = go->mppe; - /* MPPE is not compatible with other compression types */ + int auth_mschap_bits = pcb->auth_done; + int numbits; + + /* + * Start with a basic sanity check: mschap[v2] auth must be in + * exactly one direction. RFC 3079 says that the keys are + * 'derived from the credentials of the peer that initiated the call', + * however the PPP protocol doesn't have such a concept, and pppd + * cannot get this info externally. Instead we do the best we can. + * NB: If MPPE is required, all other compression opts are invalid. + * So, we return right away if we can't do it. + */ + + /* Leave only the mschap auth bits set */ + auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER | + CHAP_MS2_WITHPEER | CHAP_MS2_PEER); + /* Count the mschap auths */ + auth_mschap_bits >>= CHAP_MS_SHIFT; + numbits = 0; + do { + numbits += auth_mschap_bits & 1; + auth_mschap_bits >>= 1; + } while (auth_mschap_bits); + if (numbits > 1) { + ppp_error("MPPE required, but auth done in both directions."); + lcp_close(pcb, "MPPE required but not available"); + return; + } + if (!numbits) { + ppp_error("MPPE required, but MS-CHAP[v2] auth not performed."); + lcp_close(pcb, "MPPE required but not available"); + return; + } + + /* A plugin (eg radius) may not have obtained key material. */ + if (!pcb->mppe_keys_set) { + ppp_error("MPPE required, but keys are not available. " + "Possible plugin problem?"); + lcp_close(pcb, "MPPE required but not available"); + return; + } + + /* LM auth not supported for MPPE */ + if (pcb->auth_done & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) { + /* This might be noise */ + if (go->mppe & MPPE_OPT_40) { + ppp_notice("Disabling 40-bit MPPE; MS-CHAP LM not supported"); + go->mppe &= ~MPPE_OPT_40; + wo->mppe &= ~MPPE_OPT_40; + } + } + + /* Last check: can we actually negotiate something? */ + if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) { + /* Could be misconfig, could be 40-bit disabled above. */ + ppp_error("MPPE required, but both 40-bit and 128-bit disabled."); + lcp_close(pcb, "MPPE required but not available"); + return; + } + + /* sync options */ + ao->mppe = go->mppe; + /* MPPE is not compatible with other compression types */ #if BSDCOMPRESS_SUPPORT - ao->bsd_compress = go->bsd_compress = 0; + ao->bsd_compress = go->bsd_compress = 0; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - ao->predictor_1 = go->predictor_1 = 0; - ao->predictor_2 = go->predictor_2 = 0; + ao->predictor_1 = go->predictor_1 = 0; + ao->predictor_2 = go->predictor_2 = 0; #endif /* PREDICTOR_SUPPORT */ #if DEFLATE_SUPPORT - ao->deflate = go->deflate = 0; + ao->deflate = go->deflate = 0; #endif /* DEFLATE_SUPPORT */ } #endif /* MPPE_SUPPORT */ @@ -650,23 +650,23 @@ static void ccp_resetci(fsm *f) { * if BSDCOMPRESS_SUPPORT is set, it is. */ if (go->bsd_compress) { - opt_buf[0] = CI_BSD_COMPRESS; - opt_buf[1] = CILEN_BSD_COMPRESS; - for (;;) { - if (go->bsd_bits < BSD_MIN_BITS) { - go->bsd_compress = 0; - break; - } - opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); - res = ccp_test(pcb, opt_buf, CILEN_BSD_COMPRESS, 0); - if (res > 0) { - break; - } else if (res < 0) { - go->bsd_compress = 0; - break; - } - go->bsd_bits--; - } + opt_buf[0] = CI_BSD_COMPRESS; + opt_buf[1] = CILEN_BSD_COMPRESS; + for (;;) { + if (go->bsd_bits < BSD_MIN_BITS) { + go->bsd_compress = 0; + break; + } + opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); + res = ccp_test(pcb, opt_buf, CILEN_BSD_COMPRESS, 0); + if (res > 0) { + break; + } else if (res < 0) { + go->bsd_compress = 0; + break; + } + go->bsd_bits--; + } } #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT @@ -674,48 +674,48 @@ static void ccp_resetci(fsm *f) { * if DEFLATE_SUPPORT is set, it is. */ if (go->deflate) { - if (go->deflate_correct) { - opt_buf[0] = CI_DEFLATE; - opt_buf[1] = CILEN_DEFLATE; - opt_buf[3] = DEFLATE_CHK_SEQUENCE; - for (;;) { - if (go->deflate_size < DEFLATE_MIN_WORKS) { - go->deflate_correct = 0; - break; - } - opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); - res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); - if (res > 0) { - break; - } else if (res < 0) { - go->deflate_correct = 0; - break; - } - go->deflate_size--; - } - } - if (go->deflate_draft) { - opt_buf[0] = CI_DEFLATE_DRAFT; - opt_buf[1] = CILEN_DEFLATE; - opt_buf[3] = DEFLATE_CHK_SEQUENCE; - for (;;) { - if (go->deflate_size < DEFLATE_MIN_WORKS) { - go->deflate_draft = 0; - break; - } - opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); - res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); - if (res > 0) { - break; - } else if (res < 0) { - go->deflate_draft = 0; - break; - } - go->deflate_size--; - } - } - if (!go->deflate_correct && !go->deflate_draft) - go->deflate = 0; + if (go->deflate_correct) { + opt_buf[0] = CI_DEFLATE; + opt_buf[1] = CILEN_DEFLATE; + opt_buf[3] = DEFLATE_CHK_SEQUENCE; + for (;;) { + if (go->deflate_size < DEFLATE_MIN_WORKS) { + go->deflate_correct = 0; + break; + } + opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); + res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); + if (res > 0) { + break; + } else if (res < 0) { + go->deflate_correct = 0; + break; + } + go->deflate_size--; + } + } + if (go->deflate_draft) { + opt_buf[0] = CI_DEFLATE_DRAFT; + opt_buf[1] = CILEN_DEFLATE; + opt_buf[3] = DEFLATE_CHK_SEQUENCE; + for (;;) { + if (go->deflate_size < DEFLATE_MIN_WORKS) { + go->deflate_draft = 0; + break; + } + opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); + res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); + if (res > 0) { + break; + } else if (res < 0) { + go->deflate_draft = 0; + break; + } + go->deflate_size--; + } + } + if (!go->deflate_correct && !go->deflate_draft) + go->deflate = 0; } #endif /* DEFLATE_SUPPORT */ #if PREDICTOR_SUPPORT @@ -723,16 +723,16 @@ static void ccp_resetci(fsm *f) { * if PREDICTOR_SUPPORT is set, it is. */ if (go->predictor_1) { - opt_buf[0] = CI_PREDICTOR_1; - opt_buf[1] = CILEN_PREDICTOR_1; - if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_1, 0) <= 0) - go->predictor_1 = 0; + opt_buf[0] = CI_PREDICTOR_1; + opt_buf[1] = CILEN_PREDICTOR_1; + if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_1, 0) <= 0) + go->predictor_1 = 0; } if (go->predictor_2) { - opt_buf[0] = CI_PREDICTOR_2; - opt_buf[1] = CILEN_PREDICTOR_2; - if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_2, 0) <= 0) - go->predictor_2 = 0; + opt_buf[0] = CI_PREDICTOR_2; + opt_buf[1] = CILEN_PREDICTOR_2; + if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_2, 0) <= 0) + go->predictor_2 = 0; } #endif /* PREDICTOR_SUPPORT */ } @@ -746,20 +746,20 @@ static int ccp_cilen(fsm *f) { return 0 #if BSDCOMPRESS_SUPPORT - + (go->bsd_compress? CILEN_BSD_COMPRESS: 0) + + (go->bsd_compress? CILEN_BSD_COMPRESS: 0) #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT - + (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0) - + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0) + + (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0) + + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0) #endif /* DEFLATE_SUPPORT */ #if PREDICTOR_SUPPORT - + (go->predictor_1? CILEN_PREDICTOR_1: 0) - + (go->predictor_2? CILEN_PREDICTOR_2: 0) + + (go->predictor_1? CILEN_PREDICTOR_1: 0) + + (go->predictor_2? CILEN_PREDICTOR_2: 0) #endif /* PREDICTOR_SUPPORT */ #if MPPE_SUPPORT - + (go->mppe? CILEN_MPPE: 0) + + (go->mppe? CILEN_MPPE: 0) #endif /* MPPE_SUPPORT */ - ; + ; } /* @@ -776,50 +776,50 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) { */ #if MPPE_SUPPORT if (go->mppe) { - p[0] = CI_MPPE; - p[1] = CILEN_MPPE; - MPPE_OPTS_TO_CI(go->mppe, &p[2]); - mppe_init(pcb, &pcb->mppe_decomp, go->mppe); - p += CILEN_MPPE; + p[0] = CI_MPPE; + p[1] = CILEN_MPPE; + MPPE_OPTS_TO_CI(go->mppe, &p[2]); + mppe_init(pcb, &pcb->mppe_decomp, go->mppe); + p += CILEN_MPPE; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate) { - if (go->deflate_correct) { - p[0] = CI_DEFLATE; - p[1] = CILEN_DEFLATE; - p[2] = DEFLATE_MAKE_OPT(go->deflate_size); - p[3] = DEFLATE_CHK_SEQUENCE; - p += CILEN_DEFLATE; - } - if (go->deflate_draft) { - p[0] = CI_DEFLATE_DRAFT; - p[1] = CILEN_DEFLATE; - p[2] = p[2 - CILEN_DEFLATE]; - p[3] = DEFLATE_CHK_SEQUENCE; - p += CILEN_DEFLATE; - } + if (go->deflate_correct) { + p[0] = CI_DEFLATE; + p[1] = CILEN_DEFLATE; + p[2] = DEFLATE_MAKE_OPT(go->deflate_size); + p[3] = DEFLATE_CHK_SEQUENCE; + p += CILEN_DEFLATE; + } + if (go->deflate_draft) { + p[0] = CI_DEFLATE_DRAFT; + p[1] = CILEN_DEFLATE; + p[2] = p[2 - CILEN_DEFLATE]; + p[3] = DEFLATE_CHK_SEQUENCE; + p += CILEN_DEFLATE; + } } #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress) { - p[0] = CI_BSD_COMPRESS; - p[1] = CILEN_BSD_COMPRESS; - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); - p += CILEN_BSD_COMPRESS; + p[0] = CI_BSD_COMPRESS; + p[1] = CILEN_BSD_COMPRESS; + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); + p += CILEN_BSD_COMPRESS; } #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT /* XXX Should Predictor 2 be preferable to Predictor 1? */ if (go->predictor_1) { - p[0] = CI_PREDICTOR_1; - p[1] = CILEN_PREDICTOR_1; - p += CILEN_PREDICTOR_1; + p[0] = CI_PREDICTOR_1; + p[1] = CILEN_PREDICTOR_1; + p += CILEN_PREDICTOR_1; } if (go->predictor_2) { - p[0] = CI_PREDICTOR_2; - p[1] = CILEN_PREDICTOR_2; - p += CILEN_PREDICTOR_2; + p[0] = CI_PREDICTOR_2; + p[1] = CILEN_PREDICTOR_2; + p += CILEN_PREDICTOR_2; } #endif /* PREDICTOR_SUPPORT */ @@ -841,83 +841,83 @@ static int ccp_ackci(fsm *f, u_char *p, int len) { #if MPPE_SUPPORT if (go->mppe) { - u_char opt_buf[CILEN_MPPE]; - - opt_buf[0] = CI_MPPE; - opt_buf[1] = CILEN_MPPE; - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); - if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE)) - return 0; - p += CILEN_MPPE; - len -= CILEN_MPPE; - /* XXX Cope with first/fast ack */ - if (len == 0) - return 1; + u_char opt_buf[CILEN_MPPE]; + + opt_buf[0] = CI_MPPE; + opt_buf[1] = CILEN_MPPE; + MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); + if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE)) + return 0; + p += CILEN_MPPE; + len -= CILEN_MPPE; + /* XXX Cope with first/fast ack */ + if (len == 0) + return 1; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate) { - if (len < CILEN_DEFLATE - || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) - || p[1] != CILEN_DEFLATE - || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - /* XXX Cope with first/fast ack */ - if (len == 0) - return 1; - if (go->deflate_correct && go->deflate_draft) { - if (len < CILEN_DEFLATE - || p[0] != CI_DEFLATE_DRAFT - || p[1] != CILEN_DEFLATE - || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - } + if (len < CILEN_DEFLATE + || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) + || p[1] != CILEN_DEFLATE + || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + /* XXX Cope with first/fast ack */ + if (len == 0) + return 1; + if (go->deflate_correct && go->deflate_draft) { + if (len < CILEN_DEFLATE + || p[0] != CI_DEFLATE_DRAFT + || p[1] != CILEN_DEFLATE + || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + } } #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress) { - if (len < CILEN_BSD_COMPRESS - || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS - || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) - return 0; - p += CILEN_BSD_COMPRESS; - len -= CILEN_BSD_COMPRESS; - /* XXX Cope with first/fast ack */ - if (p == p0 && len == 0) - return 1; + if (len < CILEN_BSD_COMPRESS + || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS + || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) + return 0; + p += CILEN_BSD_COMPRESS; + len -= CILEN_BSD_COMPRESS; + /* XXX Cope with first/fast ack */ + if (p == p0 && len == 0) + return 1; } #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT if (go->predictor_1) { - if (len < CILEN_PREDICTOR_1 - || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1) - return 0; - p += CILEN_PREDICTOR_1; - len -= CILEN_PREDICTOR_1; - /* XXX Cope with first/fast ack */ - if (p == p0 && len == 0) - return 1; + if (len < CILEN_PREDICTOR_1 + || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1) + return 0; + p += CILEN_PREDICTOR_1; + len -= CILEN_PREDICTOR_1; + /* XXX Cope with first/fast ack */ + if (p == p0 && len == 0) + return 1; } if (go->predictor_2) { - if (len < CILEN_PREDICTOR_2 - || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2) - return 0; - p += CILEN_PREDICTOR_2; - len -= CILEN_PREDICTOR_2; - /* XXX Cope with first/fast ack */ - if (p == p0 && len == 0) - return 1; + if (len < CILEN_PREDICTOR_2 + || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2) + return 0; + p += CILEN_PREDICTOR_2; + len -= CILEN_PREDICTOR_2; + /* XXX Cope with first/fast ack */ + if (p == p0 && len == 0) + return 1; } #endif /* PREDICTOR_SUPPORT */ if (len != 0) - return 0; + return 0; return 1; } @@ -928,8 +928,8 @@ static int ccp_ackci(fsm *f, u_char *p, int len) { static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; ccp_options *go = &pcb->ccp_gotoptions; - ccp_options no; /* options we've seen already */ - ccp_options try_; /* options to ask for next time */ + ccp_options no; /* options we've seen already */ + ccp_options try_; /* options to ask for next time */ LWIP_UNUSED_ARG(treat_as_reject); #if !MPPE_SUPPORT && !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT LWIP_UNUSED_ARG(p); @@ -941,66 +941,66 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { #if MPPE_SUPPORT if (go->mppe && len >= CILEN_MPPE - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { - no.mppe = 1; - /* - * Peer wants us to use a different strength or other setting. - * Fail if we aren't willing to use his suggestion. - */ - MPPE_CI_TO_OPTS(&p[2], try_.mppe); - if ((try_.mppe & MPPE_OPT_STATEFUL) && pcb->settings.refuse_mppe_stateful) { - ppp_error("Refusing MPPE stateful mode offered by peer"); - try_.mppe = 0; - } else if (((go->mppe | MPPE_OPT_STATEFUL) & try_.mppe) != try_.mppe) { - /* Peer must have set options we didn't request (suggest) */ - try_.mppe = 0; - } - - if (!try_.mppe) { - ppp_error("MPPE required but peer negotiation failed"); - lcp_close(pcb, "MPPE required but peer negotiation failed"); - } + && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { + no.mppe = 1; + /* + * Peer wants us to use a different strength or other setting. + * Fail if we aren't willing to use his suggestion. + */ + MPPE_CI_TO_OPTS(&p[2], try_.mppe); + if ((try_.mppe & MPPE_OPT_STATEFUL) && pcb->settings.refuse_mppe_stateful) { + ppp_error("Refusing MPPE stateful mode offered by peer"); + try_.mppe = 0; + } else if (((go->mppe | MPPE_OPT_STATEFUL) & try_.mppe) != try_.mppe) { + /* Peer must have set options we didn't request (suggest) */ + try_.mppe = 0; + } + + if (!try_.mppe) { + ppp_error("MPPE required but peer negotiation failed"); + lcp_close(pcb, "MPPE required but peer negotiation failed"); + } } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate && len >= CILEN_DEFLATE - && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) - && p[1] == CILEN_DEFLATE) { - no.deflate = 1; - /* - * Peer wants us to use a different code size or something. - * Stop asking for Deflate if we don't understand his suggestion. - */ - if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL - || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_WORKS - || p[3] != DEFLATE_CHK_SEQUENCE) - try_.deflate = 0; - else if (DEFLATE_SIZE(p[2]) < go->deflate_size) - try_.deflate_size = DEFLATE_SIZE(p[2]); - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - if (go->deflate_correct && go->deflate_draft - && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT - && p[1] == CILEN_DEFLATE) { - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - } + && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) + && p[1] == CILEN_DEFLATE) { + no.deflate = 1; + /* + * Peer wants us to use a different code size or something. + * Stop asking for Deflate if we don't understand his suggestion. + */ + if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL + || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_WORKS + || p[3] != DEFLATE_CHK_SEQUENCE) + try_.deflate = 0; + else if (DEFLATE_SIZE(p[2]) < go->deflate_size) + try_.deflate_size = DEFLATE_SIZE(p[2]); + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + if (go->deflate_correct && go->deflate_draft + && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT + && p[1] == CILEN_DEFLATE) { + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + } } #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress && len >= CILEN_BSD_COMPRESS - && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { - no.bsd_compress = 1; - /* - * Peer wants us to use a different number of bits - * or a different version. - */ - if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION) - try_.bsd_compress = 0; - else if (BSD_NBITS(p[2]) < go->bsd_bits) - try_.bsd_bits = BSD_NBITS(p[2]); - p += CILEN_BSD_COMPRESS; - len -= CILEN_BSD_COMPRESS; + && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { + no.bsd_compress = 1; + /* + * Peer wants us to use a different number of bits + * or a different version. + */ + if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION) + try_.bsd_compress = 0; + else if (BSD_NBITS(p[2]) < go->bsd_bits) + try_.bsd_bits = BSD_NBITS(p[2]); + p += CILEN_BSD_COMPRESS; + len -= CILEN_BSD_COMPRESS; } #endif /* BSDCOMPRESS_SUPPORT */ @@ -1011,7 +1011,7 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; } @@ -1021,7 +1021,7 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { static int ccp_rejci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; ccp_options *go = &pcb->ccp_gotoptions; - ccp_options try_; /* options to request next time */ + ccp_options try_; /* options to request next time */ try_ = *go; @@ -1030,69 +1030,69 @@ static int ccp_rejci(fsm *f, u_char *p, int len) { * configure-requests. */ if (len == 0 && pcb->ccp_all_rejected) - return -1; + return -1; #if MPPE_SUPPORT if (go->mppe && len >= CILEN_MPPE - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { - ppp_error("MPPE required but peer refused"); - lcp_close(pcb, "MPPE required but peer refused"); - p += CILEN_MPPE; - len -= CILEN_MPPE; + && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { + ppp_error("MPPE required but peer refused"); + lcp_close(pcb, "MPPE required but peer refused"); + p += CILEN_MPPE; + len -= CILEN_MPPE; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate_correct && len >= CILEN_DEFLATE - && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) { - if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; /* Rej is bad */ - try_.deflate_correct = 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; + && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) { + if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; /* Rej is bad */ + try_.deflate_correct = 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; } if (go->deflate_draft && len >= CILEN_DEFLATE - && p[0] == CI_DEFLATE_DRAFT && p[1] == CILEN_DEFLATE) { - if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; /* Rej is bad */ - try_.deflate_draft = 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; + && p[0] == CI_DEFLATE_DRAFT && p[1] == CILEN_DEFLATE) { + if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; /* Rej is bad */ + try_.deflate_draft = 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; } if (!try_.deflate_correct && !try_.deflate_draft) - try_.deflate = 0; + try_.deflate = 0; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress && len >= CILEN_BSD_COMPRESS - && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { - if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) - return 0; - try_.bsd_compress = 0; - p += CILEN_BSD_COMPRESS; - len -= CILEN_BSD_COMPRESS; + && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { + if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) + return 0; + try_.bsd_compress = 0; + p += CILEN_BSD_COMPRESS; + len -= CILEN_BSD_COMPRESS; } #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT if (go->predictor_1 && len >= CILEN_PREDICTOR_1 - && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) { - try_.predictor_1 = 0; - p += CILEN_PREDICTOR_1; - len -= CILEN_PREDICTOR_1; + && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) { + try_.predictor_1 = 0; + p += CILEN_PREDICTOR_1; + len -= CILEN_PREDICTOR_1; } if (go->predictor_2 && len >= CILEN_PREDICTOR_2 - && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) { - try_.predictor_2 = 0; - p += CILEN_PREDICTOR_2; - len -= CILEN_PREDICTOR_2; + && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) { + try_.predictor_2 = 0; + p += CILEN_PREDICTOR_2; + len -= CILEN_PREDICTOR_2; } #endif /* PREDICTOR_SUPPORT */ if (len != 0) - return 0; + return 0; if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; } @@ -1114,8 +1114,8 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) { u_char *p0, *retp; int len, clen, type; #if MPPE_SUPPORT - u8_t rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */ - /* CI_MPPE, or due to other options? */ + u8_t rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */ + /* CI_MPPE, or due to other options? */ #endif /* MPPE_SUPPORT */ ret = CONFACK; @@ -1126,257 +1126,257 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) { ho->method = (len > 0)? p[0]: 0; while (len > 0) { - newret = CONFACK; - if (len < 2 || p[1] < 2 || p[1] > len) { - /* length is bad */ - clen = len; - newret = CONFREJ; + newret = CONFACK; + if (len < 2 || p[1] < 2 || p[1] > len) { + /* length is bad */ + clen = len; + newret = CONFREJ; - } else { - type = p[0]; - clen = p[1]; + } else { + type = p[0]; + clen = p[1]; - switch (type) { + switch (type) { #if MPPE_SUPPORT - case CI_MPPE: - if (!ao->mppe || clen != CILEN_MPPE) { - newret = CONFREJ; - break; - } - MPPE_CI_TO_OPTS(&p[2], ho->mppe); - - /* Nak if anything unsupported or unknown are set. */ - if (ho->mppe & MPPE_OPT_UNSUPPORTED) { - newret = CONFNAK; - ho->mppe &= ~MPPE_OPT_UNSUPPORTED; - } - if (ho->mppe & MPPE_OPT_UNKNOWN) { - newret = CONFNAK; - ho->mppe &= ~MPPE_OPT_UNKNOWN; - } - - /* Check state opt */ - if (ho->mppe & MPPE_OPT_STATEFUL) { - /* - * We can Nak and request stateless, but it's a - * lot easier to just assume the peer will request - * it if he can do it; stateful mode is bad over - * the Internet -- which is where we expect MPPE. - */ - if (pcb->settings.refuse_mppe_stateful) { - ppp_error("Refusing MPPE stateful mode offered by peer"); - newret = CONFREJ; - break; - } - } - - /* Find out which of {S,L} are set. */ - if ((ho->mppe & MPPE_OPT_128) - && (ho->mppe & MPPE_OPT_40)) { - /* Both are set, negotiate the strongest. */ - newret = CONFNAK; - if (ao->mppe & MPPE_OPT_128) - ho->mppe &= ~MPPE_OPT_40; - else if (ao->mppe & MPPE_OPT_40) - ho->mppe &= ~MPPE_OPT_128; - else { - newret = CONFREJ; - break; - } - } else if (ho->mppe & MPPE_OPT_128) { - if (!(ao->mppe & MPPE_OPT_128)) { - newret = CONFREJ; - break; - } - } else if (ho->mppe & MPPE_OPT_40) { - if (!(ao->mppe & MPPE_OPT_40)) { - newret = CONFREJ; - break; - } - } else { - /* Neither are set. */ - /* We cannot accept this. */ - newret = CONFNAK; - /* Give the peer our idea of what can be used, - so it can choose and confirm */ - ho->mppe = ao->mppe; - } - - /* rebuild the opts */ - MPPE_OPTS_TO_CI(ho->mppe, &p[2]); - if (newret == CONFACK) { - int mtu; - - mppe_init(pcb, &pcb->mppe_comp, ho->mppe); - /* - * We need to decrease the interface MTU by MPPE_PAD - * because MPPE frames **grow**. The kernel [must] - * allocate MPPE_PAD extra bytes in xmit buffers. - */ - mtu = netif_get_mtu(pcb); - if (mtu) - netif_set_mtu(pcb, mtu - MPPE_PAD); - else - newret = CONFREJ; - } - - /* - * We have accepted MPPE or are willing to negotiate - * MPPE parameters. A CONFREJ is due to subsequent - * (non-MPPE) processing. - */ - rej_for_ci_mppe = 0; - break; + case CI_MPPE: + if (!ao->mppe || clen != CILEN_MPPE) { + newret = CONFREJ; + break; + } + MPPE_CI_TO_OPTS(&p[2], ho->mppe); + + /* Nak if anything unsupported or unknown are set. */ + if (ho->mppe & MPPE_OPT_UNSUPPORTED) { + newret = CONFNAK; + ho->mppe &= ~MPPE_OPT_UNSUPPORTED; + } + if (ho->mppe & MPPE_OPT_UNKNOWN) { + newret = CONFNAK; + ho->mppe &= ~MPPE_OPT_UNKNOWN; + } + + /* Check state opt */ + if (ho->mppe & MPPE_OPT_STATEFUL) { + /* + * We can Nak and request stateless, but it's a + * lot easier to just assume the peer will request + * it if he can do it; stateful mode is bad over + * the Internet -- which is where we expect MPPE. + */ + if (pcb->settings.refuse_mppe_stateful) { + ppp_error("Refusing MPPE stateful mode offered by peer"); + newret = CONFREJ; + break; + } + } + + /* Find out which of {S,L} are set. */ + if ((ho->mppe & MPPE_OPT_128) + && (ho->mppe & MPPE_OPT_40)) { + /* Both are set, negotiate the strongest. */ + newret = CONFNAK; + if (ao->mppe & MPPE_OPT_128) + ho->mppe &= ~MPPE_OPT_40; + else if (ao->mppe & MPPE_OPT_40) + ho->mppe &= ~MPPE_OPT_128; + else { + newret = CONFREJ; + break; + } + } else if (ho->mppe & MPPE_OPT_128) { + if (!(ao->mppe & MPPE_OPT_128)) { + newret = CONFREJ; + break; + } + } else if (ho->mppe & MPPE_OPT_40) { + if (!(ao->mppe & MPPE_OPT_40)) { + newret = CONFREJ; + break; + } + } else { + /* Neither are set. */ + /* We cannot accept this. */ + newret = CONFNAK; + /* Give the peer our idea of what can be used, + so it can choose and confirm */ + ho->mppe = ao->mppe; + } + + /* rebuild the opts */ + MPPE_OPTS_TO_CI(ho->mppe, &p[2]); + if (newret == CONFACK) { + int mtu; + + mppe_init(pcb, &pcb->mppe_comp, ho->mppe); + /* + * We need to decrease the interface MTU by MPPE_PAD + * because MPPE frames **grow**. The kernel [must] + * allocate MPPE_PAD extra bytes in xmit buffers. + */ + mtu = netif_get_mtu(pcb); + if (mtu) + netif_set_mtu(pcb, mtu - MPPE_PAD); + else + newret = CONFREJ; + } + + /* + * We have accepted MPPE or are willing to negotiate + * MPPE parameters. A CONFREJ is due to subsequent + * (non-MPPE) processing. + */ + rej_for_ci_mppe = 0; + break; #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (!ao->deflate || clen != CILEN_DEFLATE - || (!ao->deflate_correct && type == CI_DEFLATE) - || (!ao->deflate_draft && type == CI_DEFLATE_DRAFT)) { - newret = CONFREJ; - break; - } - - ho->deflate = 1; - ho->deflate_size = nb = DEFLATE_SIZE(p[2]); - if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL - || p[3] != DEFLATE_CHK_SEQUENCE - || nb > ao->deflate_size || nb < DEFLATE_MIN_WORKS) { - newret = CONFNAK; - if (!dont_nak) { - p[2] = DEFLATE_MAKE_OPT(ao->deflate_size); - p[3] = DEFLATE_CHK_SEQUENCE; - /* fall through to test this #bits below */ - } else - break; - } - - /* - * Check whether we can do Deflate with the window - * size they want. If the window is too big, reduce - * it until the kernel can cope and nak with that. - * We only check this for the first option. - */ - if (p == p0) { - for (;;) { - res = ccp_test(pcb, p, CILEN_DEFLATE, 1); - if (res > 0) - break; /* it's OK now */ - if (res < 0 || nb == DEFLATE_MIN_WORKS || dont_nak) { - newret = CONFREJ; - p[2] = DEFLATE_MAKE_OPT(ho->deflate_size); - break; - } - newret = CONFNAK; - --nb; - p[2] = DEFLATE_MAKE_OPT(nb); - } - } - break; + case CI_DEFLATE: + case CI_DEFLATE_DRAFT: + if (!ao->deflate || clen != CILEN_DEFLATE + || (!ao->deflate_correct && type == CI_DEFLATE) + || (!ao->deflate_draft && type == CI_DEFLATE_DRAFT)) { + newret = CONFREJ; + break; + } + + ho->deflate = 1; + ho->deflate_size = nb = DEFLATE_SIZE(p[2]); + if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL + || p[3] != DEFLATE_CHK_SEQUENCE + || nb > ao->deflate_size || nb < DEFLATE_MIN_WORKS) { + newret = CONFNAK; + if (!dont_nak) { + p[2] = DEFLATE_MAKE_OPT(ao->deflate_size); + p[3] = DEFLATE_CHK_SEQUENCE; + /* fall through to test this #bits below */ + } else + break; + } + + /* + * Check whether we can do Deflate with the window + * size they want. If the window is too big, reduce + * it until the kernel can cope and nak with that. + * We only check this for the first option. + */ + if (p == p0) { + for (;;) { + res = ccp_test(pcb, p, CILEN_DEFLATE, 1); + if (res > 0) + break; /* it's OK now */ + if (res < 0 || nb == DEFLATE_MIN_WORKS || dont_nak) { + newret = CONFREJ; + p[2] = DEFLATE_MAKE_OPT(ho->deflate_size); + break; + } + newret = CONFNAK; + --nb; + p[2] = DEFLATE_MAKE_OPT(nb); + } + } + break; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - case CI_BSD_COMPRESS: - if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) { - newret = CONFREJ; - break; - } - - ho->bsd_compress = 1; - ho->bsd_bits = nb = BSD_NBITS(p[2]); - if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION - || nb > ao->bsd_bits || nb < BSD_MIN_BITS) { - newret = CONFNAK; - if (!dont_nak) { - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits); - /* fall through to test this #bits below */ - } else - break; - } - - /* - * Check whether we can do BSD-Compress with the code - * size they want. If the code size is too big, reduce - * it until the kernel can cope and nak with that. - * We only check this for the first option. - */ - if (p == p0) { - for (;;) { - res = ccp_test(pcb, p, CILEN_BSD_COMPRESS, 1); - if (res > 0) - break; - if (res < 0 || nb == BSD_MIN_BITS || dont_nak) { - newret = CONFREJ; - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, - ho->bsd_bits); - break; - } - newret = CONFNAK; - --nb; - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb); - } - } - break; + case CI_BSD_COMPRESS: + if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) { + newret = CONFREJ; + break; + } + + ho->bsd_compress = 1; + ho->bsd_bits = nb = BSD_NBITS(p[2]); + if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION + || nb > ao->bsd_bits || nb < BSD_MIN_BITS) { + newret = CONFNAK; + if (!dont_nak) { + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits); + /* fall through to test this #bits below */ + } else + break; + } + + /* + * Check whether we can do BSD-Compress with the code + * size they want. If the code size is too big, reduce + * it until the kernel can cope and nak with that. + * We only check this for the first option. + */ + if (p == p0) { + for (;;) { + res = ccp_test(pcb, p, CILEN_BSD_COMPRESS, 1); + if (res > 0) + break; + if (res < 0 || nb == BSD_MIN_BITS || dont_nak) { + newret = CONFREJ; + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, + ho->bsd_bits); + break; + } + newret = CONFNAK; + --nb; + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb); + } + } + break; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - case CI_PREDICTOR_1: - if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) { - newret = CONFREJ; - break; - } - - ho->predictor_1 = 1; - if (p == p0 - && ccp_test(pcb, p, CILEN_PREDICTOR_1, 1) <= 0) { - newret = CONFREJ; - } - break; - - case CI_PREDICTOR_2: - if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) { - newret = CONFREJ; - break; - } - - ho->predictor_2 = 1; - if (p == p0 - && ccp_test(pcb, p, CILEN_PREDICTOR_2, 1) <= 0) { - newret = CONFREJ; - } - break; + case CI_PREDICTOR_1: + if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) { + newret = CONFREJ; + break; + } + + ho->predictor_1 = 1; + if (p == p0 + && ccp_test(pcb, p, CILEN_PREDICTOR_1, 1) <= 0) { + newret = CONFREJ; + } + break; + + case CI_PREDICTOR_2: + if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) { + newret = CONFREJ; + break; + } + + ho->predictor_2 = 1; + if (p == p0 + && ccp_test(pcb, p, CILEN_PREDICTOR_2, 1) <= 0) { + newret = CONFREJ; + } + break; #endif /* PREDICTOR_SUPPORT */ - default: - newret = CONFREJ; - } - } + default: + newret = CONFREJ; + } + } - if (newret == CONFNAK && dont_nak) - newret = CONFREJ; - if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) { - /* we're returning this option */ - if (newret == CONFREJ && ret == CONFNAK) - retp = p0; - ret = newret; - if (p != retp) - MEMCPY(retp, p, clen); - retp += clen; - } + if (newret == CONFNAK && dont_nak) + newret = CONFREJ; + if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) { + /* we're returning this option */ + if (newret == CONFREJ && ret == CONFNAK) + retp = p0; + ret = newret; + if (p != retp) + MEMCPY(retp, p, clen); + retp += clen; + } - p += clen; - len -= clen; + p += clen; + len -= clen; } if (ret != CONFACK) { - if (ret == CONFREJ && *lenp == retp - p0) - pcb->ccp_all_rejected = 1; - else - *lenp = retp - p0; + if (ret == CONFREJ && *lenp == retp - p0) + pcb->ccp_all_rejected = 1; + else + *lenp = retp - p0; } #if MPPE_SUPPORT if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) { - ppp_error("MPPE required but peer negotiation failed"); - lcp_close(pcb, "MPPE required but peer negotiation failed"); + ppp_error("MPPE required but peer negotiation failed"); + lcp_close(pcb, "MPPE required but peer negotiation failed"); } #endif /* MPPE_SUPPORT */ return ret; @@ -1392,63 +1392,63 @@ static const char *method_name(ccp_options *opt, ccp_options *opt2) { #endif /* !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT */ if (!ccp_anycompress(opt)) - return "(none)"; + return "(none)"; switch (opt->method) { #if MPPE_SUPPORT case CI_MPPE: { - char *p = result; - char *q = result + sizeof(result); /* 1 past result */ - - ppp_slprintf(p, q - p, "MPPE "); - p += 5; - if (opt->mppe & MPPE_OPT_128) { - ppp_slprintf(p, q - p, "128-bit "); - p += 8; - } - if (opt->mppe & MPPE_OPT_40) { - ppp_slprintf(p, q - p, "40-bit "); - p += 7; - } - if (opt->mppe & MPPE_OPT_STATEFUL) - ppp_slprintf(p, q - p, "stateful"); - else - ppp_slprintf(p, q - p, "stateless"); - - break; + char *p = result; + char *q = result + sizeof(result); /* 1 past result */ + + ppp_slprintf(p, q - p, "MPPE "); + p += 5; + if (opt->mppe & MPPE_OPT_128) { + ppp_slprintf(p, q - p, "128-bit "); + p += 8; + } + if (opt->mppe & MPPE_OPT_40) { + ppp_slprintf(p, q - p, "40-bit "); + p += 7; + } + if (opt->mppe & MPPE_OPT_STATEFUL) + ppp_slprintf(p, q - p, "stateful"); + else + ppp_slprintf(p, q - p, "stateless"); + + break; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT case CI_DEFLATE: case CI_DEFLATE_DRAFT: - if (opt2 != NULL && opt2->deflate_size != opt->deflate_size) - ppp_slprintf(result, sizeof(result), "Deflate%s (%d/%d)", - (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), - opt->deflate_size, opt2->deflate_size); - else - ppp_slprintf(result, sizeof(result), "Deflate%s (%d)", - (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), - opt->deflate_size); - break; + if (opt2 != NULL && opt2->deflate_size != opt->deflate_size) + ppp_slprintf(result, sizeof(result), "Deflate%s (%d/%d)", + (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), + opt->deflate_size, opt2->deflate_size); + else + ppp_slprintf(result, sizeof(result), "Deflate%s (%d)", + (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), + opt->deflate_size); + break; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT case CI_BSD_COMPRESS: - if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits) - ppp_slprintf(result, sizeof(result), "BSD-Compress (%d/%d)", - opt->bsd_bits, opt2->bsd_bits); - else - ppp_slprintf(result, sizeof(result), "BSD-Compress (%d)", - opt->bsd_bits); - break; + if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits) + ppp_slprintf(result, sizeof(result), "BSD-Compress (%d/%d)", + opt->bsd_bits, opt2->bsd_bits); + else + ppp_slprintf(result, sizeof(result), "BSD-Compress (%d)", + opt->bsd_bits); + break; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT case CI_PREDICTOR_1: - return "Predictor 1"; + return "Predictor 1"; case CI_PREDICTOR_2: - return "Predictor 2"; + return "Predictor 2"; #endif /* PREDICTOR_SUPPORT */ default: - ppp_slprintf(result, sizeof(result), "Method %d", opt->method); + ppp_slprintf(result, sizeof(result), "Method %d", opt->method); } return result; } @@ -1464,21 +1464,21 @@ static void ccp_up(fsm *f) { ccp_set(pcb, 1, 1, go->method, ho->method); if (ccp_anycompress(go)) { - if (ccp_anycompress(ho)) { - if (go->method == ho->method) { - ppp_notice("%s compression enabled", method_name(go, ho)); - } else { - ppp_strlcpy(method1, method_name(go, NULL), sizeof(method1)); - ppp_notice("%s / %s compression enabled", - method1, method_name(ho, NULL)); - } - } else - ppp_notice("%s receive compression enabled", method_name(go, NULL)); + if (ccp_anycompress(ho)) { + if (go->method == ho->method) { + ppp_notice("%s compression enabled", method_name(go, ho)); + } else { + ppp_strlcpy(method1, method_name(go, NULL), sizeof(method1)); + ppp_notice("%s / %s compression enabled", + method1, method_name(ho, NULL)); + } + } else + ppp_notice("%s receive compression enabled", method_name(go, NULL)); } else if (ccp_anycompress(ho)) - ppp_notice("%s transmit compression enabled", method_name(ho, NULL)); + ppp_notice("%s transmit compression enabled", method_name(ho, NULL)); #if MPPE_SUPPORT if (go->mppe) { - continue_networks(pcb); /* Bring up IP et al */ + continue_networks(pcb); /* Bring up IP et al */ } #endif /* MPPE_SUPPORT */ } @@ -1493,17 +1493,17 @@ static void ccp_down(fsm *f) { #endif /* MPPE_SUPPORT */ if (pcb->ccp_localstate & RACK_PENDING) - UNTIMEOUT(ccp_rack_timeout, f); + UNTIMEOUT(ccp_rack_timeout, f); pcb->ccp_localstate = 0; ccp_set(pcb, 1, 0, 0, 0); #if MPPE_SUPPORT if (go->mppe) { - go->mppe = 0; - if (pcb->lcp_fsm.state == PPP_FSM_OPENED) { - /* If LCP is not already going down, make sure it does. */ - ppp_error("MPPE disabled"); - lcp_close(pcb, "MPPE disabled"); - } + go->mppe = 0; + if (pcb->lcp_fsm.state == PPP_FSM_OPENED) { + /* If LCP is not already going down, make sure it does. */ + ppp_error("MPPE disabled"); + lcp_close(pcb, "MPPE disabled"); + } } #endif /* MPPE_SUPPORT */ } @@ -1526,17 +1526,17 @@ static int ccp_printpkt(const u_char *p, int plen, void (*printer) (void *, cons p0 = p; if (plen < HEADERLEN) - return 0; + return 0; code = p[0]; id = p[1]; len = (p[2] << 8) + p[3]; if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(ccp_codenames) && ccp_codenames[code-1] != NULL) - printer(arg, " %s", ccp_codenames[code-1]); + printer(arg, " %s", ccp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; p += HEADERLEN; @@ -1546,99 +1546,99 @@ static int ccp_printpkt(const u_char *p, int plen, void (*printer) (void *, cons case CONFACK: case CONFNAK: case CONFREJ: - /* print list of possible compression methods */ - while (len >= 2) { - code = p[0]; - optlen = p[1]; - if (optlen < 2 || optlen > len) - break; - printer(arg, " <"); - len -= optlen; - optend = p + optlen; - switch (code) { + /* print list of possible compression methods */ + while (len >= 2) { + code = p[0]; + optlen = p[1]; + if (optlen < 2 || optlen > len) + break; + printer(arg, " <"); + len -= optlen; + optend = p + optlen; + switch (code) { #if MPPE_SUPPORT - case CI_MPPE: - if (optlen >= CILEN_MPPE) { - u_char mppe_opts; - - MPPE_CI_TO_OPTS(&p[2], mppe_opts); - printer(arg, "mppe %s %s %s %s %s %s%s", - (p[2] & MPPE_H_BIT)? "+H": "-H", - (p[5] & MPPE_M_BIT)? "+M": "-M", - (p[5] & MPPE_S_BIT)? "+S": "-S", - (p[5] & MPPE_L_BIT)? "+L": "-L", - (p[5] & MPPE_D_BIT)? "+D": "-D", - (p[5] & MPPE_C_BIT)? "+C": "-C", - (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": ""); - if (mppe_opts & MPPE_OPT_UNKNOWN) - printer(arg, " (%.2x %.2x %.2x %.2x)", - p[2], p[3], p[4], p[5]); - p += CILEN_MPPE; - } - break; + case CI_MPPE: + if (optlen >= CILEN_MPPE) { + u_char mppe_opts; + + MPPE_CI_TO_OPTS(&p[2], mppe_opts); + printer(arg, "mppe %s %s %s %s %s %s%s", + (p[2] & MPPE_H_BIT)? "+H": "-H", + (p[5] & MPPE_M_BIT)? "+M": "-M", + (p[5] & MPPE_S_BIT)? "+S": "-S", + (p[5] & MPPE_L_BIT)? "+L": "-L", + (p[5] & MPPE_D_BIT)? "+D": "-D", + (p[5] & MPPE_C_BIT)? "+C": "-C", + (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": ""); + if (mppe_opts & MPPE_OPT_UNKNOWN) + printer(arg, " (%.2x %.2x %.2x %.2x)", + p[2], p[3], p[4], p[5]); + p += CILEN_MPPE; + } + break; #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (optlen >= CILEN_DEFLATE) { - printer(arg, "deflate%s %d", - (code == CI_DEFLATE_DRAFT? "(old#)": ""), - DEFLATE_SIZE(p[2])); - if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL) - printer(arg, " method %d", DEFLATE_METHOD(p[2])); - if (p[3] != DEFLATE_CHK_SEQUENCE) - printer(arg, " check %d", p[3]); - p += CILEN_DEFLATE; - } - break; + case CI_DEFLATE: + case CI_DEFLATE_DRAFT: + if (optlen >= CILEN_DEFLATE) { + printer(arg, "deflate%s %d", + (code == CI_DEFLATE_DRAFT? "(old#)": ""), + DEFLATE_SIZE(p[2])); + if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL) + printer(arg, " method %d", DEFLATE_METHOD(p[2])); + if (p[3] != DEFLATE_CHK_SEQUENCE) + printer(arg, " check %d", p[3]); + p += CILEN_DEFLATE; + } + break; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - case CI_BSD_COMPRESS: - if (optlen >= CILEN_BSD_COMPRESS) { - printer(arg, "bsd v%d %d", BSD_VERSION(p[2]), - BSD_NBITS(p[2])); - p += CILEN_BSD_COMPRESS; - } - break; + case CI_BSD_COMPRESS: + if (optlen >= CILEN_BSD_COMPRESS) { + printer(arg, "bsd v%d %d", BSD_VERSION(p[2]), + BSD_NBITS(p[2])); + p += CILEN_BSD_COMPRESS; + } + break; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - case CI_PREDICTOR_1: - if (optlen >= CILEN_PREDICTOR_1) { - printer(arg, "predictor 1"); - p += CILEN_PREDICTOR_1; - } - break; - case CI_PREDICTOR_2: - if (optlen >= CILEN_PREDICTOR_2) { - printer(arg, "predictor 2"); - p += CILEN_PREDICTOR_2; - } - break; + case CI_PREDICTOR_1: + if (optlen >= CILEN_PREDICTOR_1) { + printer(arg, "predictor 1"); + p += CILEN_PREDICTOR_1; + } + break; + case CI_PREDICTOR_2: + if (optlen >= CILEN_PREDICTOR_2) { + printer(arg, "predictor 2"); + p += CILEN_PREDICTOR_2; + } + break; #endif /* PREDICTOR_SUPPORT */ - default: + default: break; - } - while (p < optend) - printer(arg, " %.2x", *p++); - printer(arg, ">"); - } - break; + } + while (p < optend) + printer(arg, " %.2x", *p++); + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: break; } /* dump out the rest of the packet in hex */ while (--len >= 0) - printer(arg, " %.2x", *p++); + printer(arg, " %.2x", *p++); return p - p0; } @@ -1667,34 +1667,34 @@ static void ccp_datainput(ppp_pcb *pcb, u_char *pkt, int len) { f = &pcb->ccp_fsm; if (f->state == PPP_FSM_OPENED) { - if (ccp_fatal_error(pcb)) { - /* - * Disable compression by taking CCP down. - */ - ppp_error("Lost compression sync: disabling compression"); - ccp_close(pcb, "Lost compression sync"); + if (ccp_fatal_error(pcb)) { + /* + * Disable compression by taking CCP down. + */ + ppp_error("Lost compression sync: disabling compression"); + ccp_close(pcb, "Lost compression sync"); #if MPPE_SUPPORT - /* - * If we were doing MPPE, we must also take the link down. - */ - if (go->mppe) { - ppp_error("Too many MPPE errors, closing LCP"); - lcp_close(pcb, "Too many MPPE errors"); - } + /* + * If we were doing MPPE, we must also take the link down. + */ + if (go->mppe) { + ppp_error("Too many MPPE errors, closing LCP"); + lcp_close(pcb, "Too many MPPE errors"); + } #endif /* MPPE_SUPPORT */ - } else { - /* - * Send a reset-request to reset the peer's compressor. - * We don't do that if we are still waiting for an - * acknowledgement to a previous reset-request. - */ - if (!(pcb->ccp_localstate & RACK_PENDING)) { - fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); - TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); - pcb->ccp_localstate |= RACK_PENDING; - } else - pcb->ccp_localstate |= RREQ_REPEAT; - } + } else { + /* + * Send a reset-request to reset the peer's compressor. + * We don't do that if we are still waiting for an + * acknowledgement to a previous reset-request. + */ + if (!(pcb->ccp_localstate & RACK_PENDING)) { + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate |= RACK_PENDING; + } else + pcb->ccp_localstate |= RREQ_REPEAT; + } } } #endif /* PPP_DATAINPUT */ @@ -1707,7 +1707,7 @@ void ccp_resetrequest(ppp_pcb *pcb) { fsm *f = &pcb->ccp_fsm; if (f->state != PPP_FSM_OPENED) - return; + return; /* * Send a reset-request to reset the peer's compressor. @@ -1715,11 +1715,11 @@ void ccp_resetrequest(ppp_pcb *pcb) { * acknowledgement to a previous reset-request. */ if (!(pcb->ccp_localstate & RACK_PENDING)) { - fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); - TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); - pcb->ccp_localstate |= RACK_PENDING; + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate |= RACK_PENDING; } else - pcb->ccp_localstate |= RREQ_REPEAT; + pcb->ccp_localstate |= RREQ_REPEAT; } /* @@ -1730,11 +1730,11 @@ static void ccp_rack_timeout(void *arg) { ppp_pcb *pcb = f->pcb; if (f->state == PPP_FSM_OPENED && (pcb->ccp_localstate & RREQ_REPEAT)) { - fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0); - TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); - pcb->ccp_localstate &= ~RREQ_REPEAT; + fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate &= ~RREQ_REPEAT; } else - pcb->ccp_localstate &= ~RACK_PENDING; + pcb->ccp_localstate &= ~RACK_PENDING; } #endif /* PPP_SUPPORT && CCP_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/chap-md5.c b/components/net/lwip-2.0.2/src/netif/ppp/chap-md5.c index 88f069f032..2b7c9b36a8 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/chap-md5.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/chap-md5.c @@ -43,84 +43,84 @@ #include "netif/ppp/magic.h" #include "netif/ppp/pppcrypt.h" -#define MD5_HASH_SIZE 16 -#define MD5_MIN_CHALLENGE 17 -#define MD5_MAX_CHALLENGE 24 +#define MD5_HASH_SIZE 16 +#define MD5_MIN_CHALLENGE 17 +#define MD5_MAX_CHALLENGE 24 #define MD5_MIN_MAX_POWER_OF_TWO_CHALLENGE 3 /* 2^3-1 = 7, 17+7 = 24 */ #if PPP_SERVER static void chap_md5_generate_challenge(ppp_pcb *pcb, unsigned char *cp) { - int clen; - LWIP_UNUSED_ARG(pcb); + int clen; + LWIP_UNUSED_ARG(pcb); - clen = MD5_MIN_CHALLENGE + magic_pow(MD5_MIN_MAX_POWER_OF_TWO_CHALLENGE); - *cp++ = clen; - magic_random_bytes(cp, clen); + clen = MD5_MIN_CHALLENGE + magic_pow(MD5_MIN_MAX_POWER_OF_TWO_CHALLENGE); + *cp++ = clen; + magic_random_bytes(cp, clen); } static int chap_md5_verify_response(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) { - lwip_md5_context ctx; - unsigned char idbyte = id; - unsigned char hash[MD5_HASH_SIZE]; - int challenge_len, response_len; - LWIP_UNUSED_ARG(name); - LWIP_UNUSED_ARG(pcb); + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) { + lwip_md5_context ctx; + unsigned char idbyte = id; + unsigned char hash[MD5_HASH_SIZE]; + int challenge_len, response_len; + LWIP_UNUSED_ARG(name); + LWIP_UNUSED_ARG(pcb); - challenge_len = *challenge++; - response_len = *response++; - if (response_len == MD5_HASH_SIZE) { - /* Generate hash of ID, secret, challenge */ - lwip_md5_init(&ctx); - lwip_md5_starts(&ctx); - lwip_md5_update(&ctx, &idbyte, 1); - lwip_md5_update(&ctx, secret, secret_len); - lwip_md5_update(&ctx, challenge, challenge_len); - lwip_md5_finish(&ctx, hash); - lwip_md5_free(&ctx); + challenge_len = *challenge++; + response_len = *response++; + if (response_len == MD5_HASH_SIZE) { + /* Generate hash of ID, secret, challenge */ + lwip_md5_init(&ctx); + lwip_md5_starts(&ctx); + lwip_md5_update(&ctx, &idbyte, 1); + lwip_md5_update(&ctx, secret, secret_len); + lwip_md5_update(&ctx, challenge, challenge_len); + lwip_md5_finish(&ctx, hash); + lwip_md5_free(&ctx); - /* Test if our hash matches the peer's response */ - if (memcmp(hash, response, MD5_HASH_SIZE) == 0) { - ppp_slprintf(message, message_space, "Access granted"); - return 1; - } - } - ppp_slprintf(message, message_space, "Access denied"); - return 0; + /* Test if our hash matches the peer's response */ + if (memcmp(hash, response, MD5_HASH_SIZE) == 0) { + ppp_slprintf(message, message_space, "Access granted"); + return 1; + } + } + ppp_slprintf(message, message_space, "Access denied"); + return 0; } #endif /* PPP_SERVER */ static void chap_md5_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *private_) { - lwip_md5_context ctx; - unsigned char idbyte = id; - int challenge_len = *challenge++; - LWIP_UNUSED_ARG(our_name); - LWIP_UNUSED_ARG(private_); - LWIP_UNUSED_ARG(pcb); + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *private_) { + lwip_md5_context ctx; + unsigned char idbyte = id; + int challenge_len = *challenge++; + LWIP_UNUSED_ARG(our_name); + LWIP_UNUSED_ARG(private_); + LWIP_UNUSED_ARG(pcb); - lwip_md5_init(&ctx); - lwip_md5_starts(&ctx); - lwip_md5_update(&ctx, &idbyte, 1); - lwip_md5_update(&ctx, (const u_char *)secret, secret_len); - lwip_md5_update(&ctx, challenge, challenge_len); - lwip_md5_finish(&ctx, &response[1]); - lwip_md5_free(&ctx); - response[0] = MD5_HASH_SIZE; + lwip_md5_init(&ctx); + lwip_md5_starts(&ctx); + lwip_md5_update(&ctx, &idbyte, 1); + lwip_md5_update(&ctx, (const u_char *)secret, secret_len); + lwip_md5_update(&ctx, challenge, challenge_len); + lwip_md5_finish(&ctx, &response[1]); + lwip_md5_free(&ctx); + response[0] = MD5_HASH_SIZE; } const struct chap_digest_type md5_digest = { - CHAP_MD5, /* code */ + CHAP_MD5, /* code */ #if PPP_SERVER - chap_md5_generate_challenge, - chap_md5_verify_response, + chap_md5_generate_challenge, + chap_md5_verify_response, #endif /* PPP_SERVER */ - chap_md5_make_response, - NULL, /* check_success */ - NULL, /* handle_failure */ + chap_md5_make_response, + NULL, /* check_success */ + NULL, /* handle_failure */ }; #endif /* PPP_SUPPORT && CHAP_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/chap-new.c b/components/net/lwip-2.0.2/src/netif/ppp/chap-new.c index 485122d272..e599f3eb76 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/chap-new.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/chap-new.c @@ -52,9 +52,9 @@ #if 0 /* UNUSED */ /* Hook for a plugin to validate CHAP challenge */ int (*chap_verify_hook)(const char *name, const char *ourname, int id, - const struct chap_digest_type *digest, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) = NULL; + const struct chap_digest_type *digest, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) = NULL; #endif /* UNUSED */ #if PPP_OPTIONS @@ -62,24 +62,24 @@ int (*chap_verify_hook)(const char *name, const char *ourname, int id, * 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, &pcb->settings.chap_max_transmits, - "Set max #xmits for challenge", OPT_PRIO }, - { "chap-interval", o_int, &pcb->settings.chap_rechallenge_time, - "Set interval for rechallenge", OPT_PRIO }, - { NULL } + { "chap-restart", o_int, &chap_timeout_time, + "Set timeout for CHAP", OPT_PRIO }, + { "chap-max-challenge", o_int, &pcb->settings.chap_max_transmits, + "Set max #xmits for challenge", OPT_PRIO }, + { "chap-interval", o_int, &pcb->settings.chap_rechallenge_time, + "Set interval for rechallenge", OPT_PRIO }, + { NULL } }; #endif /* PPP_OPTIONS */ /* 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 +#define LOWERUP 1 +#define AUTH_STARTED 2 +#define AUTH_DONE 4 +#define AUTH_FAILED 8 +#define TIMEOUT_PENDING 0x10 +#define CHALLENGE_VALID 0x20 /* * Prototypes. @@ -91,21 +91,21 @@ static void chap_lowerdown(ppp_pcb *pcb); static void chap_timeout(void *arg); static void chap_generate_challenge(ppp_pcb *pcb); static void chap_handle_response(ppp_pcb *pcb, int code, - unsigned char *pkt, int len); + unsigned char *pkt, int len); static int chap_verify_response(ppp_pcb *pcb, const char *name, const char *ourname, int id, - const struct chap_digest_type *digest, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space); + const struct chap_digest_type *digest, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space); #endif /* PPP_SERVER */ static void chap_respond(ppp_pcb *pcb, int id, - unsigned char *pkt, int len); + unsigned char *pkt, int len); static void chap_handle_status(ppp_pcb *pcb, int code, int id, - unsigned char *pkt, int len); + unsigned char *pkt, int len); static void chap_protrej(ppp_pcb *pcb); static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen); #if PRINTPKT_SUPPORT static int chap_print_pkt(const unsigned char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ /* List of digest types that we know about */ @@ -122,12 +122,12 @@ static const struct chap_digest_type* const chap_digests[] = { * chap_init - reset to initial state. */ static void chap_init(ppp_pcb *pcb) { - LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(pcb); #if 0 /* Not necessary, everything is cleared in ppp_new() */ - memset(&pcb->chap_client, 0, sizeof(chap_client_state)); + memset(&pcb->chap_client, 0, sizeof(chap_client_state)); #if PPP_SERVER - memset(&pcb->chap_server, 0, sizeof(chap_server_state)); + memset(&pcb->chap_server, 0, sizeof(chap_server_state)); #endif /* PPP_SERVER */ #endif /* 0 */ } @@ -137,21 +137,21 @@ static void chap_init(ppp_pcb *pcb) { */ static void chap_lowerup(ppp_pcb *pcb) { - pcb->chap_client.flags |= LOWERUP; + pcb->chap_client.flags |= LOWERUP; #if PPP_SERVER - pcb->chap_server.flags |= LOWERUP; - if (pcb->chap_server.flags & AUTH_STARTED) - chap_timeout(pcb); + pcb->chap_server.flags |= LOWERUP; + if (pcb->chap_server.flags & AUTH_STARTED) + chap_timeout(pcb); #endif /* PPP_SERVER */ } static void chap_lowerdown(ppp_pcb *pcb) { - pcb->chap_client.flags = 0; + pcb->chap_client.flags = 0; #if PPP_SERVER - if (pcb->chap_server.flags & TIMEOUT_PENDING) - UNTIMEOUT(chap_timeout, pcb); - pcb->chap_server.flags = 0; + if (pcb->chap_server.flags & TIMEOUT_PENDING) + UNTIMEOUT(chap_timeout, pcb); + pcb->chap_server.flags = 0; #endif /* PPP_SERVER */ } @@ -162,27 +162,27 @@ static void chap_lowerdown(ppp_pcb *pcb) { * otherwise we wait for the lower layer to come up. */ void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { - const struct chap_digest_type *dp; - int i; - - if (pcb->chap_server.flags & AUTH_STARTED) { - ppp_error("CHAP: peer authentication already started!"); - return; - } - for (i = 0; (dp = chap_digests[i]) != NULL; ++i) - if (dp->code == digest_code) - break; - if (dp == NULL) - ppp_fatal("CHAP digest 0x%x requested but not available", - digest_code); - - pcb->chap_server.digest = dp; - pcb->chap_server.name = our_name; - /* Start with a random ID value */ - pcb->chap_server.id = magic(); - pcb->chap_server.flags |= AUTH_STARTED; - if (pcb->chap_server.flags & LOWERUP) - chap_timeout(pcb); + const struct chap_digest_type *dp; + int i; + + if (pcb->chap_server.flags & AUTH_STARTED) { + ppp_error("CHAP: peer authentication already started!"); + return; + } + for (i = 0; (dp = chap_digests[i]) != NULL; ++i) + if (dp->code == digest_code) + break; + if (dp == NULL) + ppp_fatal("CHAP digest 0x%x requested but not available", + digest_code); + + pcb->chap_server.digest = dp; + pcb->chap_server.name = our_name; + /* Start with a random ID value */ + pcb->chap_server.id = magic(); + pcb->chap_server.flags |= AUTH_STARTED; + if (pcb->chap_server.flags & LOWERUP) + chap_timeout(pcb); } #endif /* PPP_SERVER */ @@ -191,27 +191,27 @@ void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { * There isn't much to do until we receive a challenge. */ void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { - const struct chap_digest_type *dp; - int i; - - if(NULL == our_name) - return; - - if (pcb->chap_client.flags & AUTH_STARTED) { - ppp_error("CHAP: authentication with peer already started!"); - return; - } - for (i = 0; (dp = chap_digests[i]) != NULL; ++i) - if (dp->code == digest_code) - break; - - if (dp == NULL) - ppp_fatal("CHAP digest 0x%x requested but not available", - digest_code); - - pcb->chap_client.digest = dp; - pcb->chap_client.name = our_name; - pcb->chap_client.flags |= AUTH_STARTED; + const struct chap_digest_type *dp; + int i; + + if(NULL == our_name) + return; + + if (pcb->chap_client.flags & AUTH_STARTED) { + ppp_error("CHAP: authentication with peer already started!"); + return; + } + for (i = 0; (dp = chap_digests[i]) != NULL; ++i) + if (dp->code == digest_code) + break; + + if (dp == NULL) + ppp_fatal("CHAP digest 0x%x requested but not available", + digest_code); + + pcb->chap_client.digest = dp; + pcb->chap_client.name = our_name; + pcb->chap_client.flags |= AUTH_STARTED; } #if PPP_SERVER @@ -221,33 +221,33 @@ void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { * or a new challenge to start re-authentication. */ static void chap_timeout(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; - struct pbuf *p; - - pcb->chap_server.flags &= ~TIMEOUT_PENDING; - if ((pcb->chap_server.flags & CHALLENGE_VALID) == 0) { - pcb->chap_server.challenge_xmits = 0; - chap_generate_challenge(pcb); - pcb->chap_server.flags |= CHALLENGE_VALID; - } else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) { - pcb->chap_server.flags &= ~CHALLENGE_VALID; - pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED; - auth_peer_fail(pcb, PPP_CHAP); - return; - } - - p = pbuf_alloc(PBUF_RAW, (u16_t)(pcb->chap_server.challenge_pktlen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen); - ppp_write(pcb, p); - ++pcb->chap_server.challenge_xmits; - pcb->chap_server.flags |= TIMEOUT_PENDING; - TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time); + ppp_pcb *pcb = (ppp_pcb*)arg; + struct pbuf *p; + + pcb->chap_server.flags &= ~TIMEOUT_PENDING; + if ((pcb->chap_server.flags & CHALLENGE_VALID) == 0) { + pcb->chap_server.challenge_xmits = 0; + chap_generate_challenge(pcb); + pcb->chap_server.flags |= CHALLENGE_VALID; + } else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) { + pcb->chap_server.flags &= ~CHALLENGE_VALID; + pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED; + auth_peer_fail(pcb, PPP_CHAP); + return; + } + + p = pbuf_alloc(PBUF_RAW, (u16_t)(pcb->chap_server.challenge_pktlen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen); + ppp_write(pcb, p); + ++pcb->chap_server.challenge_xmits; + pcb->chap_server.flags |= TIMEOUT_PENDING; + TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time); } /* @@ -255,152 +255,152 @@ static void chap_timeout(void *arg) { * the challenge packet in pcb->chap_server.challenge_pkt. */ static void chap_generate_challenge(ppp_pcb *pcb) { - int clen = 1, nlen, len; - unsigned char *p; - - p = pcb->chap_server.challenge; - MAKEHEADER(p, PPP_CHAP); - p += CHAP_HDRLEN; - pcb->chap_server.digest->generate_challenge(pcb, p); - clen = *p; - nlen = strlen(pcb->chap_server.name); - memcpy(p + 1 + clen, pcb->chap_server.name, nlen); - - len = CHAP_HDRLEN + 1 + clen + nlen; - pcb->chap_server.challenge_pktlen = PPP_HDRLEN + len; - - p = pcb->chap_server.challenge + PPP_HDRLEN; - p[0] = CHAP_CHALLENGE; - p[1] = ++pcb->chap_server.id; - p[2] = len >> 8; - p[3] = len; + int clen = 1, nlen, len; + unsigned char *p; + + p = pcb->chap_server.challenge; + MAKEHEADER(p, PPP_CHAP); + p += CHAP_HDRLEN; + pcb->chap_server.digest->generate_challenge(pcb, p); + clen = *p; + nlen = strlen(pcb->chap_server.name); + memcpy(p + 1 + clen, pcb->chap_server.name, nlen); + + len = CHAP_HDRLEN + 1 + clen + nlen; + pcb->chap_server.challenge_pktlen = PPP_HDRLEN + len; + + p = pcb->chap_server.challenge + PPP_HDRLEN; + p[0] = CHAP_CHALLENGE; + p[1] = ++pcb->chap_server.id; + p[2] = len >> 8; + p[3] = len; } /* * chap_handle_response - check the response to our challenge. */ static void chap_handle_response(ppp_pcb *pcb, int id, - unsigned char *pkt, int len) { - int response_len, ok, mlen; - const unsigned char *response; - unsigned char *outp; - struct pbuf *p; - const char *name = NULL; /* initialized to shut gcc up */ + unsigned char *pkt, int len) { + int response_len, ok, mlen; + const unsigned char *response; + unsigned char *outp; + struct pbuf *p; + const char *name = NULL; /* initialized to shut gcc up */ #if 0 /* UNUSED */ - int (*verifier)(const char *, const char *, int, const struct chap_digest_type *, - const unsigned char *, const unsigned char *, char *, int); + int (*verifier)(const char *, const char *, int, const struct chap_digest_type *, + const unsigned char *, const unsigned char *, char *, int); #endif /* UNUSED */ - char rname[MAXNAMELEN+1]; - char message[256]; - - if ((pcb->chap_server.flags & LOWERUP) == 0) - return; - if (id != pcb->chap_server.challenge[PPP_HDRLEN+1] || len < 2) - return; - if (pcb->chap_server.flags & CHALLENGE_VALID) { - response = pkt; - GETCHAR(response_len, pkt); - len -= response_len + 1; /* length of name */ - name = (char *)pkt + response_len; - if (len < 0) - return; - - if (pcb->chap_server.flags & TIMEOUT_PENDING) { - pcb->chap_server.flags &= ~TIMEOUT_PENDING; - UNTIMEOUT(chap_timeout, pcb); - } + char rname[MAXNAMELEN+1]; + char message[256]; + + if ((pcb->chap_server.flags & LOWERUP) == 0) + return; + if (id != pcb->chap_server.challenge[PPP_HDRLEN+1] || len < 2) + return; + if (pcb->chap_server.flags & CHALLENGE_VALID) { + response = pkt; + GETCHAR(response_len, pkt); + len -= response_len + 1; /* length of name */ + name = (char *)pkt + response_len; + if (len < 0) + return; + + if (pcb->chap_server.flags & TIMEOUT_PENDING) { + pcb->chap_server.flags &= ~TIMEOUT_PENDING; + UNTIMEOUT(chap_timeout, pcb); + } #if PPP_REMOTENAME - if (pcb->settings.explicit_remote) { - name = pcb->remote_name; - } else + if (pcb->settings.explicit_remote) { + name = pcb->remote_name; + } else #endif /* PPP_REMOTENAME */ - { - /* Null terminate and clean remote name. */ - ppp_slprintf(rname, sizeof(rname), "%.*v", len, name); - name = rname; - } + { + /* Null terminate and clean remote name. */ + ppp_slprintf(rname, sizeof(rname), "%.*v", len, name); + name = rname; + } #if 0 /* UNUSED */ - if (chap_verify_hook) - verifier = chap_verify_hook; - else - verifier = chap_verify_response; - ok = (*verifier)(name, pcb->chap_server.name, id, pcb->chap_server.digest, - pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, - response, pcb->chap_server.message, sizeof(pcb->chap_server.message)); + if (chap_verify_hook) + verifier = chap_verify_hook; + else + verifier = chap_verify_response; + ok = (*verifier)(name, pcb->chap_server.name, id, pcb->chap_server.digest, + pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, + response, pcb->chap_server.message, sizeof(pcb->chap_server.message)); #endif /* UNUSED */ - ok = chap_verify_response(pcb, name, pcb->chap_server.name, id, pcb->chap_server.digest, + ok = chap_verify_response(pcb, name, pcb->chap_server.name, id, pcb->chap_server.digest, pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, response, message, sizeof(message)); #if 0 /* UNUSED */ - if (!ok || !auth_number()) { + if (!ok || !auth_number()) { #endif /* UNUSED */ - if (!ok) { - pcb->chap_server.flags |= AUTH_FAILED; - ppp_warn("Peer %q failed CHAP authentication", name); - } - } else if ((pcb->chap_server.flags & AUTH_DONE) == 0) - return; - - /* send the response */ - mlen = strlen(message); - len = CHAP_HDRLEN + mlen; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +len), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (unsigned char *)p->payload; - MAKEHEADER(outp, PPP_CHAP); - - outp[0] = (pcb->chap_server.flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS; - outp[1] = id; - outp[2] = len >> 8; - outp[3] = len; - if (mlen > 0) - memcpy(outp + CHAP_HDRLEN, message, mlen); - ppp_write(pcb, p); - - if (pcb->chap_server.flags & CHALLENGE_VALID) { - pcb->chap_server.flags &= ~CHALLENGE_VALID; - if (!(pcb->chap_server.flags & AUTH_DONE) && !(pcb->chap_server.flags & AUTH_FAILED)) { + if (!ok) { + pcb->chap_server.flags |= AUTH_FAILED; + ppp_warn("Peer %q failed CHAP authentication", name); + } + } else if ((pcb->chap_server.flags & AUTH_DONE) == 0) + return; + + /* send the response */ + mlen = strlen(message); + len = CHAP_HDRLEN + mlen; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +len), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (unsigned char *)p->payload; + MAKEHEADER(outp, PPP_CHAP); + + outp[0] = (pcb->chap_server.flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS; + outp[1] = id; + outp[2] = len >> 8; + outp[3] = len; + if (mlen > 0) + memcpy(outp + CHAP_HDRLEN, message, mlen); + ppp_write(pcb, p); + + if (pcb->chap_server.flags & CHALLENGE_VALID) { + pcb->chap_server.flags &= ~CHALLENGE_VALID; + if (!(pcb->chap_server.flags & AUTH_DONE) && !(pcb->chap_server.flags & AUTH_FAILED)) { #if 0 /* UNUSED */ - /* - * Auth is OK, so now we need to check session restrictions - * to ensure everything is OK, but only if we used a - * plugin, and only if we're configured to check. This - * allows us to do PAM checks on PPP servers that - * authenticate against ActiveDirectory, and use AD for - * account info (like when using Winbind integrated with - * PAM). - */ - if (session_mgmt && - session_check(name, NULL, devnam, NULL) == 0) { - pcb->chap_server.flags |= AUTH_FAILED; - ppp_warn("Peer %q failed CHAP Session verification", name); - } + /* + * Auth is OK, so now we need to check session restrictions + * to ensure everything is OK, but only if we used a + * plugin, and only if we're configured to check. This + * allows us to do PAM checks on PPP servers that + * authenticate against ActiveDirectory, and use AD for + * account info (like when using Winbind integrated with + * PAM). + */ + if (session_mgmt && + session_check(name, NULL, devnam, NULL) == 0) { + pcb->chap_server.flags |= AUTH_FAILED; + ppp_warn("Peer %q failed CHAP Session verification", name); + } #endif /* UNUSED */ - } - if (pcb->chap_server.flags & AUTH_FAILED) { - auth_peer_fail(pcb, PPP_CHAP); - } else { - if ((pcb->chap_server.flags & AUTH_DONE) == 0) - auth_peer_success(pcb, PPP_CHAP, - pcb->chap_server.digest->code, - name, strlen(name)); - if (pcb->settings.chap_rechallenge_time) { - pcb->chap_server.flags |= TIMEOUT_PENDING; - TIMEOUT(chap_timeout, pcb, - pcb->settings.chap_rechallenge_time); - } - } - pcb->chap_server.flags |= AUTH_DONE; - } + } + if (pcb->chap_server.flags & AUTH_FAILED) { + auth_peer_fail(pcb, PPP_CHAP); + } else { + if ((pcb->chap_server.flags & AUTH_DONE) == 0) + auth_peer_success(pcb, PPP_CHAP, + pcb->chap_server.digest->code, + name, strlen(name)); + if (pcb->settings.chap_rechallenge_time) { + pcb->chap_server.flags |= TIMEOUT_PENDING; + TIMEOUT(chap_timeout, pcb, + pcb->settings.chap_rechallenge_time); + } + } + pcb->chap_server.flags |= AUTH_DONE; + } } /* @@ -409,23 +409,23 @@ static void chap_handle_response(ppp_pcb *pcb, int id, * succeeded), or 0 if it doesn't. */ static int chap_verify_response(ppp_pcb *pcb, const char *name, const char *ourname, int id, - const struct chap_digest_type *digest, - const unsigned char *challenge, const 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(pcb, name, ourname, (char *)secret, &secret_len, 1)) { - ppp_error("No CHAP secret found for authenticating %q", name); - return 0; - } - ok = digest->verify_response(pcb, id, name, secret, secret_len, challenge, - response, message, message_space); - memset(secret, 0, sizeof(secret)); - - return ok; + const struct chap_digest_type *digest, + const unsigned char *challenge, const 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(pcb, name, ourname, (char *)secret, &secret_len, 1)) { + ppp_error("No CHAP secret found for authenticating %q", name); + return 0; + } + ok = digest->verify_response(pcb, id, name, secret, secret_len, challenge, + response, message, message_space); + memset(secret, 0, sizeof(secret)); + + return ok; } #endif /* PPP_SERVER */ @@ -433,153 +433,153 @@ static int chap_verify_response(ppp_pcb *pcb, const char *name, const char *ourn * chap_respond - Generate and send a response to a challenge. */ static void chap_respond(ppp_pcb *pcb, int id, - unsigned char *pkt, int len) { - int clen, nlen; - int secret_len; - struct pbuf *p; - u_char *outp; - char rname[MAXNAMELEN+1]; - char secret[MAXSECRETLEN+1]; - - p = pbuf_alloc(PBUF_RAW, (u16_t)(RESP_MAX_PKTLEN), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - if ((pcb->chap_client.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. */ - ppp_slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1); + unsigned char *pkt, int len) { + int clen, nlen; + int secret_len; + struct pbuf *p; + u_char *outp; + char rname[MAXNAMELEN+1]; + char secret[MAXSECRETLEN+1]; + + p = pbuf_alloc(PBUF_RAW, (u16_t)(RESP_MAX_PKTLEN), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + if ((pcb->chap_client.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. */ + ppp_slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1); #if PPP_REMOTENAME - /* Microsoft doesn't send their name back in the PPP packet */ - if (pcb->settings.explicit_remote || (pcb->settings.remote_name[0] != 0 && rname[0] == 0)) - strlcpy(rname, pcb->settings.remote_name, sizeof(rname)); + /* Microsoft doesn't send their name back in the PPP packet */ + if (pcb->settings.explicit_remote || (pcb->settings.remote_name[0] != 0 && rname[0] == 0)) + strlcpy(rname, pcb->settings.remote_name, sizeof(rname)); #endif /* PPP_REMOTENAME */ - /* get secret for authenticating ourselves with the specified host */ - if (!get_secret(pcb, pcb->chap_client.name, rname, secret, &secret_len, 0)) { - secret_len = 0; /* assume null secret if can't find one */ - ppp_warn("No CHAP secret found for authenticating us to %q", rname); - } - - outp = (u_char*)p->payload; - MAKEHEADER(outp, PPP_CHAP); - outp += CHAP_HDRLEN; - - pcb->chap_client.digest->make_response(pcb, outp, id, pcb->chap_client.name, pkt, - secret, secret_len, pcb->chap_client.priv); - memset(secret, 0, secret_len); - - clen = *outp; - nlen = strlen(pcb->chap_client.name); - memcpy(outp + clen + 1, pcb->chap_client.name, nlen); - - outp = (u_char*)p->payload + PPP_HDRLEN; - len = CHAP_HDRLEN + clen + 1 + nlen; - outp[0] = CHAP_RESPONSE; - outp[1] = id; - outp[2] = len >> 8; - outp[3] = len; - - pbuf_realloc(p, PPP_HDRLEN + len); - ppp_write(pcb, p); + /* get secret for authenticating ourselves with the specified host */ + if (!get_secret(pcb, pcb->chap_client.name, rname, secret, &secret_len, 0)) { + secret_len = 0; /* assume null secret if can't find one */ + ppp_warn("No CHAP secret found for authenticating us to %q", rname); + } + + outp = (u_char*)p->payload; + MAKEHEADER(outp, PPP_CHAP); + outp += CHAP_HDRLEN; + + pcb->chap_client.digest->make_response(pcb, outp, id, pcb->chap_client.name, pkt, + secret, secret_len, pcb->chap_client.priv); + memset(secret, 0, secret_len); + + clen = *outp; + nlen = strlen(pcb->chap_client.name); + memcpy(outp + clen + 1, pcb->chap_client.name, nlen); + + outp = (u_char*)p->payload + PPP_HDRLEN; + len = CHAP_HDRLEN + clen + 1 + nlen; + outp[0] = CHAP_RESPONSE; + outp[1] = id; + outp[2] = len >> 8; + outp[3] = len; + + pbuf_realloc(p, PPP_HDRLEN + len); + ppp_write(pcb, p); } static void chap_handle_status(ppp_pcb *pcb, int code, int id, - unsigned char *pkt, int len) { - const char *msg = NULL; - LWIP_UNUSED_ARG(id); - - if ((pcb->chap_client.flags & (AUTH_DONE|AUTH_STARTED|LOWERUP)) - != (AUTH_STARTED|LOWERUP)) - return; - pcb->chap_client.flags |= AUTH_DONE; - - if (code == CHAP_SUCCESS) { - /* used for MS-CHAP v2 mutual auth, yuck */ - if (pcb->chap_client.digest->check_success != NULL) { - if (!(*pcb->chap_client.digest->check_success)(pcb, pkt, len, pcb->chap_client.priv)) - code = CHAP_FAILURE; - } else - msg = "CHAP authentication succeeded"; - } else { - if (pcb->chap_client.digest->handle_failure != NULL) - (*pcb->chap_client.digest->handle_failure)(pcb, pkt, len); - else - msg = "CHAP authentication failed"; - } - if (msg) { - if (len > 0) - ppp_info("%s: %.*v", msg, len, pkt); - else - ppp_info("%s", msg); - } - if (code == CHAP_SUCCESS) - auth_withpeer_success(pcb, PPP_CHAP, pcb->chap_client.digest->code); - else { - pcb->chap_client.flags |= AUTH_FAILED; - ppp_error("CHAP authentication failed"); - auth_withpeer_fail(pcb, PPP_CHAP); - } + unsigned char *pkt, int len) { + const char *msg = NULL; + LWIP_UNUSED_ARG(id); + + if ((pcb->chap_client.flags & (AUTH_DONE|AUTH_STARTED|LOWERUP)) + != (AUTH_STARTED|LOWERUP)) + return; + pcb->chap_client.flags |= AUTH_DONE; + + if (code == CHAP_SUCCESS) { + /* used for MS-CHAP v2 mutual auth, yuck */ + if (pcb->chap_client.digest->check_success != NULL) { + if (!(*pcb->chap_client.digest->check_success)(pcb, pkt, len, pcb->chap_client.priv)) + code = CHAP_FAILURE; + } else + msg = "CHAP authentication succeeded"; + } else { + if (pcb->chap_client.digest->handle_failure != NULL) + (*pcb->chap_client.digest->handle_failure)(pcb, pkt, len); + else + msg = "CHAP authentication failed"; + } + if (msg) { + if (len > 0) + ppp_info("%s: %.*v", msg, len, pkt); + else + ppp_info("%s", msg); + } + if (code == CHAP_SUCCESS) + auth_withpeer_success(pcb, PPP_CHAP, pcb->chap_client.digest->code); + else { + pcb->chap_client.flags |= AUTH_FAILED; + ppp_error("CHAP authentication failed"); + auth_withpeer_fail(pcb, PPP_CHAP); + } } static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen) { - 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(pcb, id, pkt, len); - break; + 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(pcb, id, pkt, len); + break; #if PPP_SERVER - case CHAP_RESPONSE: - chap_handle_response(pcb, id, pkt, len); - break; + case CHAP_RESPONSE: + chap_handle_response(pcb, id, pkt, len); + break; #endif /* PPP_SERVER */ - case CHAP_FAILURE: - case CHAP_SUCCESS: - chap_handle_status(pcb, code, id, pkt, len); - break; - default: - break; - } + case CHAP_FAILURE: + case CHAP_SUCCESS: + chap_handle_status(pcb, code, id, pkt, len); + break; + default: + break; + } } static void chap_protrej(ppp_pcb *pcb) { #if PPP_SERVER - if (pcb->chap_server.flags & TIMEOUT_PENDING) { - pcb->chap_server.flags &= ~TIMEOUT_PENDING; - UNTIMEOUT(chap_timeout, pcb); - } - if (pcb->chap_server.flags & AUTH_STARTED) { - pcb->chap_server.flags = 0; - auth_peer_fail(pcb, PPP_CHAP); - } + if (pcb->chap_server.flags & TIMEOUT_PENDING) { + pcb->chap_server.flags &= ~TIMEOUT_PENDING; + UNTIMEOUT(chap_timeout, pcb); + } + if (pcb->chap_server.flags & AUTH_STARTED) { + pcb->chap_server.flags = 0; + auth_peer_fail(pcb, PPP_CHAP); + } #endif /* PPP_SERVER */ - if ((pcb->chap_client.flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) { - pcb->chap_client.flags &= ~AUTH_STARTED; - ppp_error("CHAP authentication failed due to protocol-reject"); - auth_withpeer_fail(pcb, PPP_CHAP); - } + if ((pcb->chap_client.flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) { + pcb->chap_client.flags &= ~AUTH_STARTED; + ppp_error("CHAP authentication failed due to protocol-reject"); + auth_withpeer_fail(pcb, PPP_CHAP); + } } #if PRINTPKT_SUPPORT @@ -587,90 +587,90 @@ static void chap_protrej(ppp_pcb *pcb) { * chap_print_pkt - print the contents of a CHAP packet. */ static const char* const chap_code_names[] = { - "Challenge", "Response", "Success", "Failure" + "Challenge", "Response", "Success", "Failure" }; static int chap_print_pkt(const unsigned char *p, int plen, - void (*printer) (void *, const 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 <= (int)LWIP_ARRAYSIZE(chap_code_names)) - 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 = "); - ppp_print_string(p, nlen, printer, arg); - break; - case CHAP_FAILURE: - case CHAP_SUCCESS: - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - break; - default: - for (clen = len; clen > 0; --clen) { - GETCHAR(x, p); - printer(arg, " %.2x", x); - } - /* no break */ - } - - return len + CHAP_HDRLEN; + void (*printer) (void *, const 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 <= (int)LWIP_ARRAYSIZE(chap_code_names)) + 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 = "); + ppp_print_string(p, nlen, printer, arg); + break; + case CHAP_FAILURE: + case CHAP_SUCCESS: + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + break; + default: + for (clen = len; clen > 0; --clen) { + GETCHAR(x, p); + printer(arg, " %.2x", x); + } + /* no break */ + } + + return len + CHAP_HDRLEN; } #endif /* PRINTPKT_SUPPORT */ const struct protent chap_protent = { - PPP_CHAP, - chap_init, - chap_input, - chap_protrej, - chap_lowerup, - chap_lowerdown, - NULL, /* open */ - NULL, /* close */ + PPP_CHAP, + chap_init, + chap_input, + chap_protrej, + chap_lowerup, + chap_lowerdown, + NULL, /* open */ + NULL, /* close */ #if PRINTPKT_SUPPORT - chap_print_pkt, + chap_print_pkt, #endif /* PRINTPKT_SUPPORT */ #if PPP_DATAINPUT - NULL, /* datainput */ + NULL, /* datainput */ #endif /* PPP_DATAINPUT */ #if PRINTPKT_SUPPORT - "CHAP", /* name */ - NULL, /* data_name */ + "CHAP", /* name */ + NULL, /* data_name */ #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS - chap_option_list, - NULL, /* check_options */ + chap_option_list, + NULL, /* check_options */ #endif /* PPP_OPTIONS */ #if DEMAND_SUPPORT - NULL, - NULL + NULL, + NULL #endif /* DEMAND_SUPPORT */ }; diff --git a/components/net/lwip-2.0.2/src/netif/ppp/chap_ms.c b/components/net/lwip-2.0.2/src/netif/ppp/chap_ms.c index 5a989c9b7e..b050aa1cd1 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/chap_ms.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/chap_ms.c @@ -97,41 +97,41 @@ #include "netif/ppp/mppe.h" /* For mppe_sha1_pad*, mppe_set_key() */ #endif /* MPPE_SUPPORT */ -#define SHA1_SIGNATURE_SIZE 20 -#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 SHA1_SIGNATURE_SIZE 20 +#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 */ +#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 */ /* 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 +#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 /* * Offsets within the response field for MS-CHAP */ -#define MS_CHAP_LANMANRESP 0 -#define MS_CHAP_LANMANRESP_LEN 24 -#define MS_CHAP_NTRESP 24 -#define MS_CHAP_NTRESP_LEN 24 -#define MS_CHAP_USENT 48 +#define MS_CHAP_LANMANRESP 0 +#define MS_CHAP_LANMANRESP_LEN 24 +#define MS_CHAP_NTRESP 24 +#define MS_CHAP_NTRESP_LEN 24 +#define MS_CHAP_USENT 48 /* * Offsets within the response field for MS-CHAP2 */ -#define MS_CHAP2_PEER_CHALLENGE 0 -#define MS_CHAP2_PEER_CHAL_LEN 16 -#define MS_CHAP2_RESERVED_LEN 8 -#define MS_CHAP2_NTRESP 24 -#define MS_CHAP2_NTRESP_LEN 24 -#define MS_CHAP2_FLAGS 48 +#define MS_CHAP2_PEER_CHALLENGE 0 +#define MS_CHAP2_PEER_CHAL_LEN 16 +#define MS_CHAP2_RESERVED_LEN 8 +#define MS_CHAP2_NTRESP 24 +#define MS_CHAP2_NTRESP_LEN 24 +#define MS_CHAP2_FLAGS 48 #if MPPE_SUPPORT #if 0 /* UNUSED */ @@ -150,37 +150,37 @@ extern void set_mppe_enc_types(int, int); #define MS_CHAP2_AUTHENTICATEE 0 #define MS_CHAP2_AUTHENTICATOR 1 -static void ascii2unicode (const char[], int, u_char[]); -static void NTPasswordHash (u_char *, int, u_char[MD4_SIGNATURE_SIZE]); -static void ChallengeResponse (const u_char *, const u_char *, u_char[24]); -static void ChallengeHash (const u_char[16], const u_char *, const char *, u_char[8]); -static void ChapMS_NT (const u_char *, const char *, int, u_char[24]); -static void ChapMS2_NT (const u_char *, const u_char[16], const char *, const char *, int, - u_char[24]); -static void GenerateAuthenticatorResponsePlain - (const char*, int, u_char[24], const u_char[16], const u_char *, - const char *, u_char[41]); +static void ascii2unicode (const char[], int, u_char[]); +static void NTPasswordHash (u_char *, int, u_char[MD4_SIGNATURE_SIZE]); +static void ChallengeResponse (const u_char *, const u_char *, u_char[24]); +static void ChallengeHash (const u_char[16], const u_char *, const char *, u_char[8]); +static void ChapMS_NT (const u_char *, const char *, int, u_char[24]); +static void ChapMS2_NT (const u_char *, const u_char[16], const char *, const char *, int, + u_char[24]); +static void GenerateAuthenticatorResponsePlain + (const char*, int, u_char[24], const u_char[16], const u_char *, + const char *, u_char[41]); #ifdef MSLANMAN -static void ChapMS_LANMan (u_char *, char *, int, u_char *); +static void ChapMS_LANMan (u_char *, char *, int, u_char *); #endif static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGNATURE_SIZE], - u_char NTResponse[24], const u_char PeerChallenge[16], - const u_char *rchallenge, const char *username, - u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]); + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, + u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]); #if MPPE_SUPPORT -static void Set_Start_Key (ppp_pcb *pcb, const u_char *, const char *, int); -static void SetMasterKeys (ppp_pcb *pcb, const char *, int, u_char[24], int); +static void Set_Start_Key (ppp_pcb *pcb, const u_char *, const char *, int); +static void SetMasterKeys (ppp_pcb *pcb, const char *, int, u_char[24], int); #endif /* MPPE_SUPPORT */ static void ChapMS (ppp_pcb *pcb, const u_char *, const char *, int, u_char *); static void ChapMS2 (ppp_pcb *pcb, const u_char *, const u_char *, const char *, const char *, int, - u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int); + u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int); #ifdef MSLANMAN -bool ms_lanman = 0; /* Use LanMan password instead of NT */ - /* Has meaning only with MS-CHAP challenges */ +bool ms_lanman = 0; /* Use LanMan password instead of NT */ + /* Has meaning only with MS-CHAP challenges */ #endif #if MPPE_SUPPORT @@ -192,7 +192,7 @@ static char *mschap_challenge = NULL; static char *mschap2_peer_challenge = NULL; #endif -#include "netif/ppp/fsm.h" /* Need to poke MPPE options */ +#include "netif/ppp/fsm.h" /* Need to poke MPPE options */ #include "netif/ppp/ccp.h" #endif /* MPPE_SUPPORT */ @@ -202,16 +202,16 @@ static char *mschap2_peer_challenge = NULL; */ static option_t chapms_option_list[] = { #ifdef MSLANMAN - { "ms-lanman", o_bool, &ms_lanman, - "Use LanMan passwd when using MS-CHAP", 1 }, + { "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" }, + { "mschap-challenge", o_string, &mschap_challenge, + "specify CHAP challenge" }, + { "mschap2-peer-challenge", o_string, &mschap2_peer_challenge, + "specify CHAP peer challenge" }, #endif - { NULL } + { NULL } }; #endif /* PPP_OPTIONS */ @@ -223,279 +223,279 @@ static option_t chapms_option_list[] = { * at challenge[1]. */ static void chapms_generate_challenge(ppp_pcb *pcb, unsigned char *challenge) { - LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(pcb); - *challenge++ = 8; + *challenge++ = 8; #ifdef DEBUGMPPEKEY - if (mschap_challenge && strlen(mschap_challenge) == 8) - memcpy(challenge, mschap_challenge, 8); - else + if (mschap_challenge && strlen(mschap_challenge) == 8) + memcpy(challenge, mschap_challenge, 8); + else #endif - magic_random_bytes(challenge, 8); + magic_random_bytes(challenge, 8); } static void chapms2_generate_challenge(ppp_pcb *pcb, unsigned char *challenge) { - LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(pcb); - *challenge++ = 16; + *challenge++ = 16; #ifdef DEBUGMPPEKEY - if (mschap_challenge && strlen(mschap_challenge) == 16) - memcpy(challenge, mschap_challenge, 16); - else + if (mschap_challenge && strlen(mschap_challenge) == 16) + memcpy(challenge, mschap_challenge, 16); + else #endif - magic_random_bytes(challenge, 16); + magic_random_bytes(challenge, 16); } static int chapms_verify_response(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) { - unsigned char md[MS_CHAP_RESPONSE_LEN]; - int diff; - int challenge_len, response_len; - LWIP_UNUSED_ARG(id); - LWIP_UNUSED_ARG(name); - - challenge_len = *challenge++; /* skip length, is 8 */ - response_len = *response++; - if (response_len != MS_CHAP_RESPONSE_LEN) - goto bad; + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) { + unsigned char md[MS_CHAP_RESPONSE_LEN]; + int diff; + int challenge_len, response_len; + LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(name); + + challenge_len = *challenge++; /* skip length, is 8 */ + response_len = *response++; + if (response_len != MS_CHAP_RESPONSE_LEN) + goto bad; #ifndef MSLANMAN - if (!response[MS_CHAP_USENT]) { - /* Should really propagate this into the error packet. */ - ppp_notice("Peer request for LANMAN auth not supported"); - goto bad; - } + if (!response[MS_CHAP_USENT]) { + /* Should really propagate this into the error packet. */ + ppp_notice("Peer request for LANMAN auth not supported"); + goto bad; + } #endif - /* Generate the expected response. */ - ChapMS(pcb, (const u_char *)challenge, (const char *)secret, secret_len, md); + /* Generate the expected response. */ + ChapMS(pcb, (const u_char *)challenge, (const char *)secret, secret_len, md); #ifdef MSLANMAN - /* Determine which part of response to verify against */ - if (!response[MS_CHAP_USENT]) - diff = memcmp(&response[MS_CHAP_LANMANRESP], - &md[MS_CHAP_LANMANRESP], MS_CHAP_LANMANRESP_LEN); - else + /* Determine which part of response to verify against */ + if (!response[MS_CHAP_USENT]) + diff = memcmp(&response[MS_CHAP_LANMANRESP], + &md[MS_CHAP_LANMANRESP], MS_CHAP_LANMANRESP_LEN); + else #endif - diff = memcmp(&response[MS_CHAP_NTRESP], &md[MS_CHAP_NTRESP], - MS_CHAP_NTRESP_LEN); + diff = memcmp(&response[MS_CHAP_NTRESP], &md[MS_CHAP_NTRESP], + MS_CHAP_NTRESP_LEN); - if (diff == 0) { - ppp_slprintf(message, message_space, "Access granted"); - return 1; - } + if (diff == 0) { + ppp_slprintf(message, message_space, "Access granted"); + return 1; + } bad: - /* See comments below for MS-CHAP V2 */ - ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0", - challenge_len, challenge); - return 0; + /* See comments below for MS-CHAP V2 */ + ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0", + challenge_len, challenge); + return 0; } static int chapms2_verify_response(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) { - unsigned char md[MS_CHAP2_RESPONSE_LEN]; - char saresponse[MS_AUTH_RESPONSE_LENGTH+1]; - int challenge_len, response_len; - LWIP_UNUSED_ARG(id); - - challenge_len = *challenge++; /* skip length, is 16 */ - response_len = *response++; - if (response_len != MS_CHAP2_RESPONSE_LEN) - goto bad; /* not even the right length */ - - /* Generate the expected response and our mutual auth. */ - ChapMS2(pcb, (const u_char*)challenge, (const u_char*)&response[MS_CHAP2_PEER_CHALLENGE], name, - (const 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= M=" - * where - * is the Authenticator Response (mutual auth) - * is a text message - * - * However, some versions of Windows (win98 tested) do not know - * about the M= 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 for - * help debugging this. - */ - if (memcmp(&md[MS_CHAP2_NTRESP], &response[MS_CHAP2_NTRESP], - MS_CHAP2_NTRESP_LEN) == 0) { - if (response[MS_CHAP2_FLAGS]) - ppp_slprintf(message, message_space, "S=%s", saresponse); - else - ppp_slprintf(message, message_space, "S=%s M=%s", - saresponse, "Access granted"); - return 1; - } + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) { + unsigned char md[MS_CHAP2_RESPONSE_LEN]; + char saresponse[MS_AUTH_RESPONSE_LENGTH+1]; + int challenge_len, response_len; + LWIP_UNUSED_ARG(id); + + challenge_len = *challenge++; /* skip length, is 16 */ + response_len = *response++; + if (response_len != MS_CHAP2_RESPONSE_LEN) + goto bad; /* not even the right length */ + + /* Generate the expected response and our mutual auth. */ + ChapMS2(pcb, (const u_char*)challenge, (const u_char*)&response[MS_CHAP2_PEER_CHALLENGE], name, + (const 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= M=" + * where + * is the Authenticator Response (mutual auth) + * is a text message + * + * However, some versions of Windows (win98 tested) do not know + * about the M= 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 for + * help debugging this. + */ + if (memcmp(&md[MS_CHAP2_NTRESP], &response[MS_CHAP2_NTRESP], + MS_CHAP2_NTRESP_LEN) == 0) { + if (response[MS_CHAP2_FLAGS]) + ppp_slprintf(message, message_space, "S=%s", saresponse); + else + ppp_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. - */ - ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0 M=%s", - challenge_len, challenge, "Access denied"); - return 0; + /* + * 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. + */ + ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0 M=%s", + challenge_len, challenge, "Access denied"); + return 0; } #endif /* PPP_SERVER */ static void chapms_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *private_) { - LWIP_UNUSED_ARG(id); - LWIP_UNUSED_ARG(our_name); - LWIP_UNUSED_ARG(private_); - challenge++; /* skip length, should be 8 */ - *response++ = MS_CHAP_RESPONSE_LEN; - ChapMS(pcb, challenge, secret, secret_len, response); + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *private_) { + LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(our_name); + LWIP_UNUSED_ARG(private_); + challenge++; /* skip length, should be 8 */ + *response++ = MS_CHAP_RESPONSE_LEN; + ChapMS(pcb, challenge, secret, secret_len, response); } static void chapms2_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *private_) { - LWIP_UNUSED_ARG(id); - challenge++; /* skip length, should be 16 */ - *response++ = MS_CHAP2_RESPONSE_LEN; - ChapMS2(pcb, challenge, + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *private_) { + LWIP_UNUSED_ARG(id); + challenge++; /* skip length, should be 16 */ + *response++ = MS_CHAP2_RESPONSE_LEN; + ChapMS2(pcb, challenge, #ifdef DEBUGMPPEKEY - mschap2_peer_challenge, + mschap2_peer_challenge, #else - NULL, + NULL, #endif - our_name, secret, secret_len, response, private_, - MS_CHAP2_AUTHENTICATEE); + our_name, secret, secret_len, response, private_, + MS_CHAP2_AUTHENTICATEE); } static int chapms2_check_success(ppp_pcb *pcb, unsigned char *msg, int len, unsigned char *private_) { - LWIP_UNUSED_ARG(pcb); - - if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || - strncmp((char *)msg, "S=", 2) != 0) { - /* Packet does not start with "S=" */ - ppp_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. */ - ppp_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=" */ - ppp_error("MS-CHAPv2 Success packet is badly formed."); - return 0; - } - return 1; + LWIP_UNUSED_ARG(pcb); + + if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || + strncmp((char *)msg, "S=", 2) != 0) { + /* Packet does not start with "S=" */ + ppp_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. */ + ppp_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=" */ + ppp_error("MS-CHAPv2 Success packet is badly formed."); + return 0; + } + return 1; } static void chapms_handle_failure(ppp_pcb *pcb, unsigned char *inp, int len) { - int err; - const char *p; - char msg[64]; - LWIP_UNUSED_ARG(pcb); - - /* We want a null-terminated string for strxxx(). */ - len = LWIP_MIN(len, 63); - MEMCPY(msg, inp, len); - msg[len] = 0; - p = msg; - - /* - * Deal with MS-CHAP formatted failure messages; just print the - * M= part (if any). For MS-CHAP we're not really supposed - * to use M=, but it shouldn't hurt. See - * chapms[2]_verify_response. - */ - if (!strncmp(p, "E=", 2)) - err = strtol(p+2, NULL, 10); /* Remember the error code. */ - else - goto print_msg; /* Message is badly formatted. */ - - if (len && ((p = strstr(p, " M=")) != NULL)) { - /* M= field found. */ - p += 3; - } else { - /* No M=; 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: - ppp_error("Unknown MS-CHAP authentication failure: %.*v", - len, inp); - return; - } - } + int err; + const char *p; + char msg[64]; + LWIP_UNUSED_ARG(pcb); + + /* We want a null-terminated string for strxxx(). */ + len = LWIP_MIN(len, 63); + MEMCPY(msg, inp, len); + msg[len] = 0; + p = msg; + + /* + * Deal with MS-CHAP formatted failure messages; just print the + * M= part (if any). For MS-CHAP we're not really supposed + * to use M=, but it shouldn't hurt. See + * chapms[2]_verify_response. + */ + if (!strncmp(p, "E=", 2)) + err = strtol(p+2, NULL, 10); /* Remember the error code. */ + else + goto print_msg; /* Message is badly formatted. */ + + if (len && ((p = strstr(p, " M=")) != NULL)) { + /* M= field found. */ + p += 3; + } else { + /* No M=; 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: + ppp_error("Unknown MS-CHAP authentication failure: %.*v", + len, inp); + return; + } + } print_msg: - if (p != NULL) - ppp_error("MS-CHAP authentication failed: %v", p); + if (p != NULL) + ppp_error("MS-CHAP authentication failed: %v", p); } static void ChallengeResponse(const u_char *challenge, - const u_char PasswordHash[MD4_SIGNATURE_SIZE], - u_char response[24]) { + const u_char PasswordHash[MD4_SIGNATURE_SIZE], + u_char response[24]) { u_char ZPasswordHash[21]; lwip_des_context des; u_char des_key[8]; @@ -505,7 +505,7 @@ static void ChallengeResponse(const u_char *challenge, #if 0 dbglog("ChallengeResponse - ZPasswordHash %.*B", - sizeof(ZPasswordHash), ZPasswordHash); + sizeof(ZPasswordHash), ZPasswordHash); #endif pppcrypt_56_to_64_bit_key(ZPasswordHash + 0, des_key); @@ -532,16 +532,16 @@ static void ChallengeResponse(const u_char *challenge, } static void ChallengeHash(const u_char PeerChallenge[16], const u_char *rchallenge, - const char *username, u_char Challenge[8]) { - lwip_sha1_context sha1Context; - u_char sha1Hash[SHA1_SIGNATURE_SIZE]; - const char *user; + const char *username, u_char Challenge[8]) { + lwip_sha1_context sha1Context; + u_char sha1Hash[SHA1_SIGNATURE_SIZE]; + const char *user; /* remove domain from "domain\username" */ if ((user = strrchr(username, '\\')) != NULL) - ++user; + ++user; else - user = username; + user = username; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); @@ -566,11 +566,11 @@ static void ascii2unicode(const char ascii[], int ascii_len, u_char unicode[]) { BZERO(unicode, ascii_len * 2); for (i = 0; i < ascii_len; i++) - unicode[i * 2] = (u_char) ascii[i]; + unicode[i * 2] = (u_char) ascii[i]; } static void NTPasswordHash(u_char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE]) { - lwip_md4_context md4Context; + lwip_md4_context md4Context; lwip_md4_init(&md4Context); lwip_md4_starts(&md4Context); @@ -580,9 +580,9 @@ static void NTPasswordHash(u_char *secret, int secret_len, u_char hash[MD4_SIGNA } static void ChapMS_NT(const u_char *rchallenge, const char *secret, int secret_len, - u_char NTResponse[24]) { - u_char unicodePassword[MAX_NT_PASSWORD * 2]; - u_char PasswordHash[MD4_SIGNATURE_SIZE]; + 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); @@ -592,10 +592,10 @@ static void ChapMS_NT(const u_char *rchallenge, const char *secret, int secret_l } static void ChapMS2_NT(const u_char *rchallenge, const u_char PeerChallenge[16], const char *username, - const 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]; + const 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, rchallenge, username, Challenge); @@ -610,10 +610,10 @@ static void ChapMS2_NT(const u_char *rchallenge, const u_char PeerChallenge[16], static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ static void ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len, - unsigned char *response) { - int i; - u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ - u_char PasswordHash[MD4_SIGNATURE_SIZE]; + unsigned char *response) { + int i; + u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ + u_char PasswordHash[MD4_SIGNATURE_SIZE]; lwip_des_context des; u_char des_key[8]; @@ -640,28 +640,28 @@ static void ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len, static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGNATURE_SIZE], - u_char NTResponse[24], const u_char PeerChallenge[16], - const u_char *rchallenge, const char *username, - u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) { + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, + u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) { /* * "Magic" constants used in response generation, from RFC 2759. */ static const 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 }; + { 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 }; static const 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 }; + { 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; - lwip_sha1_context sha1Context; - u_char Digest[SHA1_SIGNATURE_SIZE]; - u_char Challenge[8]; + int i; + lwip_sha1_context sha1Context; + u_char Digest[SHA1_SIGNATURE_SIZE]; + u_char Challenge[8]; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); @@ -683,27 +683,27 @@ static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGN /* Convert to ASCII hex string. */ for (i = 0; i < LWIP_MAX((MS_AUTH_RESPONSE_LENGTH / 2), (int)sizeof(Digest)); i++) - sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]); + sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]); } static void GenerateAuthenticatorResponsePlain( - const char *secret, int secret_len, - u_char NTResponse[24], const u_char PeerChallenge[16], - const u_char *rchallenge, const 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]; + const char *secret, int secret_len, + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const 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(unicodePassword, secret_len * 2, PasswordHash); NTPasswordHash(PasswordHash, sizeof(PasswordHash), - PasswordHashHash); + PasswordHashHash); GenerateAuthenticatorResponse(PasswordHashHash, NTResponse, PeerChallenge, - rchallenge, username, authResponse); + rchallenge, username, authResponse); } @@ -712,11 +712,11 @@ static void GenerateAuthenticatorResponsePlain( * Set mppe_xxxx_key from MS-CHAP credentials. (see RFC 3079) */ static void Set_Start_Key(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, int secret_len) { - u_char unicodePassword[MAX_NT_PASSWORD * 2]; - u_char PasswordHash[MD4_SIGNATURE_SIZE]; - u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; - lwip_sha1_context sha1Context; - u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ + u_char unicodePassword[MAX_NT_PASSWORD * 2]; + u_char PasswordHash[MD4_SIGNATURE_SIZE]; + u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; + lwip_sha1_context sha1Context; + u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ /* Hash (x2) the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); @@ -742,43 +742,43 @@ static void Set_Start_Key(ppp_pcb *pcb, const u_char *rchallenge, const char *se * Set mppe_xxxx_key from MS-CHAPv2 credentials. (see RFC 3079) */ static void SetMasterKeys(ppp_pcb *pcb, const 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]; - lwip_sha1_context sha1Context; - u_char MasterKey[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ - u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ + u_char unicodePassword[MAX_NT_PASSWORD * 2]; + u_char PasswordHash[MD4_SIGNATURE_SIZE]; + u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; + lwip_sha1_context sha1Context; + u_char MasterKey[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ + u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ const u_char *s; /* "This is the MPPE Master Key" */ static const 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 }; + { 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." */ static const 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 }; + { 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." */ static const 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 }; + { 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 }; /* Hash (x2) the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); @@ -797,9 +797,9 @@ static void SetMasterKeys(ppp_pcb *pcb, const char *secret, int secret_len, u_ch * generate send key */ if (IsServer) - s = Magic3; + s = Magic3; else - s = Magic2; + s = Magic2; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); lwip_sha1_update(&sha1Context, MasterKey, 16); @@ -815,9 +815,9 @@ static void SetMasterKeys(ppp_pcb *pcb, const char *secret, int secret_len, u_ch * generate recv key */ if (IsServer) - s = Magic2; + s = Magic2; else - s = Magic3; + s = Magic3; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); lwip_sha1_update(&sha1Context, MasterKey, 16); @@ -846,7 +846,7 @@ static void ChapMS(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, i #ifdef MSLANMAN ChapMS_LANMan(rchallenge, secret, secret_len, - &response[MS_CHAP_LANMANRESP]); + &response[MS_CHAP_LANMANRESP]); /* preferred method is set by option */ response[MS_CHAP_USENT] = !ms_lanman; @@ -871,8 +871,8 @@ static void ChapMS(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, i * Authenticator Response. */ static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerChallenge, - const char *user, const char *secret, int secret_len, unsigned char *response, - u_char authResponse[], int authenticator) { + const char *user, const char *secret, int secret_len, unsigned char *response, + u_char authResponse[], int authenticator) { /* ARGSUSED */ LWIP_UNUSED_ARG(authenticator); #if !MPPE_SUPPORT @@ -883,24 +883,24 @@ static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerCh /* Generate the Peer-Challenge if requested, or copy it if supplied. */ if (!PeerChallenge) - magic_random_bytes(&response[MS_CHAP2_PEER_CHALLENGE], MS_CHAP2_PEER_CHAL_LEN); + magic_random_bytes(&response[MS_CHAP2_PEER_CHALLENGE], MS_CHAP2_PEER_CHAL_LEN); else - MEMCPY(&response[MS_CHAP2_PEER_CHALLENGE], PeerChallenge, - MS_CHAP2_PEER_CHAL_LEN); + MEMCPY(&response[MS_CHAP2_PEER_CHALLENGE], PeerChallenge, + MS_CHAP2_PEER_CHAL_LEN); /* Generate the NT-Response */ ChapMS2_NT(rchallenge, &response[MS_CHAP2_PEER_CHALLENGE], user, - secret, secret_len, &response[MS_CHAP2_NTRESP]); + secret, secret_len, &response[MS_CHAP2_NTRESP]); /* Generate the Authenticator Response. */ GenerateAuthenticatorResponsePlain(secret, secret_len, - &response[MS_CHAP2_NTRESP], - &response[MS_CHAP2_PEER_CHALLENGE], - rchallenge, user, authResponse); + &response[MS_CHAP2_NTRESP], + &response[MS_CHAP2_PEER_CHALLENGE], + rchallenge, user, authResponse); #if MPPE_SUPPORT SetMasterKeys(pcb, secret, secret_len, - &response[MS_CHAP2_NTRESP], authenticator); + &response[MS_CHAP2_NTRESP], authenticator); #endif /* MPPE_SUPPORT */ } @@ -912,51 +912,51 @@ static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerCh 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; + 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; + 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; + 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_SUPPORT */ #endif /* UNUSED */ const struct chap_digest_type chapms_digest = { - CHAP_MICROSOFT, /* code */ + CHAP_MICROSOFT, /* code */ #if PPP_SERVER - chapms_generate_challenge, - chapms_verify_response, + chapms_generate_challenge, + chapms_verify_response, #endif /* PPP_SERVER */ - chapms_make_response, - NULL, /* check_success */ - chapms_handle_failure, + chapms_make_response, + NULL, /* check_success */ + chapms_handle_failure, }; const struct chap_digest_type chapms2_digest = { - CHAP_MICROSOFT_V2, /* code */ + CHAP_MICROSOFT_V2, /* code */ #if PPP_SERVER - chapms2_generate_challenge, - chapms2_verify_response, + chapms2_generate_challenge, + chapms2_verify_response, #endif /* PPP_SERVER */ - chapms2_make_response, - chapms2_check_success, - chapms_handle_failure, + chapms2_make_response, + chapms2_check_success, + chapms_handle_failure, }; #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/demand.c b/components/net/lwip-2.0.2/src/netif/ppp/demand.c index 26c6c30db1..f3774e087c 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/demand.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/demand.c @@ -87,11 +87,11 @@ demand_conf() /* framemax = lcp_allowoptions[0].mru; if (framemax < PPP_MRU) */ - framemax = PPP_MRU; + framemax = PPP_MRU; framemax += PPP_HDRLEN + PPP_FCSLEN; frame = malloc(framemax); if (frame == NULL) - novm("demand frame"); + novm("demand frame"); framelen = 0; pend_q = NULL; escape_flag = 0; @@ -100,8 +100,8 @@ demand_conf() netif_set_mtu(pcb, LWIP_MIN(lcp_allowoptions[0].mru, PPP_MRU)); if (ppp_send_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0 - || ppp_recv_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0) - fatal("Couldn't set up demand-dialled PPP interface: %m"); + || ppp_recv_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0) + fatal("Couldn't set up demand-dialled PPP interface: %m"); #ifdef PPP_FILTER set_filters(&pass_filter, &active_filter); @@ -111,12 +111,12 @@ demand_conf() * Call the demand_conf procedure for each protocol that's got one. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - ((*protp->demand_conf)(pcb)); + if (protp->demand_conf != NULL) + ((*protp->demand_conf)(pcb)); /* FIXME: find a way to die() here */ #if 0 - if (!((*protp->demand_conf)(pcb))) - die(1); + if (!((*protp->demand_conf)(pcb))) + die(1); #endif } @@ -131,8 +131,8 @@ demand_block() const struct protent *protp; for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_QUEUE); + if (protp->demand_conf != NULL) + sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_QUEUE); get_loop_output(); } @@ -148,14 +148,14 @@ demand_discard() const struct protent *protp; for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_ERROR); + if (protp->demand_conf != NULL) + sifnpmode(pcb, 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); + nextpkt = pkt->next; + free(pkt); } pend_q = NULL; framelen = 0; @@ -174,46 +174,46 @@ demand_unblock() const struct protent *protp; for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_PASS); + if (protp->demand_conf != NULL) + sifnpmode(pcb, 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 + 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 }; /* @@ -238,35 +238,35 @@ loop_chars(p, n) } 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); + 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; } @@ -290,22 +290,22 @@ loop_frame(frame, len) /* dbglog("from loop: %P", frame, len); */ if (len < PPP_HDRLEN) - return 0; + return 0; if ((PPP_PROTOCOL(frame) & 0x8000) != 0) - return 0; /* shouldn't get any of these anyway */ + return 0; /* shouldn't get any of these anyway */ if (!active_packet(frame, len)) - return 0; + 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; + 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; } @@ -332,23 +332,23 @@ demand_rexmit(proto, newip) pend_q = NULL; tv.tv_sec = 1; tv.tv_usec = 0; - select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */ + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */ for (; pkt != NULL; pkt = nextpkt) { - nextpkt = pkt->next; - if (PPP_PROTOCOL(pkt->data) == proto) { + nextpkt = pkt->next; + if (PPP_PROTOCOL(pkt->data) == proto) { if ( (proto == PPP_IP) && newip ) { - /* Get old checksum */ + /* Get old checksum */ - iphdr = (pkt->data[4] & 15) << 2; - checksum = *((unsigned short *) (pkt->data+14)); + iphdr = (pkt->data[4] & 15) << 2; + checksum = *((unsigned short *) (pkt->data+14)); if (checksum == 0xFFFF) { checksum = 0; } - + if (pkt->data[13] == 17) { pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr)); - if (pkt_checksum) { + if (pkt_checksum) { cv = 1; if (pkt_checksum == 0xFFFF) { pkt_checksum = 0; @@ -359,71 +359,71 @@ demand_rexmit(proto, newip) } } - if (pkt->data[13] == 6) { - pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr)); - cv = 1; + if (pkt->data[13] == 6) { + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr)); + cv = 1; if (pkt_checksum == 0xFFFF) { pkt_checksum = 0; } - } + } - /* Delete old Source-IP-Address */ + /* Delete old Source-IP-Address */ checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; - pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; - pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; - /* Change Source-IP-Address */ + /* Change Source-IP-Address */ * ((u32_t *) (pkt->data + 16)) = newip; - /* Add new Source-IP-Address */ + /* Add new Source-IP-Address */ checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; - /* Write new checksum */ + /* Write new checksum */ if (!checksum) { checksum = 0xFFFF; } *((unsigned short *) (pkt->data+14)) = checksum; - if (pkt->data[13] == 6) { - *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum; - } - if (cv && (pkt->data[13] == 17) ) { - *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum; - } - - /* Log Packet */ - strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16)))); - if (pkt->data[13] == 1) { - syslog(LOG_INFO,"Open ICMP %s -> %s\n", - ipstr, - inet_ntoa(*( (struct in_addr *) (pkt->data+20)))); - } else { - syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n", - pkt->data[13] == 6 ? "TCP" : "UDP", - ipstr, - ntohs(*( (short *) (pkt->data+iphdr+4))), - inet_ntoa(*( (struct in_addr *) (pkt->data+20))), - ntohs(*( (short *) (pkt->data+iphdr+6)))); + if (pkt->data[13] == 6) { + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum; + } + if (cv && (pkt->data[13] == 17) ) { + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum; + } + + /* Log Packet */ + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16)))); + if (pkt->data[13] == 1) { + syslog(LOG_INFO,"Open ICMP %s -> %s\n", + ipstr, + inet_ntoa(*( (struct in_addr *) (pkt->data+20)))); + } else { + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n", + pkt->data[13] == 6 ? "TCP" : "UDP", + ipstr, + ntohs(*( (short *) (pkt->data+iphdr+4))), + inet_ntoa(*( (struct in_addr *) (pkt->data+20))), + ntohs(*( (short *) (pkt->data+iphdr+6)))); } } - output(pcb, pkt->data, pkt->length); - free(pkt); - } else { - if (prev == NULL) - pend_q = pkt; - else - prev->next = pkt; - prev = pkt; - } + output(pcb, 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; + prev->next = NULL; } /* @@ -439,27 +439,27 @@ active_packet(p, len) const struct protent *protp; if (len < PPP_HDRLEN) - return 0; + return 0; proto = PPP_PROTOCOL(p); #ifdef PPP_FILTER - p[0] = 1; /* outbound packet indicator */ + p[0] = 1; /* outbound packet indicator */ if ((pass_filter.bf_len != 0 - && bpf_filter(pass_filter.bf_insns, p, len, len) == 0) - || (active_filter.bf_len != 0 - && bpf_filter(active_filter.bf_insns, p, len, len) == 0)) { - p[0] = 0xff; - return 0; + && bpf_filter(pass_filter.bf_insns, p, len, len) == 0) + || (active_filter.bf_len != 0 + && bpf_filter(active_filter.bf_insns, p, len, len) == 0)) { + p[0] = 0xff; + return 0; } p[0] = 0xff; #endif for (i = 0; (protp = protocols[i]) != NULL; ++i) { - if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { - if (protp->active_pkt == NULL) - return 1; - return (*protp->active_pkt)(p, len); - } + if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { + if (protp->active_pkt == NULL) + return 1; + return (*protp->active_pkt)(p, len); + } } - return 0; /* not a supported protocol !!?? */ + return 0; /* not a supported protocol !!?? */ } #endif /* PPP_SUPPORT && DEMAND_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/eap.c b/components/net/lwip-2.0.2/src/netif/ppp/eap.c index 8fb56368e7..8ca53d2a0d 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/eap.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/eap.c @@ -58,11 +58,11 @@ #endif /* USE_SRP */ #ifndef SHA_DIGESTSIZE -#define SHA_DIGESTSIZE 20 +#define SHA_DIGESTSIZE 20 #endif #ifdef USE_SRP -static char *pn_secret = NULL; /* Pseudonym generating secret */ +static char *pn_secret = NULL; /* Pseudonym generating secret */ #endif #if PPP_OPTIONS @@ -106,31 +106,31 @@ static int eap_printpkt(const u_char *inp, int inlen, #endif /* PRINTPKT_SUPPORT */ const struct protent eap_protent = { - PPP_EAP, /* protocol number */ - eap_init, /* initialization procedure */ - eap_input, /* process a received packet */ - eap_protrej, /* process a received protocol-reject */ - eap_lowerup, /* lower layer has gone up */ - eap_lowerdown, /* lower layer has gone down */ - NULL, /* open the protocol */ - NULL, /* close the protocol */ + PPP_EAP, /* protocol number */ + eap_init, /* initialization procedure */ + eap_input, /* process a received packet */ + eap_protrej, /* process a received protocol-reject */ + eap_lowerup, /* lower layer has gone up */ + eap_lowerdown, /* lower layer has gone down */ + NULL, /* open the protocol */ + NULL, /* close the protocol */ #if PRINTPKT_SUPPORT - eap_printpkt, /* print a packet in readable form */ + eap_printpkt, /* print a packet in readable form */ #endif /* PRINTPKT_SUPPORT */ #if PPP_DATAINPUT - NULL, /* process a received data packet */ + NULL, /* process a received data packet */ #endif /* PPP_DATAINPUT */ #if PRINTPKT_SUPPORT - "EAP", /* text name of protocol */ - NULL, /* text name of corresponding data protocol */ + "EAP", /* text name of protocol */ + NULL, /* text name of corresponding data protocol */ #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS - eap_option_list, /* list of command-line options */ - NULL, /* check requested options; assign defaults */ + eap_option_list, /* list of command-line options */ + NULL, /* check requested options; assign defaults */ #endif /* PPP_OPTIONS */ #if DEMAND_SUPPORT - NULL, /* configure interface for demand-dial */ - NULL /* say whether to bring up link for this pkt */ + NULL, /* configure interface for demand-dial */ + NULL /* say whether to bring up link for this pkt */ #endif /* DEMAND_SUPPORT */ }; @@ -139,38 +139,38 @@ const struct protent eap_protent = { * A well-known 2048 bit modulus. */ static const u_char wkmodulus[] = { - 0xAC, 0x6B, 0xDB, 0x41, 0x32, 0x4A, 0x9A, 0x9B, - 0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58, 0x2F, - 0xAF, 0x72, 0xB6, 0x65, 0x19, 0x87, 0xEE, 0x07, - 0xFC, 0x31, 0x92, 0x94, 0x3D, 0xB5, 0x60, 0x50, - 0xA3, 0x73, 0x29, 0xCB, 0xB4, 0xA0, 0x99, 0xED, - 0x81, 0x93, 0xE0, 0x75, 0x77, 0x67, 0xA1, 0x3D, - 0xD5, 0x23, 0x12, 0xAB, 0x4B, 0x03, 0x31, 0x0D, - 0xCD, 0x7F, 0x48, 0xA9, 0xDA, 0x04, 0xFD, 0x50, - 0xE8, 0x08, 0x39, 0x69, 0xED, 0xB7, 0x67, 0xB0, - 0xCF, 0x60, 0x95, 0x17, 0x9A, 0x16, 0x3A, 0xB3, - 0x66, 0x1A, 0x05, 0xFB, 0xD5, 0xFA, 0xAA, 0xE8, - 0x29, 0x18, 0xA9, 0x96, 0x2F, 0x0B, 0x93, 0xB8, - 0x55, 0xF9, 0x79, 0x93, 0xEC, 0x97, 0x5E, 0xEA, - 0xA8, 0x0D, 0x74, 0x0A, 0xDB, 0xF4, 0xFF, 0x74, - 0x73, 0x59, 0xD0, 0x41, 0xD5, 0xC3, 0x3E, 0xA7, - 0x1D, 0x28, 0x1E, 0x44, 0x6B, 0x14, 0x77, 0x3B, - 0xCA, 0x97, 0xB4, 0x3A, 0x23, 0xFB, 0x80, 0x16, - 0x76, 0xBD, 0x20, 0x7A, 0x43, 0x6C, 0x64, 0x81, - 0xF1, 0xD2, 0xB9, 0x07, 0x87, 0x17, 0x46, 0x1A, - 0x5B, 0x9D, 0x32, 0xE6, 0x88, 0xF8, 0x77, 0x48, - 0x54, 0x45, 0x23, 0xB5, 0x24, 0xB0, 0xD5, 0x7D, - 0x5E, 0xA7, 0x7A, 0x27, 0x75, 0xD2, 0xEC, 0xFA, - 0x03, 0x2C, 0xFB, 0xDB, 0xF5, 0x2F, 0xB3, 0x78, - 0x61, 0x60, 0x27, 0x90, 0x04, 0xE5, 0x7A, 0xE6, - 0xAF, 0x87, 0x4E, 0x73, 0x03, 0xCE, 0x53, 0x29, - 0x9C, 0xCC, 0x04, 0x1C, 0x7B, 0xC3, 0x08, 0xD8, - 0x2A, 0x56, 0x98, 0xF3, 0xA8, 0xD0, 0xC3, 0x82, - 0x71, 0xAE, 0x35, 0xF8, 0xE9, 0xDB, 0xFB, 0xB6, - 0x94, 0xB5, 0xC8, 0x03, 0xD8, 0x9F, 0x7A, 0xE4, - 0x35, 0xDE, 0x23, 0x6D, 0x52, 0x5F, 0x54, 0x75, - 0x9B, 0x65, 0xE3, 0x72, 0xFC, 0xD6, 0x8E, 0xF2, - 0x0F, 0xA7, 0x11, 0x1F, 0x9E, 0x4A, 0xFF, 0x73 + 0xAC, 0x6B, 0xDB, 0x41, 0x32, 0x4A, 0x9A, 0x9B, + 0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58, 0x2F, + 0xAF, 0x72, 0xB6, 0x65, 0x19, 0x87, 0xEE, 0x07, + 0xFC, 0x31, 0x92, 0x94, 0x3D, 0xB5, 0x60, 0x50, + 0xA3, 0x73, 0x29, 0xCB, 0xB4, 0xA0, 0x99, 0xED, + 0x81, 0x93, 0xE0, 0x75, 0x77, 0x67, 0xA1, 0x3D, + 0xD5, 0x23, 0x12, 0xAB, 0x4B, 0x03, 0x31, 0x0D, + 0xCD, 0x7F, 0x48, 0xA9, 0xDA, 0x04, 0xFD, 0x50, + 0xE8, 0x08, 0x39, 0x69, 0xED, 0xB7, 0x67, 0xB0, + 0xCF, 0x60, 0x95, 0x17, 0x9A, 0x16, 0x3A, 0xB3, + 0x66, 0x1A, 0x05, 0xFB, 0xD5, 0xFA, 0xAA, 0xE8, + 0x29, 0x18, 0xA9, 0x96, 0x2F, 0x0B, 0x93, 0xB8, + 0x55, 0xF9, 0x79, 0x93, 0xEC, 0x97, 0x5E, 0xEA, + 0xA8, 0x0D, 0x74, 0x0A, 0xDB, 0xF4, 0xFF, 0x74, + 0x73, 0x59, 0xD0, 0x41, 0xD5, 0xC3, 0x3E, 0xA7, + 0x1D, 0x28, 0x1E, 0x44, 0x6B, 0x14, 0x77, 0x3B, + 0xCA, 0x97, 0xB4, 0x3A, 0x23, 0xFB, 0x80, 0x16, + 0x76, 0xBD, 0x20, 0x7A, 0x43, 0x6C, 0x64, 0x81, + 0xF1, 0xD2, 0xB9, 0x07, 0x87, 0x17, 0x46, 0x1A, + 0x5B, 0x9D, 0x32, 0xE6, 0x88, 0xF8, 0x77, 0x48, + 0x54, 0x45, 0x23, 0xB5, 0x24, 0xB0, 0xD5, 0x7D, + 0x5E, 0xA7, 0x7A, 0x27, 0x75, 0xD2, 0xEC, 0xFA, + 0x03, 0x2C, 0xFB, 0xDB, 0xF5, 0x2F, 0xB3, 0x78, + 0x61, 0x60, 0x27, 0x90, 0x04, 0xE5, 0x7A, 0xE6, + 0xAF, 0x87, 0x4E, 0x73, 0x03, 0xCE, 0x53, 0x29, + 0x9C, 0xCC, 0x04, 0x1C, 0x7B, 0xC3, 0x08, 0xD8, + 0x2A, 0x56, 0x98, 0xF3, 0xA8, 0xD0, 0xC3, 0x82, + 0x71, 0xAE, 0x35, 0xF8, 0xE9, 0xDB, 0xFB, 0xB6, + 0x94, 0xB5, 0xC8, 0x03, 0xD8, 0x9F, 0x7A, 0xE4, + 0x35, 0xDE, 0x23, 0x6D, 0x52, 0x5F, 0x54, 0x75, + 0x9B, 0x65, 0xE3, 0x72, 0xFC, 0xD6, 0x8E, 0xF2, + 0x0F, 0xA7, 0x11, 0x1F, 0x9E, 0x4A, 0xFF, 0x73 }; #endif @@ -184,9 +184,9 @@ static void eap_server_timeout(void *arg); */ static const char * eap_state_name(enum eap_state_code esc) { - static const char *state_names[] = { EAP_STATES }; + static const char *state_names[] = { EAP_STATES }; - return (state_names[(int)esc]); + return (state_names[(int)esc]); } /* @@ -195,9 +195,9 @@ static const char * eap_state_name(enum eap_state_code esc) */ static void eap_init(ppp_pcb *pcb) { - BZERO(&pcb->eap, sizeof(eap_state)); + BZERO(&pcb->eap, sizeof(eap_state)); #if PPP_SERVER - pcb->eap.es_server.ea_id = magic(); + pcb->eap.es_server.ea_id = magic(); #endif /* PPP_SERVER */ } @@ -206,14 +206,14 @@ static void eap_init(ppp_pcb *pcb) { * Request messages. */ static void eap_client_timeout(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (!eap_client_active(pcb)) - return; + if (!eap_client_active(pcb)) + return; - ppp_error("EAP: timeout waiting for Request from peer"); - auth_withpeer_fail(pcb, PPP_EAP); - pcb->eap.es_client.ea_state = eapBadAuth; + ppp_error("EAP: timeout waiting for Request from peer"); + auth_withpeer_fail(pcb, PPP_EAP); + pcb->eap.es_client.ea_state = eapBadAuth; } /* @@ -224,22 +224,22 @@ static void eap_client_timeout(void *arg) { */ void eap_authwithpeer(ppp_pcb *pcb, const char *localname) { - if(NULL == localname) - return; + if(NULL == localname) + return; - /* Save the peer name we're given */ - pcb->eap.es_client.ea_name = localname; - pcb->eap.es_client.ea_namelen = strlen(localname); + /* Save the peer name we're given */ + pcb->eap.es_client.ea_name = localname; + pcb->eap.es_client.ea_namelen = strlen(localname); - pcb->eap.es_client.ea_state = eapListen; + pcb->eap.es_client.ea_state = eapListen; - /* - * Start a timer so that if the other end just goes - * silent, we don't sit here waiting forever. - */ - if (pcb->settings.eap_req_time > 0) - TIMEOUT(eap_client_timeout, pcb, - pcb->settings.eap_req_time); + /* + * Start a timer so that if the other end just goes + * silent, we don't sit here waiting forever. + */ + if (pcb->settings.eap_req_time > 0) + TIMEOUT(eap_client_timeout, pcb, + pcb->settings.eap_req_time); } #if PPP_SERVER @@ -248,30 +248,30 @@ void eap_authwithpeer(ppp_pcb *pcb, const char *localname) { * (Server operation) */ static void eap_send_failure(ppp_pcb *pcb) { - struct pbuf *p; - u_char *outp; + struct pbuf *p; + u_char *outp; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } - outp = (u_char*)p->payload; + outp = (u_char*)p->payload; - MAKEHEADER(outp, PPP_EAP); + MAKEHEADER(outp, PPP_EAP); - PUTCHAR(EAP_FAILURE, outp); - pcb->eap.es_server.ea_id++; - PUTCHAR(pcb->eap.es_server.ea_id, outp); - PUTSHORT(EAP_HEADERLEN, outp); + PUTCHAR(EAP_FAILURE, outp); + pcb->eap.es_server.ea_id++; + PUTCHAR(pcb->eap.es_server.ea_id, outp); + PUTSHORT(EAP_HEADERLEN, outp); - ppp_write(pcb, p); + ppp_write(pcb, p); - pcb->eap.es_server.ea_state = eapBadAuth; - auth_peer_fail(pcb, PPP_EAP); + pcb->eap.es_server.ea_state = eapBadAuth; + auth_peer_fail(pcb, PPP_EAP); } /* @@ -279,30 +279,30 @@ static void eap_send_failure(ppp_pcb *pcb) { * (Server operation) */ static void eap_send_success(ppp_pcb *pcb) { - struct pbuf *p; - u_char *outp; - - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_SUCCESS, outp); - pcb->eap.es_server.ea_id++; - PUTCHAR(pcb->eap.es_server.ea_id, outp); - PUTSHORT(EAP_HEADERLEN, outp); - - ppp_write(pcb, p); - - auth_peer_success(pcb, PPP_EAP, 0, - pcb->eap.es_server.ea_peer, pcb->eap.es_server.ea_peerlen); + struct pbuf *p; + u_char *outp; + + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_SUCCESS, outp); + pcb->eap.es_server.ea_id++; + PUTCHAR(pcb->eap.es_server.ea_id, outp); + PUTSHORT(EAP_HEADERLEN, outp); + + ppp_write(pcb, p); + + auth_peer_success(pcb, PPP_EAP, 0, + pcb->eap.es_server.ea_peer, pcb->eap.es_server.ea_peerlen); } #endif /* PPP_SERVER */ @@ -314,31 +314,31 @@ static void eap_send_success(ppp_pcb *pcb) { static bool pncrypt_setkey(int timeoffs) { - struct tm *tp; - char tbuf[9]; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; - time_t reftime; - - if (pn_secret == NULL) - return (0); - reftime = time(NULL) + timeoffs; - tp = localtime(&reftime); - SHA1Init(&ctxt); - SHA1Update(&ctxt, pn_secret, strlen(pn_secret)); - strftime(tbuf, sizeof (tbuf), "%Y%m%d", tp); - SHA1Update(&ctxt, tbuf, strlen(tbuf)); - SHA1Final(dig, &ctxt); - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - return (DesSetkey(dig)); + struct tm *tp; + char tbuf[9]; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; + time_t reftime; + + if (pn_secret == NULL) + return (0); + reftime = time(NULL) + timeoffs; + tp = localtime(&reftime); + SHA1Init(&ctxt); + SHA1Update(&ctxt, pn_secret, strlen(pn_secret)); + strftime(tbuf, sizeof (tbuf), "%Y%m%d", tp); + SHA1Update(&ctxt, tbuf, strlen(tbuf)); + SHA1Final(dig, &ctxt); + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + return (DesSetkey(dig)); } static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; struct b64state { - u32_t bs_bits; - int bs_offs; + u32_t bs_bits; + int bs_offs; }; static int @@ -348,23 +348,23 @@ u_char *inp; int inlen; u_char *outp; { - int outlen = 0; - - while (inlen > 0) { - bs->bs_bits = (bs->bs_bits << 8) | *inp++; - inlen--; - bs->bs_offs += 8; - if (bs->bs_offs >= 24) { - *outp++ = base64[(bs->bs_bits >> 18) & 0x3F]; - *outp++ = base64[(bs->bs_bits >> 12) & 0x3F]; - *outp++ = base64[(bs->bs_bits >> 6) & 0x3F]; - *outp++ = base64[bs->bs_bits & 0x3F]; - outlen += 4; - bs->bs_offs = 0; - bs->bs_bits = 0; - } - } - return (outlen); + int outlen = 0; + + while (inlen > 0) { + bs->bs_bits = (bs->bs_bits << 8) | *inp++; + inlen--; + bs->bs_offs += 8; + if (bs->bs_offs >= 24) { + *outp++ = base64[(bs->bs_bits >> 18) & 0x3F]; + *outp++ = base64[(bs->bs_bits >> 12) & 0x3F]; + *outp++ = base64[(bs->bs_bits >> 6) & 0x3F]; + *outp++ = base64[bs->bs_bits & 0x3F]; + outlen += 4; + bs->bs_offs = 0; + bs->bs_bits = 0; + } + } + return (outlen); } static int @@ -372,21 +372,21 @@ b64flush(bs, outp) struct b64state *bs; u_char *outp; { - int outlen = 0; - - if (bs->bs_offs == 8) { - *outp++ = base64[(bs->bs_bits >> 2) & 0x3F]; - *outp++ = base64[(bs->bs_bits << 4) & 0x3F]; - outlen = 2; - } else if (bs->bs_offs == 16) { - *outp++ = base64[(bs->bs_bits >> 10) & 0x3F]; - *outp++ = base64[(bs->bs_bits >> 4) & 0x3F]; - *outp++ = base64[(bs->bs_bits << 2) & 0x3F]; - outlen = 3; - } - bs->bs_offs = 0; - bs->bs_bits = 0; - return (outlen); + int outlen = 0; + + if (bs->bs_offs == 8) { + *outp++ = base64[(bs->bs_bits >> 2) & 0x3F]; + *outp++ = base64[(bs->bs_bits << 4) & 0x3F]; + outlen = 2; + } else if (bs->bs_offs == 16) { + *outp++ = base64[(bs->bs_bits >> 10) & 0x3F]; + *outp++ = base64[(bs->bs_bits >> 4) & 0x3F]; + *outp++ = base64[(bs->bs_bits << 2) & 0x3F]; + outlen = 3; + } + bs->bs_offs = 0; + bs->bs_bits = 0; + return (outlen); } static int @@ -396,22 +396,22 @@ u_char *inp; int inlen; u_char *outp; { - int outlen = 0; - char *cp; - - while (inlen > 0) { - if ((cp = strchr(base64, *inp++)) == NULL) - break; - bs->bs_bits = (bs->bs_bits << 6) | (cp - base64); - inlen--; - bs->bs_offs += 6; - if (bs->bs_offs >= 8) { - *outp++ = bs->bs_bits >> (bs->bs_offs - 8); - outlen++; - bs->bs_offs -= 8; - } - } - return (outlen); + int outlen = 0; + char *cp; + + while (inlen > 0) { + if ((cp = strchr(base64, *inp++)) == NULL) + break; + bs->bs_bits = (bs->bs_bits << 6) | (cp - base64); + inlen--; + bs->bs_offs += 6; + if (bs->bs_offs >= 8) { + *outp++ = bs->bs_bits >> (bs->bs_offs - 8); + outlen++; + bs->bs_offs -= 8; + } + } + return (outlen); } #endif /* USE_SRP */ @@ -424,211 +424,211 @@ u_char *outp; */ static void eap_figure_next_state(ppp_pcb *pcb, int status) { #ifdef USE_SRP - unsigned char secbuf[MAXSECRETLEN], clear[8], *sp, *dp; - struct t_pw tpw; - struct t_confent *tce, mytce; - char *cp, *cp2; - struct t_server *ts; - int id, i, plen, toffs; - u_char vals[2]; - struct b64state bs; + unsigned char secbuf[MAXSECRETLEN], clear[8], *sp, *dp; + struct t_pw tpw; + struct t_confent *tce, mytce; + char *cp, *cp2; + struct t_server *ts; + int id, i, plen, toffs; + u_char vals[2]; + struct b64state bs; #endif /* USE_SRP */ - pcb->settings.eap_timeout_time = pcb->eap.es_savedtime; - switch (pcb->eap.es_server.ea_state) { - case eapBadAuth: - return; + pcb->settings.eap_timeout_time = pcb->eap.es_savedtime; + switch (pcb->eap.es_server.ea_state) { + case eapBadAuth: + return; - case eapIdentify: + case eapIdentify: #ifdef USE_SRP - /* Discard any previous session. */ - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + /* Discard any previous session. */ + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status != 0) { - pcb->eap.es_server.ea_state = eapBadAuth; - break; - } + if (status != 0) { + pcb->eap.es_server.ea_state = eapBadAuth; + break; + } #ifdef USE_SRP - /* If we've got a pseudonym, try to decode to real name. */ - if (pcb->eap.es_server.ea_peerlen > SRP_PSEUDO_LEN && - strncmp(pcb->eap.es_server.ea_peer, SRP_PSEUDO_ID, - SRP_PSEUDO_LEN) == 0 && - (pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN) * 3 / 4 < - sizeof (secbuf)) { - BZERO(&bs, sizeof (bs)); - plen = b64dec(&bs, - pcb->eap.es_server.ea_peer + SRP_PSEUDO_LEN, - pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN, - secbuf); - toffs = 0; - for (i = 0; i < 5; i++) { - pncrypt_setkey(toffs); - toffs -= 86400; - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - if (!DesDecrypt(secbuf, clear)) { - ppp_dbglog("no DES here; cannot decode " - "pseudonym"); - return; - } - id = *(unsigned char *)clear; - if (id + 1 <= plen && id + 9 > plen) - break; - } - if (plen % 8 == 0 && i < 5) { - /* - * Note that this is always shorter than the - * original stored string, so there's no need - * to realloc. - */ - if ((i = plen = *(unsigned char *)clear) > 7) - i = 7; - pcb->eap.es_server.ea_peerlen = plen; - dp = (unsigned char *)pcb->eap.es_server.ea_peer; - MEMCPY(dp, clear + 1, i); - plen -= i; - dp += i; - sp = secbuf + 8; - while (plen > 0) { - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - (void) DesDecrypt(sp, dp); - sp += 8; - dp += 8; - plen -= 8; - } - pcb->eap.es_server.ea_peer[ - pcb->eap.es_server.ea_peerlen] = '\0'; - ppp_dbglog("decoded pseudonym to \"%.*q\"", - pcb->eap.es_server.ea_peerlen, - pcb->eap.es_server.ea_peer); - } else { - ppp_dbglog("failed to decode real name"); - /* Stay in eapIdentfy state; requery */ - break; - } - } - /* Look up user in secrets database. */ - if (get_srp_secret(pcb->eap.es_unit, pcb->eap.es_server.ea_peer, - pcb->eap.es_server.ea_name, (char *)secbuf, 1) != 0) { - /* Set up default in case SRP entry is bad */ - pcb->eap.es_server.ea_state = eapMD5Chall; - /* Get t_confent based on index in srp-secrets */ - id = strtol((char *)secbuf, &cp, 10); - if (*cp++ != ':' || id < 0) - break; - if (id == 0) { - mytce.index = 0; - mytce.modulus.data = (u_char *)wkmodulus; - mytce.modulus.len = sizeof (wkmodulus); - mytce.generator.data = (u_char *)"\002"; - mytce.generator.len = 1; - tce = &mytce; - } else if ((tce = gettcid(id)) != NULL) { - /* - * Client will have to verify this modulus/ - * generator combination, and that will take - * a while. Lengthen the timeout here. - */ - if (pcb->settings.eap_timeout_time > 0 && - pcb->settings.eap_timeout_time < 30) - pcb->settings.eap_timeout_time = 30; - } else { - break; - } - if ((cp2 = strchr(cp, ':')) == NULL) - break; - *cp2++ = '\0'; - tpw.pebuf.name = pcb->eap.es_server.ea_peer; - tpw.pebuf.password.len = t_fromb64((char *)tpw.pwbuf, - cp); - tpw.pebuf.password.data = tpw.pwbuf; - tpw.pebuf.salt.len = t_fromb64((char *)tpw.saltbuf, - cp2); - tpw.pebuf.salt.data = tpw.saltbuf; - if ((ts = t_serveropenraw(&tpw.pebuf, tce)) == NULL) - break; - pcb->eap.es_server.ea_session = (void *)ts; - pcb->eap.es_server.ea_state = eapSRP1; - vals[0] = pcb->eap.es_server.ea_id + 1; - vals[1] = EAPT_SRP; - t_serveraddexdata(ts, vals, 2); - /* Generate B; must call before t_servergetkey() */ - t_servergenexp(ts); - break; - } + /* If we've got a pseudonym, try to decode to real name. */ + if (pcb->eap.es_server.ea_peerlen > SRP_PSEUDO_LEN && + strncmp(pcb->eap.es_server.ea_peer, SRP_PSEUDO_ID, + SRP_PSEUDO_LEN) == 0 && + (pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN) * 3 / 4 < + sizeof (secbuf)) { + BZERO(&bs, sizeof (bs)); + plen = b64dec(&bs, + pcb->eap.es_server.ea_peer + SRP_PSEUDO_LEN, + pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN, + secbuf); + toffs = 0; + for (i = 0; i < 5; i++) { + pncrypt_setkey(toffs); + toffs -= 86400; + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + if (!DesDecrypt(secbuf, clear)) { + ppp_dbglog("no DES here; cannot decode " + "pseudonym"); + return; + } + id = *(unsigned char *)clear; + if (id + 1 <= plen && id + 9 > plen) + break; + } + if (plen % 8 == 0 && i < 5) { + /* + * Note that this is always shorter than the + * original stored string, so there's no need + * to realloc. + */ + if ((i = plen = *(unsigned char *)clear) > 7) + i = 7; + pcb->eap.es_server.ea_peerlen = plen; + dp = (unsigned char *)pcb->eap.es_server.ea_peer; + MEMCPY(dp, clear + 1, i); + plen -= i; + dp += i; + sp = secbuf + 8; + while (plen > 0) { + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + (void) DesDecrypt(sp, dp); + sp += 8; + dp += 8; + plen -= 8; + } + pcb->eap.es_server.ea_peer[ + pcb->eap.es_server.ea_peerlen] = '\0'; + ppp_dbglog("decoded pseudonym to \"%.*q\"", + pcb->eap.es_server.ea_peerlen, + pcb->eap.es_server.ea_peer); + } else { + ppp_dbglog("failed to decode real name"); + /* Stay in eapIdentfy state; requery */ + break; + } + } + /* Look up user in secrets database. */ + if (get_srp_secret(pcb->eap.es_unit, pcb->eap.es_server.ea_peer, + pcb->eap.es_server.ea_name, (char *)secbuf, 1) != 0) { + /* Set up default in case SRP entry is bad */ + pcb->eap.es_server.ea_state = eapMD5Chall; + /* Get t_confent based on index in srp-secrets */ + id = strtol((char *)secbuf, &cp, 10); + if (*cp++ != ':' || id < 0) + break; + if (id == 0) { + mytce.index = 0; + mytce.modulus.data = (u_char *)wkmodulus; + mytce.modulus.len = sizeof (wkmodulus); + mytce.generator.data = (u_char *)"\002"; + mytce.generator.len = 1; + tce = &mytce; + } else if ((tce = gettcid(id)) != NULL) { + /* + * Client will have to verify this modulus/ + * generator combination, and that will take + * a while. Lengthen the timeout here. + */ + if (pcb->settings.eap_timeout_time > 0 && + pcb->settings.eap_timeout_time < 30) + pcb->settings.eap_timeout_time = 30; + } else { + break; + } + if ((cp2 = strchr(cp, ':')) == NULL) + break; + *cp2++ = '\0'; + tpw.pebuf.name = pcb->eap.es_server.ea_peer; + tpw.pebuf.password.len = t_fromb64((char *)tpw.pwbuf, + cp); + tpw.pebuf.password.data = tpw.pwbuf; + tpw.pebuf.salt.len = t_fromb64((char *)tpw.saltbuf, + cp2); + tpw.pebuf.salt.data = tpw.saltbuf; + if ((ts = t_serveropenraw(&tpw.pebuf, tce)) == NULL) + break; + pcb->eap.es_server.ea_session = (void *)ts; + pcb->eap.es_server.ea_state = eapSRP1; + vals[0] = pcb->eap.es_server.ea_id + 1; + vals[1] = EAPT_SRP; + t_serveraddexdata(ts, vals, 2); + /* Generate B; must call before t_servergetkey() */ + t_servergenexp(ts); + break; + } #endif /* USE_SRP */ - pcb->eap.es_server.ea_state = eapMD5Chall; - break; + pcb->eap.es_server.ea_state = eapMD5Chall; + break; - case eapSRP1: + case eapSRP1: #ifdef USE_SRP - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL && status != 0) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL && status != 0) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status == 1) { - pcb->eap.es_server.ea_state = eapMD5Chall; - } else if (status != 0 || pcb->eap.es_server.ea_session == NULL) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapSRP2; - } - break; - - case eapSRP2: + if (status == 1) { + pcb->eap.es_server.ea_state = eapMD5Chall; + } else if (status != 0 || pcb->eap.es_server.ea_session == NULL) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapSRP2; + } + break; + + case eapSRP2: #ifdef USE_SRP - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL && status != 0) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL && status != 0) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status != 0 || pcb->eap.es_server.ea_session == NULL) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapSRP3; - } - break; - - case eapSRP3: - case eapSRP4: + if (status != 0 || pcb->eap.es_server.ea_session == NULL) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapSRP3; + } + break; + + case eapSRP3: + case eapSRP4: #ifdef USE_SRP - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL && status != 0) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL && status != 0) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status != 0 || pcb->eap.es_server.ea_session == NULL) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapOpen; - } - break; - - case eapMD5Chall: - if (status != 0) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapOpen; - } - break; - - default: - pcb->eap.es_server.ea_state = eapBadAuth; - break; - } - if (pcb->eap.es_server.ea_state == eapBadAuth) - eap_send_failure(pcb); + if (status != 0 || pcb->eap.es_server.ea_session == NULL) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapOpen; + } + break; + + case eapMD5Chall: + if (status != 0) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapOpen; + } + break; + + default: + pcb->eap.es_server.ea_state = eapBadAuth; + break; + } + if (pcb->eap.es_server.ea_state == eapBadAuth) + eap_send_failure(pcb); } /* @@ -636,235 +636,235 @@ static void eap_figure_next_state(ppp_pcb *pcb, int status) { * type depends on current state. (Server operation) */ static void eap_send_request(ppp_pcb *pcb) { - struct pbuf *p; - u_char *outp; - u_char *lenloc; - int outlen; - int len; - const char *str; + struct pbuf *p; + u_char *outp; + u_char *lenloc; + int outlen; + int len; + const char *str; #ifdef USE_SRP - struct t_server *ts; - u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp; - int i, j; - struct b64state b64; - SHA1_CTX ctxt; + struct t_server *ts; + u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp; + int i, j; + struct b64state b64; + SHA1_CTX ctxt; #endif /* USE_SRP */ - /* Handle both initial auth and restart */ - if (pcb->eap.es_server.ea_state < eapIdentify && - pcb->eap.es_server.ea_state != eapInitial) { - pcb->eap.es_server.ea_state = eapIdentify; + /* Handle both initial auth and restart */ + if (pcb->eap.es_server.ea_state < eapIdentify && + pcb->eap.es_server.ea_state != eapInitial) { + pcb->eap.es_server.ea_state = eapIdentify; #if PPP_REMOTENAME - if (pcb->settings.explicit_remote && pcb->remote_name) { - /* - * If we already know the peer's - * unauthenticated name, then there's no - * reason to ask. Go to next state instead. - */ - int len = (int)strlen(pcb->remote_name); - if (len > MAXNAMELEN) { - len = MAXNAMELEN; - } - MEMCPY(pcb->eap.es_server.ea_peer, pcb->remote_name, len); - pcb->eap.es_server.ea_peer[len] = '\0'; - pcb->eap.es_server.ea_peerlen = len; - eap_figure_next_state(pcb, 0); - } + if (pcb->settings.explicit_remote && pcb->remote_name) { + /* + * If we already know the peer's + * unauthenticated name, then there's no + * reason to ask. Go to next state instead. + */ + int len = (int)strlen(pcb->remote_name); + if (len > MAXNAMELEN) { + len = MAXNAMELEN; + } + MEMCPY(pcb->eap.es_server.ea_peer, pcb->remote_name, len); + pcb->eap.es_server.ea_peer[len] = '\0'; + pcb->eap.es_server.ea_peerlen = len; + eap_figure_next_state(pcb, 0); + } #endif /* PPP_REMOTENAME */ - } - - if (pcb->settings.eap_max_transmits > 0 && - pcb->eap.es_server.ea_requests >= pcb->settings.eap_max_transmits) { - if (pcb->eap.es_server.ea_responses > 0) - ppp_error("EAP: too many Requests sent"); - else - ppp_error("EAP: no response to Requests"); - eap_send_failure(pcb); - return; - } - - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_CTRL_PBUF_MAX_SIZE), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_REQUEST, outp); - PUTCHAR(pcb->eap.es_server.ea_id, outp); - lenloc = outp; - INCPTR(2, outp); - - switch (pcb->eap.es_server.ea_state) { - case eapIdentify: - PUTCHAR(EAPT_IDENTITY, outp); - str = "Name"; - len = strlen(str); - MEMCPY(outp, str, len); - INCPTR(len, outp); - break; - - case eapMD5Chall: - PUTCHAR(EAPT_MD5CHAP, outp); - /* - * pick a random challenge length between - * EAP_MIN_CHALLENGE_LENGTH and EAP_MAX_CHALLENGE_LENGTH - */ - pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + - magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); - PUTCHAR(pcb->eap.es_challen, outp); - magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); - MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); - INCPTR(pcb->eap.es_challen, outp); - MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); - INCPTR(pcb->eap.es_server.ea_namelen, outp); - break; + } + + if (pcb->settings.eap_max_transmits > 0 && + pcb->eap.es_server.ea_requests >= pcb->settings.eap_max_transmits) { + if (pcb->eap.es_server.ea_responses > 0) + ppp_error("EAP: too many Requests sent"); + else + ppp_error("EAP: no response to Requests"); + eap_send_failure(pcb); + return; + } + + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_CTRL_PBUF_MAX_SIZE), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_REQUEST, outp); + PUTCHAR(pcb->eap.es_server.ea_id, outp); + lenloc = outp; + INCPTR(2, outp); + + switch (pcb->eap.es_server.ea_state) { + case eapIdentify: + PUTCHAR(EAPT_IDENTITY, outp); + str = "Name"; + len = strlen(str); + MEMCPY(outp, str, len); + INCPTR(len, outp); + break; + + case eapMD5Chall: + PUTCHAR(EAPT_MD5CHAP, outp); + /* + * pick a random challenge length between + * EAP_MIN_CHALLENGE_LENGTH and EAP_MAX_CHALLENGE_LENGTH + */ + pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + + magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); + PUTCHAR(pcb->eap.es_challen, outp); + magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); + MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); + INCPTR(pcb->eap.es_challen, outp); + MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); + INCPTR(pcb->eap.es_server.ea_namelen, outp); + break; #ifdef USE_SRP - case eapSRP1: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_CHALLENGE, outp); - - PUTCHAR(pcb->eap.es_server.ea_namelen, outp); - MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); - INCPTR(pcb->eap.es_server.ea_namelen, outp); - - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - PUTCHAR(ts->s.len, outp); - MEMCPY(outp, ts->s.data, ts->s.len); - INCPTR(ts->s.len, outp); - - if (ts->g.len == 1 && ts->g.data[0] == 2) { - PUTCHAR(0, outp); - } else { - PUTCHAR(ts->g.len, outp); - MEMCPY(outp, ts->g.data, ts->g.len); - INCPTR(ts->g.len, outp); - } - - if (ts->n.len != sizeof (wkmodulus) || - BCMP(ts->n.data, wkmodulus, sizeof (wkmodulus)) != 0) { - MEMCPY(outp, ts->n.data, ts->n.len); - INCPTR(ts->n.len, outp); - } - break; - - case eapSRP2: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_SKEY, outp); - - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - MEMCPY(outp, ts->B.data, ts->B.len); - INCPTR(ts->B.len, outp); - break; - - case eapSRP3: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_SVALIDATOR, outp); - PUTLONG(SRPVAL_EBIT, outp); - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - MEMCPY(outp, t_serverresponse(ts), SHA_DIGESTSIZE); - INCPTR(SHA_DIGESTSIZE, outp); - - if (pncrypt_setkey(0)) { - /* Generate pseudonym */ - optr = outp; - cp = (unsigned char *)pcb->eap.es_server.ea_peer; - if ((j = i = pcb->eap.es_server.ea_peerlen) > 7) - j = 7; - clear[0] = i; - MEMCPY(clear + 1, cp, j); - i -= j; - cp += j; - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - if (!DesEncrypt(clear, cipher)) { - ppp_dbglog("no DES here; not generating pseudonym"); - break; - } - BZERO(&b64, sizeof (b64)); - outp++; /* space for pseudonym length */ - outp += b64enc(&b64, cipher, 8, outp); - while (i >= 8) { - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - (void) DesEncrypt(cp, cipher); - outp += b64enc(&b64, cipher, 8, outp); - cp += 8; - i -= 8; - } - if (i > 0) { - MEMCPY(clear, cp, i); - cp += i; - magic_random_bytes(cp, 8-i); - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - (void) DesEncrypt(clear, cipher); - outp += b64enc(&b64, cipher, 8, outp); - } - outp += b64flush(&b64, outp); - - /* Set length and pad out to next 20 octet boundary */ - i = outp - optr - 1; - *optr = i; - i %= SHA_DIGESTSIZE; - if (i != 0) { - magic_random_bytes(outp, SHA_DIGESTSIZE-i); - INCPTR(SHA_DIGESTSIZE-i, outp); - } - - /* Obscure the pseudonym with SHA1 hash */ - SHA1Init(&ctxt); - SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); - SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, - pcb->eap.es_server.ea_peerlen); - while (optr < outp) { - SHA1Final(dig, &ctxt); - cp = dig; - while (cp < dig + SHA_DIGESTSIZE) - *optr++ ^= *cp++; - SHA1Init(&ctxt); - SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); - SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, optr - SHA_DIGESTSIZE, - SHA_DIGESTSIZE); - } - } - break; - - case eapSRP4: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_LWRECHALLENGE, outp); - pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + - magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); - magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); - MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); - INCPTR(pcb->eap.es_challen, outp); - break; + case eapSRP1: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_CHALLENGE, outp); + + PUTCHAR(pcb->eap.es_server.ea_namelen, outp); + MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); + INCPTR(pcb->eap.es_server.ea_namelen, outp); + + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + PUTCHAR(ts->s.len, outp); + MEMCPY(outp, ts->s.data, ts->s.len); + INCPTR(ts->s.len, outp); + + if (ts->g.len == 1 && ts->g.data[0] == 2) { + PUTCHAR(0, outp); + } else { + PUTCHAR(ts->g.len, outp); + MEMCPY(outp, ts->g.data, ts->g.len); + INCPTR(ts->g.len, outp); + } + + if (ts->n.len != sizeof (wkmodulus) || + BCMP(ts->n.data, wkmodulus, sizeof (wkmodulus)) != 0) { + MEMCPY(outp, ts->n.data, ts->n.len); + INCPTR(ts->n.len, outp); + } + break; + + case eapSRP2: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_SKEY, outp); + + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + MEMCPY(outp, ts->B.data, ts->B.len); + INCPTR(ts->B.len, outp); + break; + + case eapSRP3: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_SVALIDATOR, outp); + PUTLONG(SRPVAL_EBIT, outp); + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + MEMCPY(outp, t_serverresponse(ts), SHA_DIGESTSIZE); + INCPTR(SHA_DIGESTSIZE, outp); + + if (pncrypt_setkey(0)) { + /* Generate pseudonym */ + optr = outp; + cp = (unsigned char *)pcb->eap.es_server.ea_peer; + if ((j = i = pcb->eap.es_server.ea_peerlen) > 7) + j = 7; + clear[0] = i; + MEMCPY(clear + 1, cp, j); + i -= j; + cp += j; + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + if (!DesEncrypt(clear, cipher)) { + ppp_dbglog("no DES here; not generating pseudonym"); + break; + } + BZERO(&b64, sizeof (b64)); + outp++; /* space for pseudonym length */ + outp += b64enc(&b64, cipher, 8, outp); + while (i >= 8) { + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + (void) DesEncrypt(cp, cipher); + outp += b64enc(&b64, cipher, 8, outp); + cp += 8; + i -= 8; + } + if (i > 0) { + MEMCPY(clear, cp, i); + cp += i; + magic_random_bytes(cp, 8-i); + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + (void) DesEncrypt(clear, cipher); + outp += b64enc(&b64, cipher, 8, outp); + } + outp += b64flush(&b64, outp); + + /* Set length and pad out to next 20 octet boundary */ + i = outp - optr - 1; + *optr = i; + i %= SHA_DIGESTSIZE; + if (i != 0) { + magic_random_bytes(outp, SHA_DIGESTSIZE-i); + INCPTR(SHA_DIGESTSIZE-i, outp); + } + + /* Obscure the pseudonym with SHA1 hash */ + SHA1Init(&ctxt); + SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); + SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, + pcb->eap.es_server.ea_peerlen); + while (optr < outp) { + SHA1Final(dig, &ctxt); + cp = dig; + while (cp < dig + SHA_DIGESTSIZE) + *optr++ ^= *cp++; + SHA1Init(&ctxt); + SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); + SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, optr - SHA_DIGESTSIZE, + SHA_DIGESTSIZE); + } + } + break; + + case eapSRP4: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_LWRECHALLENGE, outp); + pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + + magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); + magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); + MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); + INCPTR(pcb->eap.es_challen, outp); + break; #endif /* USE_SRP */ - default: - return; - } + default: + return; + } - outlen = (outp - (unsigned char*)p->payload) - PPP_HDRLEN; - PUTSHORT(outlen, lenloc); + outlen = (outp - (unsigned char*)p->payload) - PPP_HDRLEN; + PUTSHORT(outlen, lenloc); - pbuf_realloc(p, outlen + PPP_HDRLEN); - ppp_write(pcb, p); + pbuf_realloc(p, outlen + PPP_HDRLEN); + ppp_write(pcb, p); - pcb->eap.es_server.ea_requests++; + pcb->eap.es_server.ea_requests++; - if (pcb->settings.eap_timeout_time > 0) - TIMEOUT(eap_server_timeout, pcb, pcb->settings.eap_timeout_time); + if (pcb->settings.eap_timeout_time > 0) + TIMEOUT(eap_server_timeout, pcb, pcb->settings.eap_timeout_time); } /* @@ -875,23 +875,23 @@ static void eap_send_request(ppp_pcb *pcb) { */ void eap_authpeer(ppp_pcb *pcb, const char *localname) { - /* Save the name we're given. */ - pcb->eap.es_server.ea_name = localname; - pcb->eap.es_server.ea_namelen = strlen(localname); + /* Save the name we're given. */ + pcb->eap.es_server.ea_name = localname; + pcb->eap.es_server.ea_namelen = strlen(localname); - pcb->eap.es_savedtime = pcb->settings.eap_timeout_time; + pcb->eap.es_savedtime = pcb->settings.eap_timeout_time; - /* Lower layer up yet? */ - if (pcb->eap.es_server.ea_state == eapInitial || - pcb->eap.es_server.ea_state == eapPending) { - pcb->eap.es_server.ea_state = eapPending; - return; - } + /* Lower layer up yet? */ + if (pcb->eap.es_server.ea_state == eapInitial || + pcb->eap.es_server.ea_state == eapPending) { + pcb->eap.es_server.ea_state = eapPending; + return; + } - pcb->eap.es_server.ea_state = eapPending; + pcb->eap.es_server.ea_state = eapPending; - /* ID number not updated here intentionally; hashed into M1 */ - eap_send_request(pcb); + /* ID number not updated here intentionally; hashed into M1 */ + eap_send_request(pcb); } /* @@ -899,13 +899,13 @@ void eap_authpeer(ppp_pcb *pcb, const char *localname) { * expired. */ static void eap_server_timeout(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (!eap_server_active(pcb)) - return; + if (!eap_server_active(pcb)) + return; - /* EAP ID number must not change on timeout. */ - eap_send_request(pcb); + /* EAP ID number must not change on timeout. */ + eap_send_request(pcb); } /* @@ -914,30 +914,30 @@ static void eap_server_timeout(void *arg) { * will restart the timer. If it fails, then the link is dropped. */ static void eap_rechallenge(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (pcb->eap.es_server.ea_state != eapOpen && - pcb->eap.es_server.ea_state != eapSRP4) - return; + if (pcb->eap.es_server.ea_state != eapOpen && + pcb->eap.es_server.ea_state != eapSRP4) + return; - pcb->eap.es_server.ea_requests = 0; - pcb->eap.es_server.ea_state = eapIdentify; - eap_figure_next_state(pcb, 0); - pcb->eap.es_server.ea_id++; - eap_send_request(pcb); + pcb->eap.es_server.ea_requests = 0; + pcb->eap.es_server.ea_state = eapIdentify; + eap_figure_next_state(pcb, 0); + pcb->eap.es_server.ea_id++; + eap_send_request(pcb); } static void srp_lwrechallenge(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (pcb->eap.es_server.ea_state != eapOpen || - pcb->eap.es_server.ea_type != EAPT_SRP) - return; + if (pcb->eap.es_server.ea_state != eapOpen || + pcb->eap.es_server.ea_type != EAPT_SRP) + return; - pcb->eap.es_server.ea_requests = 0; - pcb->eap.es_server.ea_state = eapSRP4; - pcb->eap.es_server.ea_id++; - eap_send_request(pcb); + pcb->eap.es_server.ea_requests = 0; + pcb->eap.es_server.ea_state = eapSRP4; + pcb->eap.es_server.ea_id++; + eap_send_request(pcb); } #endif /* PPP_SERVER */ @@ -950,9 +950,9 @@ static void srp_lwrechallenge(void *arg) { * thing. */ static void eap_lowerup(ppp_pcb *pcb) { - pcb->eap.es_client.ea_state = eapClosed; + pcb->eap.es_client.ea_state = eapClosed; #if PPP_SERVER - pcb->eap.es_server.ea_state = eapClosed; + pcb->eap.es_server.ea_state = eapClosed; #endif /* PPP_SERVER */ } @@ -963,28 +963,28 @@ static void eap_lowerup(ppp_pcb *pcb) { */ static void eap_lowerdown(ppp_pcb *pcb) { - if (eap_client_active(pcb) && pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } + if (eap_client_active(pcb) && pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } #if PPP_SERVER - if (eap_server_active(pcb)) { - if (pcb->settings.eap_timeout_time > 0) { - UNTIMEOUT(eap_server_timeout, pcb); - } - } else { - if ((pcb->eap.es_server.ea_state == eapOpen || - pcb->eap.es_server.ea_state == eapSRP4) && - pcb->eap.es_rechallenge > 0) { - UNTIMEOUT(eap_rechallenge, (void *)pcb); - } - if (pcb->eap.es_server.ea_state == eapOpen && - pcb->eap.es_lwrechallenge > 0) { - UNTIMEOUT(srp_lwrechallenge, (void *)pcb); - } - } - - pcb->eap.es_client.ea_state = pcb->eap.es_server.ea_state = eapInitial; - pcb->eap.es_client.ea_requests = pcb->eap.es_server.ea_requests = 0; + if (eap_server_active(pcb)) { + if (pcb->settings.eap_timeout_time > 0) { + UNTIMEOUT(eap_server_timeout, pcb); + } + } else { + if ((pcb->eap.es_server.ea_state == eapOpen || + pcb->eap.es_server.ea_state == eapSRP4) && + pcb->eap.es_rechallenge > 0) { + UNTIMEOUT(eap_rechallenge, (void *)pcb); + } + if (pcb->eap.es_server.ea_state == eapOpen && + pcb->eap.es_lwrechallenge > 0) { + UNTIMEOUT(srp_lwrechallenge, (void *)pcb); + } + } + + pcb->eap.es_client.ea_state = pcb->eap.es_server.ea_state = eapInitial; + pcb->eap.es_client.ea_requests = pcb->eap.es_server.ea_requests = 0; #endif /* PPP_SERVER */ } @@ -996,87 +996,87 @@ static void eap_lowerdown(ppp_pcb *pcb) { */ static void eap_protrej(ppp_pcb *pcb) { - if (eap_client_active(pcb)) { - ppp_error("EAP authentication failed due to Protocol-Reject"); - auth_withpeer_fail(pcb, PPP_EAP); - } + if (eap_client_active(pcb)) { + ppp_error("EAP authentication failed due to Protocol-Reject"); + auth_withpeer_fail(pcb, PPP_EAP); + } #if PPP_SERVER - if (eap_server_active(pcb)) { - ppp_error("EAP authentication of peer failed on Protocol-Reject"); - auth_peer_fail(pcb, PPP_EAP); - } + if (eap_server_active(pcb)) { + ppp_error("EAP authentication of peer failed on Protocol-Reject"); + auth_peer_fail(pcb, PPP_EAP); + } #endif /* PPP_SERVER */ - eap_lowerdown(pcb); + eap_lowerdown(pcb); } /* * Format and send a regular EAP Response message. */ static void eap_send_response(ppp_pcb *pcb, u_char id, u_char typenum, const u_char *str, int lenstr) { - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + sizeof (u_char) + lenstr; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(typenum, outp); - if (lenstr > 0) { - MEMCPY(outp, str, lenstr); - } - - ppp_write(pcb, p); + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + sizeof (u_char) + lenstr; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(typenum, outp); + if (lenstr > 0) { + MEMCPY(outp, str, lenstr); + } + + ppp_write(pcb, p); } /* * Format and send an MD5-Challenge EAP Response message. */ static void eap_chap_response(ppp_pcb *pcb, u_char id, u_char *hash, const char *name, int namelen) { - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + MD5_SIGNATURE_SIZE + - namelen; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_MD5CHAP, outp); - PUTCHAR(MD5_SIGNATURE_SIZE, outp); - MEMCPY(outp, hash, MD5_SIGNATURE_SIZE); - INCPTR(MD5_SIGNATURE_SIZE, outp); - if (namelen > 0) { - MEMCPY(outp, name, namelen); - } - - ppp_write(pcb, p); + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + MD5_SIGNATURE_SIZE + + namelen; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_MD5CHAP, outp); + PUTCHAR(MD5_SIGNATURE_SIZE, outp); + MEMCPY(outp, hash, MD5_SIGNATURE_SIZE); + INCPTR(MD5_SIGNATURE_SIZE, outp); + if (namelen > 0) { + MEMCPY(outp, name, namelen); + } + + ppp_write(pcb, p); } #ifdef USE_SRP @@ -1091,35 +1091,35 @@ u_char subtypenum; u_char *str; int lenstr; { - ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + lenstr; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(subtypenum, outp); - if (lenstr > 0) { - MEMCPY(outp, str, lenstr); - } - - ppp_write(pcb, p); + ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + lenstr; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(subtypenum, outp); + if (lenstr > 0) { + MEMCPY(outp, str, lenstr); + } + + ppp_write(pcb, p); } /* @@ -1132,118 +1132,118 @@ u_char id; u32_t flags; u_char *str; { - ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + sizeof (u32_t) + - SHA_DIGESTSIZE; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_CVALIDATOR, outp); - PUTLONG(flags, outp); - MEMCPY(outp, str, SHA_DIGESTSIZE); - - ppp_write(pcb, p); + ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + sizeof (u32_t) + + SHA_DIGESTSIZE; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_CVALIDATOR, outp); + PUTLONG(flags, outp); + MEMCPY(outp, str, SHA_DIGESTSIZE); + + ppp_write(pcb, p); } #endif /* USE_SRP */ static void eap_send_nak(ppp_pcb *pcb, u_char id, u_char type) { - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char); - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_NAK, outp); - PUTCHAR(type, outp); - - ppp_write(pcb, p); + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char); + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_NAK, outp); + PUTCHAR(type, outp); + + ppp_write(pcb, p); } #ifdef USE_SRP static char * name_of_pn_file() { - char *user, *path, *file; - struct passwd *pw; - size_t pl; - static bool pnlogged = 0; - - pw = getpwuid(getuid()); - if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0) { - errno = EINVAL; - return (NULL); - } - file = _PATH_PSEUDONYM; - pl = strlen(user) + strlen(file) + 2; - path = malloc(pl); - if (path == NULL) - return (NULL); - (void) slprintf(path, pl, "%s/%s", user, file); - if (!pnlogged) { - ppp_dbglog("pseudonym file: %s", path); - pnlogged = 1; - } - return (path); + char *user, *path, *file; + struct passwd *pw; + size_t pl; + static bool pnlogged = 0; + + pw = getpwuid(getuid()); + if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0) { + errno = EINVAL; + return (NULL); + } + file = _PATH_PSEUDONYM; + pl = strlen(user) + strlen(file) + 2; + path = malloc(pl); + if (path == NULL) + return (NULL); + (void) slprintf(path, pl, "%s/%s", user, file); + if (!pnlogged) { + ppp_dbglog("pseudonym file: %s", path); + pnlogged = 1; + } + return (path); } static int open_pn_file(modebits) mode_t modebits; { - char *path; - int fd, err; - - if ((path = name_of_pn_file()) == NULL) - return (-1); - fd = open(path, modebits, S_IRUSR | S_IWUSR); - err = errno; - free(path); - errno = err; - return (fd); + char *path; + int fd, err; + + if ((path = name_of_pn_file()) == NULL) + return (-1); + fd = open(path, modebits, S_IRUSR | S_IWUSR); + err = errno; + free(path); + errno = err; + return (fd); } static void remove_pn_file() { - char *path; + char *path; - if ((path = name_of_pn_file()) != NULL) { - (void) unlink(path); - (void) free(path); - } + if ((path = name_of_pn_file()) != NULL) { + (void) unlink(path); + (void) free(path); + } } static void @@ -1252,56 +1252,56 @@ eap_state *esp; u_char *inp; int len, id; { - u_char val; - u_char *datp, *digp; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; - int dsize, fd, olen = len; - - /* - * Do the decoding by working backwards. This eliminates the need - * to save the decoded output in a separate buffer. - */ - val = id; - while (len > 0) { - if ((dsize = len % SHA_DIGESTSIZE) == 0) - dsize = SHA_DIGESTSIZE; - len -= dsize; - datp = inp + len; - SHA1Init(&ctxt); - SHA1Update(&ctxt, &val, 1); - SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, SESSION_KEY_LEN); - if (len > 0) { - SHA1Update(&ctxt, datp, SHA_DIGESTSIZE); - } else { - SHA1Update(&ctxt, pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - } - SHA1Final(dig, &ctxt); - for (digp = dig; digp < dig + SHA_DIGESTSIZE; digp++) - *datp++ ^= *digp; - } - - /* Now check that the result is sane */ - if (olen <= 0 || *inp + 1 > olen) { - ppp_dbglog("EAP: decoded pseudonym is unusable <%.*B>", olen, inp); - return; - } - - /* Save it away */ - fd = open_pn_file(O_WRONLY | O_CREAT | O_TRUNC); - if (fd < 0) { - ppp_dbglog("EAP: error saving pseudonym: %m"); - return; - } - len = write(fd, inp + 1, *inp); - if (close(fd) != -1 && len == *inp) { - ppp_dbglog("EAP: saved pseudonym"); - pcb->eap.es_usedpseudo = 0; - } else { - ppp_dbglog("EAP: failed to save pseudonym"); - remove_pn_file(); - } + u_char val; + u_char *datp, *digp; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; + int dsize, fd, olen = len; + + /* + * Do the decoding by working backwards. This eliminates the need + * to save the decoded output in a separate buffer. + */ + val = id; + while (len > 0) { + if ((dsize = len % SHA_DIGESTSIZE) == 0) + dsize = SHA_DIGESTSIZE; + len -= dsize; + datp = inp + len; + SHA1Init(&ctxt); + SHA1Update(&ctxt, &val, 1); + SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, SESSION_KEY_LEN); + if (len > 0) { + SHA1Update(&ctxt, datp, SHA_DIGESTSIZE); + } else { + SHA1Update(&ctxt, pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + } + SHA1Final(dig, &ctxt); + for (digp = dig; digp < dig + SHA_DIGESTSIZE; digp++) + *datp++ ^= *digp; + } + + /* Now check that the result is sane */ + if (olen <= 0 || *inp + 1 > olen) { + ppp_dbglog("EAP: decoded pseudonym is unusable <%.*B>", olen, inp); + return; + } + + /* Save it away */ + fd = open_pn_file(O_WRONLY | O_CREAT | O_TRUNC); + if (fd < 0) { + ppp_dbglog("EAP: error saving pseudonym: %m"); + return; + } + len = write(fd, inp + 1, *inp); + if (close(fd) != -1 && len == *inp) { + ppp_dbglog("EAP: saved pseudonym"); + pcb->eap.es_usedpseudo = 0; + } else { + ppp_dbglog("EAP: failed to save pseudonym"); + remove_pn_file(); + } } #endif /* USE_SRP */ @@ -1309,412 +1309,412 @@ int len, id; * eap_request - Receive EAP Request message (client mode). */ static void eap_request(ppp_pcb *pcb, u_char *inp, int id, int len) { - u_char typenum; - u_char vallen; - int secret_len; - char secret[MAXSECRETLEN]; - char rhostname[MAXNAMELEN]; - lwip_md5_context mdContext; - u_char hash[MD5_SIGNATURE_SIZE]; + u_char typenum; + u_char vallen; + int secret_len; + char secret[MAXSECRETLEN]; + char rhostname[MAXNAMELEN]; + lwip_md5_context mdContext; + u_char hash[MD5_SIGNATURE_SIZE]; #ifdef USE_SRP - struct t_client *tc; - struct t_num sval, gval, Nval, *Ap, Bval; - u_char vals[2]; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; - int fd; + struct t_client *tc; + struct t_num sval, gval, Nval, *Ap, Bval; + u_char vals[2]; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; + int fd; #endif /* USE_SRP */ - /* - * Note: we update es_client.ea_id *only if* a Response - * message is being generated. Otherwise, we leave it the - * same for duplicate detection purposes. - */ - - pcb->eap.es_client.ea_requests++; - if (pcb->settings.eap_allow_req != 0 && - pcb->eap.es_client.ea_requests > pcb->settings.eap_allow_req) { - ppp_info("EAP: received too many Request messages"); - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } - auth_withpeer_fail(pcb, PPP_EAP); - return; - } - - if (len <= 0) { - ppp_error("EAP: empty Request message discarded"); - return; - } - - GETCHAR(typenum, inp); - len--; - - switch (typenum) { - case EAPT_IDENTITY: - if (len > 0) - ppp_info("EAP: Identity prompt \"%.*q\"", len, inp); + /* + * Note: we update es_client.ea_id *only if* a Response + * message is being generated. Otherwise, we leave it the + * same for duplicate detection purposes. + */ + + pcb->eap.es_client.ea_requests++; + if (pcb->settings.eap_allow_req != 0 && + pcb->eap.es_client.ea_requests > pcb->settings.eap_allow_req) { + ppp_info("EAP: received too many Request messages"); + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } + auth_withpeer_fail(pcb, PPP_EAP); + return; + } + + if (len <= 0) { + ppp_error("EAP: empty Request message discarded"); + return; + } + + GETCHAR(typenum, inp); + len--; + + switch (typenum) { + case EAPT_IDENTITY: + if (len > 0) + ppp_info("EAP: Identity prompt \"%.*q\"", len, inp); #ifdef USE_SRP - if (pcb->eap.es_usepseudo && - (pcb->eap.es_usedpseudo == 0 || - (pcb->eap.es_usedpseudo == 1 && - id == pcb->eap.es_client.ea_id))) { - pcb->eap.es_usedpseudo = 1; - /* Try to get a pseudonym */ - if ((fd = open_pn_file(O_RDONLY)) >= 0) { - strcpy(rhostname, SRP_PSEUDO_ID); - len = read(fd, rhostname + SRP_PSEUDO_LEN, - sizeof (rhostname) - SRP_PSEUDO_LEN); - /* XXX NAI unsupported */ - if (len > 0) { - eap_send_response(pcb, id, typenum, - rhostname, len + SRP_PSEUDO_LEN); - } - (void) close(fd); - if (len > 0) - break; - } - } - /* Stop using pseudonym now. */ - if (pcb->eap.es_usepseudo && pcb->eap.es_usedpseudo != 2) { - remove_pn_file(); - pcb->eap.es_usedpseudo = 2; - } + if (pcb->eap.es_usepseudo && + (pcb->eap.es_usedpseudo == 0 || + (pcb->eap.es_usedpseudo == 1 && + id == pcb->eap.es_client.ea_id))) { + pcb->eap.es_usedpseudo = 1; + /* Try to get a pseudonym */ + if ((fd = open_pn_file(O_RDONLY)) >= 0) { + strcpy(rhostname, SRP_PSEUDO_ID); + len = read(fd, rhostname + SRP_PSEUDO_LEN, + sizeof (rhostname) - SRP_PSEUDO_LEN); + /* XXX NAI unsupported */ + if (len > 0) { + eap_send_response(pcb, id, typenum, + rhostname, len + SRP_PSEUDO_LEN); + } + (void) close(fd); + if (len > 0) + break; + } + } + /* Stop using pseudonym now. */ + if (pcb->eap.es_usepseudo && pcb->eap.es_usedpseudo != 2) { + remove_pn_file(); + pcb->eap.es_usedpseudo = 2; + } #endif /* USE_SRP */ - eap_send_response(pcb, id, typenum, (const u_char*)pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - break; - - case EAPT_NOTIFICATION: - if (len > 0) - ppp_info("EAP: Notification \"%.*q\"", len, inp); - eap_send_response(pcb, id, typenum, NULL, 0); - break; - - case EAPT_NAK: - /* - * Avoid the temptation to send Response Nak in reply - * to Request Nak here. It can only lead to trouble. - */ - ppp_warn("EAP: unexpected Nak in Request; ignored"); - /* Return because we're waiting for something real. */ - return; - - case EAPT_MD5CHAP: - if (len < 1) { - ppp_error("EAP: received MD5-Challenge with no data"); - /* Bogus request; wait for something real. */ - return; - } - GETCHAR(vallen, inp); - len--; - if (vallen < 8 || vallen > len) { - ppp_error("EAP: MD5-Challenge with bad length %d (8..%d)", - vallen, len); - /* Try something better. */ - eap_send_nak(pcb, id, EAPT_SRP); - break; - } - - /* Not so likely to happen. */ - if (vallen >= len + sizeof (rhostname)) { - ppp_dbglog("EAP: trimming really long peer name down"); - MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); - rhostname[sizeof (rhostname) - 1] = '\0'; - } else { - MEMCPY(rhostname, inp + vallen, len - vallen); - rhostname[len - vallen] = '\0'; - } + eap_send_response(pcb, id, typenum, (const u_char*)pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + break; + + case EAPT_NOTIFICATION: + if (len > 0) + ppp_info("EAP: Notification \"%.*q\"", len, inp); + eap_send_response(pcb, id, typenum, NULL, 0); + break; + + case EAPT_NAK: + /* + * Avoid the temptation to send Response Nak in reply + * to Request Nak here. It can only lead to trouble. + */ + ppp_warn("EAP: unexpected Nak in Request; ignored"); + /* Return because we're waiting for something real. */ + return; + + case EAPT_MD5CHAP: + if (len < 1) { + ppp_error("EAP: received MD5-Challenge with no data"); + /* Bogus request; wait for something real. */ + return; + } + GETCHAR(vallen, inp); + len--; + if (vallen < 8 || vallen > len) { + ppp_error("EAP: MD5-Challenge with bad length %d (8..%d)", + vallen, len); + /* Try something better. */ + eap_send_nak(pcb, id, EAPT_SRP); + break; + } + + /* Not so likely to happen. */ + if (vallen >= len + sizeof (rhostname)) { + ppp_dbglog("EAP: trimming really long peer name down"); + MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); + rhostname[sizeof (rhostname) - 1] = '\0'; + } else { + MEMCPY(rhostname, inp + vallen, len - vallen); + rhostname[len - vallen] = '\0'; + } #if PPP_REMOTENAME - /* In case the remote doesn't give us his name. */ - if (pcb->settings.explicit_remote || - (pcb->settings.remote_name[0] != '\0' && vallen == len)) - strlcpy(rhostname, pcb->settings.remote_name, sizeof (rhostname)); + /* In case the remote doesn't give us his name. */ + if (pcb->settings.explicit_remote || + (pcb->settings.remote_name[0] != '\0' && vallen == len)) + strlcpy(rhostname, pcb->settings.remote_name, sizeof (rhostname)); #endif /* PPP_REMOTENAME */ - /* - * Get the secret for authenticating ourselves with - * the specified host. - */ - if (!get_secret(pcb, pcb->eap.es_client.ea_name, - rhostname, secret, &secret_len, 0)) { - ppp_dbglog("EAP: no MD5 secret for auth to %q", rhostname); - eap_send_nak(pcb, id, EAPT_SRP); - break; - } - lwip_md5_init(&mdContext); - lwip_md5_starts(&mdContext); - typenum = id; - lwip_md5_update(&mdContext, &typenum, 1); - lwip_md5_update(&mdContext, (u_char *)secret, secret_len); - BZERO(secret, sizeof (secret)); - lwip_md5_update(&mdContext, inp, vallen); - lwip_md5_finish(&mdContext, hash); - lwip_md5_free(&mdContext); - eap_chap_response(pcb, id, hash, pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - break; + /* + * Get the secret for authenticating ourselves with + * the specified host. + */ + if (!get_secret(pcb, pcb->eap.es_client.ea_name, + rhostname, secret, &secret_len, 0)) { + ppp_dbglog("EAP: no MD5 secret for auth to %q", rhostname); + eap_send_nak(pcb, id, EAPT_SRP); + break; + } + lwip_md5_init(&mdContext); + lwip_md5_starts(&mdContext); + typenum = id; + lwip_md5_update(&mdContext, &typenum, 1); + lwip_md5_update(&mdContext, (u_char *)secret, secret_len); + BZERO(secret, sizeof (secret)); + lwip_md5_update(&mdContext, inp, vallen); + lwip_md5_finish(&mdContext, hash); + lwip_md5_free(&mdContext); + eap_chap_response(pcb, id, hash, pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + break; #ifdef USE_SRP - case EAPT_SRP: - if (len < 1) { - ppp_error("EAP: received empty SRP Request"); - /* Bogus request; wait for something real. */ - return; - } - - /* Get subtype */ - GETCHAR(vallen, inp); - len--; - switch (vallen) { - case EAPSRP_CHALLENGE: - tc = NULL; - if (pcb->eap.es_client.ea_session != NULL) { - tc = (struct t_client *)pcb->eap.es_client. - ea_session; - /* - * If this is a new challenge, then start - * over with a new client session context. - * Otherwise, just resend last response. - */ - if (id != pcb->eap.es_client.ea_id) { - t_clientclose(tc); - pcb->eap.es_client.ea_session = NULL; - tc = NULL; - } - } - /* No session key just yet */ - pcb->eap.es_client.ea_skey = NULL; - if (tc == NULL) { - int rhostnamelen; - - GETCHAR(vallen, inp); - len--; - if (vallen >= len) { - ppp_error("EAP: badly-formed SRP Challenge" - " (name)"); - /* Ignore badly-formed messages */ - return; - } - MEMCPY(rhostname, inp, vallen); - rhostname[vallen] = '\0'; - INCPTR(vallen, inp); - len -= vallen; - - /* - * In case the remote doesn't give us his name, - * use configured name. - */ - if (explicit_remote || - (remote_name[0] != '\0' && vallen == 0)) { - strlcpy(rhostname, remote_name, - sizeof (rhostname)); - } - - rhostnamelen = (int)strlen(rhostname); - if (rhostnamelen > MAXNAMELEN) { - rhostnamelen = MAXNAMELEN; - } - MEMCPY(pcb->eap.es_client.ea_peer, rhostname, rhostnamelen); - pcb->eap.es_client.ea_peer[rhostnamelen] = '\0'; - pcb->eap.es_client.ea_peerlen = rhostnamelen; - - GETCHAR(vallen, inp); - len--; - if (vallen >= len) { - ppp_error("EAP: badly-formed SRP Challenge" - " (s)"); - /* Ignore badly-formed messages */ - return; - } - sval.data = inp; - sval.len = vallen; - INCPTR(vallen, inp); - len -= vallen; - - GETCHAR(vallen, inp); - len--; - if (vallen > len) { - ppp_error("EAP: badly-formed SRP Challenge" - " (g)"); - /* Ignore badly-formed messages */ - return; - } - /* If no generator present, then use value 2 */ - if (vallen == 0) { - gval.data = (u_char *)"\002"; - gval.len = 1; - } else { - gval.data = inp; - gval.len = vallen; - } - INCPTR(vallen, inp); - len -= vallen; - - /* - * If no modulus present, then use well-known - * value. - */ - if (len == 0) { - Nval.data = (u_char *)wkmodulus; - Nval.len = sizeof (wkmodulus); - } else { - Nval.data = inp; - Nval.len = len; - } - tc = t_clientopen(pcb->eap.es_client.ea_name, - &Nval, &gval, &sval); - if (tc == NULL) { - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - pcb->eap.es_client.ea_session = (void *)tc; - - /* Add Challenge ID & type to verifier */ - vals[0] = id; - vals[1] = EAPT_SRP; - t_clientaddexdata(tc, vals, 2); - } - Ap = t_clientgenexp(tc); - eap_srp_response(esp, id, EAPSRP_CKEY, Ap->data, - Ap->len); - break; - - case EAPSRP_SKEY: - tc = (struct t_client *)pcb->eap.es_client.ea_session; - if (tc == NULL) { - ppp_warn("EAP: peer sent Subtype 2 without 1"); - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - if (pcb->eap.es_client.ea_skey != NULL) { - /* - * ID number should not change here. Warn - * if it does (but otherwise ignore). - */ - if (id != pcb->eap.es_client.ea_id) { - ppp_warn("EAP: ID changed from %d to %d " - "in SRP Subtype 2 rexmit", - pcb->eap.es_client.ea_id, id); - } - } else { - if (get_srp_secret(pcb->eap.es_unit, - pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_peer, secret, 0) == 0) { - /* - * Can't work with this peer because - * the secret is missing. Just give - * up. - */ - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - Bval.data = inp; - Bval.len = len; - t_clientpasswd(tc, secret); - BZERO(secret, sizeof (secret)); - pcb->eap.es_client.ea_skey = - t_clientgetkey(tc, &Bval); - if (pcb->eap.es_client.ea_skey == NULL) { - /* Server is rogue; stop now */ - ppp_error("EAP: SRP server is rogue"); - goto client_failure; - } - } - eap_srpval_response(esp, id, SRPVAL_EBIT, - t_clientresponse(tc)); - break; - - case EAPSRP_SVALIDATOR: - tc = (struct t_client *)pcb->eap.es_client.ea_session; - if (tc == NULL || pcb->eap.es_client.ea_skey == NULL) { - ppp_warn("EAP: peer sent Subtype 3 without 1/2"); - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - /* - * If we're already open, then this ought to be a - * duplicate. Otherwise, check that the server is - * who we think it is. - */ - if (pcb->eap.es_client.ea_state == eapOpen) { - if (id != pcb->eap.es_client.ea_id) { - ppp_warn("EAP: ID changed from %d to %d " - "in SRP Subtype 3 rexmit", - pcb->eap.es_client.ea_id, id); - } - } else { - len -= sizeof (u32_t) + SHA_DIGESTSIZE; - if (len < 0 || t_clientverify(tc, inp + - sizeof (u32_t)) != 0) { - ppp_error("EAP: SRP server verification " - "failed"); - goto client_failure; - } - GETLONG(pcb->eap.es_client.ea_keyflags, inp); - /* Save pseudonym if user wants it. */ - if (len > 0 && pcb->eap.es_usepseudo) { - INCPTR(SHA_DIGESTSIZE, inp); - write_pseudonym(esp, inp, len, id); - } - } - /* - * We've verified our peer. We're now mostly done, - * except for waiting on the regular EAP Success - * message. - */ - eap_srp_response(esp, id, EAPSRP_ACK, NULL, 0); - break; - - case EAPSRP_LWRECHALLENGE: - if (len < 4) { - ppp_warn("EAP: malformed Lightweight rechallenge"); - return; - } - SHA1Init(&ctxt); - vals[0] = id; - SHA1Update(&ctxt, vals, 1); - SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, inp, len); - SHA1Update(&ctxt, pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - SHA1Final(dig, &ctxt); - eap_srp_response(esp, id, EAPSRP_LWRECHALLENGE, dig, - SHA_DIGESTSIZE); - break; - - default: - ppp_error("EAP: unknown SRP Subtype %d", vallen); - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - break; + case EAPT_SRP: + if (len < 1) { + ppp_error("EAP: received empty SRP Request"); + /* Bogus request; wait for something real. */ + return; + } + + /* Get subtype */ + GETCHAR(vallen, inp); + len--; + switch (vallen) { + case EAPSRP_CHALLENGE: + tc = NULL; + if (pcb->eap.es_client.ea_session != NULL) { + tc = (struct t_client *)pcb->eap.es_client. + ea_session; + /* + * If this is a new challenge, then start + * over with a new client session context. + * Otherwise, just resend last response. + */ + if (id != pcb->eap.es_client.ea_id) { + t_clientclose(tc); + pcb->eap.es_client.ea_session = NULL; + tc = NULL; + } + } + /* No session key just yet */ + pcb->eap.es_client.ea_skey = NULL; + if (tc == NULL) { + int rhostnamelen; + + GETCHAR(vallen, inp); + len--; + if (vallen >= len) { + ppp_error("EAP: badly-formed SRP Challenge" + " (name)"); + /* Ignore badly-formed messages */ + return; + } + MEMCPY(rhostname, inp, vallen); + rhostname[vallen] = '\0'; + INCPTR(vallen, inp); + len -= vallen; + + /* + * In case the remote doesn't give us his name, + * use configured name. + */ + if (explicit_remote || + (remote_name[0] != '\0' && vallen == 0)) { + strlcpy(rhostname, remote_name, + sizeof (rhostname)); + } + + rhostnamelen = (int)strlen(rhostname); + if (rhostnamelen > MAXNAMELEN) { + rhostnamelen = MAXNAMELEN; + } + MEMCPY(pcb->eap.es_client.ea_peer, rhostname, rhostnamelen); + pcb->eap.es_client.ea_peer[rhostnamelen] = '\0'; + pcb->eap.es_client.ea_peerlen = rhostnamelen; + + GETCHAR(vallen, inp); + len--; + if (vallen >= len) { + ppp_error("EAP: badly-formed SRP Challenge" + " (s)"); + /* Ignore badly-formed messages */ + return; + } + sval.data = inp; + sval.len = vallen; + INCPTR(vallen, inp); + len -= vallen; + + GETCHAR(vallen, inp); + len--; + if (vallen > len) { + ppp_error("EAP: badly-formed SRP Challenge" + " (g)"); + /* Ignore badly-formed messages */ + return; + } + /* If no generator present, then use value 2 */ + if (vallen == 0) { + gval.data = (u_char *)"\002"; + gval.len = 1; + } else { + gval.data = inp; + gval.len = vallen; + } + INCPTR(vallen, inp); + len -= vallen; + + /* + * If no modulus present, then use well-known + * value. + */ + if (len == 0) { + Nval.data = (u_char *)wkmodulus; + Nval.len = sizeof (wkmodulus); + } else { + Nval.data = inp; + Nval.len = len; + } + tc = t_clientopen(pcb->eap.es_client.ea_name, + &Nval, &gval, &sval); + if (tc == NULL) { + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + pcb->eap.es_client.ea_session = (void *)tc; + + /* Add Challenge ID & type to verifier */ + vals[0] = id; + vals[1] = EAPT_SRP; + t_clientaddexdata(tc, vals, 2); + } + Ap = t_clientgenexp(tc); + eap_srp_response(esp, id, EAPSRP_CKEY, Ap->data, + Ap->len); + break; + + case EAPSRP_SKEY: + tc = (struct t_client *)pcb->eap.es_client.ea_session; + if (tc == NULL) { + ppp_warn("EAP: peer sent Subtype 2 without 1"); + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + if (pcb->eap.es_client.ea_skey != NULL) { + /* + * ID number should not change here. Warn + * if it does (but otherwise ignore). + */ + if (id != pcb->eap.es_client.ea_id) { + ppp_warn("EAP: ID changed from %d to %d " + "in SRP Subtype 2 rexmit", + pcb->eap.es_client.ea_id, id); + } + } else { + if (get_srp_secret(pcb->eap.es_unit, + pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_peer, secret, 0) == 0) { + /* + * Can't work with this peer because + * the secret is missing. Just give + * up. + */ + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + Bval.data = inp; + Bval.len = len; + t_clientpasswd(tc, secret); + BZERO(secret, sizeof (secret)); + pcb->eap.es_client.ea_skey = + t_clientgetkey(tc, &Bval); + if (pcb->eap.es_client.ea_skey == NULL) { + /* Server is rogue; stop now */ + ppp_error("EAP: SRP server is rogue"); + goto client_failure; + } + } + eap_srpval_response(esp, id, SRPVAL_EBIT, + t_clientresponse(tc)); + break; + + case EAPSRP_SVALIDATOR: + tc = (struct t_client *)pcb->eap.es_client.ea_session; + if (tc == NULL || pcb->eap.es_client.ea_skey == NULL) { + ppp_warn("EAP: peer sent Subtype 3 without 1/2"); + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + /* + * If we're already open, then this ought to be a + * duplicate. Otherwise, check that the server is + * who we think it is. + */ + if (pcb->eap.es_client.ea_state == eapOpen) { + if (id != pcb->eap.es_client.ea_id) { + ppp_warn("EAP: ID changed from %d to %d " + "in SRP Subtype 3 rexmit", + pcb->eap.es_client.ea_id, id); + } + } else { + len -= sizeof (u32_t) + SHA_DIGESTSIZE; + if (len < 0 || t_clientverify(tc, inp + + sizeof (u32_t)) != 0) { + ppp_error("EAP: SRP server verification " + "failed"); + goto client_failure; + } + GETLONG(pcb->eap.es_client.ea_keyflags, inp); + /* Save pseudonym if user wants it. */ + if (len > 0 && pcb->eap.es_usepseudo) { + INCPTR(SHA_DIGESTSIZE, inp); + write_pseudonym(esp, inp, len, id); + } + } + /* + * We've verified our peer. We're now mostly done, + * except for waiting on the regular EAP Success + * message. + */ + eap_srp_response(esp, id, EAPSRP_ACK, NULL, 0); + break; + + case EAPSRP_LWRECHALLENGE: + if (len < 4) { + ppp_warn("EAP: malformed Lightweight rechallenge"); + return; + } + SHA1Init(&ctxt); + vals[0] = id; + SHA1Update(&ctxt, vals, 1); + SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, inp, len); + SHA1Update(&ctxt, pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + SHA1Final(dig, &ctxt); + eap_srp_response(esp, id, EAPSRP_LWRECHALLENGE, dig, + SHA_DIGESTSIZE); + break; + + default: + ppp_error("EAP: unknown SRP Subtype %d", vallen); + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + break; #endif /* USE_SRP */ - default: - ppp_info("EAP: unknown authentication type %d; Naking", typenum); - eap_send_nak(pcb, id, EAPT_SRP); - break; - } + default: + ppp_info("EAP: unknown authentication type %d; Naking", typenum); + eap_send_nak(pcb, id, EAPT_SRP); + break; + } - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - TIMEOUT(eap_client_timeout, pcb, - pcb->settings.eap_req_time); - } - return; + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + TIMEOUT(eap_client_timeout, pcb, + pcb->settings.eap_req_time); + } + return; #ifdef USE_SRP client_failure: - pcb->eap.es_client.ea_state = eapBadAuth; - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, (void *)esp); - } - pcb->eap.es_client.ea_session = NULL; - t_clientclose(tc); - auth_withpeer_fail(pcb, PPP_EAP); + pcb->eap.es_client.ea_state = eapBadAuth; + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, (void *)esp); + } + pcb->eap.es_client.ea_session = NULL; + t_clientclose(tc); + auth_withpeer_fail(pcb, PPP_EAP); #endif /* USE_SRP */ } @@ -1723,291 +1723,291 @@ client_failure: * eap_response - Receive EAP Response message (server mode). */ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) { - u_char typenum; - u_char vallen; - int secret_len; - char secret[MAXSECRETLEN]; - char rhostname[MAXNAMELEN]; - lwip_md5_context mdContext; - u_char hash[MD5_SIGNATURE_SIZE]; + u_char typenum; + u_char vallen; + int secret_len; + char secret[MAXSECRETLEN]; + char rhostname[MAXNAMELEN]; + lwip_md5_context mdContext; + u_char hash[MD5_SIGNATURE_SIZE]; #ifdef USE_SRP - struct t_server *ts; - struct t_num A; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; + struct t_server *ts; + struct t_num A; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; #endif /* USE_SRP */ - if (pcb->eap.es_server.ea_id != id) { - ppp_dbglog("EAP: discarding Response %d; expected ID %d", id, - pcb->eap.es_server.ea_id); - return; - } - - pcb->eap.es_server.ea_responses++; - - if (len <= 0) { - ppp_error("EAP: empty Response message discarded"); - return; - } - - GETCHAR(typenum, inp); - len--; - - switch (typenum) { - case EAPT_IDENTITY: - if (pcb->eap.es_server.ea_state != eapIdentify) { - ppp_dbglog("EAP discarding unwanted Identify \"%.q\"", len, - inp); - break; - } - ppp_info("EAP: unauthenticated peer name \"%.*q\"", len, inp); - if (len > MAXNAMELEN) { - len = MAXNAMELEN; - } - MEMCPY(pcb->eap.es_server.ea_peer, inp, len); - pcb->eap.es_server.ea_peer[len] = '\0'; - pcb->eap.es_server.ea_peerlen = len; - eap_figure_next_state(pcb, 0); - break; - - case EAPT_NOTIFICATION: - ppp_dbglog("EAP unexpected Notification; response discarded"); - break; - - case EAPT_NAK: - if (len < 1) { - ppp_info("EAP: Nak Response with no suggested protocol"); - eap_figure_next_state(pcb, 1); - break; - } - - GETCHAR(vallen, inp); - len--; - - if ( + if (pcb->eap.es_server.ea_id != id) { + ppp_dbglog("EAP: discarding Response %d; expected ID %d", id, + pcb->eap.es_server.ea_id); + return; + } + + pcb->eap.es_server.ea_responses++; + + if (len <= 0) { + ppp_error("EAP: empty Response message discarded"); + return; + } + + GETCHAR(typenum, inp); + len--; + + switch (typenum) { + case EAPT_IDENTITY: + if (pcb->eap.es_server.ea_state != eapIdentify) { + ppp_dbglog("EAP discarding unwanted Identify \"%.q\"", len, + inp); + break; + } + ppp_info("EAP: unauthenticated peer name \"%.*q\"", len, inp); + if (len > MAXNAMELEN) { + len = MAXNAMELEN; + } + MEMCPY(pcb->eap.es_server.ea_peer, inp, len); + pcb->eap.es_server.ea_peer[len] = '\0'; + pcb->eap.es_server.ea_peerlen = len; + eap_figure_next_state(pcb, 0); + break; + + case EAPT_NOTIFICATION: + ppp_dbglog("EAP unexpected Notification; response discarded"); + break; + + case EAPT_NAK: + if (len < 1) { + ppp_info("EAP: Nak Response with no suggested protocol"); + eap_figure_next_state(pcb, 1); + break; + } + + GETCHAR(vallen, inp); + len--; + + if ( #if PPP_REMOTENAME - !pcb->explicit_remote && + !pcb->explicit_remote && #endif /* PPP_REMOTENAME */ - pcb->eap.es_server.ea_state == eapIdentify){ - /* Peer cannot Nak Identify Request */ - eap_figure_next_state(pcb, 1); - break; - } - - switch (vallen) { - case EAPT_SRP: - /* Run through SRP validator selection again. */ - pcb->eap.es_server.ea_state = eapIdentify; - eap_figure_next_state(pcb, 0); - break; - - case EAPT_MD5CHAP: - pcb->eap.es_server.ea_state = eapMD5Chall; - break; - - default: - ppp_dbglog("EAP: peer requesting unknown Type %d", vallen); - switch (pcb->eap.es_server.ea_state) { - case eapSRP1: - case eapSRP2: - case eapSRP3: - pcb->eap.es_server.ea_state = eapMD5Chall; - break; - case eapMD5Chall: - case eapSRP4: - pcb->eap.es_server.ea_state = eapIdentify; - eap_figure_next_state(pcb, 0); - break; - default: - break; - } - break; - } - break; - - case EAPT_MD5CHAP: - if (pcb->eap.es_server.ea_state != eapMD5Chall) { - ppp_error("EAP: unexpected MD5-Response"); - eap_figure_next_state(pcb, 1); - break; - } - if (len < 1) { - ppp_error("EAP: received MD5-Response with no data"); - eap_figure_next_state(pcb, 1); - break; - } - GETCHAR(vallen, inp); - len--; - if (vallen != 16 || vallen > len) { - ppp_error("EAP: MD5-Response with bad length %d", vallen); - eap_figure_next_state(pcb, 1); - break; - } - - /* Not so likely to happen. */ - if (vallen >= len + sizeof (rhostname)) { - ppp_dbglog("EAP: trimming really long peer name down"); - MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); - rhostname[sizeof (rhostname) - 1] = '\0'; - } else { - MEMCPY(rhostname, inp + vallen, len - vallen); - rhostname[len - vallen] = '\0'; - } + pcb->eap.es_server.ea_state == eapIdentify){ + /* Peer cannot Nak Identify Request */ + eap_figure_next_state(pcb, 1); + break; + } + + switch (vallen) { + case EAPT_SRP: + /* Run through SRP validator selection again. */ + pcb->eap.es_server.ea_state = eapIdentify; + eap_figure_next_state(pcb, 0); + break; + + case EAPT_MD5CHAP: + pcb->eap.es_server.ea_state = eapMD5Chall; + break; + + default: + ppp_dbglog("EAP: peer requesting unknown Type %d", vallen); + switch (pcb->eap.es_server.ea_state) { + case eapSRP1: + case eapSRP2: + case eapSRP3: + pcb->eap.es_server.ea_state = eapMD5Chall; + break; + case eapMD5Chall: + case eapSRP4: + pcb->eap.es_server.ea_state = eapIdentify; + eap_figure_next_state(pcb, 0); + break; + default: + break; + } + break; + } + break; + + case EAPT_MD5CHAP: + if (pcb->eap.es_server.ea_state != eapMD5Chall) { + ppp_error("EAP: unexpected MD5-Response"); + eap_figure_next_state(pcb, 1); + break; + } + if (len < 1) { + ppp_error("EAP: received MD5-Response with no data"); + eap_figure_next_state(pcb, 1); + break; + } + GETCHAR(vallen, inp); + len--; + if (vallen != 16 || vallen > len) { + ppp_error("EAP: MD5-Response with bad length %d", vallen); + eap_figure_next_state(pcb, 1); + break; + } + + /* Not so likely to happen. */ + if (vallen >= len + sizeof (rhostname)) { + ppp_dbglog("EAP: trimming really long peer name down"); + MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); + rhostname[sizeof (rhostname) - 1] = '\0'; + } else { + MEMCPY(rhostname, inp + vallen, len - vallen); + rhostname[len - vallen] = '\0'; + } #if PPP_REMOTENAME - /* In case the remote doesn't give us his name. */ - if (explicit_remote || - (remote_name[0] != '\0' && vallen == len)) - strlcpy(rhostname, remote_name, sizeof (rhostname)); + /* In case the remote doesn't give us his name. */ + if (explicit_remote || + (remote_name[0] != '\0' && vallen == len)) + strlcpy(rhostname, remote_name, sizeof (rhostname)); #endif /* PPP_REMOTENAME */ - /* - * Get the secret for authenticating the specified - * host. - */ - if (!get_secret(pcb, rhostname, - pcb->eap.es_server.ea_name, secret, &secret_len, 1)) { - ppp_dbglog("EAP: no MD5 secret for auth of %q", rhostname); - eap_send_failure(pcb); - break; - } - lwip_md5_init(&mdContext); - lwip_md5_starts(&mdContext); - lwip_md5_update(&mdContext, &pcb->eap.es_server.ea_id, 1); - lwip_md5_update(&mdContext, (u_char *)secret, secret_len); - BZERO(secret, sizeof (secret)); - lwip_md5_update(&mdContext, pcb->eap.es_challenge, pcb->eap.es_challen); - lwip_md5_finish(&mdContext, hash); - lwip_md5_free(&mdContext); - if (BCMP(hash, inp, MD5_SIGNATURE_SIZE) != 0) { - eap_send_failure(pcb); - break; - } - pcb->eap.es_server.ea_type = EAPT_MD5CHAP; - eap_send_success(pcb); - eap_figure_next_state(pcb, 0); - if (pcb->eap.es_rechallenge != 0) - TIMEOUT(eap_rechallenge, pcb, pcb->eap.es_rechallenge); - break; + /* + * Get the secret for authenticating the specified + * host. + */ + if (!get_secret(pcb, rhostname, + pcb->eap.es_server.ea_name, secret, &secret_len, 1)) { + ppp_dbglog("EAP: no MD5 secret for auth of %q", rhostname); + eap_send_failure(pcb); + break; + } + lwip_md5_init(&mdContext); + lwip_md5_starts(&mdContext); + lwip_md5_update(&mdContext, &pcb->eap.es_server.ea_id, 1); + lwip_md5_update(&mdContext, (u_char *)secret, secret_len); + BZERO(secret, sizeof (secret)); + lwip_md5_update(&mdContext, pcb->eap.es_challenge, pcb->eap.es_challen); + lwip_md5_finish(&mdContext, hash); + lwip_md5_free(&mdContext); + if (BCMP(hash, inp, MD5_SIGNATURE_SIZE) != 0) { + eap_send_failure(pcb); + break; + } + pcb->eap.es_server.ea_type = EAPT_MD5CHAP; + eap_send_success(pcb); + eap_figure_next_state(pcb, 0); + if (pcb->eap.es_rechallenge != 0) + TIMEOUT(eap_rechallenge, pcb, pcb->eap.es_rechallenge); + break; #ifdef USE_SRP - case EAPT_SRP: - if (len < 1) { - ppp_error("EAP: empty SRP Response"); - eap_figure_next_state(pcb, 1); - break; - } - GETCHAR(typenum, inp); - len--; - switch (typenum) { - case EAPSRP_CKEY: - if (pcb->eap.es_server.ea_state != eapSRP1) { - ppp_error("EAP: unexpected SRP Subtype 1 Response"); - eap_figure_next_state(pcb, 1); - break; - } - A.data = inp; - A.len = len; - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - pcb->eap.es_server.ea_skey = t_servergetkey(ts, &A); - if (pcb->eap.es_server.ea_skey == NULL) { - /* Client's A value is bogus; terminate now */ - ppp_error("EAP: bogus A value from client"); - eap_send_failure(pcb); - } else { - eap_figure_next_state(pcb, 0); - } - break; - - case EAPSRP_CVALIDATOR: - if (pcb->eap.es_server.ea_state != eapSRP2) { - ppp_error("EAP: unexpected SRP Subtype 2 Response"); - eap_figure_next_state(pcb, 1); - break; - } - if (len < sizeof (u32_t) + SHA_DIGESTSIZE) { - ppp_error("EAP: M1 length %d < %d", len, - sizeof (u32_t) + SHA_DIGESTSIZE); - eap_figure_next_state(pcb, 1); - break; - } - GETLONG(pcb->eap.es_server.ea_keyflags, inp); - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - if (t_serververify(ts, inp)) { - ppp_info("EAP: unable to validate client identity"); - eap_send_failure(pcb); - break; - } - eap_figure_next_state(pcb, 0); - break; - - case EAPSRP_ACK: - if (pcb->eap.es_server.ea_state != eapSRP3) { - ppp_error("EAP: unexpected SRP Subtype 3 Response"); - eap_send_failure(esp); - break; - } - pcb->eap.es_server.ea_type = EAPT_SRP; - eap_send_success(pcb, esp); - eap_figure_next_state(pcb, 0); - if (pcb->eap.es_rechallenge != 0) - TIMEOUT(eap_rechallenge, pcb, - pcb->eap.es_rechallenge); - if (pcb->eap.es_lwrechallenge != 0) - TIMEOUT(srp_lwrechallenge, pcb, - pcb->eap.es_lwrechallenge); - break; - - case EAPSRP_LWRECHALLENGE: - if (pcb->eap.es_server.ea_state != eapSRP4) { - ppp_info("EAP: unexpected SRP Subtype 4 Response"); - return; - } - if (len != SHA_DIGESTSIZE) { - ppp_error("EAP: bad Lightweight rechallenge " - "response"); - return; - } - SHA1Init(&ctxt); - vallen = id; - SHA1Update(&ctxt, &vallen, 1); - SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, pcb->eap.es_challenge, pcb->eap.es_challen); - SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, - pcb->eap.es_server.ea_peerlen); - SHA1Final(dig, &ctxt); - if (BCMP(dig, inp, SHA_DIGESTSIZE) != 0) { - ppp_error("EAP: failed Lightweight rechallenge"); - eap_send_failure(pcb); - break; - } - pcb->eap.es_server.ea_state = eapOpen; - if (pcb->eap.es_lwrechallenge != 0) - TIMEOUT(srp_lwrechallenge, esp, - pcb->eap.es_lwrechallenge); - break; - } - break; + case EAPT_SRP: + if (len < 1) { + ppp_error("EAP: empty SRP Response"); + eap_figure_next_state(pcb, 1); + break; + } + GETCHAR(typenum, inp); + len--; + switch (typenum) { + case EAPSRP_CKEY: + if (pcb->eap.es_server.ea_state != eapSRP1) { + ppp_error("EAP: unexpected SRP Subtype 1 Response"); + eap_figure_next_state(pcb, 1); + break; + } + A.data = inp; + A.len = len; + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + pcb->eap.es_server.ea_skey = t_servergetkey(ts, &A); + if (pcb->eap.es_server.ea_skey == NULL) { + /* Client's A value is bogus; terminate now */ + ppp_error("EAP: bogus A value from client"); + eap_send_failure(pcb); + } else { + eap_figure_next_state(pcb, 0); + } + break; + + case EAPSRP_CVALIDATOR: + if (pcb->eap.es_server.ea_state != eapSRP2) { + ppp_error("EAP: unexpected SRP Subtype 2 Response"); + eap_figure_next_state(pcb, 1); + break; + } + if (len < sizeof (u32_t) + SHA_DIGESTSIZE) { + ppp_error("EAP: M1 length %d < %d", len, + sizeof (u32_t) + SHA_DIGESTSIZE); + eap_figure_next_state(pcb, 1); + break; + } + GETLONG(pcb->eap.es_server.ea_keyflags, inp); + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + if (t_serververify(ts, inp)) { + ppp_info("EAP: unable to validate client identity"); + eap_send_failure(pcb); + break; + } + eap_figure_next_state(pcb, 0); + break; + + case EAPSRP_ACK: + if (pcb->eap.es_server.ea_state != eapSRP3) { + ppp_error("EAP: unexpected SRP Subtype 3 Response"); + eap_send_failure(esp); + break; + } + pcb->eap.es_server.ea_type = EAPT_SRP; + eap_send_success(pcb, esp); + eap_figure_next_state(pcb, 0); + if (pcb->eap.es_rechallenge != 0) + TIMEOUT(eap_rechallenge, pcb, + pcb->eap.es_rechallenge); + if (pcb->eap.es_lwrechallenge != 0) + TIMEOUT(srp_lwrechallenge, pcb, + pcb->eap.es_lwrechallenge); + break; + + case EAPSRP_LWRECHALLENGE: + if (pcb->eap.es_server.ea_state != eapSRP4) { + ppp_info("EAP: unexpected SRP Subtype 4 Response"); + return; + } + if (len != SHA_DIGESTSIZE) { + ppp_error("EAP: bad Lightweight rechallenge " + "response"); + return; + } + SHA1Init(&ctxt); + vallen = id; + SHA1Update(&ctxt, &vallen, 1); + SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, pcb->eap.es_challenge, pcb->eap.es_challen); + SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, + pcb->eap.es_server.ea_peerlen); + SHA1Final(dig, &ctxt); + if (BCMP(dig, inp, SHA_DIGESTSIZE) != 0) { + ppp_error("EAP: failed Lightweight rechallenge"); + eap_send_failure(pcb); + break; + } + pcb->eap.es_server.ea_state = eapOpen; + if (pcb->eap.es_lwrechallenge != 0) + TIMEOUT(srp_lwrechallenge, esp, + pcb->eap.es_lwrechallenge); + break; + } + break; #endif /* USE_SRP */ - default: - /* This can't happen. */ - ppp_error("EAP: unknown Response type %d; ignored", typenum); - return; - } - - if (pcb->settings.eap_timeout_time > 0) { - UNTIMEOUT(eap_server_timeout, pcb); - } - - if (pcb->eap.es_server.ea_state != eapBadAuth && - pcb->eap.es_server.ea_state != eapOpen) { - pcb->eap.es_server.ea_id++; - eap_send_request(pcb); - } + default: + /* This can't happen. */ + ppp_error("EAP: unknown Response type %d; ignored", typenum); + return; + } + + if (pcb->settings.eap_timeout_time > 0) { + UNTIMEOUT(eap_server_timeout, pcb); + } + + if (pcb->eap.es_server.ea_state != eapBadAuth && + pcb->eap.es_server.ea_state != eapOpen) { + pcb->eap.es_server.ea_id++; + eap_send_request(pcb); + } } #endif /* PPP_SERVER */ @@ -2015,105 +2015,105 @@ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) { * eap_success - Receive EAP Success message (client mode). */ static void eap_success(ppp_pcb *pcb, u_char *inp, int id, int len) { - LWIP_UNUSED_ARG(id); - - if (pcb->eap.es_client.ea_state != eapOpen && !eap_client_active(pcb)) { - ppp_dbglog("EAP unexpected success message in state %s (%d)", - eap_state_name(pcb->eap.es_client.ea_state), - pcb->eap.es_client.ea_state); - return; - } - - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } - - if (len > 0) { - /* This is odd. The spec doesn't allow for this. */ - PRINTMSG(inp, len); - } - - pcb->eap.es_client.ea_state = eapOpen; - auth_withpeer_success(pcb, PPP_EAP, 0); + LWIP_UNUSED_ARG(id); + + if (pcb->eap.es_client.ea_state != eapOpen && !eap_client_active(pcb)) { + ppp_dbglog("EAP unexpected success message in state %s (%d)", + eap_state_name(pcb->eap.es_client.ea_state), + pcb->eap.es_client.ea_state); + return; + } + + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } + + if (len > 0) { + /* This is odd. The spec doesn't allow for this. */ + PRINTMSG(inp, len); + } + + pcb->eap.es_client.ea_state = eapOpen; + auth_withpeer_success(pcb, PPP_EAP, 0); } /* * eap_failure - Receive EAP Failure message (client mode). */ static void eap_failure(ppp_pcb *pcb, u_char *inp, int id, int len) { - LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(id); - if (!eap_client_active(pcb)) { - ppp_dbglog("EAP unexpected failure message in state %s (%d)", - eap_state_name(pcb->eap.es_client.ea_state), - pcb->eap.es_client.ea_state); - } + if (!eap_client_active(pcb)) { + ppp_dbglog("EAP unexpected failure message in state %s (%d)", + eap_state_name(pcb->eap.es_client.ea_state), + pcb->eap.es_client.ea_state); + } - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } - if (len > 0) { - /* This is odd. The spec doesn't allow for this. */ - PRINTMSG(inp, len); - } + if (len > 0) { + /* This is odd. The spec doesn't allow for this. */ + PRINTMSG(inp, len); + } - pcb->eap.es_client.ea_state = eapBadAuth; + pcb->eap.es_client.ea_state = eapBadAuth; - ppp_error("EAP: peer reports authentication failure"); - auth_withpeer_fail(pcb, PPP_EAP); + ppp_error("EAP: peer reports authentication failure"); + auth_withpeer_fail(pcb, PPP_EAP); } /* * eap_input - Handle received EAP message. */ static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen) { - u_char code, id; - int len; - - /* - * Parse header (code, id and length). If packet too short, - * drop it. - */ - if (inlen < EAP_HEADERLEN) { - ppp_error("EAP: packet too short: %d < %d", inlen, EAP_HEADERLEN); - return; - } - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < EAP_HEADERLEN || len > inlen) { - ppp_error("EAP: packet has illegal length field %d (%d..%d)", len, - EAP_HEADERLEN, inlen); - return; - } - len -= EAP_HEADERLEN; - - /* Dispatch based on message code */ - switch (code) { - case EAP_REQUEST: - eap_request(pcb, inp, id, len); - break; + u_char code, id; + int len; + + /* + * Parse header (code, id and length). If packet too short, + * drop it. + */ + if (inlen < EAP_HEADERLEN) { + ppp_error("EAP: packet too short: %d < %d", inlen, EAP_HEADERLEN); + return; + } + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < EAP_HEADERLEN || len > inlen) { + ppp_error("EAP: packet has illegal length field %d (%d..%d)", len, + EAP_HEADERLEN, inlen); + return; + } + len -= EAP_HEADERLEN; + + /* Dispatch based on message code */ + switch (code) { + case EAP_REQUEST: + eap_request(pcb, inp, id, len); + break; #if PPP_SERVER - case EAP_RESPONSE: - eap_response(pcb, inp, id, len); - break; + case EAP_RESPONSE: + eap_response(pcb, inp, id, len); + break; #endif /* PPP_SERVER */ - case EAP_SUCCESS: - eap_success(pcb, inp, id, len); - break; + case EAP_SUCCESS: + eap_success(pcb, inp, id, len); + break; - case EAP_FAILURE: - eap_failure(pcb, inp, id, len); - break; + case EAP_FAILURE: + eap_failure(pcb, inp, id, len); + break; - default: /* XXX Need code reject */ - /* Note: it's not legal to send EAP Nak here. */ - ppp_warn("EAP: unknown code %d received", code); - break; - } + default: /* XXX Need code reject */ + /* Note: it's not legal to send EAP Nak here. */ + ppp_warn("EAP: unknown code %d received", code); + break; + } } #if PRINTPKT_SUPPORT @@ -2121,302 +2121,302 @@ static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen) { * eap_printpkt - print the contents of an EAP packet. */ static const char* const eap_codenames[] = { - "Request", "Response", "Success", "Failure" + "Request", "Response", "Success", "Failure" }; static const char* const eap_typenames[] = { - "Identity", "Notification", "Nak", "MD5-Challenge", - "OTP", "Generic-Token", NULL, NULL, - "RSA", "DSS", "KEA", "KEA-Validate", - "TLS", "Defender", "Windows 2000", "Arcot", - "Cisco", "Nokia", "SRP" + "Identity", "Notification", "Nak", "MD5-Challenge", + "OTP", "Generic-Token", NULL, NULL, + "RSA", "DSS", "KEA", "KEA-Validate", + "TLS", "Defender", "Windows 2000", "Arcot", + "Cisco", "Nokia", "SRP" }; static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, const char *, ...), void *arg) { - int code, id, len, rtype, vallen; - const u_char *pstart; - u32_t uval; - - if (inlen < EAP_HEADERLEN) - return (0); - pstart = inp; - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < EAP_HEADERLEN || len > inlen) - return (0); - - if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(eap_codenames)) - printer(arg, " %s", eap_codenames[code-1]); - else - printer(arg, " code=0x%x", code); - printer(arg, " id=0x%x", id); - len -= EAP_HEADERLEN; - switch (code) { - case EAP_REQUEST: - if (len < 1) { - printer(arg, " "); - break; - } - GETCHAR(rtype, inp); - len--; - if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) - printer(arg, " %s", eap_typenames[rtype-1]); - else - printer(arg, " type=0x%x", rtype); - switch (rtype) { - case EAPT_IDENTITY: - case EAPT_NOTIFICATION: - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } else { - printer(arg, " "); - } - break; - - case EAPT_MD5CHAP: - if (len <= 0) - break; - GETCHAR(vallen, inp); - len--; - if (vallen > len) - goto truncated; - printer(arg, " ", vallen, inp); - INCPTR(vallen, inp); - len -= vallen; - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } else { - printer(arg, " "); - } - break; - - case EAPT_SRP: - if (len < 3) - goto truncated; - GETCHAR(vallen, inp); - len--; - printer(arg, "-%d", vallen); - switch (vallen) { - case EAPSRP_CHALLENGE: - GETCHAR(vallen, inp); - len--; - if (vallen >= len) - goto truncated; - if (vallen > 0) { - printer(arg, " "); - } else { - printer(arg, " "); - } - INCPTR(vallen, inp); - len -= vallen; - GETCHAR(vallen, inp); - len--; - if (vallen >= len) - goto truncated; - printer(arg, " ", vallen, inp); - INCPTR(vallen, inp); - len -= vallen; - GETCHAR(vallen, inp); - len--; - if (vallen > len) - goto truncated; - if (vallen == 0) { - printer(arg, " "); - } else { - printer(arg, " ", vallen, inp); - } - INCPTR(vallen, inp); - len -= vallen; - if (len == 0) { - printer(arg, " "); - } else { - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - } - break; - - case EAPSRP_SKEY: - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - break; - - case EAPSRP_SVALIDATOR: - if (len < (int)sizeof (u32_t)) - break; - GETLONG(uval, inp); - len -= sizeof (u32_t); - if (uval & SRPVAL_EBIT) { - printer(arg, " E"); - uval &= ~SRPVAL_EBIT; - } - if (uval != 0) { - printer(arg, " f<%X>", uval); - } - if ((vallen = len) > SHA_DIGESTSIZE) - vallen = SHA_DIGESTSIZE; - printer(arg, " ", len, inp, - len < SHA_DIGESTSIZE ? "?" : ""); - INCPTR(vallen, inp); - len -= vallen; - if (len > 0) { - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - } - break; - - case EAPSRP_LWRECHALLENGE: - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - break; - default: - break; - } - break; - default: - break; - } - break; - - case EAP_RESPONSE: - if (len < 1) - break; - GETCHAR(rtype, inp); - len--; - if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) - printer(arg, " %s", eap_typenames[rtype-1]); - else - printer(arg, " type=0x%x", rtype); - switch (rtype) { - case EAPT_IDENTITY: - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } - break; - - case EAPT_NAK: - if (len <= 0) { - printer(arg, " "); - break; - } - GETCHAR(rtype, inp); - len--; - printer(arg, " = 1 && rtype < (int)LWIP_ARRAYSIZE(eap_typenames)) - printer(arg, " (%s)", eap_typenames[rtype-1]); - printer(arg, ">"); - break; - - case EAPT_MD5CHAP: - if (len <= 0) { - printer(arg, " "); - break; - } - GETCHAR(vallen, inp); - len--; - if (vallen > len) - goto truncated; - printer(arg, " ", vallen, inp); - INCPTR(vallen, inp); - len -= vallen; - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } else { - printer(arg, " "); - } - break; - - case EAPT_SRP: - if (len < 1) - goto truncated; - GETCHAR(vallen, inp); - len--; - printer(arg, "-%d", vallen); - switch (vallen) { - case EAPSRP_CKEY: - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - break; - - case EAPSRP_CVALIDATOR: - if (len < (int)sizeof (u32_t)) - break; - GETLONG(uval, inp); - len -= sizeof (u32_t); - if (uval & SRPVAL_EBIT) { - printer(arg, " E"); - uval &= ~SRPVAL_EBIT; - } - if (uval != 0) { - printer(arg, " f<%X>", uval); - } - printer(arg, " ", len, inp, - len == SHA_DIGESTSIZE ? "" : "?"); - INCPTR(len, inp); - len = 0; - break; - - case EAPSRP_ACK: - break; - - case EAPSRP_LWRECHALLENGE: - printer(arg, " ", len, inp, - len == SHA_DIGESTSIZE ? "" : "?"); - if ((vallen = len) > SHA_DIGESTSIZE) - vallen = SHA_DIGESTSIZE; - INCPTR(vallen, inp); - len -= vallen; - break; - default: - break; - } - break; - default: - break; - } - break; - - case EAP_SUCCESS: /* No payload expected for these! */ - case EAP_FAILURE: - default: - break; - - truncated: - printer(arg, " "); - break; - } - - if (len > 8) - printer(arg, "%8B...", inp); - else if (len > 0) - printer(arg, "%.*B", len, inp); - INCPTR(len, inp); - - return (inp - pstart); + int code, id, len, rtype, vallen; + const u_char *pstart; + u32_t uval; + + if (inlen < EAP_HEADERLEN) + return (0); + pstart = inp; + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < EAP_HEADERLEN || len > inlen) + return (0); + + if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(eap_codenames)) + printer(arg, " %s", eap_codenames[code-1]); + else + printer(arg, " code=0x%x", code); + printer(arg, " id=0x%x", id); + len -= EAP_HEADERLEN; + switch (code) { + case EAP_REQUEST: + if (len < 1) { + printer(arg, " "); + break; + } + GETCHAR(rtype, inp); + len--; + if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) + printer(arg, " %s", eap_typenames[rtype-1]); + else + printer(arg, " type=0x%x", rtype); + switch (rtype) { + case EAPT_IDENTITY: + case EAPT_NOTIFICATION: + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } else { + printer(arg, " "); + } + break; + + case EAPT_MD5CHAP: + if (len <= 0) + break; + GETCHAR(vallen, inp); + len--; + if (vallen > len) + goto truncated; + printer(arg, " ", vallen, inp); + INCPTR(vallen, inp); + len -= vallen; + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } else { + printer(arg, " "); + } + break; + + case EAPT_SRP: + if (len < 3) + goto truncated; + GETCHAR(vallen, inp); + len--; + printer(arg, "-%d", vallen); + switch (vallen) { + case EAPSRP_CHALLENGE: + GETCHAR(vallen, inp); + len--; + if (vallen >= len) + goto truncated; + if (vallen > 0) { + printer(arg, " "); + } else { + printer(arg, " "); + } + INCPTR(vallen, inp); + len -= vallen; + GETCHAR(vallen, inp); + len--; + if (vallen >= len) + goto truncated; + printer(arg, " ", vallen, inp); + INCPTR(vallen, inp); + len -= vallen; + GETCHAR(vallen, inp); + len--; + if (vallen > len) + goto truncated; + if (vallen == 0) { + printer(arg, " "); + } else { + printer(arg, " ", vallen, inp); + } + INCPTR(vallen, inp); + len -= vallen; + if (len == 0) { + printer(arg, " "); + } else { + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + } + break; + + case EAPSRP_SKEY: + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + break; + + case EAPSRP_SVALIDATOR: + if (len < (int)sizeof (u32_t)) + break; + GETLONG(uval, inp); + len -= sizeof (u32_t); + if (uval & SRPVAL_EBIT) { + printer(arg, " E"); + uval &= ~SRPVAL_EBIT; + } + if (uval != 0) { + printer(arg, " f<%X>", uval); + } + if ((vallen = len) > SHA_DIGESTSIZE) + vallen = SHA_DIGESTSIZE; + printer(arg, " ", len, inp, + len < SHA_DIGESTSIZE ? "?" : ""); + INCPTR(vallen, inp); + len -= vallen; + if (len > 0) { + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + } + break; + + case EAPSRP_LWRECHALLENGE: + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + break; + default: + break; + } + break; + default: + break; + } + break; + + case EAP_RESPONSE: + if (len < 1) + break; + GETCHAR(rtype, inp); + len--; + if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) + printer(arg, " %s", eap_typenames[rtype-1]); + else + printer(arg, " type=0x%x", rtype); + switch (rtype) { + case EAPT_IDENTITY: + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } + break; + + case EAPT_NAK: + if (len <= 0) { + printer(arg, " "); + break; + } + GETCHAR(rtype, inp); + len--; + printer(arg, " = 1 && rtype < (int)LWIP_ARRAYSIZE(eap_typenames)) + printer(arg, " (%s)", eap_typenames[rtype-1]); + printer(arg, ">"); + break; + + case EAPT_MD5CHAP: + if (len <= 0) { + printer(arg, " "); + break; + } + GETCHAR(vallen, inp); + len--; + if (vallen > len) + goto truncated; + printer(arg, " ", vallen, inp); + INCPTR(vallen, inp); + len -= vallen; + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } else { + printer(arg, " "); + } + break; + + case EAPT_SRP: + if (len < 1) + goto truncated; + GETCHAR(vallen, inp); + len--; + printer(arg, "-%d", vallen); + switch (vallen) { + case EAPSRP_CKEY: + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + break; + + case EAPSRP_CVALIDATOR: + if (len < (int)sizeof (u32_t)) + break; + GETLONG(uval, inp); + len -= sizeof (u32_t); + if (uval & SRPVAL_EBIT) { + printer(arg, " E"); + uval &= ~SRPVAL_EBIT; + } + if (uval != 0) { + printer(arg, " f<%X>", uval); + } + printer(arg, " ", len, inp, + len == SHA_DIGESTSIZE ? "" : "?"); + INCPTR(len, inp); + len = 0; + break; + + case EAPSRP_ACK: + break; + + case EAPSRP_LWRECHALLENGE: + printer(arg, " ", len, inp, + len == SHA_DIGESTSIZE ? "" : "?"); + if ((vallen = len) > SHA_DIGESTSIZE) + vallen = SHA_DIGESTSIZE; + INCPTR(vallen, inp); + len -= vallen; + break; + default: + break; + } + break; + default: + break; + } + break; + + case EAP_SUCCESS: /* No payload expected for these! */ + case EAP_FAILURE: + default: + break; + + truncated: + printer(arg, " "); + break; + } + + if (len > 8) + printer(arg, "%8B...", inp); + else if (len > 0) + printer(arg, "%.*B", len, inp); + INCPTR(len, inp); + + return (inp - pstart); } #endif /* PRINTPKT_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/ecp.c b/components/net/lwip-2.0.2/src/netif/ppp/ecp.c index 4d84f60931..5b3b331560 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/ecp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/ecp.c @@ -92,8 +92,8 @@ static void ecp_protrej (int unit); */ #if PRINTPKT_SUPPORT static int ecp_printpkt (const u_char *pkt, int len, - void (*printer) (void *, char *, ...), - void *arg); + void (*printer) (void *, char *, ...), + void *arg); #endif /* PRINTPKT_SUPPORT */ /* static void ecp_datainput (int unit, u_char *pkt, int len); @@ -129,10 +129,10 @@ const struct protent ecp_protent = { }; 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 */ +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 const fsm_callbacks ecp_callbacks = { NULL, /* ecp_resetci, */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/eui64.c b/components/net/lwip-2.0.2/src/netif/ppp/eui64.c index 01493bc1f8..9e25fc4c2f 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/eui64.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/eui64.c @@ -48,8 +48,8 @@ char *eui64_ntoa(eui64_t e) { static char buf[20]; sprintf(buf, "%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]); + 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; } diff --git a/components/net/lwip-2.0.2/src/netif/ppp/fsm.c b/components/net/lwip-2.0.2/src/netif/ppp/fsm.c index 81eba11602..0f6cafa5b1 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/fsm.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/fsm.c @@ -68,7 +68,7 @@ static void fsm_rtermack(fsm *f); static void fsm_rcoderej(fsm *f, u_char *inp, int len); static void fsm_sconfreq(fsm *f, int retransmit); -#define PROTO_NAME(f) ((f)->callbacks->proto_name) +#define PROTO_NAME(f) ((f)->callbacks->proto_name) /* * fsm_init - Initialize fsm. @@ -79,7 +79,7 @@ void fsm_init(fsm *f) { ppp_pcb *pcb = f->pcb; f->state = PPP_FSM_INITIAL; f->flags = 0; - f->id = 0; /* XXX Start with random id? */ + f->id = 0; /* XXX Start with random id? */ f->maxnakloops = pcb->settings.fsm_max_nak_loops; f->term_reason_len = 0; } @@ -91,22 +91,22 @@ void fsm_init(fsm *f) { void fsm_lowerup(fsm *f) { switch( f->state ){ case PPP_FSM_INITIAL: - f->state = PPP_FSM_CLOSED; - break; + f->state = PPP_FSM_CLOSED; + break; case PPP_FSM_STARTING: - if( f->flags & OPT_SILENT ) - f->state = PPP_FSM_STOPPED; - else { - /* Send an initial configure-request */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - } - break; + if( f->flags & OPT_SILENT ) + f->state = PPP_FSM_STOPPED; + else { + /* Send an initial configure-request */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + } + break; default: - FSMDEBUG(("%s: Up event in state %d!", PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Up event in state %d!", PROTO_NAME(f), f->state)); + /* no break */ } } @@ -119,37 +119,37 @@ void fsm_lowerup(fsm *f) { void fsm_lowerdown(fsm *f) { switch( f->state ){ case PPP_FSM_CLOSED: - f->state = PPP_FSM_INITIAL; - break; + f->state = PPP_FSM_INITIAL; + break; case PPP_FSM_STOPPED: - f->state = PPP_FSM_STARTING; - if( f->callbacks->starting ) - (*f->callbacks->starting)(f); - break; + f->state = PPP_FSM_STARTING; + if( f->callbacks->starting ) + (*f->callbacks->starting)(f); + break; case PPP_FSM_CLOSING: - f->state = PPP_FSM_INITIAL; - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - break; + f->state = PPP_FSM_INITIAL; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + break; case PPP_FSM_STOPPING: case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - f->state = PPP_FSM_STARTING; - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - break; + f->state = PPP_FSM_STARTING; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + break; case PPP_FSM_OPENED: - if( f->callbacks->down ) - (*f->callbacks->down)(f); - f->state = PPP_FSM_STARTING; - break; + if( f->callbacks->down ) + (*f->callbacks->down)(f); + f->state = PPP_FSM_STARTING; + break; default: - FSMDEBUG(("%s: Down event in state %d!", PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Down event in state %d!", PROTO_NAME(f), f->state)); + /* no break */ } } @@ -160,34 +160,34 @@ void fsm_lowerdown(fsm *f) { void fsm_open(fsm *f) { switch( f->state ){ case PPP_FSM_INITIAL: - f->state = PPP_FSM_STARTING; - if( f->callbacks->starting ) - (*f->callbacks->starting)(f); - break; + f->state = PPP_FSM_STARTING; + if( f->callbacks->starting ) + (*f->callbacks->starting)(f); + break; case PPP_FSM_CLOSED: - if( f->flags & OPT_SILENT ) - f->state = PPP_FSM_STOPPED; - else { - /* Send an initial configure-request */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - } - break; + if( f->flags & OPT_SILENT ) + f->state = PPP_FSM_STOPPED; + else { + /* Send an initial configure-request */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + } + break; case PPP_FSM_CLOSING: - f->state = PPP_FSM_STOPPING; - /* fall through */ - /* no break */ + f->state = PPP_FSM_STOPPING; + /* fall through */ + /* no break */ case PPP_FSM_STOPPED: case PPP_FSM_OPENED: - if( f->flags & OPT_RESTART ){ - fsm_lowerdown(f); - fsm_lowerup(f); - } - break; + if( f->flags & OPT_RESTART ){ + fsm_lowerdown(f); + fsm_lowerup(f); + } + break; default: - break; + break; } } @@ -201,25 +201,25 @@ static void terminate_layer(fsm *f, int nextstate) { ppp_pcb *pcb = f->pcb; if( f->state != PPP_FSM_OPENED ) - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ else if( f->callbacks->down ) - (*f->callbacks->down)(f); /* Inform upper layers we're down */ + (*f->callbacks->down)(f); /* Inform upper layers we're down */ /* Init restart counter and send Terminate-Request */ f->retransmits = pcb->settings.fsm_max_term_transmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (const u_char *) f->term_reason, f->term_reason_len); + (const 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 == PPP_FSM_CLOSING ? PPP_FSM_CLOSED : PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - return; + /* + * 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 == PPP_FSM_CLOSING ? PPP_FSM_CLOSED : PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + return; } TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); @@ -239,23 +239,23 @@ void fsm_close(fsm *f, const char *reason) { f->term_reason_len = (reason == NULL? 0: LWIP_MIN(strlen(reason), 0xFF) ); switch( f->state ){ case PPP_FSM_STARTING: - f->state = PPP_FSM_INITIAL; - break; + f->state = PPP_FSM_INITIAL; + break; case PPP_FSM_STOPPED: - f->state = PPP_FSM_CLOSED; - break; + f->state = PPP_FSM_CLOSED; + break; case PPP_FSM_STOPPING: - f->state = PPP_FSM_CLOSING; - break; + f->state = PPP_FSM_CLOSING; + break; case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: case PPP_FSM_OPENED: - terminate_layer(f, PPP_FSM_CLOSING); - break; + terminate_layer(f, PPP_FSM_CLOSING); + break; default: - break; + break; } } @@ -270,44 +270,44 @@ static void fsm_timeout(void *arg) { switch (f->state) { case PPP_FSM_CLOSING: case PPP_FSM_STOPPING: - if( f->retransmits <= 0 ){ - /* - * We've waited for an ack long enough. Peer probably heard us. - */ - f->state = (f->state == PPP_FSM_CLOSING)? PPP_FSM_CLOSED: PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - } else { - /* Send Terminate-Request */ - fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (const u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); - --f->retransmits; - } - break; + if( f->retransmits <= 0 ){ + /* + * We've waited for an ack long enough. Peer probably heard us. + */ + f->state = (f->state == PPP_FSM_CLOSING)? PPP_FSM_CLOSED: PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + } else { + /* Send Terminate-Request */ + fsm_sdata(f, TERMREQ, f->reqid = ++f->id, + (const u_char *) f->term_reason, f->term_reason_len); + TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); + --f->retransmits; + } + break; case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - if (f->retransmits <= 0) { - ppp_warn("%s: timeout sending Config-Requests", PROTO_NAME(f)); - f->state = PPP_FSM_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 == PPP_FSM_ACKRCVD ) - f->state = PPP_FSM_REQSENT; - } - break; + if (f->retransmits <= 0) { + ppp_warn("%s: timeout sending Config-Requests", PROTO_NAME(f)); + f->state = PPP_FSM_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 == PPP_FSM_ACKRCVD ) + f->state = PPP_FSM_REQSENT; + } + break; default: - FSMDEBUG(("%s: Timeout event in state %d!", PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Timeout event in state %d!", PROTO_NAME(f), f->state)); + /* no break */ } } @@ -326,26 +326,26 @@ void fsm_input(fsm *f, u_char *inpacket, int l) { */ inp = inpacket; if (l < HEADERLEN) { - FSMDEBUG(("fsm_input(%x): Rcvd short header.", f->protocol)); - return; + 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; + FSMDEBUG(("fsm_input(%x): Rcvd illegal length.", f->protocol)); + return; } if (len > l) { - FSMDEBUG(("fsm_input(%x): Rcvd short packet.", f->protocol)); - return; + FSMDEBUG(("fsm_input(%x): Rcvd short packet.", f->protocol)); + return; } - len -= HEADERLEN; /* subtract header length */ + len -= HEADERLEN; /* subtract header length */ if( f->state == PPP_FSM_INITIAL || f->state == PPP_FSM_STARTING ){ - FSMDEBUG(("fsm_input(%x): Rcvd packet in state %d.", - f->protocol, f->state)); - return; + FSMDEBUG(("fsm_input(%x): Rcvd packet in state %d.", + f->protocol, f->state)); + return; } /* @@ -353,35 +353,35 @@ void fsm_input(fsm *f, u_char *inpacket, int l) { */ switch (code) { case CONFREQ: - fsm_rconfreq(f, id, inp, len); - break; - + fsm_rconfreq(f, id, inp, len); + break; + case CONFACK: - fsm_rconfack(f, id, inp, len); - break; - + fsm_rconfack(f, id, inp, len); + break; + case CONFNAK: case CONFREJ: - fsm_rconfnakrej(f, code, id, inp, len); - break; - + fsm_rconfnakrej(f, code, id, inp, len); + break; + case TERMREQ: - fsm_rtermreq(f, id, inp, len); - break; - + fsm_rtermreq(f, id, inp, len); + break; + case TERMACK: - fsm_rtermack(f); - break; - + fsm_rtermack(f); + break; + case CODEREJ: - fsm_rcoderej(f, inp, len); - break; - + 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; + if( !f->callbacks->extcode + || !(*f->callbacks->extcode)(f, code, id, inp, len) ) + fsm_sdata(f, CODEREJ, ++f->id, inpacket, len + HEADERLEN); + break; } } @@ -394,61 +394,61 @@ static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { switch( f->state ){ case PPP_FSM_CLOSED: - /* Go away, we're closed */ - fsm_sdata(f, TERMACK, id, NULL, 0); - return; + /* Go away, we're closed */ + fsm_sdata(f, TERMACK, id, NULL, 0); + return; case PPP_FSM_CLOSING: case PPP_FSM_STOPPING: - return; + return; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; case PPP_FSM_STOPPED: - /* Negotiation started by our peer */ - fsm_sconfreq(f, 0); /* Send initial Configure-Request */ - f->state = PPP_FSM_REQSENT; - break; + /* Negotiation started by our peer */ + fsm_sconfreq(f, 0); /* Send initial Configure-Request */ + f->state = PPP_FSM_REQSENT; + break; default: - break; + 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); + 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 */ + code = CONFREJ; /* Reject all CI */ else - code = CONFACK; + code = CONFACK; /* send the Ack, Nak or Rej to the peer */ fsm_sdata(f, code, id, inp, len); if (code == CONFACK) { - if (f->state == PPP_FSM_ACKRCVD) { - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - f->state = PPP_FSM_OPENED; - if (f->callbacks->up) - (*f->callbacks->up)(f); /* Inform upper layers */ - } else - f->state = PPP_FSM_ACKSENT; - f->nakloops = 0; + if (f->state == PPP_FSM_ACKRCVD) { + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + f->state = PPP_FSM_OPENED; + if (f->callbacks->up) + (*f->callbacks->up)(f); /* Inform upper layers */ + } else + f->state = PPP_FSM_ACKSENT; + f->nakloops = 0; } else { - /* we sent CONFACK or CONFREJ */ - if (f->state != PPP_FSM_ACKRCVD) - f->state = PPP_FSM_REQSENT; - if( code == CONFNAK ) - ++f->nakloops; + /* we sent CONFACK or CONFREJ */ + if (f->state != PPP_FSM_ACKRCVD) + f->state = PPP_FSM_REQSENT; + if( code == CONFNAK ) + ++f->nakloops; } } @@ -459,13 +459,13 @@ static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) { ppp_pcb *pcb = f->pcb; - if (id != f->reqid || f->seen_ack) /* Expected id? */ - return; /* Nope, toss... */ + 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 */ - ppp_error("Received bad configure-ack: %P", inp, len); - return; + (len == 0)) ){ + /* Ack is bad - ignore it */ + ppp_error("Received bad configure-ack: %P", inp, len); + return; } f->seen_ack = 1; f->rnakloops = 0; @@ -473,38 +473,38 @@ static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) { switch (f->state) { case PPP_FSM_CLOSED: case PPP_FSM_STOPPED: - fsm_sdata(f, TERMACK, id, NULL, 0); - break; + fsm_sdata(f, TERMACK, id, NULL, 0); + break; case PPP_FSM_REQSENT: - f->state = PPP_FSM_ACKRCVD; - f->retransmits = pcb->settings.fsm_max_conf_req_transmits; - break; + f->state = PPP_FSM_ACKRCVD; + f->retransmits = pcb->settings.fsm_max_conf_req_transmits; + break; case PPP_FSM_ACKRCVD: - /* Huh? an extra valid Ack? oh well... */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - break; + /* Huh? an extra valid Ack? oh well... */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + break; case PPP_FSM_ACKSENT: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - f->state = PPP_FSM_OPENED; - f->retransmits = pcb->settings.fsm_max_conf_req_transmits; - if (f->callbacks->up) - (*f->callbacks->up)(f); /* Inform upper layers */ - break; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + f->state = PPP_FSM_OPENED; + f->retransmits = pcb->settings.fsm_max_conf_req_transmits; + if (f->callbacks->up) + (*f->callbacks->up)(f); /* Inform upper layers */ + break; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; default: - break; + break; } } @@ -516,24 +516,24 @@ static void fsm_rconfnakrej(fsm *f, int code, int 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 (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))) { - ppp_error("Received bad configure-nak: %P", inp, len); - return; - } + ++f->rnakloops; + treat_as_reject = (f->rnakloops >= f->maxnakloops); + if (f->callbacks->nakci == NULL + || !(ret = f->callbacks->nakci(f, inp, len, treat_as_reject))) { + ppp_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))) { - ppp_error("Received bad configure-rej: %P", inp, len); - return; - } + f->rnakloops = 0; + if (f->callbacks->rejci == NULL + || !(ret = f->callbacks->rejci(f, inp, len))) { + ppp_error("Received bad configure-rej: %P", inp, len); + return; + } } f->seen_ack = 1; @@ -541,35 +541,35 @@ static void fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) { switch (f->state) { case PPP_FSM_CLOSED: case PPP_FSM_STOPPED: - fsm_sdata(f, TERMACK, id, NULL, 0); - break; + fsm_sdata(f, TERMACK, id, NULL, 0); + break; case PPP_FSM_REQSENT: case PPP_FSM_ACKSENT: - /* They didn't agree to what we wanted - try another request */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - if (ret < 0) - f->state = PPP_FSM_STOPPED; /* kludge for stopping CCP */ - else - fsm_sconfreq(f, 0); /* Send Configure-Request */ - break; + /* They didn't agree to what we wanted - try another request */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + if (ret < 0) + f->state = PPP_FSM_STOPPED; /* kludge for stopping CCP */ + else + fsm_sconfreq(f, 0); /* Send Configure-Request */ + break; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; default: - break; + break; } } @@ -583,22 +583,22 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) { switch (f->state) { case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - f->state = PPP_FSM_REQSENT; /* Start over but keep trying */ - break; + f->state = PPP_FSM_REQSENT; /* Start over but keep trying */ + break; case PPP_FSM_OPENED: - if (len > 0) { - ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p); - } else - ppp_info("%s terminated by peer", PROTO_NAME(f)); - f->retransmits = 0; - f->state = PPP_FSM_STOPPING; - if (f->callbacks->down) - (*f->callbacks->down)(f); /* Inform upper layers */ - TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); - break; + if (len > 0) { + ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p); + } else + ppp_info("%s terminated by peer", PROTO_NAME(f)); + f->retransmits = 0; + f->state = PPP_FSM_STOPPING; + if (f->callbacks->down) + (*f->callbacks->down)(f); /* Inform upper layers */ + TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); + break; default: - break; + break; } fsm_sdata(f, TERMACK, id, NULL, 0); @@ -611,30 +611,30 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) { static void fsm_rtermack(fsm *f) { switch (f->state) { case PPP_FSM_CLOSING: - UNTIMEOUT(fsm_timeout, f); - f->state = PPP_FSM_CLOSED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + UNTIMEOUT(fsm_timeout, f); + f->state = PPP_FSM_CLOSED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_STOPPING: - UNTIMEOUT(fsm_timeout, f); - f->state = PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + UNTIMEOUT(fsm_timeout, f); + f->state = PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_ACKRCVD: - f->state = PPP_FSM_REQSENT; - break; + f->state = PPP_FSM_REQSENT; + break; case PPP_FSM_OPENED: - if (f->callbacks->down) - (*f->callbacks->down)(f); /* Inform upper layers */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - break; + if (f->callbacks->down) + (*f->callbacks->down)(f); /* Inform upper layers */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + break; default: - break; + break; } } @@ -646,15 +646,15 @@ static void fsm_rcoderej(fsm *f, u_char *inp, int len) { u_char code, id; if (len < HEADERLEN) { - FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!")); - return; + FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!")); + return; } GETCHAR(code, inp); GETCHAR(id, inp); ppp_warn("%s: Rcvd Code-Reject for code %d, id %d", PROTO_NAME(f), code, id); if( f->state == PPP_FSM_ACKRCVD ) - f->state = PPP_FSM_REQSENT; + f->state = PPP_FSM_REQSENT; } @@ -666,36 +666,36 @@ static void fsm_rcoderej(fsm *f, u_char *inp, int len) { void fsm_protreject(fsm *f) { switch( f->state ){ case PPP_FSM_CLOSING: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - /* fall through */ - /* no break */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + /* fall through */ + /* no break */ case PPP_FSM_CLOSED: - f->state = PPP_FSM_CLOSED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + f->state = PPP_FSM_CLOSED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_STOPPING: case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - /* fall through */ - /* no break */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + /* fall through */ + /* no break */ case PPP_FSM_STOPPED: - f->state = PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + f->state = PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_OPENED: - terminate_layer(f, PPP_FSM_STOPPING); - break; + terminate_layer(f, PPP_FSM_STOPPING); + break; default: - FSMDEBUG(("%s: Protocol-reject event in state %d!", - PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Protocol-reject event in state %d!", + PROTO_NAME(f), f->state)); + /* no break */ } } @@ -710,17 +710,17 @@ static void fsm_sconfreq(fsm *f, int retransmit) { int cilen; if( f->state != PPP_FSM_REQSENT && f->state != PPP_FSM_ACKRCVD && f->state != PPP_FSM_ACKSENT ){ - /* Not currently negotiating - reset options */ - if( f->callbacks->resetci ) - (*f->callbacks->resetci)(f); - f->nakloops = 0; - f->rnakloops = 0; + /* 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 = pcb->settings.fsm_max_conf_req_transmits; - f->reqid = ++f->id; + /* New request - reset retransmission counter, use new ID */ + f->retransmits = pcb->settings.fsm_max_conf_req_transmits; + f->reqid = ++f->id; } f->seen_ack = 0; @@ -729,11 +729,11 @@ static void fsm_sconfreq(fsm *f, int retransmit) { * Make up the request packet */ if( f->callbacks->cilen && f->callbacks->addci ){ - cilen = (*f->callbacks->cilen)(f); - if( cilen > pcb->peer_mru - HEADERLEN ) - cilen = pcb->peer_mru - HEADERLEN; + cilen = (*f->callbacks->cilen)(f); + if( cilen > pcb->peer_mru - HEADERLEN ) + cilen = pcb->peer_mru - HEADERLEN; } else - cilen = 0; + cilen = 0; p = pbuf_alloc(PBUF_RAW, (u16_t)(cilen + HEADERLEN + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE); if(NULL == p) @@ -750,8 +750,8 @@ static void fsm_sconfreq(fsm *f, int retransmit) { PUTCHAR(f->reqid, outp); PUTSHORT(cilen + HEADERLEN, outp); if (cilen != 0) { - (*f->callbacks->addci)(f, outp, &cilen); - LWIP_ASSERT("cilen == p->len - HEADERLEN - PPP_HDRLEN", cilen == p->len - HEADERLEN - PPP_HDRLEN); + (*f->callbacks->addci)(f, outp, &cilen); + LWIP_ASSERT("cilen == p->len - HEADERLEN - PPP_HDRLEN", cilen == p->len - HEADERLEN - PPP_HDRLEN); } ppp_write(pcb, p); @@ -775,7 +775,7 @@ void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen) /* Adjust length to be smaller than MTU */ if (datalen > pcb->peer_mru - HEADERLEN) - datalen = pcb->peer_mru - HEADERLEN; + datalen = pcb->peer_mru - HEADERLEN; outlen = datalen + HEADERLEN; p = pbuf_alloc(PBUF_RAW, (u16_t)(outlen + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE); @@ -788,7 +788,7 @@ void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen) outp = (u_char*)p->payload; if (datalen) /* && data != outp + PPP_HDRLEN + HEADERLEN) -- was only for fsm_sconfreq() */ - MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen); + MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen); MAKEHEADER(outp, f->protocol); PUTCHAR(code, outp); PUTCHAR(id, outp); diff --git a/components/net/lwip-2.0.2/src/netif/ppp/ipcp.c b/components/net/lwip-2.0.2/src/netif/ppp/ipcp.c index b7c766eb0b..feb1f4becc 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/ipcp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/ipcp.c @@ -66,15 +66,15 @@ #if 0 /* UNUSED */ /* global vars */ -u32_t netmask = 0; /* IP netmask to set on interface */ +u32_t netmask = 0; /* IP netmask to set on interface */ #endif /* UNUSED */ #if 0 /* UNUSED */ -bool disable_defaultip = 0; /* Don't use hostname for default IP adrs */ +bool disable_defaultip = 0; /* Don't use hostname for default IP adrs */ #endif /* UNUSED */ #if 0 /* moved to ppp_settings */ -bool noremoteip = 0; /* Let him have no IP address */ +bool noremoteip = 0; /* Let him have no IP address */ #endif /* moved to ppp_setting */ #if 0 /* UNUSED */ @@ -96,47 +96,47 @@ struct notifier *ip_down_notifier = NULL; /* local vars */ #if 0 /* moved to ppp_pcb */ -static int default_route_set[NUM_PPP]; /* Have set up a default route */ -static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ -static int ipcp_is_up; /* have called np_up() */ -static int ipcp_is_open; /* haven't called np_finished() */ -static bool ask_for_local; /* request our address from peer */ +static int default_route_set[NUM_PPP]; /* Have set up a default route */ +static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ +static int ipcp_is_up; /* have called np_up() */ +static int ipcp_is_open; /* haven't called np_finished() */ +static bool ask_for_local; /* request our address from peer */ #endif /* moved to ppp_pcb */ #if 0 /* UNUSED */ -static char vj_value[8]; /* string form of vj option value */ -static char netmask_str[20]; /* string form of netmask value */ +static char vj_value[8]; /* string form of vj option value */ +static char netmask_str[20]; /* string form of netmask value */ #endif /* UNUSED */ /* * Callbacks for fsm code. (CI = Configuration Information) */ -static void ipcp_resetci(fsm *f); /* Reset our CI */ -static int ipcp_cilen(fsm *f); /* Return length of our CI */ +static void ipcp_resetci(fsm *f); /* Reset our CI */ +static int ipcp_cilen(fsm *f); /* Return length of our CI */ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI */ -static int ipcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */ +static int ipcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject);/* Peer nak'd our CI */ -static int ipcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */ +static int ipcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree); /* Rcv CI */ -static void ipcp_up(fsm *f); /* We're UP */ -static void ipcp_down(fsm *f); /* We're DOWN */ -static void ipcp_finished(fsm *f); /* Don't need lower layer */ +static void ipcp_up(fsm *f); /* We're UP */ +static void ipcp_down(fsm *f); /* We're DOWN */ +static void ipcp_finished(fsm *f); /* Don't need lower layer */ static const fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */ - ipcp_resetci, /* Reset our Configuration Information */ - ipcp_cilen, /* Length of our Configuration Information */ - ipcp_addci, /* Add our Configuration Information */ - ipcp_ackci, /* ACK our Configuration Information */ - ipcp_nakci, /* NAK our Configuration Information */ - ipcp_rejci, /* Reject our Configuration Information */ - ipcp_reqci, /* Request peer's Configuration Information */ - ipcp_up, /* Called when fsm reaches OPENED state */ - ipcp_down, /* Called when fsm leaves OPENED state */ - NULL, /* Called when we want the lower layer up */ - ipcp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - NULL, /* Called to handle protocol-specific codes */ - "IPCP" /* String name of protocol */ + ipcp_resetci, /* Reset our Configuration Information */ + ipcp_cilen, /* Length of our Configuration Information */ + ipcp_addci, /* Add our Configuration Information */ + ipcp_ackci, /* ACK our Configuration Information */ + ipcp_nakci, /* NAK our Configuration Information */ + ipcp_rejci, /* Reject our Configuration Information */ + ipcp_reqci, /* Request peer's Configuration Information */ + ipcp_up, /* Called when fsm reaches OPENED state */ + ipcp_down, /* Called when fsm leaves OPENED state */ + NULL, /* Called when we want the lower layer up */ + ipcp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + NULL, /* Called to handle protocol-specific codes */ + "IPCP" /* String name of protocol */ }; /* @@ -209,13 +209,13 @@ static option_t ipcp_option_list[] = { &ipcp_wantoptions[0].default_route }, { "replacedefaultroute", o_bool, - &ipcp_wantoptions[0].replace_default_route, + &ipcp_wantoptions[0].replace_default_route, "Replace default route", 1 }, { "noreplacedefaultroute", o_bool, - &ipcp_allowoptions[0].replace_default_route, + &ipcp_allowoptions[0].replace_default_route, "Never replace default route", OPT_A2COPY, - &ipcp_wantoptions[0].replace_default_route }, + &ipcp_wantoptions[0].replace_default_route }, { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp, "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp }, { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp, @@ -265,7 +265,7 @@ static void ipcp_input(ppp_pcb *pcb, u_char *p, int len); static void ipcp_protrej(ppp_pcb *pcb); #if PRINTPKT_SUPPORT static int ipcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS static void ip_check_options (void); @@ -312,15 +312,15 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re /* * Lengths of configuration options. */ -#define CILEN_VOID 2 -#define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ -#define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ -#define CILEN_ADDR 6 /* new-style single address option */ -#define CILEN_ADDRS 10 /* old-style dual address option */ +#define CILEN_VOID 2 +#define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ +#define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ +#define CILEN_ADDR 6 /* new-style single address option */ +#define CILEN_ADDRS 10 /* old-style dual address option */ -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") #if 0 /* UNUSED, already defined by lwIP */ /* @@ -351,11 +351,11 @@ setvjslots(argv) int value; if (!int_option(*argv, &value)) - return 0; + return 0; if (value < 2 || value > 16) { - option_error("vj-max-slots value must be between 2 and 16"); - return 0; + option_error("vj-max-slots value must be between 2 and 16"); + return 0; } ipcp_wantoptions [0].maxslotindex = ipcp_allowoptions[0].maxslotindex = value - 1; @@ -375,21 +375,21 @@ setdnsaddr(argv) dns = inet_addr(*argv); if (dns == (u32_t) -1) { - if ((hp = gethostbyname(*argv)) == NULL) { - option_error("invalid address parameter '%s' for ms-dns option", - *argv); - return 0; - } - dns = *(u32_t *)hp->h_addr; + if ((hp = gethostbyname(*argv)) == NULL) { + option_error("invalid address parameter '%s' for ms-dns option", + *argv); + return 0; + } + dns = *(u32_t *)hp->h_addr; } /* We take the last 2 values given, the 2nd-last as the primary and the last as the secondary. If only one is given it becomes both primary and secondary. */ if (ipcp_allowoptions[0].dnsaddr[1] == 0) - ipcp_allowoptions[0].dnsaddr[0] = dns; + ipcp_allowoptions[0].dnsaddr[0] = dns; else - ipcp_allowoptions[0].dnsaddr[0] = ipcp_allowoptions[0].dnsaddr[1]; + ipcp_allowoptions[0].dnsaddr[0] = ipcp_allowoptions[0].dnsaddr[1]; /* always set the secondary address value. */ ipcp_allowoptions[0].dnsaddr[1] = dns; @@ -411,21 +411,21 @@ setwinsaddr(argv) wins = inet_addr(*argv); if (wins == (u32_t) -1) { - if ((hp = gethostbyname(*argv)) == NULL) { - option_error("invalid address parameter '%s' for ms-wins option", - *argv); - return 0; - } - wins = *(u32_t *)hp->h_addr; + if ((hp = gethostbyname(*argv)) == NULL) { + option_error("invalid address parameter '%s' for ms-wins option", + *argv); + return 0; + } + wins = *(u32_t *)hp->h_addr; } /* We take the last 2 values given, the 2nd-last as the primary and the last as the secondary. If only one is given it becomes both primary and secondary. */ if (ipcp_allowoptions[0].winsaddr[1] == 0) - ipcp_allowoptions[0].winsaddr[0] = wins; + ipcp_allowoptions[0].winsaddr[0] = wins; else - ipcp_allowoptions[0].winsaddr[0] = ipcp_allowoptions[0].winsaddr[1]; + ipcp_allowoptions[0].winsaddr[0] = ipcp_allowoptions[0].winsaddr[1]; /* always set the secondary address value. */ ipcp_allowoptions[0].winsaddr[1] = wins; @@ -455,52 +455,52 @@ setipaddr(arg, argv, doit) * IP address pair separated by ":". */ if ((colon = strchr(arg, ':')) == NULL) - return 0; + return 0; if (!doit) - return 1; - + return 1; + /* * If colon first character, then no local addr. */ if (colon != arg && option_priority >= prio_local) { - *colon = '\0'; - if ((local = inet_addr(arg)) == (u32_t) -1) { - if ((hp = gethostbyname(arg)) == NULL) { - option_error("unknown host: %s", arg); - return 0; - } - local = *(u32_t *)hp->h_addr; - } - if (bad_ip_adrs(local)) { - option_error("bad local IP address %s", ip_ntoa(local)); - return 0; - } - if (local != 0) - wo->ouraddr = local; - *colon = ':'; - prio_local = option_priority; - } - + *colon = '\0'; + if ((local = inet_addr(arg)) == (u32_t) -1) { + if ((hp = gethostbyname(arg)) == NULL) { + option_error("unknown host: %s", arg); + return 0; + } + local = *(u32_t *)hp->h_addr; + } + if (bad_ip_adrs(local)) { + option_error("bad local IP address %s", ip_ntoa(local)); + return 0; + } + if (local != 0) + wo->ouraddr = local; + *colon = ':'; + prio_local = option_priority; + } + /* * If colon last character, then no remote addr. */ if (*++colon != '\0' && option_priority >= prio_remote) { - if ((remote = inet_addr(colon)) == (u32_t) -1) { - if ((hp = gethostbyname(colon)) == NULL) { - option_error("unknown host: %s", colon); - return 0; - } - remote = *(u32_t *)hp->h_addr; - if (remote_name[0] == 0) - strlcpy(remote_name, colon, sizeof(remote_name)); - } - if (bad_ip_adrs(remote)) { - option_error("bad remote IP address %s", ip_ntoa(remote)); - return 0; - } - if (remote != 0) - wo->hisaddr = remote; - prio_remote = option_priority; + if ((remote = inet_addr(colon)) == (u32_t) -1) { + if ((hp = gethostbyname(colon)) == NULL) { + option_error("unknown host: %s", colon); + return 0; + } + remote = *(u32_t *)hp->h_addr; + if (remote_name[0] == 0) + strlcpy(remote_name, colon, sizeof(remote_name)); + } + if (bad_ip_adrs(remote)) { + option_error("bad remote IP address %s", ip_ntoa(remote)); + return 0; + } + if (remote != 0) + wo->hisaddr = remote; + prio_remote = option_priority; } return 1; @@ -512,13 +512,13 @@ printipaddr(opt, printer, arg) void (*printer) (void *, char *, ...); void *arg; { - ipcp_options *wo = &ipcp_wantoptions[0]; + ipcp_options *wo = &ipcp_wantoptions[0]; - if (wo->ouraddr != 0) - printer(arg, "%I", wo->ouraddr); - printer(arg, ":"); - if (wo->hisaddr != 0) - printer(arg, "%I", wo->hisaddr); + if (wo->ouraddr != 0) + printer(arg, "%I", wo->ouraddr); + printer(arg, ":"); + if (wo->hisaddr != 0) + printer(arg, "%I", wo->hisaddr); } /* @@ -542,8 +542,8 @@ setnetmask(argv) mask = lwip_htonl(mask); if (n == 0 || p[n] != 0 || (netmask & ~mask) != 0) { - option_error("invalid netmask value '%s'", *argv); - return 0; + option_error("invalid netmask value '%s'", *argv); + return 0; } netmask = mask; @@ -563,23 +563,23 @@ parse_dotted_ip(p, vp) v = 0; for (n = 3;; --n) { - b = strtoul(p, &endp, 0); - if (endp == p) - return 0; - if (b > 255) { - if (n < 3) - return 0; - /* accept e.g. 0xffffff00 */ - *vp = b; - return endp - p0; - } - v |= b << (n * 8); - p = endp; - if (n == 0) - break; - if (*p != '.') - return 0; - ++p; + b = strtoul(p, &endp, 0); + if (endp == p) + return 0; + if (b > 255) { + if (n < 3) + return 0; + /* accept e.g. 0xffffff00 */ + *vp = b; + return endp - p0; + } + v |= b << (n * 8); + p = endp; + if (n == 0) + break; + if (*p != '.') + return 0; + ++p; } *vp = v; return p - p0; @@ -716,23 +716,23 @@ static void ipcp_resetci(fsm *f) { ipcp_options *ao = &pcb->ipcp_allowoptions; wo->req_addr = (wo->neg_addr || wo->old_addrs) && - (ao->neg_addr || ao->old_addrs); + (ao->neg_addr || ao->old_addrs); if (wo->ouraddr == 0) - wo->accept_local = 1; + wo->accept_local = 1; if (wo->hisaddr == 0) - wo->accept_remote = 1; + wo->accept_remote = 1; #if LWIP_DNS - wo->req_dns1 = wo->req_dns2 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */ + wo->req_dns1 = wo->req_dns2 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */ #endif /* LWIP_DNS */ *go = *wo; if (!pcb->ask_for_local) - go->ouraddr = 0; + go->ouraddr = 0; #if 0 /* UNUSED */ if (ip_choose_hook) { - ip_choose_hook(&wo->hisaddr); - if (wo->hisaddr) { - wo->accept_remote = 0; - } + ip_choose_hook(&wo->hisaddr); + if (wo->hisaddr) { + wo->accept_remote = 0; + } } #endif /* UNUSED */ BZERO(&pcb->ipcp_hisoptions, sizeof(ipcp_options)); @@ -751,16 +751,16 @@ static int ipcp_cilen(fsm *f) { #endif /* VJ_SUPPORT */ ipcp_options *ho = &pcb->ipcp_hisoptions; -#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0) +#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0) #if VJ_SUPPORT -#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) +#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) #endif /* VJ_SUPPORT */ -#define LENCIADDR(neg) (neg ? CILEN_ADDR : 0) +#define LENCIADDR(neg) (neg ? CILEN_ADDR : 0) #if LWIP_DNS -#define LENCIDNS(neg) LENCIADDR(neg) +#define LENCIDNS(neg) LENCIADDR(neg) #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ -#define LENCIWINS(neg) LENCIADDR(neg) +#define LENCIWINS(neg) LENCIADDR(neg) #endif /* UNUSED - WINS */ /* @@ -768,34 +768,34 @@ static int ipcp_cilen(fsm *f) { * forms because we have received old forms from the peer. */ if (go->neg_addr && go->old_addrs && !ho->neg_addr && ho->old_addrs) - go->neg_addr = 0; + go->neg_addr = 0; #if VJ_SUPPORT if (wo->neg_vj && !go->neg_vj && !go->old_vj) { - /* try an older style of VJ negotiation */ - /* use the old style only if the peer did */ - if (ho->neg_vj && ho->old_vj) { - go->neg_vj = 1; - go->old_vj = 1; - go->vj_protocol = ho->vj_protocol; - } + /* try an older style of VJ negotiation */ + /* use the old style only if the peer did */ + if (ho->neg_vj && ho->old_vj) { + go->neg_vj = 1; + go->old_vj = 1; + go->vj_protocol = ho->vj_protocol; + } } #endif /* VJ_SUPPORT */ return (LENCIADDRS(!go->neg_addr && go->old_addrs) + #if VJ_SUPPORT - LENCIVJ(go->neg_vj, go->old_vj) + + LENCIVJ(go->neg_vj, go->old_vj) + #endif /* VJ_SUPPORT */ - LENCIADDR(go->neg_addr) + + LENCIADDR(go->neg_addr) + #if LWIP_DNS - LENCIDNS(go->req_dns1) + - LENCIDNS(go->req_dns2) + + LENCIDNS(go->req_dns1) + + LENCIDNS(go->req_dns2) + #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - LENCIWINS(go->winsaddr[0]) + - LENCIWINS(go->winsaddr[1]) + + LENCIWINS(go->winsaddr[0]) + + LENCIWINS(go->winsaddr[1]) + #endif /* UNUSED - WINS */ - 0); + 0); } @@ -810,86 +810,86 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { #define ADDCIADDRS(opt, neg, val1, val2) \ if (neg) { \ - if (len >= CILEN_ADDRS) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDRS, ucp); \ - l = lwip_ntohl(val1); \ - PUTLONG(l, ucp); \ - l = lwip_ntohl(val2); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDRS; \ - } else \ - go->old_addrs = 0; \ + if (len >= CILEN_ADDRS) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDRS, ucp); \ + l = lwip_ntohl(val1); \ + PUTLONG(l, ucp); \ + l = lwip_ntohl(val2); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDRS; \ + } else \ + go->old_addrs = 0; \ } #if VJ_SUPPORT #define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ - int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ - if (len >= vjlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(vjlen, ucp); \ - PUTSHORT(val, ucp); \ - if (!old) { \ - PUTCHAR(maxslotindex, ucp); \ - PUTCHAR(cflag, ucp); \ - } \ - len -= vjlen; \ - } else \ - neg = 0; \ + int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ + if (len >= vjlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(vjlen, ucp); \ + PUTSHORT(val, ucp); \ + if (!old) { \ + PUTCHAR(maxslotindex, ucp); \ + PUTCHAR(cflag, ucp); \ + } \ + len -= vjlen; \ + } else \ + neg = 0; \ } #endif /* VJ_SUPPORT */ #define ADDCIADDR(opt, neg, val) \ if (neg) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = lwip_ntohl(val); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else \ - neg = 0; \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = lwip_ntohl(val); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else \ + neg = 0; \ } #if LWIP_DNS #define ADDCIDNS(opt, neg, addr) \ if (neg) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = lwip_ntohl(addr); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else \ - neg = 0; \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = lwip_ntohl(addr); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else \ + neg = 0; \ } #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define ADDCIWINS(opt, addr) \ if (addr) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = lwip_ntohl(addr); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else \ - addr = 0; \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = lwip_ntohl(addr); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else \ + addr = 0; \ } #endif /* UNUSED - WINS */ ADDCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, - go->hisaddr); + go->hisaddr); #if VJ_SUPPORT ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); + go->maxslotindex, go->cflag); #endif /* VJ_SUPPORT */ ADDCIADDR(CI_ADDR, go->neg_addr, go->ouraddr); @@ -905,7 +905,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { ADDCIWINS(CI_MS_WINS2, go->winsaddr[1]); #endif /* UNUSED - WINS */ - + *lenp -= len; } @@ -915,8 +915,8 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { * Called by fsm_rconfack, Receive Configure ACK. * * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. + * 0 - Ack was bad. + * 1 - Ack was good. */ static int ipcp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -936,105 +936,105 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { #define ACKCIADDRS(opt, neg, val1, val2) \ if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDRS) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDRS || \ - citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (val1 != cilong) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (val2 != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDRS) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDRS || \ + citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (val1 != cilong) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (val2 != cilong) \ + goto bad; \ } #if VJ_SUPPORT #define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ - int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ - if ((len -= vjlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != vjlen || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ - if (!old) { \ - GETCHAR(cimaxslotindex, p); \ - if (cimaxslotindex != maxslotindex) \ - goto bad; \ - GETCHAR(cicflag, p); \ - if (cicflag != cflag) \ - goto bad; \ - } \ + int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ + if ((len -= vjlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != vjlen || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ + if (!old) { \ + GETCHAR(cimaxslotindex, p); \ + if (cimaxslotindex != maxslotindex) \ + goto bad; \ + GETCHAR(cicflag, p); \ + if (cicflag != cflag) \ + goto bad; \ + } \ } #endif /* VJ_SUPPORT */ #define ACKCIADDR(opt, neg, val) \ if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || \ - citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (val != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || \ + citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (val != cilong) \ + goto bad; \ } #if LWIP_DNS #define ACKCIDNS(opt, neg, addr) \ if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (addr != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (addr != cilong) \ + goto bad; \ } #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define ACKCIWINS(opt, addr) \ if (addr) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (addr != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (addr != cilong) \ + goto bad; \ } #endif /* UNUSED - WINS */ ACKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, - go->hisaddr); + go->hisaddr); #if VJ_SUPPORT ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); + go->maxslotindex, go->cflag); #endif /* VJ_SUPPORT */ ACKCIADDR(CI_ADDR, go->neg_addr, go->ouraddr); @@ -1055,7 +1055,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; return (1); bad: @@ -1070,8 +1070,8 @@ bad: * Calback from fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. * * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. + * 0 - Nak was bad. + * 1 - Nak was good. */ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; @@ -1085,8 +1085,8 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { #if LWIP_DNS u32_t cidnsaddr; #endif /* LWIP_DNS */ - ipcp_options no; /* options we've seen Naks for */ - ipcp_options try_; /* options to request next time */ + ipcp_options no; /* options we've seen Naks for */ + ipcp_options try_; /* options to request next time */ BZERO(&no, sizeof(no)); try_ = *go; @@ -1098,58 +1098,58 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ #define NAKCIADDRS(opt, neg, code) \ if ((neg) && \ - (cilen = p[1]) == CILEN_ADDRS && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - ciaddr1 = lwip_htonl(l); \ - GETLONG(l, p); \ - ciaddr2 = lwip_htonl(l); \ - no.old_addrs = 1; \ - code \ + (cilen = p[1]) == CILEN_ADDRS && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + ciaddr1 = lwip_htonl(l); \ + GETLONG(l, p); \ + ciaddr2 = lwip_htonl(l); \ + no.old_addrs = 1; \ + code \ } #if VJ_SUPPORT #define NAKCIVJ(opt, neg, code) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ + ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ code \ } #endif /* VJ_SUPPORT */ #define NAKCIADDR(opt, neg, code) \ if (go->neg && \ - (cilen = p[1]) == CILEN_ADDR && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - ciaddr1 = lwip_htonl(l); \ - no.neg = 1; \ - code \ + (cilen = p[1]) == CILEN_ADDR && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + ciaddr1 = lwip_htonl(l); \ + no.neg = 1; \ + code \ } #if LWIP_DNS #define NAKCIDNS(opt, neg, code) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cidnsaddr = lwip_htonl(l); \ - no.neg = 1; \ - code \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cidnsaddr = lwip_htonl(l); \ + no.neg = 1; \ + code \ } #endif /* LWIP_DNS */ @@ -1158,19 +1158,19 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * from our idea, only if the accept_{local,remote} flag is set. */ NAKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, - if (treat_as_reject) { - try_.old_addrs = 0; - } else { - if (go->accept_local && ciaddr1) { - /* take his idea of our address */ - try_.ouraddr = ciaddr1; - } - if (go->accept_remote && ciaddr2) { - /* take his idea of his address */ - try_.hisaddr = ciaddr2; - } - } - ); + if (treat_as_reject) { + try_.old_addrs = 0; + } else { + if (go->accept_local && ciaddr1) { + /* take his idea of our address */ + try_.ouraddr = ciaddr1; + } + if (go->accept_remote && ciaddr2) { + /* take his idea of his address */ + try_.hisaddr = ciaddr2; + } + } + ); #if VJ_SUPPORT /* @@ -1180,57 +1180,57 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * the peer wants. */ NAKCIVJ(CI_COMPRESSTYPE, neg_vj, - if (treat_as_reject) { - try_.neg_vj = 0; - } else if (cilen == CILEN_VJ) { - GETCHAR(cimaxslotindex, p); - GETCHAR(cicflag, p); - if (cishort == IPCP_VJ_COMP) { - try_.old_vj = 0; - if (cimaxslotindex < go->maxslotindex) - try_.maxslotindex = cimaxslotindex; - if (!cicflag) - try_.cflag = 0; - } else { - try_.neg_vj = 0; - } - } else { - if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { - try_.old_vj = 1; - try_.vj_protocol = cishort; - } else { - try_.neg_vj = 0; - } - } - ); + if (treat_as_reject) { + try_.neg_vj = 0; + } else if (cilen == CILEN_VJ) { + GETCHAR(cimaxslotindex, p); + GETCHAR(cicflag, p); + if (cishort == IPCP_VJ_COMP) { + try_.old_vj = 0; + if (cimaxslotindex < go->maxslotindex) + try_.maxslotindex = cimaxslotindex; + if (!cicflag) + try_.cflag = 0; + } else { + try_.neg_vj = 0; + } + } else { + if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { + try_.old_vj = 1; + try_.vj_protocol = cishort; + } else { + try_.neg_vj = 0; + } + } + ); #endif /* VJ_SUPPORT */ NAKCIADDR(CI_ADDR, neg_addr, - if (treat_as_reject) { - try_.neg_addr = 0; - try_.old_addrs = 0; - } else if (go->accept_local && ciaddr1) { - /* take his idea of our address */ - try_.ouraddr = ciaddr1; - } - ); + if (treat_as_reject) { + try_.neg_addr = 0; + try_.old_addrs = 0; + } else if (go->accept_local && ciaddr1) { + /* take his idea of our address */ + try_.ouraddr = ciaddr1; + } + ); #if LWIP_DNS NAKCIDNS(CI_MS_DNS1, req_dns1, - if (treat_as_reject) { - try_.req_dns1 = 0; - } else { - try_.dnsaddr[0] = cidnsaddr; - } - ); + if (treat_as_reject) { + try_.req_dns1 = 0; + } else { + try_.dnsaddr[0] = cidnsaddr; + } + ); NAKCIDNS(CI_MS_DNS2, req_dns2, - if (treat_as_reject) { - try_.req_dns2 = 0; - } else { - try_.dnsaddr[1] = cidnsaddr; - } - ); + if (treat_as_reject) { + try_.req_dns2 = 0; + } else { + try_.dnsaddr[1] = cidnsaddr; + } + ); #endif /* #if LWIP_DNS */ /* @@ -1242,81 +1242,81 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * peers get huffy if we don't. */ while (len >= CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) - goto bad; - next = p + cilen - 2; + GETCHAR(citype, p); + GETCHAR(cilen, p); + if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) + goto bad; + next = p + cilen - 2; - switch (citype) { + switch (citype) { #if VJ_SUPPORT - case CI_COMPRESSTYPE: - if (go->neg_vj || no.neg_vj || - (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) - goto bad; - no.neg_vj = 1; - break; + case CI_COMPRESSTYPE: + if (go->neg_vj || no.neg_vj || + (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) + goto bad; + no.neg_vj = 1; + break; #endif /* VJ_SUPPORT */ - case CI_ADDRS: - if ((!go->neg_addr && go->old_addrs) || no.old_addrs - || cilen != CILEN_ADDRS) - goto bad; - try_.neg_addr = 0; - GETLONG(l, p); - ciaddr1 = lwip_htonl(l); - if (ciaddr1 && go->accept_local) - try_.ouraddr = ciaddr1; - GETLONG(l, p); - ciaddr2 = lwip_htonl(l); - if (ciaddr2 && go->accept_remote) - try_.hisaddr = ciaddr2; - no.old_addrs = 1; - break; - case CI_ADDR: - if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) - goto bad; - try_.old_addrs = 0; - GETLONG(l, p); - ciaddr1 = lwip_htonl(l); - if (ciaddr1 && go->accept_local) - try_.ouraddr = ciaddr1; - if (try_.ouraddr != 0) - try_.neg_addr = 1; - no.neg_addr = 1; - break; + case CI_ADDRS: + if ((!go->neg_addr && go->old_addrs) || no.old_addrs + || cilen != CILEN_ADDRS) + goto bad; + try_.neg_addr = 0; + GETLONG(l, p); + ciaddr1 = lwip_htonl(l); + if (ciaddr1 && go->accept_local) + try_.ouraddr = ciaddr1; + GETLONG(l, p); + ciaddr2 = lwip_htonl(l); + if (ciaddr2 && go->accept_remote) + try_.hisaddr = ciaddr2; + no.old_addrs = 1; + break; + case CI_ADDR: + if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) + goto bad; + try_.old_addrs = 0; + GETLONG(l, p); + ciaddr1 = lwip_htonl(l); + if (ciaddr1 && go->accept_local) + try_.ouraddr = ciaddr1; + if (try_.ouraddr != 0) + try_.neg_addr = 1; + no.neg_addr = 1; + break; #if LWIP_DNS - case CI_MS_DNS1: - if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR) - goto bad; - GETLONG(l, p); - try_.dnsaddr[0] = lwip_htonl(l); - try_.req_dns1 = 1; - no.req_dns1 = 1; - break; - case CI_MS_DNS2: - if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR) - goto bad; - GETLONG(l, p); - try_.dnsaddr[1] = lwip_htonl(l); - try_.req_dns2 = 1; - no.req_dns2 = 1; - break; + case CI_MS_DNS1: + if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR) + goto bad; + GETLONG(l, p); + try_.dnsaddr[0] = lwip_htonl(l); + try_.req_dns1 = 1; + no.req_dns1 = 1; + break; + case CI_MS_DNS2: + if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR) + goto bad; + GETLONG(l, p); + try_.dnsaddr[1] = lwip_htonl(l); + try_.req_dns2 = 1; + no.req_dns2 = 1; + break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - case CI_MS_WINS1: - case CI_MS_WINS2: - if (cilen != CILEN_ADDR) - goto bad; - GETLONG(l, p); - ciaddr1 = lwip_htonl(l); - if (ciaddr1) - try_.winsaddr[citype == CI_MS_WINS2] = ciaddr1; - break; + case CI_MS_WINS1: + case CI_MS_WINS2: + if (cilen != CILEN_ADDR) + goto bad; + GETLONG(l, p); + ciaddr1 = lwip_htonl(l); + if (ciaddr1) + try_.winsaddr[citype == CI_MS_WINS2] = ciaddr1; + break; #endif /* UNUSED - WINS */ - default: - break; - } - p = next; + default: + break; + } + p = next; } /* @@ -1324,7 +1324,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If there are any remaining options, we ignore them. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; @@ -1347,7 +1347,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { u_short cishort; #endif /* VJ_SUPPORT */ u32_t cilong; - ipcp_options try_; /* options to request next time */ + ipcp_options try_; /* options to request next time */ try_ = *go; /* @@ -1357,107 +1357,107 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { */ #define REJCIADDRS(opt, neg, val1, val2) \ if ((neg) && \ - (cilen = p[1]) == CILEN_ADDRS && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val1) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val2) \ - goto bad; \ - try_.old_addrs = 0; \ + (cilen = p[1]) == CILEN_ADDRS && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val1) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val2) \ + goto bad; \ + try_.old_addrs = 0; \ } #if VJ_SUPPORT #define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ if (go->neg && \ - p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ - len >= p[1] && \ - p[0] == opt) { \ - len -= p[1]; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) \ - goto bad; \ - if (!old) { \ - GETCHAR(cimaxslotindex, p); \ - if (cimaxslotindex != maxslot) \ - goto bad; \ - GETCHAR(ciflag, p); \ - if (ciflag != cflag) \ - goto bad; \ + p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ + len >= p[1] && \ + p[0] == opt) { \ + len -= p[1]; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) \ + goto bad; \ + if (!old) { \ + GETCHAR(cimaxslotindex, p); \ + if (cimaxslotindex != maxslot) \ + goto bad; \ + GETCHAR(ciflag, p); \ + if (ciflag != cflag) \ + goto bad; \ } \ - try_.neg = 0; \ + try_.neg = 0; \ } #endif /* VJ_SUPPORT */ #define REJCIADDR(opt, neg, val) \ if (go->neg && \ - (cilen = p[1]) == CILEN_ADDR && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val) \ - goto bad; \ - try_.neg = 0; \ + (cilen = p[1]) == CILEN_ADDR && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val) \ + goto bad; \ + try_.neg = 0; \ } #if LWIP_DNS #define REJCIDNS(opt, neg, dnsaddr) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != dnsaddr) \ - goto bad; \ - try_.neg = 0; \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != dnsaddr) \ + goto bad; \ + try_.neg = 0; \ } #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define REJCIWINS(opt, addr) \ if (addr && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != addr) \ - goto bad; \ - try_.winsaddr[opt == CI_MS_WINS2] = 0; \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != addr) \ + goto bad; \ + try_.winsaddr[opt == CI_MS_WINS2] = 0; \ } #endif /* UNUSED - WINS */ REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, - go->ouraddr, go->hisaddr); + go->ouraddr, go->hisaddr); #if VJ_SUPPORT REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); + go->maxslotindex, go->cflag); #endif /* VJ_SUPPORT */ REJCIADDR(CI_ADDR, neg_addr, go->ouraddr); @@ -1478,12 +1478,12 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; bad: @@ -1508,17 +1508,17 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { ipcp_options *wo = &pcb->ipcp_wantoptions; ipcp_options *ho = &pcb->ipcp_hisoptions; ipcp_options *ao = &pcb->ipcp_allowoptions; - u_char *cip, *next; /* Pointer to current and next CIs */ - u_short cilen, citype; /* Parsed len, type */ + u_char *cip, *next; /* Pointer to current and next CIs */ + u_short cilen, citype; /* Parsed len, type */ #if VJ_SUPPORT - u_short cishort; /* Parsed short value */ + u_short cishort; /* Parsed short value */ #endif /* VJ_SUPPORT */ u32_t tl, ciaddr1, ciaddr2;/* Parsed address values */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *ucp = inp; /* Pointer to current output char */ - int l = *len; /* Length left */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *ucp = inp; /* Pointer to current output char */ + int l = *len; /* Length left */ #if VJ_SUPPORT u_char maxslotindex, cflag; #endif /* VJ_SUPPORT */ @@ -1530,243 +1530,243 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { * Reset all his options. */ BZERO(ho, sizeof(*ho)); - + /* * Process all his options. */ next = inp; while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - IPCPDEBUG(("ipcp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_ADDRS: - if (!ao->old_addrs || ho->neg_addr || - cilen != CILEN_ADDRS) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no address, or if we both have his address but - * disagree about it, then NAK it with our idea. - * In particular, if we don't know his address, but he does, - * then accept it. - */ - GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = lwip_htonl(tl); - if (ciaddr1 != wo->hisaddr - && (ciaddr1 == 0 || !wo->accept_remote)) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(wo->hisaddr); - PUTLONG(tl, p); - } - } else if (ciaddr1 == 0 && wo->hisaddr == 0) { - /* - * If neither we nor he knows his address, reject the option. - */ - orc = CONFREJ; - wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ - break; - } - - /* - * If he doesn't know our address, or if we both have our address - * but disagree about it, then NAK it with our idea. - */ - GETLONG(tl, p); /* Parse desination address (ours) */ - ciaddr2 = lwip_htonl(tl); - if (ciaddr2 != wo->ouraddr) { - if (ciaddr2 == 0 || !wo->accept_local) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(wo->ouraddr); - PUTLONG(tl, p); - } - } else { - wo->ouraddr = ciaddr2; /* accept peer's idea */ - } - } - - ho->old_addrs = 1; - ho->hisaddr = ciaddr1; - ho->ouraddr = ciaddr2; - break; - - case CI_ADDR: - if (!ao->neg_addr || ho->old_addrs || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no address, or if we both have his address but - * disagree about it, then NAK it with our idea. - * In particular, if we don't know his address, but he does, - * then accept it. - */ - GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = lwip_htonl(tl); - if (ciaddr1 != wo->hisaddr - && (ciaddr1 == 0 || !wo->accept_remote)) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(wo->hisaddr); - PUTLONG(tl, p); - } - } else if (ciaddr1 == 0 && wo->hisaddr == 0) { - /* - * Don't ACK an address of 0.0.0.0 - reject it instead. - */ - orc = CONFREJ; - wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ - break; - } - - ho->neg_addr = 1; - ho->hisaddr = ciaddr1; - break; + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + IPCPDEBUG(("ipcp_reqci: bad CI length!")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_ADDRS: + if (!ao->old_addrs || ho->neg_addr || + cilen != CILEN_ADDRS) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no address, or if we both have his address but + * disagree about it, then NAK it with our idea. + * In particular, if we don't know his address, but he does, + * then accept it. + */ + GETLONG(tl, p); /* Parse source address (his) */ + ciaddr1 = lwip_htonl(tl); + if (ciaddr1 != wo->hisaddr + && (ciaddr1 == 0 || !wo->accept_remote)) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = lwip_ntohl(wo->hisaddr); + PUTLONG(tl, p); + } + } else if (ciaddr1 == 0 && wo->hisaddr == 0) { + /* + * If neither we nor he knows his address, reject the option. + */ + orc = CONFREJ; + wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ + break; + } + + /* + * If he doesn't know our address, or if we both have our address + * but disagree about it, then NAK it with our idea. + */ + GETLONG(tl, p); /* Parse desination address (ours) */ + ciaddr2 = lwip_htonl(tl); + if (ciaddr2 != wo->ouraddr) { + if (ciaddr2 == 0 || !wo->accept_local) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = lwip_ntohl(wo->ouraddr); + PUTLONG(tl, p); + } + } else { + wo->ouraddr = ciaddr2; /* accept peer's idea */ + } + } + + ho->old_addrs = 1; + ho->hisaddr = ciaddr1; + ho->ouraddr = ciaddr2; + break; + + case CI_ADDR: + if (!ao->neg_addr || ho->old_addrs || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no address, or if we both have his address but + * disagree about it, then NAK it with our idea. + * In particular, if we don't know his address, but he does, + * then accept it. + */ + GETLONG(tl, p); /* Parse source address (his) */ + ciaddr1 = lwip_htonl(tl); + if (ciaddr1 != wo->hisaddr + && (ciaddr1 == 0 || !wo->accept_remote)) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = lwip_ntohl(wo->hisaddr); + PUTLONG(tl, p); + } + } else if (ciaddr1 == 0 && wo->hisaddr == 0) { + /* + * Don't ACK an address of 0.0.0.0 - reject it instead. + */ + orc = CONFREJ; + wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ + break; + } + + ho->neg_addr = 1; + ho->hisaddr = ciaddr1; + break; #if LWIP_DNS - case CI_MS_DNS1: - case CI_MS_DNS2: - /* Microsoft primary or secondary DNS request */ - d = citype == CI_MS_DNS2; - - /* If we do not have a DNS address then we cannot send it */ - if (ao->dnsaddr[d] == 0 || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETLONG(tl, p); - if (lwip_htonl(tl) != ao->dnsaddr[d]) { + case CI_MS_DNS1: + case CI_MS_DNS2: + /* Microsoft primary or secondary DNS request */ + d = citype == CI_MS_DNS2; + + /* If we do not have a DNS address then we cannot send it */ + if (ao->dnsaddr[d] == 0 || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETLONG(tl, p); + if (lwip_htonl(tl) != ao->dnsaddr[d]) { DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(ao->dnsaddr[d]); - PUTLONG(tl, p); - orc = CONFNAK; + tl = lwip_ntohl(ao->dnsaddr[d]); + PUTLONG(tl, p); + orc = CONFNAK; } break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - case CI_MS_WINS1: - case CI_MS_WINS2: - /* Microsoft primary or secondary WINS request */ - d = citype == CI_MS_WINS2; - - /* If we do not have a DNS address then we cannot send it */ - if (ao->winsaddr[d] == 0 || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETLONG(tl, p); - if (lwip_htonl(tl) != ao->winsaddr[d]) { + case CI_MS_WINS1: + case CI_MS_WINS2: + /* Microsoft primary or secondary WINS request */ + d = citype == CI_MS_WINS2; + + /* If we do not have a DNS address then we cannot send it */ + if (ao->winsaddr[d] == 0 || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETLONG(tl, p); + if (lwip_htonl(tl) != ao->winsaddr[d]) { DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(ao->winsaddr[d]); - PUTLONG(tl, p); - orc = CONFNAK; + tl = lwip_ntohl(ao->winsaddr[d]); + PUTLONG(tl, p); + orc = CONFNAK; } break; #endif /* UNUSED - WINS */ #if VJ_SUPPORT - case CI_COMPRESSTYPE: - if (!ao->neg_vj || - (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - - if (!(cishort == IPCP_VJ_COMP || - (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { - orc = CONFREJ; - break; - } - - ho->neg_vj = 1; - ho->vj_protocol = cishort; - if (cilen == CILEN_VJ) { - GETCHAR(maxslotindex, p); - if (maxslotindex > ao->maxslotindex) { - orc = CONFNAK; - if (!reject_if_disagree){ - DECPTR(1, p); - PUTCHAR(ao->maxslotindex, p); - } - } - GETCHAR(cflag, p); - if (cflag && !ao->cflag) { - orc = CONFNAK; - if (!reject_if_disagree){ - DECPTR(1, p); - PUTCHAR(wo->cflag, p); - } - } - ho->maxslotindex = maxslotindex; - ho->cflag = cflag; - } else { - ho->old_vj = 1; - ho->maxslotindex = MAX_STATES - 1; - ho->cflag = 1; - } - break; + case CI_COMPRESSTYPE: + if (!ao->neg_vj || + (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + + if (!(cishort == IPCP_VJ_COMP || + (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { + orc = CONFREJ; + break; + } + + ho->neg_vj = 1; + ho->vj_protocol = cishort; + if (cilen == CILEN_VJ) { + GETCHAR(maxslotindex, p); + if (maxslotindex > ao->maxslotindex) { + orc = CONFNAK; + if (!reject_if_disagree){ + DECPTR(1, p); + PUTCHAR(ao->maxslotindex, p); + } + } + GETCHAR(cflag, p); + if (cflag && !ao->cflag) { + orc = CONFNAK; + if (!reject_if_disagree){ + DECPTR(1, p); + PUTCHAR(wo->cflag, p); + } + } + ho->maxslotindex = maxslotindex; + ho->cflag = cflag; + } else { + ho->old_vj = 1; + ho->maxslotindex = MAX_STATES - 1; + ho->cflag = 1; + } + break; #endif /* VJ_SUPPORT */ - default: - orc = CONFREJ; - break; - } + default: + orc = CONFREJ; + break; + } endswitch: - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree) /* Getting fed up with sending NAKs? */ - orc = CONFREJ; /* Get tough if so */ - else { - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - if (rc == CONFACK) { /* Ack'd all prior CIs? */ - rc = CONFNAK; /* Not anymore... */ - ucp = inp; /* Backup */ - } - } - } - - if (orc == CONFREJ && /* Reject this CI */ - rc != CONFREJ) { /* but no prior ones? */ - rc = CONFREJ; - ucp = inp; /* Backup */ - } - - /* Need to move CI? */ - if (ucp != cip) - MEMCPY(ucp, cip, cilen); /* Move it */ - - /* Update output pointer */ - INCPTR(cilen, ucp); + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) /* but prior CI wasnt? */ + continue; /* Don't send this one */ + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree) /* Getting fed up with sending NAKs? */ + orc = CONFREJ; /* Get tough if so */ + else { + if (rc == CONFREJ) /* Rejecting prior CI? */ + continue; /* Don't send this one */ + if (rc == CONFACK) { /* Ack'd all prior CIs? */ + rc = CONFNAK; /* Not anymore... */ + ucp = inp; /* Backup */ + } + } + } + + if (orc == CONFREJ && /* Reject this CI */ + rc != CONFREJ) { /* but no prior ones? */ + rc = CONFREJ; + ucp = inp; /* Backup */ + } + + /* Need to move CI? */ + if (ucp != cip) + MEMCPY(ucp, cip, cilen); /* Move it */ + + /* Update output pointer */ + INCPTR(cilen, ucp); } /* @@ -1777,21 +1777,21 @@ endswitch: * option safely. */ if (rc != CONFREJ && !ho->neg_addr && !ho->old_addrs && - wo->req_addr && !reject_if_disagree && !pcb->settings.noremoteip) { - if (rc == CONFACK) { - rc = CONFNAK; - ucp = inp; /* reset pointer */ - wo->req_addr = 0; /* don't ask again */ - } - PUTCHAR(CI_ADDR, ucp); - PUTCHAR(CILEN_ADDR, ucp); - tl = lwip_ntohl(wo->hisaddr); - PUTLONG(tl, ucp); - } - - *len = ucp - inp; /* Compute output length */ + wo->req_addr && !reject_if_disagree && !pcb->settings.noremoteip) { + if (rc == CONFACK) { + rc = CONFNAK; + ucp = inp; /* reset pointer */ + wo->req_addr = 0; /* don't ask again */ + } + PUTCHAR(CI_ADDR, ucp); + PUTCHAR(CILEN_ADDR, ucp); + tl = lwip_ntohl(wo->hisaddr); + PUTLONG(tl, ucp); + } + + *len = ucp - inp; /* Compute output length */ IPCPDEBUG(("ipcp: returning Configure-%s", CODENAME(rc))); - return (rc); /* Return final code */ + return (rc); /* Return final code */ } @@ -1812,17 +1812,17 @@ ip_check_options() * If local IP address already given, don't bother. */ if (wo->ouraddr == 0 && !disable_defaultip) { - /* - * Look up our hostname (possibly with domain name appended) - * and take the first IP address as our local IP address. - * If there isn't an IP address for our hostname, too bad. - */ - wo->accept_local = 1; /* don't insist on this default value */ - if ((hp = gethostbyname(hostname)) != NULL) { - local = *(u32_t *)hp->h_addr; - if (local != 0 && !bad_ip_adrs(local)) - wo->ouraddr = local; - } + /* + * Look up our hostname (possibly with domain name appended) + * and take the first IP address as our local IP address. + * If there isn't an IP address for our hostname, too bad. + */ + wo->accept_local = 1; /* don't insist on this default value */ + if ((hp = gethostbyname(hostname)) != NULL) { + local = *(u32_t *)hp->h_addr; + if (local != 0 && !bad_ip_adrs(local)) + wo->ouraddr = local; + } } ask_for_local = wo->ouraddr != 0 || !disable_defaultip; } @@ -1841,37 +1841,37 @@ ip_demand_conf(u) ipcp_options *wo = &ipcp_wantoptions[u]; if (wo->hisaddr == 0 && !pcb->settings.noremoteip) { - /* make up an arbitrary address for the peer */ - wo->hisaddr = lwip_htonl(0x0a707070 + ifunit); - wo->accept_remote = 1; + /* make up an arbitrary address for the peer */ + wo->hisaddr = lwip_htonl(0x0a707070 + ifunit); + wo->accept_remote = 1; } if (wo->ouraddr == 0) { - /* make up an arbitrary address for us */ - wo->ouraddr = lwip_htonl(0x0a404040 + ifunit); - wo->accept_local = 1; - ask_for_local = 0; /* don't tell the peer this address */ + /* make up an arbitrary address for us */ + wo->ouraddr = lwip_htonl(0x0a404040 + ifunit); + wo->accept_local = 1; + ask_for_local = 0; /* don't tell the peer this address */ } if (!sifaddr(pcb, wo->ouraddr, wo->hisaddr, get_mask(wo->ouraddr))) - return 0; + return 0; if (!sifup(pcb)) - return 0; + return 0; if (!sifnpmode(pcb, PPP_IP, NPMODE_QUEUE)) - return 0; + return 0; #if 0 /* UNUSED */ if (wo->default_route) - if (sifdefaultroute(pcb, wo->ouraddr, wo->hisaddr, - wo->replace_default_route)) - default_route_set[u] = 1; + if (sifdefaultroute(pcb, wo->ouraddr, wo->hisaddr, + wo->replace_default_route)) + default_route_set[u] = 1; #endif /* UNUSED */ #if 0 /* UNUSED - PROXY ARP */ if (wo->proxy_arp) - if (sifproxyarp(pcb, wo->hisaddr)) - proxy_arp_set[u] = 1; + if (sifproxyarp(pcb, wo->hisaddr)) + proxy_arp_set[u] = 1; #endif /* UNUSED - PROXY ARP */ ppp_notice("local IP address %I", wo->ouraddr); if (wo->hisaddr) - ppp_notice("remote IP address %I", wo->hisaddr); + ppp_notice("remote IP address %I", wo->hisaddr); return 1; } @@ -1895,46 +1895,46 @@ static void ipcp_up(fsm *f) { * We must have a non-zero IP address for both ends of the link. */ if (!ho->neg_addr && !ho->old_addrs) - ho->hisaddr = wo->hisaddr; + ho->hisaddr = wo->hisaddr; if (!(go->neg_addr || go->old_addrs) && (wo->neg_addr || wo->old_addrs) - && wo->ouraddr != 0) { - ppp_error("Peer refused to agree to our IP address"); - ipcp_close(f->pcb, "Refused our IP address"); - return; + && wo->ouraddr != 0) { + ppp_error("Peer refused to agree to our IP address"); + ipcp_close(f->pcb, "Refused our IP address"); + return; } if (go->ouraddr == 0) { - ppp_error("Could not determine local IP address"); - ipcp_close(f->pcb, "Could not determine local IP address"); - return; + ppp_error("Could not determine local IP address"); + ipcp_close(f->pcb, "Could not determine local IP address"); + return; } if (ho->hisaddr == 0 && !pcb->settings.noremoteip) { - ho->hisaddr = lwip_htonl(0x0a404040); - ppp_warn("Could not determine remote IP address: defaulting to %I", - ho->hisaddr); + ho->hisaddr = lwip_htonl(0x0a404040); + ppp_warn("Could not determine remote IP address: defaulting to %I", + ho->hisaddr); } #if 0 /* UNUSED */ script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0); if (ho->hisaddr != 0) - script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); + script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); #endif /* UNUSED */ #if LWIP_DNS if (!go->req_dns1) - go->dnsaddr[0] = 0; + go->dnsaddr[0] = 0; if (!go->req_dns2) - go->dnsaddr[1] = 0; + go->dnsaddr[1] = 0; #if 0 /* UNUSED */ if (go->dnsaddr[0]) - script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); + script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); if (go->dnsaddr[1]) - script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); + script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); #endif /* UNUSED */ if (pcb->settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { - sdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); + sdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); #if 0 /* UNUSED */ - script_setenv("USEPEERDNS", "1", 0); - create_resolv(go->dnsaddr[0], go->dnsaddr[1]); + script_setenv("USEPEERDNS", "1", 0); + create_resolv(go->dnsaddr[0], go->dnsaddr[1]); #endif /* UNUSED */ } #endif /* LWIP_DNS */ @@ -1943,29 +1943,29 @@ static void ipcp_up(fsm *f) { * Check that the peer is allowed to use the IP address it wants. */ if (ho->hisaddr != 0) { - u32_t addr = lwip_ntohl(ho->hisaddr); - if ((addr >> IP_CLASSA_NSHIFT) == IP_LOOPBACKNET - || IP_MULTICAST(addr) || IP_BADCLASS(addr) - /* - * For now, consider that PPP in server mode with peer required - * to authenticate must provide the peer IP address, reject any - * IP address wanted by peer different than the one we wanted. - */ + u32_t addr = lwip_ntohl(ho->hisaddr); + if ((addr >> IP_CLASSA_NSHIFT) == IP_LOOPBACKNET + || IP_MULTICAST(addr) || IP_BADCLASS(addr) + /* + * For now, consider that PPP in server mode with peer required + * to authenticate must provide the peer IP address, reject any + * IP address wanted by peer different than the one we wanted. + */ #if PPP_SERVER && PPP_AUTH_SUPPORT - || (pcb->settings.auth_required && wo->hisaddr != ho->hisaddr) + || (pcb->settings.auth_required && wo->hisaddr != ho->hisaddr) #endif /* PPP_SERVER && PPP_AUTH_SUPPORT */ - ) { - ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); - ipcp_close(pcb, "Unauthorized remote IP address"); - return; - } + ) { + ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); + ipcp_close(pcb, "Unauthorized remote IP address"); + return; + } } #if 0 /* Unused */ /* Upstream checking code */ if (ho->hisaddr != 0 && !auth_ip_addr(f->unit, ho->hisaddr)) { - ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); - ipcp_close(f->unit, "Unauthorized remote IP address"); - return; + ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); + ipcp_close(f->unit, "Unauthorized remote IP address"); + return; } #endif /* Unused */ @@ -1981,114 +1981,114 @@ static void ipcp_up(fsm *f) { * interface to pass IP packets. */ if (demand) { - if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) { - ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr, - wo->replace_default_route); - if (go->ouraddr != wo->ouraddr) { - ppp_warn("Local IP address changed to %I", go->ouraddr); - script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0); - wo->ouraddr = go->ouraddr; - } else - script_unsetenv("OLDIPLOCAL"); - if (ho->hisaddr != wo->hisaddr && wo->hisaddr != 0) { - ppp_warn("Remote IP address changed to %I", ho->hisaddr); - script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0); - wo->hisaddr = ho->hisaddr; - } else - script_unsetenv("OLDIPREMOTE"); - - /* Set the interface to the new addresses */ - mask = get_mask(go->ouraddr); - if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { + if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) { + ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr, + wo->replace_default_route); + if (go->ouraddr != wo->ouraddr) { + ppp_warn("Local IP address changed to %I", go->ouraddr); + script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0); + wo->ouraddr = go->ouraddr; + } else + script_unsetenv("OLDIPLOCAL"); + if (ho->hisaddr != wo->hisaddr && wo->hisaddr != 0) { + ppp_warn("Remote IP address changed to %I", ho->hisaddr); + script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0); + wo->hisaddr = ho->hisaddr; + } else + script_unsetenv("OLDIPREMOTE"); + + /* Set the interface to the new addresses */ + mask = get_mask(go->ouraddr); + if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { #if PPP_DEBUG - ppp_warn("Interface configuration failed"); + ppp_warn("Interface configuration failed"); #endif /* PPP_DEBUG */ - ipcp_close(f->unit, "Interface configuration failed"); - return; - } + ipcp_close(f->unit, "Interface configuration failed"); + return; + } - /* assign a default route through the interface if required */ - if (ipcp_wantoptions[f->unit].default_route) - if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, - wo->replace_default_route)) - default_route_set[f->unit] = 1; + /* assign a default route through the interface if required */ + if (ipcp_wantoptions[f->unit].default_route) + if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, + wo->replace_default_route)) + default_route_set[f->unit] = 1; #if 0 /* UNUSED - PROXY ARP */ - /* Make a proxy ARP entry if requested. */ - if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp) - if (sifproxyarp(pcb, ho->hisaddr)) - proxy_arp_set[f->unit] = 1; + /* Make a proxy ARP entry if requested. */ + if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp) + if (sifproxyarp(pcb, ho->hisaddr)) + proxy_arp_set[f->unit] = 1; #endif /* UNUSED - PROXY ARP */ - } - demand_rexmit(PPP_IP,go->ouraddr); - sifnpmode(pcb, PPP_IP, NPMODE_PASS); + } + demand_rexmit(PPP_IP,go->ouraddr); + sifnpmode(pcb, PPP_IP, NPMODE_PASS); } else #endif /* DEMAND_SUPPORT */ { - /* - * Set IP addresses and (if specified) netmask. - */ - mask = get_mask(go->ouraddr); + /* + * Set IP addresses and (if specified) netmask. + */ + mask = get_mask(go->ouraddr); #if !(defined(SVR4) && (defined(SNI) || defined(__USLC__))) - if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { + if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { #if PPP_DEBUG - ppp_warn("Interface configuration failed"); + ppp_warn("Interface configuration failed"); #endif /* PPP_DEBUG */ - ipcp_close(f->pcb, "Interface configuration failed"); - return; - } + ipcp_close(f->pcb, "Interface configuration failed"); + return; + } #endif - /* bring the interface up for IP */ - if (!sifup(pcb)) { + /* bring the interface up for IP */ + if (!sifup(pcb)) { #if PPP_DEBUG - ppp_warn("Interface failed to come up"); + ppp_warn("Interface failed to come up"); #endif /* PPP_DEBUG */ - ipcp_close(f->pcb, "Interface configuration failed"); - return; - } + ipcp_close(f->pcb, "Interface configuration failed"); + return; + } #if (defined(SVR4) && (defined(SNI) || defined(__USLC__))) - if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { + if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { #if PPP_DEBUG - ppp_warn("Interface configuration failed"); + ppp_warn("Interface configuration failed"); #endif /* PPP_DEBUG */ - ipcp_close(f->unit, "Interface configuration failed"); - return; - } + ipcp_close(f->unit, "Interface configuration failed"); + return; + } #endif #if DEMAND_SUPPORT - sifnpmode(pcb, PPP_IP, NPMODE_PASS); + sifnpmode(pcb, PPP_IP, NPMODE_PASS); #endif /* DEMAND_SUPPORT */ #if 0 /* UNUSED */ - /* assign a default route through the interface if required */ - if (wo->default_route) - if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, - wo->replace_default_route)) - pcb->default_route_set = 1; + /* assign a default route through the interface if required */ + if (wo->default_route) + if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, + wo->replace_default_route)) + pcb->default_route_set = 1; #endif /* UNUSED */ #if 0 /* UNUSED - PROXY ARP */ - /* Make a proxy ARP entry if requested. */ - if (ho->hisaddr != 0 && wo->proxy_arp) - if (sifproxyarp(pcb, ho->hisaddr)) - pcb->proxy_arp_set = 1; + /* Make a proxy ARP entry if requested. */ + if (ho->hisaddr != 0 && wo->proxy_arp) + if (sifproxyarp(pcb, ho->hisaddr)) + pcb->proxy_arp_set = 1; #endif /* UNUSED - PROXY ARP */ - wo->ouraddr = go->ouraddr; + wo->ouraddr = go->ouraddr; - ppp_notice("local IP address %I", go->ouraddr); - if (ho->hisaddr != 0) - ppp_notice("remote IP address %I", ho->hisaddr); + ppp_notice("local IP address %I", go->ouraddr); + if (ho->hisaddr != 0) + ppp_notice("remote IP address %I", ho->hisaddr); #if LWIP_DNS - if (go->dnsaddr[0]) - ppp_notice("primary DNS address %I", go->dnsaddr[0]); - if (go->dnsaddr[1]) - ppp_notice("secondary DNS address %I", go->dnsaddr[1]); + if (go->dnsaddr[0]) + ppp_notice("primary DNS address %I", go->dnsaddr[0]); + if (go->dnsaddr[1]) + ppp_notice("secondary DNS address %I", go->dnsaddr[1]); #endif /* LWIP_DNS */ } @@ -2104,7 +2104,7 @@ static void ipcp_up(fsm *f) { #endif /* PPP_NOTIFY */ #if 0 /* UNUSED */ if (ip_up_hook) - ip_up_hook(); + ip_up_hook(); #endif /* UNUSED */ } @@ -2133,11 +2133,11 @@ static void ipcp_down(fsm *f) { #endif /* PPP_NOTIFY */ #if 0 /* UNUSED */ if (ip_down_hook) - ip_down_hook(); + ip_down_hook(); #endif /* UNUSED */ if (pcb->ipcp_is_up) { - pcb->ipcp_is_up = 0; - np_down(pcb, PPP_IP); + pcb->ipcp_is_up = 0; + np_down(pcb, PPP_IP); } #if VJ_SUPPORT sifvjcomp(pcb, 0, 0, 0); @@ -2145,8 +2145,8 @@ static void ipcp_down(fsm *f) { #if PPP_STATS_SUPPORT print_link_stats(); /* _after_ running the notifiers and ip_down_hook(), - * because print_link_stats() sets link_stats_valid - * to 0 (zero) */ + * because print_link_stats() sets link_stats_valid + * to 0 (zero) */ #endif /* PPP_STATS_SUPPORT */ #if DEMAND_SUPPORT @@ -2155,18 +2155,18 @@ static void ipcp_down(fsm *f) { * to queue up outgoing packets (for now). */ if (demand) { - sifnpmode(pcb, PPP_IP, NPMODE_QUEUE); + sifnpmode(pcb, PPP_IP, NPMODE_QUEUE); } else #endif /* DEMAND_SUPPORT */ { #if DEMAND_SUPPORT - sifnpmode(pcb, PPP_IP, NPMODE_DROP); + sifnpmode(pcb, PPP_IP, NPMODE_DROP); #endif /* DEMAND_SUPPORT */ - sifdown(pcb); - ipcp_clear_addrs(pcb, go->ouraddr, - ho->hisaddr, 0); + sifdown(pcb); + ipcp_clear_addrs(pcb, go->ouraddr, + ho->hisaddr, 0); #if LWIP_DNS - cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); + cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); #endif /* LWIP_DNS */ } } @@ -2181,8 +2181,8 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re #if 0 /* UNUSED - PROXY ARP */ if (pcb->proxy_arp_set) { - cifproxyarp(pcb, hisaddr); - pcb->proxy_arp_set = 0; + cifproxyarp(pcb, hisaddr); + pcb->proxy_arp_set = 0; } #endif /* UNUSED - PROXY ARP */ #if 0 /* UNUSED */ @@ -2195,8 +2195,8 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re * is one saved by an sifdefaultroute with replacedefaultroute. */ if (!replacedefaultroute && pcb->default_route_set) { - cifdefaultroute(pcb, ouraddr, hisaddr); - pcb->default_route_set = 0; + cifdefaultroute(pcb, ouraddr, hisaddr); + pcb->default_route_set = 0; } #endif /* UNUSED */ cifaddr(pcb, ouraddr, hisaddr); @@ -2207,11 +2207,11 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re * ipcp_finished - possibly shut down the lower layers. */ static void ipcp_finished(fsm *f) { - ppp_pcb *pcb = f->pcb; - if (pcb->ipcp_is_open) { - pcb->ipcp_is_open = 0; - np_finished(pcb, PPP_IP); - } + ppp_pcb *pcb = f->pcb; + if (pcb->ipcp_is_open) { + pcb->ipcp_is_open = 0; + np_finished(pcb, PPP_IP); + } } @@ -2237,7 +2237,7 @@ static const char* const ipcp_codenames[] = { }; static int ipcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg) { + void (*printer) (void *, const char *, ...), void *arg) { int code, id, len, olen; const u_char *pstart, *optend; #if VJ_SUPPORT @@ -2246,18 +2246,18 @@ static int ipcp_printpkt(const u_char *p, int plen, u32_t cilong; if (plen < HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(ipcp_codenames)) - printer(arg, " %s", ipcp_codenames[code-1]); + printer(arg, " %s", ipcp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { @@ -2265,98 +2265,98 @@ static int ipcp_printpkt(const u_char *p, int plen, case CONFACK: case CONFNAK: case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { - case CI_ADDRS: - if (olen == CILEN_ADDRS) { - p += 2; - GETLONG(cilong, p); - printer(arg, "addrs %I", lwip_htonl(cilong)); - GETLONG(cilong, p); - printer(arg, " %I", lwip_htonl(cilong)); - } - break; + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { + case CI_ADDRS: + if (olen == CILEN_ADDRS) { + p += 2; + GETLONG(cilong, p); + printer(arg, "addrs %I", lwip_htonl(cilong)); + GETLONG(cilong, p); + printer(arg, " %I", lwip_htonl(cilong)); + } + break; #if VJ_SUPPORT - case CI_COMPRESSTYPE: - if (olen >= CILEN_COMPRESS) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "compress "); - switch (cishort) { - case IPCP_VJ_COMP: - printer(arg, "VJ"); - break; - case IPCP_VJ_COMP_OLD: - printer(arg, "old-VJ"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; + case CI_COMPRESSTYPE: + if (olen >= CILEN_COMPRESS) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "compress "); + switch (cishort) { + case IPCP_VJ_COMP: + printer(arg, "VJ"); + break; + case IPCP_VJ_COMP_OLD: + printer(arg, "old-VJ"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; #endif /* VJ_SUPPORT */ - case CI_ADDR: - if (olen == CILEN_ADDR) { - p += 2; - GETLONG(cilong, p); - printer(arg, "addr %I", lwip_htonl(cilong)); - } - break; + case CI_ADDR: + if (olen == CILEN_ADDR) { + p += 2; + GETLONG(cilong, p); + printer(arg, "addr %I", lwip_htonl(cilong)); + } + break; #if LWIP_DNS - case CI_MS_DNS1: - case CI_MS_DNS2: - p += 2; - GETLONG(cilong, p); - printer(arg, "ms-dns%d %I", (code == CI_MS_DNS1? 1: 2), - htonl(cilong)); - break; + case CI_MS_DNS1: + case CI_MS_DNS2: + p += 2; + GETLONG(cilong, p); + printer(arg, "ms-dns%d %I", (code == CI_MS_DNS1? 1: 2), + htonl(cilong)); + break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - case CI_MS_WINS1: - case CI_MS_WINS2: - p += 2; - GETLONG(cilong, p); - printer(arg, "ms-wins %I", lwip_htonl(cilong)); - break; + case CI_MS_WINS1: + case CI_MS_WINS2: + p += 2; + GETLONG(cilong, p); + printer(arg, "ms-wins %I", lwip_htonl(cilong)); + break; #endif /* UNUSED - WINS */ - default: - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; + default: + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } return p - pstart; @@ -2369,25 +2369,25 @@ static int ipcp_printpkt(const u_char *p, int plen, * We don't bring the link up for IP fragments or for TCP FIN packets * with no data. */ -#define IP_HDRLEN 20 /* bytes */ -#define IP_OFFMASK 0x1fff +#define IP_HDRLEN 20 /* bytes */ +#define IP_OFFMASK 0x1fff #ifndef IPPROTO_TCP -#define IPPROTO_TCP 6 +#define IPPROTO_TCP 6 #endif -#define TCP_HDRLEN 20 -#define TH_FIN 0x01 +#define TCP_HDRLEN 20 +#define TH_FIN 0x01 /* * We use these macros because the IP header may be at an odd address, * and some compilers might use word loads to get th_off or ip_hl. */ -#define net_short(x) (((x)[0] << 8) + (x)[1]) -#define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) -#define get_ipoff(x) net_short((unsigned char *)(x) + 6) -#define get_ipproto(x) (((unsigned char *)(x))[9]) -#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) -#define get_tcpflags(x) (((unsigned char *)(x))[13]) +#define net_short(x) (((x)[0] << 8) + (x)[1]) +#define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) +#define get_ipoff(x) net_short((unsigned char *)(x) + 6) +#define get_ipproto(x) (((unsigned char *)(x))[9]) +#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) +#define get_tcpflags(x) (((unsigned char *)(x))[13]) static int ip_active_pkt(pkt, len) @@ -2400,17 +2400,17 @@ ip_active_pkt(pkt, len) len -= PPP_HDRLEN; pkt += PPP_HDRLEN; if (len < IP_HDRLEN) - return 0; + return 0; if ((get_ipoff(pkt) & IP_OFFMASK) != 0) - return 0; + return 0; if (get_ipproto(pkt) != IPPROTO_TCP) - return 1; + return 1; hlen = get_iphl(pkt) * 4; if (len < hlen + TCP_HDRLEN) - return 0; + return 0; tcp = pkt + hlen; if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4) - return 0; + return 0; return 1; } #endif /* DEMAND_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/ipv6cp.c b/components/net/lwip-2.0.2/src/netif/ppp/ipv6cp.c index 11c18df743..47521eeb02 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/ipv6cp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/ipv6cp.c @@ -73,7 +73,7 @@ between BULL S.A. and INRIA). This software is available with usual "research" terms - with the aim of retain credits of the software. + 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, @@ -135,11 +135,11 @@ * 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.c,v 1.21 2005/08/25 23:59:34 paulus Exp $ + * $Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp $ */ /* - * @todo: + * @todo: * * Proxy Neighbour Discovery. * @@ -188,21 +188,21 @@ static void ipv6cp_down(fsm *f); /* We're DOWN */ static void ipv6cp_finished(fsm *f); /* Don't need lower layer */ static const fsm_callbacks ipv6cp_callbacks = { /* IPV6CP callback routines */ - ipv6cp_resetci, /* Reset our Configuration Information */ - ipv6cp_cilen, /* Length of our Configuration Information */ - ipv6cp_addci, /* Add our Configuration Information */ - ipv6cp_ackci, /* ACK our Configuration Information */ - ipv6cp_nakci, /* NAK our Configuration Information */ - ipv6cp_rejci, /* Reject our Configuration Information */ - ipv6cp_reqci, /* Request peer's Configuration Information */ - ipv6cp_up, /* Called when fsm reaches OPENED state */ - ipv6cp_down, /* Called when fsm leaves OPENED state */ - NULL, /* Called when we want the lower layer up */ - ipv6cp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - NULL, /* Called to handle protocol-specific codes */ - "IPV6CP" /* String name of protocol */ + ipv6cp_resetci, /* Reset our Configuration Information */ + ipv6cp_cilen, /* Length of our Configuration Information */ + ipv6cp_addci, /* Add our Configuration Information */ + ipv6cp_ackci, /* ACK our Configuration Information */ + ipv6cp_nakci, /* NAK our Configuration Information */ + ipv6cp_rejci, /* Reject our Configuration Information */ + ipv6cp_reqci, /* Request peer's Configuration Information */ + ipv6cp_up, /* Called when fsm reaches OPENED state */ + ipv6cp_down, /* Called when fsm leaves OPENED state */ + NULL, /* Called when we want the lower layer up */ + ipv6cp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + NULL, /* Called to handle protocol-specific codes */ + "IPV6CP" /* String name of protocol */ }; #if PPP_OPTIONS @@ -211,7 +211,7 @@ static const fsm_callbacks ipv6cp_callbacks = { /* IPV6CP callback routines */ */ static int setifaceid(char **arg)); static void printifaceid(option_t *, - void (*)(void *, char *, ...), void *)); + void (*)(void *, char *, ...), void *)); static option_t ipv6cp_option_list[] = { { "ipv6", o_special, (void *)setifaceid, @@ -265,7 +265,7 @@ static int ipv6_demand_conf(int u); #endif /* DEMAND_SUPPORT */ #if PRINTPKT_SUPPORT static int ipv6cp_printpkt(const u_char *p, int plen, - void (*printer)(void *, const char *, ...), void *arg); + void (*printer)(void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ #if DEMAND_SUPPORT static int ipv6_active_pkt(u_char *pkt, int len); @@ -309,12 +309,12 @@ static void ipv6cp_script_done(void *)); /* * Lengths of configuration options. */ -#define CILEN_VOID 2 -#define CILEN_COMPRESS 4 /* length for RFC2023 compress opt. */ -#define CILEN_IFACEID 10 /* RFC2472, interface identifier */ +#define CILEN_VOID 2 +#define CILEN_COMPRESS 4 /* length for RFC2023 compress opt. */ +#define CILEN_IFACEID 10 /* RFC2472, interface identifier */ -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") #if 0 /* UNUSED */ /* @@ -344,49 +344,49 @@ setifaceid(argv) static int prio_local, prio_remote; #define VALIDID(a) ( (((a).s6_addr32[0] == 0) && ((a).s6_addr32[1] == 0)) && \ - (((a).s6_addr32[2] != 0) || ((a).s6_addr32[3] != 0)) ) - + (((a).s6_addr32[2] != 0) || ((a).s6_addr32[3] != 0)) ) + arg = *argv; if ((comma = strchr(arg, ',')) == NULL) - comma = arg + strlen(arg); - - /* + comma = arg + strlen(arg); + + /* * If comma first character, then no local identifier */ if (comma != arg) { - c = *comma; - *comma = '\0'; - - if (inet_pton(AF_INET6, arg, &addr) == 0 || !VALIDID(addr)) { - option_error("Illegal interface identifier (local): %s", arg); - return 0; - } - - if (option_priority >= prio_local) { - eui64_copy(addr.s6_addr32[2], wo->ourid); - wo->opt_local = 1; - prio_local = option_priority; - } - *comma = c; + c = *comma; + *comma = '\0'; + + if (inet_pton(AF_INET6, arg, &addr) == 0 || !VALIDID(addr)) { + option_error("Illegal interface identifier (local): %s", arg); + return 0; + } + + if (option_priority >= prio_local) { + eui64_copy(addr.s6_addr32[2], wo->ourid); + wo->opt_local = 1; + prio_local = option_priority; + } + *comma = c; } - + /* * If comma last character, the no remote identifier */ if (*comma != 0 && *++comma != '\0') { - if (inet_pton(AF_INET6, comma, &addr) == 0 || !VALIDID(addr)) { - option_error("Illegal interface identifier (remote): %s", comma); - return 0; - } - if (option_priority >= prio_remote) { - eui64_copy(addr.s6_addr32[2], wo->hisid); - wo->opt_remote = 1; - prio_remote = option_priority; - } + if (inet_pton(AF_INET6, comma, &addr) == 0 || !VALIDID(addr)) { + option_error("Illegal interface identifier (remote): %s", comma); + return 0; + } + if (option_priority >= prio_remote) { + eui64_copy(addr.s6_addr32[2], wo->hisid); + wo->opt_remote = 1; + prio_remote = option_priority; + } } if (override_value("+ipv6", option_priority, option_source)) - ipv6cp_protent.enabled_flag = 1; + ipv6cp_protent.enabled_flag = 1; return 1; } @@ -396,13 +396,13 @@ printifaceid(opt, printer, arg) void (*printer)(void *, char *, ...)); void *arg; { - ipv6cp_options *wo = &ipv6cp_wantoptions[0]; + ipv6cp_options *wo = &ipv6cp_wantoptions[0]; - if (wo->opt_local) - printer(arg, "%s", llv6_ntoa(wo->ourid)); - printer(arg, ","); - if (wo->opt_remote) - printer(arg, "%s", llv6_ntoa(wo->hisid)); + if (wo->opt_local) + printer(arg, "%s", llv6_ntoa(wo->ourid)); + printer(arg, ","); + if (wo->opt_remote) + printer(arg, "%s", llv6_ntoa(wo->hisid)); } #endif /* PPP_OPTIONS */ @@ -513,13 +513,13 @@ static void ipv6cp_resetci(fsm *f) { ipv6cp_options *ao = &pcb->ipv6cp_allowoptions; wo->req_ifaceid = wo->neg_ifaceid && ao->neg_ifaceid; - + if (!wo->opt_local) { - eui64_magic_nz(wo->ourid); + eui64_magic_nz(wo->ourid); } - + *go = *wo; - eui64_zero(go->hisid); /* last proposed interface identifier */ + eui64_zero(go->hisid); /* last proposed interface identifier */ } @@ -531,15 +531,15 @@ static int ipv6cp_cilen(fsm *f) { ipv6cp_options *go = &pcb->ipv6cp_gotoptions; #ifdef IPV6CP_COMP -#define LENCIVJ(neg) (neg ? CILEN_COMPRESS : 0) +#define LENCIVJ(neg) (neg ? CILEN_COMPRESS : 0) #endif /* IPV6CP_COMP */ -#define LENCIIFACEID(neg) (neg ? CILEN_IFACEID : 0) +#define LENCIIFACEID(neg) (neg ? CILEN_IFACEID : 0) return (LENCIIFACEID(go->neg_ifaceid) + #ifdef IPV6CP_COMP - LENCIVJ(go->neg_vj) + + LENCIVJ(go->neg_vj) + #endif /* IPV6CP_COMP */ - 0); + 0); } @@ -554,27 +554,27 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) { #ifdef IPV6CP_COMP #define ADDCIVJ(opt, neg, val) \ if (neg) { \ - int vjlen = CILEN_COMPRESS; \ - if (len >= vjlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(vjlen, ucp); \ - PUTSHORT(val, ucp); \ - len -= vjlen; \ - } else \ - neg = 0; \ + int vjlen = CILEN_COMPRESS; \ + if (len >= vjlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(vjlen, ucp); \ + PUTSHORT(val, ucp); \ + len -= vjlen; \ + } else \ + neg = 0; \ } #endif /* IPV6CP_COMP */ #define ADDCIIFACEID(opt, neg, val1) \ if (neg) { \ - int idlen = CILEN_IFACEID; \ - if (len >= idlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(idlen, ucp); \ - eui64_put(val1, ucp); \ - len -= idlen; \ - } else \ - neg = 0; \ + int idlen = CILEN_IFACEID; \ + if (len >= idlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(idlen, ucp); \ + eui64_put(val1, ucp); \ + len -= idlen; \ + } else \ + neg = 0; \ } ADDCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid); @@ -591,8 +591,8 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) { * ipv6cp_ackci - Ack our CIs. * * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. + * 0 - Ack was bad. + * 1 - Ack was good. */ static int ipv6cp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -612,33 +612,33 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) { #ifdef IPV6CP_COMP #define ACKCIVJ(opt, neg, val) \ if (neg) { \ - int vjlen = CILEN_COMPRESS; \ - if ((len -= vjlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != vjlen || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ + int vjlen = CILEN_COMPRESS; \ + if ((len -= vjlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != vjlen || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ } #endif /* IPV6CP_COMP */ #define ACKCIIFACEID(opt, neg, val1) \ if (neg) { \ - int idlen = CILEN_IFACEID; \ - if ((len -= idlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != idlen || \ - citype != opt) \ - goto bad; \ - eui64_get(ifaceid, p); \ - if (! eui64_equals(val1, ifaceid)) \ - goto bad; \ + int idlen = CILEN_IFACEID; \ + if ((len -= idlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != idlen || \ + citype != opt) \ + goto bad; \ + eui64_get(ifaceid, p); \ + if (! eui64_equals(val1, ifaceid)) \ + goto bad; \ } ACKCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid); @@ -651,7 +651,7 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; return (1); bad: @@ -665,8 +665,8 @@ bad: * or if IPV6CP is in the OPENED state. * * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. + * 0 - Nak was bad. + * 1 - Nak was good. */ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; @@ -676,8 +676,8 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { u_short cishort; #endif /* IPV6CP_COMP */ eui64_t ifaceid; - ipv6cp_options no; /* options we've seen Naks for */ - ipv6cp_options try_; /* options to request next time */ + ipv6cp_options no; /* options we've seen Naks for */ + ipv6cp_options try_; /* options to request next time */ BZERO(&no, sizeof(no)); try_ = *go; @@ -689,26 +689,26 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ #define NAKCIIFACEID(opt, neg, code) \ if (go->neg && \ - len >= (cilen = CILEN_IFACEID) && \ - p[1] == cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - eui64_get(ifaceid, p); \ - no.neg = 1; \ - code \ + len >= (cilen = CILEN_IFACEID) && \ + p[1] == cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + eui64_get(ifaceid, p); \ + no.neg = 1; \ + code \ } #ifdef IPV6CP_COMP #define NAKCIVJ(opt, neg, code) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_COMPRESS) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ + ((cilen = p[1]) == CILEN_COMPRESS) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ code \ } #endif /* IPV6CP_COMP */ @@ -718,27 +718,27 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * from our idea, only if the accept_{local,remote} flag is set. */ NAKCIIFACEID(CI_IFACEID, neg_ifaceid, - if (treat_as_reject) { - try_.neg_ifaceid = 0; - } else if (go->accept_local) { - while (eui64_iszero(ifaceid) || - eui64_equals(ifaceid, go->hisid)) /* bad luck */ - eui64_magic(ifaceid); - try_.ourid = ifaceid; - IPV6CPDEBUG(("local LL address %s", llv6_ntoa(ifaceid))); - } - ); + if (treat_as_reject) { + try_.neg_ifaceid = 0; + } else if (go->accept_local) { + while (eui64_iszero(ifaceid) || + eui64_equals(ifaceid, go->hisid)) /* bad luck */ + eui64_magic(ifaceid); + try_.ourid = ifaceid; + IPV6CPDEBUG(("local LL address %s", llv6_ntoa(ifaceid))); + } + ); #ifdef IPV6CP_COMP NAKCIVJ(CI_COMPRESSTYPE, neg_vj, - { - if (cishort == IPV6CP_COMP && !treat_as_reject) { - try_.vj_protocol = cishort; - } else { - try_.neg_vj = 0; - } - } - ); + { + if (cishort == IPV6CP_COMP && !treat_as_reject) { + try_.vj_protocol = cishort; + } else { + try_.neg_vj = 0; + } + } + ); #endif /* IPV6CP_COMP */ /* @@ -748,49 +748,49 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If they want us to ask for compression, we refuse. */ while (len >= CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) - goto bad; - next = p + cilen - 2; + GETCHAR(citype, p); + GETCHAR(cilen, p); + if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) + goto bad; + next = p + cilen - 2; - switch (citype) { + switch (citype) { #ifdef IPV6CP_COMP - case CI_COMPRESSTYPE: - if (go->neg_vj || no.neg_vj || - (cilen != CILEN_COMPRESS)) - goto bad; - no.neg_vj = 1; - break; + case CI_COMPRESSTYPE: + if (go->neg_vj || no.neg_vj || + (cilen != CILEN_COMPRESS)) + goto bad; + no.neg_vj = 1; + break; #endif /* IPV6CP_COMP */ - case CI_IFACEID: - if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID) - goto bad; - try_.neg_ifaceid = 1; - eui64_get(ifaceid, p); - if (go->accept_local) { - while (eui64_iszero(ifaceid) || - eui64_equals(ifaceid, go->hisid)) /* bad luck */ - eui64_magic(ifaceid); - try_.ourid = ifaceid; - } - no.neg_ifaceid = 1; - break; - default: - break; - } - p = next; + case CI_IFACEID: + if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID) + goto bad; + try_.neg_ifaceid = 1; + eui64_get(ifaceid, p); + if (go->accept_local) { + while (eui64_iszero(ifaceid) || + eui64_equals(ifaceid, go->hisid)) /* bad luck */ + eui64_magic(ifaceid); + try_.ourid = ifaceid; + } + no.neg_ifaceid = 1; + break; + default: + break; + } + p = next; } /* If there is still anything left, this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * OK, the Nak is good. Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; @@ -811,7 +811,7 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) { u_short cishort; #endif /* IPV6CP_COMP */ eui64_t ifaceid; - ipv6cp_options try_; /* options to request next time */ + ipv6cp_options try_; /* options to request next time */ try_ = *go; /* @@ -821,31 +821,31 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) { */ #define REJCIIFACEID(opt, neg, val1) \ if (go->neg && \ - len >= (cilen = CILEN_IFACEID) && \ - p[1] == cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - eui64_get(ifaceid, p); \ - /* Check rejected value. */ \ - if (! eui64_equals(ifaceid, val1)) \ - goto bad; \ - try_.neg = 0; \ + len >= (cilen = CILEN_IFACEID) && \ + p[1] == cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + eui64_get(ifaceid, p); \ + /* Check rejected value. */ \ + if (! eui64_equals(ifaceid, val1)) \ + goto bad; \ + try_.neg = 0; \ } #ifdef IPV6CP_COMP #define REJCIVJ(opt, neg, val) \ if (go->neg && \ - p[1] == CILEN_COMPRESS && \ - len >= p[1] && \ - p[0] == opt) { \ - len -= p[1]; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) \ - goto bad; \ - try_.neg = 0; \ + p[1] == CILEN_COMPRESS && \ + len >= p[1] && \ + p[0] == opt) { \ + len -= p[1]; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) \ + goto bad; \ + try_.neg = 0; \ } #endif /* IPV6CP_COMP */ @@ -859,12 +859,12 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; bad: @@ -890,150 +890,150 @@ static int ipv6cp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { ipv6cp_options *ho = &pcb->ipv6cp_hisoptions; ipv6cp_options *ao = &pcb->ipv6cp_allowoptions; ipv6cp_options *go = &pcb->ipv6cp_gotoptions; - u_char *cip, *next; /* Pointer to current and next CIs */ - u_short cilen, citype; /* Parsed len, type */ + u_char *cip, *next; /* Pointer to current and next CIs */ + u_short cilen, citype; /* Parsed len, type */ #ifdef IPV6CP_COMP - u_short cishort; /* Parsed short value */ + u_short cishort; /* Parsed short value */ #endif /* IPV6CP_COMP */ - eui64_t ifaceid; /* Parsed interface identifier */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *ucp = inp; /* Pointer to current output char */ - int l = *len; /* Length left */ + eui64_t ifaceid; /* Parsed interface identifier */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *ucp = inp; /* Pointer to current output char */ + int l = *len; /* Length left */ /* * Reset all his options. */ BZERO(ho, sizeof(*ho)); - + /* * Process all his options. */ next = inp; while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - IPV6CPDEBUG(("ipv6cp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_IFACEID: - IPV6CPDEBUG(("ipv6cp: received interface identifier ")); - - if (!ao->neg_ifaceid || - cilen != CILEN_IFACEID) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no interface identifier, or if we both have same - * identifier then NAK it with new idea. - * In particular, if we don't know his identifier, but he does, - * then accept it. - */ - eui64_get(ifaceid, p); - IPV6CPDEBUG(("(%s)", llv6_ntoa(ifaceid))); - if (eui64_iszero(ifaceid) && eui64_iszero(go->ourid)) { - orc = CONFREJ; /* Reject CI */ - break; - } - if (!eui64_iszero(wo->hisid) && - !eui64_equals(ifaceid, wo->hisid) && - eui64_iszero(go->hisid)) { - - orc = CONFNAK; - ifaceid = wo->hisid; - go->hisid = ifaceid; - DECPTR(sizeof(ifaceid), p); - eui64_put(ifaceid, p); - } else - if (eui64_iszero(ifaceid) || eui64_equals(ifaceid, go->ourid)) { - orc = CONFNAK; - if (eui64_iszero(go->hisid)) /* first time, try option */ - ifaceid = wo->hisid; - while (eui64_iszero(ifaceid) || - eui64_equals(ifaceid, go->ourid)) /* bad luck */ - eui64_magic(ifaceid); - go->hisid = ifaceid; - DECPTR(sizeof(ifaceid), p); - eui64_put(ifaceid, p); - } - - ho->neg_ifaceid = 1; - ho->hisid = ifaceid; - break; + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + IPV6CPDEBUG(("ipv6cp_reqci: bad CI length!")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_IFACEID: + IPV6CPDEBUG(("ipv6cp: received interface identifier ")); + + if (!ao->neg_ifaceid || + cilen != CILEN_IFACEID) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no interface identifier, or if we both have same + * identifier then NAK it with new idea. + * In particular, if we don't know his identifier, but he does, + * then accept it. + */ + eui64_get(ifaceid, p); + IPV6CPDEBUG(("(%s)", llv6_ntoa(ifaceid))); + if (eui64_iszero(ifaceid) && eui64_iszero(go->ourid)) { + orc = CONFREJ; /* Reject CI */ + break; + } + if (!eui64_iszero(wo->hisid) && + !eui64_equals(ifaceid, wo->hisid) && + eui64_iszero(go->hisid)) { + + orc = CONFNAK; + ifaceid = wo->hisid; + go->hisid = ifaceid; + DECPTR(sizeof(ifaceid), p); + eui64_put(ifaceid, p); + } else + if (eui64_iszero(ifaceid) || eui64_equals(ifaceid, go->ourid)) { + orc = CONFNAK; + if (eui64_iszero(go->hisid)) /* first time, try option */ + ifaceid = wo->hisid; + while (eui64_iszero(ifaceid) || + eui64_equals(ifaceid, go->ourid)) /* bad luck */ + eui64_magic(ifaceid); + go->hisid = ifaceid; + DECPTR(sizeof(ifaceid), p); + eui64_put(ifaceid, p); + } + + ho->neg_ifaceid = 1; + ho->hisid = ifaceid; + break; #ifdef IPV6CP_COMP - case CI_COMPRESSTYPE: - IPV6CPDEBUG(("ipv6cp: received COMPRESSTYPE ")); - if (!ao->neg_vj || - (cilen != CILEN_COMPRESS)) { - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - IPV6CPDEBUG(("(%d)", cishort)); - - if (!(cishort == IPV6CP_COMP)) { - orc = CONFREJ; - break; - } - - ho->neg_vj = 1; - ho->vj_protocol = cishort; - break; + case CI_COMPRESSTYPE: + IPV6CPDEBUG(("ipv6cp: received COMPRESSTYPE ")); + if (!ao->neg_vj || + (cilen != CILEN_COMPRESS)) { + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + IPV6CPDEBUG(("(%d)", cishort)); + + if (!(cishort == IPV6CP_COMP)) { + orc = CONFREJ; + break; + } + + ho->neg_vj = 1; + ho->vj_protocol = cishort; + break; #endif /* IPV6CP_COMP */ - default: - orc = CONFREJ; - break; - } + default: + orc = CONFREJ; + break; + } endswitch: - IPV6CPDEBUG((" (%s)\n", CODENAME(orc))); - - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree) /* Getting fed up with sending NAKs? */ - orc = CONFREJ; /* Get tough if so */ - else { - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - if (rc == CONFACK) { /* Ack'd all prior CIs? */ - rc = CONFNAK; /* Not anymore... */ - ucp = inp; /* Backup */ - } - } - } - - if (orc == CONFREJ && /* Reject this CI */ - rc != CONFREJ) { /* but no prior ones? */ - rc = CONFREJ; - ucp = inp; /* Backup */ - } - - /* Need to move CI? */ - if (ucp != cip) - MEMCPY(ucp, cip, cilen); /* Move it */ - - /* Update output pointer */ - INCPTR(cilen, ucp); + IPV6CPDEBUG((" (%s)\n", CODENAME(orc))); + + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) /* but prior CI wasnt? */ + continue; /* Don't send this one */ + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree) /* Getting fed up with sending NAKs? */ + orc = CONFREJ; /* Get tough if so */ + else { + if (rc == CONFREJ) /* Rejecting prior CI? */ + continue; /* Don't send this one */ + if (rc == CONFACK) { /* Ack'd all prior CIs? */ + rc = CONFNAK; /* Not anymore... */ + ucp = inp; /* Backup */ + } + } + } + + if (orc == CONFREJ && /* Reject this CI */ + rc != CONFREJ) { /* but no prior ones? */ + rc = CONFREJ; + ucp = inp; /* Backup */ + } + + /* Need to move CI? */ + if (ucp != cip) + MEMCPY(ucp, cip, cilen); /* Move it */ + + /* Update output pointer */ + INCPTR(cilen, ucp); } /* @@ -1044,20 +1044,20 @@ endswitch: * option safely. */ if (rc != CONFREJ && !ho->neg_ifaceid && - wo->req_ifaceid && !reject_if_disagree) { - if (rc == CONFACK) { - rc = CONFNAK; - ucp = inp; /* reset pointer */ - wo->req_ifaceid = 0; /* don't ask again */ - } - PUTCHAR(CI_IFACEID, ucp); - PUTCHAR(CILEN_IFACEID, ucp); - eui64_put(wo->hisid, ucp); + wo->req_ifaceid && !reject_if_disagree) { + if (rc == CONFACK) { + rc = CONFNAK; + ucp = inp; /* reset pointer */ + wo->req_ifaceid = 0; /* don't ask again */ + } + PUTCHAR(CI_IFACEID, ucp); + PUTCHAR(CILEN_IFACEID, ucp); + eui64_put(wo->hisid, ucp); } - *len = ucp - inp; /* Compute output length */ + *len = ucp - inp; /* Compute output length */ IPV6CPDEBUG(("ipv6cp: returning Configure-%s", CODENAME(rc))); - return (rc); /* Return final code */ + return (rc); /* Return final code */ } #if PPP_OPTIONS @@ -1069,7 +1069,7 @@ static void ipv6_check_options() { ipv6cp_options *wo = &ipv6cp_wantoptions[0]; if (!ipv6cp_protent.enabled_flag) - return; + return; /* * Persistent link-local id is only used when user has not explicitly @@ -1077,42 +1077,42 @@ static void ipv6_check_options() { */ if ((wo->use_persistent) && (!wo->opt_local) && (!wo->opt_remote)) { - /* - * On systems where there are no Ethernet interfaces used, there - * may be other ways to obtain a persistent id. Right now, it - * will fall back to using magic [see eui64_magic] below when - * an EUI-48 from MAC address can't be obtained. Other possibilities - * include obtaining EEPROM serial numbers, or some other unique - * yet persistent number. On Sparc platforms, this is possible, - * but too bad there's no standards yet for x86 machines. - */ - if (ether_to_eui64(&wo->ourid)) { - wo->opt_local = 1; - } + /* + * On systems where there are no Ethernet interfaces used, there + * may be other ways to obtain a persistent id. Right now, it + * will fall back to using magic [see eui64_magic] below when + * an EUI-48 from MAC address can't be obtained. Other possibilities + * include obtaining EEPROM serial numbers, or some other unique + * yet persistent number. On Sparc platforms, this is possible, + * but too bad there's no standards yet for x86 machines. + */ + if (ether_to_eui64(&wo->ourid)) { + wo->opt_local = 1; + } + } + + if (!wo->opt_local) { /* init interface identifier */ + if (wo->use_ip && eui64_iszero(wo->ourid)) { + eui64_setlo32(wo->ourid, lwip_ntohl(ipcp_wantoptions[0].ouraddr)); + if (!eui64_iszero(wo->ourid)) + wo->opt_local = 1; } - if (!wo->opt_local) { /* init interface identifier */ - if (wo->use_ip && eui64_iszero(wo->ourid)) { - eui64_setlo32(wo->ourid, lwip_ntohl(ipcp_wantoptions[0].ouraddr)); - if (!eui64_iszero(wo->ourid)) - wo->opt_local = 1; - } - - while (eui64_iszero(wo->ourid)) - eui64_magic(wo->ourid); + while (eui64_iszero(wo->ourid)) + eui64_magic(wo->ourid); } if (!wo->opt_remote) { - if (wo->use_ip && eui64_iszero(wo->hisid)) { - eui64_setlo32(wo->hisid, lwip_ntohl(ipcp_wantoptions[0].hisaddr)); - if (!eui64_iszero(wo->hisid)) - wo->opt_remote = 1; - } + if (wo->use_ip && eui64_iszero(wo->hisid)) { + eui64_setlo32(wo->hisid, lwip_ntohl(ipcp_wantoptions[0].hisaddr)); + if (!eui64_iszero(wo->hisid)) + wo->opt_remote = 1; + } } if (demand && (eui64_iszero(wo->ourid) || eui64_iszero(wo->hisid))) { - option_error("local/remote LL address required for demand-dialling\n"); - exit(1); + option_error("local/remote LL address required for demand-dialling\n"); + exit(1); } } #endif /* PPP_OPTIONS */ @@ -1126,13 +1126,13 @@ static int ipv6_demand_conf(int u) { ipv6cp_options *wo = &ipv6cp_wantoptions[u]; if (!sif6up(u)) - return 0; + return 0; if (!sif6addr(u, wo->ourid, wo->hisid)) - return 0; + return 0; if (!sifnpmode(u, PPP_IPV6, NPMODE_QUEUE)) - return 0; + return 0; ppp_notice("ipv6_demand_conf"); ppp_notice("local LL address %s", llv6_ntoa(wo->ourid)); @@ -1160,26 +1160,26 @@ static void ipv6cp_up(fsm *f) { * We must have a non-zero LL address for both ends of the link. */ if (!ho->neg_ifaceid) - ho->hisid = wo->hisid; + ho->hisid = wo->hisid; #if 0 /* UNUSED */ if(!no_ifaceid_neg) { #endif /* UNUSED */ - if (eui64_iszero(ho->hisid)) { - ppp_error("Could not determine remote LL address"); - ipv6cp_close(f->pcb, "Could not determine remote LL address"); - return; - } - if (eui64_iszero(go->ourid)) { - ppp_error("Could not determine local LL address"); - ipv6cp_close(f->pcb, "Could not determine local LL address"); - return; - } - if (eui64_equals(go->ourid, ho->hisid)) { - ppp_error("local and remote LL addresses are equal"); - ipv6cp_close(f->pcb, "local and remote LL addresses are equal"); - return; - } + if (eui64_iszero(ho->hisid)) { + ppp_error("Could not determine remote LL address"); + ipv6cp_close(f->pcb, "Could not determine remote LL address"); + return; + } + if (eui64_iszero(go->ourid)) { + ppp_error("Could not determine local LL address"); + ipv6cp_close(f->pcb, "Could not determine local LL address"); + return; + } + if (eui64_equals(go->ourid, ho->hisid)) { + ppp_error("local and remote LL addresses are equal"); + ipv6cp_close(f->pcb, "local and remote LL addresses are equal"); + return; + } #if 0 /* UNUSED */ } #endif /* UNUSED */ @@ -1200,52 +1200,52 @@ static void ipv6cp_up(fsm *f) { * interface to pass IPv6 packets. */ if (demand) { - if (! eui64_equals(go->ourid, wo->ourid) || - ! eui64_equals(ho->hisid, wo->hisid)) { - if (! eui64_equals(go->ourid, wo->ourid)) - warn("Local LL address changed to %s", - llv6_ntoa(go->ourid)); - if (! eui64_equals(ho->hisid, wo->hisid)) - warn("Remote LL address changed to %s", - llv6_ntoa(ho->hisid)); - ipv6cp_clear_addrs(f->pcb, go->ourid, ho->hisid); - - /* Set the interface to the new addresses */ - if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { - if (debug) - warn("sif6addr failed"); - ipv6cp_close(f->unit, "Interface configuration failed"); - return; - } - - } - demand_rexmit(PPP_IPV6); - sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); + if (! eui64_equals(go->ourid, wo->ourid) || + ! eui64_equals(ho->hisid, wo->hisid)) { + if (! eui64_equals(go->ourid, wo->ourid)) + warn("Local LL address changed to %s", + llv6_ntoa(go->ourid)); + if (! eui64_equals(ho->hisid, wo->hisid)) + warn("Remote LL address changed to %s", + llv6_ntoa(ho->hisid)); + ipv6cp_clear_addrs(f->pcb, go->ourid, ho->hisid); + + /* Set the interface to the new addresses */ + if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { + if (debug) + warn("sif6addr failed"); + ipv6cp_close(f->unit, "Interface configuration failed"); + return; + } + + } + demand_rexmit(PPP_IPV6); + sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); } else #endif /* DEMAND_SUPPORT */ { - /* - * Set LL addresses - */ - if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { - PPPDEBUG(LOG_DEBUG, ("sif6addr failed")); - ipv6cp_close(f->pcb, "Interface configuration failed"); - return; - } - - /* bring the interface up for IPv6 */ - if (!sif6up(f->pcb)) { - PPPDEBUG(LOG_DEBUG, ("sif6up failed (IPV6)")); - ipv6cp_close(f->pcb, "Interface configuration failed"); - return; - } + /* + * Set LL addresses + */ + if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { + PPPDEBUG(LOG_DEBUG, ("sif6addr failed")); + ipv6cp_close(f->pcb, "Interface configuration failed"); + return; + } + + /* bring the interface up for IPv6 */ + if (!sif6up(f->pcb)) { + PPPDEBUG(LOG_DEBUG, ("sif6up failed (IPV6)")); + ipv6cp_close(f->pcb, "Interface configuration failed"); + return; + } #if DEMAND_SUPPORT - sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS); + sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS); #endif /* DEMAND_SUPPORT */ - ppp_notice("local LL address %s", llv6_ntoa(go->ourid)); - ppp_notice("remote LL address %s", llv6_ntoa(ho->hisid)); + ppp_notice("local LL address %s", llv6_ntoa(go->ourid)); + ppp_notice("remote LL address %s", llv6_ntoa(ho->hisid)); } np_up(f->pcb, PPP_IPV6); @@ -1254,11 +1254,11 @@ static void ipv6cp_up(fsm *f) { #if 0 /* UNUSED */ /* * Execute the ipv6-up script, like this: - * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL + * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL */ if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) { - ipv6cp_script_state = s_up; - ipv6cp_script(_PATH_IPV6UP); + ipv6cp_script_state = s_up; + ipv6cp_script(_PATH_IPV6UP); } #endif /* UNUSED */ } @@ -1280,8 +1280,8 @@ static void ipv6cp_down(fsm *f) { update_link_stats(f->unit); #endif /* PPP_STATS_SUPPORT */ if (pcb->ipv6cp_is_up) { - pcb->ipv6cp_is_up = 0; - np_down(f->pcb, PPP_IPV6); + pcb->ipv6cp_is_up = 0; + np_down(f->pcb, PPP_IPV6); } #ifdef IPV6CP_COMP sif6comp(f->unit, 0); @@ -1293,24 +1293,24 @@ static void ipv6cp_down(fsm *f) { * to queue up outgoing packets (for now). */ if (demand) { - sifnpmode(f->pcb, PPP_IPV6, NPMODE_QUEUE); + sifnpmode(f->pcb, PPP_IPV6, NPMODE_QUEUE); } else #endif /* DEMAND_SUPPORT */ { #if DEMAND_SUPPORT - sifnpmode(f->pcb, PPP_IPV6, NPMODE_DROP); + sifnpmode(f->pcb, PPP_IPV6, NPMODE_DROP); #endif /* DEMAND_SUPPORT */ - ipv6cp_clear_addrs(f->pcb, - go->ourid, - ho->hisid); - sif6down(f->pcb); + ipv6cp_clear_addrs(f->pcb, + go->ourid, + ho->hisid); + sif6down(f->pcb); } #if 0 /* UNUSED */ /* Execute the ipv6-down script */ if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) { - ipv6cp_script_state = s_down; - ipv6cp_script(_PATH_IPV6DOWN); + ipv6cp_script_state = s_down; + ipv6cp_script(_PATH_IPV6DOWN); } #endif /* UNUSED */ } @@ -1345,17 +1345,17 @@ ipv6cp_script_done(arg) ipv6cp_script_pid = 0; switch (ipv6cp_script_state) { case s_up: - if (ipv6cp_fsm[0].state != PPP_FSM_OPENED) { - ipv6cp_script_state = s_down; - ipv6cp_script(_PATH_IPV6DOWN); - } - break; + if (ipv6cp_fsm[0].state != PPP_FSM_OPENED) { + ipv6cp_script_state = s_down; + ipv6cp_script(_PATH_IPV6DOWN); + } + break; case s_down: - if (ipv6cp_fsm[0].state == PPP_FSM_OPENED) { - ipv6cp_script_state = s_up; - ipv6cp_script(_PATH_IPV6UP); - } - break; + if (ipv6cp_fsm[0].state == PPP_FSM_OPENED) { + ipv6cp_script_state = s_up; + ipv6cp_script(_PATH_IPV6UP); + } + break; } } @@ -1385,7 +1385,7 @@ ipv6cp_script(script) argv[7] = NULL; ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done, - NULL, 0); + NULL, 0); } #endif /* UNUSED */ @@ -1399,7 +1399,7 @@ static const char* const ipv6cp_codenames[] = { }; static int ipv6cp_printpkt(const u_char *p, int plen, - void (*printer)(void *, const char *, ...), void *arg) { + void (*printer)(void *, const char *, ...), void *arg) { int code, id, len, olen; const u_char *pstart, *optend; #ifdef IPV6CP_COMP @@ -1408,18 +1408,18 @@ static int ipv6cp_printpkt(const u_char *p, int plen, eui64_t ifaceid; if (plen < HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(ipv6cp_codenames)) - printer(arg, " %s", ipv6cp_codenames[code-1]); + printer(arg, " %s", ipv6cp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { @@ -1427,63 +1427,63 @@ static int ipv6cp_printpkt(const u_char *p, int plen, case CONFACK: case CONFNAK: case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { #ifdef IPV6CP_COMP - case CI_COMPRESSTYPE: - if (olen >= CILEN_COMPRESS) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "compress "); - printer(arg, "0x%x", cishort); - } - break; + case CI_COMPRESSTYPE: + if (olen >= CILEN_COMPRESS) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "compress "); + printer(arg, "0x%x", cishort); + } + break; #endif /* IPV6CP_COMP */ - case CI_IFACEID: - if (olen == CILEN_IFACEID) { - p += 2; - eui64_get(ifaceid, p); - printer(arg, "addr %s", llv6_ntoa(ifaceid)); - } - break; - default: - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; + case CI_IFACEID: + if (olen == CILEN_IFACEID) { + p += 2; + eui64_get(ifaceid, p); + printer(arg, "addr %s", llv6_ntoa(ifaceid)); + } + break; + default: + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } return p - pstart; @@ -1496,19 +1496,19 @@ static int ipv6cp_printpkt(const u_char *p, int plen, * We don't bring the link up for IP fragments or for TCP FIN packets * with no data. */ -#define IP6_HDRLEN 40 /* bytes */ -#define IP6_NHDR_FRAG 44 /* fragment IPv6 header */ -#define TCP_HDRLEN 20 -#define TH_FIN 0x01 +#define IP6_HDRLEN 40 /* bytes */ +#define IP6_NHDR_FRAG 44 /* fragment IPv6 header */ +#define TCP_HDRLEN 20 +#define TH_FIN 0x01 /* * We use these macros because the IP header may be at an odd address, * and some compilers might use word loads to get th_off or ip_hl. */ -#define get_ip6nh(x) (((unsigned char *)(x))[6]) -#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) -#define get_tcpflags(x) (((unsigned char *)(x))[13]) +#define get_ip6nh(x) (((unsigned char *)(x))[6]) +#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) +#define get_tcpflags(x) (((unsigned char *)(x))[13]) static int ipv6_active_pkt(u_char *pkt, int len) { u_char *tcp; @@ -1516,16 +1516,16 @@ static int ipv6_active_pkt(u_char *pkt, int len) { len -= PPP_HDRLEN; pkt += PPP_HDRLEN; if (len < IP6_HDRLEN) - return 0; + return 0; if (get_ip6nh(pkt) == IP6_NHDR_FRAG) - return 0; + return 0; if (get_ip6nh(pkt) != IPPROTO_TCP) - return 1; + return 1; if (len < IP6_HDRLEN + TCP_HDRLEN) - return 0; + return 0; tcp = pkt + IP6_HDRLEN; if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == IP6_HDRLEN + get_tcpoff(tcp) * 4) - return 0; + return 0; return 1; } #endif /* DEMAND_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/lcp.c b/components/net/lwip-2.0.2/src/netif/ppp/lcp.c index 90ed183b75..040135637c 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/lcp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/lcp.c @@ -68,7 +68,7 @@ * configure-requests. We do this by delaying the fsm_lowerup call. */ /* steal a bit in fsm flags word */ -#define DELAYED_UP 0x80 +#define DELAYED_UP 0x80 static void lcp_delayed_up(void *arg); @@ -76,8 +76,8 @@ static void lcp_delayed_up(void *arg); * LCP-related command-line options. */ #if 0 /* UNUSED */ -int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ -int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ +int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ +int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ #endif /* UNUSED */ #if 0 /* UNUSED */ @@ -88,10 +88,10 @@ static u_int lcp_echo_fails = LCP_MAXECHOFAILS; /* Tolerance to unanswer #if 0 /* UNUSED */ #if PPP_LCP_ADAPTIVE -bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */ +bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */ #endif -bool lax_recv = 0; /* accept control chars in asyncmap */ -bool noendpoint = 0; /* don't send/accept endpoint discriminator */ +bool lax_recv = 0; /* accept control chars in asyncmap */ +bool noendpoint = 0; /* don't send/accept endpoint discriminator */ #endif /* UNUSED */ #if PPP_OPTIONS @@ -101,7 +101,7 @@ static int noopt (char **); #ifdef HAVE_MULTILINK static int setendpoint (char **); static void printendpoint (option_t *, void (*)(void *, char *, ...), - void *); + void *); #endif /* HAVE_MULTILINK */ #if PPP_OPTIONS @@ -215,17 +215,17 @@ static option_t lcp_option_list[] = { /* * Callbacks for fsm code. (CI = Configuration Information) */ -static void lcp_resetci(fsm *f); /* Reset our CI */ -static int lcp_cilen(fsm *f); /* Return length of our CI */ +static void lcp_resetci(fsm *f); /* Reset our CI */ +static int lcp_cilen(fsm *f); /* Return length of our CI */ static void lcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI to pkt */ static int lcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject); /* Peer nak'd our CI */ static int lcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree); /* Rcv peer CI */ -static void lcp_up(fsm *f); /* We're UP */ -static void lcp_down(fsm *f); /* We're DOWN */ -static void lcp_starting (fsm *); /* We need lower layer up */ -static void lcp_finished (fsm *); /* We need lower layer down */ +static void lcp_up(fsm *f); /* We're UP */ +static void lcp_down(fsm *f); /* We're DOWN */ +static void lcp_starting (fsm *); /* We need lower layer up */ +static void lcp_finished (fsm *); /* We need lower layer down */ static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len); static void lcp_rprotrej(fsm *f, u_char *inp, int len); @@ -241,22 +241,22 @@ static void LcpSendEchoRequest(fsm *f); static void LcpLinkFailure(fsm *f); static void LcpEchoCheck(fsm *f); -static const fsm_callbacks lcp_callbacks = { /* LCP callback routines */ - lcp_resetci, /* Reset our Configuration Information */ - lcp_cilen, /* Length of our Configuration Information */ - lcp_addci, /* Add our Configuration Information */ - lcp_ackci, /* ACK our Configuration Information */ - lcp_nakci, /* NAK our Configuration Information */ - lcp_rejci, /* Reject our Configuration Information */ - lcp_reqci, /* Request peer's Configuration Information */ - lcp_up, /* Called when fsm reaches OPENED state */ - lcp_down, /* Called when fsm leaves OPENED state */ - lcp_starting, /* Called when we want the lower layer up */ - lcp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - lcp_extcode, /* Called to handle LCP-specific codes */ - "LCP" /* String name of protocol */ +static const fsm_callbacks lcp_callbacks = { /* LCP callback routines */ + lcp_resetci, /* Reset our Configuration Information */ + lcp_cilen, /* Length of our Configuration Information */ + lcp_addci, /* Add our Configuration Information */ + lcp_ackci, /* ACK our Configuration Information */ + lcp_nakci, /* NAK our Configuration Information */ + lcp_rejci, /* Reject our Configuration Information */ + lcp_reqci, /* Request peer's Configuration Information */ + lcp_up, /* Called when fsm reaches OPENED state */ + lcp_down, /* Called when fsm leaves OPENED state */ + lcp_starting, /* Called when we want the lower layer up */ + lcp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + lcp_extcode, /* Called to handle LCP-specific codes */ + "LCP" /* String name of protocol */ }; /* @@ -269,7 +269,7 @@ static void lcp_input(ppp_pcb *pcb, u_char *p, int len); static void lcp_protrej(ppp_pcb *pcb); #if PRINTPKT_SUPPORT static int lcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ const struct protent lcp_protent = { @@ -304,20 +304,20 @@ const struct protent lcp_protent = { /* * Length of each type of configuration option (in octets) */ -#define CILEN_VOID 2 -#define CILEN_CHAR 3 -#define CILEN_SHORT 4 /* CILEN_VOID + 2 */ +#define CILEN_VOID 2 +#define CILEN_CHAR 3 +#define CILEN_SHORT 4 /* CILEN_VOID + 2 */ #if CHAP_SUPPORT -#define CILEN_CHAP 5 /* CILEN_VOID + 2 + 1 */ +#define CILEN_CHAP 5 /* CILEN_VOID + 2 + 1 */ #endif /* CHAP_SUPPORT */ -#define CILEN_LONG 6 /* CILEN_VOID + 4 */ +#define CILEN_LONG 6 /* CILEN_VOID + 4 */ #if LQR_SUPPORT -#define CILEN_LQR 8 /* CILEN_VOID + 2 + 4 */ +#define CILEN_LQR 8 /* CILEN_VOID + 2 + 4 */ #endif /* LQR_SUPPORT */ -#define CILEN_CBCP 3 +#define CILEN_CBCP 3 -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") #if PPP_OPTIONS /* @@ -340,8 +340,8 @@ setendpoint(argv) char **argv; { if (str_to_epdisc(&lcp_wantoptions[0].endpoint, *argv)) { - lcp_wantoptions[0].neg_endpoint = 1; - return 1; + lcp_wantoptions[0].neg_endpoint = 1; + return 1; } option_error("Can't parse '%s' as an endpoint discriminator", *argv); return 0; @@ -353,7 +353,7 @@ printendpoint(opt, printer, arg) void (*printer) (void *, char *, ...); void *arg; { - printer(arg, "%s", epdisc_to_str(&lcp_wantoptions[0].endpoint)); + printer(arg, "%s", epdisc_to_str(&lcp_wantoptions[0].endpoint)); } #endif /* HAVE_MULTILINK */ @@ -409,9 +409,9 @@ void lcp_open(ppp_pcb *pcb) { f->flags &= ~(OPT_PASSIVE | OPT_SILENT); if (wo->passive) - f->flags |= OPT_PASSIVE; + f->flags |= OPT_PASSIVE; if (wo->silent) - f->flags |= OPT_SILENT; + f->flags |= OPT_SILENT; fsm_open(f); } @@ -428,25 +428,25 @@ void lcp_close(ppp_pcb *pcb, const char *reason) { && pcb->phase != PPP_PHASE_MASTER #endif /* HAVE_MULTILINK */ ) - new_phase(pcb, PPP_PHASE_TERMINATE); + new_phase(pcb, PPP_PHASE_TERMINATE); if (f->flags & DELAYED_UP) { - UNTIMEOUT(lcp_delayed_up, f); - f->state = PPP_FSM_STOPPED; + UNTIMEOUT(lcp_delayed_up, f); + f->state = PPP_FSM_STOPPED; } oldstate = f->state; fsm_close(f, reason); if (oldstate == PPP_FSM_STOPPED && (f->flags & (OPT_PASSIVE|OPT_SILENT|DELAYED_UP))) { - /* - * This action is not strictly according to the FSM in RFC1548, - * but it does mean that the program terminates if you do a - * lcp_close() when a connection hasn't been established - * because we are in passive/silent mode or because we have - * delayed the fsm_lowerup() call and it hasn't happened yet. - */ - f->flags &= ~DELAYED_UP; - lcp_finished(f); + /* + * This action is not strictly according to the FSM in RFC1548, + * but it does mean that the program terminates if you do a + * lcp_close() when a connection hasn't been established + * because we are in passive/silent mode or because we have + * delayed the fsm_lowerup() call and it hasn't happened yet. + */ + f->flags &= ~DELAYED_UP; + lcp_finished(f); } } @@ -463,16 +463,16 @@ void lcp_lowerup(ppp_pcb *pcb) { * if we are going to ask for A/C and protocol compression. */ if (ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0) < 0 - || ppp_recv_config(pcb, PPP_MRU, (pcb->settings.lax_recv? 0: 0xffffffff), - wo->neg_pcompression, wo->neg_accompression) < 0) - return; + || ppp_recv_config(pcb, PPP_MRU, (pcb->settings.lax_recv? 0: 0xffffffff), + wo->neg_pcompression, wo->neg_accompression) < 0) + return; pcb->peer_mru = PPP_MRU; if (pcb->settings.listen_time != 0) { - f->flags |= DELAYED_UP; - TIMEOUTMS(lcp_delayed_up, f, pcb->settings.listen_time); + f->flags |= DELAYED_UP; + TIMEOUTMS(lcp_delayed_up, f, pcb->settings.listen_time); } else - fsm_lowerup(f); + fsm_lowerup(f); } @@ -483,10 +483,10 @@ void lcp_lowerdown(ppp_pcb *pcb) { fsm *f = &pcb->lcp_fsm; if (f->flags & DELAYED_UP) { - f->flags &= ~DELAYED_UP; - UNTIMEOUT(lcp_delayed_up, f); + f->flags &= ~DELAYED_UP; + UNTIMEOUT(lcp_delayed_up, f); } else - fsm_lowerdown(f); + fsm_lowerdown(f); } @@ -497,8 +497,8 @@ static void lcp_delayed_up(void *arg) { fsm *f = (fsm*)arg; if (f->flags & DELAYED_UP) { - f->flags &= ~DELAYED_UP; - fsm_lowerup(f); + f->flags &= ~DELAYED_UP; + fsm_lowerup(f); } } @@ -510,9 +510,9 @@ static void lcp_input(ppp_pcb *pcb, u_char *p, int len) { fsm *f = &pcb->lcp_fsm; if (f->flags & DELAYED_UP) { - f->flags &= ~DELAYED_UP; - UNTIMEOUT(lcp_delayed_up, f); - fsm_lowerup(f); + f->flags &= ~DELAYED_UP; + UNTIMEOUT(lcp_delayed_up, f); + fsm_lowerup(f); } fsm_input(f, p, len); } @@ -527,33 +527,33 @@ static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len) { switch( code ){ case PROTREJ: - lcp_rprotrej(f, inp, len); - break; - + lcp_rprotrej(f, inp, len); + break; + case ECHOREQ: - if (f->state != PPP_FSM_OPENED) - break; - magp = inp; - PUTLONG(go->magicnumber, magp); - fsm_sdata(f, ECHOREP, id, inp, len); - break; - + if (f->state != PPP_FSM_OPENED) + break; + magp = inp; + PUTLONG(go->magicnumber, magp); + fsm_sdata(f, ECHOREP, id, inp, len); + break; + case ECHOREP: - lcp_received_echo_reply(f, id, inp, len); - break; + lcp_received_echo_reply(f, id, inp, len); + break; case DISCREQ: case IDENTIF: case TIMEREM: - break; + break; default: - return 0; + return 0; } return 1; } - + /* * lcp_rprotrej - Receive an Protocol-Reject. * @@ -568,8 +568,8 @@ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { #endif /* PPP_PROTOCOLNAME */ if (len < 2) { - LCPDEBUG(("lcp_rprotrej: Rcvd short Protocol-Reject packet!")); - return; + LCPDEBUG(("lcp_rprotrej: Rcvd short Protocol-Reject packet!")); + return; } GETSHORT(prot, inp); @@ -579,8 +579,8 @@ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { * OPENED state SHOULD be silently discarded. */ if( f->state != PPP_FSM_OPENED ){ - LCPDEBUG(("Protocol-Reject discarded: LCP in state %d", f->state)); - return; + LCPDEBUG(("Protocol-Reject discarded: LCP in state %d", f->state)); + return; } #if PPP_PROTOCOLNAME @@ -591,25 +591,25 @@ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { * Upcall the proper Protocol-Reject routine. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->protocol == prot) { + if (protp->protocol == prot) { #if PPP_PROTOCOLNAME - if (pname != NULL) - ppp_dbglog("Protocol-Reject for '%s' (0x%x) received", pname, - prot); - else + if (pname != NULL) + ppp_dbglog("Protocol-Reject for '%s' (0x%x) received", pname, + prot); + else #endif /* PPP_PROTOCOLNAME */ - ppp_dbglog("Protocol-Reject for 0x%x received", prot); - (*protp->protrej)(f->pcb); - return; - } + ppp_dbglog("Protocol-Reject for 0x%x received", prot); + (*protp->protrej)(f->pcb); + return; + } #if PPP_PROTOCOLNAME if (pname != NULL) - ppp_warn("Protocol-Reject for unsupported protocol '%s' (0x%x)", pname, - prot); + ppp_warn("Protocol-Reject for unsupported protocol '%s' (0x%x)", pname, + prot); else #endif /* #if PPP_PROTOCOLNAME */ - ppp_warn("Protocol-Reject for unsupported protocol 0x%x", prot); + ppp_warn("Protocol-Reject for unsupported protocol 0x%x", prot); } @@ -641,7 +641,7 @@ void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len) { #endif fsm_sdata(f, PROTREJ, ++f->id, - p, len); + p, len); } @@ -748,15 +748,15 @@ static void lcp_resetci(fsm *f) { *go = *wo; #ifdef HAVE_MULTILINK if (!multilink) { - go->neg_mrru = 0; + go->neg_mrru = 0; #endif /* HAVE_MULTILINK */ - go->neg_ssnhf = 0; - go->neg_endpoint = 0; + go->neg_ssnhf = 0; + go->neg_endpoint = 0; #ifdef HAVE_MULTILINK } #endif /* HAVE_MULTILINK */ if (pcb->settings.noendpoint) - ao->neg_endpoint = 0; + ao->neg_endpoint = 0; pcb->peer_mru = PPP_MRU; #if 0 /* UNUSED */ auth_reset(pcb); @@ -771,60 +771,60 @@ static int lcp_cilen(fsm *f) { ppp_pcb *pcb = f->pcb; lcp_options *go = &pcb->lcp_gotoptions; -#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) +#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) #if CHAP_SUPPORT -#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) +#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) #endif /* CHAP_SUPPORT */ -#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) -#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) +#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) +#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) #if LQR_SUPPORT -#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) +#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) #endif /* LQR_SUPPORT */ -#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) +#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) /* * NB: we only ask for one of CHAP, UPAP, or EAP, even if we will * accept more than one. We prefer EAP first, then CHAP, then * PAP. */ return (LENCISHORT(go->neg_mru && go->mru != PPP_DEFMRU) + - LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + + LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + #if EAP_SUPPORT - LENCISHORT(go->neg_eap) + + LENCISHORT(go->neg_eap) + #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT /* cannot be improved, embedding a directive within macro arguments is not portable */ #if EAP_SUPPORT - LENCICHAP(!go->neg_eap && go->neg_chap) + + LENCICHAP(!go->neg_eap && go->neg_chap) + #endif /* EAP_SUPPORT */ #if !EAP_SUPPORT - LENCICHAP(go->neg_chap) + + LENCICHAP(go->neg_chap) + #endif /* !EAP_SUPPORT */ #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT /* cannot be improved, embedding a directive within macro arguments is not portable */ #if EAP_SUPPORT && CHAP_SUPPORT - LENCISHORT(!go->neg_eap && !go->neg_chap && go->neg_upap) + + LENCISHORT(!go->neg_eap && !go->neg_chap && go->neg_upap) + #endif /* EAP_SUPPORT && CHAP_SUPPORT */ #if EAP_SUPPORT && !CHAP_SUPPORT - LENCISHORT(!go->neg_eap && go->neg_upap) + + LENCISHORT(!go->neg_eap && go->neg_upap) + #endif /* EAP_SUPPORT && !CHAP_SUPPORT */ #if !EAP_SUPPORT && CHAP_SUPPORT - LENCISHORT(!go->neg_chap && go->neg_upap) + + LENCISHORT(!go->neg_chap && go->neg_upap) + #endif /* !EAP_SUPPORT && CHAP_SUPPORT */ #if !EAP_SUPPORT && !CHAP_SUPPORT - LENCISHORT(go->neg_upap) + + LENCISHORT(go->neg_upap) + #endif /* !EAP_SUPPORT && !CHAP_SUPPORT */ #endif /* PAP_SUPPORT */ #if LQR_SUPPORT - LENCILQR(go->neg_lqr) + + LENCILQR(go->neg_lqr) + #endif /* LQR_SUPPORT */ - LENCICBCP(go->neg_cbcp) + - LENCILONG(go->neg_magicnumber) + - LENCIVOID(go->neg_pcompression) + - LENCIVOID(go->neg_accompression) + + LENCICBCP(go->neg_cbcp) + + LENCILONG(go->neg_magicnumber) + + LENCIVOID(go->neg_pcompression) + + LENCIVOID(go->neg_accompression) + #ifdef HAVE_MULTILINK - LENCISHORT(go->neg_mrru) + + LENCISHORT(go->neg_mrru) + #endif /* HAVE_MULTILINK */ - LENCIVOID(go->neg_ssnhf) + - (go->neg_endpoint? CILEN_CHAR + go->endpoint.length: 0)); + LENCIVOID(go->neg_ssnhf) + + (go->neg_endpoint? CILEN_CHAR + go->endpoint.length: 0)); } @@ -838,58 +838,58 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { #define ADDCIVOID(opt, neg) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_VOID, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_VOID, ucp); \ } #define ADDCISHORT(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_SHORT, ucp); \ - PUTSHORT(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_SHORT, ucp); \ + PUTSHORT(val, ucp); \ } #if CHAP_SUPPORT #define ADDCICHAP(opt, neg, val) \ if (neg) { \ - PUTCHAR((opt), ucp); \ - PUTCHAR(CILEN_CHAP, ucp); \ - PUTSHORT(PPP_CHAP, ucp); \ - PUTCHAR((CHAP_DIGEST(val)), ucp); \ + PUTCHAR((opt), ucp); \ + PUTCHAR(CILEN_CHAP, ucp); \ + PUTSHORT(PPP_CHAP, ucp); \ + PUTCHAR((CHAP_DIGEST(val)), ucp); \ } #endif /* CHAP_SUPPORT */ #define ADDCILONG(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_LONG, ucp); \ - PUTLONG(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_LONG, ucp); \ + PUTLONG(val, ucp); \ } #if LQR_SUPPORT #define ADDCILQR(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_LQR, ucp); \ - PUTSHORT(PPP_LQR, ucp); \ - PUTLONG(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_LQR, ucp); \ + PUTSHORT(PPP_LQR, ucp); \ + PUTLONG(val, ucp); \ } #endif /* LQR_SUPPORT */ #define ADDCICHAR(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_CHAR, ucp); \ - PUTCHAR(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_CHAR, ucp); \ + PUTCHAR(val, ucp); \ } #define ADDCIENDP(opt, neg, class, val, len) \ if (neg) { \ - int i; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_CHAR + len, ucp); \ - PUTCHAR(class, ucp); \ - for (i = 0; i < len; ++i) \ - PUTCHAR(val[i], ucp); \ + int i; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_CHAR + len, ucp); \ + PUTCHAR(class, ucp); \ + for (i = 0; i < len; ++i) \ + PUTCHAR(val[i], ucp); \ } ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF, - go->asyncmap); + go->asyncmap); #if EAP_SUPPORT ADDCISHORT(CI_AUTHTYPE, go->neg_eap, PPP_EAP); #endif /* EAP_SUPPORT */ @@ -927,11 +927,11 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { #endif ADDCIVOID(CI_SSNHF, go->neg_ssnhf); ADDCIENDP(CI_EPDISC, go->neg_endpoint, go->endpoint.class_, - go->endpoint.value, go->endpoint.length); + go->endpoint.value, go->endpoint.length); if (ucp - start_ucp != *lenp) { - /* this should never happen, because peer_mtu should be 1500 */ - ppp_error("Bug in lcp_addci: wrong length"); + /* this should never happen, because peer_mtu should be 1500 */ + ppp_error("Bug in lcp_addci: wrong length"); } } @@ -941,8 +941,8 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { * This should not modify any state if the Ack is bad. * * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. + * 0 - Ack was bad. + * 1 - Ack was good. */ static int lcp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -958,112 +958,112 @@ static int lcp_ackci(fsm *f, u_char *p, int len) { */ #define ACKCIVOID(opt, neg) \ if (neg) { \ - if ((len -= CILEN_VOID) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_VOID || \ - citype != opt) \ - goto bad; \ + if ((len -= CILEN_VOID) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_VOID || \ + citype != opt) \ + goto bad; \ } #define ACKCISHORT(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_SHORT) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_SHORT || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ + if ((len -= CILEN_SHORT) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_SHORT || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ } #define ACKCICHAR(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_CHAR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAR || \ - citype != opt) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != val) \ - goto bad; \ + if ((len -= CILEN_CHAR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAR || \ + citype != opt) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != val) \ + goto bad; \ } #if CHAP_SUPPORT #define ACKCICHAP(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_CHAP) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAP || \ - citype != (opt)) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != PPP_CHAP) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != (CHAP_DIGEST(val))) \ - goto bad; \ + if ((len -= CILEN_CHAP) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAP || \ + citype != (opt)) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != PPP_CHAP) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != (CHAP_DIGEST(val))) \ + goto bad; \ } #endif /* CHAP_SUPPORT */ #define ACKCILONG(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_LONG) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_LONG || \ - citype != opt) \ - goto bad; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - goto bad; \ + if ((len -= CILEN_LONG) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_LONG || \ + citype != opt) \ + goto bad; \ + GETLONG(cilong, p); \ + if (cilong != val) \ + goto bad; \ } #if LQR_SUPPORT #define ACKCILQR(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_LQR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_LQR || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != PPP_LQR) \ - goto bad; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - goto bad; \ + if ((len -= CILEN_LQR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_LQR || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != PPP_LQR) \ + goto bad; \ + GETLONG(cilong, p); \ + if (cilong != val) \ + goto bad; \ } #endif /* LQR_SUPPORT */ #define ACKCIENDP(opt, neg, class, val, vlen) \ if (neg) { \ - int i; \ - if ((len -= CILEN_CHAR + vlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAR + vlen || \ - citype != opt) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != class) \ - goto bad; \ - for (i = 0; i < vlen; ++i) { \ - GETCHAR(cichar, p); \ - if (cichar != val[i]) \ - goto bad; \ - } \ + int i; \ + if ((len -= CILEN_CHAR + vlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAR + vlen || \ + citype != opt) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != class) \ + goto bad; \ + for (i = 0; i < vlen; ++i) { \ + GETCHAR(cichar, p); \ + if (cichar != val[i]) \ + goto bad; \ + } \ } ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF, - go->asyncmap); + go->asyncmap); #if EAP_SUPPORT ACKCISHORT(CI_AUTHTYPE, go->neg_eap, PPP_EAP); #endif /* EAP_SUPPORT */ @@ -1101,13 +1101,13 @@ static int lcp_ackci(fsm *f, u_char *p, int len) { #endif /* HAVE_MULTILINK */ ACKCIVOID(CI_SSNHF, go->neg_ssnhf); ACKCIENDP(CI_EPDISC, go->neg_endpoint, go->endpoint.class_, - go->endpoint.value, go->endpoint.length); + go->endpoint.value, go->endpoint.length); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; return (1); bad: LCPDEBUG(("lcp_acki: received bad Ack!")); @@ -1121,8 +1121,8 @@ bad: * or if LCP is in the OPENED state. * * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. + * 0 - Nak was bad. + * 1 - Nak was good. */ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; @@ -1131,8 +1131,8 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { u_char citype, cichar, *next; u_short cishort; u32_t cilong; - lcp_options no; /* options we've seen Naks for */ - lcp_options try_; /* options to request next time */ + lcp_options no; /* options we've seen Naks for */ + lcp_options try_; /* options to request next time */ int looped_back = 0; int cilen; @@ -1146,85 +1146,85 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ #define NAKCIVOID(opt, neg) \ if (go->neg && \ - len >= CILEN_VOID && \ - p[1] == CILEN_VOID && \ - p[0] == opt) { \ - len -= CILEN_VOID; \ - INCPTR(CILEN_VOID, p); \ - no.neg = 1; \ - try_.neg = 0; \ + len >= CILEN_VOID && \ + p[1] == CILEN_VOID && \ + p[0] == opt) { \ + len -= CILEN_VOID; \ + INCPTR(CILEN_VOID, p); \ + no.neg = 1; \ + try_.neg = 0; \ } #if CHAP_SUPPORT #define NAKCICHAP(opt, neg, code) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - no.neg = 1; \ - code \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + no.neg = 1; \ + code \ } #endif /* CHAP_SUPPORT */ #define NAKCICHAR(opt, neg, code) \ if (go->neg && \ - len >= CILEN_CHAR && \ - p[1] == CILEN_CHAR && \ - p[0] == opt) { \ - len -= CILEN_CHAR; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - no.neg = 1; \ - code \ + len >= CILEN_CHAR && \ + p[1] == CILEN_CHAR && \ + p[0] == opt) { \ + len -= CILEN_CHAR; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + no.neg = 1; \ + code \ } #define NAKCISHORT(opt, neg, code) \ if (go->neg && \ - len >= CILEN_SHORT && \ - p[1] == CILEN_SHORT && \ - p[0] == opt) { \ - len -= CILEN_SHORT; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ - code \ + len >= CILEN_SHORT && \ + p[1] == CILEN_SHORT && \ + p[0] == opt) { \ + len -= CILEN_SHORT; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ + code \ } #define NAKCILONG(opt, neg, code) \ if (go->neg && \ - len >= CILEN_LONG && \ - p[1] == CILEN_LONG && \ - p[0] == opt) { \ - len -= CILEN_LONG; \ - INCPTR(2, p); \ - GETLONG(cilong, p); \ - no.neg = 1; \ - code \ + len >= CILEN_LONG && \ + p[1] == CILEN_LONG && \ + p[0] == opt) { \ + len -= CILEN_LONG; \ + INCPTR(2, p); \ + GETLONG(cilong, p); \ + no.neg = 1; \ + code \ } #if LQR_SUPPORT #define NAKCILQR(opt, neg, code) \ if (go->neg && \ - len >= CILEN_LQR && \ - p[1] == CILEN_LQR && \ - p[0] == opt) { \ - len -= CILEN_LQR; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETLONG(cilong, p); \ - no.neg = 1; \ - code \ + len >= CILEN_LQR && \ + p[1] == CILEN_LQR && \ + p[0] == opt) { \ + len -= CILEN_LQR; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETLONG(cilong, p); \ + no.neg = 1; \ + code \ } #endif /* LQR_SUPPORT */ #define NAKCIENDP(opt, neg) \ if (go->neg && \ - len >= CILEN_CHAR && \ - p[0] == opt && \ - p[1] >= CILEN_CHAR && \ - p[1] <= len) { \ - len -= p[1]; \ - INCPTR(p[1], p); \ - no.neg = 1; \ - try_.neg = 0; \ + len >= CILEN_CHAR && \ + p[0] == opt && \ + p[1] >= CILEN_CHAR && \ + p[1] <= len) { \ + len -= p[1]; \ + INCPTR(p[1], p); \ + no.neg = 1; \ + try_.neg = 0; \ } /* @@ -1239,19 +1239,19 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * the limit of the default MRU we'd get if we didn't negotiate. */ if (go->neg_mru && go->mru != PPP_DEFMRU) { - NAKCISHORT(CI_MRU, neg_mru, - if (cishort <= wo->mru || cishort <= PPP_DEFMRU) - try_.mru = cishort; - ); + NAKCISHORT(CI_MRU, neg_mru, + if (cishort <= wo->mru || cishort <= PPP_DEFMRU) + try_.mru = cishort; + ); } /* * Add any characters they want to our (receive-side) asyncmap. */ if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) { - NAKCILONG(CI_ASYNCMAP, neg_asyncmap, - try_.asyncmap = go->asyncmap | cilong; - ); + NAKCILONG(CI_ASYNCMAP, neg_asyncmap, + try_.asyncmap = go->asyncmap | cilong; + ); } /* @@ -1270,125 +1270,125 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { || go->neg_eap #endif /* EAP_SUPPORT */ ) - && len >= CILEN_SHORT - && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { - cilen = p[1]; - len -= cilen; + && len >= CILEN_SHORT + && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { + cilen = p[1]; + len -= cilen; #if CHAP_SUPPORT - no.neg_chap = go->neg_chap; + no.neg_chap = go->neg_chap; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - no.neg_upap = go->neg_upap; + no.neg_upap = go->neg_upap; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - no.neg_eap = go->neg_eap; + no.neg_eap = go->neg_eap; #endif /* EAP_SUPPORT */ - INCPTR(2, p); - GETSHORT(cishort, p); + INCPTR(2, p); + GETSHORT(cishort, p); #if PAP_SUPPORT - if (cishort == PPP_PAP && cilen == CILEN_SHORT) { + if (cishort == PPP_PAP && cilen == CILEN_SHORT) { #if EAP_SUPPORT - /* If we were asking for EAP, then we need to stop that. */ - if (go->neg_eap) - try_.neg_eap = 0; - else + /* If we were asking for EAP, then we need to stop that. */ + if (go->neg_eap) + try_.neg_eap = 0; + else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - /* If we were asking for CHAP, then we need to stop that. */ - if (go->neg_chap) - try_.neg_chap = 0; - else + /* If we were asking for CHAP, then we need to stop that. */ + if (go->neg_chap) + try_.neg_chap = 0; + else #endif /* CHAP_SUPPORT */ - /* - * If we weren't asking for CHAP or EAP, then we were asking for - * PAP, in which case this Nak is bad. - */ - goto bad; - } else + /* + * If we weren't asking for CHAP or EAP, then we were asking for + * PAP, in which case this Nak is bad. + */ + goto bad; + } else #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { - GETCHAR(cichar, p); + if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { + GETCHAR(cichar, p); #if EAP_SUPPORT - /* Stop asking for EAP, if we were. */ - if (go->neg_eap) { - try_.neg_eap = 0; - /* Try to set up to use their suggestion, if possible */ - if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) - try_.chap_mdtype = CHAP_MDTYPE_D(cichar); - } else + /* Stop asking for EAP, if we were. */ + if (go->neg_eap) { + try_.neg_eap = 0; + /* Try to set up to use their suggestion, if possible */ + if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) + try_.chap_mdtype = CHAP_MDTYPE_D(cichar); + } else #endif /* EAP_SUPPORT */ - if (go->neg_chap) { - /* - * We were asking for our preferred algorithm, they must - * want something different. - */ - if (cichar != CHAP_DIGEST(go->chap_mdtype)) { - if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) { - /* Use their suggestion if we support it ... */ - try_.chap_mdtype = CHAP_MDTYPE_D(cichar); - } else { - /* ... otherwise, try our next-preferred algorithm. */ - try_.chap_mdtype &= ~(CHAP_MDTYPE(try_.chap_mdtype)); - if (try_.chap_mdtype == MDTYPE_NONE) /* out of algos */ - try_.neg_chap = 0; - } - } else { - /* - * Whoops, they Nak'd our algorithm of choice - * but then suggested it back to us. - */ - goto bad; - } - } else { - /* - * Stop asking for PAP if we were asking for it. - */ + if (go->neg_chap) { + /* + * We were asking for our preferred algorithm, they must + * want something different. + */ + if (cichar != CHAP_DIGEST(go->chap_mdtype)) { + if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) { + /* Use their suggestion if we support it ... */ + try_.chap_mdtype = CHAP_MDTYPE_D(cichar); + } else { + /* ... otherwise, try our next-preferred algorithm. */ + try_.chap_mdtype &= ~(CHAP_MDTYPE(try_.chap_mdtype)); + if (try_.chap_mdtype == MDTYPE_NONE) /* out of algos */ + try_.neg_chap = 0; + } + } else { + /* + * Whoops, they Nak'd our algorithm of choice + * but then suggested it back to us. + */ + goto bad; + } + } else { + /* + * Stop asking for PAP if we were asking for it. + */ #if PAP_SUPPORT - try_.neg_upap = 0; + try_.neg_upap = 0; #endif /* PAP_SUPPORT */ - } + } - } else + } else #endif /* CHAP_SUPPORT */ - { + { #if EAP_SUPPORT - /* - * If we were asking for EAP, and they're Conf-Naking EAP, - * well, that's just strange. Nobody should do that. - */ - if (cishort == PPP_EAP && cilen == CILEN_SHORT && go->neg_eap) - ppp_dbglog("Unexpected Conf-Nak for EAP"); - - /* - * We don't recognize what they're suggesting. - * Stop asking for what we were asking for. - */ - if (go->neg_eap) - try_.neg_eap = 0; - else + /* + * If we were asking for EAP, and they're Conf-Naking EAP, + * well, that's just strange. Nobody should do that. + */ + if (cishort == PPP_EAP && cilen == CILEN_SHORT && go->neg_eap) + ppp_dbglog("Unexpected Conf-Nak for EAP"); + + /* + * We don't recognize what they're suggesting. + * Stop asking for what we were asking for. + */ + if (go->neg_eap) + try_.neg_eap = 0; + else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - if (go->neg_chap) - try_.neg_chap = 0; - else + if (go->neg_chap) + try_.neg_chap = 0; + else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - if(1) - try_.neg_upap = 0; - else + if(1) + try_.neg_upap = 0; + else #endif /* PAP_SUPPORT */ - {} + {} - p += cilen - CILEN_SHORT; - } + p += cilen - CILEN_SHORT; + } } #if LQR_SUPPORT @@ -1398,11 +1398,11 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If they Nak the reporting period, take their value XXX ? */ NAKCILQR(CI_QUALITY, neg_lqr, - if (cishort != PPP_LQR) - try_.neg_lqr = 0; - else - try_.lqr_period = cilong; - ); + if (cishort != PPP_LQR) + try_.neg_lqr = 0; + else + try_.lqr_period = cilong; + ); #endif /* LQR_SUPPORT */ /* @@ -1417,9 +1417,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * Check for a looped-back line. */ NAKCILONG(CI_MAGICNUMBER, neg_magicnumber, - try_.magicnumber = magic(); - looped_back = 1; - ); + try_.magicnumber = magic(); + looped_back = 1; + ); /* * Peer shouldn't send Nak for protocol compression or @@ -1435,12 +1435,12 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * than the one we want. */ if (go->neg_mrru) { - NAKCISHORT(CI_MRRU, neg_mrru, - if (treat_as_reject) - try_.neg_mrru = 0; - else if (cishort <= wo->mrru) - try_.mrru = cishort; - ); + NAKCISHORT(CI_MRRU, neg_mrru, + if (treat_as_reject) + try_.neg_mrru = 0; + else if (cishort <= wo->mrru) + try_.mrru = cishort; + ); } #else /* HAVE_MULTILINK */ LWIP_UNUSED_ARG(treat_as_reject); @@ -1475,30 +1475,30 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * negotiate some option we don't support, so ignore it. */ while (len >= CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if (cilen < CILEN_VOID || (len -= cilen) < 0) - goto bad; - next = p + cilen - 2; - - switch (citype) { - case CI_MRU: - if ((go->neg_mru && go->mru != PPP_DEFMRU) - || no.neg_mru || cilen != CILEN_SHORT) - goto bad; - GETSHORT(cishort, p); - if (cishort < PPP_DEFMRU) { - try_.neg_mru = 1; - try_.mru = cishort; - } - break; - case CI_ASYNCMAP: - if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) - || no.neg_asyncmap || cilen != CILEN_LONG) - goto bad; - break; - case CI_AUTHTYPE: - if (0 + GETCHAR(citype, p); + GETCHAR(cilen, p); + if (cilen < CILEN_VOID || (len -= cilen) < 0) + goto bad; + next = p + cilen - 2; + + switch (citype) { + case CI_MRU: + if ((go->neg_mru && go->mru != PPP_DEFMRU) + || no.neg_mru || cilen != CILEN_SHORT) + goto bad; + GETSHORT(cishort, p); + if (cishort < PPP_DEFMRU) { + try_.neg_mru = 1; + try_.mru = cishort; + } + break; + case CI_ASYNCMAP: + if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + || no.neg_asyncmap || cilen != CILEN_LONG) + goto bad; + break; + case CI_AUTHTYPE: + if (0 #if CHAP_SUPPORT || go->neg_chap || no.neg_chap #endif /* CHAP_SUPPORT */ @@ -1506,51 +1506,51 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { || go->neg_upap || no.neg_upap #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - || go->neg_eap || no.neg_eap + || go->neg_eap || no.neg_eap #endif /* EAP_SUPPORT */ - ) - goto bad; - break; - case CI_MAGICNUMBER: - if (go->neg_magicnumber || no.neg_magicnumber || - cilen != CILEN_LONG) - goto bad; - break; - case CI_PCOMPRESSION: - if (go->neg_pcompression || no.neg_pcompression - || cilen != CILEN_VOID) - goto bad; - break; - case CI_ACCOMPRESSION: - if (go->neg_accompression || no.neg_accompression - || cilen != CILEN_VOID) - goto bad; - break; + ) + goto bad; + break; + case CI_MAGICNUMBER: + if (go->neg_magicnumber || no.neg_magicnumber || + cilen != CILEN_LONG) + goto bad; + break; + case CI_PCOMPRESSION: + if (go->neg_pcompression || no.neg_pcompression + || cilen != CILEN_VOID) + goto bad; + break; + case CI_ACCOMPRESSION: + if (go->neg_accompression || no.neg_accompression + || cilen != CILEN_VOID) + goto bad; + break; #if LQR_SUPPORT - case CI_QUALITY: - if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) - goto bad; - break; + case CI_QUALITY: + if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) + goto bad; + break; #endif /* LQR_SUPPORT */ #ifdef HAVE_MULTILINK - case CI_MRRU: - if (go->neg_mrru || no.neg_mrru || cilen != CILEN_SHORT) - goto bad; - break; + case CI_MRRU: + if (go->neg_mrru || no.neg_mrru || cilen != CILEN_SHORT) + goto bad; + break; #endif /* HAVE_MULTILINK */ - case CI_SSNHF: - if (go->neg_ssnhf || no.neg_ssnhf || cilen != CILEN_VOID) - goto bad; - try_.neg_ssnhf = 1; - break; - case CI_EPDISC: - if (go->neg_endpoint || no.neg_endpoint || cilen < CILEN_CHAR) - goto bad; - break; - default: - break; - } - p = next; + case CI_SSNHF: + if (go->neg_ssnhf || no.neg_ssnhf || cilen != CILEN_VOID) + goto bad; + try_.neg_ssnhf = 1; + break; + case CI_EPDISC: + if (go->neg_endpoint || no.neg_endpoint || cilen < CILEN_CHAR) + goto bad; + break; + default: + break; + } + p = next; } /* @@ -1558,15 +1558,15 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If there are any options left we ignore them. */ if (f->state != PPP_FSM_OPENED) { - if (looped_back) { - if (++try_.numloops >= pcb->settings.lcp_loopbackfail) { - ppp_notice("Serial line is looped back."); - pcb->err_code = PPPERR_LOOPBACK; - lcp_close(f->pcb, "Loopback detected"); - } - } else - try_.numloops = 0; - *go = try_; + if (looped_back) { + if (++try_.numloops >= pcb->settings.lcp_loopbackfail) { + ppp_notice("Serial line is looped back."); + pcb->err_code = PPPERR_LOOPBACK; + lcp_close(f->pcb, "Loopback detected"); + } + } else + try_.numloops = 0; + *go = try_; } return 1; @@ -1583,8 +1583,8 @@ bad: * or if LCP is in the OPENED state. * * Returns: - * 0 - Reject was bad. - * 1 - Reject was good. + * 0 - Reject was bad. + * 1 - Reject was good. */ static int lcp_rejci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -1592,7 +1592,7 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { u_char cichar; u_short cishort; u32_t cilong; - lcp_options try_; /* options to request next time */ + lcp_options try_; /* options to request next time */ try_ = *go; @@ -1603,157 +1603,157 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { */ #define REJCIVOID(opt, neg) \ if (go->neg && \ - len >= CILEN_VOID && \ - p[1] == CILEN_VOID && \ - p[0] == opt) { \ - len -= CILEN_VOID; \ - INCPTR(CILEN_VOID, p); \ - try_.neg = 0; \ + len >= CILEN_VOID && \ + p[1] == CILEN_VOID && \ + p[0] == opt) { \ + len -= CILEN_VOID; \ + INCPTR(CILEN_VOID, p); \ + try_.neg = 0; \ } #define REJCISHORT(opt, neg, val) \ if (go->neg && \ - len >= CILEN_SHORT && \ - p[1] == CILEN_SHORT && \ - p[0] == opt) { \ - len -= CILEN_SHORT; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_SHORT && \ + p[1] == CILEN_SHORT && \ + p[0] == opt) { \ + len -= CILEN_SHORT; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) \ + goto bad; \ + try_.neg = 0; \ } #if CHAP_SUPPORT && EAP_SUPPORT && PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ - try_.neg_eap = try_.neg_upap = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ + try_.neg_eap = try_.neg_upap = 0; \ } #endif /* CHAP_SUPPORT && EAP_SUPPORT && PAP_SUPPORT */ #if CHAP_SUPPORT && !EAP_SUPPORT && PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ - try_.neg_upap = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ + try_.neg_upap = 0; \ } #endif /* CHAP_SUPPORT && !EAP_SUPPORT && PAP_SUPPORT */ #if CHAP_SUPPORT && EAP_SUPPORT && !PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ - try_.neg_eap = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ + try_.neg_eap = 0; \ } #endif /* CHAP_SUPPORT && EAP_SUPPORT && !PAP_SUPPORT */ #if CHAP_SUPPORT && !EAP_SUPPORT && !PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ } #endif /* CHAP_SUPPORT && !EAP_SUPPORT && !PAP_SUPPORT */ #define REJCILONG(opt, neg, val) \ if (go->neg && \ - len >= CILEN_LONG && \ - p[1] == CILEN_LONG && \ - p[0] == opt) { \ - len -= CILEN_LONG; \ - INCPTR(2, p); \ - GETLONG(cilong, p); \ - /* Check rejected value. */ \ - if (cilong != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_LONG && \ + p[1] == CILEN_LONG && \ + p[0] == opt) { \ + len -= CILEN_LONG; \ + INCPTR(2, p); \ + GETLONG(cilong, p); \ + /* Check rejected value. */ \ + if (cilong != val) \ + goto bad; \ + try_.neg = 0; \ } #if LQR_SUPPORT #define REJCILQR(opt, neg, val) \ if (go->neg && \ - len >= CILEN_LQR && \ - p[1] == CILEN_LQR && \ - p[0] == opt) { \ - len -= CILEN_LQR; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETLONG(cilong, p); \ - /* Check rejected value. */ \ - if (cishort != PPP_LQR || cilong != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_LQR && \ + p[1] == CILEN_LQR && \ + p[0] == opt) { \ + len -= CILEN_LQR; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETLONG(cilong, p); \ + /* Check rejected value. */ \ + if (cishort != PPP_LQR || cilong != val) \ + goto bad; \ + try_.neg = 0; \ } #endif /* LQR_SUPPORT */ #define REJCICBCP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CBCP && \ - p[1] == CILEN_CBCP && \ - p[0] == opt) { \ - len -= CILEN_CBCP; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if (cichar != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_CBCP && \ + p[1] == CILEN_CBCP && \ + p[0] == opt) { \ + len -= CILEN_CBCP; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if (cichar != val) \ + goto bad; \ + try_.neg = 0; \ } #define REJCIENDP(opt, neg, class, val, vlen) \ if (go->neg && \ - len >= CILEN_CHAR + vlen && \ - p[0] == opt && \ - p[1] == CILEN_CHAR + vlen) { \ - int i; \ - len -= CILEN_CHAR + vlen; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - if (cichar != class) \ - goto bad; \ - for (i = 0; i < vlen; ++i) { \ - GETCHAR(cichar, p); \ - if (cichar != val[i]) \ - goto bad; \ - } \ - try_.neg = 0; \ + len >= CILEN_CHAR + vlen && \ + p[0] == opt && \ + p[1] == CILEN_CHAR + vlen) { \ + int i; \ + len -= CILEN_CHAR + vlen; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + if (cichar != class) \ + goto bad; \ + for (i = 0; i < vlen; ++i) { \ + GETCHAR(cichar, p); \ + if (cichar != val[i]) \ + goto bad; \ + } \ + try_.neg = 0; \ } REJCISHORT(CI_MRU, neg_mru, go->mru); @@ -1763,14 +1763,14 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { if (!go->neg_eap) { #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - REJCICHAP(CI_AUTHTYPE, neg_chap, go->chap_mdtype); - if (!go->neg_chap) { + REJCICHAP(CI_AUTHTYPE, neg_chap, go->chap_mdtype); + if (!go->neg_chap) { #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); + REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - } + } #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT } @@ -1787,18 +1787,18 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { #endif /* HAVE_MULTILINK */ REJCIVOID(CI_SSNHF, neg_ssnhf); REJCIENDP(CI_EPDISC, neg_endpoint, go->endpoint.class_, - go->endpoint.value, go->endpoint.length); + go->endpoint.value, go->endpoint.length); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; bad: @@ -1822,17 +1822,17 @@ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree) { lcp_options *go = &pcb->lcp_gotoptions; lcp_options *ho = &pcb->lcp_hisoptions; lcp_options *ao = &pcb->lcp_allowoptions; - u_char *cip, *next; /* Pointer to current and next CIs */ - int cilen, citype, cichar; /* Parsed len, type, char value */ - u_short cishort; /* Parsed short value */ - u32_t cilong; /* Parse long value */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *rejp; /* Pointer to next char in reject frame */ + u_char *cip, *next; /* Pointer to current and next CIs */ + int cilen, citype, cichar; /* Parsed len, type, char value */ + u_short cishort; /* Parsed short value */ + u32_t cilong; /* Parse long value */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *rejp; /* Pointer to next char in reject frame */ struct pbuf *nakp; /* Nak buffer */ - u_char *nakoutp; /* Pointer to next char in Nak frame */ - int l = *lenp; /* Length left */ + u_char *nakoutp; /* Pointer to next char in Nak frame */ + int l = *lenp; /* Length left */ /* * Reset all his options. @@ -1854,403 +1854,403 @@ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree) { nakoutp = (u_char*)nakp->payload; rejp = inp; while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - LCPDEBUG(("lcp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - citype = 0; - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_MRU: - if (!ao->neg_mru || /* Allow option? */ - cilen != CILEN_SHORT) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETSHORT(cishort, p); /* Parse MRU */ - - /* - * He must be able to receive at least our minimum. - * No need to check a maximum. If he sends a large number, - * we'll just ignore it. - */ - if (cishort < PPP_MINMRU) { - orc = CONFNAK; /* Nak CI */ - PUTCHAR(CI_MRU, nakoutp); - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_MINMRU, nakoutp); /* Give him a hint */ - break; - } - ho->neg_mru = 1; /* Remember he sent MRU */ - ho->mru = cishort; /* And remember value */ - break; - - case CI_ASYNCMAP: - if (!ao->neg_asyncmap || - cilen != CILEN_LONG) { - orc = CONFREJ; - break; - } - GETLONG(cilong, p); - - /* - * Asyncmap must have set at least the bits - * which are set in lcp_allowoptions[unit].asyncmap. - */ - if ((ao->asyncmap & ~cilong) != 0) { - orc = CONFNAK; - PUTCHAR(CI_ASYNCMAP, nakoutp); - PUTCHAR(CILEN_LONG, nakoutp); - PUTLONG(ao->asyncmap | cilong, nakoutp); - break; - } - ho->neg_asyncmap = 1; - ho->asyncmap = cilong; - break; - - case CI_AUTHTYPE: - if (cilen < CILEN_SHORT || - !(0 + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + LCPDEBUG(("lcp_reqci: bad CI length!")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + citype = 0; + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_MRU: + if (!ao->neg_mru || /* Allow option? */ + cilen != CILEN_SHORT) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETSHORT(cishort, p); /* Parse MRU */ + + /* + * He must be able to receive at least our minimum. + * No need to check a maximum. If he sends a large number, + * we'll just ignore it. + */ + if (cishort < PPP_MINMRU) { + orc = CONFNAK; /* Nak CI */ + PUTCHAR(CI_MRU, nakoutp); + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_MINMRU, nakoutp); /* Give him a hint */ + break; + } + ho->neg_mru = 1; /* Remember he sent MRU */ + ho->mru = cishort; /* And remember value */ + break; + + case CI_ASYNCMAP: + if (!ao->neg_asyncmap || + cilen != CILEN_LONG) { + orc = CONFREJ; + break; + } + GETLONG(cilong, p); + + /* + * Asyncmap must have set at least the bits + * which are set in lcp_allowoptions[unit].asyncmap. + */ + if ((ao->asyncmap & ~cilong) != 0) { + orc = CONFNAK; + PUTCHAR(CI_ASYNCMAP, nakoutp); + PUTCHAR(CILEN_LONG, nakoutp); + PUTLONG(ao->asyncmap | cilong, nakoutp); + break; + } + ho->neg_asyncmap = 1; + ho->asyncmap = cilong; + break; + + case CI_AUTHTYPE: + if (cilen < CILEN_SHORT || + !(0 #if PAP_SUPPORT - || ao->neg_upap + || ao->neg_upap #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - || ao->neg_chap + || ao->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || ao->neg_eap + || ao->neg_eap #endif /* EAP_SUPPORT */ - )) { - /* - * Reject the option if we're not willing to authenticate. - */ - ppp_dbglog("No auth is possible"); - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - - /* - * Authtype must be PAP, CHAP, or EAP. - * - * Note: if more than one of ao->neg_upap, ao->neg_chap, and - * ao->neg_eap are set, and the peer sends a Configure-Request - * with two or more authenticate-protocol requests, then we will - * reject the second request. - * Whether we end up doing CHAP, UPAP, or EAP depends then on - * the ordering of the CIs in the peer's Configure-Request. + )) { + /* + * Reject the option if we're not willing to authenticate. + */ + ppp_dbglog("No auth is possible"); + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + + /* + * Authtype must be PAP, CHAP, or EAP. + * + * Note: if more than one of ao->neg_upap, ao->neg_chap, and + * ao->neg_eap are set, and the peer sends a Configure-Request + * with two or more authenticate-protocol requests, then we will + * reject the second request. + * Whether we end up doing CHAP, UPAP, or EAP depends then on + * the ordering of the CIs in the peer's Configure-Request. */ #if PAP_SUPPORT - if (cishort == PPP_PAP) { - /* we've already accepted CHAP or EAP */ - if (0 + if (cishort == PPP_PAP) { + /* we've already accepted CHAP or EAP */ + if (0 #if CHAP_SUPPORT - || ho->neg_chap + || ho->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || ho->neg_eap + || ho->neg_eap #endif /* EAP_SUPPORT */ - || cilen != CILEN_SHORT) { - LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE PAP, rejecting...")); - orc = CONFREJ; - break; - } - if (!ao->neg_upap) { /* we don't want to do PAP */ - orc = CONFNAK; /* NAK it and suggest CHAP or EAP */ - PUTCHAR(CI_AUTHTYPE, nakoutp); + || cilen != CILEN_SHORT) { + LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE PAP, rejecting...")); + orc = CONFREJ; + break; + } + if (!ao->neg_upap) { /* we don't want to do PAP */ + orc = CONFNAK; /* NAK it and suggest CHAP or EAP */ + PUTCHAR(CI_AUTHTYPE, nakoutp); #if EAP_SUPPORT - if (ao->neg_eap) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_EAP, nakoutp); - } else { + if (ao->neg_eap) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_EAP, nakoutp); + } else { #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - } + } #endif /* EAP_SUPPORT */ - break; - } - ho->neg_upap = 1; - break; - } + break; + } + ho->neg_upap = 1; + break; + } #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - if (cishort == PPP_CHAP) { - /* we've already accepted PAP or EAP */ - if ( + if (cishort == PPP_CHAP) { + /* we've already accepted PAP or EAP */ + if ( #if PAP_SUPPORT - ho->neg_upap || + ho->neg_upap || #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - ho->neg_eap || + ho->neg_eap || #endif /* EAP_SUPPORT */ - cilen != CILEN_CHAP) { - LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE CHAP, rejecting...")); - orc = CONFREJ; - break; - } - if (!ao->neg_chap) { /* we don't want to do CHAP */ - orc = CONFNAK; /* NAK it and suggest EAP or PAP */ - PUTCHAR(CI_AUTHTYPE, nakoutp); - PUTCHAR(CILEN_SHORT, nakoutp); + cilen != CILEN_CHAP) { + LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE CHAP, rejecting...")); + orc = CONFREJ; + break; + } + if (!ao->neg_chap) { /* we don't want to do CHAP */ + orc = CONFNAK; /* NAK it and suggest EAP or PAP */ + PUTCHAR(CI_AUTHTYPE, nakoutp); + PUTCHAR(CILEN_SHORT, nakoutp); #if EAP_SUPPORT - if (ao->neg_eap) { - PUTSHORT(PPP_EAP, nakoutp); - } else + if (ao->neg_eap) { + PUTSHORT(PPP_EAP, nakoutp); + } else #endif /* EAP_SUPPORT */ #if PAP_SUPPORT - if(1) { - PUTSHORT(PPP_PAP, nakoutp); - } - else + if(1) { + PUTSHORT(PPP_PAP, nakoutp); + } + else #endif /* PAP_SUPPORT */ - {} - break; - } - GETCHAR(cichar, p); /* get digest type */ - if (!(CHAP_CANDIGEST(ao->chap_mdtype, cichar))) { - /* - * We can't/won't do the requested type, - * suggest something else. - */ - orc = CONFNAK; - PUTCHAR(CI_AUTHTYPE, nakoutp); - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); - break; - } - ho->chap_mdtype = CHAP_MDTYPE_D(cichar); /* save md type */ - ho->neg_chap = 1; - break; - } + {} + break; + } + GETCHAR(cichar, p); /* get digest type */ + if (!(CHAP_CANDIGEST(ao->chap_mdtype, cichar))) { + /* + * We can't/won't do the requested type, + * suggest something else. + */ + orc = CONFNAK; + PUTCHAR(CI_AUTHTYPE, nakoutp); + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + break; + } + ho->chap_mdtype = CHAP_MDTYPE_D(cichar); /* save md type */ + ho->neg_chap = 1; + break; + } #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - if (cishort == PPP_EAP) { - /* we've already accepted CHAP or PAP */ - if ( + if (cishort == PPP_EAP) { + /* we've already accepted CHAP or PAP */ + if ( #if CHAP_SUPPORT - ho->neg_chap || + ho->neg_chap || #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - ho->neg_upap || + ho->neg_upap || #endif /* PAP_SUPPORT */ - cilen != CILEN_SHORT) { - LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE EAP, rejecting...")); - orc = CONFREJ; - break; - } - if (!ao->neg_eap) { /* we don't want to do EAP */ - orc = CONFNAK; /* NAK it and suggest CHAP or PAP */ - PUTCHAR(CI_AUTHTYPE, nakoutp); + cilen != CILEN_SHORT) { + LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE EAP, rejecting...")); + orc = CONFREJ; + break; + } + if (!ao->neg_eap) { /* we don't want to do EAP */ + orc = CONFNAK; /* NAK it and suggest CHAP or PAP */ + PUTCHAR(CI_AUTHTYPE, nakoutp); #if CHAP_SUPPORT - if (ao->neg_chap) { - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); - } else + if (ao->neg_chap) { + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - if(1) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_PAP, nakoutp); - } else + if(1) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_PAP, nakoutp); + } else #endif /* PAP_SUPPORT */ - {} - break; - } - ho->neg_eap = 1; - break; - } + {} + break; + } + ho->neg_eap = 1; + break; + } #endif /* EAP_SUPPORT */ - /* - * We don't recognize the protocol they're asking for. - * Nak it with something we're willing to do. - * (At this point we know ao->neg_upap || ao->neg_chap || - * ao->neg_eap.) - */ - orc = CONFNAK; - PUTCHAR(CI_AUTHTYPE, nakoutp); + /* + * We don't recognize the protocol they're asking for. + * Nak it with something we're willing to do. + * (At this point we know ao->neg_upap || ao->neg_chap || + * ao->neg_eap.) + */ + orc = CONFNAK; + PUTCHAR(CI_AUTHTYPE, nakoutp); #if EAP_SUPPORT - if (ao->neg_eap) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_EAP, nakoutp); - } else + if (ao->neg_eap) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_EAP, nakoutp); + } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - if (ao->neg_chap) { - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); - } else + if (ao->neg_chap) { + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - if(1) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_PAP, nakoutp); - } else + if(1) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_PAP, nakoutp); + } else #endif /* PAP_SUPPORT */ - {} - break; + {} + break; #if LQR_SUPPORT - case CI_QUALITY: - if (!ao->neg_lqr || - cilen != CILEN_LQR) { - orc = CONFREJ; - break; - } - - GETSHORT(cishort, p); - GETLONG(cilong, p); - - /* - * Check the protocol and the reporting period. - * XXX When should we Nak this, and what with? - */ - if (cishort != PPP_LQR) { - orc = CONFNAK; - PUTCHAR(CI_QUALITY, nakoutp); - PUTCHAR(CILEN_LQR, nakoutp); - PUTSHORT(PPP_LQR, nakoutp); - PUTLONG(ao->lqr_period, nakoutp); - break; - } - break; + case CI_QUALITY: + if (!ao->neg_lqr || + cilen != CILEN_LQR) { + orc = CONFREJ; + break; + } + + GETSHORT(cishort, p); + GETLONG(cilong, p); + + /* + * Check the protocol and the reporting period. + * XXX When should we Nak this, and what with? + */ + if (cishort != PPP_LQR) { + orc = CONFNAK; + PUTCHAR(CI_QUALITY, nakoutp); + PUTCHAR(CILEN_LQR, nakoutp); + PUTSHORT(PPP_LQR, nakoutp); + PUTLONG(ao->lqr_period, nakoutp); + break; + } + break; #endif /* LQR_SUPPORT */ - case CI_MAGICNUMBER: - if (!(ao->neg_magicnumber || go->neg_magicnumber) || - cilen != CILEN_LONG) { - orc = CONFREJ; - break; - } - GETLONG(cilong, p); - - /* - * He must have a different magic number. - */ - if (go->neg_magicnumber && - cilong == go->magicnumber) { - cilong = magic(); /* Don't put magic() inside macro! */ - orc = CONFNAK; - PUTCHAR(CI_MAGICNUMBER, nakoutp); - PUTCHAR(CILEN_LONG, nakoutp); - PUTLONG(cilong, nakoutp); - break; - } - ho->neg_magicnumber = 1; - ho->magicnumber = cilong; - break; - - - case CI_PCOMPRESSION: - if (!ao->neg_pcompression || - cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_pcompression = 1; - break; - - case CI_ACCOMPRESSION: - if (!ao->neg_accompression || - cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_accompression = 1; - break; + case CI_MAGICNUMBER: + if (!(ao->neg_magicnumber || go->neg_magicnumber) || + cilen != CILEN_LONG) { + orc = CONFREJ; + break; + } + GETLONG(cilong, p); + + /* + * He must have a different magic number. + */ + if (go->neg_magicnumber && + cilong == go->magicnumber) { + cilong = magic(); /* Don't put magic() inside macro! */ + orc = CONFNAK; + PUTCHAR(CI_MAGICNUMBER, nakoutp); + PUTCHAR(CILEN_LONG, nakoutp); + PUTLONG(cilong, nakoutp); + break; + } + ho->neg_magicnumber = 1; + ho->magicnumber = cilong; + break; + + + case CI_PCOMPRESSION: + if (!ao->neg_pcompression || + cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_pcompression = 1; + break; + + case CI_ACCOMPRESSION: + if (!ao->neg_accompression || + cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_accompression = 1; + break; #ifdef HAVE_MULTILINK - case CI_MRRU: - if (!ao->neg_mrru - || !multilink - || cilen != CILEN_SHORT) { - orc = CONFREJ; - break; - } - - GETSHORT(cishort, p); - /* possibly should insist on a minimum/maximum MRRU here */ - ho->neg_mrru = 1; - ho->mrru = cishort; - break; + case CI_MRRU: + if (!ao->neg_mrru + || !multilink + || cilen != CILEN_SHORT) { + orc = CONFREJ; + break; + } + + GETSHORT(cishort, p); + /* possibly should insist on a minimum/maximum MRRU here */ + ho->neg_mrru = 1; + ho->mrru = cishort; + break; #endif /* HAVE_MULTILINK */ - case CI_SSNHF: - if (!ao->neg_ssnhf + case CI_SSNHF: + if (!ao->neg_ssnhf #ifdef HAVE_MULTILINK - || !multilink + || !multilink #endif /* HAVE_MULTILINK */ - || cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_ssnhf = 1; - break; - - case CI_EPDISC: - if (!ao->neg_endpoint || - cilen < CILEN_CHAR || - cilen > CILEN_CHAR + MAX_ENDP_LEN) { - orc = CONFREJ; - break; - } - GETCHAR(cichar, p); - cilen -= CILEN_CHAR; - ho->neg_endpoint = 1; - ho->endpoint.class_ = cichar; - ho->endpoint.length = cilen; - MEMCPY(ho->endpoint.value, p, cilen); - INCPTR(cilen, p); - break; - - default: - LCPDEBUG(("lcp_reqci: rcvd unknown option %d", citype)); - orc = CONFREJ; - break; - } + || cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_ssnhf = 1; + break; + + case CI_EPDISC: + if (!ao->neg_endpoint || + cilen < CILEN_CHAR || + cilen > CILEN_CHAR + MAX_ENDP_LEN) { + orc = CONFREJ; + break; + } + GETCHAR(cichar, p); + cilen -= CILEN_CHAR; + ho->neg_endpoint = 1; + ho->endpoint.class_ = cichar; + ho->endpoint.length = cilen; + MEMCPY(ho->endpoint.value, p, cilen); + INCPTR(cilen, p); + break; + + default: + LCPDEBUG(("lcp_reqci: rcvd unknown option %d", citype)); + orc = CONFREJ; + break; + } endswitch: - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree /* Getting fed up with sending NAKs? */ - && citype != CI_MAGICNUMBER) { - orc = CONFREJ; /* Get tough if so */ - } else { - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - rc = CONFNAK; - } - } - if (orc == CONFREJ) { /* Reject this CI */ - rc = CONFREJ; - if (cip != rejp) /* Need to move rejected CI? */ - MEMCPY(rejp, cip, cilen); /* Move it */ - INCPTR(cilen, rejp); /* Update output pointer */ - } + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) /* but prior CI wasnt? */ + continue; /* Don't send this one */ + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree /* Getting fed up with sending NAKs? */ + && citype != CI_MAGICNUMBER) { + orc = CONFREJ; /* Get tough if so */ + } else { + if (rc == CONFREJ) /* Rejecting prior CI? */ + continue; /* Don't send this one */ + rc = CONFNAK; + } + } + if (orc == CONFREJ) { /* Reject this CI */ + rc = CONFREJ; + if (cip != rejp) /* Need to move rejected CI? */ + MEMCPY(rejp, cip, cilen); /* Move it */ + INCPTR(cilen, rejp); /* Update output pointer */ + } } /* @@ -2262,25 +2262,25 @@ endswitch: switch (rc) { case CONFACK: - *lenp = next - inp; - break; + *lenp = next - inp; + break; case CONFNAK: - /* - * Copy the Nak'd options from the nak buffer to the caller's buffer. - */ - *lenp = nakoutp - (u_char*)nakp->payload; - MEMCPY(inp, nakp->payload, *lenp); - break; + /* + * Copy the Nak'd options from the nak buffer to the caller's buffer. + */ + *lenp = nakoutp - (u_char*)nakp->payload; + MEMCPY(inp, nakp->payload, *lenp); + break; case CONFREJ: - *lenp = rejp - inp; - break; + *lenp = rejp - inp; + break; default: - break; + break; } pbuf_free(nakp); LCPDEBUG(("lcp_reqci: returning CONF%s.", CODENAME(rc))); - return (rc); /* Return final code */ + return (rc); /* Return final code */ } @@ -2296,9 +2296,9 @@ static void lcp_up(fsm *f) { int mtu, mru; if (!go->neg_magicnumber) - go->magicnumber = 0; + go->magicnumber = 0; if (!ho->neg_magicnumber) - ho->magicnumber = 0; + ho->magicnumber = 0; /* * Set our MTU to the smaller of the MTU we wanted and @@ -2314,16 +2314,16 @@ static void lcp_up(fsm *f) { #ifdef HAVE_MULTILINK if (!(multilink && go->neg_mrru && ho->neg_mrru)) #endif /* HAVE_MULTILINK */ - netif_set_mtu(pcb, LWIP_MIN(LWIP_MIN(mtu, mru), ao->mru)); + netif_set_mtu(pcb, LWIP_MIN(LWIP_MIN(mtu, mru), ao->mru)); ppp_send_config(pcb, mtu, - (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), - ho->neg_pcompression, ho->neg_accompression); + (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), + ho->neg_pcompression, ho->neg_accompression); ppp_recv_config(pcb, mru, - (pcb->settings.lax_recv? 0: go->neg_asyncmap? go->asyncmap: 0xffffffff), - go->neg_pcompression, go->neg_accompression); + (pcb->settings.lax_recv? 0: go->neg_asyncmap? go->asyncmap: 0xffffffff), + go->neg_pcompression, go->neg_accompression); if (ho->neg_mru) - pcb->peer_mru = ho->mru; + pcb->peer_mru = ho->mru; lcp_echo_lowerup(f->pcb); /* Enable echo messages */ @@ -2346,8 +2346,8 @@ static void lcp_down(fsm *f) { ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0); ppp_recv_config(pcb, PPP_MRU, - (go->neg_asyncmap? go->asyncmap: 0xffffffff), - go->neg_pcompression, go->neg_accompression); + (go->neg_asyncmap? go->asyncmap: 0xffffffff), + go->neg_pcompression, go->neg_accompression); pcb->peer_mru = PPP_MRU; } @@ -2382,25 +2382,25 @@ static const char* const lcp_codenames[] = { }; static int lcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg) { + void (*printer) (void *, const char *, ...), void *arg) { int code, id, len, olen, i; const u_char *pstart, *optend; u_short cishort; u32_t cilong; if (plen < HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(lcp_codenames)) - printer(arg, " %s", lcp_codenames[code-1]); + printer(arg, " %s", lcp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { @@ -2408,224 +2408,224 @@ static int lcp_printpkt(const u_char *p, int plen, case CONFACK: case CONFNAK: case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { - case CI_MRU: - if (olen == CILEN_SHORT) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "mru %d", cishort); - } - break; - case CI_ASYNCMAP: - if (olen == CILEN_LONG) { - p += 2; - GETLONG(cilong, p); - printer(arg, "asyncmap 0x%x", cilong); - } - break; - case CI_AUTHTYPE: - if (olen >= CILEN_SHORT) { - p += 2; - printer(arg, "auth "); - GETSHORT(cishort, p); - switch (cishort) { + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { + case CI_MRU: + if (olen == CILEN_SHORT) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "mru %d", cishort); + } + break; + case CI_ASYNCMAP: + if (olen == CILEN_LONG) { + p += 2; + GETLONG(cilong, p); + printer(arg, "asyncmap 0x%x", cilong); + } + break; + case CI_AUTHTYPE: + if (olen >= CILEN_SHORT) { + p += 2; + printer(arg, "auth "); + GETSHORT(cishort, p); + switch (cishort) { #if PAP_SUPPORT - case PPP_PAP: - printer(arg, "pap"); - break; + case PPP_PAP: + printer(arg, "pap"); + break; #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - case PPP_CHAP: - printer(arg, "chap"); - if (p < optend) { - switch (*p) { - case CHAP_MD5: - printer(arg, " MD5"); - ++p; - break; + case PPP_CHAP: + printer(arg, "chap"); + if (p < optend) { + switch (*p) { + case CHAP_MD5: + printer(arg, " MD5"); + ++p; + break; #if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - printer(arg, " MS"); - ++p; - break; - - case CHAP_MICROSOFT_V2: - printer(arg, " MS-v2"); - ++p; - break; + case CHAP_MICROSOFT: + printer(arg, " MS"); + ++p; + break; + + case CHAP_MICROSOFT_V2: + printer(arg, " MS-v2"); + ++p; + break; #endif /* MSCHAP_SUPPORT */ - default: - break; - } - } - break; + default: + break; + } + } + break; #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - case PPP_EAP: - printer(arg, "eap"); - break; + case PPP_EAP: + printer(arg, "eap"); + break; #endif /* EAP_SUPPORT */ - default: - printer(arg, "0x%x", cishort); - } - } - break; + default: + printer(arg, "0x%x", cishort); + } + } + break; #if LQR_SUPPORT - case CI_QUALITY: - if (olen >= CILEN_SHORT) { - p += 2; - printer(arg, "quality "); - GETSHORT(cishort, p); - switch (cishort) { - case PPP_LQR: - printer(arg, "lqr"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; + case CI_QUALITY: + if (olen >= CILEN_SHORT) { + p += 2; + printer(arg, "quality "); + GETSHORT(cishort, p); + switch (cishort) { + case PPP_LQR: + printer(arg, "lqr"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; #endif /* LQR_SUPPORT */ - case CI_CALLBACK: - if (olen >= CILEN_CHAR) { - p += 2; - printer(arg, "callback "); - GETCHAR(cishort, p); - switch (cishort) { - case CBCP_OPT: - printer(arg, "CBCP"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; - case CI_MAGICNUMBER: - if (olen == CILEN_LONG) { - p += 2; - GETLONG(cilong, p); - printer(arg, "magic 0x%x", cilong); - } - break; - case CI_PCOMPRESSION: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "pcomp"); - } - break; - case CI_ACCOMPRESSION: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "accomp"); - } - break; - case CI_MRRU: - if (olen == CILEN_SHORT) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "mrru %d", cishort); - } - break; - case CI_SSNHF: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "ssnhf"); - } - break; - case CI_EPDISC: + case CI_CALLBACK: + if (olen >= CILEN_CHAR) { + p += 2; + printer(arg, "callback "); + GETCHAR(cishort, p); + switch (cishort) { + case CBCP_OPT: + printer(arg, "CBCP"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; + case CI_MAGICNUMBER: + if (olen == CILEN_LONG) { + p += 2; + GETLONG(cilong, p); + printer(arg, "magic 0x%x", cilong); + } + break; + case CI_PCOMPRESSION: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "pcomp"); + } + break; + case CI_ACCOMPRESSION: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "accomp"); + } + break; + case CI_MRRU: + if (olen == CILEN_SHORT) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "mrru %d", cishort); + } + break; + case CI_SSNHF: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "ssnhf"); + } + break; + case CI_EPDISC: #ifdef HAVE_MULTILINK - if (olen >= CILEN_CHAR) { - struct epdisc epd; - p += 2; - GETCHAR(epd.class, p); - epd.length = olen - CILEN_CHAR; - if (epd.length > MAX_ENDP_LEN) - epd.length = MAX_ENDP_LEN; - if (epd.length > 0) { - MEMCPY(epd.value, p, epd.length); - p += epd.length; - } - printer(arg, "endpoint [%s]", epdisc_to_str(&epd)); - } + if (olen >= CILEN_CHAR) { + struct epdisc epd; + p += 2; + GETCHAR(epd.class, p); + epd.length = olen - CILEN_CHAR; + if (epd.length > MAX_ENDP_LEN) + epd.length = MAX_ENDP_LEN; + if (epd.length > 0) { + MEMCPY(epd.value, p, epd.length); + p += epd.length; + } + printer(arg, "endpoint [%s]", epdisc_to_str(&epd)); + } #else - printer(arg, "endpoint"); + printer(arg, "endpoint"); #endif - break; - default: - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; + break; + default: + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; case ECHOREQ: case ECHOREP: case DISCREQ: - if (len >= 4) { - GETLONG(cilong, p); - printer(arg, " magic=0x%x", cilong); - len -= 4; - } - break; + if (len >= 4) { + GETLONG(cilong, p); + printer(arg, " magic=0x%x", cilong); + len -= 4; + } + break; case IDENTIF: case TIMEREM: - if (len >= 4) { - GETLONG(cilong, p); - printer(arg, " magic=0x%x", cilong); - len -= 4; - } - if (code == TIMEREM) { - if (len < 4) - break; - GETLONG(cilong, p); - printer(arg, " seconds=%u", cilong); - len -= 4; - } - if (len > 0) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len >= 4) { + GETLONG(cilong, p); + printer(arg, " magic=0x%x", cilong); + len -= 4; + } + if (code == TIMEREM) { + if (len < 4) + break; + GETLONG(cilong, p); + printer(arg, " seconds=%u", cilong); + len -= 4; + } + if (len > 0) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (i = 0; i < len && i < 32; ++i) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } if (i < len) { - printer(arg, " ..."); - p += len - i; + printer(arg, " ..."); + p += len - i; } return p - pstart; @@ -2639,10 +2639,10 @@ static int lcp_printpkt(const u_char *p, int plen, static void LcpLinkFailure(fsm *f) { ppp_pcb *pcb = f->pcb; if (f->state == PPP_FSM_OPENED) { - ppp_info("No response to %d echo-requests", pcb->lcp_echos_pending); + ppp_info("No response to %d echo-requests", pcb->lcp_echos_pending); ppp_notice("Serial link appears to be disconnected."); - pcb->err_code = PPPERR_PEERDEAD; - lcp_close(pcb, "Peer not responding"); + pcb->err_code = PPPERR_PEERDEAD; + lcp_close(pcb, "Peer not responding"); } } @@ -2655,13 +2655,13 @@ static void LcpEchoCheck(fsm *f) { LcpSendEchoRequest (f); if (f->state != PPP_FSM_OPENED) - return; + return; /* * Start the timer for the next interval. */ if (pcb->lcp_echo_timer_running) - ppp_warn("assertion lcp_echo_timer_running==0 failed"); + ppp_warn("assertion lcp_echo_timer_running==0 failed"); TIMEOUT (LcpEchoTimeout, f, pcb->settings.lcp_echo_interval); pcb->lcp_echo_timer_running = 1; } @@ -2691,14 +2691,14 @@ static void lcp_received_echo_reply(fsm *f, int id, u_char *inp, int len) { /* Check the magic number - don't count replies from ourselves. */ if (len < 4) { - ppp_dbglog("lcp: received short Echo-Reply, length %d", len); - return; + ppp_dbglog("lcp: received short Echo-Reply, length %d", len); + return; } GETLONG(magic_val, inp); if (go->neg_magicnumber - && magic_val == go->magicnumber) { - ppp_warn("appear to have received our own echo-reply!"); - return; + && magic_val == go->magicnumber) { + ppp_warn("appear to have received our own echo-reply!"); + return; } /* Reset the number of outstanding echo frames */ @@ -2722,7 +2722,7 @@ static void LcpSendEchoRequest(fsm *f) { if (pcb->lcp_echos_pending >= pcb->settings.lcp_echo_fails) { LcpLinkFailure(f); pcb->lcp_echos_pending = 0; - } + } } #if PPP_LCP_ADAPTIVE @@ -2731,17 +2731,17 @@ static void LcpSendEchoRequest(fsm *f) { * no traffic was received since the last one. */ if (pcb->settings.lcp_echo_adaptive) { - static unsigned int last_pkts_in = 0; + static unsigned int last_pkts_in = 0; #if PPP_STATS_SUPPORT - update_link_stats(f->unit); - link_stats_valid = 0; + update_link_stats(f->unit); + link_stats_valid = 0; #endif /* PPP_STATS_SUPPORT */ - if (link_stats.pkts_in != last_pkts_in) { - last_pkts_in = link_stats.pkts_in; - return; - } + if (link_stats.pkts_in != last_pkts_in) { + last_pkts_in = link_stats.pkts_in; + return; + } } #endif @@ -2750,10 +2750,10 @@ static void LcpSendEchoRequest(fsm *f) { */ if (f->state == PPP_FSM_OPENED) { lcp_magic = go->magicnumber; - pktp = pkt; - PUTLONG(lcp_magic, pktp); + pktp = pkt; + PUTLONG(lcp_magic, pktp); fsm_sdata(f, ECHOREQ, pcb->lcp_echo_number++, pkt, pktp - pkt); - ++pcb->lcp_echos_pending; + ++pcb->lcp_echos_pending; } } @@ -2768,7 +2768,7 @@ static void lcp_echo_lowerup(ppp_pcb *pcb) { pcb->lcp_echos_pending = 0; pcb->lcp_echo_number = 0; pcb->lcp_echo_timer_running = 0; - + /* If a timeout interval is specified then start the timer */ if (pcb->settings.lcp_echo_interval != 0) LcpEchoCheck (f); diff --git a/components/net/lwip-2.0.2/src/netif/ppp/mppe.c b/components/net/lwip-2.0.2/src/netif/ppp/mppe.c index 331039f8ed..5cab8a407e 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/mppe.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/mppe.c @@ -39,20 +39,20 @@ #define SHA1_SIGNATURE_SIZE 20 /* ppp_mppe_state.bits definitions */ -#define MPPE_BIT_A 0x80 /* Encryption table were (re)inititalized */ -#define MPPE_BIT_B 0x40 /* MPPC only (not implemented) */ -#define MPPE_BIT_C 0x20 /* MPPC only (not implemented) */ -#define MPPE_BIT_D 0x10 /* This is an encrypted frame */ +#define MPPE_BIT_A 0x80 /* Encryption table were (re)inititalized */ +#define MPPE_BIT_B 0x40 /* MPPC only (not implemented) */ +#define MPPE_BIT_C 0x20 /* MPPC only (not implemented) */ +#define MPPE_BIT_D 0x10 /* This is an encrypted frame */ -#define MPPE_BIT_FLUSHED MPPE_BIT_A -#define MPPE_BIT_ENCRYPTED MPPE_BIT_D +#define MPPE_BIT_FLUSHED MPPE_BIT_A +#define MPPE_BIT_ENCRYPTED MPPE_BIT_D #define MPPE_BITS(p) ((p)[0] & 0xf0) #define MPPE_CCOUNT(p) ((((p)[0] & 0x0f) << 8) + (p)[1]) -#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */ +#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */ -#define MPPE_OVHD 2 /* MPPE overhead/packet */ -#define SANITY_MAX 1600 /* Max bogon factor we will tolerate */ +#define MPPE_OVHD 2 /* MPPE overhead/packet */ +#define SANITY_MAX 1600 /* Max bogon factor we will tolerate */ /* * Perform the MPPE rekey algorithm, from RFC 3078, sec. 7.3. @@ -60,37 +60,37 @@ */ static void mppe_rekey(ppp_mppe_state * state, int initial_key) { - lwip_sha1_context sha1_ctx; - u8_t sha1_digest[SHA1_SIGNATURE_SIZE]; - - /* - * Key Derivation, from RFC 3078, RFC 3079. - * Equivalent to Get_Key() for MS-CHAP as described in RFC 3079. - */ - lwip_sha1_init(&sha1_ctx); - lwip_sha1_starts(&sha1_ctx); - lwip_sha1_update(&sha1_ctx, state->master_key, state->keylen); - lwip_sha1_update(&sha1_ctx, mppe_sha1_pad1, SHA1_PAD_SIZE); - lwip_sha1_update(&sha1_ctx, state->session_key, state->keylen); - lwip_sha1_update(&sha1_ctx, mppe_sha1_pad2, SHA1_PAD_SIZE); - lwip_sha1_finish(&sha1_ctx, sha1_digest); - lwip_sha1_free(&sha1_ctx); - MEMCPY(state->session_key, sha1_digest, state->keylen); - - if (!initial_key) { - lwip_arc4_init(&state->arc4); - lwip_arc4_setup(&state->arc4, sha1_digest, state->keylen); - lwip_arc4_crypt(&state->arc4, state->session_key, state->keylen); - lwip_arc4_free(&state->arc4); - } - if (state->keylen == 8) { - /* See RFC 3078 */ - state->session_key[0] = 0xd1; - state->session_key[1] = 0x26; - state->session_key[2] = 0x9e; - } - lwip_arc4_init(&state->arc4); - lwip_arc4_setup(&state->arc4, state->session_key, state->keylen); + lwip_sha1_context sha1_ctx; + u8_t sha1_digest[SHA1_SIGNATURE_SIZE]; + + /* + * Key Derivation, from RFC 3078, RFC 3079. + * Equivalent to Get_Key() for MS-CHAP as described in RFC 3079. + */ + lwip_sha1_init(&sha1_ctx); + lwip_sha1_starts(&sha1_ctx); + lwip_sha1_update(&sha1_ctx, state->master_key, state->keylen); + lwip_sha1_update(&sha1_ctx, mppe_sha1_pad1, SHA1_PAD_SIZE); + lwip_sha1_update(&sha1_ctx, state->session_key, state->keylen); + lwip_sha1_update(&sha1_ctx, mppe_sha1_pad2, SHA1_PAD_SIZE); + lwip_sha1_finish(&sha1_ctx, sha1_digest); + lwip_sha1_free(&sha1_ctx); + MEMCPY(state->session_key, sha1_digest, state->keylen); + + if (!initial_key) { + lwip_arc4_init(&state->arc4); + lwip_arc4_setup(&state->arc4, sha1_digest, state->keylen); + lwip_arc4_crypt(&state->arc4, state->session_key, state->keylen); + lwip_arc4_free(&state->arc4); + } + if (state->keylen == 8) { + /* See RFC 3078 */ + state->session_key[0] = 0xd1; + state->session_key[1] = 0x26; + state->session_key[2] = 0x9e; + } + lwip_arc4_init(&state->arc4); + lwip_arc4_setup(&state->arc4, state->session_key, state->keylen); } /* @@ -98,8 +98,8 @@ static void mppe_rekey(ppp_mppe_state * state, int initial_key) * don't have to keep multiple copies of keys. */ void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key) { - LWIP_UNUSED_ARG(pcb); - MEMCPY(state->master_key, key, MPPE_MAX_KEY_LEN); + LWIP_UNUSED_ARG(pcb); + MEMCPY(state->master_key, key, MPPE_MAX_KEY_LEN); } /* @@ -109,64 +109,64 @@ void mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) { #if PPP_DEBUG - const u8_t *debugstr = (const u8_t*)"mppe_comp_init"; - if (&pcb->mppe_decomp == state) { - debugstr = (const u8_t*)"mppe_decomp_init"; - } + const u8_t *debugstr = (const u8_t*)"mppe_comp_init"; + if (&pcb->mppe_decomp == state) { + debugstr = (const u8_t*)"mppe_decomp_init"; + } #endif /* PPP_DEBUG */ - /* Save keys. */ - MEMCPY(state->session_key, state->master_key, sizeof(state->master_key)); - - if (options & MPPE_OPT_128) - state->keylen = 16; - else if (options & MPPE_OPT_40) - state->keylen = 8; - else { - PPPDEBUG(LOG_DEBUG, ("%s[%d]: unknown key length\n", debugstr, - pcb->netif->num)); - lcp_close(pcb, "MPPE required but peer negotiation failed"); - return; - } - if (options & MPPE_OPT_STATEFUL) - state->stateful = 1; - - /* Generate the initial session key. */ - mppe_rekey(state, 1); + /* Save keys. */ + MEMCPY(state->session_key, state->master_key, sizeof(state->master_key)); + + if (options & MPPE_OPT_128) + state->keylen = 16; + else if (options & MPPE_OPT_40) + state->keylen = 8; + else { + PPPDEBUG(LOG_DEBUG, ("%s[%d]: unknown key length\n", debugstr, + pcb->netif->num)); + lcp_close(pcb, "MPPE required but peer negotiation failed"); + return; + } + if (options & MPPE_OPT_STATEFUL) + state->stateful = 1; + + /* Generate the initial session key. */ + mppe_rekey(state, 1); #if PPP_DEBUG - { - int i; - char mkey[sizeof(state->master_key) * 2 + 1]; - char skey[sizeof(state->session_key) * 2 + 1]; - - PPPDEBUG(LOG_DEBUG, ("%s[%d]: initialized with %d-bit %s mode\n", - debugstr, pcb->netif->num, (state->keylen == 16) ? 128 : 40, - (state->stateful) ? "stateful" : "stateless")); - - for (i = 0; i < (int)sizeof(state->master_key); i++) - sprintf(mkey + i * 2, "%02x", state->master_key[i]); - for (i = 0; i < (int)sizeof(state->session_key); i++) - sprintf(skey + i * 2, "%02x", state->session_key[i]); - PPPDEBUG(LOG_DEBUG, - ("%s[%d]: keys: master: %s initial session: %s\n", - debugstr, pcb->netif->num, mkey, skey)); - } + { + int i; + char mkey[sizeof(state->master_key) * 2 + 1]; + char skey[sizeof(state->session_key) * 2 + 1]; + + PPPDEBUG(LOG_DEBUG, ("%s[%d]: initialized with %d-bit %s mode\n", + debugstr, pcb->netif->num, (state->keylen == 16) ? 128 : 40, + (state->stateful) ? "stateful" : "stateless")); + + for (i = 0; i < (int)sizeof(state->master_key); i++) + sprintf(mkey + i * 2, "%02x", state->master_key[i]); + for (i = 0; i < (int)sizeof(state->session_key); i++) + sprintf(skey + i * 2, "%02x", state->session_key[i]); + PPPDEBUG(LOG_DEBUG, + ("%s[%d]: keys: master: %s initial session: %s\n", + debugstr, pcb->netif->num, mkey, skey)); + } #endif /* PPP_DEBUG */ - /* - * Initialize the coherency count. The initial value is not specified - * in RFC 3078, but we can make a reasonable assumption that it will - * start at 0. Setting it to the max here makes the comp/decomp code - * do the right thing (determined through experiment). - */ - state->ccount = MPPE_CCOUNT_SPACE - 1; - - /* - * Note that even though we have initialized the key table, we don't - * set the FLUSHED bit. This is contrary to RFC 3078, sec. 3.1. - */ - state->bits = MPPE_BIT_ENCRYPTED; + /* + * Initialize the coherency count. The initial value is not specified + * in RFC 3078, but we can make a reasonable assumption that it will + * start at 0. Setting it to the max here makes the comp/decomp code + * do the right thing (determined through experiment). + */ + state->ccount = MPPE_CCOUNT_SPACE - 1; + + /* + * Note that even though we have initialized the key table, we don't + * set the FLUSHED bit. This is contrary to RFC 3078, sec. 3.1. + */ + state->bits = MPPE_BIT_ENCRYPTED; } /* @@ -180,8 +180,8 @@ mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) */ void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state) { - LWIP_UNUSED_ARG(pcb); - state->bits |= MPPE_BIT_FLUSHED; + LWIP_UNUSED_ARG(pcb); + state->bits |= MPPE_BIT_FLUSHED; } /* @@ -192,74 +192,74 @@ void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state) err_t mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t protocol) { - struct pbuf *n, *np; - u8_t *pl; - err_t err; - - LWIP_UNUSED_ARG(pcb); - - /* TCP stack requires that we don't change the packet payload, therefore we copy - * the whole packet before encryption. - */ - np = pbuf_alloc(PBUF_RAW, MPPE_OVHD + sizeof(protocol) + (*pb)->tot_len, PBUF_POOL); - if (!np) { - return ERR_MEM; - } - - /* Hide MPPE header + protocol */ - pbuf_header(np, -(s16_t)(MPPE_OVHD + sizeof(protocol))); - - if ((err = pbuf_copy(np, *pb)) != ERR_OK) { - pbuf_free(np); - return err; - } - - /* Reveal MPPE header + protocol */ - pbuf_header(np, (s16_t)(MPPE_OVHD + sizeof(protocol))); - - *pb = np; - pl = (u8_t*)np->payload; - - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; - PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", pcb->netif->num, state->ccount)); - /* FIXME: use PUT* macros */ - pl[0] = state->ccount>>8; - pl[1] = state->ccount; - - if (!state->stateful || /* stateless mode */ - ((state->ccount & 0xff) == 0xff) || /* "flag" packet */ - (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */ - /* We must rekey */ - if (state->stateful) { - PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: rekeying\n", pcb->netif->num)); - } - mppe_rekey(state, 0); - state->bits |= MPPE_BIT_FLUSHED; - } - pl[0] |= state->bits; - state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */ - pl += MPPE_OVHD; - - /* Add protocol */ - /* FIXME: add PFC support */ - pl[0] = protocol >> 8; - pl[1] = protocol; - - /* Hide MPPE header */ - pbuf_header(np, -(s16_t)MPPE_OVHD); - - /* Encrypt packet */ - for (n = np; n != NULL; n = n->next) { - lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); - if (n->tot_len == n->len) { - break; - } - } - - /* Reveal MPPE header */ - pbuf_header(np, (s16_t)MPPE_OVHD); - - return ERR_OK; + struct pbuf *n, *np; + u8_t *pl; + err_t err; + + LWIP_UNUSED_ARG(pcb); + + /* TCP stack requires that we don't change the packet payload, therefore we copy + * the whole packet before encryption. + */ + np = pbuf_alloc(PBUF_RAW, MPPE_OVHD + sizeof(protocol) + (*pb)->tot_len, PBUF_POOL); + if (!np) { + return ERR_MEM; + } + + /* Hide MPPE header + protocol */ + pbuf_header(np, -(s16_t)(MPPE_OVHD + sizeof(protocol))); + + if ((err = pbuf_copy(np, *pb)) != ERR_OK) { + pbuf_free(np); + return err; + } + + /* Reveal MPPE header + protocol */ + pbuf_header(np, (s16_t)(MPPE_OVHD + sizeof(protocol))); + + *pb = np; + pl = (u8_t*)np->payload; + + state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; + PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", pcb->netif->num, state->ccount)); + /* FIXME: use PUT* macros */ + pl[0] = state->ccount>>8; + pl[1] = state->ccount; + + if (!state->stateful || /* stateless mode */ + ((state->ccount & 0xff) == 0xff) || /* "flag" packet */ + (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */ + /* We must rekey */ + if (state->stateful) { + PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: rekeying\n", pcb->netif->num)); + } + mppe_rekey(state, 0); + state->bits |= MPPE_BIT_FLUSHED; + } + pl[0] |= state->bits; + state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */ + pl += MPPE_OVHD; + + /* Add protocol */ + /* FIXME: add PFC support */ + pl[0] = protocol >> 8; + pl[1] = protocol; + + /* Hide MPPE header */ + pbuf_header(np, -(s16_t)MPPE_OVHD); + + /* Encrypt packet */ + for (n = np; n != NULL; n = n->next) { + lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); + if (n->tot_len == n->len) { + break; + } + } + + /* Reveal MPPE header */ + pbuf_header(np, (s16_t)MPPE_OVHD); + + return ERR_OK; } /* @@ -267,9 +267,9 @@ mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t proto */ void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state) { - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(state); - return; + LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(state); + return; } /* @@ -278,135 +278,135 @@ void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state) err_t mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb) { - struct pbuf *n0 = *pb, *n; - u8_t *pl; - u16_t ccount; - u8_t flushed; - - /* MPPE Header */ - if (n0->len < MPPE_OVHD) { - PPPDEBUG(LOG_DEBUG, - ("mppe_decompress[%d]: short pkt (%d)\n", - pcb->netif->num, n0->len)); - state->sanity_errors += 100; - goto sanity_error; - } - - pl = (u8_t*)n0->payload; - flushed = MPPE_BITS(pl) & MPPE_BIT_FLUSHED; - ccount = MPPE_CCOUNT(pl); - PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n", - pcb->netif->num, ccount)); - - /* sanity checks -- terminate with extreme prejudice */ - if (!(MPPE_BITS(pl) & MPPE_BIT_ENCRYPTED)) { - PPPDEBUG(LOG_DEBUG, - ("mppe_decompress[%d]: ENCRYPTED bit not set!\n", - pcb->netif->num)); - state->sanity_errors += 100; - goto sanity_error; - } - if (!state->stateful && !flushed) { - PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in " - "stateless mode!\n", pcb->netif->num)); - state->sanity_errors += 100; - goto sanity_error; - } - if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { - PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on " - "flag packet!\n", pcb->netif->num)); - state->sanity_errors += 100; - goto sanity_error; - } - - /* - * Check the coherency count. - */ - - if (!state->stateful) { - /* Discard late packet */ - if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE > MPPE_CCOUNT_SPACE / 2) { - state->sanity_errors++; - goto sanity_error; - } - - /* RFC 3078, sec 8.1. Rekey for every packet. */ - while (state->ccount != ccount) { - mppe_rekey(state, 0); - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; - } - } else { - /* RFC 3078, sec 8.2. */ - if (!state->discard) { - /* normal state */ - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; - if (ccount != state->ccount) { - /* - * (ccount > state->ccount) - * Packet loss detected, enter the discard state. - * Signal the peer to rekey (by sending a CCP Reset-Request). - */ - state->discard = 1; - ccp_resetrequest(pcb); - return ERR_BUF; - } - } else { - /* discard state */ - if (!flushed) { - /* ccp.c will be silent (no additional CCP Reset-Requests). */ - return ERR_BUF; - } else { - /* Rekey for every missed "flag" packet. */ - while ((ccount & ~0xff) != - (state->ccount & ~0xff)) { - mppe_rekey(state, 0); - state->ccount = - (state->ccount + - 256) % MPPE_CCOUNT_SPACE; - } - - /* reset */ - state->discard = 0; - state->ccount = ccount; - /* - * Another problem with RFC 3078 here. It implies that the - * peer need not send a Reset-Ack packet. But RFC 1962 - * requires it. Hopefully, M$ does send a Reset-Ack; even - * though it isn't required for MPPE synchronization, it is - * required to reset CCP state. - */ - } - } - if (flushed) - mppe_rekey(state, 0); - } - - /* Hide MPPE header */ - pbuf_header(n0, -(s16_t)(MPPE_OVHD)); - - /* Decrypt the packet. */ - for (n = n0; n != NULL; n = n->next) { - lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); - if (n->tot_len == n->len) { - break; - } - } - - /* good packet credit */ - state->sanity_errors >>= 1; - - return ERR_OK; + struct pbuf *n0 = *pb, *n; + u8_t *pl; + u16_t ccount; + u8_t flushed; + + /* MPPE Header */ + if (n0->len < MPPE_OVHD) { + PPPDEBUG(LOG_DEBUG, + ("mppe_decompress[%d]: short pkt (%d)\n", + pcb->netif->num, n0->len)); + state->sanity_errors += 100; + goto sanity_error; + } + + pl = (u8_t*)n0->payload; + flushed = MPPE_BITS(pl) & MPPE_BIT_FLUSHED; + ccount = MPPE_CCOUNT(pl); + PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n", + pcb->netif->num, ccount)); + + /* sanity checks -- terminate with extreme prejudice */ + if (!(MPPE_BITS(pl) & MPPE_BIT_ENCRYPTED)) { + PPPDEBUG(LOG_DEBUG, + ("mppe_decompress[%d]: ENCRYPTED bit not set!\n", + pcb->netif->num)); + state->sanity_errors += 100; + goto sanity_error; + } + if (!state->stateful && !flushed) { + PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in " + "stateless mode!\n", pcb->netif->num)); + state->sanity_errors += 100; + goto sanity_error; + } + if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { + PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on " + "flag packet!\n", pcb->netif->num)); + state->sanity_errors += 100; + goto sanity_error; + } + + /* + * Check the coherency count. + */ + + if (!state->stateful) { + /* Discard late packet */ + if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE > MPPE_CCOUNT_SPACE / 2) { + state->sanity_errors++; + goto sanity_error; + } + + /* RFC 3078, sec 8.1. Rekey for every packet. */ + while (state->ccount != ccount) { + mppe_rekey(state, 0); + state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; + } + } else { + /* RFC 3078, sec 8.2. */ + if (!state->discard) { + /* normal state */ + state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; + if (ccount != state->ccount) { + /* + * (ccount > state->ccount) + * Packet loss detected, enter the discard state. + * Signal the peer to rekey (by sending a CCP Reset-Request). + */ + state->discard = 1; + ccp_resetrequest(pcb); + return ERR_BUF; + } + } else { + /* discard state */ + if (!flushed) { + /* ccp.c will be silent (no additional CCP Reset-Requests). */ + return ERR_BUF; + } else { + /* Rekey for every missed "flag" packet. */ + while ((ccount & ~0xff) != + (state->ccount & ~0xff)) { + mppe_rekey(state, 0); + state->ccount = + (state->ccount + + 256) % MPPE_CCOUNT_SPACE; + } + + /* reset */ + state->discard = 0; + state->ccount = ccount; + /* + * Another problem with RFC 3078 here. It implies that the + * peer need not send a Reset-Ack packet. But RFC 1962 + * requires it. Hopefully, M$ does send a Reset-Ack; even + * though it isn't required for MPPE synchronization, it is + * required to reset CCP state. + */ + } + } + if (flushed) + mppe_rekey(state, 0); + } + + /* Hide MPPE header */ + pbuf_header(n0, -(s16_t)(MPPE_OVHD)); + + /* Decrypt the packet. */ + for (n = n0; n != NULL; n = n->next) { + lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); + if (n->tot_len == n->len) { + break; + } + } + + /* good packet credit */ + state->sanity_errors >>= 1; + + return ERR_OK; sanity_error: - if (state->sanity_errors >= SANITY_MAX) { - /* - * Take LCP down if the peer is sending too many bogons. - * We don't want to do this for a single or just a few - * instances since it could just be due to packet corruption. - */ - lcp_close(pcb, "Too many MPPE errors"); - } - return ERR_BUF; + if (state->sanity_errors >= SANITY_MAX) { + /* + * Take LCP down if the peer is sending too many bogons. + * We don't want to do this for a single or just a few + * instances since it could just be due to packet corruption. + */ + lcp_close(pcb, "Too many MPPE errors"); + } + return ERR_BUF; } #endif /* PPP_SUPPORT && MPPE_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/multilink.c b/components/net/lwip-2.0.2/src/netif/ppp/multilink.c index 62014e8c87..08e8130d48 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/multilink.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/multilink.c @@ -55,11 +55,11 @@ #include "netif/ppp/lcp.h" #include "netif/ppp/tdb.h" -bool endpoint_specified; /* user gave explicit endpoint discriminator */ -char *bundle_id; /* identifier for our bundle */ -char *blinks_id; /* key for the list of links */ -bool doing_multilink; /* multilink was enabled and agreed to */ -bool multilink_master; /* we own the multilink bundle */ +bool endpoint_specified; /* user gave explicit endpoint discriminator */ +char *bundle_id; /* identifier for our bundle */ +char *blinks_id; /* key for the list of links */ +bool doing_multilink; /* multilink was enabled and agreed to */ +bool multilink_master; /* we own the multilink bundle */ extern TDB_CONTEXT *pppdb; extern char db_key[]; @@ -72,43 +72,43 @@ static int get_default_epdisc (struct epdisc *); static int parse_num (char *str, const char *key, int *valp); static int owns_unit (TDB_DATA pid, int unit); -#define set_ip_epdisc(ep, addr) do { \ - ep->length = 4; \ - ep->value[0] = addr >> 24; \ - ep->value[1] = addr >> 16; \ - ep->value[2] = addr >> 8; \ - ep->value[3] = addr; \ +#define set_ip_epdisc(ep, addr) do { \ + ep->length = 4; \ + ep->value[0] = addr >> 24; \ + ep->value[1] = addr >> 16; \ + ep->value[2] = addr >> 8; \ + ep->value[3] = addr; \ } while (0) -#define LOCAL_IP_ADDR(addr) \ - (((addr) & 0xff000000) == 0x0a000000 /* 10.x.x.x */ \ - || ((addr) & 0xfff00000) == 0xac100000 /* 172.16.x.x */ \ - || ((addr) & 0xffff0000) == 0xc0a80000) /* 192.168.x.x */ +#define LOCAL_IP_ADDR(addr) \ + (((addr) & 0xff000000) == 0x0a000000 /* 10.x.x.x */ \ + || ((addr) & 0xfff00000) == 0xac100000 /* 172.16.x.x */ \ + || ((addr) & 0xffff0000) == 0xc0a80000) /* 192.168.x.x */ -#define process_exists(n) (kill((n), 0) == 0 || errno != ESRCH) +#define process_exists(n) (kill((n), 0) == 0 || errno != ESRCH) void mp_check_options() { - lcp_options *wo = &lcp_wantoptions[0]; - lcp_options *ao = &lcp_allowoptions[0]; - - doing_multilink = 0; - if (!multilink) - return; - /* if we're doing multilink, we have to negotiate MRRU */ - if (!wo->neg_mrru) { - /* mrru not specified, default to mru */ - wo->mrru = wo->mru; - wo->neg_mrru = 1; - } - ao->mrru = ao->mru; - ao->neg_mrru = 1; - - if (!wo->neg_endpoint && !noendpoint) { - /* get a default endpoint value */ - wo->neg_endpoint = get_default_epdisc(&wo->endpoint); - } + lcp_options *wo = &lcp_wantoptions[0]; + lcp_options *ao = &lcp_allowoptions[0]; + + doing_multilink = 0; + if (!multilink) + return; + /* if we're doing multilink, we have to negotiate MRRU */ + if (!wo->neg_mrru) { + /* mrru not specified, default to mru */ + wo->mrru = wo->mru; + wo->neg_mrru = 1; + } + ao->mrru = ao->mru; + ao->neg_mrru = 1; + + if (!wo->neg_endpoint && !noendpoint) { + /* get a default endpoint value */ + wo->neg_endpoint = get_default_epdisc(&wo->endpoint); + } } /* @@ -118,289 +118,289 @@ mp_check_options() int mp_join_bundle() { - lcp_options *go = &lcp_gotoptions[0]; - lcp_options *ho = &lcp_hisoptions[0]; - lcp_options *ao = &lcp_allowoptions[0]; - int unit, pppd_pid; - int l, mtu; - char *p; - TDB_DATA key, pid, rec; - - if (doing_multilink) { - /* have previously joined a bundle */ - if (!go->neg_mrru || !ho->neg_mrru) { - notice("oops, didn't get multilink on renegotiation"); - lcp_close(pcb, "multilink required"); - return 0; - } - /* XXX should check the peer_authname and ho->endpoint - are the same as previously */ - return 0; - } - - if (!go->neg_mrru || !ho->neg_mrru) { - /* not doing multilink */ - if (go->neg_mrru) - notice("oops, multilink negotiated only for receive"); - mtu = ho->neg_mru? ho->mru: PPP_MRU; - if (mtu > ao->mru) - mtu = ao->mru; - if (demand) { - /* already have a bundle */ - cfg_bundle(0, 0, 0, 0); - netif_set_mtu(pcb, mtu); - return 0; - } - make_new_bundle(0, 0, 0, 0); - set_ifunit(1); - netif_set_mtu(pcb, mtu); - return 0; - } - - doing_multilink = 1; - - /* - * Find the appropriate bundle or join a new one. - * First we make up a name for the bundle. - * The length estimate is worst-case assuming every - * character has to be quoted. - */ - l = 4 * strlen(peer_authname) + 10; - if (ho->neg_endpoint) - l += 3 * ho->endpoint.length + 8; - if (bundle_name) - l += 3 * strlen(bundle_name) + 2; - bundle_id = malloc(l); - if (bundle_id == 0) - novm("bundle identifier"); - - p = bundle_id; - p += slprintf(p, l-1, "BUNDLE=\"%q\"", peer_authname); - if (ho->neg_endpoint || bundle_name) - *p++ = '/'; - if (ho->neg_endpoint) - p += slprintf(p, bundle_id+l-p, "%s", - epdisc_to_str(&ho->endpoint)); - if (bundle_name) - p += slprintf(p, bundle_id+l-p, "/%v", bundle_name); - - /* Make the key for the list of links belonging to the bundle */ - l = p - bundle_id; - blinks_id = malloc(l + 7); - if (blinks_id == NULL) - novm("bundle links key"); - slprintf(blinks_id, l + 7, "BUNDLE_LINKS=%s", bundle_id + 7); - - /* - * For demand mode, we only need to configure the bundle - * and attach the link. - */ - mtu = LWIP_MIN(ho->mrru, ao->mru); - if (demand) { - cfg_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); - netif_set_mtu(pcb, mtu); - script_setenv("BUNDLE", bundle_id + 7, 1); - return 0; - } - - /* - * Check if the bundle ID is already in the database. - */ - unit = -1; - lock_db(); - key.dptr = bundle_id; - key.dsize = p - bundle_id; - pid = tdb_fetch(pppdb, key); - if (pid.dptr != NULL) { - /* bundle ID exists, see if the pppd record exists */ - rec = tdb_fetch(pppdb, pid); - if (rec.dptr != NULL && rec.dsize > 0) { - /* make sure the string is null-terminated */ - rec.dptr[rec.dsize-1] = 0; - /* parse the interface number */ - parse_num(rec.dptr, "IFNAME=ppp", &unit); - /* check the pid value */ - if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid) - || !process_exists(pppd_pid) - || !owns_unit(pid, unit)) - unit = -1; - free(rec.dptr); - } - free(pid.dptr); - } - - if (unit >= 0) { - /* attach to existing unit */ - if (bundle_attach(unit)) { - set_ifunit(0); - script_setenv("BUNDLE", bundle_id + 7, 0); - make_bundle_links(1); - unlock_db(); - info("Link attached to %s", ifname); - return 1; - } - /* attach failed because bundle doesn't exist */ - } - - /* we have to make a new bundle */ - make_new_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); - set_ifunit(1); - netif_set_mtu(pcb, mtu); - script_setenv("BUNDLE", bundle_id + 7, 1); - make_bundle_links(pcb); - unlock_db(); - info("New bundle %s created", ifname); - multilink_master = 1; - return 0; + lcp_options *go = &lcp_gotoptions[0]; + lcp_options *ho = &lcp_hisoptions[0]; + lcp_options *ao = &lcp_allowoptions[0]; + int unit, pppd_pid; + int l, mtu; + char *p; + TDB_DATA key, pid, rec; + + if (doing_multilink) { + /* have previously joined a bundle */ + if (!go->neg_mrru || !ho->neg_mrru) { + notice("oops, didn't get multilink on renegotiation"); + lcp_close(pcb, "multilink required"); + return 0; + } + /* XXX should check the peer_authname and ho->endpoint + are the same as previously */ + return 0; + } + + if (!go->neg_mrru || !ho->neg_mrru) { + /* not doing multilink */ + if (go->neg_mrru) + notice("oops, multilink negotiated only for receive"); + mtu = ho->neg_mru? ho->mru: PPP_MRU; + if (mtu > ao->mru) + mtu = ao->mru; + if (demand) { + /* already have a bundle */ + cfg_bundle(0, 0, 0, 0); + netif_set_mtu(pcb, mtu); + return 0; + } + make_new_bundle(0, 0, 0, 0); + set_ifunit(1); + netif_set_mtu(pcb, mtu); + return 0; + } + + doing_multilink = 1; + + /* + * Find the appropriate bundle or join a new one. + * First we make up a name for the bundle. + * The length estimate is worst-case assuming every + * character has to be quoted. + */ + l = 4 * strlen(peer_authname) + 10; + if (ho->neg_endpoint) + l += 3 * ho->endpoint.length + 8; + if (bundle_name) + l += 3 * strlen(bundle_name) + 2; + bundle_id = malloc(l); + if (bundle_id == 0) + novm("bundle identifier"); + + p = bundle_id; + p += slprintf(p, l-1, "BUNDLE=\"%q\"", peer_authname); + if (ho->neg_endpoint || bundle_name) + *p++ = '/'; + if (ho->neg_endpoint) + p += slprintf(p, bundle_id+l-p, "%s", + epdisc_to_str(&ho->endpoint)); + if (bundle_name) + p += slprintf(p, bundle_id+l-p, "/%v", bundle_name); + + /* Make the key for the list of links belonging to the bundle */ + l = p - bundle_id; + blinks_id = malloc(l + 7); + if (blinks_id == NULL) + novm("bundle links key"); + slprintf(blinks_id, l + 7, "BUNDLE_LINKS=%s", bundle_id + 7); + + /* + * For demand mode, we only need to configure the bundle + * and attach the link. + */ + mtu = LWIP_MIN(ho->mrru, ao->mru); + if (demand) { + cfg_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); + netif_set_mtu(pcb, mtu); + script_setenv("BUNDLE", bundle_id + 7, 1); + return 0; + } + + /* + * Check if the bundle ID is already in the database. + */ + unit = -1; + lock_db(); + key.dptr = bundle_id; + key.dsize = p - bundle_id; + pid = tdb_fetch(pppdb, key); + if (pid.dptr != NULL) { + /* bundle ID exists, see if the pppd record exists */ + rec = tdb_fetch(pppdb, pid); + if (rec.dptr != NULL && rec.dsize > 0) { + /* make sure the string is null-terminated */ + rec.dptr[rec.dsize-1] = 0; + /* parse the interface number */ + parse_num(rec.dptr, "IFNAME=ppp", &unit); + /* check the pid value */ + if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid) + || !process_exists(pppd_pid) + || !owns_unit(pid, unit)) + unit = -1; + free(rec.dptr); + } + free(pid.dptr); + } + + if (unit >= 0) { + /* attach to existing unit */ + if (bundle_attach(unit)) { + set_ifunit(0); + script_setenv("BUNDLE", bundle_id + 7, 0); + make_bundle_links(1); + unlock_db(); + info("Link attached to %s", ifname); + return 1; + } + /* attach failed because bundle doesn't exist */ + } + + /* we have to make a new bundle */ + make_new_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); + set_ifunit(1); + netif_set_mtu(pcb, mtu); + script_setenv("BUNDLE", bundle_id + 7, 1); + make_bundle_links(pcb); + unlock_db(); + info("New bundle %s created", ifname); + multilink_master = 1; + return 0; } void mp_exit_bundle() { - lock_db(); - remove_bundle_link(); - unlock_db(); + lock_db(); + remove_bundle_link(); + unlock_db(); } static void sendhup(char *str) { - int pid; + int pid; - if (parse_num(str, "PPPD_PID=", &pid) && pid != getpid()) { - if (debug) - dbglog("sending SIGHUP to process %d", pid); - kill(pid, SIGHUP); - } + if (parse_num(str, "PPPD_PID=", &pid) && pid != getpid()) { + if (debug) + dbglog("sending SIGHUP to process %d", pid); + kill(pid, SIGHUP); + } } void mp_bundle_terminated() { - TDB_DATA key; + TDB_DATA key; - bundle_terminating = 1; - upper_layers_down(pcb); - notice("Connection terminated."); + bundle_terminating = 1; + upper_layers_down(pcb); + notice("Connection terminated."); #if PPP_STATS_SUPPORT - print_link_stats(); + print_link_stats(); #endif /* PPP_STATS_SUPPORT */ - if (!demand) { - remove_pidfiles(); - script_unsetenv("IFNAME"); - } - - lock_db(); - destroy_bundle(); - iterate_bundle_links(sendhup); - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - tdb_delete(pppdb, key); - unlock_db(); - - new_phase(PPP_PHASE_DEAD); - - doing_multilink = 0; - multilink_master = 0; + if (!demand) { + remove_pidfiles(); + script_unsetenv("IFNAME"); + } + + lock_db(); + destroy_bundle(); + iterate_bundle_links(sendhup); + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + tdb_delete(pppdb, key); + unlock_db(); + + new_phase(PPP_PHASE_DEAD); + + doing_multilink = 0; + multilink_master = 0; } static void make_bundle_links(int append) { - TDB_DATA key, rec; - char *p; - char entry[32]; - int l; - - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - slprintf(entry, sizeof(entry), "%s;", db_key); - p = entry; - if (append) { - rec = tdb_fetch(pppdb, key); - if (rec.dptr != NULL && rec.dsize > 0) { - rec.dptr[rec.dsize-1] = 0; - if (strstr(rec.dptr, db_key) != NULL) { - /* already in there? strange */ - warn("link entry already exists in tdb"); - return; - } - l = rec.dsize + strlen(entry); - p = malloc(l); - if (p == NULL) - novm("bundle link list"); - slprintf(p, l, "%s%s", rec.dptr, entry); - } else { - warn("bundle link list not found"); - } - if (rec.dptr != NULL) - free(rec.dptr); - } - rec.dptr = p; - rec.dsize = strlen(p) + 1; - if (tdb_store(pppdb, key, rec, TDB_REPLACE)) - error("couldn't %s bundle link list", - append? "update": "create"); - if (p != entry) - free(p); + TDB_DATA key, rec; + char *p; + char entry[32]; + int l; + + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + slprintf(entry, sizeof(entry), "%s;", db_key); + p = entry; + if (append) { + rec = tdb_fetch(pppdb, key); + if (rec.dptr != NULL && rec.dsize > 0) { + rec.dptr[rec.dsize-1] = 0; + if (strstr(rec.dptr, db_key) != NULL) { + /* already in there? strange */ + warn("link entry already exists in tdb"); + return; + } + l = rec.dsize + strlen(entry); + p = malloc(l); + if (p == NULL) + novm("bundle link list"); + slprintf(p, l, "%s%s", rec.dptr, entry); + } else { + warn("bundle link list not found"); + } + if (rec.dptr != NULL) + free(rec.dptr); + } + rec.dptr = p; + rec.dsize = strlen(p) + 1; + if (tdb_store(pppdb, key, rec, TDB_REPLACE)) + error("couldn't %s bundle link list", + append? "update": "create"); + if (p != entry) + free(p); } static void remove_bundle_link() { - TDB_DATA key, rec; - char entry[32]; - char *p, *q; - int l; - - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - slprintf(entry, sizeof(entry), "%s;", db_key); - - rec = tdb_fetch(pppdb, key); - if (rec.dptr == NULL || rec.dsize <= 0) { - if (rec.dptr != NULL) - free(rec.dptr); - return; - } - rec.dptr[rec.dsize-1] = 0; - p = strstr(rec.dptr, entry); - if (p != NULL) { - q = p + strlen(entry); - l = strlen(q) + 1; - memmove(p, q, l); - rec.dsize = p - rec.dptr + l; - if (tdb_store(pppdb, key, rec, TDB_REPLACE)) - error("couldn't update bundle link list (removal)"); - } - free(rec.dptr); + TDB_DATA key, rec; + char entry[32]; + char *p, *q; + int l; + + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + slprintf(entry, sizeof(entry), "%s;", db_key); + + rec = tdb_fetch(pppdb, key); + if (rec.dptr == NULL || rec.dsize <= 0) { + if (rec.dptr != NULL) + free(rec.dptr); + return; + } + rec.dptr[rec.dsize-1] = 0; + p = strstr(rec.dptr, entry); + if (p != NULL) { + q = p + strlen(entry); + l = strlen(q) + 1; + memmove(p, q, l); + rec.dsize = p - rec.dptr + l; + if (tdb_store(pppdb, key, rec, TDB_REPLACE)) + error("couldn't update bundle link list (removal)"); + } + free(rec.dptr); } static void iterate_bundle_links(void (*func)(char *)) { - TDB_DATA key, rec, pp; - char *p, *q; - - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - rec = tdb_fetch(pppdb, key); - if (rec.dptr == NULL || rec.dsize <= 0) { - error("bundle link list not found (iterating list)"); - if (rec.dptr != NULL) - free(rec.dptr); - return; - } - p = rec.dptr; - p[rec.dsize-1] = 0; - while ((q = strchr(p, ';')) != NULL) { - *q = 0; - key.dptr = p; - key.dsize = q - p; - pp = tdb_fetch(pppdb, key); - if (pp.dptr != NULL && pp.dsize > 0) { - pp.dptr[pp.dsize-1] = 0; - func(pp.dptr); - } - if (pp.dptr != NULL) - free(pp.dptr); - p = q + 1; - } - free(rec.dptr); + TDB_DATA key, rec, pp; + char *p, *q; + + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + rec = tdb_fetch(pppdb, key); + if (rec.dptr == NULL || rec.dsize <= 0) { + error("bundle link list not found (iterating list)"); + if (rec.dptr != NULL) + free(rec.dptr); + return; + } + p = rec.dptr; + p[rec.dsize-1] = 0; + while ((q = strchr(p, ';')) != NULL) { + *q = 0; + key.dptr = p; + key.dsize = q - p; + pp = tdb_fetch(pppdb, key); + if (pp.dptr != NULL && pp.dsize > 0) { + pp.dptr[pp.dsize-1] = 0; + func(pp.dptr); + } + if (pp.dptr != NULL) + free(pp.dptr); + p = q + 1; + } + free(rec.dptr); } static int @@ -409,19 +409,19 @@ parse_num(str, key, valp) const char *key; int *valp; { - char *p, *endp; - int i; - - p = strstr(str, key); - if (p != 0) { - p += strlen(key); - i = strtol(p, &endp, 10); - if (endp != p && (*endp == 0 || *endp == ';')) { - *valp = i; - return 1; - } - } - return 0; + char *p, *endp; + int i; + + p = strstr(str, key); + if (p != 0) { + p += strlen(key); + i = strtol(p, &endp, 10); + if (endp != p && (*endp == 0 || *endp == ';')) { + *valp = i; + return 1; + } + } + return 0; } /* @@ -432,53 +432,53 @@ owns_unit(key, unit) TDB_DATA key; int unit; { - char ifkey[32]; - TDB_DATA kd, vd; - int ret = 0; - - slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit); - kd.dptr = ifkey; - kd.dsize = strlen(ifkey); - vd = tdb_fetch(pppdb, kd); - if (vd.dptr != NULL) { - ret = vd.dsize == key.dsize - && memcmp(vd.dptr, key.dptr, vd.dsize) == 0; - free(vd.dptr); - } - return ret; + char ifkey[32]; + TDB_DATA kd, vd; + int ret = 0; + + slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit); + kd.dptr = ifkey; + kd.dsize = strlen(ifkey); + vd = tdb_fetch(pppdb, kd); + if (vd.dptr != NULL) { + ret = vd.dsize == key.dsize + && memcmp(vd.dptr, key.dptr, vd.dsize) == 0; + free(vd.dptr); + } + return ret; } static int get_default_epdisc(ep) struct epdisc *ep; { - char *p; - struct hostent *hp; - u32_t addr; - - /* First try for an ethernet MAC address */ - p = get_first_ethernet(); - if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) { - ep->class = EPD_MAC; - ep->length = 6; - return 1; - } - - /* see if our hostname corresponds to a reasonable IP address */ - hp = gethostbyname(hostname); - if (hp != NULL) { - addr = *(u32_t *)hp->h_addr; - if (!bad_ip_adrs(addr)) { - addr = lwip_ntohl(addr); - if (!LOCAL_IP_ADDR(addr)) { - ep->class = EPD_IP; - set_ip_epdisc(ep, addr); - return 1; - } - } - } - - return 0; + char *p; + struct hostent *hp; + u32_t addr; + + /* First try for an ethernet MAC address */ + p = get_first_ethernet(); + if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) { + ep->class = EPD_MAC; + ep->length = 6; + return 1; + } + + /* see if our hostname corresponds to a reasonable IP address */ + hp = gethostbyname(hostname); + if (hp != NULL) { + addr = *(u32_t *)hp->h_addr; + if (!bad_ip_adrs(addr)) { + addr = lwip_ntohl(addr); + if (!LOCAL_IP_ADDR(addr)) { + ep->class = EPD_IP; + set_ip_epdisc(ep, addr); + return 1; + } + } + } + + return 0; } /* @@ -493,51 +493,51 @@ char * epdisc_to_str(ep) struct epdisc *ep; { - static char str[MAX_ENDP_LEN*3+8]; - u_char *p = ep->value; - int i, mask = 0; - char *q, c, c2; - - if (ep->class == EPD_NULL && ep->length == 0) - return "null"; - if (ep->class == EPD_IP && ep->length == 4) { - u32_t addr; - - GETLONG(addr, p); - slprintf(str, sizeof(str), "IP:%I", lwip_htonl(addr)); - return str; - } - - c = ':'; - c2 = '.'; - if (ep->class == EPD_MAC && ep->length == 6) - c2 = ':'; - else if (ep->class == EPD_MAGIC && (ep->length % 4) == 0) - mask = 3; - q = str; - if (ep->class <= EPD_PHONENUM) - q += slprintf(q, sizeof(str)-1, "%s", - endp_class_names[ep->class]); - else - q += slprintf(q, sizeof(str)-1, "%d", ep->class); - c = ':'; - for (i = 0; i < ep->length && i < MAX_ENDP_LEN; ++i) { - if ((i & mask) == 0) { - *q++ = c; - c = c2; - } - q += slprintf(q, str + sizeof(str) - q, "%.2x", ep->value[i]); - } - return str; + static char str[MAX_ENDP_LEN*3+8]; + u_char *p = ep->value; + int i, mask = 0; + char *q, c, c2; + + if (ep->class == EPD_NULL && ep->length == 0) + return "null"; + if (ep->class == EPD_IP && ep->length == 4) { + u32_t addr; + + GETLONG(addr, p); + slprintf(str, sizeof(str), "IP:%I", lwip_htonl(addr)); + return str; + } + + c = ':'; + c2 = '.'; + if (ep->class == EPD_MAC && ep->length == 6) + c2 = ':'; + else if (ep->class == EPD_MAGIC && (ep->length % 4) == 0) + mask = 3; + q = str; + if (ep->class <= EPD_PHONENUM) + q += slprintf(q, sizeof(str)-1, "%s", + endp_class_names[ep->class]); + else + q += slprintf(q, sizeof(str)-1, "%d", ep->class); + c = ':'; + for (i = 0; i < ep->length && i < MAX_ENDP_LEN; ++i) { + if ((i & mask) == 0) { + *q++ = c; + c = c2; + } + q += slprintf(q, str + sizeof(str) - q, "%.2x", ep->value[i]); + } + return str; } static int hexc_val(int c) { - if (c >= 'a') - return c - 'a' + 10; - if (c >= 'A') - return c - 'A' + 10; - return c - '0'; + if (c >= 'a') + return c - 'a' + 10; + if (c >= 'A') + return c - 'A' + 10; + return c - '0'; } int @@ -545,65 +545,65 @@ str_to_epdisc(ep, str) struct epdisc *ep; char *str; { - int i, l; - char *p, *endp; - - for (i = EPD_NULL; i <= EPD_PHONENUM; ++i) { - int sl = strlen(endp_class_names[i]); - if (strncasecmp(str, endp_class_names[i], sl) == 0) { - str += sl; - break; - } - } - if (i > EPD_PHONENUM) { - /* not a class name, try a decimal class number */ - i = strtol(str, &endp, 10); - if (endp == str) - return 0; /* can't parse class number */ - str = endp; - } - ep->class = i; - if (*str == 0) { - ep->length = 0; - return 1; - } - if (*str != ':' && *str != '.') - return 0; - ++str; - - if (i == EPD_IP) { - u32_t addr; - i = parse_dotted_ip(str, &addr); - if (i == 0 || str[i] != 0) - return 0; - set_ip_epdisc(ep, addr); - return 1; - } - if (i == EPD_MAC && get_if_hwaddr(ep->value, str) >= 0) { - ep->length = 6; - return 1; - } - - p = str; - for (l = 0; l < MAX_ENDP_LEN; ++l) { - if (*str == 0) - break; - if (p <= str) - for (p = str; isxdigit(*p); ++p) - ; - i = p - str; - if (i == 0) - return 0; - ep->value[l] = hexc_val(*str++); - if ((i & 1) == 0) - ep->value[l] = (ep->value[l] << 4) + hexc_val(*str++); - if (*str == ':' || *str == '.') - ++str; - } - if (*str != 0 || (ep->class == EPD_MAC && l != 6)) - return 0; - ep->length = l; - return 1; + int i, l; + char *p, *endp; + + for (i = EPD_NULL; i <= EPD_PHONENUM; ++i) { + int sl = strlen(endp_class_names[i]); + if (strncasecmp(str, endp_class_names[i], sl) == 0) { + str += sl; + break; + } + } + if (i > EPD_PHONENUM) { + /* not a class name, try a decimal class number */ + i = strtol(str, &endp, 10); + if (endp == str) + return 0; /* can't parse class number */ + str = endp; + } + ep->class = i; + if (*str == 0) { + ep->length = 0; + return 1; + } + if (*str != ':' && *str != '.') + return 0; + ++str; + + if (i == EPD_IP) { + u32_t addr; + i = parse_dotted_ip(str, &addr); + if (i == 0 || str[i] != 0) + return 0; + set_ip_epdisc(ep, addr); + return 1; + } + if (i == EPD_MAC && get_if_hwaddr(ep->value, str) >= 0) { + ep->length = 6; + return 1; + } + + p = str; + for (l = 0; l < MAX_ENDP_LEN; ++l) { + if (*str == 0) + break; + if (p <= str) + for (p = str; isxdigit(*p); ++p) + ; + i = p - str; + if (i == 0) + return 0; + ep->value[l] = hexc_val(*str++); + if ((i & 1) == 0) + ep->value[l] = (ep->value[l] << 4) + hexc_val(*str++); + if (*str == ':' || *str == '.') + ++str; + } + if (*str != 0 || (ep->class == EPD_MAC && l != 6)) + return 0; + ep->length = l; + return 1; } #endif /* PPP_SUPPORT && HAVE_MULTILINK */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/arc4.c b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/arc4.c index 6e17ec421b..cb31b8761e 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/arc4.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/arc4.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/des.c b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/des.c index 9a89d007bd..b01e07fa5c 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/des.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/des.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md4.c b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md4.c index b1701a07b9..34e5b10cd4 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md4.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md4.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md5.c b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md5.c index 1ec4d81a69..fa6365848f 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md5.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/md5.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -156,7 +156,7 @@ static void md5_process( md5_context *ctx, const unsigned char data[64] ) P( B, C, D, A, 12, 20, 0x8D2A4C8A ); #undef F - + #define F(x,y,z) (x ^ y ^ z) P( A, B, C, D, 5, 4, 0xFFFA3942 ); diff --git a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/sha1.c b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/sha1.c index c2192eac54..6079af3ba2 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/polarssl/sha1.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/polarssl/sha1.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.0.2/src/netif/ppp/ppp.c b/components/net/lwip-2.0.2/src/netif/ppp/ppp.c index 8b77765e5a..66a1156ff8 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/ppp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/ppp.c @@ -629,7 +629,7 @@ int ppp_init(void) return 0; } - + /* * Create a new PPP control block. * diff --git a/components/net/lwip-2.0.2/src/netif/ppp/pppapi.c b/components/net/lwip-2.0.2/src/netif/ppp/pppapi.c index 947f7ba8c1..0ad8e986b4 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/pppapi.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/pppapi.c @@ -57,10 +57,10 @@ LWIP_MEMPOOL_DECLARE(PPPAPI_MSG, MEMP_NUM_PPP_API_MSG, sizeof(struct pppapi_msg) static err_t pppapi_do_ppp_set_default(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; - + ppp_set_default(msg->msg.ppp); return ERR_OK; } @@ -90,7 +90,7 @@ pppapi_set_default(ppp_pcb *pcb) static err_t pppapi_do_ppp_set_notify_phase_callback(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -125,7 +125,7 @@ pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_pha static err_t pppapi_do_pppos_create(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -166,7 +166,7 @@ pppapi_pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, static err_t pppapi_do_pppoe_create(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -211,7 +211,7 @@ pppapi_pppoe_create(struct netif *pppif, struct netif *ethif, const char *servic static err_t pppapi_do_pppol2tp_create(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -270,7 +270,7 @@ pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipad static err_t pppapi_do_ppp_connect(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -303,7 +303,7 @@ pppapi_connect(ppp_pcb *pcb, u16_t holdoff) static err_t pppapi_do_ppp_listen(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -335,7 +335,7 @@ pppapi_listen(ppp_pcb *pcb) static err_t pppapi_do_ppp_close(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -367,7 +367,7 @@ pppapi_close(ppp_pcb *pcb, u8_t nocarrier) static err_t pppapi_do_ppp_free(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -398,7 +398,7 @@ pppapi_free(ppp_pcb *pcb) static err_t pppapi_do_ppp_ioctl(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; diff --git a/components/net/lwip-2.0.2/src/netif/ppp/pppcrypt.c b/components/net/lwip-2.0.2/src/netif/ppp/pppcrypt.c index 82d78c13ac..81e4008d3d 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/pppcrypt.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/pppcrypt.c @@ -39,28 +39,28 @@ static u_char pppcrypt_get_7bits(u_char *input, int startBit) { - unsigned int word; + unsigned int word; - word = (unsigned)input[startBit / 8] << 8; - word |= (unsigned)input[startBit / 8 + 1]; + word = (unsigned)input[startBit / 8] << 8; + word |= (unsigned)input[startBit / 8 + 1]; - word >>= 15 - (startBit % 8 + 7); + word >>= 15 - (startBit % 8 + 7); - return word & 0xFE; + return word & 0xFE; } /* IN 56 bit DES key missing parity bits * OUT 64 bit DES key with parity bits added */ void pppcrypt_56_to_64_bit_key(u_char *key, u_char * des_key) { - des_key[0] = pppcrypt_get_7bits(key, 0); - des_key[1] = pppcrypt_get_7bits(key, 7); - des_key[2] = pppcrypt_get_7bits(key, 14); - des_key[3] = pppcrypt_get_7bits(key, 21); - des_key[4] = pppcrypt_get_7bits(key, 28); - des_key[5] = pppcrypt_get_7bits(key, 35); - des_key[6] = pppcrypt_get_7bits(key, 42); - des_key[7] = pppcrypt_get_7bits(key, 49); + des_key[0] = pppcrypt_get_7bits(key, 0); + des_key[1] = pppcrypt_get_7bits(key, 7); + des_key[2] = pppcrypt_get_7bits(key, 14); + des_key[3] = pppcrypt_get_7bits(key, 21); + des_key[4] = pppcrypt_get_7bits(key, 28); + des_key[5] = pppcrypt_get_7bits(key, 35); + des_key[6] = pppcrypt_get_7bits(key, 42); + des_key[7] = pppcrypt_get_7bits(key, 49); } #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ diff --git a/components/net/lwip-2.0.2/src/netif/ppp/pppoe.c b/components/net/lwip-2.0.2/src/netif/ppp/pppoe.c index eabfa4d041..48260be832 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/pppoe.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/pppoe.c @@ -6,13 +6,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -664,7 +664,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header failed\n")); LINK_STATS_INC(link.lenerr); goto drop; - } + } if (pb->len < sizeof(*ph)) { PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: could not get PPPoE header\n")); @@ -697,7 +697,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_header PPPOE_HEADERLEN failed\n")); LINK_STATS_INC(link.lenerr); goto drop; - } + } PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: %c%c%"U16_F": pkthdr.len=%d, pppoe.len=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, diff --git a/components/net/lwip-2.0.2/src/netif/ppp/pppol2tp.c b/components/net/lwip-2.0.2/src/netif/ppp/pppol2tp.c index d44471e25f..9033fb3a34 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/pppol2tp.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/pppol2tp.c @@ -740,15 +740,15 @@ static void pppol2tp_timeout(void *arg) { PPPDEBUG(LOG_DEBUG, ("pppol2tp: icrq_retried=%d\n", l2tp->icrq_retried)); if (l2tp->peer_nr <= l2tp->our_ns -1) { /* the SCCCN was not acknowledged */ if ((err = pppol2tp_send_scccn(l2tp, l2tp->our_ns -1)) != 0) { - l2tp->icrq_retried--; - PPPDEBUG(LOG_DEBUG, ("pppol2tp: failed to send SCCCN, error=%d\n", err)); - sys_timeout(PPPOL2TP_CONTROL_TIMEOUT, pppol2tp_timeout, l2tp); - break; - } + l2tp->icrq_retried--; + PPPDEBUG(LOG_DEBUG, ("pppol2tp: failed to send SCCCN, error=%d\n", err)); + sys_timeout(PPPOL2TP_CONTROL_TIMEOUT, pppol2tp_timeout, l2tp); + break; + } } if ((err = pppol2tp_send_icrq(l2tp, l2tp->our_ns)) != 0) { - l2tp->icrq_retried--; - PPPDEBUG(LOG_DEBUG, ("pppol2tp: failed to send ICRQ, error=%d\n", err)); + l2tp->icrq_retried--; + PPPDEBUG(LOG_DEBUG, ("pppol2tp: failed to send ICRQ, error=%d\n", err)); } sys_timeout(PPPOL2TP_CONTROL_TIMEOUT, pppol2tp_timeout, l2tp); break; @@ -761,8 +761,8 @@ static void pppol2tp_timeout(void *arg) { } PPPDEBUG(LOG_DEBUG, ("pppol2tp: iccn_retried=%d\n", l2tp->iccn_retried)); if ((err = pppol2tp_send_iccn(l2tp, l2tp->our_ns)) != 0) { - l2tp->iccn_retried--; - PPPDEBUG(LOG_DEBUG, ("pppol2tp: failed to send ICCN, error=%d\n", err)); + l2tp->iccn_retried--; + PPPDEBUG(LOG_DEBUG, ("pppol2tp: failed to send ICCN, error=%d\n", err)); } sys_timeout(PPPOL2TP_CONTROL_TIMEOUT, pppol2tp_timeout, l2tp); break; diff --git a/components/net/lwip-2.0.2/src/netif/ppp/upap.c b/components/net/lwip-2.0.2/src/netif/ppp/upap.c index d00c2d76e5..f00f2ac46e 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/upap.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/upap.c @@ -166,12 +166,12 @@ void upap_authwithpeer(ppp_pcb *pcb, const char *user, const char *password) { /* Lower layer up yet? */ if (pcb->upap.us_clientstate == UPAPCS_INITIAL || - pcb->upap.us_clientstate == UPAPCS_PENDING) { - pcb->upap.us_clientstate = UPAPCS_PENDING; - return; + pcb->upap.us_clientstate == UPAPCS_PENDING) { + pcb->upap.us_clientstate = UPAPCS_PENDING; + return; } - upap_sauthreq(pcb); /* Start protocol */ + upap_sauthreq(pcb); /* Start protocol */ } #if PPP_SERVER @@ -184,14 +184,14 @@ void upap_authpeer(ppp_pcb *pcb) { /* Lower layer up yet? */ if (pcb->upap.us_serverstate == UPAPSS_INITIAL || - pcb->upap.us_serverstate == UPAPSS_PENDING) { - pcb->upap.us_serverstate = UPAPSS_PENDING; - return; + pcb->upap.us_serverstate == UPAPSS_PENDING) { + pcb->upap.us_serverstate = UPAPSS_PENDING; + return; } pcb->upap.us_serverstate = UPAPSS_LISTEN; if (pcb->settings.pap_req_timeout > 0) - TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); + TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); } #endif /* PPP_SERVER */ @@ -202,17 +202,17 @@ static void upap_timeout(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) - return; + return; if (pcb->upap.us_transmits >= pcb->settings.pap_max_transmits) { - /* give up in disgust */ - ppp_error("No response to PAP authenticate-requests"); - pcb->upap.us_clientstate = UPAPCS_BADAUTH; - auth_withpeer_fail(pcb, PPP_PAP); - return; + /* give up in disgust */ + ppp_error("No response to PAP authenticate-requests"); + pcb->upap.us_clientstate = UPAPCS_BADAUTH; + auth_withpeer_fail(pcb, PPP_PAP); + return; } - upap_sauthreq(pcb); /* Send Authenticate-Request */ + upap_sauthreq(pcb); /* Send Authenticate-Request */ } @@ -224,7 +224,7 @@ static void upap_reqtimeout(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; if (pcb->upap.us_serverstate != UPAPSS_LISTEN) - return; /* huh?? */ + return; /* huh?? */ auth_peer_fail(pcb, PPP_PAP); pcb->upap.us_serverstate = UPAPSS_BADAUTH; @@ -240,18 +240,18 @@ static void upap_reqtimeout(void *arg) { static void upap_lowerup(ppp_pcb *pcb) { if (pcb->upap.us_clientstate == UPAPCS_INITIAL) - pcb->upap.us_clientstate = UPAPCS_CLOSED; + pcb->upap.us_clientstate = UPAPCS_CLOSED; else if (pcb->upap.us_clientstate == UPAPCS_PENDING) { - upap_sauthreq(pcb); /* send an auth-request */ + upap_sauthreq(pcb); /* send an auth-request */ } #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_INITIAL) - pcb->upap.us_serverstate = UPAPSS_CLOSED; + pcb->upap.us_serverstate = UPAPSS_CLOSED; else if (pcb->upap.us_serverstate == UPAPSS_PENDING) { - pcb->upap.us_serverstate = UPAPSS_LISTEN; - if (pcb->settings.pap_req_timeout > 0) - TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); + pcb->upap.us_serverstate = UPAPSS_LISTEN; + if (pcb->settings.pap_req_timeout > 0) + TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); } #endif /* PPP_SERVER */ } @@ -264,11 +264,11 @@ static void upap_lowerup(ppp_pcb *pcb) { */ static void upap_lowerdown(ppp_pcb *pcb) { - if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */ - UNTIMEOUT(upap_timeout, pcb); /* Cancel timeout */ + if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */ + UNTIMEOUT(upap_timeout, pcb); /* Cancel timeout */ #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_LISTEN && pcb->settings.pap_req_timeout > 0) - UNTIMEOUT(upap_reqtimeout, pcb); + UNTIMEOUT(upap_reqtimeout, pcb); #endif /* PPP_SERVER */ pcb->upap.us_clientstate = UPAPCS_INITIAL; @@ -286,13 +286,13 @@ static void upap_lowerdown(ppp_pcb *pcb) { static void upap_protrej(ppp_pcb *pcb) { if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) { - ppp_error("PAP authentication failed due to protocol-reject"); - auth_withpeer_fail(pcb, PPP_PAP); + ppp_error("PAP authentication failed due to protocol-reject"); + auth_withpeer_fail(pcb, PPP_PAP); } #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_LISTEN) { - ppp_error("PAP authentication of peer failed (protocol-reject)"); - auth_peer_fail(pcb, PPP_PAP); + ppp_error("PAP authentication of peer failed (protocol-reject)"); + auth_peer_fail(pcb, PPP_PAP); } #endif /* PPP_SERVER */ upap_lowerdown(pcb); @@ -313,19 +313,19 @@ static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l) { */ inp = inpacket; if (l < UPAP_HEADERLEN) { - UPAPDEBUG(("pap_input: rcvd short header.")); - return; + UPAPDEBUG(("pap_input: rcvd short header.")); + return; } GETCHAR(code, inp); GETCHAR(id, inp); GETSHORT(len, inp); if (len < UPAP_HEADERLEN) { - UPAPDEBUG(("pap_input: rcvd illegal length.")); - return; + UPAPDEBUG(("pap_input: rcvd illegal length.")); + return; } if (len > l) { - UPAPDEBUG(("pap_input: rcvd short packet.")); - return; + UPAPDEBUG(("pap_input: rcvd short packet.")); + return; } len -= UPAP_HEADERLEN; @@ -335,20 +335,20 @@ static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l) { switch (code) { case UPAP_AUTHREQ: #if PPP_SERVER - upap_rauthreq(pcb, inp, id, len); + upap_rauthreq(pcb, inp, id, len); #endif /* PPP_SERVER */ - break; + break; case UPAP_AUTHACK: - upap_rauthack(pcb, inp, id, len); - break; + upap_rauthack(pcb, inp, id, len); + break; case UPAP_AUTHNAK: - upap_rauthnak(pcb, inp, id, len); - break; + upap_rauthnak(pcb, inp, id, len); + break; - default: /* XXX Need code reject */ - break; + default: /* XXX Need code reject */ + break; } } @@ -366,40 +366,40 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) { int msglen; if (pcb->upap.us_serverstate < UPAPSS_LISTEN) - return; + return; /* * If we receive a duplicate authenticate-request, we are * supposed to return the same status as for the first request. */ if (pcb->upap.us_serverstate == UPAPSS_OPEN) { - upap_sresp(pcb, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ - return; + upap_sresp(pcb, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ + return; } if (pcb->upap.us_serverstate == UPAPSS_BADAUTH) { - upap_sresp(pcb, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ - return; + upap_sresp(pcb, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ + return; } /* * Parse user/passwd. */ if (len < 1) { - UPAPDEBUG(("pap_rauth: rcvd short packet.")); - return; + UPAPDEBUG(("pap_rauth: rcvd short packet.")); + return; } GETCHAR(ruserlen, inp); len -= sizeof (u_char) + ruserlen + sizeof (u_char); if (len < 0) { - UPAPDEBUG(("pap_rauth: rcvd short packet.")); - return; + UPAPDEBUG(("pap_rauth: rcvd short packet.")); + return; } ruser = (char *) inp; INCPTR(ruserlen, inp); GETCHAR(rpasswdlen, inp); if (len < rpasswdlen) { - UPAPDEBUG(("pap_rauth: rcvd short packet.")); - return; + UPAPDEBUG(("pap_rauth: rcvd short packet.")); + return; } rpasswd = (char *) inp; @@ -420,16 +420,16 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) { * return an authenticate failure, is leaving it for us to verify. */ if (retcode == UPAP_AUTHACK) { - if (!auth_number()) { - /* We do not want to leak info about the pap result. */ - retcode = UPAP_AUTHNAK; /* XXX exit value will be "wrong" */ - warn("calling number %q is not authorized", remote_number); - } + if (!auth_number()) { + /* We do not want to leak info about the pap result. */ + retcode = UPAP_AUTHNAK; /* XXX exit value will be "wrong" */ + warn("calling number %q is not authorized", remote_number); + } } msglen = strlen(msg); if (msglen > 255) - msglen = 255; + msglen = 255; #endif /* UNUSED */ upap_sresp(pcb, retcode, id, msg, msglen); @@ -438,17 +438,17 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) { ppp_slprintf(rhostname, sizeof(rhostname), "%.*v", ruserlen, ruser); if (retcode == UPAP_AUTHACK) { - pcb->upap.us_serverstate = UPAPSS_OPEN; - ppp_notice("PAP peer authentication succeeded for %q", rhostname); - auth_peer_success(pcb, PPP_PAP, 0, ruser, ruserlen); + pcb->upap.us_serverstate = UPAPSS_OPEN; + ppp_notice("PAP peer authentication succeeded for %q", rhostname); + auth_peer_success(pcb, PPP_PAP, 0, ruser, ruserlen); } else { - pcb->upap.us_serverstate = UPAPSS_BADAUTH; - ppp_warn("PAP peer authentication failed for %q", rhostname); - auth_peer_fail(pcb, PPP_PAP); + pcb->upap.us_serverstate = UPAPSS_BADAUTH; + ppp_warn("PAP peer authentication failed for %q", rhostname); + auth_peer_fail(pcb, PPP_PAP); } if (pcb->settings.pap_req_timeout > 0) - UNTIMEOUT(upap_reqtimeout, pcb); + UNTIMEOUT(upap_reqtimeout, pcb); } #endif /* PPP_SERVER */ @@ -461,24 +461,24 @@ static void upap_rauthack(ppp_pcb *pcb, u_char *inp, int id, int len) { LWIP_UNUSED_ARG(id); if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */ - return; + return; /* * Parse message. */ if (len < 1) { - UPAPDEBUG(("pap_rauthack: ignoring missing msg-length.")); + UPAPDEBUG(("pap_rauthack: ignoring missing msg-length.")); } else { - GETCHAR(msglen, inp); - if (msglen > 0) { - len -= sizeof (u_char); - if (len < msglen) { - UPAPDEBUG(("pap_rauthack: rcvd short packet.")); - return; - } - msg = (char *) inp; - PRINTMSG(msg, msglen); - } + GETCHAR(msglen, inp); + if (msglen > 0) { + len -= sizeof (u_char); + if (len < msglen) { + UPAPDEBUG(("pap_rauthack: rcvd short packet.")); + return; + } + msg = (char *) inp; + PRINTMSG(msg, msglen); + } } pcb->upap.us_clientstate = UPAPCS_OPEN; @@ -496,24 +496,24 @@ static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len) { LWIP_UNUSED_ARG(id); if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */ - return; + return; /* * Parse message. */ if (len < 1) { - UPAPDEBUG(("pap_rauthnak: ignoring missing msg-length.")); + UPAPDEBUG(("pap_rauthnak: ignoring missing msg-length.")); } else { - GETCHAR(msglen, inp); - if (msglen > 0) { - len -= sizeof (u_char); - if (len < msglen) { - UPAPDEBUG(("pap_rauthnak: rcvd short packet.")); - return; - } - msg = (char *) inp; - PRINTMSG(msg, msglen); - } + GETCHAR(msglen, inp); + if (msglen > 0) { + len -= sizeof (u_char); + if (len < msglen) { + UPAPDEBUG(("pap_rauthnak: rcvd short packet.")); + return; + } + msg = (char *) inp; + PRINTMSG(msg, msglen); + } } pcb->upap.us_clientstate = UPAPCS_BADAUTH; @@ -532,7 +532,7 @@ static void upap_sauthreq(ppp_pcb *pcb) { int outlen; outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + - pcb->upap.us_userlen + pcb->upap.us_passwdlen; + pcb->upap.us_userlen + pcb->upap.us_passwdlen; p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PPP_CTRL_PBUF_TYPE); if(NULL == p) return; @@ -606,68 +606,68 @@ static int upap_printpkt(const u_char *p, int plen, void (*printer) (void *, con const u_char *pstart; if (plen < UPAP_HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < UPAP_HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(upap_codenames)) - printer(arg, " %s", upap_codenames[code-1]); + printer(arg, " %s", upap_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= UPAP_HEADERLEN; switch (code) { case UPAP_AUTHREQ: - if (len < 1) - break; - ulen = p[0]; - if (len < ulen + 2) - break; - wlen = p[ulen + 1]; - if (len < ulen + wlen + 2) - break; - user = (const u_char *) (p + 1); - pwd = (const u_char *) (p + ulen + 2); - p += ulen + wlen + 2; - len -= ulen + wlen + 2; - printer(arg, " user="); - ppp_print_string(user, ulen, printer, arg); - printer(arg, " password="); + if (len < 1) + break; + ulen = p[0]; + if (len < ulen + 2) + break; + wlen = p[ulen + 1]; + if (len < ulen + wlen + 2) + break; + user = (const u_char *) (p + 1); + pwd = (const u_char *) (p + ulen + 2); + p += ulen + wlen + 2; + len -= ulen + wlen + 2; + printer(arg, " user="); + ppp_print_string(user, ulen, printer, arg); + printer(arg, " password="); /* FIXME: require ppp_pcb struct as printpkt() argument */ #if 0 - if (!pcb->settings.hide_password) + if (!pcb->settings.hide_password) #endif - ppp_print_string(pwd, wlen, printer, arg); + ppp_print_string(pwd, wlen, printer, arg); #if 0 - else - printer(arg, ""); + else + printer(arg, ""); #endif - break; + break; case UPAP_AUTHACK: case UPAP_AUTHNAK: - if (len < 1) - break; - mlen = p[0]; - if (len < mlen + 1) - break; - msg = (const u_char *) (p + 1); - p += mlen + 1; - len -= mlen + 1; - printer(arg, " "); - ppp_print_string(msg, mlen, printer, arg); - break; + if (len < 1) + break; + mlen = p[0]; + if (len < mlen + 1) + break; + msg = (const u_char *) (p + 1); + p += mlen + 1; + len -= mlen + 1; + printer(arg, " "); + ppp_print_string(msg, mlen, printer, arg); + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } return p - pstart; diff --git a/components/net/lwip-2.0.2/src/netif/ppp/utils.c b/components/net/lwip-2.0.2/src/netif/ppp/utils.c index 008c63375a..dd8e0f3b7c 100644 --- a/components/net/lwip-2.0.2/src/netif/ppp/utils.c +++ b/components/net/lwip-2.0.2/src/netif/ppp/utils.c @@ -74,7 +74,7 @@ static void ppp_log_write(int level, char *buf); #if PRINTPKT_SUPPORT static void ppp_vslp_printer(void *arg, const char *fmt, ...); static void ppp_format_packet(const u_char *p, int len, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); struct buffer_info { char *ptr; @@ -90,12 +90,12 @@ size_t ppp_strlcpy(char *dest, const char *src, size_t len) { size_t ret = strlen(src); if (len != 0) { - if (ret < len) - strcpy(dest, src); - else { - strncpy(dest, src, len - 1); - dest[len-1] = 0; - } + if (ret < len) + strcpy(dest, src); + else { + strncpy(dest, src, len - 1); + dest[len-1] = 0; + } } return ret; } @@ -132,7 +132,7 @@ int ppp_slprintf(char *buf, int buflen, const char *fmt, ...) { /* * ppp_vslprintf - like ppp_slprintf, takes a va_list instead of a list of args. */ -#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) +#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { int c, i, n; @@ -155,249 +155,249 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { buf0 = buf; --buflen; while (buflen > 0) { - for (f = fmt; *f != '%' && *f != 0; ++f) - ; - if (f > fmt) { - len = f - fmt; - if (len > buflen) - len = buflen; - memcpy(buf, fmt, len); - buf += len; - buflen -= len; - fmt = f; - } - if (*fmt == 0) - break; - c = *++fmt; - width = 0; - prec = -1; - fillch = ' '; - if (c == '0') { - fillch = '0'; - c = *++fmt; - } - if (c == '*') { - width = va_arg(args, int); - c = *++fmt; - } else { - while (isdigit(c)) { - width = width * 10 + c - '0'; - c = *++fmt; - } - } - if (c == '.') { - c = *++fmt; - if (c == '*') { - prec = va_arg(args, int); - c = *++fmt; - } else { - prec = 0; - while (isdigit(c)) { - prec = prec * 10 + c - '0'; - c = *++fmt; - } - } - } - str = 0; - base = 0; - neg = 0; - ++fmt; - switch (c) { - case 'l': - c = *fmt++; - switch (c) { - case 'd': - val = va_arg(args, long); - if ((long)val < 0) { - neg = 1; - val = (unsigned long)-(long)val; - } - base = 10; - break; - case 'u': - val = va_arg(args, unsigned long); - base = 10; - break; - default: - OUTCHAR('%'); - OUTCHAR('l'); - --fmt; /* so %lz outputs %lz etc. */ - continue; - } - break; - case 'd': - i = va_arg(args, int); - if (i < 0) { - neg = 1; - val = -i; - } else - val = i; - base = 10; - break; - case 'u': - val = va_arg(args, unsigned int); - base = 10; - break; - case 'o': - val = va_arg(args, unsigned int); - base = 8; - break; - case 'x': - case 'X': - val = va_arg(args, unsigned int); - base = 16; - break; + for (f = fmt; *f != '%' && *f != 0; ++f) + ; + if (f > fmt) { + len = f - fmt; + if (len > buflen) + len = buflen; + memcpy(buf, fmt, len); + buf += len; + buflen -= len; + fmt = f; + } + if (*fmt == 0) + break; + c = *++fmt; + width = 0; + prec = -1; + fillch = ' '; + if (c == '0') { + fillch = '0'; + c = *++fmt; + } + if (c == '*') { + width = va_arg(args, int); + c = *++fmt; + } else { + while (isdigit(c)) { + width = width * 10 + c - '0'; + c = *++fmt; + } + } + if (c == '.') { + c = *++fmt; + if (c == '*') { + prec = va_arg(args, int); + c = *++fmt; + } else { + prec = 0; + while (isdigit(c)) { + prec = prec * 10 + c - '0'; + c = *++fmt; + } + } + } + str = 0; + base = 0; + neg = 0; + ++fmt; + switch (c) { + case 'l': + c = *fmt++; + switch (c) { + case 'd': + val = va_arg(args, long); + if ((long)val < 0) { + neg = 1; + val = (unsigned long)-(long)val; + } + base = 10; + break; + case 'u': + val = va_arg(args, unsigned long); + base = 10; + break; + default: + OUTCHAR('%'); + OUTCHAR('l'); + --fmt; /* so %lz outputs %lz etc. */ + continue; + } + break; + case 'd': + i = va_arg(args, int); + if (i < 0) { + neg = 1; + val = -i; + } else + val = i; + base = 10; + break; + case 'u': + val = va_arg(args, unsigned int); + base = 10; + break; + case 'o': + val = va_arg(args, unsigned int); + base = 8; + break; + case 'x': + case 'X': + val = va_arg(args, unsigned int); + base = 16; + break; #if 0 /* unused (and wrong on LLP64 systems) */ - case 'p': - val = (unsigned long) va_arg(args, void *); - base = 16; - neg = 2; - break; + case 'p': + val = (unsigned long) va_arg(args, void *); + base = 16; + neg = 2; + break; #endif /* unused (and wrong on LLP64 systems) */ - case 's': - str = va_arg(args, char *); - break; - case 'c': - num[0] = va_arg(args, int); - num[1] = 0; - str = num; - break; + case 's': + str = va_arg(args, char *); + break; + case 'c': + num[0] = va_arg(args, int); + num[1] = 0; + str = num; + break; #if 0 /* do we always have strerror() in embedded ? */ - case 'm': - str = strerror(errno); - break; + case 'm': + str = strerror(errno); + break; #endif /* do we always have strerror() in embedded ? */ - case 'I': - ip = va_arg(args, u32_t); - ip = lwip_ntohl(ip); - ppp_slprintf(num, sizeof(num), "%d.%d.%d.%d", (ip >> 24) & 0xff, - (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); - str = num; - break; + case 'I': + ip = va_arg(args, u32_t); + ip = lwip_ntohl(ip); + ppp_slprintf(num, sizeof(num), "%d.%d.%d.%d", (ip >> 24) & 0xff, + (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); + str = num; + break; #if 0 /* need port */ - case 't': - time(&t); - str = ctime(&t); - str += 4; /* chop off the day name */ - str[15] = 0; /* chop off year and newline */ - break; + case 't': + time(&t); + str = ctime(&t); + str += 4; /* chop off the day name */ + str[15] = 0; /* chop off year and newline */ + break; #endif /* need port */ - case 'v': /* "visible" string */ - case 'q': /* quoted string */ - quoted = c == 'q'; - p = va_arg(args, unsigned char *); - if (p == NULL) - p = (const unsigned char *)""; - if (fillch == '0' && prec >= 0) { - n = prec; - } else { - n = strlen((const char *)p); - if (prec >= 0 && n > prec) - n = prec; - } - while (n > 0 && buflen > 0) { - c = *p++; - --n; - if (!quoted && c >= 0x80) { - OUTCHAR('M'); - OUTCHAR('-'); - c -= 0x80; - } - if (quoted && (c == '"' || c == '\\')) - OUTCHAR('\\'); - if (c < 0x20 || (0x7f <= c && c < 0xa0)) { - if (quoted) { - OUTCHAR('\\'); - switch (c) { - case '\t': OUTCHAR('t'); break; - case '\n': OUTCHAR('n'); break; - case '\b': OUTCHAR('b'); break; - case '\f': OUTCHAR('f'); break; - default: - OUTCHAR('x'); - OUTCHAR(hexchars[c >> 4]); - OUTCHAR(hexchars[c & 0xf]); - } - } else { - if (c == '\t') - OUTCHAR(c); - else { - OUTCHAR('^'); - OUTCHAR(c ^ 0x40); - } - } - } else - OUTCHAR(c); - } - continue; + case 'v': /* "visible" string */ + case 'q': /* quoted string */ + quoted = c == 'q'; + p = va_arg(args, unsigned char *); + if (p == NULL) + p = (const unsigned char *)""; + if (fillch == '0' && prec >= 0) { + n = prec; + } else { + n = strlen((const char *)p); + if (prec >= 0 && n > prec) + n = prec; + } + while (n > 0 && buflen > 0) { + c = *p++; + --n; + if (!quoted && c >= 0x80) { + OUTCHAR('M'); + OUTCHAR('-'); + c -= 0x80; + } + if (quoted && (c == '"' || c == '\\')) + OUTCHAR('\\'); + if (c < 0x20 || (0x7f <= c && c < 0xa0)) { + if (quoted) { + OUTCHAR('\\'); + switch (c) { + case '\t': OUTCHAR('t'); break; + case '\n': OUTCHAR('n'); break; + case '\b': OUTCHAR('b'); break; + case '\f': OUTCHAR('f'); break; + default: + OUTCHAR('x'); + OUTCHAR(hexchars[c >> 4]); + OUTCHAR(hexchars[c & 0xf]); + } + } else { + if (c == '\t') + OUTCHAR(c); + else { + OUTCHAR('^'); + OUTCHAR(c ^ 0x40); + } + } + } else + OUTCHAR(c); + } + continue; #if PRINTPKT_SUPPORT - case 'P': /* print PPP packet */ - bufinfo.ptr = buf; - bufinfo.len = buflen + 1; - p = va_arg(args, unsigned char *); - n = va_arg(args, int); - ppp_format_packet(p, n, ppp_vslp_printer, &bufinfo); - buf = bufinfo.ptr; - buflen = bufinfo.len - 1; - continue; + case 'P': /* print PPP packet */ + bufinfo.ptr = buf; + bufinfo.len = buflen + 1; + p = va_arg(args, unsigned char *); + n = va_arg(args, int); + ppp_format_packet(p, n, ppp_vslp_printer, &bufinfo); + buf = bufinfo.ptr; + buflen = bufinfo.len - 1; + continue; #endif /* PRINTPKT_SUPPORT */ - case 'B': - p = va_arg(args, unsigned char *); - for (n = prec; n > 0; --n) { - c = *p++; - if (fillch == ' ') - OUTCHAR(' '); - OUTCHAR(hexchars[(c >> 4) & 0xf]); - OUTCHAR(hexchars[c & 0xf]); - } - continue; - default: - *buf++ = '%'; - if (c != '%') - --fmt; /* so %z outputs %z etc. */ - --buflen; - continue; - } - if (base != 0) { - str = num + sizeof(num); - *--str = 0; - while (str > num + neg) { - *--str = hexchars[val % base]; - val = val / base; - if (--prec <= 0 && val == 0) - break; - } - switch (neg) { - case 1: - *--str = '-'; - break; - case 2: - *--str = 'x'; - *--str = '0'; - break; - default: - break; - } - len = num + sizeof(num) - 1 - str; - } else { - len = strlen(str); - if (prec >= 0 && len > prec) - len = prec; - } - if (width > 0) { - if (width > buflen) - width = buflen; - if ((n = width - len) > 0) { - buflen -= n; - for (; n > 0; --n) - *buf++ = fillch; - } - } - if (len > buflen) - len = buflen; - memcpy(buf, str, len); - buf += len; - buflen -= len; + case 'B': + p = va_arg(args, unsigned char *); + for (n = prec; n > 0; --n) { + c = *p++; + if (fillch == ' ') + OUTCHAR(' '); + OUTCHAR(hexchars[(c >> 4) & 0xf]); + OUTCHAR(hexchars[c & 0xf]); + } + continue; + default: + *buf++ = '%'; + if (c != '%') + --fmt; /* so %z outputs %z etc. */ + --buflen; + continue; + } + if (base != 0) { + str = num + sizeof(num); + *--str = 0; + while (str > num + neg) { + *--str = hexchars[val % base]; + val = val / base; + if (--prec <= 0 && val == 0) + break; + } + switch (neg) { + case 1: + *--str = '-'; + break; + case 2: + *--str = 'x'; + *--str = '0'; + break; + default: + break; + } + len = num + sizeof(num) - 1 - str; + } else { + len = strlen(str); + if (prec >= 0 && len > prec) + len = prec; + } + if (width > 0) { + if (width > buflen) + width = buflen; + if ((n = width - len) > 0) { + buflen -= n; + for (; n > 0; --n) + *buf++ = fillch; + } + } + if (len > buflen) + len = buflen; + memcpy(buf, str, len); + buf += len; + buflen -= len; } *buf = 0; return buf - buf0; @@ -434,9 +434,9 @@ log_packet(p, len, prefix, level) char *prefix; int level; { - init_pr_log(prefix, level); - ppp_format_packet(p, len, pr_log, &level); - end_pr_log(); + init_pr_log(prefix, level); + ppp_format_packet(p, len, pr_log, &level); + end_pr_log(); } #endif /* UNUSED */ @@ -446,43 +446,43 @@ log_packet(p, len, prefix, level) * calling `printer(arg, format, ...)' to output it. */ static void ppp_format_packet(const u_char *p, int len, - void (*printer) (void *, const char *, ...), void *arg) { + void (*printer) (void *, const char *, ...), void *arg) { int i, n; u_short proto; const struct protent *protp; if (len >= 2) { - GETSHORT(proto, p); - len -= 2; - for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (proto == protp->protocol) - break; - if (protp != NULL) { - printer(arg, "[%s", protp->name); - n = (*protp->printpkt)(p, len, printer, arg); - printer(arg, "]"); - p += n; - len -= n; - } else { - for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (proto == (protp->protocol & ~0x8000)) - break; - if (protp != 0 && protp->data_name != 0) { - printer(arg, "[%s data]", protp->data_name); - if (len > 8) - printer(arg, "%.8B ...", p); - else - printer(arg, "%.*B", len, p); - len = 0; - } else - printer(arg, "[proto=0x%x]", proto); - } + GETSHORT(proto, p); + len -= 2; + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (proto == protp->protocol) + break; + if (protp != NULL) { + printer(arg, "[%s", protp->name); + n = (*protp->printpkt)(p, len, printer, arg); + printer(arg, "]"); + p += n; + len -= n; + } else { + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (proto == (protp->protocol & ~0x8000)) + break; + if (protp != 0 && protp->data_name != 0) { + printer(arg, "[%s data]", protp->data_name); + if (len > 8) + printer(arg, "%.8B ...", p); + else + printer(arg, "%.*B", len, p); + len = 0; + } else + printer(arg, "[proto=0x%x]", proto); + } } if (len > 32) - printer(arg, "%.32B ...", p); + printer(arg, "%.32B ...", p); else - printer(arg, "%.*B", len, p); + printer(arg, "%.*B", len, p); } #endif /* PRINTPKT_SUPPORT */ @@ -491,30 +491,30 @@ static void ppp_format_packet(const u_char *p, int len, * init_pr_log, end_pr_log - initialize and finish use of pr_log. */ -static char line[256]; /* line to be logged accumulated here */ -static char *linep; /* current pointer within line */ -static int llevel; /* level for logging */ +static char line[256]; /* line to be logged accumulated here */ +static char *linep; /* current pointer within line */ +static int llevel; /* level for logging */ void init_pr_log(prefix, level) const char *prefix; int level; { - linep = line; - if (prefix != NULL) { - ppp_strlcpy(line, prefix, sizeof(line)); - linep = line + strlen(line); - } - llevel = level; + linep = line; + if (prefix != NULL) { + ppp_strlcpy(line, prefix, sizeof(line)); + linep = line + strlen(line); + } + llevel = level; } void end_pr_log() { - if (linep != line) { - *linep = 0; - ppp_log_write(llevel, line); - } + if (linep != line) { + *linep = 0; + ppp_log_write(llevel, line); + } } /* @@ -523,47 +523,47 @@ end_pr_log() void pr_log (void *arg, const char *fmt, ...) { - int l, n; - va_list pvar; - char *p, *eol; - char buf[256]; - - va_start(pvar, fmt); - n = ppp_vslprintf(buf, sizeof(buf), fmt, pvar); - va_end(pvar); - - p = buf; - eol = strchr(buf, '\n'); - if (linep != line) { - l = (eol == NULL)? n: eol - buf; - if (linep + l < line + sizeof(line)) { - if (l > 0) { - memcpy(linep, buf, l); - linep += l; - } - if (eol == NULL) - return; - p = eol + 1; - eol = strchr(p, '\n'); - } - *linep = 0; - ppp_log_write(llevel, line); - linep = line; - } - - while (eol != NULL) { - *eol = 0; - ppp_log_write(llevel, p); - p = eol + 1; - eol = strchr(p, '\n'); - } - - /* assumes sizeof(buf) <= sizeof(line) */ - l = buf + n - p; - if (l > 0) { - memcpy(line, p, n); - linep = line + l; - } + int l, n; + va_list pvar; + char *p, *eol; + char buf[256]; + + va_start(pvar, fmt); + n = ppp_vslprintf(buf, sizeof(buf), fmt, pvar); + va_end(pvar); + + p = buf; + eol = strchr(buf, '\n'); + if (linep != line) { + l = (eol == NULL)? n: eol - buf; + if (linep + l < line + sizeof(line)) { + if (l > 0) { + memcpy(linep, buf, l); + linep += l; + } + if (eol == NULL) + return; + p = eol + 1; + eol = strchr(p, '\n'); + } + *linep = 0; + ppp_log_write(llevel, line); + linep = line; + } + + while (eol != NULL) { + *eol = 0; + ppp_log_write(llevel, p); + p = eol + 1; + eol = strchr(p, '\n'); + } + + /* assumes sizeof(buf) <= sizeof(line) */ + l = buf + n - p; + if (l > 0) { + memcpy(line, p, n); + linep = line + l; + } } #endif /* UNUSED */ @@ -576,27 +576,27 @@ void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const c printer(arg, "\""); for (; len > 0; --len) { - c = *p++; - if (' ' <= c && c <= '~') { - if (c == '\\' || c == '"') - printer(arg, "\\"); - printer(arg, "%c", c); - } else { - switch (c) { - case '\n': - printer(arg, "\\n"); - break; - case '\r': - printer(arg, "\\r"); - break; - case '\t': - printer(arg, "\\t"); - break; - default: - printer(arg, "\\%.3o", (u8_t)c); - /* no break */ - } - } + c = *p++; + if (' ' <= c && c <= '~') { + if (c == '\\' || c == '"') + printer(arg, "\\"); + printer(arg, "%c", c); + } else { + switch (c) { + case '\n': + printer(arg, "\\n"); + break; + case '\r': + printer(arg, "\\r"); + break; + case '\t': + printer(arg, "\\t"); + break; + default: + printer(arg, "\\%.3o", (u8_t)c); + /* no break */ + } + } } printer(arg, "\""); } @@ -617,13 +617,13 @@ static void ppp_log_write(int level, char *buf) { PPPDEBUG(level, ("%s\n", buf) ); #if 0 if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) { - int n = strlen(buf); + int n = strlen(buf); - if (n > 0 && buf[n-1] == '\n') - --n; - if (write(log_to_fd, buf, n) != n - || write(log_to_fd, "\n", 1) != 1) - log_to_fd = -1; + if (n > 0 && buf[n-1] == '\n') + --n; + if (write(log_to_fd, buf, n) != n + || write(log_to_fd, "\n", 1) != 1) + log_to_fd = -1; } #endif } @@ -712,18 +712,18 @@ void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len) { */ proto = (p[0] << 8) + p[1]; if (proto < 0xC000 && (proto & ~0x8000) == proto) - return; + return; /* * don't print valid LCP echo request/reply packets if the link is up. */ if (proto == PPP_LCP && pcb->phase == PPP_PHASE_RUNNING && len >= 2 + HEADERLEN) { - unsigned char *lcp = p + 2; - int l = (lcp[2] << 8) + lcp[3]; + unsigned char *lcp = p + 2; + int l = (lcp[2] << 8) + lcp[3]; - if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP) - && l >= HEADERLEN && l <= len - 2) - return; + if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP) + && l >= HEADERLEN && l <= len - 2) + return; } ppp_dbglog("%s %P", tag, p, len); @@ -739,34 +739,34 @@ void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len) { ssize_t complete_read(int fd, void *buf, size_t count) { - size_t done; - ssize_t nb; - char *ptr = buf; - - for (done = 0; done < count; ) { - nb = read(fd, ptr, count - done); - if (nb < 0) { - if (errno == EINTR) - continue; - return -1; - } - if (nb == 0) - break; - done += nb; - ptr += nb; - } - return done; + size_t done; + ssize_t nb; + char *ptr = buf; + + for (done = 0; done < count; ) { + nb = read(fd, ptr, count - done); + if (nb < 0) { + if (errno == EINTR) + continue; + return -1; + } + if (nb == 0) + break; + done += nb; + ptr += nb; + } + return done; } /* Procedures for locking the serial device using a lock file. */ #ifndef LOCK_DIR #ifdef __linux__ -#define LOCK_DIR "/var/lock" +#define LOCK_DIR "/var/lock" #else #ifdef SVR4 -#define LOCK_DIR "/var/spool/locks" +#define LOCK_DIR "/var/spool/locks" #else -#define LOCK_DIR "/var/spool/lock" +#define LOCK_DIR "/var/spool/lock" #endif #endif #endif /* LOCK_DIR */ @@ -785,14 +785,14 @@ lock(dev) result = mklock (dev, (void *) 0); if (result == 0) { - ppp_strlcpy(lock_file, dev, sizeof(lock_file)); - return 0; + ppp_strlcpy(lock_file, dev, sizeof(lock_file)); + return 0; } if (result > 0) ppp_notice("Device %s is locked by pid %d", dev, result); else - ppp_error("Can't create lock file %s", lock_file); + ppp_error("Can't create lock file %s", lock_file); return -1; #else /* LOCKLIB */ @@ -804,83 +804,83 @@ lock(dev) struct stat sbuf; if (stat(dev, &sbuf) < 0) { - ppp_error("Can't get device number for %s: %m", dev); - return -1; + ppp_error("Can't get device number for %s: %m", dev); + return -1; } if ((sbuf.st_mode & S_IFMT) != S_IFCHR) { - ppp_error("Can't lock %s: not a character device", dev); - return -1; + ppp_error("Can't lock %s: not a character device", dev); + return -1; } ppp_slprintf(lock_file, sizeof(lock_file), "%s/LK.%03d.%03d.%03d", - LOCK_DIR, major(sbuf.st_dev), - major(sbuf.st_rdev), minor(sbuf.st_rdev)); + LOCK_DIR, major(sbuf.st_dev), + major(sbuf.st_rdev), minor(sbuf.st_rdev)); #else char *p; char lockdev[MAXPATHLEN]; if ((p = strstr(dev, "dev/")) != NULL) { - dev = p + 4; - strncpy(lockdev, dev, MAXPATHLEN-1); - lockdev[MAXPATHLEN-1] = 0; - while ((p = strrchr(lockdev, '/')) != NULL) { - *p = '_'; - } - dev = lockdev; + dev = p + 4; + strncpy(lockdev, dev, MAXPATHLEN-1); + lockdev[MAXPATHLEN-1] = 0; + while ((p = strrchr(lockdev, '/')) != NULL) { + *p = '_'; + } + dev = lockdev; } else - if ((p = strrchr(dev, '/')) != NULL) - dev = p + 1; + if ((p = strrchr(dev, '/')) != NULL) + dev = p + 1; ppp_slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev); #endif while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) { - if (errno != EEXIST) { - ppp_error("Can't create lock file %s: %m", lock_file); - break; - } - - /* Read the lock file to find out who has the device locked. */ - fd = open(lock_file, O_RDONLY, 0); - if (fd < 0) { - if (errno == ENOENT) /* This is just a timing problem. */ - continue; - ppp_error("Can't open existing lock file %s: %m", lock_file); - break; - } + if (errno != EEXIST) { + ppp_error("Can't create lock file %s: %m", lock_file); + break; + } + + /* Read the lock file to find out who has the device locked. */ + fd = open(lock_file, O_RDONLY, 0); + if (fd < 0) { + if (errno == ENOENT) /* This is just a timing problem. */ + continue; + ppp_error("Can't open existing lock file %s: %m", lock_file); + break; + } #ifndef LOCK_BINARY - n = read(fd, lock_buffer, 11); + n = read(fd, lock_buffer, 11); #else - n = read(fd, &pid, sizeof(pid)); + n = read(fd, &pid, sizeof(pid)); #endif /* LOCK_BINARY */ - close(fd); - fd = -1; - if (n <= 0) { - ppp_error("Can't read pid from lock file %s", lock_file); - break; - } - - /* See if the process still exists. */ + close(fd); + fd = -1; + if (n <= 0) { + ppp_error("Can't read pid from lock file %s", lock_file); + break; + } + + /* See if the process still exists. */ #ifndef LOCK_BINARY - lock_buffer[n] = 0; - pid = atoi(lock_buffer); + lock_buffer[n] = 0; + pid = atoi(lock_buffer); #endif /* LOCK_BINARY */ - if (pid == getpid()) - return 1; /* somebody else locked it for us */ - if (pid == 0 - || (kill(pid, 0) == -1 && errno == ESRCH)) { - if (unlink (lock_file) == 0) { - ppp_notice("Removed stale lock on %s (pid %d)", dev, pid); - continue; - } - ppp_warn("Couldn't remove stale lock on %s", dev); - } else - ppp_notice("Device %s is locked by pid %d", dev, pid); - break; + if (pid == getpid()) + return 1; /* somebody else locked it for us */ + if (pid == 0 + || (kill(pid, 0) == -1 && errno == ESRCH)) { + if (unlink (lock_file) == 0) { + ppp_notice("Removed stale lock on %s (pid %d)", dev, pid); + continue; + } + ppp_warn("Couldn't remove stale lock on %s", dev); + } else + ppp_notice("Device %s is locked by pid %d", dev, pid); + break; } if (fd < 0) { - lock_file[0] = 0; - return -1; + lock_file[0] = 0; + return -1; } pid = getpid(); @@ -918,12 +918,12 @@ relock(pid) char lock_buffer[12]; if (lock_file[0] == 0) - return -1; + return -1; fd = open(lock_file, O_WRONLY, 0); if (fd < 0) { - ppp_error("Couldn't reopen lock file %s: %m", lock_file); - lock_file[0] = 0; - return -1; + ppp_error("Couldn't reopen lock file %s: %m", lock_file); + lock_file[0] = 0; + return -1; } #ifndef LOCK_BINARY @@ -946,11 +946,11 @@ unlock() { if (lock_file[0]) { #ifdef LOCKLIB - (void) rmlock(lock_file, (void *) 0); + (void) rmlock(lock_file, (void *) 0); #else - unlink(lock_file); + unlink(lock_file); #endif - lock_file[0] = 0; + lock_file[0] = 0; } } diff --git a/components/net/lwip-2.0.2/test/fuzz/fuzz.c b/components/net/lwip-2.0.2/test/fuzz/fuzz.c index a9157f1385..ecf81d7e21 100644 --- a/components/net/lwip-2.0.2/test/fuzz/fuzz.c +++ b/components/net/lwip-2.0.2/test/fuzz/fuzz.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Erik Ekman * */ diff --git a/components/net/lwip-2.0.2/test/fuzz/lwipopts.h b/components/net/lwip-2.0.2/test/fuzz/lwipopts.h index 4aff09bad6..1e355599e5 100644 --- a/components/net/lwip-2.0.2/test/fuzz/lwipopts.h +++ b/components/net/lwip-2.0.2/test/fuzz/lwipopts.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.0.2/test/unit/dhcp/test_dhcp.c b/components/net/lwip-2.0.2/test/unit/dhcp/test_dhcp.c index 47aaa08420..a9a2507937 100644 --- a/components/net/lwip-2.0.2/test/unit/dhcp/test_dhcp.c +++ b/components/net/lwip-2.0.2/test/unit/dhcp/test_dhcp.c @@ -888,7 +888,7 @@ START_TEST(test_dhcp_nak_no_endmarker) xid = htonl(netif_dhcp_data(&net_test)->xid); memcpy(&dhcp_offer[46], &xid, 4); /* insert correct transaction id */ send_pkt(&net_test, dhcp_offer, sizeof(dhcp_offer)); - + fail_unless(netif_dhcp_data(&net_test)->state == DHCP_STATE_REQUESTING); fail_unless(txpacket == 2); /* No more sent */ diff --git a/components/net/lwip-2.0.2/test/unit/lwipopts.h b/components/net/lwip-2.0.2/test/unit/lwipopts.h index 25252b426c..ea0ff2e0b5 100644 --- a/components/net/lwip-2.0.2/test/unit/lwipopts.h +++ b/components/net/lwip-2.0.2/test/unit/lwipopts.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.0.2/test/unit/tcp/tcp_helper.c b/components/net/lwip-2.0.2/test/unit/tcp/tcp_helper.c index 64121ca8f3..1512b03cd1 100644 --- a/components/net/lwip-2.0.2/test/unit/tcp/tcp_helper.c +++ b/components/net/lwip-2.0.2/test/unit/tcp/tcp_helper.c @@ -146,13 +146,13 @@ tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, ip_addr_t* local_ip, /* @todo: are these all states? */ /* @todo: remove from previous list */ pcb->state = state; - + iss = tcp_next_iss(pcb); pcb->snd_wl2 = iss; pcb->snd_nxt = iss; pcb->lastack = iss; pcb->snd_lbb = iss; - + if (state == ESTABLISHED) { TCP_REG(&tcp_active_pcbs, pcb); ip_addr_copy(pcb->local_ip, *local_ip); diff --git a/components/net/lwip-2.0.2/test/unit/tcp/test_tcp.c b/components/net/lwip-2.0.2/test/unit/tcp/test_tcp.c index d99b807d96..86dd6cc95c 100644 --- a/components/net/lwip-2.0.2/test/unit/tcp/test_tcp.c +++ b/components/net/lwip-2.0.2/test/unit/tcp/test_tcp.c @@ -281,7 +281,7 @@ START_TEST(test_tcp_fast_retx_recover) EXPECT_RET(pcb->dupacks == 3); memset(&txcounters, 0, sizeof(txcounters)); /* @todo: check expected data?*/ - + /* send data5, not output yet */ err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); EXPECT_RET(err == ERR_OK); diff --git a/components/net/lwip-2.1.2/src/api/tcpip.c b/components/net/lwip-2.1.2/src/api/tcpip.c index 743553a587..b0382e83c4 100644 --- a/components/net/lwip-2.1.2/src/api/tcpip.c +++ b/components/net/lwip-2.1.2/src/api/tcpip.c @@ -519,7 +519,7 @@ tcpip_api_call(tcpip_api_call_fn fn, struct tcpip_api_call_data *call) * e.g. the message is allocated once and posted several times from an IRQ * using tcpip_callbackmsg_trycallback(). * Example usage: Trigger execution of an ethernet IRQ DPC routine in lwIP thread context. - * + * * @param function the function to call * @param ctx parameter passed to function * @return a struct pointer to pass to tcpip_callbackmsg_trycallback(). diff --git a/components/net/lwip-2.1.2/src/apps/altcp_tls/altcp_tls_mbedtls.c b/components/net/lwip-2.1.2/src/apps/altcp_tls/altcp_tls_mbedtls.c index d642decb54..d5ff3fe4f0 100644 --- a/components/net/lwip-2.1.2/src/apps/altcp_tls/altcp_tls_mbedtls.c +++ b/components/net/lwip-2.1.2/src/apps/altcp_tls/altcp_tls_mbedtls.c @@ -886,7 +886,7 @@ altcp_tls_free_config(struct altcp_tls_config *conf) } if (conf->ca) { mbedtls_x509_crt_free(conf->ca); - } + } altcp_mbedtls_free_config(conf); } diff --git a/components/net/lwip-2.1.2/src/apps/http/http_client.c b/components/net/lwip-2.1.2/src/apps/http/http_client.c index 82da60d73a..6fbb691510 100644 --- a/components/net/lwip-2.1.2/src/apps/http/http_client.c +++ b/components/net/lwip-2.1.2/src/apps/http/http_client.c @@ -615,7 +615,7 @@ httpc_init_connection_addr(httpc_state_t **connection, const httpc_connection_t } /** - * @ingroup httpc + * @ingroup httpc * HTTP client API: get a file by passing server IP address * * @param server_addr IP address of the server to connect @@ -660,7 +660,7 @@ httpc_get_file(const ip_addr_t* server_addr, u16_t port, const char* uri, const } /** - * @ingroup httpc + * @ingroup httpc * HTTP client API: get a file by passing server name as string (DNS name or IP address string) * * @param server_name server name as string (DNS name or IP address string) @@ -802,7 +802,7 @@ httpc_fs_tcp_recv(void *arg, struct altcp_pcb *pcb, struct pbuf *p, err_t err) } /** - * @ingroup httpc + * @ingroup httpc * HTTP client API: get a file to disk by passing server IP address * * @param server_addr IP address of the server to connect @@ -854,7 +854,7 @@ httpc_get_file_to_disk(const ip_addr_t* server_addr, u16_t port, const char* uri } /** - * @ingroup httpc + * @ingroup httpc * HTTP client API: get a file to disk by passing server name as string (DNS name or IP address string) * * @param server_name server name as string (DNS name or IP address string) diff --git a/components/net/lwip-2.1.2/src/apps/http/httpd.c b/components/net/lwip-2.1.2/src/apps/http/httpd.c index ccc9ba7284..6e53b48412 100644 --- a/components/net/lwip-2.1.2/src/apps/http/httpd.c +++ b/components/net/lwip-2.1.2/src/apps/http/httpd.c @@ -233,7 +233,7 @@ struct http_ssi_state { struct http_ssi_tag_description { const char *lead_in; - const char *lead_out; + const char *lead_out; }; #endif /* LWIP_HTTPD_SSI */ diff --git a/components/net/lwip-2.1.2/src/apps/http/makefsdata/tinydir.h b/components/net/lwip-2.1.2/src/apps/http/makefsdata/tinydir.h index 32ae5e84a9..88043e8e93 100644 --- a/components/net/lwip-2.1.2/src/apps/http/makefsdata/tinydir.h +++ b/components/net/lwip-2.1.2/src/apps/http/makefsdata/tinydir.h @@ -121,7 +121,7 @@ extern "C" { /* readdir_r is a POSIX-only function, and may not be available under various * environments/settings, e.g. MinGW. Use readdir fallback */ #if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE ||\ - _POSIX_SOURCE + _POSIX_SOURCE # define _TINYDIR_HAS_READDIR_R #endif #if _POSIX_C_SOURCE >= 200112L @@ -129,16 +129,16 @@ extern "C" { # include #endif #if _BSD_SOURCE || _SVID_SOURCE || \ - (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) + (_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700) # define _TINYDIR_HAS_DIRFD # include #endif #if defined _TINYDIR_HAS_FPATHCONF && defined _TINYDIR_HAS_DIRFD &&\ - defined _PC_NAME_MAX + defined _PC_NAME_MAX # define _TINYDIR_USE_FPATHCONF #endif #if defined __MINGW32__ || !defined _TINYDIR_HAS_READDIR_R ||\ - !(defined _TINYDIR_USE_FPATHCONF || defined NAME_MAX) + !(defined _TINYDIR_USE_FPATHCONF || defined NAME_MAX) # define _TINYDIR_USE_READDIR #endif @@ -172,42 +172,42 @@ extern "C" { #endif #if !defined(_TINYDIR_MALLOC) - #define _TINYDIR_MALLOC(_size) malloc(_size) - #define _TINYDIR_FREE(_ptr) free(_ptr) + #define _TINYDIR_MALLOC(_size) malloc(_size) + #define _TINYDIR_FREE(_ptr) free(_ptr) #endif /* !defined(_TINYDIR_MALLOC) */ typedef struct tinydir_file { - _tinydir_char_t path[_TINYDIR_PATH_MAX]; - _tinydir_char_t name[_TINYDIR_FILENAME_MAX]; - _tinydir_char_t *extension; - int is_dir; - int is_reg; + _tinydir_char_t path[_TINYDIR_PATH_MAX]; + _tinydir_char_t name[_TINYDIR_FILENAME_MAX]; + _tinydir_char_t *extension; + int is_dir; + int is_reg; #ifndef _MSC_VER #ifdef __MINGW32__ - struct _stat _s; + struct _stat _s; #else - struct stat _s; + struct stat _s; #endif #endif } tinydir_file; typedef struct tinydir_dir { - _tinydir_char_t path[_TINYDIR_PATH_MAX]; - int has_next; - size_t n_files; + _tinydir_char_t path[_TINYDIR_PATH_MAX]; + int has_next; + size_t n_files; - tinydir_file *_files; + tinydir_file *_files; #ifdef _MSC_VER - HANDLE _h; - WIN32_FIND_DATA _f; + HANDLE _h; + WIN32_FIND_DATA _f; #else - _TINYDIR_DIR *_d; - struct _tinydir_dirent *_e; + _TINYDIR_DIR *_d; + struct _tinydir_dirent *_e; #ifndef _TINYDIR_USE_READDIR - struct _tinydir_dirent *_ep; + struct _tinydir_dirent *_ep; #endif #endif } tinydir_dir; @@ -252,184 +252,184 @@ int tinydir_open(tinydir_dir *dir, const _tinydir_char_t *path) { #ifndef _MSC_VER #ifndef _TINYDIR_USE_READDIR - int error; - int size; /* using int size */ + int error; + int size; /* using int size */ #endif #else - _tinydir_char_t path_buf[_TINYDIR_PATH_MAX]; -#endif - _tinydir_char_t *pathp; - - if (dir == NULL || path == NULL || _tinydir_strlen(path) == 0) - { - errno = EINVAL; - return -1; - } - if (_tinydir_strlen(path) + _TINYDIR_PATH_EXTRA >= _TINYDIR_PATH_MAX) - { - errno = ENAMETOOLONG; - return -1; - } - - /* initialise dir */ - dir->_files = NULL; + _tinydir_char_t path_buf[_TINYDIR_PATH_MAX]; +#endif + _tinydir_char_t *pathp; + + if (dir == NULL || path == NULL || _tinydir_strlen(path) == 0) + { + errno = EINVAL; + return -1; + } + if (_tinydir_strlen(path) + _TINYDIR_PATH_EXTRA >= _TINYDIR_PATH_MAX) + { + errno = ENAMETOOLONG; + return -1; + } + + /* initialise dir */ + dir->_files = NULL; #ifdef _MSC_VER - dir->_h = INVALID_HANDLE_VALUE; + dir->_h = INVALID_HANDLE_VALUE; #else - dir->_d = NULL; + dir->_d = NULL; #ifndef _TINYDIR_USE_READDIR - dir->_ep = NULL; + dir->_ep = NULL; #endif #endif - tinydir_close(dir); + tinydir_close(dir); - _tinydir_strcpy(dir->path, path); - /* Remove trailing slashes */ - pathp = &dir->path[_tinydir_strlen(dir->path) - 1]; - while (pathp != dir->path && (*pathp == TINYDIR_STRING('\\') || *pathp == TINYDIR_STRING('/'))) - { - *pathp = TINYDIR_STRING('\0'); - pathp++; - } + _tinydir_strcpy(dir->path, path); + /* Remove trailing slashes */ + pathp = &dir->path[_tinydir_strlen(dir->path) - 1]; + while (pathp != dir->path && (*pathp == TINYDIR_STRING('\\') || *pathp == TINYDIR_STRING('/'))) + { + *pathp = TINYDIR_STRING('\0'); + pathp++; + } #ifdef _MSC_VER - _tinydir_strcpy(path_buf, dir->path); - _tinydir_strcat(path_buf, TINYDIR_STRING("\\*")); + _tinydir_strcpy(path_buf, dir->path); + _tinydir_strcat(path_buf, TINYDIR_STRING("\\*")); #if (defined WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) - dir->_h = FindFirstFileEx(path_buf, FindExInfoStandard, &dir->_f, FindExSearchNameMatch, NULL, 0); + dir->_h = FindFirstFileEx(path_buf, FindExInfoStandard, &dir->_f, FindExSearchNameMatch, NULL, 0); #else - dir->_h = FindFirstFile(path_buf, &dir->_f); + dir->_h = FindFirstFile(path_buf, &dir->_f); #endif - if (dir->_h == INVALID_HANDLE_VALUE) - { - errno = ENOENT; + if (dir->_h == INVALID_HANDLE_VALUE) + { + errno = ENOENT; #else - dir->_d = _tinydir_opendir(path); - if (dir->_d == NULL) - { + dir->_d = _tinydir_opendir(path); + if (dir->_d == NULL) + { #endif - goto bail; - } + goto bail; + } - /* read first file */ - dir->has_next = 1; + /* read first file */ + dir->has_next = 1; #ifndef _MSC_VER #ifdef _TINYDIR_USE_READDIR - dir->_e = _tinydir_readdir(dir->_d); + dir->_e = _tinydir_readdir(dir->_d); #else - /* allocate dirent buffer for readdir_r */ - size = _tinydir_dirent_buf_size(dir->_d); /* conversion to int */ - if (size == -1) return -1; - dir->_ep = (struct _tinydir_dirent*)_TINYDIR_MALLOC(size); - if (dir->_ep == NULL) return -1; + /* allocate dirent buffer for readdir_r */ + size = _tinydir_dirent_buf_size(dir->_d); /* conversion to int */ + if (size == -1) return -1; + dir->_ep = (struct _tinydir_dirent*)_TINYDIR_MALLOC(size); + if (dir->_ep == NULL) return -1; - error = readdir_r(dir->_d, dir->_ep, &dir->_e); - if (error != 0) return -1; + error = readdir_r(dir->_d, dir->_ep, &dir->_e); + if (error != 0) return -1; #endif - if (dir->_e == NULL) - { - dir->has_next = 0; - } + if (dir->_e == NULL) + { + dir->has_next = 0; + } #endif - return 0; + return 0; bail: - tinydir_close(dir); - return -1; + tinydir_close(dir); + return -1; } _TINYDIR_FUNC int tinydir_open_sorted(tinydir_dir *dir, const _tinydir_char_t *path) { - /* Count the number of files first, to pre-allocate the files array */ - size_t n_files = 0; - if (tinydir_open(dir, path) == -1) - { - return -1; - } - while (dir->has_next) - { - n_files++; - if (tinydir_next(dir) == -1) - { - goto bail; - } - } - tinydir_close(dir); - - if (tinydir_open(dir, path) == -1) - { - return -1; - } - - dir->n_files = 0; - dir->_files = (tinydir_file *)_TINYDIR_MALLOC(sizeof *dir->_files * n_files); - if (dir->_files == NULL) - { - goto bail; - } - while (dir->has_next) - { - tinydir_file *p_file; - dir->n_files++; - - p_file = &dir->_files[dir->n_files - 1]; - if (tinydir_readfile(dir, p_file) == -1) - { - goto bail; - } - - if (tinydir_next(dir) == -1) - { - goto bail; - } - - /* Just in case the number of files has changed between the first and - second reads, terminate without writing into unallocated memory */ - if (dir->n_files == n_files) - { - break; - } - } - - qsort(dir->_files, dir->n_files, sizeof(tinydir_file), _tinydir_file_cmp); - - return 0; + /* Count the number of files first, to pre-allocate the files array */ + size_t n_files = 0; + if (tinydir_open(dir, path) == -1) + { + return -1; + } + while (dir->has_next) + { + n_files++; + if (tinydir_next(dir) == -1) + { + goto bail; + } + } + tinydir_close(dir); + + if (tinydir_open(dir, path) == -1) + { + return -1; + } + + dir->n_files = 0; + dir->_files = (tinydir_file *)_TINYDIR_MALLOC(sizeof *dir->_files * n_files); + if (dir->_files == NULL) + { + goto bail; + } + while (dir->has_next) + { + tinydir_file *p_file; + dir->n_files++; + + p_file = &dir->_files[dir->n_files - 1]; + if (tinydir_readfile(dir, p_file) == -1) + { + goto bail; + } + + if (tinydir_next(dir) == -1) + { + goto bail; + } + + /* Just in case the number of files has changed between the first and + second reads, terminate without writing into unallocated memory */ + if (dir->n_files == n_files) + { + break; + } + } + + qsort(dir->_files, dir->n_files, sizeof(tinydir_file), _tinydir_file_cmp); + + return 0; bail: - tinydir_close(dir); - return -1; + tinydir_close(dir); + return -1; } _TINYDIR_FUNC void tinydir_close(tinydir_dir *dir) { - if (dir == NULL) - { - return; - } - - memset(dir->path, 0, sizeof(dir->path)); - dir->has_next = 0; - dir->n_files = 0; - _TINYDIR_FREE(dir->_files); - dir->_files = NULL; + if (dir == NULL) + { + return; + } + + memset(dir->path, 0, sizeof(dir->path)); + dir->has_next = 0; + dir->n_files = 0; + _TINYDIR_FREE(dir->_files); + dir->_files = NULL; #ifdef _MSC_VER - if (dir->_h != INVALID_HANDLE_VALUE) - { - FindClose(dir->_h); - } - dir->_h = INVALID_HANDLE_VALUE; + if (dir->_h != INVALID_HANDLE_VALUE) + { + FindClose(dir->_h); + } + dir->_h = INVALID_HANDLE_VALUE; #else - if (dir->_d) - { - _tinydir_closedir(dir->_d); - } - dir->_d = NULL; - dir->_e = NULL; + if (dir->_d) + { + _tinydir_closedir(dir->_d); + } + dir->_d = NULL; + dir->_e = NULL; #ifndef _TINYDIR_USE_READDIR - _TINYDIR_FREE(dir->_ep); - dir->_ep = NULL; + _TINYDIR_FREE(dir->_ep); + dir->_ep = NULL; #endif #endif } @@ -437,323 +437,323 @@ void tinydir_close(tinydir_dir *dir) _TINYDIR_FUNC int tinydir_next(tinydir_dir *dir) { - if (dir == NULL) - { - errno = EINVAL; - return -1; - } - if (!dir->has_next) - { - errno = ENOENT; - return -1; - } + if (dir == NULL) + { + errno = EINVAL; + return -1; + } + if (!dir->has_next) + { + errno = ENOENT; + return -1; + } #ifdef _MSC_VER - if (FindNextFile(dir->_h, &dir->_f) == 0) + if (FindNextFile(dir->_h, &dir->_f) == 0) #else #ifdef _TINYDIR_USE_READDIR - dir->_e = _tinydir_readdir(dir->_d); + dir->_e = _tinydir_readdir(dir->_d); #else - if (dir->_ep == NULL) - { - return -1; - } - if (readdir_r(dir->_d, dir->_ep, &dir->_e) != 0) - { - return -1; - } -#endif - if (dir->_e == NULL) -#endif - { - dir->has_next = 0; + if (dir->_ep == NULL) + { + return -1; + } + if (readdir_r(dir->_d, dir->_ep, &dir->_e) != 0) + { + return -1; + } +#endif + if (dir->_e == NULL) +#endif + { + dir->has_next = 0; #ifdef _MSC_VER - if (GetLastError() != ERROR_SUCCESS && - GetLastError() != ERROR_NO_MORE_FILES) - { - tinydir_close(dir); - errno = EIO; - return -1; - } + if (GetLastError() != ERROR_SUCCESS && + GetLastError() != ERROR_NO_MORE_FILES) + { + tinydir_close(dir); + errno = EIO; + return -1; + } #endif - } + } - return 0; + return 0; } _TINYDIR_FUNC int tinydir_readfile(const tinydir_dir *dir, tinydir_file *file) { - if (dir == NULL || file == NULL) - { - errno = EINVAL; - return -1; - } + if (dir == NULL || file == NULL) + { + errno = EINVAL; + return -1; + } #ifdef _MSC_VER - if (dir->_h == INVALID_HANDLE_VALUE) + if (dir->_h == INVALID_HANDLE_VALUE) #else - if (dir->_e == NULL) -#endif - { - errno = ENOENT; - return -1; - } - if (_tinydir_strlen(dir->path) + - _tinydir_strlen( + if (dir->_e == NULL) +#endif + { + errno = ENOENT; + return -1; + } + if (_tinydir_strlen(dir->path) + + _tinydir_strlen( #ifdef _MSC_VER - dir->_f.cFileName + dir->_f.cFileName #else - dir->_e->d_name -#endif - ) + 1 + _TINYDIR_PATH_EXTRA >= - _TINYDIR_PATH_MAX) - { - /* the path for the file will be too long */ - errno = ENAMETOOLONG; - return -1; - } - if (_tinydir_strlen( + dir->_e->d_name +#endif + ) + 1 + _TINYDIR_PATH_EXTRA >= + _TINYDIR_PATH_MAX) + { + /* the path for the file will be too long */ + errno = ENAMETOOLONG; + return -1; + } + if (_tinydir_strlen( #ifdef _MSC_VER - dir->_f.cFileName + dir->_f.cFileName #else - dir->_e->d_name + dir->_e->d_name #endif - ) >= _TINYDIR_FILENAME_MAX) - { - errno = ENAMETOOLONG; - return -1; - } + ) >= _TINYDIR_FILENAME_MAX) + { + errno = ENAMETOOLONG; + return -1; + } - _tinydir_strcpy(file->path, dir->path); - _tinydir_strcat(file->path, TINYDIR_STRING("/")); - _tinydir_strcpy(file->name, + _tinydir_strcpy(file->path, dir->path); + _tinydir_strcat(file->path, TINYDIR_STRING("/")); + _tinydir_strcpy(file->name, #ifdef _MSC_VER - dir->_f.cFileName + dir->_f.cFileName #else - dir->_e->d_name + dir->_e->d_name #endif - ); - _tinydir_strcat(file->path, file->name); + ); + _tinydir_strcat(file->path, file->name); #ifndef _MSC_VER #ifdef __MINGW32__ - if (_tstat( + if (_tstat( #else - if (stat( + if (stat( #endif - file->path, &file->_s) == -1) - { - return -1; - } + file->path, &file->_s) == -1) + { + return -1; + } #endif - _tinydir_get_ext(file); + _tinydir_get_ext(file); - file->is_dir = + file->is_dir = #ifdef _MSC_VER - !!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); + !!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); #else - S_ISDIR(file->_s.st_mode); + S_ISDIR(file->_s.st_mode); #endif - file->is_reg = + file->is_reg = #ifdef _MSC_VER - !!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || - ( - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) && - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) && + !!(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) || + ( + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) && + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) && #ifdef FILE_ATTRIBUTE_INTEGRITY_STREAM - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_INTEGRITY_STREAM) && + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_INTEGRITY_STREAM) && #endif #ifdef FILE_ATTRIBUTE_NO_SCRUB_DATA - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_NO_SCRUB_DATA) && + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_NO_SCRUB_DATA) && #endif - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) && - !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)); + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) && + !(dir->_f.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)); #else - S_ISREG(file->_s.st_mode); + S_ISREG(file->_s.st_mode); #endif - return 0; + return 0; } _TINYDIR_FUNC int tinydir_readfile_n(const tinydir_dir *dir, tinydir_file *file, size_t i) { - if (dir == NULL || file == NULL) - { - errno = EINVAL; - return -1; - } - if (i >= dir->n_files) - { - errno = ENOENT; - return -1; - } - - memcpy(file, &dir->_files[i], sizeof(tinydir_file)); - _tinydir_get_ext(file); - - return 0; + if (dir == NULL || file == NULL) + { + errno = EINVAL; + return -1; + } + if (i >= dir->n_files) + { + errno = ENOENT; + return -1; + } + + memcpy(file, &dir->_files[i], sizeof(tinydir_file)); + _tinydir_get_ext(file); + + return 0; } _TINYDIR_FUNC int tinydir_open_subdir_n(tinydir_dir *dir, size_t i) { - _tinydir_char_t path[_TINYDIR_PATH_MAX]; - if (dir == NULL) - { - errno = EINVAL; - return -1; - } - if (i >= dir->n_files || !dir->_files[i].is_dir) - { - errno = ENOENT; - return -1; - } - - _tinydir_strcpy(path, dir->_files[i].path); - tinydir_close(dir); - if (tinydir_open_sorted(dir, path) == -1) - { - return -1; - } - - return 0; + _tinydir_char_t path[_TINYDIR_PATH_MAX]; + if (dir == NULL) + { + errno = EINVAL; + return -1; + } + if (i >= dir->n_files || !dir->_files[i].is_dir) + { + errno = ENOENT; + return -1; + } + + _tinydir_strcpy(path, dir->_files[i].path); + tinydir_close(dir); + if (tinydir_open_sorted(dir, path) == -1) + { + return -1; + } + + return 0; } /* Open a single file given its path */ _TINYDIR_FUNC int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path) { - tinydir_dir dir; - int result = 0; - int found = 0; - _tinydir_char_t dir_name_buf[_TINYDIR_PATH_MAX]; - _tinydir_char_t file_name_buf[_TINYDIR_FILENAME_MAX]; - _tinydir_char_t *dir_name; - _tinydir_char_t *base_name; + tinydir_dir dir; + int result = 0; + int found = 0; + _tinydir_char_t dir_name_buf[_TINYDIR_PATH_MAX]; + _tinydir_char_t file_name_buf[_TINYDIR_FILENAME_MAX]; + _tinydir_char_t *dir_name; + _tinydir_char_t *base_name; #if (defined _MSC_VER || defined __MINGW32__) - _tinydir_char_t drive_buf[_TINYDIR_PATH_MAX]; - _tinydir_char_t ext_buf[_TINYDIR_FILENAME_MAX]; -#endif - - if (file == NULL || path == NULL || _tinydir_strlen(path) == 0) - { - errno = EINVAL; - return -1; - } - if (_tinydir_strlen(path) + _TINYDIR_PATH_EXTRA >= _TINYDIR_PATH_MAX) - { - errno = ENAMETOOLONG; - return -1; - } - - /* Get the parent path */ + _tinydir_char_t drive_buf[_TINYDIR_PATH_MAX]; + _tinydir_char_t ext_buf[_TINYDIR_FILENAME_MAX]; +#endif + + if (file == NULL || path == NULL || _tinydir_strlen(path) == 0) + { + errno = EINVAL; + return -1; + } + if (_tinydir_strlen(path) + _TINYDIR_PATH_EXTRA >= _TINYDIR_PATH_MAX) + { + errno = ENAMETOOLONG; + return -1; + } + + /* Get the parent path */ #if (defined _MSC_VER || defined __MINGW32__) #if ((defined _MSC_VER) && (_MSC_VER >= 1400)) - _tsplitpath_s( - path, - drive_buf, _TINYDIR_DRIVE_MAX, - dir_name_buf, _TINYDIR_FILENAME_MAX, - file_name_buf, _TINYDIR_FILENAME_MAX, - ext_buf, _TINYDIR_FILENAME_MAX); + _tsplitpath_s( + path, + drive_buf, _TINYDIR_DRIVE_MAX, + dir_name_buf, _TINYDIR_FILENAME_MAX, + file_name_buf, _TINYDIR_FILENAME_MAX, + ext_buf, _TINYDIR_FILENAME_MAX); #else - _tsplitpath( - path, - drive_buf, - dir_name_buf, - file_name_buf, - ext_buf); + _tsplitpath( + path, + drive_buf, + dir_name_buf, + file_name_buf, + ext_buf); #endif /* _splitpath_s not work fine with only filename and widechar support */ #ifdef _UNICODE - if (drive_buf[0] == L'\xFEFE') - drive_buf[0] = '\0'; - if (dir_name_buf[0] == L'\xFEFE') - dir_name_buf[0] = '\0'; -#endif - - if (errno) - { - errno = EINVAL; - return -1; - } - /* Emulate the behavior of dirname by returning "." for dir name if it's - empty */ - if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0') - { - _tinydir_strcpy(dir_name_buf, TINYDIR_STRING(".")); - } - /* Concatenate the drive letter and dir name to form full dir name */ - _tinydir_strcat(drive_buf, dir_name_buf); - dir_name = drive_buf; - /* Concatenate the file name and extension to form base name */ - _tinydir_strcat(file_name_buf, ext_buf); - base_name = file_name_buf; + if (drive_buf[0] == L'\xFEFE') + drive_buf[0] = '\0'; + if (dir_name_buf[0] == L'\xFEFE') + dir_name_buf[0] = '\0'; +#endif + + if (errno) + { + errno = EINVAL; + return -1; + } + /* Emulate the behavior of dirname by returning "." for dir name if it's + empty */ + if (drive_buf[0] == '\0' && dir_name_buf[0] == '\0') + { + _tinydir_strcpy(dir_name_buf, TINYDIR_STRING(".")); + } + /* Concatenate the drive letter and dir name to form full dir name */ + _tinydir_strcat(drive_buf, dir_name_buf); + dir_name = drive_buf; + /* Concatenate the file name and extension to form base name */ + _tinydir_strcat(file_name_buf, ext_buf); + base_name = file_name_buf; #else - _tinydir_strcpy(dir_name_buf, path); - dir_name = dirname(dir_name_buf); - _tinydir_strcpy(file_name_buf, path); - base_name =basename(file_name_buf); -#endif - - /* Open the parent directory */ - if (tinydir_open(&dir, dir_name) == -1) - { - return -1; - } - - /* Read through the parent directory and look for the file */ - while (dir.has_next) - { - if (tinydir_readfile(&dir, file) == -1) - { - result = -1; - goto bail; - } - if (_tinydir_strcmp(file->name, base_name) == 0) - { - /* File found */ - found = 1; - break; - } - tinydir_next(&dir); - } - if (!found) - { - result = -1; - errno = ENOENT; - } + _tinydir_strcpy(dir_name_buf, path); + dir_name = dirname(dir_name_buf); + _tinydir_strcpy(file_name_buf, path); + base_name =basename(file_name_buf); +#endif + + /* Open the parent directory */ + if (tinydir_open(&dir, dir_name) == -1) + { + return -1; + } + + /* Read through the parent directory and look for the file */ + while (dir.has_next) + { + if (tinydir_readfile(&dir, file) == -1) + { + result = -1; + goto bail; + } + if (_tinydir_strcmp(file->name, base_name) == 0) + { + /* File found */ + found = 1; + break; + } + tinydir_next(&dir); + } + if (!found) + { + result = -1; + errno = ENOENT; + } bail: - tinydir_close(&dir); - return result; + tinydir_close(&dir); + return result; } _TINYDIR_FUNC void _tinydir_get_ext(tinydir_file *file) { - _tinydir_char_t *period = _tinydir_strrchr(file->name, TINYDIR_STRING('.')); - if (period == NULL) - { - file->extension = &(file->name[_tinydir_strlen(file->name)]); - } - else - { - file->extension = period + 1; - } + _tinydir_char_t *period = _tinydir_strrchr(file->name, TINYDIR_STRING('.')); + if (period == NULL) + { + file->extension = &(file->name[_tinydir_strlen(file->name)]); + } + else + { + file->extension = period + 1; + } } _TINYDIR_FUNC int _tinydir_file_cmp(const void *a, const void *b) { - const tinydir_file *fa = (const tinydir_file *)a; - const tinydir_file *fb = (const tinydir_file *)b; - if (fa->is_dir != fb->is_dir) - { - return -(fa->is_dir - fb->is_dir); - } - return _tinydir_strncmp(fa->name, fb->name, _TINYDIR_FILENAME_MAX); + const tinydir_file *fa = (const tinydir_file *)a; + const tinydir_file *fb = (const tinydir_file *)b; + if (fa->is_dir != fb->is_dir) + { + return -(fa->is_dir - fb->is_dir); + } + return _tinydir_strncmp(fa->name, fb->name, _TINYDIR_FILENAME_MAX); } #ifndef _MSC_VER @@ -772,27 +772,27 @@ from https://womble.decadent.org.uk/readdir_r-advisory.html _TINYDIR_FUNC size_t _tinydir_dirent_buf_size(_TINYDIR_DIR *dirp) { - long name_max; - size_t name_end; - /* parameter may be unused */ - (void)dirp; + long name_max; + size_t name_end; + /* parameter may be unused */ + (void)dirp; #if defined _TINYDIR_USE_FPATHCONF - name_max = fpathconf(dirfd(dirp), _PC_NAME_MAX); - if (name_max == -1) + name_max = fpathconf(dirfd(dirp), _PC_NAME_MAX); + if (name_max == -1) #if defined(NAME_MAX) - name_max = (NAME_MAX > 255) ? NAME_MAX : 255; + name_max = (NAME_MAX > 255) ? NAME_MAX : 255; #else - return (size_t)(-1); + return (size_t)(-1); #endif #elif defined(NAME_MAX) - name_max = (NAME_MAX > 255) ? NAME_MAX : 255; + name_max = (NAME_MAX > 255) ? NAME_MAX : 255; #else #error "buffer size for readdir_r cannot be determined" #endif - name_end = (size_t)offsetof(struct _tinydir_dirent, d_name) + name_max + 1; - return (name_end > sizeof(struct _tinydir_dirent) ? - name_end : sizeof(struct _tinydir_dirent)); + name_end = (size_t)offsetof(struct _tinydir_dirent, d_name) + name_max + 1; + return (name_end > sizeof(struct _tinydir_dirent) ? + name_end : sizeof(struct _tinydir_dirent)); } #endif #endif diff --git a/components/net/lwip-2.1.2/src/apps/smtp/smtp.c b/components/net/lwip-2.1.2/src/apps/smtp/smtp.c index 55303c35d4..2aa21ce045 100644 --- a/components/net/lwip-2.1.2/src/apps/smtp/smtp.c +++ b/components/net/lwip-2.1.2/src/apps/smtp/smtp.c @@ -1,12 +1,12 @@ /** * @file * SMTP client module - * + * * Author: Simon Goldschmidt * * @defgroup smtp SMTP client * @ingroup apps - * + * * This is simple SMTP client for raw API. * It is a minimal implementation of SMTP as specified in RFC 5321. * @@ -29,7 +29,7 @@ * When using from any other thread than the tcpip_thread (for NO_SYS==0), use * smtp_send_mail_int()! - * + * * SMTP_BODYDH usage: @code{.c} int my_smtp_bodydh_fn(void *arg, struct smtp_bodydh *bdh) @@ -42,11 +42,11 @@ ++bdh->state; return BDH_WORKING; } - - smtp_send_mail_bodycback("sender", "recipient", "subject", + + smtp_send_mail_bodycback("sender", "recipient", "subject", my_smtp_bodydh_fn, my_smtp_result_fn, some_argument); @endcode - * + * * @todo: * - attachments (the main difficulty here is streaming base64-encoding to * prevent having to allocate a buffer for the whole encoded file at once) diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h index 2c22d3a873..320beb53e0 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/cc.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/cc.h @@ -53,17 +53,17 @@ /* some errno not defined in newlib */ #define ENSRNOTFOUND 163 /* Domain name not found */ /* WARNING: ESHUTDOWN also not defined in newlib. We chose - 180 here because the number "108" which is used - in arch.h has been assigned to another error code. */ + 180 here because the number "108" which is used + in arch.h has been assigned to another error code. */ #define ESHUTDOWN 180 #endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */ #endif /* RT_USING_LIBC */ #if defined(RT_USING_LIBC) || defined(RT_LIBC_USING_TIME) || (defined( __GNUC__ ) && !defined(__ARMCC_VERSION)) #include -#define LWIP_TIMEVAL_PRIVATE 0 +#define LWIP_TIMEVAL_PRIVATE 0 #else -#define LWIP_TIMEVAL_PRIVATE 1 +#define LWIP_TIMEVAL_PRIVATE 1 #endif #if defined(__CC_ARM) /* ARMCC compiler */ @@ -95,14 +95,14 @@ #endif void sys_arch_assert(const char* file, int line); -#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) +#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0) #define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0) #include "string.h" -#define SYS_ARCH_DECL_PROTECT(level) -#define SYS_ARCH_PROTECT(level) rt_enter_critical() -#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() +#define SYS_ARCH_DECL_PROTECT(level) +#define SYS_ARCH_PROTECT(level) rt_enter_critical() +#define SYS_ARCH_UNPROTECT(level) rt_exit_critical() #endif /* __ARCH_CC_H__ */ diff --git a/components/net/lwip-2.1.2/src/arch/include/arch/perf.h b/components/net/lwip-2.1.2/src/arch/include/arch/perf.h index 675f1f65dc..4b7720ef40 100644 --- a/components/net/lwip-2.1.2/src/arch/include/arch/perf.h +++ b/components/net/lwip-2.1.2/src/arch/include/arch/perf.h @@ -1,33 +1,33 @@ /* * Copyright (c) 2001, Swedish Institute of Computer Science. - * All rights reserved. + * 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. Neither the name of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * * $Id: perf.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $ @@ -42,8 +42,8 @@ /* void perf_print(unsigned long c1l, unsigned long c1h, - unsigned long c2l, unsigned long c2h, - char *key); + unsigned long c2l, unsigned long c2h, + char *key); void perf_print_times(struct tms *start, struct tms *end, char *key); diff --git a/components/net/lwip-2.1.2/src/arch/sys_arch.c b/components/net/lwip-2.1.2/src/arch/sys_arch.c index a0eeed1073..c97609a4ea 100644 --- a/components/net/lwip-2.1.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.1.2/src/arch/sys_arch.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (C) 2006-2018, RT-Thread Development Team + * COPYRIGHT (C) 2006-2021, RT-Thread Development Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, diff --git a/components/net/lwip-2.1.2/src/core/altcp.c b/components/net/lwip-2.1.2/src/core/altcp.c index d46d6cdb1d..1156307aca 100644 --- a/components/net/lwip-2.1.2/src/core/altcp.c +++ b/components/net/lwip-2.1.2/src/core/altcp.c @@ -158,7 +158,7 @@ altcp_free(struct altcp_pcb *conn) /** * @ingroup altcp - * altcp_new_ip6: @ref altcp_new for IPv6 + * altcp_new_ip6: @ref altcp_new for IPv6 */ struct altcp_pcb * altcp_new_ip6(altcp_allocator_t *allocator) @@ -166,9 +166,9 @@ altcp_new_ip6(altcp_allocator_t *allocator) return altcp_new_ip_type(allocator, IPADDR_TYPE_V6); } -/** +/** * @ingroup altcp - * altcp_new: @ref altcp_new for IPv4 + * altcp_new: @ref altcp_new for IPv4 */ struct altcp_pcb * altcp_new(altcp_allocator_t *allocator) diff --git a/components/net/lwip-2.1.2/src/core/ipv4/dhcp.c b/components/net/lwip-2.1.2/src/core/ipv4/dhcp.c index 534574feac..1427900ebd 100644 --- a/components/net/lwip-2.1.2/src/core/ipv4/dhcp.c +++ b/components/net/lwip-2.1.2/src/core/ipv4/dhcp.c @@ -1743,7 +1743,7 @@ decode_next: /* make sure the string is really NULL-terminated */ dhcp->boot_file_name[DHCP_FILE_LEN-1] = 0; } -#endif /* LWIP_DHCP_BOOTP_FILE */ +#endif /* LWIP_DHCP_BOOTP_FILE */ return ERR_OK; } diff --git a/components/net/lwip-2.1.2/src/core/ipv6/ip6.c b/components/net/lwip-2.1.2/src/core/ipv6/ip6.c index eda11dc882..afa69f1be9 100644 --- a/components/net/lwip-2.1.2/src/core/ipv6/ip6.c +++ b/components/net/lwip-2.1.2/src/core/ipv6/ip6.c @@ -1047,7 +1047,7 @@ options_done: LWIP_DEBUGF(IP6_DEBUG, ("ip6_input: p->len %"U16_F" p->tot_len %"U16_F"\n", p->len, p->tot_len)); ip_data.current_ip_header_tot_len = hlen_tot; - + #if LWIP_RAW /* p points to IPv6 header again for raw_input. */ pbuf_add_header_force(p, hlen_tot); diff --git a/components/net/lwip-2.1.2/src/core/ipv6/mld6.c b/components/net/lwip-2.1.2/src/core/ipv6/mld6.c index 6387d468cc..fb4e9ef49a 100644 --- a/components/net/lwip-2.1.2/src/core/ipv6/mld6.c +++ b/components/net/lwip-2.1.2/src/core/ipv6/mld6.c @@ -6,7 +6,7 @@ * @ingroup ip6 * Multicast listener discovery for IPv6. Aims to be compliant with RFC 2710. * No support for MLDv2.\n - * Note: The allnodes (ff01::1, ff02::1) group is assumed be received by your + * Note: The allnodes (ff01::1, ff02::1) group is assumed be received by your * netif since it must always be received for correct IPv6 operation (e.g. SLAAC). * Ensure the netif filters are configured accordingly!\n * The netif flags also need NETIF_FLAG_MLD6 flag set to enable MLD6 on a diff --git a/components/net/lwip-2.1.2/src/core/ipv6/nd6.c b/components/net/lwip-2.1.2/src/core/ipv6/nd6.c index db0c132e48..75899c65f4 100644 --- a/components/net/lwip-2.1.2/src/core/ipv6/nd6.c +++ b/components/net/lwip-2.1.2/src/core/ipv6/nd6.c @@ -1835,9 +1835,9 @@ nd6_new_router(const ip6_addr_t *router_addr, struct netif *netif) for (router_index = LWIP_ND6_NUM_ROUTERS - 1; router_index >= 0; router_index--) { /* check if router already exists (this is a special case for 2 netifs on the same subnet - e.g. wifi and cable) */ - if(default_router_list[router_index].neighbor_entry == &(neighbor_cache[neighbor_index])){ - return router_index; - } + if(default_router_list[router_index].neighbor_entry == &(neighbor_cache[neighbor_index])){ + return router_index; + } if (default_router_list[router_index].neighbor_entry == NULL) { /* remember lowest free index to create a new entry */ free_router_index = router_index; diff --git a/components/net/lwip-2.1.2/src/core/sys.c b/components/net/lwip-2.1.2/src/core/sys.c index 5f08352bfb..69d7197a1f 100644 --- a/components/net/lwip-2.1.2/src/core/sys.c +++ b/components/net/lwip-2.1.2/src/core/sys.c @@ -45,30 +45,30 @@ * No need to implement functions in this section in NO_SYS mode. * The OS-specific code should be implemented in arch/sys_arch.h * and sys_arch.c of your port. - * + * * The operating system emulation layer provides a common interface * between the lwIP code and the underlying operating system kernel. The * general idea is that porting lwIP to new architectures requires only * small changes to a few header files and a new sys_arch * implementation. It is also possible to do a sys_arch implementation * that does not rely on any underlying operating system. - * + * * The sys_arch provides semaphores, mailboxes and mutexes to lwIP. For the full * lwIP functionality, multiple threads support can be implemented in the * sys_arch, but this is not required for the basic lwIP * functionality. Timer scheduling is implemented in lwIP, but can be implemented * by the sys_arch port (LWIP_TIMERS_CUSTOM==1). - * + * * In addition to the source file providing the functionality of sys_arch, * the OS emulation layer must provide several header files defining * macros used throughout lwip. The files required and the macros they * must define are listed below the sys_arch description. - * + * * Since lwIP 1.4.0, semaphore, mutexes and mailbox functions are prototyped in a way that * allows both using pointers or actual OS structures to be used. This way, memory * required for such types can be either allocated in place (globally or on the * stack) or on the heap (allocated internally in the "*_new()" functions). - * + * * Note: * ----- * Be careful with using mem_malloc() in sys_arch. When malloc() refers to @@ -96,7 +96,7 @@ * Mailboxes should be implemented as a queue which allows multiple messages * to be posted (implementing as a rendez-vous point where only one message can be * posted at a time can have a highly negative impact on performance). A message - * in a mailbox is just a pointer, nothing more. + * in a mailbox is just a pointer, nothing more. * * @defgroup sys_time Time * @ingroup sys_layer diff --git a/components/net/lwip-2.1.2/src/core/tcp.c b/components/net/lwip-2.1.2/src/core/tcp.c index bd7d64ec39..10aaf21968 100644 --- a/components/net/lwip-2.1.2/src/core/tcp.c +++ b/components/net/lwip-2.1.2/src/core/tcp.c @@ -11,7 +11,7 @@ * Common functions for the TCP implementation, such as functions * for manipulating the data structures and the TCP timer functions. TCP functions * related to input and output is found in tcp_in.c and tcp_out.c respectively.\n - * + * * TCP connection setup * -------------------- * The functions used for setting up connections is similar to that of @@ -24,7 +24,7 @@ * - tcp_listen() and tcp_listen_with_backlog() * - tcp_accept() * - tcp_connect() - * + * * Sending TCP data * ---------------- * TCP data is sent by enqueueing the data with a call to tcp_write() and @@ -34,7 +34,7 @@ * - tcp_write() * - tcp_output() * - tcp_sent() - * + * * Receiving TCP data * ------------------ * TCP data reception is callback based - an application specified @@ -44,7 +44,7 @@ * window. * - tcp_recv() * - tcp_recved() - * + * * Application polling * ------------------- * When a connection is idle (i.e., no data is either transmitted or @@ -62,7 +62,7 @@ * - tcp_close() * - tcp_abort() * - tcp_err() - * + * */ /* @@ -469,7 +469,7 @@ tcp_close_shutdown_fin(struct tcp_pcb *pcb) * a closing state), the connection is closed, and put in a closing state. * The pcb is then automatically freed in tcp_slowtmr(). It is therefore * unsafe to reference it (unless an error is returned). - * + * * The function may return ERR_MEM if no memory * was available for closing the connection. If so, the application * should wait and try again either by using the acknowledgment @@ -797,7 +797,7 @@ tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) * When an incoming connection is accepted, the function specified with * the tcp_accept() function will be called. The pcb has to be bound * to a local port with the tcp_bind() function. - * + * * The tcp_listen() function returns a new connection identifier, and * the one passed as an argument to the function will be * deallocated. The reason for this behavior is that less memory is @@ -812,7 +812,7 @@ tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) * The backlog limits the number of outstanding connections * in the listen queue to the value specified by the backlog argument. * To use it, your need to set TCP_LISTEN_BACKLOG=1 in your lwipopts.h. - * + * * @param pcb the original tcp_pcb * @param backlog the incoming connections queue limit * @return tcp_pcb used for listening, consumes less memory. @@ -1039,7 +1039,7 @@ again: * Connects to another host. The function given as the "connected" * argument will be called when the connection has been established. * Sets up the pcb to connect to the remote host and sends the - * initial SYN segment which opens the connection. + * initial SYN segment which opens the connection. * * The tcp_connect() function returns immediately; it does not wait for * the connection to be properly setup. Instead, it will call the @@ -1711,14 +1711,14 @@ tcp_kill_prio(u8_t prio) mprio = LWIP_MIN(TCP_PRIO_MAX, prio); - /* We want to kill connections with a lower prio, so bail out if + /* We want to kill connections with a lower prio, so bail out if * supplied prio is 0 - there can never be a lower prio */ if (mprio == 0) { return; } - /* We only want kill connections with a lower prio, so decrement prio by one + /* We only want kill connections with a lower prio, so decrement prio by one * and start searching for oldest connection with same or lower priority than mprio. * We want to find the connections with the lowest possible prio, and among * these the one with the longest inactivity time. @@ -2041,7 +2041,7 @@ tcp_sent(struct tcp_pcb *pcb, tcp_sent_fn sent) * @ingroup tcp_raw * Used to specify the function that should be called when a fatal error * has occurred on the connection. - * + * * If a connection is aborted because of an error, the application is * alerted of this event by the err callback. Errors that might abort a * connection are when there is a shortage of memory. The callback @@ -2091,7 +2091,7 @@ tcp_accept(struct tcp_pcb *pcb, tcp_accept_fn accept) * number of TCP coarse grained timer shots, which typically occurs * twice a second. An interval of 10 means that the application would * be polled every 5 seconds. - * + * * When a connection is idle (i.e., no data is either transmitted or * received), lwIP will repeatedly poll the application by calling a * specified callback function. This can be used either as a watchdog diff --git a/components/net/lwip-2.1.2/src/core/tcp_out.c b/components/net/lwip-2.1.2/src/core/tcp_out.c index 724df1097c..a00ce23f66 100644 --- a/components/net/lwip-2.1.2/src/core/tcp_out.c +++ b/components/net/lwip-2.1.2/src/core/tcp_out.c @@ -355,7 +355,7 @@ tcp_write_checks(struct tcp_pcb *pcb, u16_t len) * it can send them more efficiently by combining them together). * To prompt the system to send data now, call tcp_output() after * calling tcp_write(). - * + * * This function enqueues the data pointed to by the argument dataptr. The length of * the data is passed as the len parameter. The apiflags can be one or more of: * - TCP_WRITE_FLAG_COPY: indicates whether the new memory should be allocated diff --git a/components/net/lwip-2.1.2/src/core/timeouts.c b/components/net/lwip-2.1.2/src/core/timeouts.c index f37acfec99..8c8d497271 100644 --- a/components/net/lwip-2.1.2/src/core/timeouts.c +++ b/components/net/lwip-2.1.2/src/core/timeouts.c @@ -241,7 +241,7 @@ lwip_cyclic_timer(void *arg) cyclic->handler(); now = sys_now(); - next_timeout_time = (u32_t)(current_timeout_due_time + cyclic->interval_ms); /* overflow handled by TIME_LESS_THAN macro */ + next_timeout_time = (u32_t)(current_timeout_due_time + cyclic->interval_ms); /* overflow handled by TIME_LESS_THAN macro */ if (TIME_LESS_THAN(next_timeout_time, now)) { /* timer would immediately expire again -> "overload" -> restart without any correction */ #if LWIP_DEBUG_TIMERNAMES @@ -296,7 +296,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg) LWIP_ASSERT("Timeout time too long, max is LWIP_UINT32_MAX/4 msecs", msecs <= (LWIP_UINT32_MAX / 4)); - next_timeout_time = (u32_t)(sys_now() + msecs); /* overflow handled by TIME_LESS_THAN macro */ + next_timeout_time = (u32_t)(sys_now() + msecs); /* overflow handled by TIME_LESS_THAN macro */ #if LWIP_DEBUG_TIMERNAMES sys_timeout_abs(next_timeout_time, handler, arg, handler_name); diff --git a/components/net/lwip-2.1.2/src/core/udp.c b/components/net/lwip-2.1.2/src/core/udp.c index 9d2cb4af7f..7c25912e67 100644 --- a/components/net/lwip-2.1.2/src/core/udp.c +++ b/components/net/lwip-2.1.2/src/core/udp.c @@ -911,7 +911,7 @@ udp_sendto_if_src_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *d /** * @ingroup udp_raw * Bind an UDP PCB. - * + * * @param pcb UDP PCB to be bound with a local address ipaddr and port. * @param ipaddr local IP address to bind with. Use IP_ANY_TYPE to * bind to all local interfaces. @@ -1168,8 +1168,8 @@ udp_recv(struct udp_pcb *pcb, udp_recv_fn recv, void *recv_arg) /** * @ingroup udp_raw - * Removes and deallocates the pcb. - * + * Removes and deallocates the pcb. + * * @param pcb UDP PCB to be removed. The PCB is removed from the list of * UDP PCB's and the data structure is freed from memory. * @@ -1242,7 +1242,7 @@ udp_new(void) * Create a UDP PCB for specific IP type. * The pcb is not active until it has either been bound to a local address * or connected to a remote address. - * + * * @param type IP address type, see @ref lwip_ip_addr_type definitions. * If you want to listen to IPv4 and IPv6 (dual-stack) packets, * supply @ref IPADDR_TYPE_ANY as argument and bind to @ref IP_ANY_TYPE. diff --git a/components/net/lwip-2.1.2/src/include/compat/posix/net/if.h b/components/net/lwip-2.1.2/src/include/compat/posix/net/if.h index 6b8e63a527..8b8e48198d 100644 --- a/components/net/lwip-2.1.2/src/include/compat/posix/net/if.h +++ b/components/net/lwip-2.1.2/src/include/compat/posix/net/if.h @@ -7,7 +7,7 @@ * Copyright (c) 2017 Joel Cunningham, Garmin International, Inc. * All rights reserved. * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -16,17 +16,17 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. diff --git a/components/net/lwip-2.1.2/src/include/lwip/api.h b/components/net/lwip-2.1.2/src/include/lwip/api.h index c2afaf26d3..739f8be5bc 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/api.h +++ b/components/net/lwip-2.1.2/src/include/lwip/api.h @@ -153,27 +153,27 @@ enum netconn_state { }; /** Used to inform the callback function about changes - * + * * Event explanation: - * + * * In the netconn implementation, there are three ways to block a client: - * + * * - accept mbox (sys_arch_mbox_fetch(&conn->acceptmbox, &accept_ptr, 0); in netconn_accept()) * - receive mbox (sys_arch_mbox_fetch(&conn->recvmbox, &buf, 0); in netconn_recv_data()) * - send queue is full (sys_arch_sem_wait(LWIP_API_MSG_SEM(msg), 0); in lwip_netconn_do_write()) - * + * * The events have to be seen as events signaling the state of these mboxes/semaphores. For non-blocking * connections, you need to know in advance whether a call to a netconn function call would block or not, * and these events tell you about that. - * - * RCVPLUS events say: Safe to perform a potentially blocking call call once more. + * + * RCVPLUS events say: Safe to perform a potentially blocking call call once more. * They are counted in sockets - three RCVPLUS events for accept mbox means you are safe * to call netconn_accept 3 times without being blocked. * Same thing for receive mbox. - * + * * RCVMINUS events say: Your call to to a possibly blocking function is "acknowledged". * Socket implementation decrements the counter. - * + * * For TX, there is no need to count, its merely a flag. SENDPLUS means you may send something. * SENDPLUS occurs when enough data was delivered to peer so netconn_send() can be called again. * A SENDMINUS event occurs when the next call to a netconn_send() would be blocking. diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/fs.h b/components/net/lwip-2.1.2/src/include/lwip/apps/fs.h index 67b9a60a9c..5be77c1b9d 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/fs.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/fs.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Adam Dunkels * */ diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/http_client.h b/components/net/lwip-2.1.2/src/include/lwip/apps/http_client.h index 8a0630833f..d39e1bf829 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/http_client.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/http_client.h @@ -52,7 +52,7 @@ extern "C" { #endif /** - * @ingroup httpc + * @ingroup httpc * HTTPC_HAVE_FILE_IO: define this to 1 to have functions dowloading directly * to disk via fopen/fwrite. * These functions are example implementations of the interface only. @@ -62,13 +62,13 @@ extern "C" { #endif /** - * @ingroup httpc + * @ingroup httpc * The default TCP port used for HTTP */ #define HTTP_DEFAULT_PORT LWIP_IANA_PORT_HTTP /** - * @ingroup httpc + * @ingroup httpc * HTTP client result codes */ typedef enum ehttpc_result { @@ -97,7 +97,7 @@ typedef enum ehttpc_result { typedef struct _httpc_state httpc_state_t; /** - * @ingroup httpc + * @ingroup httpc * Prototype of a http client callback function * * @param arg argument specified when initiating the request @@ -110,7 +110,7 @@ typedef struct _httpc_state httpc_state_t; typedef void (*httpc_result_fn)(void *arg, httpc_result_t httpc_result, u32_t rx_content_len, u32_t srv_res, err_t err); /** - * @ingroup httpc + * @ingroup httpc * Prototype of http client callback: called when the headers are received * * @param connection http client connection diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/httpd_opts.h b/components/net/lwip-2.1.2/src/include/lwip/apps/httpd_opts.h index 8723961fd4..dd0c075de9 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/httpd_opts.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/httpd_opts.h @@ -175,7 +175,7 @@ #define HTTPD_DEBUG LWIP_DBG_OFF #endif -/** Set this to 1 to use a memp pool for allocating +/** Set this to 1 to use a memp pool for allocating * struct http_state instead of the heap. * If enabled, you'll need to define MEMP_NUM_PARALLEL_HTTPD_CONNS * (and MEMP_NUM_PARALLEL_HTTPD_SSI_CONNS for SSI) to set the size of diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/mqtt.h b/components/net/lwip-2.1.2/src/include/lwip/apps/mqtt.h index c2bb2288f4..f099812d2e 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/mqtt.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/mqtt.h @@ -134,7 +134,7 @@ enum { MQTT_DATA_FLAG_LAST = 1 }; -/** +/** * @ingroup mqtt * Function prototype for MQTT incoming publish data callback function. Called when data * arrives to a subscribed topic @see mqtt_subscribe @@ -149,7 +149,7 @@ enum { typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags); -/** +/** * @ingroup mqtt * Function prototype for MQTT incoming publish function. Called when an incoming publish * arrives to a subscribed topic @see mqtt_subscribe diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/smtp_opts.h b/components/net/lwip-2.1.2/src/include/lwip/apps/smtp_opts.h index bc743f679e..4ce2d5122b 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/smtp_opts.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/smtp_opts.h @@ -6,14 +6,14 @@ #ifdef __cplusplus extern "C" { #endif - + /** * @defgroup smtp_opts Options * @ingroup smtp - * + * * @{ */ - + /** Set this to 1 to enable data handler callback on BODY */ #ifndef SMTP_BODYDH #define SMTP_BODYDH 0 diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/snmp_core.h b/components/net/lwip-2.1.2/src/include/lwip/apps/snmp_core.h index 6021c72220..5a8a49f8d2 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/snmp_core.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/snmp_core.h @@ -101,7 +101,7 @@ extern "C" { /** error codes predefined by SNMP prot. */ typedef enum { SNMP_ERR_NOERROR = 0, -/* +/* outdated v1 error codes. do not use anmore! #define SNMP_ERR_NOSUCHNAME 2 use SNMP_ERR_NOSUCHINSTANCE instead #define SNMP_ERR_BADVALUE 3 use SNMP_ERR_WRONGTYPE,SNMP_ERR_WRONGLENGTH,SNMP_ERR_WRONGENCODING or SNMP_ERR_WRONGVALUE instead diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_opts.h b/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_opts.h index 198f632b68..ec0b6316aa 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_opts.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_opts.h @@ -11,7 +11,7 @@ * */ -/* +/* * Redistribution and use in source and binary forms, with or without * modification,are permitted provided that the following conditions are met: * diff --git a/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_server.h b/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_server.h index 0a7fbee02a..efd50a057b 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_server.h +++ b/components/net/lwip-2.1.2/src/include/lwip/apps/tftp_server.h @@ -11,7 +11,7 @@ * */ -/* +/* * Redistribution and use in source and binary forms, with or without * modification,are permitted provided that the following conditions are met: * @@ -67,7 +67,7 @@ struct tftp_context { */ void (*close)(void* handle); /** - * Read from file + * Read from file * @param handle File handle returned by open() * @param buf Target buffer to copy read data to * @param bytes Number of bytes to copy to buf diff --git a/components/net/lwip-2.1.2/src/include/lwip/arch.h b/components/net/lwip-2.1.2/src/include/lwip/arch.h index 1606d4faab..fd73dec5fc 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/arch.h +++ b/components/net/lwip-2.1.2/src/include/lwip/arch.h @@ -74,7 +74,7 @@ /** Platform specific diagnostic output.\n * Note the default implementation pulls in printf, which may - * in turn pull in a lot of standard libary code. In resource-constrained + * in turn pull in a lot of standard libary code. In resource-constrained * systems, this should be defined to something less resource-consuming. */ #ifndef LWIP_PLATFORM_DIAG @@ -85,7 +85,7 @@ /** Platform specific assertion handling.\n * Note the default implementation pulls in printf, fflush and abort, which may - * in turn pull in a lot of standard libary code. In resource-constrained + * in turn pull in a lot of standard libary code. In resource-constrained * systems, this should be defined to something less resource-consuming. */ #ifndef LWIP_PLATFORM_ASSERT diff --git a/components/net/lwip-2.1.2/src/include/lwip/igmp.h b/components/net/lwip-2.1.2/src/include/lwip/igmp.h index ffd80e680c..0a16db0397 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/igmp.h +++ b/components/net/lwip-2.1.2/src/include/lwip/igmp.h @@ -99,7 +99,7 @@ err_t igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr); err_t igmp_leavegroup_netif(struct netif *netif, const ip4_addr_t *groupaddr); void igmp_tmr(void); -/** @ingroup igmp +/** @ingroup igmp * Get list head of IGMP groups for netif. * Note: The allsystems group IP is contained in the list as first entry. * @see @ref netif_set_igmp_mac_filter() diff --git a/components/net/lwip-2.1.2/src/include/lwip/ip_addr.h b/components/net/lwip-2.1.2/src/include/lwip/ip_addr.h index 2f977709d1..ee7a0c9da2 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/ip_addr.h +++ b/components/net/lwip-2.1.2/src/include/lwip/ip_addr.h @@ -404,7 +404,7 @@ extern const ip_addr_t ip_addr_broadcast; extern const ip_addr_t ip6_addr_any; -/** +/** * @ingroup ip6addr * IP6_ADDR_ANY can be used as a fixed ip_addr_t * for the IPv6 wildcard address diff --git a/components/net/lwip-2.1.2/src/include/lwip/mld6.h b/components/net/lwip-2.1.2/src/include/lwip/mld6.h index 7fa0797f27..2764fdd42d 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/mld6.h +++ b/components/net/lwip-2.1.2/src/include/lwip/mld6.h @@ -84,7 +84,7 @@ err_t mld6_leavegroup_netif(struct netif *netif, const ip6_addr_t *groupaddr); /** @ingroup mld6 * Get list head of MLD6 groups for netif. - * Note: The allnodes group IP is NOT in the list, since it must always + * Note: The allnodes group IP is NOT in the list, since it must always * be received for correct IPv6 operation. * @see @ref netif_set_mld_mac_filter() */ diff --git a/components/net/lwip-2.1.2/src/include/lwip/netif.h b/components/net/lwip-2.1.2/src/include/lwip/netif.h index 911196ab3d..03b48a0ea4 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/netif.h +++ b/components/net/lwip-2.1.2/src/include/lwip/netif.h @@ -345,7 +345,7 @@ struct netif { u8_t flags; /** descriptive abbreviation */ char name[2]; - /** number of this interface. Used for @ref if_api and @ref netifapi_netif, + /** number of this interface. Used for @ref if_api and @ref netifapi_netif, * as well as for IPv6 zones */ u8_t num; #if LWIP_IPV6_AUTOCONFIG diff --git a/components/net/lwip-2.1.2/src/include/lwip/opt.h b/components/net/lwip-2.1.2/src/include/lwip/opt.h index 82c420c167..1e8eb6a35a 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/opt.h +++ b/components/net/lwip-2.1.2/src/include/lwip/opt.h @@ -1601,7 +1601,7 @@ #endif /** - * LWIP_NETIF_EXT_STATUS_CALLBACK==1: Support an extended callback function + * LWIP_NETIF_EXT_STATUS_CALLBACK==1: Support an extended callback function * for several netif related event that supports multiple subscribers. * @see netif_ext_status_callback */ @@ -2389,7 +2389,7 @@ * All addresses that have a scope according to the default policy (link-local * unicast addresses, interface-local and link-local multicast addresses) should * now have a zone set on them before being passed to the core API, although - * lwIP will currently attempt to select a zone on the caller's behalf when + * lwIP will currently attempt to select a zone on the caller's behalf when * necessary. Applications that directly assign IPv6 addresses to interfaces * (which is NOT recommended) must now ensure that link-local addresses carry * the netif's zone. See the new ip6_zone.h header file for more information and @@ -3027,8 +3027,8 @@ * - src: source eth address * - dst: destination eth address * - eth_type: ethernet type to packet to be sent\n - * - * + * + * * Return values: * - <0: Packet shall not contain VLAN header. * - 0 <= return value <= 0xFFFF: Packet shall contain VLAN header. Return value is prio_vid in host byte order. diff --git a/components/net/lwip-2.1.2/src/include/lwip/pbuf.h b/components/net/lwip-2.1.2/src/include/lwip/pbuf.h index 82902a4e98..2ddd913af1 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/pbuf.h +++ b/components/net/lwip-2.1.2/src/include/lwip/pbuf.h @@ -55,7 +55,7 @@ extern "C" { #define LWIP_SUPPORT_CUSTOM_PBUF ((IP_FRAG && !LWIP_NETIF_TX_SINGLE_PBUF) || (LWIP_IPV6 && LWIP_IPV6_FRAG)) #endif -/** @ingroup pbuf +/** @ingroup pbuf * PBUF_NEEDS_COPY(p): return a boolean value indicating whether the given * pbuf needs to be copied in order to be kept around beyond the current call * stack without risking being corrupted. The default setting provides safety: diff --git a/components/net/lwip-2.1.2/src/include/lwip/prot/ieee.h b/components/net/lwip-2.1.2/src/include/lwip/prot/ieee.h index db865635be..dce8bebce1 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/prot/ieee.h +++ b/components/net/lwip-2.1.2/src/include/lwip/prot/ieee.h @@ -53,7 +53,7 @@ enum lwip_ieee_eth_type { /** Internet protocol v4 */ ETHTYPE_IP = 0x0800U, /** Address resolution protocol */ - ETHTYPE_ARP = 0x0806U, + ETHTYPE_ARP = 0x0806U, /** Wake on lan */ ETHTYPE_WOL = 0x0842U, /** RARP */ diff --git a/components/net/lwip-2.1.2/src/include/lwip/sys.h b/components/net/lwip-2.1.2/src/include/lwip/sys.h index 168e465baa..cf13e1dcc4 100644 --- a/components/net/lwip-2.1.2/src/include/lwip/sys.h +++ b/components/net/lwip-2.1.2/src/include/lwip/sys.h @@ -130,7 +130,7 @@ typedef void (*lwip_thread_fn)(void *arg); * If the mutex has been created, ERR_OK should be returned. Returning any * other error will provide a hint what went wrong, but except for assertions, * no real error handling is implemented. - * + * * @param mutex pointer to the mutex to create * @return ERR_OK if successful, another err_t otherwise */ @@ -205,13 +205,13 @@ void sys_sem_signal(sys_sem_t *sem); * "timeout" argument is non-zero, the thread should only be blocked for the * specified time (measured in milliseconds). If the "timeout" argument is zero, * the thread should be blocked until the semaphore is signalled. - * + * * The return value is SYS_ARCH_TIMEOUT if the semaphore wasn't signaled within * the specified time or any other value if it was signaled (with or without * waiting). * Notice that lwIP implements a function with a similar name, * sys_sem_wait(), that uses the sys_arch_sem_wait() function. - * + * * @param sem the semaphore to wait for * @param timeout timeout in milliseconds to wait (0 = wait forever) * @return SYS_ARCH_TIMEOUT on timeout, any other value on success @@ -277,7 +277,7 @@ void sys_msleep(u32_t ms); /* only has a (close to) 1 ms resolution. */ * If the mailbox has been created, ERR_OK should be returned. Returning any * other error will provide a hint what went wrong, but except for assertions, * no real error handling is implemented. - * + * * @param mbox pointer to the mbox to create * @param size (minimum) number of messages in this mbox * @return ERR_OK if successful, another err_t otherwise @@ -287,7 +287,7 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int size); * @ingroup sys_mbox * Post a message to an mbox - may not fail * -> blocks if full, only to be used from tasks NOT from ISR! - * + * * @param mbox mbox to posts the message * @param msg message to post (ATTENTION: can be NULL) */ @@ -297,7 +297,7 @@ void sys_mbox_post(sys_mbox_t *mbox, void *msg); * Try to post a message to an mbox - may fail if full. * Can be used from ISR (if the sys arch layer allows this). * Returns ERR_MEM if it is full, else, ERR_OK if the "msg" is posted. - * + * * @param mbox mbox to posts the message * @param msg message to post (ATTENTION: can be NULL) */ @@ -307,7 +307,7 @@ err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg); * Try to post a message to an mbox - may fail if full. * To be be used from ISR. * Returns ERR_MEM if it is full, else, ERR_OK if the "msg" is posted. - * + * * @param mbox mbox to posts the message * @param msg message to post (ATTENTION: can be NULL) */ @@ -324,10 +324,10 @@ err_t sys_mbox_trypost_fromisr(sys_mbox_t *mbox, void *msg); * The return values are the same as for the sys_arch_sem_wait() function: * SYS_ARCH_TIMEOUT if there was a timeout, any other value if a messages * is received. - * + * * Note that a function with a similar name, sys_mbox_fetch(), is - * implemented by lwIP. - * + * implemented by lwIP. + * * @param mbox mbox to get a message from * @param msg pointer where the message is stored * @param timeout maximum time (in milliseconds) to wait for a message (0 = wait forever) @@ -346,7 +346,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout); * example, a naive implementation could be: * \#define sys_arch_mbox_tryfetch(mbox,msg) sys_arch_mbox_fetch(mbox,msg,1) * although this would introduce unnecessary delays. - * + * * @param mbox mbox to get a message from * @param msg pointer where the message is stored * @return 0 (milliseconds) if a message has been received @@ -363,7 +363,7 @@ u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg); * Deallocates a mailbox. If there are messages still present in the * mailbox when the mailbox is deallocated, it is an indication of a * programming error in lwIP and the developer should be notified. - * + * * @param mbox mbox to delete */ void sys_mbox_free(sys_mbox_t *mbox); @@ -411,7 +411,7 @@ void sys_mbox_set_invalid(sys_mbox_t *mbox); * the "stacksize" parameter. The id of the new thread is returned. Both the id * and the priority are system dependent. * ATTENTION: although this function returns a value, it MUST NOT FAIL (ports have to assert this!) - * + * * @param name human-readable name for the thread (used for debugging purposes) * @param thread thread-function * @param arg parameter passed to 'thread' diff --git a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h index 244bafdd1b..09c6d9a56f 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ethernetif.h +++ b/components/net/lwip-2.1.2/src/include/netif/ethernetif.h @@ -4,16 +4,16 @@ #include "lwip/netif.h" #include -#define NIOCTL_GADDR 0x01 +#define NIOCTL_GADDR 0x01 #ifndef RT_LWIP_ETH_MTU -#define ETHERNET_MTU 1500 +#define ETHERNET_MTU 1500 #else -#define ETHERNET_MTU RT_LWIP_ETH_MTU +#define ETHERNET_MTU RT_LWIP_ETH_MTU #endif /* eth flag with auto_linkup or phy_linkup */ -#define ETHIF_LINK_AUTOUP 0x0000 -#define ETHIF_LINK_PHYUP 0x0100 +#define ETHIF_LINK_AUTOUP 0x0000 +#define ETHIF_LINK_PHYUP 0x0100 struct eth_device { diff --git a/components/net/lwip-2.1.2/src/include/netif/lowpan6_ble.h b/components/net/lwip-2.1.2/src/include/netif/lowpan6_ble.h index 01896a7ff6..5190e7bc29 100644 --- a/components/net/lwip-2.1.2/src/include/netif/lowpan6_ble.h +++ b/components/net/lwip-2.1.2/src/include/netif/lowpan6_ble.h @@ -6,7 +6,7 @@ /* * Copyright (c) 2017 Benjamin Aigner * Copyright (c) 2015 Inico Technologies Ltd. , Author: Ivan Delamer - * + * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -32,10 +32,10 @@ * OF SUCH DAMAGE. * * Author: Benjamin Aigner - * + * * Based on the original 6lowpan implementation of lwIP ( @see 6lowpan.c) */ - + #ifndef LWIP_HDR_LOWPAN6_BLE_H #define LWIP_HDR_LOWPAN6_BLE_H diff --git a/components/net/lwip-2.1.2/src/include/netif/lowpan6_opts.h b/components/net/lwip-2.1.2/src/include/netif/lowpan6_opts.h index 17d46cdcc5..32e5c5ee14 100644 --- a/components/net/lwip-2.1.2/src/include/netif/lowpan6_opts.h +++ b/components/net/lwip-2.1.2/src/include/netif/lowpan6_opts.h @@ -109,7 +109,7 @@ #define LWIP_RFC7668_IP_UNCOMPRESSED_DEBUG LWIP_DBG_OFF #endif -/** LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS: +/** LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS: * Currently, the linux kernel driver for 6lowpan sets/clears a bit in * the address, depending on the BD address (either public or not). * Might not be RFC7668 conform, so you may select to do that (=1) or diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/ccp.h b/components/net/lwip-2.1.2/src/include/netif/ppp/ccp.h index b2285228b8..830dc3137f 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/ccp.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/ccp.h @@ -44,48 +44,48 @@ extern "C" { * 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 +#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 +#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_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 +#define CCP_OPT_CODE(dp) ((dp)[0]) +#define CCP_OPT_LENGTH(dp) ((dp)[1]) +#define CCP_OPT_MINLEN 2 #if BSDCOMPRESS_SUPPORT /* * Definitions for BSD-Compress. */ -#define CI_BSD_COMPRESS 21 /* config. option for BSD-Compress */ -#define CILEN_BSD_COMPRESS 3 /* length of config. option */ +#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_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 */ +#define BSD_MIN_BITS 9 /* smallest code size supported */ +#define BSD_MAX_BITS 15 /* largest code size supported */ #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT @@ -93,17 +93,17 @@ extern "C" { * 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 9 -#define DEFLATE_MAX_SIZE 15 -#define DEFLATE_METHOD_VAL 8 -#define DEFLATE_SIZE(x) (((x) >> 4) + 8) -#define DEFLATE_METHOD(x) ((x) & 0x0F) -#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) -#define DEFLATE_CHK_SEQUENCE 0 +#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 9 +#define DEFLATE_MAX_SIZE 15 +#define DEFLATE_METHOD_VAL 8 +#define DEFLATE_SIZE(x) (((x) >> 4) + 8) +#define DEFLATE_METHOD(x) ((x) & 0x0F) +#define DEFLATE_MAKE_OPT(w) ((((w) - 8) << 4) + DEFLATE_METHOD_VAL) +#define DEFLATE_CHK_SEQUENCE 0 #endif /* DEFLATE_SUPPORT */ #if MPPE_SUPPORT @@ -120,10 +120,10 @@ extern "C" { * 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 */ +#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 /* PREDICTOR_SUPPORT */ typedef struct ccp_options { @@ -141,15 +141,15 @@ typedef struct ccp_options { #endif /* PREDICTOR_SUPPORT */ #if MPPE_SUPPORT - u8_t mppe; /* MPPE bitfield */ + u8_t mppe; /* MPPE bitfield */ #endif /* MPPE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - u_short bsd_bits; /* # bits/code for BSD Compress */ + u_short bsd_bits; /* # bits/code for BSD Compress */ #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT - u_short deflate_size; /* lg(window size) for Deflate */ + u_short deflate_size; /* lg(window size) for Deflate */ #endif /* DEFLATE_SUPPORT */ - u8_t method; /* code for chosen compression method */ + u8_t method; /* code for chosen compression method */ } ccp_options; extern const struct protent ccp_protent; diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/chap-new.h b/components/net/lwip-2.1.2/src/include/netif/ppp/chap-new.h index 2d8cd9ca99..3d26413664 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/chap-new.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/chap-new.h @@ -43,45 +43,45 @@ extern "C" { /* * CHAP packets begin with a standard header with code, id, len (2 bytes). */ -#define CHAP_HDRLEN 4 +#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 +#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_MD5 5 #if MSCHAP_SUPPORT -#define CHAP_MICROSOFT 0x80 -#define CHAP_MICROSOFT_V2 0x81 +#define CHAP_MICROSOFT 0x80 +#define CHAP_MICROSOFT_V2 0x81 #endif /* MSCHAP_SUPPORT */ /* * Semi-arbitrary limits on challenge and response fields. */ -#define MAX_CHALLENGE_LEN 64 -#define MAX_RESPONSE_LEN 64 +#define MAX_CHALLENGE_LEN 64 +#define MAX_RESPONSE_LEN 64 /* * 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) +#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) /* bitmask of supported algorithms */ #if MSCHAP_SUPPORT -#define MDTYPE_MICROSOFT_V2 0x1 -#define MDTYPE_MICROSOFT 0x2 +#define MDTYPE_MICROSOFT_V2 0x1 +#define MDTYPE_MICROSOFT 0x2 #endif /* MSCHAP_SUPPORT */ -#define MDTYPE_MD5 0x4 -#define MDTYPE_NONE 0 +#define MDTYPE_MD5 0x4 +#define MDTYPE_NONE 0 #if MSCHAP_SUPPORT /* Return the digest alg. ID for the most preferred digest type. */ @@ -129,24 +129,24 @@ extern "C" { * The code for each digest type has to supply one of these. */ struct chap_digest_type { - int code; + int code; #if PPP_SERVER - /* - * Note: challenge and response arguments below are formatted as - * a length byte followed by the actual challenge/response data. - */ - void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge); - int (*verify_response)(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space); + /* + * Note: challenge and response arguments below are formatted as + * a length byte followed by the actual challenge/response data. + */ + void (*generate_challenge)(ppp_pcb *pcb, unsigned char *challenge); + int (*verify_response)(ppp_pcb *pcb, int id, const char *name, + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space); #endif /* PPP_SERVER */ - void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *priv); - int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); - void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); + void (*make_response)(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *priv); + int (*check_success)(ppp_pcb *pcb, unsigned char *pkt, int len, unsigned char *priv); + void (*handle_failure)(ppp_pcb *pcb, unsigned char *pkt, int len); }; /* @@ -154,21 +154,21 @@ struct chap_digest_type { */ #if CHAP_SUPPORT typedef struct chap_client_state { - u8_t flags; - const char *name; - const struct chap_digest_type *digest; - unsigned char priv[64]; /* private area for digest's use */ + u8_t flags; + const char *name; + const struct chap_digest_type *digest; + unsigned char priv[64]; /* private area for digest's use */ } chap_client_state; #if PPP_SERVER typedef struct chap_server_state { - u8_t flags; - u8_t id; - const char *name; - const struct chap_digest_type *digest; - int challenge_xmits; - int challenge_pktlen; - unsigned char challenge[CHAL_MAX_PKTLEN]; + u8_t flags; + u8_t id; + const char *name; + const struct chap_digest_type *digest; + int challenge_xmits; + int challenge_pktlen; + unsigned char challenge[CHAL_MAX_PKTLEN]; } chap_server_state; #endif /* PPP_SERVER */ #endif /* CHAP_SUPPORT */ @@ -176,9 +176,9 @@ typedef struct chap_server_state { #if 0 /* UNUSED */ /* Hook for a plugin to validate CHAP challenge */ extern int (*chap_verify_hook)(char *name, char *ourname, int id, - const struct chap_digest_type *digest, - unsigned char *challenge, unsigned char *response, - char *message, int message_space); + const struct chap_digest_type *digest, + unsigned char *challenge, unsigned char *response, + char *message, int message_space); #endif /* UNUSED */ #if PPP_SERVER diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/eap.h b/components/net/lwip-2.1.2/src/include/netif/ppp/eap.h index 3ee9aaf81a..491e52ab11 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/eap.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/eap.h @@ -24,135 +24,135 @@ #if PPP_SUPPORT && EAP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef PPP_EAP_H -#define PPP_EAP_H +#define PPP_EAP_H #include "ppp.h" -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif /* * Packet header = Code, id, length. */ -#define EAP_HEADERLEN 4 +#define EAP_HEADERLEN 4 /* EAP message codes. */ -#define EAP_REQUEST 1 -#define EAP_RESPONSE 2 -#define EAP_SUCCESS 3 -#define EAP_FAILURE 4 +#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 */ +#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 */ +#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 EAP_MIN_CHALLENGE_LENGTH 17 -#define EAP_MAX_CHALLENGE_LENGTH 24 +#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 EAP_MIN_CHALLENGE_LENGTH 17 +#define EAP_MAX_CHALLENGE_LENGTH 24 #define EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH 3 /* 2^3-1 = 7, 17+7 = 24 */ -#define EAP_STATES \ - "Initial", "Pending", "Closed", "Listen", "Identify", \ - "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth" +#define EAP_STATES \ + "Initial", "Pending", "Closed", "Listen", "Identify", \ + "SRP1", "SRP2", "SRP3", "MD5Chall", "Open", "SRP4", "BadAuth" -#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen) +#define eap_client_active(pcb) ((pcb)->eap.es_client.ea_state == eapListen) #if PPP_SERVER -#define eap_server_active(pcb) \ - ((pcb)->eap.es_server.ea_state >= eapIdentify && \ - (pcb)->eap.es_server.ea_state <= eapMD5Chall) +#define eap_server_active(pcb) \ + ((pcb)->eap.es_server.ea_state >= eapIdentify && \ + (pcb)->eap.es_server.ea_state <= eapMD5Chall) #endif /* PPP_SERVER */ /* * Complete EAP state for one PPP session. */ 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 */ + 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 */ }; struct eap_auth { - const char *ea_name; /* Our name */ - char ea_peer[MAXNAMELEN +1]; /* Peer's name */ - void *ea_session; /* Authentication library linkage */ - u_char *ea_skey; /* Shared encryption key */ - 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_* */ - u32_t ea_keyflags; /* SRP shared key usage flags */ + const char *ea_name; /* Our name */ + char ea_peer[MAXNAMELEN +1]; /* Peer's name */ + void *ea_session; /* Authentication library linkage */ + u_char *ea_skey; /* Shared encryption key */ + 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_* */ + u32_t ea_keyflags; /* SRP shared key usage flags */ }; #ifndef EAP_MAX_CHALLENGE_LENGTH -#define EAP_MAX_CHALLENGE_LENGTH 24 +#define EAP_MAX_CHALLENGE_LENGTH 24 #endif typedef struct eap_state { - struct eap_auth es_client; /* Client (authenticatee) data */ + struct eap_auth es_client; /* Client (authenticatee) data */ #if PPP_SERVER - struct eap_auth es_server; /* Server (authenticator) data */ + struct eap_auth es_server; /* Server (authenticator) data */ #endif /* PPP_SERVER */ - int es_savedtime; /* Saved timeout */ - int es_rechallenge; /* EAP rechallenge interval */ - int es_lwrechallenge; /* SRP lightweight rechallenge inter */ - u8_t 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[EAP_MAX_CHALLENGE_LENGTH]; + int es_savedtime; /* Saved timeout */ + int es_rechallenge; /* EAP rechallenge interval */ + int es_lwrechallenge; /* SRP lightweight rechallenge inter */ + u8_t 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[EAP_MAX_CHALLENGE_LENGTH]; } eap_state; /* * Timeouts. */ #if 0 /* moved to ppp_opts.h */ -#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 */ +#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 */ #endif /* moved to ppp_opts.h */ void eap_authwithpeer(ppp_pcb *pcb, const char *localname); @@ -160,7 +160,7 @@ void eap_authpeer(ppp_pcb *pcb, const char *localname); extern const struct protent eap_protent; -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/ecp.h b/components/net/lwip-2.1.2/src/include/netif/ppp/ecp.h index d8808c3ab2..fa373fe76f 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/ecp.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/ecp.h @@ -42,8 +42,8 @@ extern "C" { #endif typedef struct ecp_options { - bool required; /* Is ECP required? */ - unsigned enctype; /* Encryption type */ + bool required; /* Is ECP required? */ + unsigned enctype; /* Encryption type */ } ecp_options; extern fsm ecp_fsm[]; diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/eui64.h b/components/net/lwip-2.1.2/src/include/netif/ppp/eui64.h index 5adeb482a8..3a20081f81 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/eui64.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/eui64.h @@ -57,42 +57,42 @@ typedef union u32_t e32[2]; } eui64_t; -#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_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_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_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_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_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] = lwip_htonl(l); \ - } while (0) -#define eui64_setlo32(e, l) eui64_set32(e, l) +#define eui64_set32(e, l) do { \ + (e).e32[0] = 0; \ + (e).e32[1] = lwip_htonl(l); \ + } while (0) +#define eui64_setlo32(e, l) eui64_set32(e, l) -char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ +char *eui64_ntoa(eui64_t); /* Returns ascii representation of id */ #ifdef __cplusplus } diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/fsm.h b/components/net/lwip-2.1.2/src/include/netif/ppp/fsm.h index 8dec700e07..69d965a581 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/fsm.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/fsm.h @@ -46,7 +46,7 @@ #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef FSM_H -#define FSM_H +#define FSM_H #include "ppp.h" @@ -57,108 +57,108 @@ extern "C" { /* * Packet header = Code, id, length. */ -#define HEADERLEN 4 +#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 */ +#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 { - ppp_pcb *pcb; /* PPP Interface */ - const struct fsm_callbacks *callbacks; /* Callback routines */ - const char *term_reason; /* Reason for closing protocol */ - u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */ - /* -- This is our only flag, we might use u_int :1 if we have more flags */ - u16_t protocol; /* Data Link Layer Protocol field value */ - u8_t state; /* State */ - u8_t flags; /* Contains option bits */ - u8_t id; /* Current id */ - u8_t reqid; /* Current request id */ - u8_t retransmits; /* Number of retransmissions left */ - u8_t nakloops; /* Number of nak loops since last ack */ - u8_t rnakloops; /* Number of naks received */ - u8_t maxnakloops; /* Maximum number of nak loops tolerated - (necessary because IPCP require a custom large max nak loops value) */ - u8_t term_reason_len; /* Length of term_reason */ + ppp_pcb *pcb; /* PPP Interface */ + const struct fsm_callbacks *callbacks; /* Callback routines */ + const char *term_reason; /* Reason for closing protocol */ + u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */ + /* -- This is our only flag, we might use u_int :1 if we have more flags */ + u16_t protocol; /* Data Link Layer Protocol field value */ + u8_t state; /* State */ + u8_t flags; /* Contains option bits */ + u8_t id; /* Current id */ + u8_t reqid; /* Current request id */ + u8_t retransmits; /* Number of retransmissions left */ + u8_t nakloops; /* Number of nak loops since last ack */ + u8_t rnakloops; /* Number of naks received */ + u8_t maxnakloops; /* Maximum number of nak loops tolerated + (necessary because IPCP require a custom large max nak loops value) */ + u8_t term_reason_len; /* Length of term_reason */ } fsm; typedef struct fsm_callbacks { - void (*resetci) /* Reset our Configuration Information */ - (fsm *); - int (*cilen) /* Length of our Configuration Information */ - (fsm *); - void (*addci) /* Add our Configuration Information */ - (fsm *, u_char *, int *); - int (*ackci) /* ACK our Configuration Information */ - (fsm *, u_char *, int); - int (*nakci) /* NAK our Configuration Information */ - (fsm *, u_char *, int, int); - int (*rejci) /* Reject our Configuration Information */ - (fsm *, u_char *, int); - int (*reqci) /* Request peer's Configuration Information */ - (fsm *, u_char *, int *, int); - void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */ - (fsm *); - void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */ - (fsm *); - void (*starting) /* Called when we want the lower layer */ - (fsm *); - void (*finished) /* Called when we don't want the lower layer */ - (fsm *); - void (*protreject) /* Called when Protocol-Reject received */ - (int); - void (*retransmit) /* Retransmission is necessary */ - (fsm *); - int (*extcode) /* Called when unknown code received */ - (fsm *, int, int, u_char *, int); - const char *proto_name; /* String name for protocol (for messages) */ + void (*resetci) /* Reset our Configuration Information */ + (fsm *); + int (*cilen) /* Length of our Configuration Information */ + (fsm *); + void (*addci) /* Add our Configuration Information */ + (fsm *, u_char *, int *); + int (*ackci) /* ACK our Configuration Information */ + (fsm *, u_char *, int); + int (*nakci) /* NAK our Configuration Information */ + (fsm *, u_char *, int, int); + int (*rejci) /* Reject our Configuration Information */ + (fsm *, u_char *, int); + int (*reqci) /* Request peer's Configuration Information */ + (fsm *, u_char *, int *, int); + void (*up) /* Called when fsm reaches PPP_FSM_OPENED state */ + (fsm *); + void (*down) /* Called when fsm leaves PPP_FSM_OPENED state */ + (fsm *); + void (*starting) /* Called when we want the lower layer */ + (fsm *); + void (*finished) /* Called when we don't want the lower layer */ + (fsm *); + void (*protreject) /* Called when Protocol-Reject received */ + (int); + void (*retransmit) /* Retransmission is necessary */ + (fsm *); + int (*extcode) /* Called when unknown code received */ + (fsm *, int, int, u_char *, int); + const char *proto_name; /* String name for protocol (for messages) */ } fsm_callbacks; /* * Link states. */ -#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */ -#define PPP_FSM_STARTING 1 /* Down, been opened */ -#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */ -#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */ -#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */ -#define PPP_FSM_STOPPING 5 /* Terminating, but open */ -#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */ -#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */ -#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */ -#define PPP_FSM_OPENED 9 /* Connection available */ +#define PPP_FSM_INITIAL 0 /* Down, hasn't been opened */ +#define PPP_FSM_STARTING 1 /* Down, been opened */ +#define PPP_FSM_CLOSED 2 /* Up, hasn't been opened */ +#define PPP_FSM_STOPPED 3 /* Open, waiting for down event */ +#define PPP_FSM_CLOSING 4 /* Terminating the connection, not open */ +#define PPP_FSM_STOPPING 5 /* Terminating, but open */ +#define PPP_FSM_REQSENT 6 /* We've sent a Config Request */ +#define PPP_FSM_ACKRCVD 7 /* We've received a Config Ack */ +#define PPP_FSM_ACKSENT 8 /* We've sent a Config Ack */ +#define PPP_FSM_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 */ +#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. */ #if 0 /* moved to ppp_opts.h */ -#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 */ +#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 */ #endif /* moved to ppp_opts.h */ diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/ipcp.h b/components/net/lwip-2.1.2/src/include/netif/ppp/ipcp.h index 32fdd1c641..6d822fef0c 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/ipcp.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/ipcp.h @@ -46,7 +46,7 @@ #if PPP_SUPPORT && PPP_IPV4_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef IPCP_H -#define IPCP_H +#define IPCP_H #ifdef __cplusplus extern "C" { @@ -55,32 +55,32 @@ extern "C" { /* * Options. */ -#define CI_ADDRS 1 /* IP Addresses */ +#define CI_ADDRS 1 /* IP Addresses */ #if VJ_SUPPORT -#define CI_COMPRESSTYPE 2 /* Compression Type */ +#define CI_COMPRESSTYPE 2 /* Compression Type */ #endif /* VJ_SUPPORT */ -#define CI_ADDR 3 +#define CI_ADDR 3 #if LWIP_DNS -#define CI_MS_DNS1 129 /* Primary DNS value */ +#define CI_MS_DNS1 129 /* Primary DNS value */ #define CI_MS_DNS2 131 /* Secondary DNS value */ #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define CI_MS_WINS1 130 /* Primary WINS value */ -#define CI_MS_WINS2 132 /* Secondary WINS value */ +#define CI_MS_WINS2 132 /* Secondary WINS value */ #endif /* UNUSED - WINS */ #if VJ_SUPPORT -#define MAX_STATES 16 /* from slcompress.h */ +#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, */ +#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*/ +#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*/ #endif /* VJ_SUPPORT */ typedef struct ipcp_options { @@ -106,17 +106,17 @@ typedef struct ipcp_options { unsigned int req_dns2 :1; /* Ask peer to send secondary DNS address? */ #endif /* LWIP_DNS */ - u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ + u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ #if LWIP_DNS - u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ + u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ + u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ #endif /* UNUSED - WINS */ #if VJ_SUPPORT - u16_t vj_protocol; /* protocol value to use in VJ option */ - u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */ + u16_t vj_protocol; /* protocol value to use in VJ option */ + u8_t maxslotindex; /* values for RFC1332 VJ compression neg. */ #endif /* VJ_SUPPORT */ } ipcp_options; diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/ipv6cp.h b/components/net/lwip-2.1.2/src/include/netif/ppp/ipv6cp.h index 9099973869..756b3ecd4c 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/ipv6cp.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/ipv6cp.h @@ -73,7 +73,7 @@ between BULL S.A. and INRIA). This software is available with usual "research" terms - with the aim of retain credits of the software. + 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, @@ -142,7 +142,7 @@ #if PPP_SUPPORT && PPP_IPV6_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef IPV6CP_H -#define IPV6CP_H +#define IPV6CP_H #include "eui64.h" @@ -153,13 +153,13 @@ extern "C" { /* * Options. */ -#define CI_IFACEID 1 /* Interface Identifier */ +#define CI_IFACEID 1 /* Interface Identifier */ #ifdef IPV6CP_COMP -#define CI_COMPRESSTYPE 2 /* Compression Type */ +#define CI_COMPRESSTYPE 2 /* Compression Type */ #endif /* IPV6CP_COMP */ /* No compression types yet defined. - *#define IPV6CP_COMP 0x004f + *#define IPV6CP_COMP 0x004f */ typedef struct ipv6cp_options { unsigned int neg_ifaceid :1; /* Negotiate interface identifier? */ diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/lcp.h b/components/net/lwip-2.1.2/src/include/netif/ppp/lcp.h index 18ad1cb23b..2b49bf7ede 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/lcp.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/lcp.h @@ -46,7 +46,7 @@ #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #ifndef LCP_H -#define LCP_H +#define LCP_H #include "ppp.h" @@ -57,55 +57,55 @@ extern "C" { /* * Options. */ -#define CI_VENDOR 0 /* Vendor Specific */ -#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_FCSALTERN 9 /* FCS-Alternatives */ -#define CI_SDP 10 /* Self-Describing-Pad */ -#define CI_NUMBERED 11 /* Numbered-Mode */ -#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 */ -#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */ -#define CI_LDISC 23 /* Link-Discriminator */ -#define CI_LCPAUTH 24 /* LCP Authentication */ -#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */ -#define CI_PREFELIS 26 /* Prefix Elision */ -#define CI_MPHDRFMT 27 /* MP Header Format */ -#define CI_I18N 28 /* Internationalization */ -#define CI_SDL 29 /* Simple Data Link */ +#define CI_VENDOR 0 /* Vendor Specific */ +#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_FCSALTERN 9 /* FCS-Alternatives */ +#define CI_SDP 10 /* Self-Describing-Pad */ +#define CI_NUMBERED 11 /* Numbered-Mode */ +#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 */ +#define CI_MPPLUS 22 /* Multi-Link-Plus-Procedure */ +#define CI_LDISC 23 /* Link-Discriminator */ +#define CI_LCPAUTH 24 /* LCP Authentication */ +#define CI_COBS 25 /* Consistent Overhead Byte Stuffing */ +#define CI_PREFELIS 26 /* Prefix Elision */ +#define CI_MPHDRFMT 27 /* MP Header Format */ +#define CI_I18N 28 /* Internationalization */ +#define CI_SDL 29 /* Simple Data Link */ /* * LCP-specific packet types (code numbers). */ -#define PROTREJ 8 /* Protocol Reject */ -#define ECHOREQ 9 /* Echo Request */ -#define ECHOREP 10 /* Echo Reply */ -#define DISCREQ 11 /* Discard Request */ -#define IDENTIF 12 /* Identification */ -#define TIMEREM 13 /* Time Remaining */ +#define PROTREJ 8 /* Protocol Reject */ +#define ECHOREQ 9 /* Echo Request */ +#define ECHOREP 10 /* Echo Reply */ +#define DISCREQ 11 /* Discard Request */ +#define IDENTIF 12 /* Identification */ +#define TIMEREM 13 /* Time Remaining */ /* Value used as data for CI_CALLBACK option */ -#define CBCP_OPT 6 /* Use callback control protocol */ +#define CBCP_OPT 6 /* Use callback control protocol */ #if 0 /* moved to ppp_opts.h */ -#define DEFMRU 1500 /* Try for this */ -#define MINMRU 128 /* No MRUs below this */ -#define MAXMRU 16384 /* Normally limit MRU to this */ +#define DEFMRU 1500 /* Try for this */ +#define MINMRU 128 /* No MRUs below this */ +#define MAXMRU 16384 /* Normally limit MRU to this */ #endif /* moved to ppp_opts.h */ /* An endpoint discriminator, used with multilink. */ -#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */ +#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */ struct epdisc { - unsigned char class_; /* -- The word "class" is reserved in C++. */ - unsigned char length; - unsigned char value[MAX_ENDP_LEN]; + unsigned char class_; /* -- The word "class" is reserved in C++. */ + unsigned char length; + unsigned char value[MAX_ENDP_LEN]; }; /* @@ -141,20 +141,20 @@ typedef struct lcp_options { unsigned int neg_ssnhf :1; /* negotiate short sequence numbers */ unsigned int neg_endpoint :1; /* negotiate endpoint discriminator */ - u16_t mru; /* Value of MRU */ + u16_t mru; /* Value of MRU */ #ifdef HAVE_MULTILINK - u16_t mrru; /* Value of MRRU, and multilink enable */ + u16_t mrru; /* Value of MRRU, and multilink enable */ #endif /* MULTILINK */ #if CHAP_SUPPORT - u8_t chap_mdtype; /* which MD types (hashing algorithm) */ + u8_t chap_mdtype; /* which MD types (hashing algorithm) */ #endif /* CHAP_SUPPORT */ - u32_t asyncmap; /* Value of async map */ + u32_t asyncmap; /* Value of async map */ u32_t magicnumber; - u8_t numloops; /* Number of loops during magic number neg. */ + u8_t numloops; /* Number of loops during magic number neg. */ #if LQR_SUPPORT - u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ + u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ #endif /* LQR_SUPPORT */ - struct epdisc endpoint; /* endpoint discriminator */ + struct epdisc endpoint; /* endpoint discriminator */ } lcp_options; void lcp_open(ppp_pcb *pcb); @@ -168,7 +168,7 @@ extern const struct protent lcp_protent; #if 0 /* moved to ppp_opts.h */ /* Default number of times we receive our magic number from the peer before deciding the link is looped-back. */ -#define DEFLOOPBACKFAIL 10 +#define DEFLOOPBACKFAIL 10 #endif /* moved to ppp_opts.h */ #ifdef __cplusplus diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/magic.h b/components/net/lwip-2.1.2/src/include/netif/ppp/magic.h index a165e18fa6..b937ec6d88 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/magic.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/magic.h @@ -102,7 +102,7 @@ void magic_randomize(void); /* * Return a new random number. */ -u32_t magic(void); /* Returns the next magic number */ +u32_t magic(void); /* Returns the next magic number */ /* * Fill buffer with random bytes diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/mppe.h b/components/net/lwip-2.1.2/src/include/netif/ppp/mppe.h index 5de1128479..55f0487b93 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/mppe.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/mppe.h @@ -45,19 +45,19 @@ extern "C" { #endif -#define MPPE_PAD 4 /* MPPE growth per frame */ -#define MPPE_MAX_KEY_LEN 16 /* largest key length (128-bit) */ +#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 */ +#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_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 */ +#define MPPE_OPT_UNKNOWN 0x40 /* Bits !defined in RFC 3078 were set */ /* * This is not nice ... the alternative is a bitfield struct though. @@ -66,70 +66,70 @@ extern "C" { * but then we have to do a lwip_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) */ +#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 */ \ +#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 { \ - const 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; \ +#define MPPE_CI_TO_OPTS(ci, opts) \ + do { \ + const 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) /* Shared MPPE padding between MSCHAP and MPPE */ @@ -152,18 +152,18 @@ static const u8_t mppe_sha1_pad2[SHA1_PAD_SIZE] = { * State for an MPPE (de)compressor. */ typedef struct ppp_mppe_state { - lwip_arc4_context arc4; - u8_t master_key[MPPE_MAX_KEY_LEN]; - u8_t session_key[MPPE_MAX_KEY_LEN]; - u8_t keylen; /* key length in bytes */ - /* NB: 128-bit == 16, 40-bit == 8! - * If we want to support 56-bit, the unit has to change to bits - */ - u8_t bits; /* MPPE control bits */ - u16_t ccount; /* 12-bit coherency count (seqno) */ - u16_t sanity_errors; /* take down LCP if too many */ - unsigned int stateful :1; /* stateful mode flag */ - unsigned int discard :1; /* stateful mode packet loss flag */ + lwip_arc4_context arc4; + u8_t master_key[MPPE_MAX_KEY_LEN]; + u8_t session_key[MPPE_MAX_KEY_LEN]; + u8_t keylen; /* key length in bytes */ + /* NB: 128-bit == 16, 40-bit == 8! + * If we want to support 56-bit, the unit has to change to bits + */ + u8_t bits; /* MPPE control bits */ + u16_t ccount; /* 12-bit coherency count (seqno) */ + u16_t sanity_errors; /* take down LCP if too many */ + unsigned int stateful :1; /* stateful mode flag */ + unsigned int discard :1; /* stateful mode packet loss flag */ } ppp_mppe_state; void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key); diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/arc4.h b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/arc4.h index 4af724cd90..91b08e6779 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/arc4.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/arc4.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/des.h b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/des.h index e893890ed7..5e3a085165 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/des.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/des.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md4.h b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md4.h index 570445687e..a4aa1dcc83 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md4.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md4.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md5.h b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md5.h index 1244011890..4d7b04d8d0 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md5.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/md5.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/sha1.h b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/sha1.h index a4c53e07c5..d8f347c64e 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/sha1.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/polarssl/sha1.h @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/ppp.h b/components/net/lwip-2.1.2/src/include/netif/ppp/ppp.h index 3d73c36570..eea52f8cd8 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/ppp.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/ppp.h @@ -7,13 +7,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -107,8 +107,8 @@ extern "C" { /* * The basic PPP frame. */ -#define PPP_HDRLEN 4 /* octets for standard ppp header */ -#define PPP_FCSLEN 2 /* octets for FCS */ +#define PPP_HDRLEN 4 /* octets for standard ppp header */ +#define PPP_FCSLEN 2 /* octets for FCS */ /* * Values for phase. diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/ppp_impl.h b/components/net/lwip-2.1.2/src/include/netif/ppp/ppp_impl.h index 40843d5a0a..29a85c6827 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/ppp_impl.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/ppp_impl.h @@ -74,66 +74,66 @@ extern "C" { /* * The basic PPP frame. */ -#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]) +#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]) /* * 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 */ +#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_IP 0x21 /* Internet Protocol */ #if 0 /* UNUSED */ -#define PPP_AT 0x29 /* AppleTalk Protocol */ -#define PPP_IPX 0x2b /* IPX protocol */ +#define PPP_AT 0x29 /* AppleTalk Protocol */ +#define PPP_IPX 0x2b /* IPX protocol */ #endif /* UNUSED */ #if VJ_SUPPORT -#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ -#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ +#define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ +#define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ #endif /* VJ_SUPPORT */ #if PPP_IPV6_SUPPORT -#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ +#define PPP_IPV6 0x57 /* Internet Protocol Version 6 */ #endif /* PPP_IPV6_SUPPORT */ #if CCP_SUPPORT -#define PPP_COMP 0xfd /* compressed packet */ +#define PPP_COMP 0xfd /* compressed packet */ #endif /* CCP_SUPPORT */ -#define PPP_IPCP 0x8021 /* IP Control Protocol */ +#define PPP_IPCP 0x8021 /* IP Control Protocol */ #if 0 /* UNUSED */ -#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ -#define PPP_IPXCP 0x802b /* IPX Control Protocol */ +#define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ +#define PPP_IPXCP 0x802b /* IPX Control Protocol */ #endif /* UNUSED */ #if PPP_IPV6_SUPPORT -#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ +#define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ #endif /* PPP_IPV6_SUPPORT */ #if CCP_SUPPORT -#define PPP_CCP 0x80fd /* Compression Control Protocol */ +#define PPP_CCP 0x80fd /* Compression Control Protocol */ #endif /* CCP_SUPPORT */ #if ECP_SUPPORT -#define PPP_ECP 0x8053 /* Encryption Control Protocol */ +#define PPP_ECP 0x8053 /* Encryption Control Protocol */ #endif /* ECP_SUPPORT */ -#define PPP_LCP 0xc021 /* Link Control Protocol */ +#define PPP_LCP 0xc021 /* Link Control Protocol */ #if PAP_SUPPORT -#define PPP_PAP 0xc023 /* Password Authentication Protocol */ +#define PPP_PAP 0xc023 /* Password Authentication Protocol */ #endif /* PAP_SUPPORT */ #if LQR_SUPPORT -#define PPP_LQR 0xc025 /* Link Quality Report protocol */ +#define PPP_LQR 0xc025 /* Link Quality Report protocol */ #endif /* LQR_SUPPORT */ #if CHAP_SUPPORT -#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ +#define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ #endif /* CHAP_SUPPORT */ #if CBCP_SUPPORT -#define PPP_CBCP 0xc029 /* Callback Control Protocol */ +#define PPP_CBCP 0xc029 /* Callback Control Protocol */ #endif /* CBCP_SUPPORT */ #if EAP_SUPPORT -#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ +#define PPP_EAP 0xc227 /* Extensible Authentication Protocol */ #endif /* EAP_SUPPORT */ /* @@ -165,59 +165,59 @@ struct link_callbacks { * What to do with network protocol (NP) packets. */ 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. */ + 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. */ #if PPP_STATS_SUPPORT -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 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 */ }; #if VJ_SUPPORT struct vjstat { - unsigned int vjs_packets; /* outbound packets */ + 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_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 */ + unsigned int vjs_errorin; /* inbound unknown type packets */ + unsigned int vjs_tossed; /* inbound packets tossed because of error */ }; #endif /* VJ_SUPPORT */ struct ppp_stats { - struct pppstat p; /* basic PPP statistics */ + struct pppstat p; /* basic PPP statistics */ #if VJ_SUPPORT - struct vjstat vj; /* VJ header compression statistics */ + struct vjstat vj; /* VJ header compression statistics */ #endif /* VJ_SUPPORT */ }; #if CCP_SUPPORT 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 */ + 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 */ + struct compstat c; /* packet compression statistics */ + struct compstat d; /* packet decompression statistics */ }; #endif /* CCP_SUPPORT */ @@ -229,37 +229,37 @@ struct ppp_comp_stats { * 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 */ + time_t xmit_idle; /* time since last NP packet sent */ + time_t recv_idle; /* time since last NP packet received */ }; #endif /* PPP_IDLETIMELIMIT */ /* values for epdisc.class */ -#define EPD_NULL 0 /* null discriminator, no data */ -#define EPD_LOCAL 1 -#define EPD_IP 2 -#define EPD_MAC 3 -#define EPD_MAGIC 4 -#define EPD_PHONENUM 5 +#define EPD_NULL 0 /* null discriminator, no data */ +#define EPD_LOCAL 1 +#define EPD_IP 2 +#define EPD_MAC 3 +#define EPD_MAGIC 4 +#define EPD_PHONENUM 5 /* * Global variables. */ #ifdef HAVE_MULTILINK -extern u8_t multilink; /* enable multilink operation */ -extern u8_t doing_multilink; -extern u8_t multilink_master; -extern u8_t bundle_eof; -extern u8_t bundle_terminating; +extern u8_t multilink; /* enable multilink operation */ +extern u8_t doing_multilink; +extern u8_t multilink_master; +extern u8_t bundle_eof; +extern u8_t bundle_terminating; #endif #ifdef MAXOCTETS -extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ +extern unsigned int maxoctets; /* Maximum octetes per session (in bytes) */ extern int maxoctets_dir; /* Direction : - 0 - in+out (default) - 1 - in - 2 - out - 3 - max(in,out) */ + 0 - in+out (default) + 1 - in + 2 - out + 3 - max(in,out) */ extern int maxoctets_timeout; /* Timeout for check of octets limit */ #define PPP_OCTETS_DIRECTION_SUM 0 #define PPP_OCTETS_DIRECTION_IN 1 @@ -279,7 +279,7 @@ extern int maxoctets_timeout; /* Timeout for check of octets limit */ * for a particular protocol. */ struct protent { - u_short protocol; /* PPP protocol number */ + u_short protocol; /* PPP protocol number */ /* Initialization procedure */ void (*init) (ppp_pcb *pcb); /* Process a received packet */ @@ -297,19 +297,19 @@ struct protent { #if PRINTPKT_SUPPORT /* Print a packet in readable form */ int (*printpkt) (const u_char *pkt, int len, - void (*printer) (void *, const char *, ...), - void *arg); + void (*printer) (void *, const char *, ...), + void *arg); #endif /* PRINTPKT_SUPPORT */ #if PPP_DATAINPUT /* Process a received data packet */ void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len); #endif /* PPP_DATAINPUT */ #if PRINTPKT_SUPPORT - const char *name; /* Text name of protocol */ - const char *data_name; /* Text name of corresponding data protocol */ + const char *name; /* Text name of protocol */ + const char *data_name; /* Text name of corresponding data protocol */ #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS - option_t *options; /* List of command-line options */ + option_t *options; /* List of command-line options */ /* Check requested options, assign defaults */ void (*check_options) (void); #endif /* PPP_OPTIONS */ @@ -327,28 +327,28 @@ extern const struct protent* const protocols[]; /* Values for auth_pending, auth_done */ #if PAP_SUPPORT -#define PAP_WITHPEER 0x1 -#define PAP_PEER 0x2 +#define PAP_WITHPEER 0x1 +#define PAP_PEER 0x2 #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT -#define CHAP_WITHPEER 0x4 -#define CHAP_PEER 0x8 +#define CHAP_WITHPEER 0x4 +#define CHAP_PEER 0x8 #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT -#define EAP_WITHPEER 0x10 -#define EAP_PEER 0x20 +#define EAP_WITHPEER 0x10 +#define EAP_PEER 0x20 #endif /* EAP_SUPPORT */ /* Values for auth_done only */ #if CHAP_SUPPORT -#define CHAP_MD5_WITHPEER 0x40 -#define CHAP_MD5_PEER 0x80 +#define CHAP_MD5_WITHPEER 0x40 +#define CHAP_MD5_PEER 0x80 #if MSCHAP_SUPPORT -#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */ -#define CHAP_MS_WITHPEER 0x100 -#define CHAP_MS_PEER 0x200 -#define CHAP_MS2_WITHPEER 0x400 -#define CHAP_MS2_PEER 0x800 +#define CHAP_MS_SHIFT 8 /* LSB position for MS auths */ +#define CHAP_MS_WITHPEER 0x100 +#define CHAP_MS_PEER 0x200 +#define CHAP_MS2_WITHPEER 0x400 +#define CHAP_MS2_PEER 0x800 #endif /* MSCHAP_SUPPORT */ #endif /* CHAP_SUPPORT */ @@ -370,10 +370,10 @@ extern const struct protent* const protocols[]; * PPP statistics structure */ struct pppd_stats { - unsigned int bytes_in; - unsigned int bytes_out; - unsigned int pkts_in; - unsigned int pkts_out; + unsigned int bytes_in; + unsigned int bytes_out; + unsigned int pkts_in; + unsigned int pkts_out; }; #endif /* PPP_STATS_SUPPORT */ @@ -382,7 +382,7 @@ struct pppd_stats { * PPP private functions */ - + /* * Functions called from lwIP core. */ @@ -500,34 +500,34 @@ void update_link_stats(int u); /* Get stats at link termination */ * cp MUST be u_char *. */ #define GETCHAR(c, cp) { \ - (c) = *(cp)++; \ + (c) = *(cp)++; \ } #define PUTCHAR(c, cp) { \ - *(cp)++ = (u_char) (c); \ + *(cp)++ = (u_char) (c); \ } #define GETSHORT(s, cp) { \ - (s) = *(cp)++ << 8; \ - (s) |= *(cp)++; \ + (s) = *(cp)++ << 8; \ + (s) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ - *(cp)++ = (u_char) ((s) >> 8); \ - *(cp)++ = (u_char) (s); \ + *(cp)++ = (u_char) ((s) >> 8); \ + *(cp)++ = (u_char) (s); \ } #define GETLONG(l, cp) { \ - (l) = *(cp)++ << 8; \ - (l) |= *(cp)++; (l) <<= 8; \ - (l) |= *(cp)++; (l) <<= 8; \ - (l) |= *(cp)++; \ + (l) = *(cp)++ << 8; \ + (l) |= *(cp)++; (l) <<= 8; \ + (l) |= *(cp)++; (l) <<= 8; \ + (l) |= *(cp)++; \ } #define PUTLONG(l, cp) { \ - *(cp)++ = (u_char) ((l) >> 24); \ - *(cp)++ = (u_char) ((l) >> 16); \ - *(cp)++ = (u_char) ((l) >> 8); \ - *(cp)++ = (u_char) (l); \ + *(cp)++ = (u_char) ((l) >> 24); \ + *(cp)++ = (u_char) ((l) >> 16); \ + *(cp)++ = (u_char) ((l) >> 8); \ + *(cp)++ = (u_char) (l); \ } -#define INCPTR(n, cp) ((cp) += (n)) -#define DECPTR(n, cp) ((cp) -= (n)) +#define INCPTR(n, cp) ((cp) += (n)) +#define DECPTR(n, cp) ((cp) -= (n)) /* * System dependent definitions for user-level 4.3BSD UNIX implementation. @@ -536,10 +536,10 @@ void update_link_stats(int u); /* Get stats at link termination */ #define TIMEOUTMS(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t), (f), (a)); } while(0) #define UNTIMEOUT(f, a) sys_untimeout((f), (a)) -#define BZERO(s, n) memset(s, 0, n) -#define BCMP(s1, s2, l) memcmp(s1, s2, l) +#define BZERO(s, n) memset(s, 0, n) +#define BCMP(s1, s2, l) memcmp(s1, s2, l) -#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); } +#define PRINTMSG(m, l) { ppp_info("Remote message: %0.*v", l, m); } /* * MAKEHEADER - Add Header fields to a packet. @@ -552,7 +552,7 @@ void update_link_stats(int u); /* Get stats at link termination */ /* Procedures exported from auth.c */ void link_required(ppp_pcb *pcb); /* we are starting to use the link */ void link_terminated(ppp_pcb *pcb); /* we are finished with the link */ -void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */ +void link_down(ppp_pcb *pcb); /* the LCP layer has left the Opened state */ void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */ void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */ void start_networks(ppp_pcb *pcb); /* start all the network control protos */ @@ -562,21 +562,21 @@ void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos int auth_check_passwd(ppp_pcb *pcb, char *auser, int userlen, char *apasswd, int passwdlen, const char **msg, int *msglen); /* check the user name and passwd against configuration */ void auth_peer_fail(ppp_pcb *pcb, int protocol); - /* peer failed to authenticate itself */ + /* peer failed to authenticate itself */ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char *name, int namelen); - /* peer successfully authenticated itself */ + /* peer successfully authenticated itself */ #endif /* PPP_SERVER */ void auth_withpeer_fail(ppp_pcb *pcb, int protocol); - /* we failed to authenticate ourselves */ + /* we failed to authenticate ourselves */ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor); - /* we successfully authenticated ourselves */ + /* we successfully authenticated ourselves */ #endif /* PPP_AUTH_SUPPORT */ void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */ void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */ void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */ #if PPP_AUTH_SUPPORT int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secret, int *secret_len, int am_server); - /* get "secret" for chap */ + /* get "secret" for chap */ #endif /* PPP_AUTH_SUPPORT */ /* Procedures exported from ipcp.c */ @@ -584,8 +584,8 @@ int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secre /* Procedures exported from demand.c */ #if DEMAND_SUPPORT -void demand_conf (void); /* config interface(s) for demand-dial */ -void demand_block (void); /* set all NPs to queue up packets */ +void demand_conf (void); /* config interface(s) for demand-dial */ +void demand_block (void); /* set all NPs to queue up packets */ void demand_unblock (void); /* set all NPs to pass packets */ void demand_discard (void); /* set all NPs to discard packets */ void demand_rexmit (int, u32_t); /* retransmit saved frames for an NP*/ @@ -602,10 +602,10 @@ void mp_bundle_terminated (void); char *epdisc_to_str (struct epdisc *); /* string from endpoint discrim. */ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */ #else -#define mp_bundle_terminated() /* nothing */ -#define mp_exit_bundle() /* nothing */ -#define doing_multilink 0 -#define multilink_master 0 +#define mp_bundle_terminated() /* nothing */ +#define mp_exit_bundle() /* nothing */ +#define doing_multilink 0 +#define multilink_master 0 #endif /* Procedures exported from utils.c. */ diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/pppcrypt.h b/components/net/lwip-2.1.2/src/include/netif/ppp/pppcrypt.h index c0230bbcb7..2531ee0a99 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/pppcrypt.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/pppcrypt.h @@ -36,7 +36,7 @@ /* This header file is included in all PPP modules needing hashes and/or ciphers */ #ifndef PPPCRYPT_H -#define PPPCRYPT_H +#define PPPCRYPT_H /* * If included PolarSSL copy is not used, user is expected to include diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/pppdebug.h b/components/net/lwip-2.1.2/src/include/netif/ppp/pppdebug.h index 36ee4f9bf9..5e6741bf01 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/pppdebug.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/pppdebug.h @@ -8,13 +8,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/pppoe.h b/components/net/lwip-2.1.2/src/include/netif/ppp/pppoe.h index 08ab7ab54e..c96eb784dd 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/pppoe.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/pppoe.h @@ -6,13 +6,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, diff --git a/components/net/lwip-2.1.2/src/include/netif/ppp/upap.h b/components/net/lwip-2.1.2/src/include/netif/ppp/upap.h index 540d981492..caf81939d8 100644 --- a/components/net/lwip-2.1.2/src/include/netif/ppp/upap.h +++ b/components/net/lwip-2.1.2/src/include/netif/ppp/upap.h @@ -57,44 +57,44 @@ extern "C" { /* * Packet header = Code, id, length. */ -#define UPAP_HEADERLEN 4 +#define UPAP_HEADERLEN 4 /* * UPAP codes. */ -#define UPAP_AUTHREQ 1 /* Authenticate-Request */ -#define UPAP_AUTHACK 2 /* Authenticate-Ack */ -#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ +#define UPAP_AUTHREQ 1 /* Authenticate-Request */ +#define UPAP_AUTHACK 2 /* Authenticate-Ack */ +#define UPAP_AUTHNAK 3 /* Authenticate-Nak */ /* * Client states. */ -#define UPAPCS_INITIAL 0 /* Connection down */ -#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ -#define UPAPCS_OPEN 4 /* We've received an Ack */ -#define UPAPCS_BADAUTH 5 /* We've received a Nak */ +#define UPAPCS_INITIAL 0 /* Connection down */ +#define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPCS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ +#define UPAPCS_OPEN 4 /* We've received an Ack */ +#define UPAPCS_BADAUTH 5 /* We've received a Nak */ /* * Server states. */ -#define UPAPSS_INITIAL 0 /* Connection down */ -#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ -#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ -#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ -#define UPAPSS_OPEN 4 /* We've sent an Ack */ -#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ +#define UPAPSS_INITIAL 0 /* Connection down */ +#define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ +#define UPAPSS_PENDING 2 /* Connection down, have requested auth */ +#define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ +#define UPAPSS_OPEN 4 /* We've sent an Ack */ +#define UPAPSS_BADAUTH 5 /* We've sent a Nak */ /* * Timeouts. */ #if 0 /* moved to ppp_opts.h */ -#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ -#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ +#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */ +#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ #endif /* moved to ppp_opts.h */ /* @@ -102,16 +102,16 @@ extern "C" { */ #if PAP_SUPPORT typedef struct upap_state { - const char *us_user; /* User */ - u8_t us_userlen; /* User length */ - const char *us_passwd; /* Password */ - u8_t us_passwdlen; /* Password length */ - u8_t us_clientstate; /* Client state */ + const char *us_user; /* User */ + u8_t us_userlen; /* User length */ + const char *us_passwd; /* Password */ + u8_t us_passwdlen; /* Password length */ + u8_t us_clientstate; /* Client state */ #if PPP_SERVER - u8_t us_serverstate; /* Server state */ + u8_t us_serverstate; /* Server state */ #endif /* PPP_SERVER */ - u8_t us_id; /* Current id */ - u8_t us_transmits; /* Number of auth-reqs sent */ + u8_t us_id; /* Current id */ + u8_t us_transmits; /* Number of auth-reqs sent */ } upap_state; #endif /* PAP_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/bridgeif_fdb.c b/components/net/lwip-2.1.2/src/netif/bridgeif_fdb.c index 6739fc247c..2f052ec093 100644 --- a/components/net/lwip-2.1.2/src/netif/bridgeif_fdb.c +++ b/components/net/lwip-2.1.2/src/netif/bridgeif_fdb.c @@ -69,7 +69,7 @@ typedef struct bridgeif_dfdb_s { * remembers known src mac addresses to know which port to send frames destined for that * mac address. * - * ATTENTION: This is meant as an example only, in real-world use, you should + * ATTENTION: This is meant as an example only, in real-world use, you should * provide a better implementation :-) */ void @@ -120,9 +120,9 @@ bridgeif_fdb_update_src(void *fdb_ptr, struct eth_addr *src_addr, u8_t port_idx) /* not found, no free entry -> flood */ } -/** +/** * @ingroup bridgeif_fdb - * Walk our list of auto-learnt fdb entries and return a port to forward or BR_FLOOD if unknown + * Walk our list of auto-learnt fdb entries and return a port to forward or BR_FLOOD if unknown */ bridgeif_portmask_t bridgeif_fdb_get_dst_ports(void *fdb_ptr, struct eth_addr *dst_addr) diff --git a/components/net/lwip-2.1.2/src/netif/ethernetif.c b/components/net/lwip-2.1.2/src/netif/ethernetif.c index 52bd0fb7b6..829978c139 100644 --- a/components/net/lwip-2.1.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.1.2/src/netif/ethernetif.c @@ -1,6 +1,6 @@ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. - * COPYRIGHT (C) 2006-2018, RT-Thread Development Team + * COPYRIGHT (C) 2006-2021, RT-Thread Development Team * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -163,16 +163,16 @@ static int lwip_netdev_set_dns_server(struct netdev *netif, uint8_t dns_num, ip_ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) { netdev_low_level_set_dhcp_status(netif, is_enabled); - + if(RT_TRUE == is_enabled) { dhcp_start((struct netif *)netif->user_data); } else { - dhcp_stop((struct netif *)netif->user_data); + dhcp_stop((struct netif *)netif->user_data); } - + return ERR_OK; } #endif /* RT_LWIP_DHCP */ @@ -182,7 +182,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) extern int lwip_ping_recv(int s, int *ttl); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); -int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, +int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, uint32_t timeout, struct netdev_ping_resp *ping_resp) { int s, ttl, recv_len, result = 0; @@ -197,7 +197,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, struct addrinfo hint, *res = RT_NULL; struct sockaddr_in *h = RT_NULL; struct in_addr ina; - + RT_ASSERT(netif); RT_ASSERT(host); RT_ASSERT(ping_resp); @@ -216,7 +216,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, return -RT_ERROR; } rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t)); - + /* new a socket */ if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0) { @@ -284,7 +284,7 @@ const struct netdev_ops lwip_netdev_ops = lwip_netdev_set_addr_info, #ifdef RT_LWIP_DNS lwip_netdev_set_dns_server, -#else +#else NULL, #endif /* RT_LWIP_DNS */ @@ -323,7 +323,7 @@ static int netdev_add(struct netif *lwip_netif) { return -ERR_IF; } - + #ifdef SAL_USING_LWIP extern int sal_lwip_netdev_set_pf_info(struct netdev *netdev); /* set the lwIP network interface device protocol family information */ @@ -332,7 +332,7 @@ static int netdev_add(struct netif *lwip_netif) rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN); result = netdev_register(netdev, name, (void *)lwip_netif); - + /* Update netdev info after registered */ netdev->flags = lwip_netif->flags; netdev->mtu = lwip_netif->mtu; @@ -375,7 +375,7 @@ static int netdev_flags_sync(struct netif *lwip_netif) { return -ERR_IF; } - + netdev->mtu = lwip_netif->mtu; netdev->flags |= lwip_netif->flags; @@ -438,7 +438,7 @@ static err_t eth_netif_device_init(struct netif *netif) /* copy device flags to netif flags */ netif->flags = (ethif->flags & 0xff); netif->mtu = ETHERNET_MTU; - + /* set output */ netif->output = etharp_output; @@ -530,7 +530,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ /* set linkoutput */ netif->linkoutput = ethernetif_linkoutput; - + /* get hardware MAC address */ rt_device_control(&(dev->parent), NIOCTL_GADDR, netif->hwaddr); @@ -550,7 +550,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ ipaddr.addr = inet_addr(RT_LWIP_IPADDR); gw.addr = inet_addr(RT_LWIP_GWADDR); netmask.addr = inet_addr(RT_LWIP_MSKADDR); -#else +#else IP4_ADDR(&ipaddr, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); @@ -702,7 +702,7 @@ static void eth_rx_thread_entry(void* parameter) while (1) { if(device->eth_rx == RT_NULL) break; - + p = device->eth_rx(&(device->parent)); if (p != RT_NULL) { @@ -725,9 +725,9 @@ static void eth_rx_thread_entry(void* parameter) } #endif -/* this function does not need, - * use eth_system_device_init_private() - * call by lwip_system_init(). +/* this function does not need, + * use eth_system_device_init_private() + * call by lwip_system_init(). */ int eth_system_device_init(void) { @@ -870,27 +870,27 @@ void list_if(void) rt_kprintf("gw address: %s\n", ipaddr_ntoa(&(netif->gw))); rt_kprintf("net mask : %s\n", ipaddr_ntoa(&(netif->netmask))); #if LWIP_IPV6 - { - ip6_addr_t *addr; - int addr_state; - int i; - - addr = (ip6_addr_t *)&netif->ip6_addr[0]; - addr_state = netif->ip6_addr_state[0]; - - rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr), - addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); - - for(i=1; iip6_addr[i]; - addr_state = netif->ip6_addr_state[i]; - - rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr), - addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); - } - - } + { + ip6_addr_t *addr; + int addr_state; + int i; + + addr = (ip6_addr_t *)&netif->ip6_addr[0]; + addr_state = netif->ip6_addr_state[0]; + + rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr), + addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); + + for(i=1; iip6_addr[i]; + addr_state = netif->ip6_addr_state[i]; + + rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr), + addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); + } + + } rt_kprintf("\r\n"); #endif /* LWIP_IPV6 */ netif = netif->next; diff --git a/components/net/lwip-2.1.2/src/netif/lowpan6_ble.c b/components/net/lwip-2.1.2/src/netif/lowpan6_ble.c index d89816d3b0..d59b432f53 100644 --- a/components/net/lwip-2.1.2/src/netif/lowpan6_ble.c +++ b/components/net/lwip-2.1.2/src/netif/lowpan6_ble.c @@ -6,7 +6,7 @@ /* * Copyright (c) 2017 Benjamin Aigner * Copyright (c) 2015 Inico Technologies Ltd. , Author: Ivan Delamer - * + * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -32,7 +32,7 @@ * OF SUCH DAMAGE. * * Author: Benjamin Aigner - * + * * Based on the original 6lowpan implementation of lwIP ( @see 6lowpan.c) */ @@ -95,15 +95,15 @@ static struct lowpan6_link_addr rfc7668_peer_addr; /** * @ingroup rfc7668if * convert BT address to EUI64 addr - * + * * This method converts a Bluetooth MAC address to an EUI64 address, * which is used within IPv6 communication - * + * * @param dst IPv6 destination space * @param src BLE MAC address source * @param public_addr If the LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS * option is set, bit 0x02 will be set if param=0 (no public addr); cleared otherwise - * + * * @see LWIP_RFC7668_LINUX_WORKAROUND_PUBLIC_ADDRESS */ void @@ -128,12 +128,12 @@ ble_addr_to_eui64(uint8_t *dst, const uint8_t *src, int public_addr) /** * @ingroup rfc7668if * convert EUI64 address to Bluetooth MAC addr - * + * * This method converts an EUI64 address to a Bluetooth MAC address, - * + * * @param dst BLE MAC address destination * @param src IPv6 source - * + * */ void eui64_to_ble_addr(uint8_t *dst, const uint8_t *src) @@ -214,16 +214,16 @@ rfc7668_set_peer_addr_mac48(struct netif *netif, const u8_t *peer_addr, size_t p } /** Encapsulate IPv6 frames for BLE transmission - * + * * This method implements the IPv6 header compression: * *) According to RFC6282 * *) See Figure 2, contains base format of bit positions * *) Fragmentation not necessary (done at L2CAP layer of BLE) * @note Currently the pbuf allocation uses 256 bytes. If longer packets are used (possible due to MTU=1480Bytes), increase it here! - * + * * @param p Pbuf struct, containing the payload data * @param netif Output network interface. Should be of RFC7668 type - * + * * @return Same as netif->output. */ static err_t @@ -340,7 +340,7 @@ rfc7668_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr) * @param p the received packet, p->payload pointing to the * IPv6 header (maybe compressed) * @param netif the network interface on which the packet was received - * + * * @return ERR_OK if everything was fine */ err_t @@ -352,7 +352,7 @@ rfc7668_input(struct pbuf * p, struct netif *netif) /* Load first header byte */ puc = (u8_t*)p->payload; - + /* no IP header compression */ if (*puc == 0x41) { LWIP_DEBUGF(LWIP_LOWPAN6_DECOMPRESSION_DEBUG, ("Completed packet, removing dispatch: 0x%2x \n", *puc)); @@ -398,12 +398,12 @@ rfc7668_input(struct pbuf * p, struct netif *netif) /** * @ingroup rfc7668if * Initialize the netif - * + * * No flags are used (broadcast not possible, not ethernet, ...) * The shortname for this netif is "BT" * * @param netif the network interface to be initialized as RFC7668 netif - * + * * @return ERR_OK if everything went fine */ err_t @@ -433,7 +433,7 @@ rfc7668_if_init(struct netif *netif) * @param p the received packet, p->payload pointing to the * IEEE 802.15.4 header. * @param inp the network interface on which the packet was received - * + * * @return see @ref tcpip_inpkt, same return values */ err_t diff --git a/components/net/lwip-2.1.2/src/netif/lowpan6_common.c b/components/net/lwip-2.1.2/src/netif/lowpan6_common.c index baea206a71..89758d94d9 100644 --- a/components/net/lwip-2.1.2/src/netif/lowpan6_common.c +++ b/components/net/lwip-2.1.2/src/netif/lowpan6_common.c @@ -430,7 +430,7 @@ lowpan6_decompress_hdr(u8_t *lowpan6_buffer, size_t lowpan6_bufsize, /* offset for inline IP headers (RFC 6282 ch3)*/ lowpan6_offset = 2; - /* if CID is set (context identifier), the context byte + /* if CID is set (context identifier), the context byte * follows immediately after the header, so other IPHC fields are @+3 */ if (lowpan6_buffer[1] & 0x80) { lowpan6_offset++; diff --git a/components/net/lwip-2.1.2/src/netif/ppp/auth.c b/components/net/lwip-2.1.2/src/netif/ppp/auth.c index c8673ad0fb..480a653ddd 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/auth.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/auth.c @@ -133,10 +133,10 @@ #if 0 /* UNUSED */ /* Bits in scan_authfile return value */ -#define NONWILD_SERVER 1 -#define NONWILD_CLIENT 2 +#define NONWILD_SERVER 1 +#define NONWILD_CLIENT 2 -#define ISWILD(word) (word[0] == '*' && word[1] == 0) +#define ISWILD(word) (word[0] == '*' && word[1] == 0) #endif /* UNUSED */ #if 0 /* UNUSED */ @@ -169,8 +169,8 @@ int (*pap_check_hook) (void) = NULL; /* Hook for a plugin to check the PAP user and password */ int (*pap_auth_hook) (char *user, char *passwd, char **msgp, - struct wordlist **paddrs, - struct wordlist **popts) = NULL; + struct wordlist **paddrs, + struct wordlist **popts) = NULL; /* Hook for a plugin to know about the PAP user logout */ void (*pap_logout_hook) (void) = NULL; @@ -187,7 +187,7 @@ int (*chap_passwd_hook) (char *user, char *passwd) = NULL; /* Hook for a plugin to say whether it is OK if the peer refuses to authenticate. */ int (*null_auth_hook) (struct wordlist **paddrs, - struct wordlist **popts) = NULL; + struct wordlist **popts) = NULL; int (*allowed_address_hook) (u32_t addr) = NULL; #endif /* UNUSED */ @@ -210,27 +210,27 @@ struct notifier *link_down_notifier = NULL; * Option variables. */ #if 0 /* MOVED TO ppp_settings */ -bool uselogin = 0; /* Use /etc/passwd for checking PAP */ -bool session_mgmt = 0; /* Do session management (login records) */ -bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ -bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ -bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ -bool refuse_eap = 0; /* Don't wanna auth. ourselves with EAP */ +bool uselogin = 0; /* Use /etc/passwd for checking PAP */ +bool session_mgmt = 0; /* Do session management (login records) */ +bool cryptpap = 0; /* Passwords in pap-secrets are encrypted */ +bool refuse_pap = 0; /* Don't wanna auth. ourselves with PAP */ +bool refuse_chap = 0; /* Don't wanna auth. ourselves with CHAP */ +bool refuse_eap = 0; /* Don't wanna auth. ourselves with EAP */ #if MSCHAP_SUPPORT -bool refuse_mschap = 0; /* Don't wanna auth. ourselves with MS-CHAP */ -bool refuse_mschap_v2 = 0; /* Don't wanna auth. ourselves with MS-CHAPv2 */ +bool refuse_mschap = 0; /* Don't wanna auth. ourselves with MS-CHAP */ +bool refuse_mschap_v2 = 0; /* Don't wanna auth. ourselves with MS-CHAPv2 */ #else /* MSCHAP_SUPPORT */ -bool refuse_mschap = 1; /* Don't wanna auth. ourselves with MS-CHAP */ -bool refuse_mschap_v2 = 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ +bool refuse_mschap = 1; /* Don't wanna auth. ourselves with MS-CHAP */ +bool refuse_mschap_v2 = 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ #endif /* MSCHAP_SUPPORT */ -bool usehostname = 0; /* Use hostname for our_name */ -bool auth_required = 0; /* Always require authentication from peer */ -bool allow_any_ip = 0; /* Allow peer to use any IP address */ -bool explicit_remote = 0; /* User specified explicit remote name */ -bool explicit_user = 0; /* Set if "user" option supplied */ -bool explicit_passwd = 0; /* Set if "password" option supplied */ -char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ -static char *uafname; /* name of most recent +ua file */ +bool usehostname = 0; /* Use hostname for our_name */ +bool auth_required = 0; /* Always require authentication from peer */ +bool allow_any_ip = 0; /* Allow peer to use any IP address */ +bool explicit_remote = 0; /* User specified explicit remote name */ +bool explicit_user = 0; /* Set if "user" option supplied */ +bool explicit_passwd = 0; /* Set if "password" option supplied */ +char remote_name[MAXNAMELEN]; /* Peer's name for authentication */ +static char *uafname; /* name of most recent +ua file */ extern char *crypt (const char *, const char *); #endif /* UNUSED */ @@ -252,8 +252,8 @@ static int have_srp_secret (char *client, char *server, int need_ip, int *lacks_ipp); static int ip_addr_check (u32_t, struct permitted_ip *); static int scan_authfile (FILE *, char *, char *, char *, - struct wordlist **, struct wordlist **, - char *, int); + struct wordlist **, struct wordlist **, + char *, int); static void free_wordlist (struct wordlist *); static void set_allowed_addrs (int, struct wordlist *, struct wordlist *); static int some_ip_ok (struct wordlist *); @@ -427,46 +427,46 @@ setupapfile(argv) /* open user info file */ fname = strdup(*argv); if (fname == NULL) - novm("+ua file name"); + novm("+ua file name"); euid = geteuid(); if (seteuid(getuid()) == -1) { - option_error("unable to reset uid before opening %s: %m", fname); - return 0; + option_error("unable to reset uid before opening %s: %m", fname); + return 0; } ufile = fopen(fname, "r"); if (seteuid(euid) == -1) - fatal("unable to regain privileges: %m"); + fatal("unable to regain privileges: %m"); if (ufile == NULL) { - option_error("unable to open user login data file %s", fname); - return 0; + option_error("unable to open user login data file %s", fname); + return 0; } check_access(ufile, fname); uafname = fname; /* get username */ if (fgets(u, MAXNAMELEN - 1, ufile) == NULL - || fgets(p, MAXSECRETLEN - 1, ufile) == NULL) { - fclose(ufile); - option_error("unable to read user login data file %s", fname); - return 0; + || fgets(p, MAXSECRETLEN - 1, ufile) == NULL) { + fclose(ufile); + option_error("unable to read user login data file %s", fname); + return 0; } fclose(ufile); /* get rid of newlines */ l = strlen(u); if (l > 0 && u[l-1] == '\n') - u[l-1] = 0; + u[l-1] = 0; l = strlen(p); if (l > 0 && p[l-1] == '\n') - p[l-1] = 0; + p[l-1] = 0; if (override_value("user", option_priority, fname)) { - strlcpy(ppp_settings.user, u, sizeof(ppp_settings.user)); - explicit_user = 1; + strlcpy(ppp_settings.user, u, sizeof(ppp_settings.user)); + explicit_user = 1; } if (override_value("passwd", option_priority, fname)) { - strlcpy(ppp_settings.passwd, p, sizeof(ppp_settings.passwd)); - explicit_passwd = 1; + strlcpy(ppp_settings.passwd, p, sizeof(ppp_settings.passwd)); + explicit_passwd = 1; } return (1); @@ -484,14 +484,14 @@ privgroup(argv) g = getgrnam(*argv); if (g == 0) { - option_error("group %s is unknown", *argv); - return 0; + option_error("group %s is unknown", *argv); + return 0; } for (i = 0; i < ngroups; ++i) { - if (groups[i] == g->gr_gid) { - privileged = 1; - break; - } + if (groups[i] == g->gr_gid) { + privileged = 1; + break; + } } return 1; } @@ -511,7 +511,7 @@ set_noauth_addr(argv) wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l); if (wp == NULL) - novm("allow-ip argument"); + novm("allow-ip argument"); wp->word = (char *) (wp + 1); wp->next = noauth_addrs; MEMCPY(wp->word, addr, l); @@ -533,7 +533,7 @@ set_permitted_number(argv) wp = (struct wordlist *) malloc(sizeof(struct wordlist) + l); if (wp == NULL) - novm("allow-number argument"); + novm("allow-number argument"); wp->word = (char *) (wp + 1); wp->next = permitted_numbers; MEMCPY(wp->word, number, l); @@ -566,7 +566,7 @@ void start_link(unit) devfd = the_channel->connect(); msg = "Connect script failed"; if (devfd < 0) - goto fail; + goto fail; /* set up the serial device as a ppp interface */ /* @@ -579,21 +579,21 @@ void start_link(unit) fd_ppp = the_channel->establish_ppp(devfd); msg = "ppp establishment failed"; if (fd_ppp < 0) { - status = EXIT_FATAL_ERROR; - goto disconnect; + status = EXIT_FATAL_ERROR; + goto disconnect; } if (!demand && ifunit >= 0) - set_ifunit(1); + set_ifunit(1); /* * Start opening the connection and wait for * incoming events (reply, timeout, etc.). */ if (ifunit >= 0) - ppp_notice("Connect: %s <--> %s", ifname, ppp_devnam); + ppp_notice("Connect: %s <--> %s", ifname, ppp_devnam); else - ppp_notice("Starting negotiation on %s", ppp_devnam); + ppp_notice("Starting negotiation on %s", ppp_devnam); add_fd(fd_ppp); new_phase(pcb, PPP_PHASE_ESTABLISH); @@ -604,12 +604,12 @@ void start_link(unit) disconnect: new_phase(pcb, PPP_PHASE_DISCONNECT); if (the_channel->disconnect) - the_channel->disconnect(); + the_channel->disconnect(); fail: new_phase(pcb, PPP_PHASE_DEAD); if (the_channel->cleanup) - (*the_channel->cleanup)(); + (*the_channel->cleanup)(); } #endif @@ -623,23 +623,23 @@ void link_terminated(ppp_pcb *pcb) { || pcb->phase == PPP_PHASE_MASTER #endif /* HAVE_MULTILINK */ ) - return; + return; new_phase(pcb, PPP_PHASE_DISCONNECT); #if 0 /* UNUSED */ if (pap_logout_hook) { - pap_logout_hook(); + pap_logout_hook(); } session_end(devnam); #endif /* UNUSED */ if (!doing_multilink) { - ppp_notice("Connection terminated."); + ppp_notice("Connection terminated."); #if PPP_STATS_SUPPORT - print_link_stats(); + print_link_stats(); #endif /* PPP_STATS_SUPPORT */ } else - ppp_notice("Link terminated."); + ppp_notice("Link terminated."); lcp_lowerdown(pcb); @@ -651,7 +651,7 @@ void link_terminated(ppp_pcb *pcb) { * we delete its pid file. */ if (!doing_multilink && !demand) - remove_pidfiles(); + remove_pidfiles(); /* * If we may want to bring the link up again, transfer @@ -659,36 +659,36 @@ void link_terminated(ppp_pcb *pcb) { * real serial device back to its normal mode of operation. */ if (fd_ppp >= 0) { - remove_fd(fd_ppp); - clean_check(); - the_channel->disestablish_ppp(devfd); - if (doing_multilink) - mp_exit_bundle(); - fd_ppp = -1; + remove_fd(fd_ppp); + clean_check(); + the_channel->disestablish_ppp(devfd); + if (doing_multilink) + mp_exit_bundle(); + fd_ppp = -1; } if (!hungup) - lcp_lowerdown(pcb); + lcp_lowerdown(pcb); if (!doing_multilink && !demand) - script_unsetenv("IFNAME"); + script_unsetenv("IFNAME"); /* * Run disconnector script, if requested. * XXX we may not be able to do this if the line has hung up! */ if (devfd >= 0 && the_channel->disconnect) { - the_channel->disconnect(); - devfd = -1; + the_channel->disconnect(); + devfd = -1; } if (the_channel->cleanup) - (*the_channel->cleanup)(); + (*the_channel->cleanup)(); if (doing_multilink && multilink_master) { - if (!bundle_terminating) - new_phase(pcb, PPP_PHASE_MASTER); - else - mp_bundle_terminated(); + if (!bundle_terminating) + new_phase(pcb, PPP_PHASE_MASTER); + else + mp_bundle_terminated(); } else - new_phase(pcb, PPP_PHASE_DEAD); + new_phase(pcb, PPP_PHASE_DEAD); #endif } @@ -701,13 +701,13 @@ void link_down(ppp_pcb *pcb) { #endif /* PPP_NOTIFY */ if (!doing_multilink) { - upper_layers_down(pcb); - if (pcb->phase != PPP_PHASE_DEAD + upper_layers_down(pcb); + if (pcb->phase != PPP_PHASE_DEAD #ifdef HAVE_MULTILINK - && pcb->phase != PPP_PHASE_MASTER + && pcb->phase != PPP_PHASE_MASTER #endif /* HAVE_MULTILINK */ - ) - new_phase(pcb, PPP_PHASE_ESTABLISH); + ) + new_phase(pcb, PPP_PHASE_ESTABLISH); } /* XXX if doing_multilink, should do something to stop network-layer traffic on the link */ @@ -719,9 +719,9 @@ void upper_layers_down(ppp_pcb *pcb) { for (i = 0; (protp = protocols[i]) != NULL; ++i) { if (protp->protocol != PPP_LCP && protp->lowerdown != NULL) - (*protp->lowerdown)(pcb); + (*protp->lowerdown)(pcb); if (protp->protocol < 0xC000 && protp->close != NULL) - (*protp->close)(pcb, "LCP down"); + (*protp->close)(pcb, "LCP down"); } pcb->num_np_open = 0; pcb->num_np_up = 0; @@ -749,56 +749,56 @@ void link_established(ppp_pcb *pcb) { * Tell higher-level protocols that LCP is up. */ if (!doing_multilink) { - for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->protocol != PPP_LCP - && protp->lowerup != NULL) - (*protp->lowerup)(pcb); + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (protp->protocol != PPP_LCP + && protp->lowerup != NULL) + (*protp->lowerup)(pcb); } #if PPP_AUTH_SUPPORT #if PPP_SERVER #if PPP_ALLOWED_ADDRS if (!auth_required && noauth_addrs != NULL) - set_allowed_addrs(unit, NULL, NULL); + set_allowed_addrs(unit, NULL, NULL); #endif /* PPP_ALLOWED_ADDRS */ if (pcb->settings.auth_required && !(0 #if PAP_SUPPORT - || go->neg_upap + || go->neg_upap #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - || go->neg_chap + || go->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || go->neg_eap + || go->neg_eap #endif /* EAP_SUPPORT */ - )) { + )) { #if PPP_ALLOWED_ADDRS - /* - * We wanted the peer to authenticate itself, and it refused: - * if we have some address(es) it can use without auth, fine, - * otherwise treat it as though it authenticated with PAP using - * a username of "" and a password of "". If that's not OK, - * boot it out. - */ - if (noauth_addrs != NULL) { - set_allowed_addrs(unit, NULL, NULL); - } else + /* + * We wanted the peer to authenticate itself, and it refused: + * if we have some address(es) it can use without auth, fine, + * otherwise treat it as though it authenticated with PAP using + * a username of "" and a password of "". If that's not OK, + * boot it out. + */ + if (noauth_addrs != NULL) { + set_allowed_addrs(unit, NULL, NULL); + } else #endif /* PPP_ALLOWED_ADDRS */ - if (!pcb->settings.null_login + if (!pcb->settings.null_login #if PAP_SUPPORT - || !wo->neg_upap + || !wo->neg_upap #endif /* PAP_SUPPORT */ - ) { - ppp_warn("peer refused to authenticate: terminating link"); + ) { + ppp_warn("peer refused to authenticate: terminating link"); #if 0 /* UNUSED */ - status = EXIT_PEER_AUTH_FAILED; + status = EXIT_PEER_AUTH_FAILED; #endif /* UNUSED */ - pcb->err_code = PPPERR_AUTHFAIL; - lcp_close(pcb, "peer refused to authenticate"); - return; - } + pcb->err_code = PPPERR_AUTHFAIL; + lcp_close(pcb, "peer refused to authenticate"); + return; + } } #endif /* PPP_SERVER */ @@ -807,20 +807,20 @@ void link_established(ppp_pcb *pcb) { #if PPP_SERVER #if EAP_SUPPORT if (go->neg_eap) { - eap_authpeer(pcb, PPP_OUR_NAME); - auth |= EAP_PEER; + eap_authpeer(pcb, PPP_OUR_NAME); + auth |= EAP_PEER; } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT if (go->neg_chap) { - chap_auth_peer(pcb, PPP_OUR_NAME, CHAP_DIGEST(go->chap_mdtype)); - auth |= CHAP_PEER; + chap_auth_peer(pcb, PPP_OUR_NAME, CHAP_DIGEST(go->chap_mdtype)); + auth |= CHAP_PEER; } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT if (go->neg_upap) { - upap_authpeer(pcb); - auth |= PAP_PEER; + upap_authpeer(pcb); + auth |= PAP_PEER; } else #endif /* PAP_SUPPORT */ {} @@ -828,20 +828,20 @@ void link_established(ppp_pcb *pcb) { #if EAP_SUPPORT if (ho->neg_eap) { - eap_authwithpeer(pcb, pcb->settings.user); - auth |= EAP_WITHPEER; + eap_authwithpeer(pcb, pcb->settings.user); + auth |= EAP_WITHPEER; } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT if (ho->neg_chap) { - chap_auth_with_peer(pcb, pcb->settings.user, CHAP_DIGEST(ho->chap_mdtype)); - auth |= CHAP_WITHPEER; + chap_auth_with_peer(pcb, pcb->settings.user, CHAP_DIGEST(ho->chap_mdtype)); + auth |= CHAP_WITHPEER; } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT if (ho->neg_upap) { - upap_authwithpeer(pcb, pcb->settings.user, pcb->settings.passwd); - auth |= PAP_WITHPEER; + upap_authwithpeer(pcb, pcb->settings.user, pcb->settings.passwd); + auth |= PAP_WITHPEER; } else #endif /* PAP_SUPPORT */ {} @@ -851,7 +851,7 @@ void link_established(ppp_pcb *pcb) { if (!auth) #endif /* PPP_AUTH_SUPPORT */ - network_phase(pcb); + network_phase(pcb); } /* @@ -868,7 +868,7 @@ static void network_phase(ppp_pcb *pcb) { #if 0 /* UNUSED */ /* Log calling number. */ if (*remote_number) - ppp_notice("peer from calling number %q authorized", remote_number); + ppp_notice("peer from calling number %q authorized", remote_number); #endif /* UNUSED */ #if PPP_NOTIFY @@ -877,16 +877,16 @@ static void network_phase(ppp_pcb *pcb) { */ if (0 #if CHAP_SUPPORT - || go->neg_chap + || go->neg_chap #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - || go->neg_upap + || go->neg_upap #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - || go->neg_eap + || go->neg_eap #endif /* EAP_SUPPORT */ - ) { - notify(auth_up_notifier, 0); + ) { + notify(auth_up_notifier, 0); } #endif /* PPP_NOTIFY */ @@ -895,9 +895,9 @@ static void network_phase(ppp_pcb *pcb) { * If we negotiated callback, do it now. */ if (go->neg_cbcp) { - new_phase(pcb, PPP_PHASE_CALLBACK); - (*cbcp_protent.open)(pcb); - return; + new_phase(pcb, PPP_PHASE_CALLBACK); + (*cbcp_protent.open)(pcb); + return; } #endif @@ -906,9 +906,9 @@ static void network_phase(ppp_pcb *pcb) { * Process extra options from the secrets file */ if (extra_options) { - options_from_list(extra_options, 1); - free_wordlist(extra_options); - extra_options = 0; + options_from_list(extra_options, 1); + free_wordlist(extra_options); + extra_options = 0; } #endif /* PPP_OPTIONS */ start_networks(pcb); @@ -924,34 +924,34 @@ void start_networks(ppp_pcb *pcb) { #ifdef HAVE_MULTILINK if (multilink) { - if (mp_join_bundle()) { - if (multilink_join_hook) - (*multilink_join_hook)(); - if (updetach && !nodetach) - detach(); - return; - } + if (mp_join_bundle()) { + if (multilink_join_hook) + (*multilink_join_hook)(); + if (updetach && !nodetach) + detach(); + return; + } } #endif /* HAVE_MULTILINK */ #ifdef PPP_FILTER if (!demand) - set_filters(&pass_filter, &active_filter); + set_filters(&pass_filter, &active_filter); #endif #if CCP_SUPPORT || ECP_SUPPORT /* Start CCP and ECP */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if ( - (0 + if ( + (0 #if ECP_SUPPORT - || protp->protocol == PPP_ECP + || protp->protocol == PPP_ECP #endif /* ECP_SUPPORT */ #if CCP_SUPPORT - || protp->protocol == PPP_CCP + || protp->protocol == PPP_CCP #endif /* CCP_SUPPORT */ - ) - && protp->open != NULL) - (*protp->open)(pcb); + ) + && protp->open != NULL) + (*protp->open)(pcb); #endif /* CCP_SUPPORT || ECP_SUPPORT */ /* @@ -965,7 +965,7 @@ void start_networks(ppp_pcb *pcb) { && !pcb->ccp_gotoptions.mppe #endif /* MPPE_SUPPORT */ ) - continue_networks(pcb); + continue_networks(pcb); } void continue_networks(ppp_pcb *pcb) { @@ -976,21 +976,21 @@ void continue_networks(ppp_pcb *pcb) { * Start the "real" network protocols. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->protocol < 0xC000 + if (protp->protocol < 0xC000 #if CCP_SUPPORT - && protp->protocol != PPP_CCP + && protp->protocol != PPP_CCP #endif /* CCP_SUPPORT */ #if ECP_SUPPORT - && protp->protocol != PPP_ECP + && protp->protocol != PPP_ECP #endif /* ECP_SUPPORT */ - && protp->open != NULL) { - (*protp->open)(pcb); - ++pcb->num_np_open; - } + && protp->open != NULL) { + (*protp->open)(pcb); + ++pcb->num_np_open; + } if (pcb->num_np_open == 0) - /* nothing to do */ - lcp_close(pcb, "No network protocols running"); + /* nothing to do */ + lcp_close(pcb, "No network protocols running"); } #if PPP_AUTH_SUPPORT @@ -1053,37 +1053,37 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char * switch (protocol) { #if CHAP_SUPPORT case PPP_CHAP: - bit = CHAP_PEER; - switch (prot_flavor) { - case CHAP_MD5: - bit |= CHAP_MD5_PEER; - break; + bit = CHAP_PEER; + switch (prot_flavor) { + case CHAP_MD5: + bit |= CHAP_MD5_PEER; + break; #if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - bit |= CHAP_MS_PEER; - break; - case CHAP_MICROSOFT_V2: - bit |= CHAP_MS2_PEER; - break; + case CHAP_MICROSOFT: + bit |= CHAP_MS_PEER; + break; + case CHAP_MICROSOFT_V2: + bit |= CHAP_MS2_PEER; + break; #endif /* MSCHAP_SUPPORT */ - default: - break; - } - break; + default: + break; + } + break; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT case PPP_PAP: - bit = PAP_PEER; - break; + bit = PAP_PEER; + break; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT case PPP_EAP: - bit = EAP_PEER; - break; + bit = EAP_PEER; + break; #endif /* EAP_SUPPORT */ default: - ppp_warn("auth_peer_success: unknown protocol %x", protocol); - return; + ppp_warn("auth_peer_success: unknown protocol %x", protocol); + return; } #ifdef HAVE_MULTILINK @@ -1091,7 +1091,7 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, const char * * Save the authenticated name of the peer for later. */ if (namelen > (int)sizeof(pcb->peer_authname) - 1) - namelen = (int)sizeof(pcb->peer_authname) - 1; + namelen = (int)sizeof(pcb->peer_authname) - 1; MEMCPY(pcb->peer_authname, name, namelen); pcb->peer_authname[namelen] = 0; #endif /* HAVE_MULTILINK */ @@ -1140,41 +1140,41 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) { switch (protocol) { #if CHAP_SUPPORT case PPP_CHAP: - bit = CHAP_WITHPEER; - prot = "CHAP"; - switch (prot_flavor) { - case CHAP_MD5: - bit |= CHAP_MD5_WITHPEER; - break; + bit = CHAP_WITHPEER; + prot = "CHAP"; + switch (prot_flavor) { + case CHAP_MD5: + bit |= CHAP_MD5_WITHPEER; + break; #if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - bit |= CHAP_MS_WITHPEER; - break; - case CHAP_MICROSOFT_V2: - bit |= CHAP_MS2_WITHPEER; - break; + case CHAP_MICROSOFT: + bit |= CHAP_MS_WITHPEER; + break; + case CHAP_MICROSOFT_V2: + bit |= CHAP_MS2_WITHPEER; + break; #endif /* MSCHAP_SUPPORT */ - default: - break; - } - break; + default: + break; + } + break; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT case PPP_PAP: - bit = PAP_WITHPEER; - prot = "PAP"; - break; + bit = PAP_WITHPEER; + prot = "PAP"; + break; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT case PPP_EAP: - bit = EAP_WITHPEER; - prot = "EAP"; - break; + bit = EAP_WITHPEER; + prot = "EAP"; + break; #endif /* EAP_SUPPORT */ default: - ppp_warn("auth_withpeer_success: unknown protocol %x", protocol); - bit = 0; - /* no break */ + ppp_warn("auth_withpeer_success: unknown protocol %x", protocol); + bit = 0; + /* no break */ } ppp_notice("%s authentication succeeded", prot); @@ -1187,7 +1187,7 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) { * proceed to the network (or callback) phase. */ if ((pcb->auth_pending &= ~bit) == 0) - network_phase(pcb); + network_phase(pcb); } #endif /* PPP_AUTH_SUPPORT */ @@ -1202,42 +1202,42 @@ void np_up(ppp_pcb *pcb, int proto) { LWIP_UNUSED_ARG(proto); if (pcb->num_np_up == 0) { - /* - * At this point we consider that the link has come up successfully. - */ - new_phase(pcb, PPP_PHASE_RUNNING); + /* + * At this point we consider that the link has come up successfully. + */ + new_phase(pcb, PPP_PHASE_RUNNING); #if PPP_IDLETIMELIMIT #if 0 /* UNUSED */ - if (idle_time_hook != 0) - tlim = (*idle_time_hook)(NULL); - else + if (idle_time_hook != 0) + tlim = (*idle_time_hook)(NULL); + else #endif /* UNUSED */ - tlim = pcb->settings.idle_time_limit; - if (tlim > 0) - TIMEOUT(check_idle, (void*)pcb, tlim); + tlim = pcb->settings.idle_time_limit; + if (tlim > 0) + TIMEOUT(check_idle, (void*)pcb, tlim); #endif /* PPP_IDLETIMELIMIT */ #if PPP_MAXCONNECT - /* - * Set a timeout to close the connection once the maximum - * connect time has expired. - */ - if (pcb->settings.maxconnect > 0) - TIMEOUT(connect_time_expired, (void*)pcb, pcb->settings.maxconnect); + /* + * Set a timeout to close the connection once the maximum + * connect time has expired. + */ + if (pcb->settings.maxconnect > 0) + TIMEOUT(connect_time_expired, (void*)pcb, pcb->settings.maxconnect); #endif /* PPP_MAXCONNECT */ #ifdef MAXOCTETS - if (maxoctets > 0) - TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); + if (maxoctets > 0) + TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); #endif #if 0 /* Unused */ - /* - * Detach now, if the updetach option was given. - */ - if (updetach && !nodetach) - detach(); + /* + * Detach now, if the updetach option was given. + */ + if (updetach && !nodetach) + detach(); #endif /* Unused */ } ++pcb->num_np_up; @@ -1250,15 +1250,15 @@ void np_down(ppp_pcb *pcb, int proto) { LWIP_UNUSED_ARG(proto); if (--pcb->num_np_up == 0) { #if PPP_IDLETIMELIMIT - UNTIMEOUT(check_idle, (void*)pcb); + UNTIMEOUT(check_idle, (void*)pcb); #endif /* PPP_IDLETIMELIMIT */ #if PPP_MAXCONNECT - UNTIMEOUT(connect_time_expired, NULL); + UNTIMEOUT(connect_time_expired, NULL); #endif /* PPP_MAXCONNECT */ #ifdef MAXOCTETS - UNTIMEOUT(check_maxoctets, NULL); + UNTIMEOUT(check_maxoctets, NULL); #endif - new_phase(pcb, PPP_PHASE_NETWORK); + new_phase(pcb, PPP_PHASE_NETWORK); } } @@ -1268,8 +1268,8 @@ void np_down(ppp_pcb *pcb, int proto) { void np_finished(ppp_pcb *pcb, int proto) { LWIP_UNUSED_ARG(proto); if (--pcb->num_np_open <= 0) { - /* no further use for the link: shut up shop. */ - lcp_close(pcb, "No network protocols running"); + /* no further use for the link: shut up shop. */ + lcp_close(pcb, "No network protocols running"); } } @@ -1285,26 +1285,26 @@ check_maxoctets(arg) link_stats_valid=0; switch(maxoctets_dir) { - case PPP_OCTETS_DIRECTION_IN: - used = link_stats.bytes_in; - break; - case PPP_OCTETS_DIRECTION_OUT: - used = link_stats.bytes_out; - break; - case PPP_OCTETS_DIRECTION_MAXOVERAL: - case PPP_OCTETS_DIRECTION_MAXSESSION: - used = (link_stats.bytes_in > link_stats.bytes_out) ? link_stats.bytes_in : link_stats.bytes_out; - break; - default: - used = link_stats.bytes_in+link_stats.bytes_out; - break; + case PPP_OCTETS_DIRECTION_IN: + used = link_stats.bytes_in; + break; + case PPP_OCTETS_DIRECTION_OUT: + used = link_stats.bytes_out; + break; + case PPP_OCTETS_DIRECTION_MAXOVERAL: + case PPP_OCTETS_DIRECTION_MAXSESSION: + used = (link_stats.bytes_in > link_stats.bytes_out) ? link_stats.bytes_in : link_stats.bytes_out; + break; + default: + used = link_stats.bytes_in+link_stats.bytes_out; + break; } if (used > maxoctets) { - ppp_notice("Traffic limit reached. Limit: %u Used: %u", maxoctets, used); - status = EXIT_TRAFFIC_LIMIT; - lcp_close(pcb, "Traffic limit"); + ppp_notice("Traffic limit reached. Limit: %u Used: %u", maxoctets, used); + status = EXIT_TRAFFIC_LIMIT; + lcp_close(pcb, "Traffic limit"); #if 0 /* UNUSED */ - need_holdoff = 0; + need_holdoff = 0; #endif /* UNUSED */ } else { TIMEOUT(check_maxoctets, NULL, maxoctets_timeout); @@ -1325,27 +1325,27 @@ static void check_idle(void *arg) { int tlim; if (!get_idle_time(pcb, &idle)) - return; + return; #if 0 /* UNUSED */ if (idle_time_hook != 0) { - tlim = idle_time_hook(&idle); + tlim = idle_time_hook(&idle); } else { #endif /* UNUSED */ - itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); - tlim = pcb->settings.idle_time_limit - itime; + itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); + tlim = pcb->settings.idle_time_limit - itime; #if 0 /* UNUSED */ } #endif /* UNUSED */ if (tlim <= 0) { - /* link is idle: shut it down. */ - ppp_notice("Terminating connection due to lack of activity."); - pcb->err_code = PPPERR_IDLETIMEOUT; - lcp_close(pcb, "Link inactive"); + /* link is idle: shut it down. */ + ppp_notice("Terminating connection due to lack of activity."); + pcb->err_code = PPPERR_IDLETIMEOUT; + lcp_close(pcb, "Link inactive"); #if 0 /* UNUSED */ - need_holdoff = 0; + need_holdoff = 0; #endif /* UNUSED */ } else { - TIMEOUT(check_idle, (void*)pcb, tlim); + TIMEOUT(check_idle, (void*)pcb, tlim); } } #endif /* PPP_IDLETIMELIMIT */ @@ -1358,7 +1358,7 @@ static void connect_time_expired(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; ppp_info("Connect time expired"); pcb->err_code = PPPERR_CONNECTTIME; - lcp_close(pcb, "Connect time expired"); /* Close connection */ + lcp_close(pcb, "Connect time expired"); /* Close connection */ } #endif /* PPP_MAXCONNECT */ @@ -1375,62 +1375,62 @@ auth_check_options() /* Default our_name to hostname, and user to our_name */ if (our_name[0] == 0 || usehostname) - strlcpy(our_name, hostname, sizeof(our_name)); + strlcpy(our_name, hostname, sizeof(our_name)); /* If a blank username was explicitly given as an option, trust the user and don't use our_name */ if (ppp_settings.user[0] == 0 && !explicit_user) - strlcpy(ppp_settings.user, our_name, sizeof(ppp_settings.user)); + strlcpy(ppp_settings.user, our_name, sizeof(ppp_settings.user)); /* * If we have a default route, require the peer to authenticate * unless the noauth option was given or the real user is root. */ if (!auth_required && !allow_any_ip && have_route_to(0) && !privileged) { - auth_required = 1; - default_auth = 1; + auth_required = 1; + default_auth = 1; } #if CHAP_SUPPORT /* If we selected any CHAP flavors, we should probably negotiate it. :-) */ if (wo->chap_mdtype) - wo->neg_chap = 1; + wo->neg_chap = 1; #endif /* CHAP_SUPPORT */ /* If authentication is required, ask peer for CHAP, PAP, or EAP. */ if (auth_required) { - allow_any_ip = 0; - if (1 + allow_any_ip = 0; + if (1 #if CHAP_SUPPORT - && !wo->neg_chap + && !wo->neg_chap #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - && !wo->neg_upap + && !wo->neg_upap #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - && !wo->neg_eap + && !wo->neg_eap #endif /* EAP_SUPPORT */ - ) { + ) { #if CHAP_SUPPORT - wo->neg_chap = CHAP_MDTYPE_SUPPORTED != MDTYPE_NONE; - wo->chap_mdtype = CHAP_MDTYPE_SUPPORTED; + wo->neg_chap = CHAP_MDTYPE_SUPPORTED != MDTYPE_NONE; + wo->chap_mdtype = CHAP_MDTYPE_SUPPORTED; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - wo->neg_upap = 1; + wo->neg_upap = 1; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - wo->neg_eap = 1; + wo->neg_eap = 1; #endif /* EAP_SUPPORT */ - } + } } else { #if CHAP_SUPPORT - wo->neg_chap = 0; - wo->chap_mdtype = MDTYPE_NONE; + wo->neg_chap = 0; + wo->chap_mdtype = MDTYPE_NONE; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - wo->neg_upap = 0; + wo->neg_upap = 0; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - wo->neg_eap = 0; + wo->neg_eap = 0; #endif /* EAP_SUPPORT */ } @@ -1447,56 +1447,56 @@ auth_check_options() #endif /* PAP_SUPPORT */ if (!can_auth && (0 #if CHAP_SUPPORT - || wo->neg_chap + || wo->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || wo->neg_eap + || wo->neg_eap #endif /* EAP_SUPPORT */ - )) { + )) { #if CHAP_SUPPORT - can_auth = have_chap_secret((explicit_remote? remote_name: NULL), - our_name, 1, &lacks_ip); + can_auth = have_chap_secret((explicit_remote? remote_name: NULL), + our_name, 1, &lacks_ip); #else - can_auth = 0; + can_auth = 0; #endif } if (!can_auth #if EAP_SUPPORT - && wo->neg_eap + && wo->neg_eap #endif /* EAP_SUPPORT */ - ) { - can_auth = have_srp_secret((explicit_remote? remote_name: NULL), - our_name, 1, &lacks_ip); + ) { + can_auth = have_srp_secret((explicit_remote? remote_name: NULL), + our_name, 1, &lacks_ip); } if (auth_required && !can_auth && noauth_addrs == NULL) { - if (default_auth) { - option_error( + if (default_auth) { + option_error( "By default the remote system is required to authenticate itself"); - option_error( + option_error( "(because this system has a default route to the internet)"); - } else if (explicit_remote) - option_error( + } else if (explicit_remote) + option_error( "The remote system (%s) is required to authenticate itself", - remote_name); - else - option_error( + remote_name); + else + option_error( "The remote system is required to authenticate itself"); - option_error( + option_error( "but I couldn't find any suitable secret (password) for it to use to do so."); - if (lacks_ip) - option_error( + if (lacks_ip) + option_error( "(None of the available passwords would let it use an IP address.)"); - exit(1); + exit(1); } /* * Early check for remote number authorization. */ if (!auth_number()) { - ppp_warn("calling number %q is not authorized", remote_number); - exit(EXIT_CNID_AUTH_FAILED); + ppp_warn("calling number %q is not authorized", remote_number); + exit(EXIT_CNID_AUTH_FAILED); } } #endif /* PPP_OPTIONS */ @@ -1518,30 +1518,30 @@ auth_reset(unit) hadchap = -1; ao->neg_upap = !refuse_pap && (passwd[0] != 0 || get_pap_passwd(NULL)); ao->neg_chap = (!refuse_chap || !refuse_mschap || !refuse_mschap_v2) - && (passwd[0] != 0 || - (hadchap = have_chap_secret(user, (explicit_remote? remote_name: - NULL), 0, NULL))); + && (passwd[0] != 0 || + (hadchap = have_chap_secret(user, (explicit_remote? remote_name: + NULL), 0, NULL))); ao->neg_eap = !refuse_eap && ( - passwd[0] != 0 || - (hadchap == 1 || (hadchap == -1 && have_chap_secret(user, - (explicit_remote? remote_name: NULL), 0, NULL))) || - have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL)); + passwd[0] != 0 || + (hadchap == 1 || (hadchap == -1 && have_chap_secret(user, + (explicit_remote? remote_name: NULL), 0, NULL))) || + have_srp_secret(user, (explicit_remote? remote_name: NULL), 0, NULL)); hadchap = -1; if (go->neg_upap && !uselogin && !have_pap_secret(NULL)) - go->neg_upap = 0; + go->neg_upap = 0; if (go->neg_chap) { - if (!(hadchap = have_chap_secret((explicit_remote? remote_name: NULL), - our_name, 1, NULL))) - go->neg_chap = 0; + if (!(hadchap = have_chap_secret((explicit_remote? remote_name: NULL), + our_name, 1, NULL))) + go->neg_chap = 0; } if (go->neg_eap && - (hadchap == 0 || (hadchap == -1 && - !have_chap_secret((explicit_remote? remote_name: NULL), our_name, - 1, NULL))) && - !have_srp_secret((explicit_remote? remote_name: NULL), our_name, 1, - NULL)) - go->neg_eap = 0; + (hadchap == 0 || (hadchap == -1 && + !have_chap_secret((explicit_remote? remote_name: NULL), our_name, + 1, NULL))) && + !have_srp_secret((explicit_remote? remote_name: NULL), our_name, 1, + NULL)) + go->neg_eap = 0; } /* @@ -1550,8 +1550,8 @@ auth_reset(unit) * and login the user if OK. * * returns: - * UPAP_AUTHNAK: Authentication failed. - * UPAP_AUTHACK: Authentication succeeded. + * UPAP_AUTHNAK: Authentication failed. + * UPAP_AUTHACK: Authentication succeeded. * In either case, msg points to an appropriate message. */ int @@ -1585,19 +1585,19 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg) * Check if a plugin wants to handle this. */ if (pap_auth_hook) { - ret = (*pap_auth_hook)(ppp_settings.user, ppp_settings.passwd, msg, &addrs, &opts); - if (ret >= 0) { - /* note: set_allowed_addrs() saves opts (but not addrs): - don't free it! */ - if (ret) - set_allowed_addrs(unit, addrs, opts); - else if (opts != 0) - free_wordlist(opts); - if (addrs != 0) - free_wordlist(addrs); - BZERO(ppp_settings.passwd, sizeof(ppp_settings.passwd)); - return ret? UPAP_AUTHACK: UPAP_AUTHNAK; - } + ret = (*pap_auth_hook)(ppp_settings.user, ppp_settings.passwd, msg, &addrs, &opts); + if (ret >= 0) { + /* note: set_allowed_addrs() saves opts (but not addrs): + don't free it! */ + if (ret) + set_allowed_addrs(unit, addrs, opts); + else if (opts != 0) + free_wordlist(opts); + if (addrs != 0) + free_wordlist(addrs); + BZERO(ppp_settings.passwd, sizeof(ppp_settings.passwd)); + return ret? UPAP_AUTHACK: UPAP_AUTHNAK; + } } /* @@ -1609,67 +1609,67 @@ check_passwd(unit, auser, userlen, apasswd, passwdlen, msg) ret = UPAP_AUTHNAK; f = fopen(filename, "r"); if (f == NULL) { - ppp_error("Can't open PAP password file %s: %m", filename); + ppp_error("Can't open PAP password file %s: %m", filename); } else { - check_access(f, filename); - if (scan_authfile(f, ppp_settings.user, our_name, secret, &addrs, &opts, filename, 0) < 0) { - ppp_warn("no PAP secret found for %s", user); - } else { - /* - * If the secret is "@login", it means to check - * the password against the login database. - */ - int login_secret = strcmp(secret, "@login") == 0; - ret = UPAP_AUTHACK; - if (uselogin || login_secret) { - /* login option or secret is @login */ - if (session_full(ppp_settings.user, ppp_settings.passwd, devnam, msg) == 0) { - ret = UPAP_AUTHNAK; - } - } else if (session_mgmt) { - if (session_check(ppp_settings.user, NULL, devnam, NULL) == 0) { - ppp_warn("Peer %q failed PAP Session verification", user); - ret = UPAP_AUTHNAK; - } - } - if (secret[0] != 0 && !login_secret) { - /* password given in pap-secrets - must match */ - if ((cryptpap || strcmp(ppp_settings.passwd, secret) != 0) - && strcmp(crypt(ppp_settings.passwd, secret), secret) != 0) - ret = UPAP_AUTHNAK; - } - } - fclose(f); + check_access(f, filename); + if (scan_authfile(f, ppp_settings.user, our_name, secret, &addrs, &opts, filename, 0) < 0) { + ppp_warn("no PAP secret found for %s", user); + } else { + /* + * If the secret is "@login", it means to check + * the password against the login database. + */ + int login_secret = strcmp(secret, "@login") == 0; + ret = UPAP_AUTHACK; + if (uselogin || login_secret) { + /* login option or secret is @login */ + if (session_full(ppp_settings.user, ppp_settings.passwd, devnam, msg) == 0) { + ret = UPAP_AUTHNAK; + } + } else if (session_mgmt) { + if (session_check(ppp_settings.user, NULL, devnam, NULL) == 0) { + ppp_warn("Peer %q failed PAP Session verification", user); + ret = UPAP_AUTHNAK; + } + } + if (secret[0] != 0 && !login_secret) { + /* password given in pap-secrets - must match */ + if ((cryptpap || strcmp(ppp_settings.passwd, secret) != 0) + && strcmp(crypt(ppp_settings.passwd, secret), secret) != 0) + ret = UPAP_AUTHNAK; + } + } + fclose(f); } if (ret == UPAP_AUTHNAK) { if (**msg == 0) - *msg = "Login incorrect"; - /* - * XXX can we ever get here more than once?? - * Frustrate passwd stealer programs. - * Allow 10 tries, but start backing off after 3 (stolen from login). - * On 10'th, drop the connection. - */ - if (attempts++ >= 10) { - ppp_warn("%d LOGIN FAILURES ON %s, %s", attempts, devnam, user); - lcp_close(pcb, "login failed"); - } - if (attempts > 3) - sleep((u_int) (attempts - 3) * 5); - if (opts != NULL) - free_wordlist(opts); + *msg = "Login incorrect"; + /* + * XXX can we ever get here more than once?? + * Frustrate passwd stealer programs. + * Allow 10 tries, but start backing off after 3 (stolen from login). + * On 10'th, drop the connection. + */ + if (attempts++ >= 10) { + ppp_warn("%d LOGIN FAILURES ON %s, %s", attempts, devnam, user); + lcp_close(pcb, "login failed"); + } + if (attempts > 3) + sleep((u_int) (attempts - 3) * 5); + if (opts != NULL) + free_wordlist(opts); } else { - attempts = 0; /* Reset count */ - if (**msg == 0) - *msg = "Login ok"; - set_allowed_addrs(unit, addrs, opts); + attempts = 0; /* Reset count */ + if (**msg == 0) + *msg = "Login ok"; + set_allowed_addrs(unit, addrs, opts); } if (addrs != NULL) - free_wordlist(addrs); + free_wordlist(addrs); BZERO(ppp_settings.passwd, sizeof(ppp_settings.passwd)); BZERO(secret, sizeof(secret)); @@ -1696,31 +1696,31 @@ null_login(unit) */ ret = -1; if (null_auth_hook) - ret = (*null_auth_hook)(&addrs, &opts); + ret = (*null_auth_hook)(&addrs, &opts); /* * Open the file of pap secrets and scan for a suitable secret. */ if (ret <= 0) { - filename = _PATH_UPAPFILE; - addrs = NULL; - f = fopen(filename, "r"); - if (f == NULL) - return 0; - check_access(f, filename); + filename = _PATH_UPAPFILE; + addrs = NULL; + f = fopen(filename, "r"); + if (f == NULL) + return 0; + check_access(f, filename); - i = scan_authfile(f, "", our_name, secret, &addrs, &opts, filename, 0); - ret = i >= 0 && secret[0] == 0; - BZERO(secret, sizeof(secret)); - fclose(f); + i = scan_authfile(f, "", our_name, secret, &addrs, &opts, filename, 0); + ret = i >= 0 && secret[0] == 0; + BZERO(secret, sizeof(secret)); + fclose(f); } if (ret) - set_allowed_addrs(unit, addrs, opts); + set_allowed_addrs(unit, addrs, opts); else if (opts != 0) - free_wordlist(opts); + free_wordlist(opts); if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret; } @@ -1744,24 +1744,24 @@ get_pap_passwd(passwd) * Check whether a plugin wants to supply this. */ if (pap_passwd_hook) { - ret = (*pap_passwd_hook)(ppp_settings,user, ppp_settings.passwd); - if (ret >= 0) - return ret; + ret = (*pap_passwd_hook)(ppp_settings,user, ppp_settings.passwd); + if (ret >= 0) + return ret; } filename = _PATH_UPAPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; check_access(f, filename); ret = scan_authfile(f, user, - (remote_name[0]? remote_name: NULL), - secret, NULL, NULL, filename, 0); + (remote_name[0]? remote_name: NULL), + secret, NULL, NULL, filename, 0); fclose(f); if (ret < 0) - return 0; + return 0; if (passwd != NULL) - strlcpy(passwd, secret, MAXSECRETLEN); + strlcpy(passwd, secret, MAXSECRETLEN); BZERO(secret, sizeof(secret)); return 1; } @@ -1781,26 +1781,26 @@ have_pap_secret(lacks_ipp) /* let the plugin decide, if there is one */ if (pap_check_hook) { - ret = (*pap_check_hook)(); - if (ret >= 0) - return ret; + ret = (*pap_check_hook)(); + if (ret >= 0) + return ret; } filename = _PATH_UPAPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; ret = scan_authfile(f, (explicit_remote? remote_name: NULL), our_name, - NULL, &addrs, NULL, filename, 0); + NULL, &addrs, NULL, filename, 0); fclose(f); if (ret >= 0 && !some_ip_ok(addrs)) { - if (lacks_ipp != 0) - *lacks_ipp = 1; - ret = -1; + if (lacks_ipp != 0) + *lacks_ipp = 1; + ret = -1; } if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret >= 0; } @@ -1824,31 +1824,31 @@ have_chap_secret(client, server, need_ip, lacks_ipp) struct wordlist *addrs; if (chap_check_hook) { - ret = (*chap_check_hook)(); - if (ret >= 0) { - return ret; - } + ret = (*chap_check_hook)(); + if (ret >= 0) { + return ret; + } } filename = _PATH_CHAPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; if (client != NULL && client[0] == 0) - client = NULL; + client = NULL; else if (server != NULL && server[0] == 0) - server = NULL; + server = NULL; ret = scan_authfile(f, client, server, NULL, &addrs, NULL, filename, 0); fclose(f); if (ret >= 0 && need_ip && !some_ip_ok(addrs)) { - if (lacks_ipp != 0) - *lacks_ipp = 1; - ret = -1; + if (lacks_ipp != 0) + *lacks_ipp = 1; + ret = -1; } if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret >= 0; } @@ -1874,22 +1874,22 @@ have_srp_secret(client, server, need_ip, lacks_ipp) filename = _PATH_SRPFILE; f = fopen(filename, "r"); if (f == NULL) - return 0; + return 0; if (client != NULL && client[0] == 0) - client = NULL; + client = NULL; else if (server != NULL && server[0] == 0) - server = NULL; + server = NULL; ret = scan_authfile(f, client, server, NULL, &addrs, NULL, filename, 0); fclose(f); if (ret >= 0 && need_ip && !some_ip_ok(addrs)) { - if (lacks_ipp != 0) - *lacks_ipp = 1; - ret = -1; + if (lacks_ipp != 0) + *lacks_ipp = 1; + ret = -1; } if (addrs != 0) - free_wordlist(addrs); + free_wordlist(addrs); return ret >= 0; } @@ -1930,42 +1930,42 @@ int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secre addrs = NULL; if (!am_server && ppp_settings.passwd[0] != 0) { - strlcpy(secbuf, ppp_settings.passwd, sizeof(secbuf)); + strlcpy(secbuf, ppp_settings.passwd, sizeof(secbuf)); } else if (!am_server && chap_passwd_hook) { - if ( (*chap_passwd_hook)(client, secbuf) < 0) { - ppp_error("Unable to obtain CHAP password for %s on %s from plugin", - client, server); - return 0; - } + if ( (*chap_passwd_hook)(client, secbuf) < 0) { + ppp_error("Unable to obtain CHAP password for %s on %s from plugin", + client, server); + return 0; + } } else { - filename = _PATH_CHAPFILE; - addrs = NULL; - secbuf[0] = 0; - - f = fopen(filename, "r"); - if (f == NULL) { - ppp_error("Can't open chap secret file %s: %m", filename); - return 0; - } - check_access(f, filename); - - ret = scan_authfile(f, client, server, secbuf, &addrs, &opts, filename, 0); - fclose(f); - if (ret < 0) - return 0; - - if (am_server) - set_allowed_addrs(unit, addrs, opts); - else if (opts != 0) - free_wordlist(opts); - if (addrs != 0) - free_wordlist(addrs); + filename = _PATH_CHAPFILE; + addrs = NULL; + secbuf[0] = 0; + + f = fopen(filename, "r"); + if (f == NULL) { + ppp_error("Can't open chap secret file %s: %m", filename); + return 0; + } + check_access(f, filename); + + ret = scan_authfile(f, client, server, secbuf, &addrs, &opts, filename, 0); + fclose(f); + if (ret < 0) + return 0; + + if (am_server) + set_allowed_addrs(unit, addrs, opts); + else if (opts != 0) + free_wordlist(opts); + if (addrs != 0) + free_wordlist(addrs); } len = strlen(secbuf); if (len > MAXSECRETLEN) { - ppp_error("Secret for %s on %s is too long", client, server); - len = MAXSECRETLEN; + ppp_error("Secret for %s on %s is too long", client, server); + len = MAXSECRETLEN; } MEMCPY(secret, secbuf, len); BZERO(secbuf, sizeof(secbuf)); @@ -1997,31 +1997,31 @@ get_srp_secret(unit, client, server, secret, am_server) struct wordlist *addrs, *opts; if (!am_server && ppp_settings.passwd[0] != '\0') { - strlcpy(secret, ppp_settings.passwd, MAXWORDLEN); + strlcpy(secret, ppp_settings.passwd, MAXWORDLEN); } else { - filename = _PATH_SRPFILE; - addrs = NULL; - - fp = fopen(filename, "r"); - if (fp == NULL) { - ppp_error("Can't open srp secret file %s: %m", filename); - return 0; - } - check_access(fp, filename); - - secret[0] = '\0'; - ret = scan_authfile(fp, client, server, secret, &addrs, &opts, - filename, am_server); - fclose(fp); - if (ret < 0) - return 0; - - if (am_server) - set_allowed_addrs(unit, addrs, opts); - else if (opts != NULL) - free_wordlist(opts); - if (addrs != NULL) - free_wordlist(addrs); + filename = _PATH_SRPFILE; + addrs = NULL; + + fp = fopen(filename, "r"); + if (fp == NULL) { + ppp_error("Can't open srp secret file %s: %m", filename); + return 0; + } + check_access(fp, filename); + + secret[0] = '\0'; + ret = scan_authfile(fp, client, server, secret, &addrs, &opts, + filename, am_server); + fclose(fp); + if (ret < 0) + return 0; + + if (am_server) + set_allowed_addrs(unit, addrs, opts); + else if (opts != NULL) + free_wordlist(opts); + if (addrs != NULL) + free_wordlist(addrs); } return 1; @@ -2049,10 +2049,10 @@ set_allowed_addrs(unit, addrs, opts) u32_t suggested_ip = 0; if (addresses[unit] != NULL) - free(addresses[unit]); + free(addresses[unit]); addresses[unit] = NULL; if (extra_options != NULL) - free_wordlist(extra_options); + free_wordlist(extra_options); extra_options = opts; /* @@ -2060,109 +2060,109 @@ set_allowed_addrs(unit, addrs, opts) */ n = wordlist_count(addrs) + wordlist_count(noauth_addrs); if (n == 0) - return; + return; ip = (struct permitted_ip *) malloc((n + 1) * sizeof(struct permitted_ip)); if (ip == 0) - return; + return; /* temporarily append the noauth_addrs list to addrs */ for (plink = &addrs; *plink != NULL; plink = &(*plink)->next) - ; + ; *plink = noauth_addrs; n = 0; for (ap = addrs; ap != NULL; ap = ap->next) { - /* "-" means no addresses authorized, "*" means any address allowed */ - ptr_word = ap->word; - if (strcmp(ptr_word, "-") == 0) - break; - if (strcmp(ptr_word, "*") == 0) { - ip[n].permit = 1; - ip[n].base = ip[n].mask = 0; - ++n; - break; - } - - ip[n].permit = 1; - if (*ptr_word == '!') { - ip[n].permit = 0; - ++ptr_word; - } - - mask = ~ (u32_t) 0; - offset = 0; - ptr_mask = strchr (ptr_word, '/'); - if (ptr_mask != NULL) { - int bit_count; - char *endp; - - bit_count = (int) strtol (ptr_mask+1, &endp, 10); - if (bit_count <= 0 || bit_count > 32) { - ppp_warn("invalid address length %v in auth. address list", - ptr_mask+1); - continue; - } - bit_count = 32 - bit_count; /* # bits in host part */ - if (*endp == '+') { - offset = ifunit + 1; - ++endp; - } - if (*endp != 0) { - ppp_warn("invalid address length syntax: %v", ptr_mask+1); - continue; - } - *ptr_mask = '\0'; - mask <<= bit_count; - } - - hp = gethostbyname(ptr_word); - if (hp != NULL && hp->h_addrtype == AF_INET) { - a = *(u32_t *)hp->h_addr; - } else { - np = getnetbyname (ptr_word); - if (np != NULL && np->n_addrtype == AF_INET) { - a = lwip_htonl ((u32_t)np->n_net); - if (ptr_mask == NULL) { - /* calculate appropriate mask for net */ - ah = lwip_ntohl(a); - if (IN_CLASSA(ah)) - mask = IN_CLASSA_NET; - else if (IN_CLASSB(ah)) - mask = IN_CLASSB_NET; - else if (IN_CLASSC(ah)) - mask = IN_CLASSC_NET; - } - } else { - a = inet_addr (ptr_word); - } - } - - if (ptr_mask != NULL) - *ptr_mask = '/'; - - if (a == (u32_t)-1L) { - ppp_warn("unknown host %s in auth. address list", ap->word); - continue; - } - if (offset != 0) { - if (offset >= ~mask) { - ppp_warn("interface unit %d too large for subnet %v", - ifunit, ptr_word); - continue; - } - a = lwip_htonl((lwip_ntohl(a) & mask) + offset); - mask = ~(u32_t)0; - } - ip[n].mask = lwip_htonl(mask); - ip[n].base = a & ip[n].mask; - ++n; - if (~mask == 0 && suggested_ip == 0) - suggested_ip = a; + /* "-" means no addresses authorized, "*" means any address allowed */ + ptr_word = ap->word; + if (strcmp(ptr_word, "-") == 0) + break; + if (strcmp(ptr_word, "*") == 0) { + ip[n].permit = 1; + ip[n].base = ip[n].mask = 0; + ++n; + break; + } + + ip[n].permit = 1; + if (*ptr_word == '!') { + ip[n].permit = 0; + ++ptr_word; + } + + mask = ~ (u32_t) 0; + offset = 0; + ptr_mask = strchr (ptr_word, '/'); + if (ptr_mask != NULL) { + int bit_count; + char *endp; + + bit_count = (int) strtol (ptr_mask+1, &endp, 10); + if (bit_count <= 0 || bit_count > 32) { + ppp_warn("invalid address length %v in auth. address list", + ptr_mask+1); + continue; + } + bit_count = 32 - bit_count; /* # bits in host part */ + if (*endp == '+') { + offset = ifunit + 1; + ++endp; + } + if (*endp != 0) { + ppp_warn("invalid address length syntax: %v", ptr_mask+1); + continue; + } + *ptr_mask = '\0'; + mask <<= bit_count; + } + + hp = gethostbyname(ptr_word); + if (hp != NULL && hp->h_addrtype == AF_INET) { + a = *(u32_t *)hp->h_addr; + } else { + np = getnetbyname (ptr_word); + if (np != NULL && np->n_addrtype == AF_INET) { + a = lwip_htonl ((u32_t)np->n_net); + if (ptr_mask == NULL) { + /* calculate appropriate mask for net */ + ah = lwip_ntohl(a); + if (IN_CLASSA(ah)) + mask = IN_CLASSA_NET; + else if (IN_CLASSB(ah)) + mask = IN_CLASSB_NET; + else if (IN_CLASSC(ah)) + mask = IN_CLASSC_NET; + } + } else { + a = inet_addr (ptr_word); + } + } + + if (ptr_mask != NULL) + *ptr_mask = '/'; + + if (a == (u32_t)-1L) { + ppp_warn("unknown host %s in auth. address list", ap->word); + continue; + } + if (offset != 0) { + if (offset >= ~mask) { + ppp_warn("interface unit %d too large for subnet %v", + ifunit, ptr_word); + continue; + } + a = lwip_htonl((lwip_ntohl(a) & mask) + offset); + mask = ~(u32_t)0; + } + ip[n].mask = lwip_htonl(mask); + ip[n].base = a & ip[n].mask; + ++n; + if (~mask == 0 && suggested_ip == 0) + suggested_ip = a; } *plink = NULL; - ip[n].permit = 0; /* make the last entry forbid all addresses */ - ip[n].base = 0; /* to terminate the list */ + ip[n].permit = 0; /* make the last entry forbid all addresses */ + ip[n].base = 0; /* to terminate the list */ ip[n].mask = 0; addresses[unit] = ip; @@ -2173,14 +2173,14 @@ set_allowed_addrs(unit, addrs, opts) * which is a single host, then use that if we find one. */ if (suggested_ip != 0 - && (wo->hisaddr == 0 || !auth_ip_addr(unit, wo->hisaddr))) { - wo->hisaddr = suggested_ip; - /* - * Do we insist on this address? No, if there are other - * addresses authorized than the suggested one. - */ - if (n > 1) - wo->accept_remote = 1; + && (wo->hisaddr == 0 || !auth_ip_addr(unit, wo->hisaddr))) { + wo->hisaddr = suggested_ip; + /* + * Do we insist on this address? No, if there are other + * addresses authorized than the suggested one. + */ + if (n > 1) + wo->accept_remote = 1; } } @@ -2197,21 +2197,21 @@ auth_ip_addr(unit, addr) /* don't allow loopback or multicast address */ if (bad_ip_adrs(addr)) - return 0; + return 0; if (allowed_address_hook) { - ok = allowed_address_hook(addr); - if (ok >= 0) return ok; + ok = allowed_address_hook(addr); + if (ok >= 0) return ok; } if (addresses[unit] != NULL) { - ok = ip_addr_check(addr, addresses[unit]); - if (ok >= 0) - return ok; + ok = ip_addr_check(addr, addresses[unit]); + if (ok >= 0) + return ok; } if (auth_required) - return 0; /* no addresses authorized */ + return 0; /* no addresses authorized */ return allow_any_ip || privileged || !have_route_to(addr); } @@ -2221,8 +2221,8 @@ ip_addr_check(addr, addrs) struct permitted_ip *addrs; { for (; ; ++addrs) - if ((addr & addrs->mask) == addrs->base) - return addrs->permit; + if ((addr & addrs->mask) == addrs->base) + return addrs->permit; } /* @@ -2236,7 +2236,7 @@ bad_ip_adrs(addr) { addr = lwip_ntohl(addr); return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET - || IN_MULTICAST(addr) || IN_BADCLASS(addr); + || IN_MULTICAST(addr) || IN_BADCLASS(addr); } /* @@ -2248,10 +2248,10 @@ some_ip_ok(addrs) struct wordlist *addrs; { for (; addrs != 0; addrs = addrs->next) { - if (addrs->word[0] == '-') - break; - if (addrs->word[0] != '!') - return 1; /* some IP address is allowed */ + if (addrs->word[0] == '-') + break; + if (addrs->word[0] != '!') + return 1; /* some IP address is allowed */ } return 0; } @@ -2268,17 +2268,17 @@ auth_number() /* Allow all if no authorization list. */ if (!wp) - return 1; + return 1; /* Allow if we have a match in the authorization list. */ while (wp) { - /* trailing '*' wildcard */ - l = strlen(wp->word); - if ((wp->word)[l - 1] == '*') - l--; - if (!strncasecmp(wp->word, remote_number, l)) - return 1; - wp = wp->next; + /* trailing '*' wildcard */ + l = strlen(wp->word); + if ((wp->word)[l - 1] == '*') + l--; + if (!strncasecmp(wp->word, remote_number, l)) + return 1; + wp = wp->next; } return 0; @@ -2295,10 +2295,10 @@ check_access(f, filename) struct stat sbuf; if (fstat(fileno(f), &sbuf) < 0) { - ppp_warn("cannot stat secret file %s: %m", filename); + ppp_warn("cannot stat secret file %s: %m", filename); } else if ((sbuf.st_mode & (S_IRWXG | S_IRWXO)) != 0) { - ppp_warn("Warning - secret file %s has world and/or group access", - filename); + ppp_warn("Warning - secret file %s has world and/or group access", + filename); } } @@ -2337,141 +2337,141 @@ scan_authfile(f, client, server, secret, addrs, opts, filename, flags) char *cp; if (addrs != NULL) - *addrs = NULL; + *addrs = NULL; if (opts != NULL) - *opts = NULL; + *opts = NULL; addr_list = NULL; if (!getword(f, word, &newline, filename)) - return -1; /* file is empty??? */ + return -1; /* file is empty??? */ newline = 1; best_flag = -1; for (;;) { - /* - * Skip until we find a word at the start of a line. - */ - while (!newline && getword(f, word, &newline, filename)) - ; - if (!newline) - break; /* got to end of file */ - - /* - * Got a client - check if it's a match or a wildcard. - */ - got_flag = 0; - if (client != NULL && strcmp(word, client) != 0 && !ISWILD(word)) { - newline = 0; - continue; - } - if (!ISWILD(word)) - got_flag = NONWILD_CLIENT; - - /* - * Now get a server and check if it matches. - */ - if (!getword(f, word, &newline, filename)) - break; - if (newline) - continue; - if (!ISWILD(word)) { - if (server != NULL && strcmp(word, server) != 0) - continue; - got_flag |= NONWILD_SERVER; - } - - /* - * Got some sort of a match - see if it's better than what - * we have already. - */ - if (got_flag <= best_flag) - continue; - - /* - * Get the secret. - */ - if (!getword(f, word, &newline, filename)) - break; - if (newline) - continue; - - /* - * SRP-SHA1 authenticator should never be reading secrets from - * a file. (Authenticatee may, though.) - */ - if (flags && ((cp = strchr(word, ':')) == NULL || - strchr(cp + 1, ':') == NULL)) - continue; - - if (secret != NULL) { - /* - * Special syntax: @/pathname means read secret from file. - */ - if (word[0] == '@' && word[1] == '/') { - strlcpy(atfile, word+1, sizeof(atfile)); - if ((sf = fopen(atfile, "r")) == NULL) { - ppp_warn("can't open indirect secret file %s", atfile); - continue; - } - check_access(sf, atfile); - if (!getword(sf, word, &xxx, atfile)) { - ppp_warn("no secret in indirect secret file %s", atfile); - fclose(sf); - continue; - } - fclose(sf); - } - strlcpy(lsecret, word, sizeof(lsecret)); - } - - /* - * Now read address authorization info and make a wordlist. - */ - app = &alist; - for (;;) { - if (!getword(f, word, &newline, filename) || newline) - break; - ap = (struct wordlist *) - malloc(sizeof(struct wordlist) + strlen(word) + 1); - if (ap == NULL) - novm("authorized addresses"); - ap->word = (char *) (ap + 1); - strcpy(ap->word, word); - *app = ap; - app = &ap->next; - } - *app = NULL; - - /* - * This is the best so far; remember it. - */ - best_flag = got_flag; - if (addr_list) - free_wordlist(addr_list); - addr_list = alist; - if (secret != NULL) - strlcpy(secret, lsecret, MAXWORDLEN); - - if (!newline) - break; + /* + * Skip until we find a word at the start of a line. + */ + while (!newline && getword(f, word, &newline, filename)) + ; + if (!newline) + break; /* got to end of file */ + + /* + * Got a client - check if it's a match or a wildcard. + */ + got_flag = 0; + if (client != NULL && strcmp(word, client) != 0 && !ISWILD(word)) { + newline = 0; + continue; + } + if (!ISWILD(word)) + got_flag = NONWILD_CLIENT; + + /* + * Now get a server and check if it matches. + */ + if (!getword(f, word, &newline, filename)) + break; + if (newline) + continue; + if (!ISWILD(word)) { + if (server != NULL && strcmp(word, server) != 0) + continue; + got_flag |= NONWILD_SERVER; + } + + /* + * Got some sort of a match - see if it's better than what + * we have already. + */ + if (got_flag <= best_flag) + continue; + + /* + * Get the secret. + */ + if (!getword(f, word, &newline, filename)) + break; + if (newline) + continue; + + /* + * SRP-SHA1 authenticator should never be reading secrets from + * a file. (Authenticatee may, though.) + */ + if (flags && ((cp = strchr(word, ':')) == NULL || + strchr(cp + 1, ':') == NULL)) + continue; + + if (secret != NULL) { + /* + * Special syntax: @/pathname means read secret from file. + */ + if (word[0] == '@' && word[1] == '/') { + strlcpy(atfile, word+1, sizeof(atfile)); + if ((sf = fopen(atfile, "r")) == NULL) { + ppp_warn("can't open indirect secret file %s", atfile); + continue; + } + check_access(sf, atfile); + if (!getword(sf, word, &xxx, atfile)) { + ppp_warn("no secret in indirect secret file %s", atfile); + fclose(sf); + continue; + } + fclose(sf); + } + strlcpy(lsecret, word, sizeof(lsecret)); + } + + /* + * Now read address authorization info and make a wordlist. + */ + app = &alist; + for (;;) { + if (!getword(f, word, &newline, filename) || newline) + break; + ap = (struct wordlist *) + malloc(sizeof(struct wordlist) + strlen(word) + 1); + if (ap == NULL) + novm("authorized addresses"); + ap->word = (char *) (ap + 1); + strcpy(ap->word, word); + *app = ap; + app = &ap->next; + } + *app = NULL; + + /* + * This is the best so far; remember it. + */ + best_flag = got_flag; + if (addr_list) + free_wordlist(addr_list); + addr_list = alist; + if (secret != NULL) + strlcpy(secret, lsecret, MAXWORDLEN); + + if (!newline) + break; } /* scan for a -- word indicating the start of options */ for (app = &addr_list; (ap = *app) != NULL; app = &ap->next) - if (strcmp(ap->word, "--") == 0) - break; + if (strcmp(ap->word, "--") == 0) + break; /* ap = start of options */ if (ap != NULL) { - ap = ap->next; /* first option */ - free(*app); /* free the "--" word */ - *app = NULL; /* terminate addr list */ + ap = ap->next; /* first option */ + free(*app); /* free the "--" word */ + *app = NULL; /* terminate addr list */ } if (opts != NULL) - *opts = ap; + *opts = ap; else if (ap != NULL) - free_wordlist(ap); + free_wordlist(ap); if (addrs != NULL) - *addrs = addr_list; + *addrs = addr_list; else if (addr_list != NULL) - free_wordlist(addr_list); + free_wordlist(addr_list); return best_flag; } @@ -2486,7 +2486,7 @@ wordlist_count(wp) int n; for (n = 0; wp != NULL; wp = wp->next) - ++n; + ++n; return n; } @@ -2500,9 +2500,9 @@ free_wordlist(wp) struct wordlist *next; while (wp != NULL) { - next = wp->next; - free(wp); - wp = next; + next = wp->next; + free(wp); + wp = next; } } #endif /* UNUSED */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/ccp.c b/components/net/lwip-2.1.2/src/netif/ppp/ccp.c index f8519ebece..5e5b75c361 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/ccp.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/ccp.c @@ -40,8 +40,8 @@ #include "netif/ppp/ccp.h" #if MPPE_SUPPORT -#include "netif/ppp/lcp.h" /* lcp_close(), lcp_fsm */ -#include "netif/ppp/mppe.h" /* mppe_init() */ +#include "netif/ppp/lcp.h" /* lcp_close(), lcp_fsm */ +#include "netif/ppp/mppe.h" /* mppe_init() */ #endif /* MPPE_SUPPORT */ /* @@ -51,7 +51,7 @@ * Until this is fixed we only accept sizes in the range 9 .. 15. * Thanks to James Carlson for pointing this out. */ -#define DEFLATE_MIN_WORKS 9 +#define DEFLATE_MIN_WORKS 9 /* * Command-line options. @@ -66,7 +66,7 @@ static char deflate_value[8]; * Option variables. */ #if MPPE_SUPPORT -bool refuse_mppe_stateful = 1; /* Allow stateful mode? */ +bool refuse_mppe_stateful = 1; /* Allow stateful mode? */ #endif /* MPPE_SUPPORT */ static option_t ccp_option_list[] = { @@ -248,27 +248,27 @@ static const fsm_callbacks ccp_callbacks = { static int ccp_anycompress(ccp_options *opt) { return (0 #if DEFLATE_SUPPORT - || (opt)->deflate + || (opt)->deflate #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - || (opt)->bsd_compress + || (opt)->bsd_compress #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - || (opt)->predictor_1 || (opt)->predictor_2 + || (opt)->predictor_1 || (opt)->predictor_2 #endif /* PREDICTOR_SUPPORT */ #if MPPE_SUPPORT - || (opt)->mppe + || (opt)->mppe #endif /* MPPE_SUPPORT */ - ); + ); } /* * Local state (mainly for handling reset-reqs and reset-acks). */ -#define RACK_PENDING 1 /* waiting for reset-ack */ -#define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */ +#define RACK_PENDING 1 /* waiting for reset-ack */ +#define RREQ_REPEAT 2 /* send another reset-req if no reset-ack */ -#define RACKTIMEOUT 1 /* second */ +#define RACKTIMEOUT 1 /* second */ #if PPP_OPTIONS /* @@ -284,31 +284,31 @@ setbsdcomp(argv) str = *argv; abits = rbits = strtol(str, &endp, 0); if (endp != str && *endp == ',') { - str = endp + 1; - abits = strtol(str, &endp, 0); + str = endp + 1; + abits = strtol(str, &endp, 0); } if (*endp != 0 || endp == str) { - option_error("invalid parameter '%s' for bsdcomp option", *argv); - return 0; + option_error("invalid parameter '%s' for bsdcomp option", *argv); + return 0; } if ((rbits != 0 && (rbits < BSD_MIN_BITS || rbits > BSD_MAX_BITS)) - || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) { - option_error("bsdcomp option values must be 0 or %d .. %d", - BSD_MIN_BITS, BSD_MAX_BITS); - return 0; + || (abits != 0 && (abits < BSD_MIN_BITS || abits > BSD_MAX_BITS))) { + option_error("bsdcomp option values must be 0 or %d .. %d", + BSD_MIN_BITS, BSD_MAX_BITS); + return 0; } if (rbits > 0) { - ccp_wantoptions[0].bsd_compress = 1; - ccp_wantoptions[0].bsd_bits = rbits; + ccp_wantoptions[0].bsd_compress = 1; + ccp_wantoptions[0].bsd_bits = rbits; } else - ccp_wantoptions[0].bsd_compress = 0; + ccp_wantoptions[0].bsd_compress = 0; if (abits > 0) { - ccp_allowoptions[0].bsd_compress = 1; - ccp_allowoptions[0].bsd_bits = abits; + ccp_allowoptions[0].bsd_compress = 1; + ccp_allowoptions[0].bsd_bits = abits; } else - ccp_allowoptions[0].bsd_compress = 0; + ccp_allowoptions[0].bsd_compress = 0; ppp_slprintf(bsd_value, sizeof(bsd_value), - rbits == abits? "%d": "%d,%d", rbits, abits); + rbits == abits? "%d": "%d,%d", rbits, abits); return 1; } @@ -323,40 +323,40 @@ setdeflate(argv) str = *argv; abits = rbits = strtol(str, &endp, 0); if (endp != str && *endp == ',') { - str = endp + 1; - abits = strtol(str, &endp, 0); + str = endp + 1; + abits = strtol(str, &endp, 0); } if (*endp != 0 || endp == str) { - option_error("invalid parameter '%s' for deflate option", *argv); - return 0; + option_error("invalid parameter '%s' for deflate option", *argv); + return 0; } if ((rbits != 0 && (rbits < DEFLATE_MIN_SIZE || rbits > DEFLATE_MAX_SIZE)) - || (abits != 0 && (abits < DEFLATE_MIN_SIZE - || abits > DEFLATE_MAX_SIZE))) { - option_error("deflate option values must be 0 or %d .. %d", - DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE); - return 0; + || (abits != 0 && (abits < DEFLATE_MIN_SIZE + || abits > DEFLATE_MAX_SIZE))) { + option_error("deflate option values must be 0 or %d .. %d", + DEFLATE_MIN_SIZE, DEFLATE_MAX_SIZE); + return 0; } if (rbits == DEFLATE_MIN_SIZE || abits == DEFLATE_MIN_SIZE) { - if (rbits == DEFLATE_MIN_SIZE) - rbits = DEFLATE_MIN_WORKS; - if (abits == DEFLATE_MIN_SIZE) - abits = DEFLATE_MIN_WORKS; - warn("deflate option value of %d changed to %d to avoid zlib bug", - DEFLATE_MIN_SIZE, DEFLATE_MIN_WORKS); + if (rbits == DEFLATE_MIN_SIZE) + rbits = DEFLATE_MIN_WORKS; + if (abits == DEFLATE_MIN_SIZE) + abits = DEFLATE_MIN_WORKS; + warn("deflate option value of %d changed to %d to avoid zlib bug", + DEFLATE_MIN_SIZE, DEFLATE_MIN_WORKS); } if (rbits > 0) { - ccp_wantoptions[0].deflate = 1; - ccp_wantoptions[0].deflate_size = rbits; + ccp_wantoptions[0].deflate = 1; + ccp_wantoptions[0].deflate_size = rbits; } else - ccp_wantoptions[0].deflate = 0; + ccp_wantoptions[0].deflate = 0; if (abits > 0) { - ccp_allowoptions[0].deflate = 1; - ccp_allowoptions[0].deflate_size = abits; + ccp_allowoptions[0].deflate = 1; + ccp_allowoptions[0].deflate_size = abits; } else - ccp_allowoptions[0].deflate = 0; + ccp_allowoptions[0].deflate = 0; ppp_slprintf(deflate_value, sizeof(deflate_value), - rbits == abits? "%d": "%d,%d", rbits, abits); + rbits == abits? "%d": "%d,%d", rbits, abits); return 1; } @@ -411,7 +411,7 @@ static void ccp_open(ppp_pcb *pcb) { ccp_options *go = &pcb->ccp_gotoptions; if (f->state != PPP_FSM_OPENED) - ccp_set(pcb, 1, 0, 0, 0); + ccp_set(pcb, 1, 0, 0, 0); /* * Find out which compressors the kernel supports before @@ -419,7 +419,7 @@ static void ccp_open(ppp_pcb *pcb) { */ ccp_resetci(f); if (!ccp_anycompress(go)) - f->flags |= OPT_SILENT; + f->flags |= OPT_SILENT; fsm_open(f); } @@ -463,12 +463,12 @@ static void ccp_input(ppp_pcb *pcb, u_char *p, int len) { oldstate = f->state; fsm_input(f, p, len); if (oldstate == PPP_FSM_OPENED && p[0] == TERMREQ && f->state != PPP_FSM_OPENED) { - ppp_notice("Compression disabled by peer."); + ppp_notice("Compression disabled by peer."); #if MPPE_SUPPORT - if (go->mppe) { - ppp_error("MPPE disabled, closing LCP"); - lcp_close(pcb, "MPPE disabled by peer"); - } + if (go->mppe) { + ppp_error("MPPE disabled, closing LCP"); + lcp_close(pcb, "MPPE disabled by peer"); + } #endif /* MPPE_SUPPORT */ } @@ -477,8 +477,8 @@ static void ccp_input(ppp_pcb *pcb, u_char *p, int len) { * close CCP. */ if (oldstate == PPP_FSM_REQSENT && p[0] == TERMACK - && !ccp_anycompress(go)) - ccp_close(pcb, "No compression negotiated"); + && !ccp_anycompress(go)) + ccp_close(pcb, "No compression negotiated"); } /* @@ -491,24 +491,24 @@ static int ccp_extcode(fsm *f, int code, int id, u_char *p, int len) { switch (code) { case CCP_RESETREQ: - if (f->state != PPP_FSM_OPENED) - break; - ccp_reset_comp(pcb); - /* send a reset-ack, which the transmitter will see and - reset its compression state. */ - fsm_sdata(f, CCP_RESETACK, id, NULL, 0); - break; + if (f->state != PPP_FSM_OPENED) + break; + ccp_reset_comp(pcb); + /* send a reset-ack, which the transmitter will see and + reset its compression state. */ + fsm_sdata(f, CCP_RESETACK, id, NULL, 0); + break; case CCP_RESETACK: - if ((pcb->ccp_localstate & RACK_PENDING) && id == f->reqid) { - pcb->ccp_localstate &= ~(RACK_PENDING | RREQ_REPEAT); - UNTIMEOUT(ccp_rack_timeout, f); - ccp_reset_decomp(pcb); - } - break; + if ((pcb->ccp_localstate & RACK_PENDING) && id == f->reqid) { + pcb->ccp_localstate &= ~(RACK_PENDING | RREQ_REPEAT); + UNTIMEOUT(ccp_rack_timeout, f); + ccp_reset_decomp(pcb); + } + break; default: - return 0; + return 0; } return 1; @@ -528,8 +528,8 @@ static void ccp_protrej(ppp_pcb *pcb) { #if MPPE_SUPPORT if (go->mppe) { - ppp_error("MPPE required but peer negotiation failed"); - lcp_close(pcb, "MPPE required but peer negotiation failed"); + ppp_error("MPPE required but peer negotiation failed"); + lcp_close(pcb, "MPPE required but peer negotiation failed"); } #endif /* MPPE_SUPPORT */ @@ -554,9 +554,9 @@ static void ccp_resetci(fsm *f) { #if MPPE_SUPPORT if (pcb->settings.require_mppe) { - wo->mppe = ao->mppe = - (pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40) - | (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128); + wo->mppe = ao->mppe = + (pcb->settings.refuse_mppe_40 ? 0 : MPPE_OPT_40) + | (pcb->settings.refuse_mppe_128 ? 0 : MPPE_OPT_128); } #endif /* MPPE_SUPPORT */ @@ -565,78 +565,78 @@ static void ccp_resetci(fsm *f) { #if MPPE_SUPPORT if (go->mppe) { - int auth_mschap_bits = pcb->auth_done; - int numbits; - - /* - * Start with a basic sanity check: mschap[v2] auth must be in - * exactly one direction. RFC 3079 says that the keys are - * 'derived from the credentials of the peer that initiated the call', - * however the PPP protocol doesn't have such a concept, and pppd - * cannot get this info externally. Instead we do the best we can. - * NB: If MPPE is required, all other compression opts are invalid. - * So, we return right away if we can't do it. - */ - - /* Leave only the mschap auth bits set */ - auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER | - CHAP_MS2_WITHPEER | CHAP_MS2_PEER); - /* Count the mschap auths */ - auth_mschap_bits >>= CHAP_MS_SHIFT; - numbits = 0; - do { - numbits += auth_mschap_bits & 1; - auth_mschap_bits >>= 1; - } while (auth_mschap_bits); - if (numbits > 1) { - ppp_error("MPPE required, but auth done in both directions."); - lcp_close(pcb, "MPPE required but not available"); - return; - } - if (!numbits) { - ppp_error("MPPE required, but MS-CHAP[v2] auth not performed."); - lcp_close(pcb, "MPPE required but not available"); - return; - } - - /* A plugin (eg radius) may not have obtained key material. */ - if (!pcb->mppe_keys_set) { - ppp_error("MPPE required, but keys are not available. " - "Possible plugin problem?"); - lcp_close(pcb, "MPPE required but not available"); - return; - } - - /* LM auth not supported for MPPE */ - if (pcb->auth_done & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) { - /* This might be noise */ - if (go->mppe & MPPE_OPT_40) { - ppp_notice("Disabling 40-bit MPPE; MS-CHAP LM not supported"); - go->mppe &= ~MPPE_OPT_40; - wo->mppe &= ~MPPE_OPT_40; - } - } - - /* Last check: can we actually negotiate something? */ - if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) { - /* Could be misconfig, could be 40-bit disabled above. */ - ppp_error("MPPE required, but both 40-bit and 128-bit disabled."); - lcp_close(pcb, "MPPE required but not available"); - return; - } - - /* sync options */ - ao->mppe = go->mppe; - /* MPPE is not compatible with other compression types */ + int auth_mschap_bits = pcb->auth_done; + int numbits; + + /* + * Start with a basic sanity check: mschap[v2] auth must be in + * exactly one direction. RFC 3079 says that the keys are + * 'derived from the credentials of the peer that initiated the call', + * however the PPP protocol doesn't have such a concept, and pppd + * cannot get this info externally. Instead we do the best we can. + * NB: If MPPE is required, all other compression opts are invalid. + * So, we return right away if we can't do it. + */ + + /* Leave only the mschap auth bits set */ + auth_mschap_bits &= (CHAP_MS_WITHPEER | CHAP_MS_PEER | + CHAP_MS2_WITHPEER | CHAP_MS2_PEER); + /* Count the mschap auths */ + auth_mschap_bits >>= CHAP_MS_SHIFT; + numbits = 0; + do { + numbits += auth_mschap_bits & 1; + auth_mschap_bits >>= 1; + } while (auth_mschap_bits); + if (numbits > 1) { + ppp_error("MPPE required, but auth done in both directions."); + lcp_close(pcb, "MPPE required but not available"); + return; + } + if (!numbits) { + ppp_error("MPPE required, but MS-CHAP[v2] auth not performed."); + lcp_close(pcb, "MPPE required but not available"); + return; + } + + /* A plugin (eg radius) may not have obtained key material. */ + if (!pcb->mppe_keys_set) { + ppp_error("MPPE required, but keys are not available. " + "Possible plugin problem?"); + lcp_close(pcb, "MPPE required but not available"); + return; + } + + /* LM auth not supported for MPPE */ + if (pcb->auth_done & (CHAP_MS_WITHPEER | CHAP_MS_PEER)) { + /* This might be noise */ + if (go->mppe & MPPE_OPT_40) { + ppp_notice("Disabling 40-bit MPPE; MS-CHAP LM not supported"); + go->mppe &= ~MPPE_OPT_40; + wo->mppe &= ~MPPE_OPT_40; + } + } + + /* Last check: can we actually negotiate something? */ + if (!(go->mppe & (MPPE_OPT_40 | MPPE_OPT_128))) { + /* Could be misconfig, could be 40-bit disabled above. */ + ppp_error("MPPE required, but both 40-bit and 128-bit disabled."); + lcp_close(pcb, "MPPE required but not available"); + return; + } + + /* sync options */ + ao->mppe = go->mppe; + /* MPPE is not compatible with other compression types */ #if BSDCOMPRESS_SUPPORT - ao->bsd_compress = go->bsd_compress = 0; + ao->bsd_compress = go->bsd_compress = 0; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - ao->predictor_1 = go->predictor_1 = 0; - ao->predictor_2 = go->predictor_2 = 0; + ao->predictor_1 = go->predictor_1 = 0; + ao->predictor_2 = go->predictor_2 = 0; #endif /* PREDICTOR_SUPPORT */ #if DEFLATE_SUPPORT - ao->deflate = go->deflate = 0; + ao->deflate = go->deflate = 0; #endif /* DEFLATE_SUPPORT */ } #endif /* MPPE_SUPPORT */ @@ -650,23 +650,23 @@ static void ccp_resetci(fsm *f) { * if BSDCOMPRESS_SUPPORT is set, it is. */ if (go->bsd_compress) { - opt_buf[0] = CI_BSD_COMPRESS; - opt_buf[1] = CILEN_BSD_COMPRESS; - for (;;) { - if (go->bsd_bits < BSD_MIN_BITS) { - go->bsd_compress = 0; - break; - } - opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); - res = ccp_test(pcb, opt_buf, CILEN_BSD_COMPRESS, 0); - if (res > 0) { - break; - } else if (res < 0) { - go->bsd_compress = 0; - break; - } - go->bsd_bits--; - } + opt_buf[0] = CI_BSD_COMPRESS; + opt_buf[1] = CILEN_BSD_COMPRESS; + for (;;) { + if (go->bsd_bits < BSD_MIN_BITS) { + go->bsd_compress = 0; + break; + } + opt_buf[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); + res = ccp_test(pcb, opt_buf, CILEN_BSD_COMPRESS, 0); + if (res > 0) { + break; + } else if (res < 0) { + go->bsd_compress = 0; + break; + } + go->bsd_bits--; + } } #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT @@ -674,48 +674,48 @@ static void ccp_resetci(fsm *f) { * if DEFLATE_SUPPORT is set, it is. */ if (go->deflate) { - if (go->deflate_correct) { - opt_buf[0] = CI_DEFLATE; - opt_buf[1] = CILEN_DEFLATE; - opt_buf[3] = DEFLATE_CHK_SEQUENCE; - for (;;) { - if (go->deflate_size < DEFLATE_MIN_WORKS) { - go->deflate_correct = 0; - break; - } - opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); - res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); - if (res > 0) { - break; - } else if (res < 0) { - go->deflate_correct = 0; - break; - } - go->deflate_size--; - } - } - if (go->deflate_draft) { - opt_buf[0] = CI_DEFLATE_DRAFT; - opt_buf[1] = CILEN_DEFLATE; - opt_buf[3] = DEFLATE_CHK_SEQUENCE; - for (;;) { - if (go->deflate_size < DEFLATE_MIN_WORKS) { - go->deflate_draft = 0; - break; - } - opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); - res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); - if (res > 0) { - break; - } else if (res < 0) { - go->deflate_draft = 0; - break; - } - go->deflate_size--; - } - } - if (!go->deflate_correct && !go->deflate_draft) - go->deflate = 0; + if (go->deflate_correct) { + opt_buf[0] = CI_DEFLATE; + opt_buf[1] = CILEN_DEFLATE; + opt_buf[3] = DEFLATE_CHK_SEQUENCE; + for (;;) { + if (go->deflate_size < DEFLATE_MIN_WORKS) { + go->deflate_correct = 0; + break; + } + opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); + res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); + if (res > 0) { + break; + } else if (res < 0) { + go->deflate_correct = 0; + break; + } + go->deflate_size--; + } + } + if (go->deflate_draft) { + opt_buf[0] = CI_DEFLATE_DRAFT; + opt_buf[1] = CILEN_DEFLATE; + opt_buf[3] = DEFLATE_CHK_SEQUENCE; + for (;;) { + if (go->deflate_size < DEFLATE_MIN_WORKS) { + go->deflate_draft = 0; + break; + } + opt_buf[2] = DEFLATE_MAKE_OPT(go->deflate_size); + res = ccp_test(pcb, opt_buf, CILEN_DEFLATE, 0); + if (res > 0) { + break; + } else if (res < 0) { + go->deflate_draft = 0; + break; + } + go->deflate_size--; + } + } + if (!go->deflate_correct && !go->deflate_draft) + go->deflate = 0; } #endif /* DEFLATE_SUPPORT */ #if PREDICTOR_SUPPORT @@ -723,16 +723,16 @@ static void ccp_resetci(fsm *f) { * if PREDICTOR_SUPPORT is set, it is. */ if (go->predictor_1) { - opt_buf[0] = CI_PREDICTOR_1; - opt_buf[1] = CILEN_PREDICTOR_1; - if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_1, 0) <= 0) - go->predictor_1 = 0; + opt_buf[0] = CI_PREDICTOR_1; + opt_buf[1] = CILEN_PREDICTOR_1; + if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_1, 0) <= 0) + go->predictor_1 = 0; } if (go->predictor_2) { - opt_buf[0] = CI_PREDICTOR_2; - opt_buf[1] = CILEN_PREDICTOR_2; - if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_2, 0) <= 0) - go->predictor_2 = 0; + opt_buf[0] = CI_PREDICTOR_2; + opt_buf[1] = CILEN_PREDICTOR_2; + if (ccp_test(pcb, opt_buf, CILEN_PREDICTOR_2, 0) <= 0) + go->predictor_2 = 0; } #endif /* PREDICTOR_SUPPORT */ } @@ -746,20 +746,20 @@ static int ccp_cilen(fsm *f) { return 0 #if BSDCOMPRESS_SUPPORT - + (go->bsd_compress? CILEN_BSD_COMPRESS: 0) + + (go->bsd_compress? CILEN_BSD_COMPRESS: 0) #endif /* BSDCOMPRESS_SUPPORT */ #if DEFLATE_SUPPORT - + (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0) - + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0) + + (go->deflate && go->deflate_correct? CILEN_DEFLATE: 0) + + (go->deflate && go->deflate_draft? CILEN_DEFLATE: 0) #endif /* DEFLATE_SUPPORT */ #if PREDICTOR_SUPPORT - + (go->predictor_1? CILEN_PREDICTOR_1: 0) - + (go->predictor_2? CILEN_PREDICTOR_2: 0) + + (go->predictor_1? CILEN_PREDICTOR_1: 0) + + (go->predictor_2? CILEN_PREDICTOR_2: 0) #endif /* PREDICTOR_SUPPORT */ #if MPPE_SUPPORT - + (go->mppe? CILEN_MPPE: 0) + + (go->mppe? CILEN_MPPE: 0) #endif /* MPPE_SUPPORT */ - ; + ; } /* @@ -776,50 +776,50 @@ static void ccp_addci(fsm *f, u_char *p, int *lenp) { */ #if MPPE_SUPPORT if (go->mppe) { - p[0] = CI_MPPE; - p[1] = CILEN_MPPE; - MPPE_OPTS_TO_CI(go->mppe, &p[2]); - mppe_init(pcb, &pcb->mppe_decomp, go->mppe); - p += CILEN_MPPE; + p[0] = CI_MPPE; + p[1] = CILEN_MPPE; + MPPE_OPTS_TO_CI(go->mppe, &p[2]); + mppe_init(pcb, &pcb->mppe_decomp, go->mppe); + p += CILEN_MPPE; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate) { - if (go->deflate_correct) { - p[0] = CI_DEFLATE; - p[1] = CILEN_DEFLATE; - p[2] = DEFLATE_MAKE_OPT(go->deflate_size); - p[3] = DEFLATE_CHK_SEQUENCE; - p += CILEN_DEFLATE; - } - if (go->deflate_draft) { - p[0] = CI_DEFLATE_DRAFT; - p[1] = CILEN_DEFLATE; - p[2] = p[2 - CILEN_DEFLATE]; - p[3] = DEFLATE_CHK_SEQUENCE; - p += CILEN_DEFLATE; - } + if (go->deflate_correct) { + p[0] = CI_DEFLATE; + p[1] = CILEN_DEFLATE; + p[2] = DEFLATE_MAKE_OPT(go->deflate_size); + p[3] = DEFLATE_CHK_SEQUENCE; + p += CILEN_DEFLATE; + } + if (go->deflate_draft) { + p[0] = CI_DEFLATE_DRAFT; + p[1] = CILEN_DEFLATE; + p[2] = p[2 - CILEN_DEFLATE]; + p[3] = DEFLATE_CHK_SEQUENCE; + p += CILEN_DEFLATE; + } } #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress) { - p[0] = CI_BSD_COMPRESS; - p[1] = CILEN_BSD_COMPRESS; - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); - p += CILEN_BSD_COMPRESS; + p[0] = CI_BSD_COMPRESS; + p[1] = CILEN_BSD_COMPRESS; + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits); + p += CILEN_BSD_COMPRESS; } #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT /* XXX Should Predictor 2 be preferable to Predictor 1? */ if (go->predictor_1) { - p[0] = CI_PREDICTOR_1; - p[1] = CILEN_PREDICTOR_1; - p += CILEN_PREDICTOR_1; + p[0] = CI_PREDICTOR_1; + p[1] = CILEN_PREDICTOR_1; + p += CILEN_PREDICTOR_1; } if (go->predictor_2) { - p[0] = CI_PREDICTOR_2; - p[1] = CILEN_PREDICTOR_2; - p += CILEN_PREDICTOR_2; + p[0] = CI_PREDICTOR_2; + p[1] = CILEN_PREDICTOR_2; + p += CILEN_PREDICTOR_2; } #endif /* PREDICTOR_SUPPORT */ @@ -841,83 +841,83 @@ static int ccp_ackci(fsm *f, u_char *p, int len) { #if MPPE_SUPPORT if (go->mppe) { - u_char opt_buf[CILEN_MPPE]; - - opt_buf[0] = CI_MPPE; - opt_buf[1] = CILEN_MPPE; - MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); - if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE)) - return 0; - p += CILEN_MPPE; - len -= CILEN_MPPE; - /* XXX Cope with first/fast ack */ - if (len == 0) - return 1; + u_char opt_buf[CILEN_MPPE]; + + opt_buf[0] = CI_MPPE; + opt_buf[1] = CILEN_MPPE; + MPPE_OPTS_TO_CI(go->mppe, &opt_buf[2]); + if (len < CILEN_MPPE || memcmp(opt_buf, p, CILEN_MPPE)) + return 0; + p += CILEN_MPPE; + len -= CILEN_MPPE; + /* XXX Cope with first/fast ack */ + if (len == 0) + return 1; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate) { - if (len < CILEN_DEFLATE - || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) - || p[1] != CILEN_DEFLATE - || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - /* XXX Cope with first/fast ack */ - if (len == 0) - return 1; - if (go->deflate_correct && go->deflate_draft) { - if (len < CILEN_DEFLATE - || p[0] != CI_DEFLATE_DRAFT - || p[1] != CILEN_DEFLATE - || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - } + if (len < CILEN_DEFLATE + || p[0] != (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) + || p[1] != CILEN_DEFLATE + || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + /* XXX Cope with first/fast ack */ + if (len == 0) + return 1; + if (go->deflate_correct && go->deflate_draft) { + if (len < CILEN_DEFLATE + || p[0] != CI_DEFLATE_DRAFT + || p[1] != CILEN_DEFLATE + || p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + } } #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress) { - if (len < CILEN_BSD_COMPRESS - || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS - || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) - return 0; - p += CILEN_BSD_COMPRESS; - len -= CILEN_BSD_COMPRESS; - /* XXX Cope with first/fast ack */ - if (p == p0 && len == 0) - return 1; + if (len < CILEN_BSD_COMPRESS + || p[0] != CI_BSD_COMPRESS || p[1] != CILEN_BSD_COMPRESS + || p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) + return 0; + p += CILEN_BSD_COMPRESS; + len -= CILEN_BSD_COMPRESS; + /* XXX Cope with first/fast ack */ + if (p == p0 && len == 0) + return 1; } #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT if (go->predictor_1) { - if (len < CILEN_PREDICTOR_1 - || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1) - return 0; - p += CILEN_PREDICTOR_1; - len -= CILEN_PREDICTOR_1; - /* XXX Cope with first/fast ack */ - if (p == p0 && len == 0) - return 1; + if (len < CILEN_PREDICTOR_1 + || p[0] != CI_PREDICTOR_1 || p[1] != CILEN_PREDICTOR_1) + return 0; + p += CILEN_PREDICTOR_1; + len -= CILEN_PREDICTOR_1; + /* XXX Cope with first/fast ack */ + if (p == p0 && len == 0) + return 1; } if (go->predictor_2) { - if (len < CILEN_PREDICTOR_2 - || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2) - return 0; - p += CILEN_PREDICTOR_2; - len -= CILEN_PREDICTOR_2; - /* XXX Cope with first/fast ack */ - if (p == p0 && len == 0) - return 1; + if (len < CILEN_PREDICTOR_2 + || p[0] != CI_PREDICTOR_2 || p[1] != CILEN_PREDICTOR_2) + return 0; + p += CILEN_PREDICTOR_2; + len -= CILEN_PREDICTOR_2; + /* XXX Cope with first/fast ack */ + if (p == p0 && len == 0) + return 1; } #endif /* PREDICTOR_SUPPORT */ if (len != 0) - return 0; + return 0; return 1; } @@ -928,8 +928,8 @@ static int ccp_ackci(fsm *f, u_char *p, int len) { static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; ccp_options *go = &pcb->ccp_gotoptions; - ccp_options no; /* options we've seen already */ - ccp_options try_; /* options to ask for next time */ + ccp_options no; /* options we've seen already */ + ccp_options try_; /* options to ask for next time */ LWIP_UNUSED_ARG(treat_as_reject); #if !MPPE_SUPPORT && !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT LWIP_UNUSED_ARG(p); @@ -941,66 +941,66 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { #if MPPE_SUPPORT if (go->mppe && len >= CILEN_MPPE - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { - no.mppe = 1; - /* - * Peer wants us to use a different strength or other setting. - * Fail if we aren't willing to use his suggestion. - */ - MPPE_CI_TO_OPTS(&p[2], try_.mppe); - if ((try_.mppe & MPPE_OPT_STATEFUL) && pcb->settings.refuse_mppe_stateful) { - ppp_error("Refusing MPPE stateful mode offered by peer"); - try_.mppe = 0; - } else if (((go->mppe | MPPE_OPT_STATEFUL) & try_.mppe) != try_.mppe) { - /* Peer must have set options we didn't request (suggest) */ - try_.mppe = 0; - } - - if (!try_.mppe) { - ppp_error("MPPE required but peer negotiation failed"); - lcp_close(pcb, "MPPE required but peer negotiation failed"); - } + && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { + no.mppe = 1; + /* + * Peer wants us to use a different strength or other setting. + * Fail if we aren't willing to use his suggestion. + */ + MPPE_CI_TO_OPTS(&p[2], try_.mppe); + if ((try_.mppe & MPPE_OPT_STATEFUL) && pcb->settings.refuse_mppe_stateful) { + ppp_error("Refusing MPPE stateful mode offered by peer"); + try_.mppe = 0; + } else if (((go->mppe | MPPE_OPT_STATEFUL) & try_.mppe) != try_.mppe) { + /* Peer must have set options we didn't request (suggest) */ + try_.mppe = 0; + } + + if (!try_.mppe) { + ppp_error("MPPE required but peer negotiation failed"); + lcp_close(pcb, "MPPE required but peer negotiation failed"); + } } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate && len >= CILEN_DEFLATE - && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) - && p[1] == CILEN_DEFLATE) { - no.deflate = 1; - /* - * Peer wants us to use a different code size or something. - * Stop asking for Deflate if we don't understand his suggestion. - */ - if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL - || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_WORKS - || p[3] != DEFLATE_CHK_SEQUENCE) - try_.deflate = 0; - else if (DEFLATE_SIZE(p[2]) < go->deflate_size) - try_.deflate_size = DEFLATE_SIZE(p[2]); - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - if (go->deflate_correct && go->deflate_draft - && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT - && p[1] == CILEN_DEFLATE) { - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; - } + && p[0] == (go->deflate_correct? CI_DEFLATE: CI_DEFLATE_DRAFT) + && p[1] == CILEN_DEFLATE) { + no.deflate = 1; + /* + * Peer wants us to use a different code size or something. + * Stop asking for Deflate if we don't understand his suggestion. + */ + if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL + || DEFLATE_SIZE(p[2]) < DEFLATE_MIN_WORKS + || p[3] != DEFLATE_CHK_SEQUENCE) + try_.deflate = 0; + else if (DEFLATE_SIZE(p[2]) < go->deflate_size) + try_.deflate_size = DEFLATE_SIZE(p[2]); + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + if (go->deflate_correct && go->deflate_draft + && len >= CILEN_DEFLATE && p[0] == CI_DEFLATE_DRAFT + && p[1] == CILEN_DEFLATE) { + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; + } } #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress && len >= CILEN_BSD_COMPRESS - && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { - no.bsd_compress = 1; - /* - * Peer wants us to use a different number of bits - * or a different version. - */ - if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION) - try_.bsd_compress = 0; - else if (BSD_NBITS(p[2]) < go->bsd_bits) - try_.bsd_bits = BSD_NBITS(p[2]); - p += CILEN_BSD_COMPRESS; - len -= CILEN_BSD_COMPRESS; + && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { + no.bsd_compress = 1; + /* + * Peer wants us to use a different number of bits + * or a different version. + */ + if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION) + try_.bsd_compress = 0; + else if (BSD_NBITS(p[2]) < go->bsd_bits) + try_.bsd_bits = BSD_NBITS(p[2]); + p += CILEN_BSD_COMPRESS; + len -= CILEN_BSD_COMPRESS; } #endif /* BSDCOMPRESS_SUPPORT */ @@ -1011,7 +1011,7 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; } @@ -1021,7 +1021,7 @@ static int ccp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { static int ccp_rejci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; ccp_options *go = &pcb->ccp_gotoptions; - ccp_options try_; /* options to request next time */ + ccp_options try_; /* options to request next time */ try_ = *go; @@ -1030,69 +1030,69 @@ static int ccp_rejci(fsm *f, u_char *p, int len) { * configure-requests. */ if (len == 0 && pcb->ccp_all_rejected) - return -1; + return -1; #if MPPE_SUPPORT if (go->mppe && len >= CILEN_MPPE - && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { - ppp_error("MPPE required but peer refused"); - lcp_close(pcb, "MPPE required but peer refused"); - p += CILEN_MPPE; - len -= CILEN_MPPE; + && p[0] == CI_MPPE && p[1] == CILEN_MPPE) { + ppp_error("MPPE required but peer refused"); + lcp_close(pcb, "MPPE required but peer refused"); + p += CILEN_MPPE; + len -= CILEN_MPPE; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT if (go->deflate_correct && len >= CILEN_DEFLATE - && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) { - if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; /* Rej is bad */ - try_.deflate_correct = 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; + && p[0] == CI_DEFLATE && p[1] == CILEN_DEFLATE) { + if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; /* Rej is bad */ + try_.deflate_correct = 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; } if (go->deflate_draft && len >= CILEN_DEFLATE - && p[0] == CI_DEFLATE_DRAFT && p[1] == CILEN_DEFLATE) { - if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) - || p[3] != DEFLATE_CHK_SEQUENCE) - return 0; /* Rej is bad */ - try_.deflate_draft = 0; - p += CILEN_DEFLATE; - len -= CILEN_DEFLATE; + && p[0] == CI_DEFLATE_DRAFT && p[1] == CILEN_DEFLATE) { + if (p[2] != DEFLATE_MAKE_OPT(go->deflate_size) + || p[3] != DEFLATE_CHK_SEQUENCE) + return 0; /* Rej is bad */ + try_.deflate_draft = 0; + p += CILEN_DEFLATE; + len -= CILEN_DEFLATE; } if (!try_.deflate_correct && !try_.deflate_draft) - try_.deflate = 0; + try_.deflate = 0; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT if (go->bsd_compress && len >= CILEN_BSD_COMPRESS - && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { - if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) - return 0; - try_.bsd_compress = 0; - p += CILEN_BSD_COMPRESS; - len -= CILEN_BSD_COMPRESS; + && p[0] == CI_BSD_COMPRESS && p[1] == CILEN_BSD_COMPRESS) { + if (p[2] != BSD_MAKE_OPT(BSD_CURRENT_VERSION, go->bsd_bits)) + return 0; + try_.bsd_compress = 0; + p += CILEN_BSD_COMPRESS; + len -= CILEN_BSD_COMPRESS; } #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT if (go->predictor_1 && len >= CILEN_PREDICTOR_1 - && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) { - try_.predictor_1 = 0; - p += CILEN_PREDICTOR_1; - len -= CILEN_PREDICTOR_1; + && p[0] == CI_PREDICTOR_1 && p[1] == CILEN_PREDICTOR_1) { + try_.predictor_1 = 0; + p += CILEN_PREDICTOR_1; + len -= CILEN_PREDICTOR_1; } if (go->predictor_2 && len >= CILEN_PREDICTOR_2 - && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) { - try_.predictor_2 = 0; - p += CILEN_PREDICTOR_2; - len -= CILEN_PREDICTOR_2; + && p[0] == CI_PREDICTOR_2 && p[1] == CILEN_PREDICTOR_2) { + try_.predictor_2 = 0; + p += CILEN_PREDICTOR_2; + len -= CILEN_PREDICTOR_2; } #endif /* PREDICTOR_SUPPORT */ if (len != 0) - return 0; + return 0; if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; } @@ -1114,8 +1114,8 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) { u_char *p0, *retp; int len, clen, type; #if MPPE_SUPPORT - u8_t rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */ - /* CI_MPPE, or due to other options? */ + u8_t rej_for_ci_mppe = 1; /* Are we rejecting based on a bad/missing */ + /* CI_MPPE, or due to other options? */ #endif /* MPPE_SUPPORT */ ret = CONFACK; @@ -1126,257 +1126,257 @@ static int ccp_reqci(fsm *f, u_char *p, int *lenp, int dont_nak) { ho->method = (len > 0)? p[0]: 0; while (len > 0) { - newret = CONFACK; - if (len < 2 || p[1] < 2 || p[1] > len) { - /* length is bad */ - clen = len; - newret = CONFREJ; + newret = CONFACK; + if (len < 2 || p[1] < 2 || p[1] > len) { + /* length is bad */ + clen = len; + newret = CONFREJ; - } else { - type = p[0]; - clen = p[1]; + } else { + type = p[0]; + clen = p[1]; - switch (type) { + switch (type) { #if MPPE_SUPPORT - case CI_MPPE: - if (!ao->mppe || clen != CILEN_MPPE) { - newret = CONFREJ; - break; - } - MPPE_CI_TO_OPTS(&p[2], ho->mppe); - - /* Nak if anything unsupported or unknown are set. */ - if (ho->mppe & MPPE_OPT_UNSUPPORTED) { - newret = CONFNAK; - ho->mppe &= ~MPPE_OPT_UNSUPPORTED; - } - if (ho->mppe & MPPE_OPT_UNKNOWN) { - newret = CONFNAK; - ho->mppe &= ~MPPE_OPT_UNKNOWN; - } - - /* Check state opt */ - if (ho->mppe & MPPE_OPT_STATEFUL) { - /* - * We can Nak and request stateless, but it's a - * lot easier to just assume the peer will request - * it if he can do it; stateful mode is bad over - * the Internet -- which is where we expect MPPE. - */ - if (pcb->settings.refuse_mppe_stateful) { - ppp_error("Refusing MPPE stateful mode offered by peer"); - newret = CONFREJ; - break; - } - } - - /* Find out which of {S,L} are set. */ - if ((ho->mppe & MPPE_OPT_128) - && (ho->mppe & MPPE_OPT_40)) { - /* Both are set, negotiate the strongest. */ - newret = CONFNAK; - if (ao->mppe & MPPE_OPT_128) - ho->mppe &= ~MPPE_OPT_40; - else if (ao->mppe & MPPE_OPT_40) - ho->mppe &= ~MPPE_OPT_128; - else { - newret = CONFREJ; - break; - } - } else if (ho->mppe & MPPE_OPT_128) { - if (!(ao->mppe & MPPE_OPT_128)) { - newret = CONFREJ; - break; - } - } else if (ho->mppe & MPPE_OPT_40) { - if (!(ao->mppe & MPPE_OPT_40)) { - newret = CONFREJ; - break; - } - } else { - /* Neither are set. */ - /* We cannot accept this. */ - newret = CONFNAK; - /* Give the peer our idea of what can be used, - so it can choose and confirm */ - ho->mppe = ao->mppe; - } - - /* rebuild the opts */ - MPPE_OPTS_TO_CI(ho->mppe, &p[2]); - if (newret == CONFACK) { - int mtu; - - mppe_init(pcb, &pcb->mppe_comp, ho->mppe); - /* - * We need to decrease the interface MTU by MPPE_PAD - * because MPPE frames **grow**. The kernel [must] - * allocate MPPE_PAD extra bytes in xmit buffers. - */ - mtu = netif_get_mtu(pcb); - if (mtu) - netif_set_mtu(pcb, mtu - MPPE_PAD); - else - newret = CONFREJ; - } - - /* - * We have accepted MPPE or are willing to negotiate - * MPPE parameters. A CONFREJ is due to subsequent - * (non-MPPE) processing. - */ - rej_for_ci_mppe = 0; - break; + case CI_MPPE: + if (!ao->mppe || clen != CILEN_MPPE) { + newret = CONFREJ; + break; + } + MPPE_CI_TO_OPTS(&p[2], ho->mppe); + + /* Nak if anything unsupported or unknown are set. */ + if (ho->mppe & MPPE_OPT_UNSUPPORTED) { + newret = CONFNAK; + ho->mppe &= ~MPPE_OPT_UNSUPPORTED; + } + if (ho->mppe & MPPE_OPT_UNKNOWN) { + newret = CONFNAK; + ho->mppe &= ~MPPE_OPT_UNKNOWN; + } + + /* Check state opt */ + if (ho->mppe & MPPE_OPT_STATEFUL) { + /* + * We can Nak and request stateless, but it's a + * lot easier to just assume the peer will request + * it if he can do it; stateful mode is bad over + * the Internet -- which is where we expect MPPE. + */ + if (pcb->settings.refuse_mppe_stateful) { + ppp_error("Refusing MPPE stateful mode offered by peer"); + newret = CONFREJ; + break; + } + } + + /* Find out which of {S,L} are set. */ + if ((ho->mppe & MPPE_OPT_128) + && (ho->mppe & MPPE_OPT_40)) { + /* Both are set, negotiate the strongest. */ + newret = CONFNAK; + if (ao->mppe & MPPE_OPT_128) + ho->mppe &= ~MPPE_OPT_40; + else if (ao->mppe & MPPE_OPT_40) + ho->mppe &= ~MPPE_OPT_128; + else { + newret = CONFREJ; + break; + } + } else if (ho->mppe & MPPE_OPT_128) { + if (!(ao->mppe & MPPE_OPT_128)) { + newret = CONFREJ; + break; + } + } else if (ho->mppe & MPPE_OPT_40) { + if (!(ao->mppe & MPPE_OPT_40)) { + newret = CONFREJ; + break; + } + } else { + /* Neither are set. */ + /* We cannot accept this. */ + newret = CONFNAK; + /* Give the peer our idea of what can be used, + so it can choose and confirm */ + ho->mppe = ao->mppe; + } + + /* rebuild the opts */ + MPPE_OPTS_TO_CI(ho->mppe, &p[2]); + if (newret == CONFACK) { + int mtu; + + mppe_init(pcb, &pcb->mppe_comp, ho->mppe); + /* + * We need to decrease the interface MTU by MPPE_PAD + * because MPPE frames **grow**. The kernel [must] + * allocate MPPE_PAD extra bytes in xmit buffers. + */ + mtu = netif_get_mtu(pcb); + if (mtu) + netif_set_mtu(pcb, mtu - MPPE_PAD); + else + newret = CONFREJ; + } + + /* + * We have accepted MPPE or are willing to negotiate + * MPPE parameters. A CONFREJ is due to subsequent + * (non-MPPE) processing. + */ + rej_for_ci_mppe = 0; + break; #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (!ao->deflate || clen != CILEN_DEFLATE - || (!ao->deflate_correct && type == CI_DEFLATE) - || (!ao->deflate_draft && type == CI_DEFLATE_DRAFT)) { - newret = CONFREJ; - break; - } - - ho->deflate = 1; - ho->deflate_size = nb = DEFLATE_SIZE(p[2]); - if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL - || p[3] != DEFLATE_CHK_SEQUENCE - || nb > ao->deflate_size || nb < DEFLATE_MIN_WORKS) { - newret = CONFNAK; - if (!dont_nak) { - p[2] = DEFLATE_MAKE_OPT(ao->deflate_size); - p[3] = DEFLATE_CHK_SEQUENCE; - /* fall through to test this #bits below */ - } else - break; - } - - /* - * Check whether we can do Deflate with the window - * size they want. If the window is too big, reduce - * it until the kernel can cope and nak with that. - * We only check this for the first option. - */ - if (p == p0) { - for (;;) { - res = ccp_test(pcb, p, CILEN_DEFLATE, 1); - if (res > 0) - break; /* it's OK now */ - if (res < 0 || nb == DEFLATE_MIN_WORKS || dont_nak) { - newret = CONFREJ; - p[2] = DEFLATE_MAKE_OPT(ho->deflate_size); - break; - } - newret = CONFNAK; - --nb; - p[2] = DEFLATE_MAKE_OPT(nb); - } - } - break; + case CI_DEFLATE: + case CI_DEFLATE_DRAFT: + if (!ao->deflate || clen != CILEN_DEFLATE + || (!ao->deflate_correct && type == CI_DEFLATE) + || (!ao->deflate_draft && type == CI_DEFLATE_DRAFT)) { + newret = CONFREJ; + break; + } + + ho->deflate = 1; + ho->deflate_size = nb = DEFLATE_SIZE(p[2]); + if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL + || p[3] != DEFLATE_CHK_SEQUENCE + || nb > ao->deflate_size || nb < DEFLATE_MIN_WORKS) { + newret = CONFNAK; + if (!dont_nak) { + p[2] = DEFLATE_MAKE_OPT(ao->deflate_size); + p[3] = DEFLATE_CHK_SEQUENCE; + /* fall through to test this #bits below */ + } else + break; + } + + /* + * Check whether we can do Deflate with the window + * size they want. If the window is too big, reduce + * it until the kernel can cope and nak with that. + * We only check this for the first option. + */ + if (p == p0) { + for (;;) { + res = ccp_test(pcb, p, CILEN_DEFLATE, 1); + if (res > 0) + break; /* it's OK now */ + if (res < 0 || nb == DEFLATE_MIN_WORKS || dont_nak) { + newret = CONFREJ; + p[2] = DEFLATE_MAKE_OPT(ho->deflate_size); + break; + } + newret = CONFNAK; + --nb; + p[2] = DEFLATE_MAKE_OPT(nb); + } + } + break; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - case CI_BSD_COMPRESS: - if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) { - newret = CONFREJ; - break; - } - - ho->bsd_compress = 1; - ho->bsd_bits = nb = BSD_NBITS(p[2]); - if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION - || nb > ao->bsd_bits || nb < BSD_MIN_BITS) { - newret = CONFNAK; - if (!dont_nak) { - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits); - /* fall through to test this #bits below */ - } else - break; - } - - /* - * Check whether we can do BSD-Compress with the code - * size they want. If the code size is too big, reduce - * it until the kernel can cope and nak with that. - * We only check this for the first option. - */ - if (p == p0) { - for (;;) { - res = ccp_test(pcb, p, CILEN_BSD_COMPRESS, 1); - if (res > 0) - break; - if (res < 0 || nb == BSD_MIN_BITS || dont_nak) { - newret = CONFREJ; - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, - ho->bsd_bits); - break; - } - newret = CONFNAK; - --nb; - p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb); - } - } - break; + case CI_BSD_COMPRESS: + if (!ao->bsd_compress || clen != CILEN_BSD_COMPRESS) { + newret = CONFREJ; + break; + } + + ho->bsd_compress = 1; + ho->bsd_bits = nb = BSD_NBITS(p[2]); + if (BSD_VERSION(p[2]) != BSD_CURRENT_VERSION + || nb > ao->bsd_bits || nb < BSD_MIN_BITS) { + newret = CONFNAK; + if (!dont_nak) { + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, ao->bsd_bits); + /* fall through to test this #bits below */ + } else + break; + } + + /* + * Check whether we can do BSD-Compress with the code + * size they want. If the code size is too big, reduce + * it until the kernel can cope and nak with that. + * We only check this for the first option. + */ + if (p == p0) { + for (;;) { + res = ccp_test(pcb, p, CILEN_BSD_COMPRESS, 1); + if (res > 0) + break; + if (res < 0 || nb == BSD_MIN_BITS || dont_nak) { + newret = CONFREJ; + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, + ho->bsd_bits); + break; + } + newret = CONFNAK; + --nb; + p[2] = BSD_MAKE_OPT(BSD_CURRENT_VERSION, nb); + } + } + break; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - case CI_PREDICTOR_1: - if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) { - newret = CONFREJ; - break; - } - - ho->predictor_1 = 1; - if (p == p0 - && ccp_test(pcb, p, CILEN_PREDICTOR_1, 1) <= 0) { - newret = CONFREJ; - } - break; - - case CI_PREDICTOR_2: - if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) { - newret = CONFREJ; - break; - } - - ho->predictor_2 = 1; - if (p == p0 - && ccp_test(pcb, p, CILEN_PREDICTOR_2, 1) <= 0) { - newret = CONFREJ; - } - break; + case CI_PREDICTOR_1: + if (!ao->predictor_1 || clen != CILEN_PREDICTOR_1) { + newret = CONFREJ; + break; + } + + ho->predictor_1 = 1; + if (p == p0 + && ccp_test(pcb, p, CILEN_PREDICTOR_1, 1) <= 0) { + newret = CONFREJ; + } + break; + + case CI_PREDICTOR_2: + if (!ao->predictor_2 || clen != CILEN_PREDICTOR_2) { + newret = CONFREJ; + break; + } + + ho->predictor_2 = 1; + if (p == p0 + && ccp_test(pcb, p, CILEN_PREDICTOR_2, 1) <= 0) { + newret = CONFREJ; + } + break; #endif /* PREDICTOR_SUPPORT */ - default: - newret = CONFREJ; - } - } + default: + newret = CONFREJ; + } + } - if (newret == CONFNAK && dont_nak) - newret = CONFREJ; - if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) { - /* we're returning this option */ - if (newret == CONFREJ && ret == CONFNAK) - retp = p0; - ret = newret; - if (p != retp) - MEMCPY(retp, p, clen); - retp += clen; - } + if (newret == CONFNAK && dont_nak) + newret = CONFREJ; + if (!(newret == CONFACK || (newret == CONFNAK && ret == CONFREJ))) { + /* we're returning this option */ + if (newret == CONFREJ && ret == CONFNAK) + retp = p0; + ret = newret; + if (p != retp) + MEMCPY(retp, p, clen); + retp += clen; + } - p += clen; - len -= clen; + p += clen; + len -= clen; } if (ret != CONFACK) { - if (ret == CONFREJ && *lenp == retp - p0) - pcb->ccp_all_rejected = 1; - else - *lenp = retp - p0; + if (ret == CONFREJ && *lenp == retp - p0) + pcb->ccp_all_rejected = 1; + else + *lenp = retp - p0; } #if MPPE_SUPPORT if (ret == CONFREJ && ao->mppe && rej_for_ci_mppe) { - ppp_error("MPPE required but peer negotiation failed"); - lcp_close(pcb, "MPPE required but peer negotiation failed"); + ppp_error("MPPE required but peer negotiation failed"); + lcp_close(pcb, "MPPE required but peer negotiation failed"); } #endif /* MPPE_SUPPORT */ return ret; @@ -1392,63 +1392,63 @@ static const char *method_name(ccp_options *opt, ccp_options *opt2) { #endif /* !DEFLATE_SUPPORT && !BSDCOMPRESS_SUPPORT */ if (!ccp_anycompress(opt)) - return "(none)"; + return "(none)"; switch (opt->method) { #if MPPE_SUPPORT case CI_MPPE: { - char *p = result; - char *q = result + sizeof(result); /* 1 past result */ - - ppp_slprintf(p, q - p, "MPPE "); - p += 5; - if (opt->mppe & MPPE_OPT_128) { - ppp_slprintf(p, q - p, "128-bit "); - p += 8; - } - if (opt->mppe & MPPE_OPT_40) { - ppp_slprintf(p, q - p, "40-bit "); - p += 7; - } - if (opt->mppe & MPPE_OPT_STATEFUL) - ppp_slprintf(p, q - p, "stateful"); - else - ppp_slprintf(p, q - p, "stateless"); - - break; + char *p = result; + char *q = result + sizeof(result); /* 1 past result */ + + ppp_slprintf(p, q - p, "MPPE "); + p += 5; + if (opt->mppe & MPPE_OPT_128) { + ppp_slprintf(p, q - p, "128-bit "); + p += 8; + } + if (opt->mppe & MPPE_OPT_40) { + ppp_slprintf(p, q - p, "40-bit "); + p += 7; + } + if (opt->mppe & MPPE_OPT_STATEFUL) + ppp_slprintf(p, q - p, "stateful"); + else + ppp_slprintf(p, q - p, "stateless"); + + break; } #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT case CI_DEFLATE: case CI_DEFLATE_DRAFT: - if (opt2 != NULL && opt2->deflate_size != opt->deflate_size) - ppp_slprintf(result, sizeof(result), "Deflate%s (%d/%d)", - (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), - opt->deflate_size, opt2->deflate_size); - else - ppp_slprintf(result, sizeof(result), "Deflate%s (%d)", - (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), - opt->deflate_size); - break; + if (opt2 != NULL && opt2->deflate_size != opt->deflate_size) + ppp_slprintf(result, sizeof(result), "Deflate%s (%d/%d)", + (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), + opt->deflate_size, opt2->deflate_size); + else + ppp_slprintf(result, sizeof(result), "Deflate%s (%d)", + (opt->method == CI_DEFLATE_DRAFT? "(old#)": ""), + opt->deflate_size); + break; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT case CI_BSD_COMPRESS: - if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits) - ppp_slprintf(result, sizeof(result), "BSD-Compress (%d/%d)", - opt->bsd_bits, opt2->bsd_bits); - else - ppp_slprintf(result, sizeof(result), "BSD-Compress (%d)", - opt->bsd_bits); - break; + if (opt2 != NULL && opt2->bsd_bits != opt->bsd_bits) + ppp_slprintf(result, sizeof(result), "BSD-Compress (%d/%d)", + opt->bsd_bits, opt2->bsd_bits); + else + ppp_slprintf(result, sizeof(result), "BSD-Compress (%d)", + opt->bsd_bits); + break; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT case CI_PREDICTOR_1: - return "Predictor 1"; + return "Predictor 1"; case CI_PREDICTOR_2: - return "Predictor 2"; + return "Predictor 2"; #endif /* PREDICTOR_SUPPORT */ default: - ppp_slprintf(result, sizeof(result), "Method %d", opt->method); + ppp_slprintf(result, sizeof(result), "Method %d", opt->method); } return result; } @@ -1464,21 +1464,21 @@ static void ccp_up(fsm *f) { ccp_set(pcb, 1, 1, go->method, ho->method); if (ccp_anycompress(go)) { - if (ccp_anycompress(ho)) { - if (go->method == ho->method) { - ppp_notice("%s compression enabled", method_name(go, ho)); - } else { - ppp_strlcpy(method1, method_name(go, NULL), sizeof(method1)); - ppp_notice("%s / %s compression enabled", - method1, method_name(ho, NULL)); - } - } else - ppp_notice("%s receive compression enabled", method_name(go, NULL)); + if (ccp_anycompress(ho)) { + if (go->method == ho->method) { + ppp_notice("%s compression enabled", method_name(go, ho)); + } else { + ppp_strlcpy(method1, method_name(go, NULL), sizeof(method1)); + ppp_notice("%s / %s compression enabled", + method1, method_name(ho, NULL)); + } + } else + ppp_notice("%s receive compression enabled", method_name(go, NULL)); } else if (ccp_anycompress(ho)) - ppp_notice("%s transmit compression enabled", method_name(ho, NULL)); + ppp_notice("%s transmit compression enabled", method_name(ho, NULL)); #if MPPE_SUPPORT if (go->mppe) { - continue_networks(pcb); /* Bring up IP et al */ + continue_networks(pcb); /* Bring up IP et al */ } #endif /* MPPE_SUPPORT */ } @@ -1493,17 +1493,17 @@ static void ccp_down(fsm *f) { #endif /* MPPE_SUPPORT */ if (pcb->ccp_localstate & RACK_PENDING) - UNTIMEOUT(ccp_rack_timeout, f); + UNTIMEOUT(ccp_rack_timeout, f); pcb->ccp_localstate = 0; ccp_set(pcb, 1, 0, 0, 0); #if MPPE_SUPPORT if (go->mppe) { - go->mppe = 0; - if (pcb->lcp_fsm.state == PPP_FSM_OPENED) { - /* If LCP is not already going down, make sure it does. */ - ppp_error("MPPE disabled"); - lcp_close(pcb, "MPPE disabled"); - } + go->mppe = 0; + if (pcb->lcp_fsm.state == PPP_FSM_OPENED) { + /* If LCP is not already going down, make sure it does. */ + ppp_error("MPPE disabled"); + lcp_close(pcb, "MPPE disabled"); + } } #endif /* MPPE_SUPPORT */ } @@ -1526,17 +1526,17 @@ static int ccp_printpkt(const u_char *p, int plen, void (*printer) (void *, cons p0 = p; if (plen < HEADERLEN) - return 0; + return 0; code = p[0]; id = p[1]; len = (p[2] << 8) + p[3]; if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(ccp_codenames) && ccp_codenames[code-1] != NULL) - printer(arg, " %s", ccp_codenames[code-1]); + printer(arg, " %s", ccp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; p += HEADERLEN; @@ -1546,99 +1546,99 @@ static int ccp_printpkt(const u_char *p, int plen, void (*printer) (void *, cons case CONFACK: case CONFNAK: case CONFREJ: - /* print list of possible compression methods */ - while (len >= 2) { - code = p[0]; - optlen = p[1]; - if (optlen < 2 || optlen > len) - break; - printer(arg, " <"); - len -= optlen; - optend = p + optlen; - switch (code) { + /* print list of possible compression methods */ + while (len >= 2) { + code = p[0]; + optlen = p[1]; + if (optlen < 2 || optlen > len) + break; + printer(arg, " <"); + len -= optlen; + optend = p + optlen; + switch (code) { #if MPPE_SUPPORT - case CI_MPPE: - if (optlen >= CILEN_MPPE) { - u_char mppe_opts; - - MPPE_CI_TO_OPTS(&p[2], mppe_opts); - printer(arg, "mppe %s %s %s %s %s %s%s", - (p[2] & MPPE_H_BIT)? "+H": "-H", - (p[5] & MPPE_M_BIT)? "+M": "-M", - (p[5] & MPPE_S_BIT)? "+S": "-S", - (p[5] & MPPE_L_BIT)? "+L": "-L", - (p[5] & MPPE_D_BIT)? "+D": "-D", - (p[5] & MPPE_C_BIT)? "+C": "-C", - (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": ""); - if (mppe_opts & MPPE_OPT_UNKNOWN) - printer(arg, " (%.2x %.2x %.2x %.2x)", - p[2], p[3], p[4], p[5]); - p += CILEN_MPPE; - } - break; + case CI_MPPE: + if (optlen >= CILEN_MPPE) { + u_char mppe_opts; + + MPPE_CI_TO_OPTS(&p[2], mppe_opts); + printer(arg, "mppe %s %s %s %s %s %s%s", + (p[2] & MPPE_H_BIT)? "+H": "-H", + (p[5] & MPPE_M_BIT)? "+M": "-M", + (p[5] & MPPE_S_BIT)? "+S": "-S", + (p[5] & MPPE_L_BIT)? "+L": "-L", + (p[5] & MPPE_D_BIT)? "+D": "-D", + (p[5] & MPPE_C_BIT)? "+C": "-C", + (mppe_opts & MPPE_OPT_UNKNOWN)? " +U": ""); + if (mppe_opts & MPPE_OPT_UNKNOWN) + printer(arg, " (%.2x %.2x %.2x %.2x)", + p[2], p[3], p[4], p[5]); + p += CILEN_MPPE; + } + break; #endif /* MPPE_SUPPORT */ #if DEFLATE_SUPPORT - case CI_DEFLATE: - case CI_DEFLATE_DRAFT: - if (optlen >= CILEN_DEFLATE) { - printer(arg, "deflate%s %d", - (code == CI_DEFLATE_DRAFT? "(old#)": ""), - DEFLATE_SIZE(p[2])); - if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL) - printer(arg, " method %d", DEFLATE_METHOD(p[2])); - if (p[3] != DEFLATE_CHK_SEQUENCE) - printer(arg, " check %d", p[3]); - p += CILEN_DEFLATE; - } - break; + case CI_DEFLATE: + case CI_DEFLATE_DRAFT: + if (optlen >= CILEN_DEFLATE) { + printer(arg, "deflate%s %d", + (code == CI_DEFLATE_DRAFT? "(old#)": ""), + DEFLATE_SIZE(p[2])); + if (DEFLATE_METHOD(p[2]) != DEFLATE_METHOD_VAL) + printer(arg, " method %d", DEFLATE_METHOD(p[2])); + if (p[3] != DEFLATE_CHK_SEQUENCE) + printer(arg, " check %d", p[3]); + p += CILEN_DEFLATE; + } + break; #endif /* DEFLATE_SUPPORT */ #if BSDCOMPRESS_SUPPORT - case CI_BSD_COMPRESS: - if (optlen >= CILEN_BSD_COMPRESS) { - printer(arg, "bsd v%d %d", BSD_VERSION(p[2]), - BSD_NBITS(p[2])); - p += CILEN_BSD_COMPRESS; - } - break; + case CI_BSD_COMPRESS: + if (optlen >= CILEN_BSD_COMPRESS) { + printer(arg, "bsd v%d %d", BSD_VERSION(p[2]), + BSD_NBITS(p[2])); + p += CILEN_BSD_COMPRESS; + } + break; #endif /* BSDCOMPRESS_SUPPORT */ #if PREDICTOR_SUPPORT - case CI_PREDICTOR_1: - if (optlen >= CILEN_PREDICTOR_1) { - printer(arg, "predictor 1"); - p += CILEN_PREDICTOR_1; - } - break; - case CI_PREDICTOR_2: - if (optlen >= CILEN_PREDICTOR_2) { - printer(arg, "predictor 2"); - p += CILEN_PREDICTOR_2; - } - break; + case CI_PREDICTOR_1: + if (optlen >= CILEN_PREDICTOR_1) { + printer(arg, "predictor 1"); + p += CILEN_PREDICTOR_1; + } + break; + case CI_PREDICTOR_2: + if (optlen >= CILEN_PREDICTOR_2) { + printer(arg, "predictor 2"); + p += CILEN_PREDICTOR_2; + } + break; #endif /* PREDICTOR_SUPPORT */ - default: + default: break; - } - while (p < optend) - printer(arg, " %.2x", *p++); - printer(arg, ">"); - } - break; + } + while (p < optend) + printer(arg, " %.2x", *p++); + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: break; } /* dump out the rest of the packet in hex */ while (--len >= 0) - printer(arg, " %.2x", *p++); + printer(arg, " %.2x", *p++); return p - p0; } @@ -1667,34 +1667,34 @@ static void ccp_datainput(ppp_pcb *pcb, u_char *pkt, int len) { f = &pcb->ccp_fsm; if (f->state == PPP_FSM_OPENED) { - if (ccp_fatal_error(pcb)) { - /* - * Disable compression by taking CCP down. - */ - ppp_error("Lost compression sync: disabling compression"); - ccp_close(pcb, "Lost compression sync"); + if (ccp_fatal_error(pcb)) { + /* + * Disable compression by taking CCP down. + */ + ppp_error("Lost compression sync: disabling compression"); + ccp_close(pcb, "Lost compression sync"); #if MPPE_SUPPORT - /* - * If we were doing MPPE, we must also take the link down. - */ - if (go->mppe) { - ppp_error("Too many MPPE errors, closing LCP"); - lcp_close(pcb, "Too many MPPE errors"); - } + /* + * If we were doing MPPE, we must also take the link down. + */ + if (go->mppe) { + ppp_error("Too many MPPE errors, closing LCP"); + lcp_close(pcb, "Too many MPPE errors"); + } #endif /* MPPE_SUPPORT */ - } else { - /* - * Send a reset-request to reset the peer's compressor. - * We don't do that if we are still waiting for an - * acknowledgement to a previous reset-request. - */ - if (!(pcb->ccp_localstate & RACK_PENDING)) { - fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); - TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); - pcb->ccp_localstate |= RACK_PENDING; - } else - pcb->ccp_localstate |= RREQ_REPEAT; - } + } else { + /* + * Send a reset-request to reset the peer's compressor. + * We don't do that if we are still waiting for an + * acknowledgement to a previous reset-request. + */ + if (!(pcb->ccp_localstate & RACK_PENDING)) { + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate |= RACK_PENDING; + } else + pcb->ccp_localstate |= RREQ_REPEAT; + } } } #endif /* PPP_DATAINPUT */ @@ -1707,7 +1707,7 @@ void ccp_resetrequest(ppp_pcb *pcb) { fsm *f = &pcb->ccp_fsm; if (f->state != PPP_FSM_OPENED) - return; + return; /* * Send a reset-request to reset the peer's compressor. @@ -1715,11 +1715,11 @@ void ccp_resetrequest(ppp_pcb *pcb) { * acknowledgement to a previous reset-request. */ if (!(pcb->ccp_localstate & RACK_PENDING)) { - fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); - TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); - pcb->ccp_localstate |= RACK_PENDING; + fsm_sdata(f, CCP_RESETREQ, f->reqid = ++f->id, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate |= RACK_PENDING; } else - pcb->ccp_localstate |= RREQ_REPEAT; + pcb->ccp_localstate |= RREQ_REPEAT; } /* @@ -1730,11 +1730,11 @@ static void ccp_rack_timeout(void *arg) { ppp_pcb *pcb = f->pcb; if (f->state == PPP_FSM_OPENED && (pcb->ccp_localstate & RREQ_REPEAT)) { - fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0); - TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); - pcb->ccp_localstate &= ~RREQ_REPEAT; + fsm_sdata(f, CCP_RESETREQ, f->reqid, NULL, 0); + TIMEOUT(ccp_rack_timeout, f, RACKTIMEOUT); + pcb->ccp_localstate &= ~RREQ_REPEAT; } else - pcb->ccp_localstate &= ~RACK_PENDING; + pcb->ccp_localstate &= ~RACK_PENDING; } #endif /* PPP_SUPPORT && CCP_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/chap-md5.c b/components/net/lwip-2.1.2/src/netif/ppp/chap-md5.c index 88f069f032..2b7c9b36a8 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/chap-md5.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/chap-md5.c @@ -43,84 +43,84 @@ #include "netif/ppp/magic.h" #include "netif/ppp/pppcrypt.h" -#define MD5_HASH_SIZE 16 -#define MD5_MIN_CHALLENGE 17 -#define MD5_MAX_CHALLENGE 24 +#define MD5_HASH_SIZE 16 +#define MD5_MIN_CHALLENGE 17 +#define MD5_MAX_CHALLENGE 24 #define MD5_MIN_MAX_POWER_OF_TWO_CHALLENGE 3 /* 2^3-1 = 7, 17+7 = 24 */ #if PPP_SERVER static void chap_md5_generate_challenge(ppp_pcb *pcb, unsigned char *cp) { - int clen; - LWIP_UNUSED_ARG(pcb); + int clen; + LWIP_UNUSED_ARG(pcb); - clen = MD5_MIN_CHALLENGE + magic_pow(MD5_MIN_MAX_POWER_OF_TWO_CHALLENGE); - *cp++ = clen; - magic_random_bytes(cp, clen); + clen = MD5_MIN_CHALLENGE + magic_pow(MD5_MIN_MAX_POWER_OF_TWO_CHALLENGE); + *cp++ = clen; + magic_random_bytes(cp, clen); } static int chap_md5_verify_response(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) { - lwip_md5_context ctx; - unsigned char idbyte = id; - unsigned char hash[MD5_HASH_SIZE]; - int challenge_len, response_len; - LWIP_UNUSED_ARG(name); - LWIP_UNUSED_ARG(pcb); + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) { + lwip_md5_context ctx; + unsigned char idbyte = id; + unsigned char hash[MD5_HASH_SIZE]; + int challenge_len, response_len; + LWIP_UNUSED_ARG(name); + LWIP_UNUSED_ARG(pcb); - challenge_len = *challenge++; - response_len = *response++; - if (response_len == MD5_HASH_SIZE) { - /* Generate hash of ID, secret, challenge */ - lwip_md5_init(&ctx); - lwip_md5_starts(&ctx); - lwip_md5_update(&ctx, &idbyte, 1); - lwip_md5_update(&ctx, secret, secret_len); - lwip_md5_update(&ctx, challenge, challenge_len); - lwip_md5_finish(&ctx, hash); - lwip_md5_free(&ctx); + challenge_len = *challenge++; + response_len = *response++; + if (response_len == MD5_HASH_SIZE) { + /* Generate hash of ID, secret, challenge */ + lwip_md5_init(&ctx); + lwip_md5_starts(&ctx); + lwip_md5_update(&ctx, &idbyte, 1); + lwip_md5_update(&ctx, secret, secret_len); + lwip_md5_update(&ctx, challenge, challenge_len); + lwip_md5_finish(&ctx, hash); + lwip_md5_free(&ctx); - /* Test if our hash matches the peer's response */ - if (memcmp(hash, response, MD5_HASH_SIZE) == 0) { - ppp_slprintf(message, message_space, "Access granted"); - return 1; - } - } - ppp_slprintf(message, message_space, "Access denied"); - return 0; + /* Test if our hash matches the peer's response */ + if (memcmp(hash, response, MD5_HASH_SIZE) == 0) { + ppp_slprintf(message, message_space, "Access granted"); + return 1; + } + } + ppp_slprintf(message, message_space, "Access denied"); + return 0; } #endif /* PPP_SERVER */ static void chap_md5_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *private_) { - lwip_md5_context ctx; - unsigned char idbyte = id; - int challenge_len = *challenge++; - LWIP_UNUSED_ARG(our_name); - LWIP_UNUSED_ARG(private_); - LWIP_UNUSED_ARG(pcb); + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *private_) { + lwip_md5_context ctx; + unsigned char idbyte = id; + int challenge_len = *challenge++; + LWIP_UNUSED_ARG(our_name); + LWIP_UNUSED_ARG(private_); + LWIP_UNUSED_ARG(pcb); - lwip_md5_init(&ctx); - lwip_md5_starts(&ctx); - lwip_md5_update(&ctx, &idbyte, 1); - lwip_md5_update(&ctx, (const u_char *)secret, secret_len); - lwip_md5_update(&ctx, challenge, challenge_len); - lwip_md5_finish(&ctx, &response[1]); - lwip_md5_free(&ctx); - response[0] = MD5_HASH_SIZE; + lwip_md5_init(&ctx); + lwip_md5_starts(&ctx); + lwip_md5_update(&ctx, &idbyte, 1); + lwip_md5_update(&ctx, (const u_char *)secret, secret_len); + lwip_md5_update(&ctx, challenge, challenge_len); + lwip_md5_finish(&ctx, &response[1]); + lwip_md5_free(&ctx); + response[0] = MD5_HASH_SIZE; } const struct chap_digest_type md5_digest = { - CHAP_MD5, /* code */ + CHAP_MD5, /* code */ #if PPP_SERVER - chap_md5_generate_challenge, - chap_md5_verify_response, + chap_md5_generate_challenge, + chap_md5_verify_response, #endif /* PPP_SERVER */ - chap_md5_make_response, - NULL, /* check_success */ - NULL, /* handle_failure */ + chap_md5_make_response, + NULL, /* check_success */ + NULL, /* handle_failure */ }; #endif /* PPP_SUPPORT && CHAP_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/chap-new.c b/components/net/lwip-2.1.2/src/netif/ppp/chap-new.c index 485122d272..e599f3eb76 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/chap-new.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/chap-new.c @@ -52,9 +52,9 @@ #if 0 /* UNUSED */ /* Hook for a plugin to validate CHAP challenge */ int (*chap_verify_hook)(const char *name, const char *ourname, int id, - const struct chap_digest_type *digest, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) = NULL; + const struct chap_digest_type *digest, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) = NULL; #endif /* UNUSED */ #if PPP_OPTIONS @@ -62,24 +62,24 @@ int (*chap_verify_hook)(const char *name, const char *ourname, int id, * 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, &pcb->settings.chap_max_transmits, - "Set max #xmits for challenge", OPT_PRIO }, - { "chap-interval", o_int, &pcb->settings.chap_rechallenge_time, - "Set interval for rechallenge", OPT_PRIO }, - { NULL } + { "chap-restart", o_int, &chap_timeout_time, + "Set timeout for CHAP", OPT_PRIO }, + { "chap-max-challenge", o_int, &pcb->settings.chap_max_transmits, + "Set max #xmits for challenge", OPT_PRIO }, + { "chap-interval", o_int, &pcb->settings.chap_rechallenge_time, + "Set interval for rechallenge", OPT_PRIO }, + { NULL } }; #endif /* PPP_OPTIONS */ /* 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 +#define LOWERUP 1 +#define AUTH_STARTED 2 +#define AUTH_DONE 4 +#define AUTH_FAILED 8 +#define TIMEOUT_PENDING 0x10 +#define CHALLENGE_VALID 0x20 /* * Prototypes. @@ -91,21 +91,21 @@ static void chap_lowerdown(ppp_pcb *pcb); static void chap_timeout(void *arg); static void chap_generate_challenge(ppp_pcb *pcb); static void chap_handle_response(ppp_pcb *pcb, int code, - unsigned char *pkt, int len); + unsigned char *pkt, int len); static int chap_verify_response(ppp_pcb *pcb, const char *name, const char *ourname, int id, - const struct chap_digest_type *digest, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space); + const struct chap_digest_type *digest, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space); #endif /* PPP_SERVER */ static void chap_respond(ppp_pcb *pcb, int id, - unsigned char *pkt, int len); + unsigned char *pkt, int len); static void chap_handle_status(ppp_pcb *pcb, int code, int id, - unsigned char *pkt, int len); + unsigned char *pkt, int len); static void chap_protrej(ppp_pcb *pcb); static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen); #if PRINTPKT_SUPPORT static int chap_print_pkt(const unsigned char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ /* List of digest types that we know about */ @@ -122,12 +122,12 @@ static const struct chap_digest_type* const chap_digests[] = { * chap_init - reset to initial state. */ static void chap_init(ppp_pcb *pcb) { - LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(pcb); #if 0 /* Not necessary, everything is cleared in ppp_new() */ - memset(&pcb->chap_client, 0, sizeof(chap_client_state)); + memset(&pcb->chap_client, 0, sizeof(chap_client_state)); #if PPP_SERVER - memset(&pcb->chap_server, 0, sizeof(chap_server_state)); + memset(&pcb->chap_server, 0, sizeof(chap_server_state)); #endif /* PPP_SERVER */ #endif /* 0 */ } @@ -137,21 +137,21 @@ static void chap_init(ppp_pcb *pcb) { */ static void chap_lowerup(ppp_pcb *pcb) { - pcb->chap_client.flags |= LOWERUP; + pcb->chap_client.flags |= LOWERUP; #if PPP_SERVER - pcb->chap_server.flags |= LOWERUP; - if (pcb->chap_server.flags & AUTH_STARTED) - chap_timeout(pcb); + pcb->chap_server.flags |= LOWERUP; + if (pcb->chap_server.flags & AUTH_STARTED) + chap_timeout(pcb); #endif /* PPP_SERVER */ } static void chap_lowerdown(ppp_pcb *pcb) { - pcb->chap_client.flags = 0; + pcb->chap_client.flags = 0; #if PPP_SERVER - if (pcb->chap_server.flags & TIMEOUT_PENDING) - UNTIMEOUT(chap_timeout, pcb); - pcb->chap_server.flags = 0; + if (pcb->chap_server.flags & TIMEOUT_PENDING) + UNTIMEOUT(chap_timeout, pcb); + pcb->chap_server.flags = 0; #endif /* PPP_SERVER */ } @@ -162,27 +162,27 @@ static void chap_lowerdown(ppp_pcb *pcb) { * otherwise we wait for the lower layer to come up. */ void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { - const struct chap_digest_type *dp; - int i; - - if (pcb->chap_server.flags & AUTH_STARTED) { - ppp_error("CHAP: peer authentication already started!"); - return; - } - for (i = 0; (dp = chap_digests[i]) != NULL; ++i) - if (dp->code == digest_code) - break; - if (dp == NULL) - ppp_fatal("CHAP digest 0x%x requested but not available", - digest_code); - - pcb->chap_server.digest = dp; - pcb->chap_server.name = our_name; - /* Start with a random ID value */ - pcb->chap_server.id = magic(); - pcb->chap_server.flags |= AUTH_STARTED; - if (pcb->chap_server.flags & LOWERUP) - chap_timeout(pcb); + const struct chap_digest_type *dp; + int i; + + if (pcb->chap_server.flags & AUTH_STARTED) { + ppp_error("CHAP: peer authentication already started!"); + return; + } + for (i = 0; (dp = chap_digests[i]) != NULL; ++i) + if (dp->code == digest_code) + break; + if (dp == NULL) + ppp_fatal("CHAP digest 0x%x requested but not available", + digest_code); + + pcb->chap_server.digest = dp; + pcb->chap_server.name = our_name; + /* Start with a random ID value */ + pcb->chap_server.id = magic(); + pcb->chap_server.flags |= AUTH_STARTED; + if (pcb->chap_server.flags & LOWERUP) + chap_timeout(pcb); } #endif /* PPP_SERVER */ @@ -191,27 +191,27 @@ void chap_auth_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { * There isn't much to do until we receive a challenge. */ void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { - const struct chap_digest_type *dp; - int i; - - if(NULL == our_name) - return; - - if (pcb->chap_client.flags & AUTH_STARTED) { - ppp_error("CHAP: authentication with peer already started!"); - return; - } - for (i = 0; (dp = chap_digests[i]) != NULL; ++i) - if (dp->code == digest_code) - break; - - if (dp == NULL) - ppp_fatal("CHAP digest 0x%x requested but not available", - digest_code); - - pcb->chap_client.digest = dp; - pcb->chap_client.name = our_name; - pcb->chap_client.flags |= AUTH_STARTED; + const struct chap_digest_type *dp; + int i; + + if(NULL == our_name) + return; + + if (pcb->chap_client.flags & AUTH_STARTED) { + ppp_error("CHAP: authentication with peer already started!"); + return; + } + for (i = 0; (dp = chap_digests[i]) != NULL; ++i) + if (dp->code == digest_code) + break; + + if (dp == NULL) + ppp_fatal("CHAP digest 0x%x requested but not available", + digest_code); + + pcb->chap_client.digest = dp; + pcb->chap_client.name = our_name; + pcb->chap_client.flags |= AUTH_STARTED; } #if PPP_SERVER @@ -221,33 +221,33 @@ void chap_auth_with_peer(ppp_pcb *pcb, const char *our_name, int digest_code) { * or a new challenge to start re-authentication. */ static void chap_timeout(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; - struct pbuf *p; - - pcb->chap_server.flags &= ~TIMEOUT_PENDING; - if ((pcb->chap_server.flags & CHALLENGE_VALID) == 0) { - pcb->chap_server.challenge_xmits = 0; - chap_generate_challenge(pcb); - pcb->chap_server.flags |= CHALLENGE_VALID; - } else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) { - pcb->chap_server.flags &= ~CHALLENGE_VALID; - pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED; - auth_peer_fail(pcb, PPP_CHAP); - return; - } - - p = pbuf_alloc(PBUF_RAW, (u16_t)(pcb->chap_server.challenge_pktlen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen); - ppp_write(pcb, p); - ++pcb->chap_server.challenge_xmits; - pcb->chap_server.flags |= TIMEOUT_PENDING; - TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time); + ppp_pcb *pcb = (ppp_pcb*)arg; + struct pbuf *p; + + pcb->chap_server.flags &= ~TIMEOUT_PENDING; + if ((pcb->chap_server.flags & CHALLENGE_VALID) == 0) { + pcb->chap_server.challenge_xmits = 0; + chap_generate_challenge(pcb); + pcb->chap_server.flags |= CHALLENGE_VALID; + } else if (pcb->chap_server.challenge_xmits >= pcb->settings.chap_max_transmits) { + pcb->chap_server.flags &= ~CHALLENGE_VALID; + pcb->chap_server.flags |= AUTH_DONE | AUTH_FAILED; + auth_peer_fail(pcb, PPP_CHAP); + return; + } + + p = pbuf_alloc(PBUF_RAW, (u16_t)(pcb->chap_server.challenge_pktlen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + MEMCPY(p->payload, pcb->chap_server.challenge, pcb->chap_server.challenge_pktlen); + ppp_write(pcb, p); + ++pcb->chap_server.challenge_xmits; + pcb->chap_server.flags |= TIMEOUT_PENDING; + TIMEOUT(chap_timeout, arg, pcb->settings.chap_timeout_time); } /* @@ -255,152 +255,152 @@ static void chap_timeout(void *arg) { * the challenge packet in pcb->chap_server.challenge_pkt. */ static void chap_generate_challenge(ppp_pcb *pcb) { - int clen = 1, nlen, len; - unsigned char *p; - - p = pcb->chap_server.challenge; - MAKEHEADER(p, PPP_CHAP); - p += CHAP_HDRLEN; - pcb->chap_server.digest->generate_challenge(pcb, p); - clen = *p; - nlen = strlen(pcb->chap_server.name); - memcpy(p + 1 + clen, pcb->chap_server.name, nlen); - - len = CHAP_HDRLEN + 1 + clen + nlen; - pcb->chap_server.challenge_pktlen = PPP_HDRLEN + len; - - p = pcb->chap_server.challenge + PPP_HDRLEN; - p[0] = CHAP_CHALLENGE; - p[1] = ++pcb->chap_server.id; - p[2] = len >> 8; - p[3] = len; + int clen = 1, nlen, len; + unsigned char *p; + + p = pcb->chap_server.challenge; + MAKEHEADER(p, PPP_CHAP); + p += CHAP_HDRLEN; + pcb->chap_server.digest->generate_challenge(pcb, p); + clen = *p; + nlen = strlen(pcb->chap_server.name); + memcpy(p + 1 + clen, pcb->chap_server.name, nlen); + + len = CHAP_HDRLEN + 1 + clen + nlen; + pcb->chap_server.challenge_pktlen = PPP_HDRLEN + len; + + p = pcb->chap_server.challenge + PPP_HDRLEN; + p[0] = CHAP_CHALLENGE; + p[1] = ++pcb->chap_server.id; + p[2] = len >> 8; + p[3] = len; } /* * chap_handle_response - check the response to our challenge. */ static void chap_handle_response(ppp_pcb *pcb, int id, - unsigned char *pkt, int len) { - int response_len, ok, mlen; - const unsigned char *response; - unsigned char *outp; - struct pbuf *p; - const char *name = NULL; /* initialized to shut gcc up */ + unsigned char *pkt, int len) { + int response_len, ok, mlen; + const unsigned char *response; + unsigned char *outp; + struct pbuf *p; + const char *name = NULL; /* initialized to shut gcc up */ #if 0 /* UNUSED */ - int (*verifier)(const char *, const char *, int, const struct chap_digest_type *, - const unsigned char *, const unsigned char *, char *, int); + int (*verifier)(const char *, const char *, int, const struct chap_digest_type *, + const unsigned char *, const unsigned char *, char *, int); #endif /* UNUSED */ - char rname[MAXNAMELEN+1]; - char message[256]; - - if ((pcb->chap_server.flags & LOWERUP) == 0) - return; - if (id != pcb->chap_server.challenge[PPP_HDRLEN+1] || len < 2) - return; - if (pcb->chap_server.flags & CHALLENGE_VALID) { - response = pkt; - GETCHAR(response_len, pkt); - len -= response_len + 1; /* length of name */ - name = (char *)pkt + response_len; - if (len < 0) - return; - - if (pcb->chap_server.flags & TIMEOUT_PENDING) { - pcb->chap_server.flags &= ~TIMEOUT_PENDING; - UNTIMEOUT(chap_timeout, pcb); - } + char rname[MAXNAMELEN+1]; + char message[256]; + + if ((pcb->chap_server.flags & LOWERUP) == 0) + return; + if (id != pcb->chap_server.challenge[PPP_HDRLEN+1] || len < 2) + return; + if (pcb->chap_server.flags & CHALLENGE_VALID) { + response = pkt; + GETCHAR(response_len, pkt); + len -= response_len + 1; /* length of name */ + name = (char *)pkt + response_len; + if (len < 0) + return; + + if (pcb->chap_server.flags & TIMEOUT_PENDING) { + pcb->chap_server.flags &= ~TIMEOUT_PENDING; + UNTIMEOUT(chap_timeout, pcb); + } #if PPP_REMOTENAME - if (pcb->settings.explicit_remote) { - name = pcb->remote_name; - } else + if (pcb->settings.explicit_remote) { + name = pcb->remote_name; + } else #endif /* PPP_REMOTENAME */ - { - /* Null terminate and clean remote name. */ - ppp_slprintf(rname, sizeof(rname), "%.*v", len, name); - name = rname; - } + { + /* Null terminate and clean remote name. */ + ppp_slprintf(rname, sizeof(rname), "%.*v", len, name); + name = rname; + } #if 0 /* UNUSED */ - if (chap_verify_hook) - verifier = chap_verify_hook; - else - verifier = chap_verify_response; - ok = (*verifier)(name, pcb->chap_server.name, id, pcb->chap_server.digest, - pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, - response, pcb->chap_server.message, sizeof(pcb->chap_server.message)); + if (chap_verify_hook) + verifier = chap_verify_hook; + else + verifier = chap_verify_response; + ok = (*verifier)(name, pcb->chap_server.name, id, pcb->chap_server.digest, + pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, + response, pcb->chap_server.message, sizeof(pcb->chap_server.message)); #endif /* UNUSED */ - ok = chap_verify_response(pcb, name, pcb->chap_server.name, id, pcb->chap_server.digest, + ok = chap_verify_response(pcb, name, pcb->chap_server.name, id, pcb->chap_server.digest, pcb->chap_server.challenge + PPP_HDRLEN + CHAP_HDRLEN, response, message, sizeof(message)); #if 0 /* UNUSED */ - if (!ok || !auth_number()) { + if (!ok || !auth_number()) { #endif /* UNUSED */ - if (!ok) { - pcb->chap_server.flags |= AUTH_FAILED; - ppp_warn("Peer %q failed CHAP authentication", name); - } - } else if ((pcb->chap_server.flags & AUTH_DONE) == 0) - return; - - /* send the response */ - mlen = strlen(message); - len = CHAP_HDRLEN + mlen; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +len), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (unsigned char *)p->payload; - MAKEHEADER(outp, PPP_CHAP); - - outp[0] = (pcb->chap_server.flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS; - outp[1] = id; - outp[2] = len >> 8; - outp[3] = len; - if (mlen > 0) - memcpy(outp + CHAP_HDRLEN, message, mlen); - ppp_write(pcb, p); - - if (pcb->chap_server.flags & CHALLENGE_VALID) { - pcb->chap_server.flags &= ~CHALLENGE_VALID; - if (!(pcb->chap_server.flags & AUTH_DONE) && !(pcb->chap_server.flags & AUTH_FAILED)) { + if (!ok) { + pcb->chap_server.flags |= AUTH_FAILED; + ppp_warn("Peer %q failed CHAP authentication", name); + } + } else if ((pcb->chap_server.flags & AUTH_DONE) == 0) + return; + + /* send the response */ + mlen = strlen(message); + len = CHAP_HDRLEN + mlen; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +len), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (unsigned char *)p->payload; + MAKEHEADER(outp, PPP_CHAP); + + outp[0] = (pcb->chap_server.flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS; + outp[1] = id; + outp[2] = len >> 8; + outp[3] = len; + if (mlen > 0) + memcpy(outp + CHAP_HDRLEN, message, mlen); + ppp_write(pcb, p); + + if (pcb->chap_server.flags & CHALLENGE_VALID) { + pcb->chap_server.flags &= ~CHALLENGE_VALID; + if (!(pcb->chap_server.flags & AUTH_DONE) && !(pcb->chap_server.flags & AUTH_FAILED)) { #if 0 /* UNUSED */ - /* - * Auth is OK, so now we need to check session restrictions - * to ensure everything is OK, but only if we used a - * plugin, and only if we're configured to check. This - * allows us to do PAM checks on PPP servers that - * authenticate against ActiveDirectory, and use AD for - * account info (like when using Winbind integrated with - * PAM). - */ - if (session_mgmt && - session_check(name, NULL, devnam, NULL) == 0) { - pcb->chap_server.flags |= AUTH_FAILED; - ppp_warn("Peer %q failed CHAP Session verification", name); - } + /* + * Auth is OK, so now we need to check session restrictions + * to ensure everything is OK, but only if we used a + * plugin, and only if we're configured to check. This + * allows us to do PAM checks on PPP servers that + * authenticate against ActiveDirectory, and use AD for + * account info (like when using Winbind integrated with + * PAM). + */ + if (session_mgmt && + session_check(name, NULL, devnam, NULL) == 0) { + pcb->chap_server.flags |= AUTH_FAILED; + ppp_warn("Peer %q failed CHAP Session verification", name); + } #endif /* UNUSED */ - } - if (pcb->chap_server.flags & AUTH_FAILED) { - auth_peer_fail(pcb, PPP_CHAP); - } else { - if ((pcb->chap_server.flags & AUTH_DONE) == 0) - auth_peer_success(pcb, PPP_CHAP, - pcb->chap_server.digest->code, - name, strlen(name)); - if (pcb->settings.chap_rechallenge_time) { - pcb->chap_server.flags |= TIMEOUT_PENDING; - TIMEOUT(chap_timeout, pcb, - pcb->settings.chap_rechallenge_time); - } - } - pcb->chap_server.flags |= AUTH_DONE; - } + } + if (pcb->chap_server.flags & AUTH_FAILED) { + auth_peer_fail(pcb, PPP_CHAP); + } else { + if ((pcb->chap_server.flags & AUTH_DONE) == 0) + auth_peer_success(pcb, PPP_CHAP, + pcb->chap_server.digest->code, + name, strlen(name)); + if (pcb->settings.chap_rechallenge_time) { + pcb->chap_server.flags |= TIMEOUT_PENDING; + TIMEOUT(chap_timeout, pcb, + pcb->settings.chap_rechallenge_time); + } + } + pcb->chap_server.flags |= AUTH_DONE; + } } /* @@ -409,23 +409,23 @@ static void chap_handle_response(ppp_pcb *pcb, int id, * succeeded), or 0 if it doesn't. */ static int chap_verify_response(ppp_pcb *pcb, const char *name, const char *ourname, int id, - const struct chap_digest_type *digest, - const unsigned char *challenge, const 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(pcb, name, ourname, (char *)secret, &secret_len, 1)) { - ppp_error("No CHAP secret found for authenticating %q", name); - return 0; - } - ok = digest->verify_response(pcb, id, name, secret, secret_len, challenge, - response, message, message_space); - memset(secret, 0, sizeof(secret)); - - return ok; + const struct chap_digest_type *digest, + const unsigned char *challenge, const 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(pcb, name, ourname, (char *)secret, &secret_len, 1)) { + ppp_error("No CHAP secret found for authenticating %q", name); + return 0; + } + ok = digest->verify_response(pcb, id, name, secret, secret_len, challenge, + response, message, message_space); + memset(secret, 0, sizeof(secret)); + + return ok; } #endif /* PPP_SERVER */ @@ -433,153 +433,153 @@ static int chap_verify_response(ppp_pcb *pcb, const char *name, const char *ourn * chap_respond - Generate and send a response to a challenge. */ static void chap_respond(ppp_pcb *pcb, int id, - unsigned char *pkt, int len) { - int clen, nlen; - int secret_len; - struct pbuf *p; - u_char *outp; - char rname[MAXNAMELEN+1]; - char secret[MAXSECRETLEN+1]; - - p = pbuf_alloc(PBUF_RAW, (u16_t)(RESP_MAX_PKTLEN), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - if ((pcb->chap_client.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. */ - ppp_slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1); + unsigned char *pkt, int len) { + int clen, nlen; + int secret_len; + struct pbuf *p; + u_char *outp; + char rname[MAXNAMELEN+1]; + char secret[MAXSECRETLEN+1]; + + p = pbuf_alloc(PBUF_RAW, (u16_t)(RESP_MAX_PKTLEN), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + if ((pcb->chap_client.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. */ + ppp_slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1); #if PPP_REMOTENAME - /* Microsoft doesn't send their name back in the PPP packet */ - if (pcb->settings.explicit_remote || (pcb->settings.remote_name[0] != 0 && rname[0] == 0)) - strlcpy(rname, pcb->settings.remote_name, sizeof(rname)); + /* Microsoft doesn't send their name back in the PPP packet */ + if (pcb->settings.explicit_remote || (pcb->settings.remote_name[0] != 0 && rname[0] == 0)) + strlcpy(rname, pcb->settings.remote_name, sizeof(rname)); #endif /* PPP_REMOTENAME */ - /* get secret for authenticating ourselves with the specified host */ - if (!get_secret(pcb, pcb->chap_client.name, rname, secret, &secret_len, 0)) { - secret_len = 0; /* assume null secret if can't find one */ - ppp_warn("No CHAP secret found for authenticating us to %q", rname); - } - - outp = (u_char*)p->payload; - MAKEHEADER(outp, PPP_CHAP); - outp += CHAP_HDRLEN; - - pcb->chap_client.digest->make_response(pcb, outp, id, pcb->chap_client.name, pkt, - secret, secret_len, pcb->chap_client.priv); - memset(secret, 0, secret_len); - - clen = *outp; - nlen = strlen(pcb->chap_client.name); - memcpy(outp + clen + 1, pcb->chap_client.name, nlen); - - outp = (u_char*)p->payload + PPP_HDRLEN; - len = CHAP_HDRLEN + clen + 1 + nlen; - outp[0] = CHAP_RESPONSE; - outp[1] = id; - outp[2] = len >> 8; - outp[3] = len; - - pbuf_realloc(p, PPP_HDRLEN + len); - ppp_write(pcb, p); + /* get secret for authenticating ourselves with the specified host */ + if (!get_secret(pcb, pcb->chap_client.name, rname, secret, &secret_len, 0)) { + secret_len = 0; /* assume null secret if can't find one */ + ppp_warn("No CHAP secret found for authenticating us to %q", rname); + } + + outp = (u_char*)p->payload; + MAKEHEADER(outp, PPP_CHAP); + outp += CHAP_HDRLEN; + + pcb->chap_client.digest->make_response(pcb, outp, id, pcb->chap_client.name, pkt, + secret, secret_len, pcb->chap_client.priv); + memset(secret, 0, secret_len); + + clen = *outp; + nlen = strlen(pcb->chap_client.name); + memcpy(outp + clen + 1, pcb->chap_client.name, nlen); + + outp = (u_char*)p->payload + PPP_HDRLEN; + len = CHAP_HDRLEN + clen + 1 + nlen; + outp[0] = CHAP_RESPONSE; + outp[1] = id; + outp[2] = len >> 8; + outp[3] = len; + + pbuf_realloc(p, PPP_HDRLEN + len); + ppp_write(pcb, p); } static void chap_handle_status(ppp_pcb *pcb, int code, int id, - unsigned char *pkt, int len) { - const char *msg = NULL; - LWIP_UNUSED_ARG(id); - - if ((pcb->chap_client.flags & (AUTH_DONE|AUTH_STARTED|LOWERUP)) - != (AUTH_STARTED|LOWERUP)) - return; - pcb->chap_client.flags |= AUTH_DONE; - - if (code == CHAP_SUCCESS) { - /* used for MS-CHAP v2 mutual auth, yuck */ - if (pcb->chap_client.digest->check_success != NULL) { - if (!(*pcb->chap_client.digest->check_success)(pcb, pkt, len, pcb->chap_client.priv)) - code = CHAP_FAILURE; - } else - msg = "CHAP authentication succeeded"; - } else { - if (pcb->chap_client.digest->handle_failure != NULL) - (*pcb->chap_client.digest->handle_failure)(pcb, pkt, len); - else - msg = "CHAP authentication failed"; - } - if (msg) { - if (len > 0) - ppp_info("%s: %.*v", msg, len, pkt); - else - ppp_info("%s", msg); - } - if (code == CHAP_SUCCESS) - auth_withpeer_success(pcb, PPP_CHAP, pcb->chap_client.digest->code); - else { - pcb->chap_client.flags |= AUTH_FAILED; - ppp_error("CHAP authentication failed"); - auth_withpeer_fail(pcb, PPP_CHAP); - } + unsigned char *pkt, int len) { + const char *msg = NULL; + LWIP_UNUSED_ARG(id); + + if ((pcb->chap_client.flags & (AUTH_DONE|AUTH_STARTED|LOWERUP)) + != (AUTH_STARTED|LOWERUP)) + return; + pcb->chap_client.flags |= AUTH_DONE; + + if (code == CHAP_SUCCESS) { + /* used for MS-CHAP v2 mutual auth, yuck */ + if (pcb->chap_client.digest->check_success != NULL) { + if (!(*pcb->chap_client.digest->check_success)(pcb, pkt, len, pcb->chap_client.priv)) + code = CHAP_FAILURE; + } else + msg = "CHAP authentication succeeded"; + } else { + if (pcb->chap_client.digest->handle_failure != NULL) + (*pcb->chap_client.digest->handle_failure)(pcb, pkt, len); + else + msg = "CHAP authentication failed"; + } + if (msg) { + if (len > 0) + ppp_info("%s: %.*v", msg, len, pkt); + else + ppp_info("%s", msg); + } + if (code == CHAP_SUCCESS) + auth_withpeer_success(pcb, PPP_CHAP, pcb->chap_client.digest->code); + else { + pcb->chap_client.flags |= AUTH_FAILED; + ppp_error("CHAP authentication failed"); + auth_withpeer_fail(pcb, PPP_CHAP); + } } static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen) { - 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(pcb, id, pkt, len); - break; + 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(pcb, id, pkt, len); + break; #if PPP_SERVER - case CHAP_RESPONSE: - chap_handle_response(pcb, id, pkt, len); - break; + case CHAP_RESPONSE: + chap_handle_response(pcb, id, pkt, len); + break; #endif /* PPP_SERVER */ - case CHAP_FAILURE: - case CHAP_SUCCESS: - chap_handle_status(pcb, code, id, pkt, len); - break; - default: - break; - } + case CHAP_FAILURE: + case CHAP_SUCCESS: + chap_handle_status(pcb, code, id, pkt, len); + break; + default: + break; + } } static void chap_protrej(ppp_pcb *pcb) { #if PPP_SERVER - if (pcb->chap_server.flags & TIMEOUT_PENDING) { - pcb->chap_server.flags &= ~TIMEOUT_PENDING; - UNTIMEOUT(chap_timeout, pcb); - } - if (pcb->chap_server.flags & AUTH_STARTED) { - pcb->chap_server.flags = 0; - auth_peer_fail(pcb, PPP_CHAP); - } + if (pcb->chap_server.flags & TIMEOUT_PENDING) { + pcb->chap_server.flags &= ~TIMEOUT_PENDING; + UNTIMEOUT(chap_timeout, pcb); + } + if (pcb->chap_server.flags & AUTH_STARTED) { + pcb->chap_server.flags = 0; + auth_peer_fail(pcb, PPP_CHAP); + } #endif /* PPP_SERVER */ - if ((pcb->chap_client.flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) { - pcb->chap_client.flags &= ~AUTH_STARTED; - ppp_error("CHAP authentication failed due to protocol-reject"); - auth_withpeer_fail(pcb, PPP_CHAP); - } + if ((pcb->chap_client.flags & (AUTH_STARTED|AUTH_DONE)) == AUTH_STARTED) { + pcb->chap_client.flags &= ~AUTH_STARTED; + ppp_error("CHAP authentication failed due to protocol-reject"); + auth_withpeer_fail(pcb, PPP_CHAP); + } } #if PRINTPKT_SUPPORT @@ -587,90 +587,90 @@ static void chap_protrej(ppp_pcb *pcb) { * chap_print_pkt - print the contents of a CHAP packet. */ static const char* const chap_code_names[] = { - "Challenge", "Response", "Success", "Failure" + "Challenge", "Response", "Success", "Failure" }; static int chap_print_pkt(const unsigned char *p, int plen, - void (*printer) (void *, const 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 <= (int)LWIP_ARRAYSIZE(chap_code_names)) - 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 = "); - ppp_print_string(p, nlen, printer, arg); - break; - case CHAP_FAILURE: - case CHAP_SUCCESS: - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - break; - default: - for (clen = len; clen > 0; --clen) { - GETCHAR(x, p); - printer(arg, " %.2x", x); - } - /* no break */ - } - - return len + CHAP_HDRLEN; + void (*printer) (void *, const 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 <= (int)LWIP_ARRAYSIZE(chap_code_names)) + 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 = "); + ppp_print_string(p, nlen, printer, arg); + break; + case CHAP_FAILURE: + case CHAP_SUCCESS: + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + break; + default: + for (clen = len; clen > 0; --clen) { + GETCHAR(x, p); + printer(arg, " %.2x", x); + } + /* no break */ + } + + return len + CHAP_HDRLEN; } #endif /* PRINTPKT_SUPPORT */ const struct protent chap_protent = { - PPP_CHAP, - chap_init, - chap_input, - chap_protrej, - chap_lowerup, - chap_lowerdown, - NULL, /* open */ - NULL, /* close */ + PPP_CHAP, + chap_init, + chap_input, + chap_protrej, + chap_lowerup, + chap_lowerdown, + NULL, /* open */ + NULL, /* close */ #if PRINTPKT_SUPPORT - chap_print_pkt, + chap_print_pkt, #endif /* PRINTPKT_SUPPORT */ #if PPP_DATAINPUT - NULL, /* datainput */ + NULL, /* datainput */ #endif /* PPP_DATAINPUT */ #if PRINTPKT_SUPPORT - "CHAP", /* name */ - NULL, /* data_name */ + "CHAP", /* name */ + NULL, /* data_name */ #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS - chap_option_list, - NULL, /* check_options */ + chap_option_list, + NULL, /* check_options */ #endif /* PPP_OPTIONS */ #if DEMAND_SUPPORT - NULL, - NULL + NULL, + NULL #endif /* DEMAND_SUPPORT */ }; diff --git a/components/net/lwip-2.1.2/src/netif/ppp/chap_ms.c b/components/net/lwip-2.1.2/src/netif/ppp/chap_ms.c index 5a989c9b7e..b050aa1cd1 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/chap_ms.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/chap_ms.c @@ -97,41 +97,41 @@ #include "netif/ppp/mppe.h" /* For mppe_sha1_pad*, mppe_set_key() */ #endif /* MPPE_SUPPORT */ -#define SHA1_SIGNATURE_SIZE 20 -#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 SHA1_SIGNATURE_SIZE 20 +#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 */ +#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 */ /* 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 +#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 /* * Offsets within the response field for MS-CHAP */ -#define MS_CHAP_LANMANRESP 0 -#define MS_CHAP_LANMANRESP_LEN 24 -#define MS_CHAP_NTRESP 24 -#define MS_CHAP_NTRESP_LEN 24 -#define MS_CHAP_USENT 48 +#define MS_CHAP_LANMANRESP 0 +#define MS_CHAP_LANMANRESP_LEN 24 +#define MS_CHAP_NTRESP 24 +#define MS_CHAP_NTRESP_LEN 24 +#define MS_CHAP_USENT 48 /* * Offsets within the response field for MS-CHAP2 */ -#define MS_CHAP2_PEER_CHALLENGE 0 -#define MS_CHAP2_PEER_CHAL_LEN 16 -#define MS_CHAP2_RESERVED_LEN 8 -#define MS_CHAP2_NTRESP 24 -#define MS_CHAP2_NTRESP_LEN 24 -#define MS_CHAP2_FLAGS 48 +#define MS_CHAP2_PEER_CHALLENGE 0 +#define MS_CHAP2_PEER_CHAL_LEN 16 +#define MS_CHAP2_RESERVED_LEN 8 +#define MS_CHAP2_NTRESP 24 +#define MS_CHAP2_NTRESP_LEN 24 +#define MS_CHAP2_FLAGS 48 #if MPPE_SUPPORT #if 0 /* UNUSED */ @@ -150,37 +150,37 @@ extern void set_mppe_enc_types(int, int); #define MS_CHAP2_AUTHENTICATEE 0 #define MS_CHAP2_AUTHENTICATOR 1 -static void ascii2unicode (const char[], int, u_char[]); -static void NTPasswordHash (u_char *, int, u_char[MD4_SIGNATURE_SIZE]); -static void ChallengeResponse (const u_char *, const u_char *, u_char[24]); -static void ChallengeHash (const u_char[16], const u_char *, const char *, u_char[8]); -static void ChapMS_NT (const u_char *, const char *, int, u_char[24]); -static void ChapMS2_NT (const u_char *, const u_char[16], const char *, const char *, int, - u_char[24]); -static void GenerateAuthenticatorResponsePlain - (const char*, int, u_char[24], const u_char[16], const u_char *, - const char *, u_char[41]); +static void ascii2unicode (const char[], int, u_char[]); +static void NTPasswordHash (u_char *, int, u_char[MD4_SIGNATURE_SIZE]); +static void ChallengeResponse (const u_char *, const u_char *, u_char[24]); +static void ChallengeHash (const u_char[16], const u_char *, const char *, u_char[8]); +static void ChapMS_NT (const u_char *, const char *, int, u_char[24]); +static void ChapMS2_NT (const u_char *, const u_char[16], const char *, const char *, int, + u_char[24]); +static void GenerateAuthenticatorResponsePlain + (const char*, int, u_char[24], const u_char[16], const u_char *, + const char *, u_char[41]); #ifdef MSLANMAN -static void ChapMS_LANMan (u_char *, char *, int, u_char *); +static void ChapMS_LANMan (u_char *, char *, int, u_char *); #endif static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGNATURE_SIZE], - u_char NTResponse[24], const u_char PeerChallenge[16], - const u_char *rchallenge, const char *username, - u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]); + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, + u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]); #if MPPE_SUPPORT -static void Set_Start_Key (ppp_pcb *pcb, const u_char *, const char *, int); -static void SetMasterKeys (ppp_pcb *pcb, const char *, int, u_char[24], int); +static void Set_Start_Key (ppp_pcb *pcb, const u_char *, const char *, int); +static void SetMasterKeys (ppp_pcb *pcb, const char *, int, u_char[24], int); #endif /* MPPE_SUPPORT */ static void ChapMS (ppp_pcb *pcb, const u_char *, const char *, int, u_char *); static void ChapMS2 (ppp_pcb *pcb, const u_char *, const u_char *, const char *, const char *, int, - u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int); + u_char *, u_char[MS_AUTH_RESPONSE_LENGTH+1], int); #ifdef MSLANMAN -bool ms_lanman = 0; /* Use LanMan password instead of NT */ - /* Has meaning only with MS-CHAP challenges */ +bool ms_lanman = 0; /* Use LanMan password instead of NT */ + /* Has meaning only with MS-CHAP challenges */ #endif #if MPPE_SUPPORT @@ -192,7 +192,7 @@ static char *mschap_challenge = NULL; static char *mschap2_peer_challenge = NULL; #endif -#include "netif/ppp/fsm.h" /* Need to poke MPPE options */ +#include "netif/ppp/fsm.h" /* Need to poke MPPE options */ #include "netif/ppp/ccp.h" #endif /* MPPE_SUPPORT */ @@ -202,16 +202,16 @@ static char *mschap2_peer_challenge = NULL; */ static option_t chapms_option_list[] = { #ifdef MSLANMAN - { "ms-lanman", o_bool, &ms_lanman, - "Use LanMan passwd when using MS-CHAP", 1 }, + { "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" }, + { "mschap-challenge", o_string, &mschap_challenge, + "specify CHAP challenge" }, + { "mschap2-peer-challenge", o_string, &mschap2_peer_challenge, + "specify CHAP peer challenge" }, #endif - { NULL } + { NULL } }; #endif /* PPP_OPTIONS */ @@ -223,279 +223,279 @@ static option_t chapms_option_list[] = { * at challenge[1]. */ static void chapms_generate_challenge(ppp_pcb *pcb, unsigned char *challenge) { - LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(pcb); - *challenge++ = 8; + *challenge++ = 8; #ifdef DEBUGMPPEKEY - if (mschap_challenge && strlen(mschap_challenge) == 8) - memcpy(challenge, mschap_challenge, 8); - else + if (mschap_challenge && strlen(mschap_challenge) == 8) + memcpy(challenge, mschap_challenge, 8); + else #endif - magic_random_bytes(challenge, 8); + magic_random_bytes(challenge, 8); } static void chapms2_generate_challenge(ppp_pcb *pcb, unsigned char *challenge) { - LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(pcb); - *challenge++ = 16; + *challenge++ = 16; #ifdef DEBUGMPPEKEY - if (mschap_challenge && strlen(mschap_challenge) == 16) - memcpy(challenge, mschap_challenge, 16); - else + if (mschap_challenge && strlen(mschap_challenge) == 16) + memcpy(challenge, mschap_challenge, 16); + else #endif - magic_random_bytes(challenge, 16); + magic_random_bytes(challenge, 16); } static int chapms_verify_response(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) { - unsigned char md[MS_CHAP_RESPONSE_LEN]; - int diff; - int challenge_len, response_len; - LWIP_UNUSED_ARG(id); - LWIP_UNUSED_ARG(name); - - challenge_len = *challenge++; /* skip length, is 8 */ - response_len = *response++; - if (response_len != MS_CHAP_RESPONSE_LEN) - goto bad; + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) { + unsigned char md[MS_CHAP_RESPONSE_LEN]; + int diff; + int challenge_len, response_len; + LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(name); + + challenge_len = *challenge++; /* skip length, is 8 */ + response_len = *response++; + if (response_len != MS_CHAP_RESPONSE_LEN) + goto bad; #ifndef MSLANMAN - if (!response[MS_CHAP_USENT]) { - /* Should really propagate this into the error packet. */ - ppp_notice("Peer request for LANMAN auth not supported"); - goto bad; - } + if (!response[MS_CHAP_USENT]) { + /* Should really propagate this into the error packet. */ + ppp_notice("Peer request for LANMAN auth not supported"); + goto bad; + } #endif - /* Generate the expected response. */ - ChapMS(pcb, (const u_char *)challenge, (const char *)secret, secret_len, md); + /* Generate the expected response. */ + ChapMS(pcb, (const u_char *)challenge, (const char *)secret, secret_len, md); #ifdef MSLANMAN - /* Determine which part of response to verify against */ - if (!response[MS_CHAP_USENT]) - diff = memcmp(&response[MS_CHAP_LANMANRESP], - &md[MS_CHAP_LANMANRESP], MS_CHAP_LANMANRESP_LEN); - else + /* Determine which part of response to verify against */ + if (!response[MS_CHAP_USENT]) + diff = memcmp(&response[MS_CHAP_LANMANRESP], + &md[MS_CHAP_LANMANRESP], MS_CHAP_LANMANRESP_LEN); + else #endif - diff = memcmp(&response[MS_CHAP_NTRESP], &md[MS_CHAP_NTRESP], - MS_CHAP_NTRESP_LEN); + diff = memcmp(&response[MS_CHAP_NTRESP], &md[MS_CHAP_NTRESP], + MS_CHAP_NTRESP_LEN); - if (diff == 0) { - ppp_slprintf(message, message_space, "Access granted"); - return 1; - } + if (diff == 0) { + ppp_slprintf(message, message_space, "Access granted"); + return 1; + } bad: - /* See comments below for MS-CHAP V2 */ - ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0", - challenge_len, challenge); - return 0; + /* See comments below for MS-CHAP V2 */ + ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0", + challenge_len, challenge); + return 0; } static int chapms2_verify_response(ppp_pcb *pcb, int id, const char *name, - const unsigned char *secret, int secret_len, - const unsigned char *challenge, const unsigned char *response, - char *message, int message_space) { - unsigned char md[MS_CHAP2_RESPONSE_LEN]; - char saresponse[MS_AUTH_RESPONSE_LENGTH+1]; - int challenge_len, response_len; - LWIP_UNUSED_ARG(id); - - challenge_len = *challenge++; /* skip length, is 16 */ - response_len = *response++; - if (response_len != MS_CHAP2_RESPONSE_LEN) - goto bad; /* not even the right length */ - - /* Generate the expected response and our mutual auth. */ - ChapMS2(pcb, (const u_char*)challenge, (const u_char*)&response[MS_CHAP2_PEER_CHALLENGE], name, - (const 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= M=" - * where - * is the Authenticator Response (mutual auth) - * is a text message - * - * However, some versions of Windows (win98 tested) do not know - * about the M= 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 for - * help debugging this. - */ - if (memcmp(&md[MS_CHAP2_NTRESP], &response[MS_CHAP2_NTRESP], - MS_CHAP2_NTRESP_LEN) == 0) { - if (response[MS_CHAP2_FLAGS]) - ppp_slprintf(message, message_space, "S=%s", saresponse); - else - ppp_slprintf(message, message_space, "S=%s M=%s", - saresponse, "Access granted"); - return 1; - } + const unsigned char *secret, int secret_len, + const unsigned char *challenge, const unsigned char *response, + char *message, int message_space) { + unsigned char md[MS_CHAP2_RESPONSE_LEN]; + char saresponse[MS_AUTH_RESPONSE_LENGTH+1]; + int challenge_len, response_len; + LWIP_UNUSED_ARG(id); + + challenge_len = *challenge++; /* skip length, is 16 */ + response_len = *response++; + if (response_len != MS_CHAP2_RESPONSE_LEN) + goto bad; /* not even the right length */ + + /* Generate the expected response and our mutual auth. */ + ChapMS2(pcb, (const u_char*)challenge, (const u_char*)&response[MS_CHAP2_PEER_CHALLENGE], name, + (const 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= M=" + * where + * is the Authenticator Response (mutual auth) + * is a text message + * + * However, some versions of Windows (win98 tested) do not know + * about the M= 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 for + * help debugging this. + */ + if (memcmp(&md[MS_CHAP2_NTRESP], &response[MS_CHAP2_NTRESP], + MS_CHAP2_NTRESP_LEN) == 0) { + if (response[MS_CHAP2_FLAGS]) + ppp_slprintf(message, message_space, "S=%s", saresponse); + else + ppp_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. - */ - ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0 M=%s", - challenge_len, challenge, "Access denied"); - return 0; + /* + * 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. + */ + ppp_slprintf(message, message_space, "E=691 R=1 C=%0.*B V=0 M=%s", + challenge_len, challenge, "Access denied"); + return 0; } #endif /* PPP_SERVER */ static void chapms_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *private_) { - LWIP_UNUSED_ARG(id); - LWIP_UNUSED_ARG(our_name); - LWIP_UNUSED_ARG(private_); - challenge++; /* skip length, should be 8 */ - *response++ = MS_CHAP_RESPONSE_LEN; - ChapMS(pcb, challenge, secret, secret_len, response); + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *private_) { + LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(our_name); + LWIP_UNUSED_ARG(private_); + challenge++; /* skip length, should be 8 */ + *response++ = MS_CHAP_RESPONSE_LEN; + ChapMS(pcb, challenge, secret, secret_len, response); } static void chapms2_make_response(ppp_pcb *pcb, unsigned char *response, int id, const char *our_name, - const unsigned char *challenge, const char *secret, int secret_len, - unsigned char *private_) { - LWIP_UNUSED_ARG(id); - challenge++; /* skip length, should be 16 */ - *response++ = MS_CHAP2_RESPONSE_LEN; - ChapMS2(pcb, challenge, + const unsigned char *challenge, const char *secret, int secret_len, + unsigned char *private_) { + LWIP_UNUSED_ARG(id); + challenge++; /* skip length, should be 16 */ + *response++ = MS_CHAP2_RESPONSE_LEN; + ChapMS2(pcb, challenge, #ifdef DEBUGMPPEKEY - mschap2_peer_challenge, + mschap2_peer_challenge, #else - NULL, + NULL, #endif - our_name, secret, secret_len, response, private_, - MS_CHAP2_AUTHENTICATEE); + our_name, secret, secret_len, response, private_, + MS_CHAP2_AUTHENTICATEE); } static int chapms2_check_success(ppp_pcb *pcb, unsigned char *msg, int len, unsigned char *private_) { - LWIP_UNUSED_ARG(pcb); - - if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || - strncmp((char *)msg, "S=", 2) != 0) { - /* Packet does not start with "S=" */ - ppp_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. */ - ppp_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=" */ - ppp_error("MS-CHAPv2 Success packet is badly formed."); - return 0; - } - return 1; + LWIP_UNUSED_ARG(pcb); + + if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || + strncmp((char *)msg, "S=", 2) != 0) { + /* Packet does not start with "S=" */ + ppp_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. */ + ppp_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=" */ + ppp_error("MS-CHAPv2 Success packet is badly formed."); + return 0; + } + return 1; } static void chapms_handle_failure(ppp_pcb *pcb, unsigned char *inp, int len) { - int err; - const char *p; - char msg[64]; - LWIP_UNUSED_ARG(pcb); - - /* We want a null-terminated string for strxxx(). */ - len = LWIP_MIN(len, 63); - MEMCPY(msg, inp, len); - msg[len] = 0; - p = msg; - - /* - * Deal with MS-CHAP formatted failure messages; just print the - * M= part (if any). For MS-CHAP we're not really supposed - * to use M=, but it shouldn't hurt. See - * chapms[2]_verify_response. - */ - if (!strncmp(p, "E=", 2)) - err = strtol(p+2, NULL, 10); /* Remember the error code. */ - else - goto print_msg; /* Message is badly formatted. */ - - if (len && ((p = strstr(p, " M=")) != NULL)) { - /* M= field found. */ - p += 3; - } else { - /* No M=; 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: - ppp_error("Unknown MS-CHAP authentication failure: %.*v", - len, inp); - return; - } - } + int err; + const char *p; + char msg[64]; + LWIP_UNUSED_ARG(pcb); + + /* We want a null-terminated string for strxxx(). */ + len = LWIP_MIN(len, 63); + MEMCPY(msg, inp, len); + msg[len] = 0; + p = msg; + + /* + * Deal with MS-CHAP formatted failure messages; just print the + * M= part (if any). For MS-CHAP we're not really supposed + * to use M=, but it shouldn't hurt. See + * chapms[2]_verify_response. + */ + if (!strncmp(p, "E=", 2)) + err = strtol(p+2, NULL, 10); /* Remember the error code. */ + else + goto print_msg; /* Message is badly formatted. */ + + if (len && ((p = strstr(p, " M=")) != NULL)) { + /* M= field found. */ + p += 3; + } else { + /* No M=; 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: + ppp_error("Unknown MS-CHAP authentication failure: %.*v", + len, inp); + return; + } + } print_msg: - if (p != NULL) - ppp_error("MS-CHAP authentication failed: %v", p); + if (p != NULL) + ppp_error("MS-CHAP authentication failed: %v", p); } static void ChallengeResponse(const u_char *challenge, - const u_char PasswordHash[MD4_SIGNATURE_SIZE], - u_char response[24]) { + const u_char PasswordHash[MD4_SIGNATURE_SIZE], + u_char response[24]) { u_char ZPasswordHash[21]; lwip_des_context des; u_char des_key[8]; @@ -505,7 +505,7 @@ static void ChallengeResponse(const u_char *challenge, #if 0 dbglog("ChallengeResponse - ZPasswordHash %.*B", - sizeof(ZPasswordHash), ZPasswordHash); + sizeof(ZPasswordHash), ZPasswordHash); #endif pppcrypt_56_to_64_bit_key(ZPasswordHash + 0, des_key); @@ -532,16 +532,16 @@ static void ChallengeResponse(const u_char *challenge, } static void ChallengeHash(const u_char PeerChallenge[16], const u_char *rchallenge, - const char *username, u_char Challenge[8]) { - lwip_sha1_context sha1Context; - u_char sha1Hash[SHA1_SIGNATURE_SIZE]; - const char *user; + const char *username, u_char Challenge[8]) { + lwip_sha1_context sha1Context; + u_char sha1Hash[SHA1_SIGNATURE_SIZE]; + const char *user; /* remove domain from "domain\username" */ if ((user = strrchr(username, '\\')) != NULL) - ++user; + ++user; else - user = username; + user = username; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); @@ -566,11 +566,11 @@ static void ascii2unicode(const char ascii[], int ascii_len, u_char unicode[]) { BZERO(unicode, ascii_len * 2); for (i = 0; i < ascii_len; i++) - unicode[i * 2] = (u_char) ascii[i]; + unicode[i * 2] = (u_char) ascii[i]; } static void NTPasswordHash(u_char *secret, int secret_len, u_char hash[MD4_SIGNATURE_SIZE]) { - lwip_md4_context md4Context; + lwip_md4_context md4Context; lwip_md4_init(&md4Context); lwip_md4_starts(&md4Context); @@ -580,9 +580,9 @@ static void NTPasswordHash(u_char *secret, int secret_len, u_char hash[MD4_SIGNA } static void ChapMS_NT(const u_char *rchallenge, const char *secret, int secret_len, - u_char NTResponse[24]) { - u_char unicodePassword[MAX_NT_PASSWORD * 2]; - u_char PasswordHash[MD4_SIGNATURE_SIZE]; + 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); @@ -592,10 +592,10 @@ static void ChapMS_NT(const u_char *rchallenge, const char *secret, int secret_l } static void ChapMS2_NT(const u_char *rchallenge, const u_char PeerChallenge[16], const char *username, - const 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]; + const 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, rchallenge, username, Challenge); @@ -610,10 +610,10 @@ static void ChapMS2_NT(const u_char *rchallenge, const u_char PeerChallenge[16], static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ static void ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len, - unsigned char *response) { - int i; - u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ - u_char PasswordHash[MD4_SIGNATURE_SIZE]; + unsigned char *response) { + int i; + u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ + u_char PasswordHash[MD4_SIGNATURE_SIZE]; lwip_des_context des; u_char des_key[8]; @@ -640,28 +640,28 @@ static void ChapMS_LANMan(u_char *rchallenge, char *secret, int secret_len, static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGNATURE_SIZE], - u_char NTResponse[24], const u_char PeerChallenge[16], - const u_char *rchallenge, const char *username, - u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) { + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const char *username, + u_char authResponse[MS_AUTH_RESPONSE_LENGTH+1]) { /* * "Magic" constants used in response generation, from RFC 2759. */ static const 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 }; + { 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 }; static const 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 }; + { 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; - lwip_sha1_context sha1Context; - u_char Digest[SHA1_SIGNATURE_SIZE]; - u_char Challenge[8]; + int i; + lwip_sha1_context sha1Context; + u_char Digest[SHA1_SIGNATURE_SIZE]; + u_char Challenge[8]; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); @@ -683,27 +683,27 @@ static void GenerateAuthenticatorResponse(const u_char PasswordHashHash[MD4_SIGN /* Convert to ASCII hex string. */ for (i = 0; i < LWIP_MAX((MS_AUTH_RESPONSE_LENGTH / 2), (int)sizeof(Digest)); i++) - sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]); + sprintf((char *)&authResponse[i * 2], "%02X", Digest[i]); } static void GenerateAuthenticatorResponsePlain( - const char *secret, int secret_len, - u_char NTResponse[24], const u_char PeerChallenge[16], - const u_char *rchallenge, const 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]; + const char *secret, int secret_len, + u_char NTResponse[24], const u_char PeerChallenge[16], + const u_char *rchallenge, const 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(unicodePassword, secret_len * 2, PasswordHash); NTPasswordHash(PasswordHash, sizeof(PasswordHash), - PasswordHashHash); + PasswordHashHash); GenerateAuthenticatorResponse(PasswordHashHash, NTResponse, PeerChallenge, - rchallenge, username, authResponse); + rchallenge, username, authResponse); } @@ -712,11 +712,11 @@ static void GenerateAuthenticatorResponsePlain( * Set mppe_xxxx_key from MS-CHAP credentials. (see RFC 3079) */ static void Set_Start_Key(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, int secret_len) { - u_char unicodePassword[MAX_NT_PASSWORD * 2]; - u_char PasswordHash[MD4_SIGNATURE_SIZE]; - u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; - lwip_sha1_context sha1Context; - u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ + u_char unicodePassword[MAX_NT_PASSWORD * 2]; + u_char PasswordHash[MD4_SIGNATURE_SIZE]; + u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; + lwip_sha1_context sha1Context; + u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ /* Hash (x2) the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); @@ -742,43 +742,43 @@ static void Set_Start_Key(ppp_pcb *pcb, const u_char *rchallenge, const char *se * Set mppe_xxxx_key from MS-CHAPv2 credentials. (see RFC 3079) */ static void SetMasterKeys(ppp_pcb *pcb, const 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]; - lwip_sha1_context sha1Context; - u_char MasterKey[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ - u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ + u_char unicodePassword[MAX_NT_PASSWORD * 2]; + u_char PasswordHash[MD4_SIGNATURE_SIZE]; + u_char PasswordHashHash[MD4_SIGNATURE_SIZE]; + lwip_sha1_context sha1Context; + u_char MasterKey[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ + u_char Digest[SHA1_SIGNATURE_SIZE]; /* >= MPPE_MAX_KEY_LEN */ const u_char *s; /* "This is the MPPE Master Key" */ static const 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 }; + { 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." */ static const 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 }; + { 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." */ static const 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 }; + { 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 }; /* Hash (x2) the Unicode version of the secret (== password). */ ascii2unicode(secret, secret_len, unicodePassword); @@ -797,9 +797,9 @@ static void SetMasterKeys(ppp_pcb *pcb, const char *secret, int secret_len, u_ch * generate send key */ if (IsServer) - s = Magic3; + s = Magic3; else - s = Magic2; + s = Magic2; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); lwip_sha1_update(&sha1Context, MasterKey, 16); @@ -815,9 +815,9 @@ static void SetMasterKeys(ppp_pcb *pcb, const char *secret, int secret_len, u_ch * generate recv key */ if (IsServer) - s = Magic2; + s = Magic2; else - s = Magic3; + s = Magic3; lwip_sha1_init(&sha1Context); lwip_sha1_starts(&sha1Context); lwip_sha1_update(&sha1Context, MasterKey, 16); @@ -846,7 +846,7 @@ static void ChapMS(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, i #ifdef MSLANMAN ChapMS_LANMan(rchallenge, secret, secret_len, - &response[MS_CHAP_LANMANRESP]); + &response[MS_CHAP_LANMANRESP]); /* preferred method is set by option */ response[MS_CHAP_USENT] = !ms_lanman; @@ -871,8 +871,8 @@ static void ChapMS(ppp_pcb *pcb, const u_char *rchallenge, const char *secret, i * Authenticator Response. */ static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerChallenge, - const char *user, const char *secret, int secret_len, unsigned char *response, - u_char authResponse[], int authenticator) { + const char *user, const char *secret, int secret_len, unsigned char *response, + u_char authResponse[], int authenticator) { /* ARGSUSED */ LWIP_UNUSED_ARG(authenticator); #if !MPPE_SUPPORT @@ -883,24 +883,24 @@ static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerCh /* Generate the Peer-Challenge if requested, or copy it if supplied. */ if (!PeerChallenge) - magic_random_bytes(&response[MS_CHAP2_PEER_CHALLENGE], MS_CHAP2_PEER_CHAL_LEN); + magic_random_bytes(&response[MS_CHAP2_PEER_CHALLENGE], MS_CHAP2_PEER_CHAL_LEN); else - MEMCPY(&response[MS_CHAP2_PEER_CHALLENGE], PeerChallenge, - MS_CHAP2_PEER_CHAL_LEN); + MEMCPY(&response[MS_CHAP2_PEER_CHALLENGE], PeerChallenge, + MS_CHAP2_PEER_CHAL_LEN); /* Generate the NT-Response */ ChapMS2_NT(rchallenge, &response[MS_CHAP2_PEER_CHALLENGE], user, - secret, secret_len, &response[MS_CHAP2_NTRESP]); + secret, secret_len, &response[MS_CHAP2_NTRESP]); /* Generate the Authenticator Response. */ GenerateAuthenticatorResponsePlain(secret, secret_len, - &response[MS_CHAP2_NTRESP], - &response[MS_CHAP2_PEER_CHALLENGE], - rchallenge, user, authResponse); + &response[MS_CHAP2_NTRESP], + &response[MS_CHAP2_PEER_CHALLENGE], + rchallenge, user, authResponse); #if MPPE_SUPPORT SetMasterKeys(pcb, secret, secret_len, - &response[MS_CHAP2_NTRESP], authenticator); + &response[MS_CHAP2_NTRESP], authenticator); #endif /* MPPE_SUPPORT */ } @@ -912,51 +912,51 @@ static void ChapMS2(ppp_pcb *pcb, const u_char *rchallenge, const u_char *PeerCh 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; + 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; + 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; + 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_SUPPORT */ #endif /* UNUSED */ const struct chap_digest_type chapms_digest = { - CHAP_MICROSOFT, /* code */ + CHAP_MICROSOFT, /* code */ #if PPP_SERVER - chapms_generate_challenge, - chapms_verify_response, + chapms_generate_challenge, + chapms_verify_response, #endif /* PPP_SERVER */ - chapms_make_response, - NULL, /* check_success */ - chapms_handle_failure, + chapms_make_response, + NULL, /* check_success */ + chapms_handle_failure, }; const struct chap_digest_type chapms2_digest = { - CHAP_MICROSOFT_V2, /* code */ + CHAP_MICROSOFT_V2, /* code */ #if PPP_SERVER - chapms2_generate_challenge, - chapms2_verify_response, + chapms2_generate_challenge, + chapms2_verify_response, #endif /* PPP_SERVER */ - chapms2_make_response, - chapms2_check_success, - chapms_handle_failure, + chapms2_make_response, + chapms2_check_success, + chapms_handle_failure, }; #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/demand.c b/components/net/lwip-2.1.2/src/netif/ppp/demand.c index 26c6c30db1..f3774e087c 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/demand.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/demand.c @@ -87,11 +87,11 @@ demand_conf() /* framemax = lcp_allowoptions[0].mru; if (framemax < PPP_MRU) */ - framemax = PPP_MRU; + framemax = PPP_MRU; framemax += PPP_HDRLEN + PPP_FCSLEN; frame = malloc(framemax); if (frame == NULL) - novm("demand frame"); + novm("demand frame"); framelen = 0; pend_q = NULL; escape_flag = 0; @@ -100,8 +100,8 @@ demand_conf() netif_set_mtu(pcb, LWIP_MIN(lcp_allowoptions[0].mru, PPP_MRU)); if (ppp_send_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0 - || ppp_recv_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0) - fatal("Couldn't set up demand-dialled PPP interface: %m"); + || ppp_recv_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0) + fatal("Couldn't set up demand-dialled PPP interface: %m"); #ifdef PPP_FILTER set_filters(&pass_filter, &active_filter); @@ -111,12 +111,12 @@ demand_conf() * Call the demand_conf procedure for each protocol that's got one. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - ((*protp->demand_conf)(pcb)); + if (protp->demand_conf != NULL) + ((*protp->demand_conf)(pcb)); /* FIXME: find a way to die() here */ #if 0 - if (!((*protp->demand_conf)(pcb))) - die(1); + if (!((*protp->demand_conf)(pcb))) + die(1); #endif } @@ -131,8 +131,8 @@ demand_block() const struct protent *protp; for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_QUEUE); + if (protp->demand_conf != NULL) + sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_QUEUE); get_loop_output(); } @@ -148,14 +148,14 @@ demand_discard() const struct protent *protp; for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_ERROR); + if (protp->demand_conf != NULL) + sifnpmode(pcb, 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); + nextpkt = pkt->next; + free(pkt); } pend_q = NULL; framelen = 0; @@ -174,46 +174,46 @@ demand_unblock() const struct protent *protp; for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->demand_conf != NULL) - sifnpmode(pcb, protp->protocol & ~0x8000, NPMODE_PASS); + if (protp->demand_conf != NULL) + sifnpmode(pcb, 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 + 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 }; /* @@ -238,35 +238,35 @@ loop_chars(p, n) } 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); + 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; } @@ -290,22 +290,22 @@ loop_frame(frame, len) /* dbglog("from loop: %P", frame, len); */ if (len < PPP_HDRLEN) - return 0; + return 0; if ((PPP_PROTOCOL(frame) & 0x8000) != 0) - return 0; /* shouldn't get any of these anyway */ + return 0; /* shouldn't get any of these anyway */ if (!active_packet(frame, len)) - return 0; + 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; + 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; } @@ -332,23 +332,23 @@ demand_rexmit(proto, newip) pend_q = NULL; tv.tv_sec = 1; tv.tv_usec = 0; - select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */ + select(0,NULL,NULL,NULL,&tv); /* Sleep for 1 Seconds */ for (; pkt != NULL; pkt = nextpkt) { - nextpkt = pkt->next; - if (PPP_PROTOCOL(pkt->data) == proto) { + nextpkt = pkt->next; + if (PPP_PROTOCOL(pkt->data) == proto) { if ( (proto == PPP_IP) && newip ) { - /* Get old checksum */ + /* Get old checksum */ - iphdr = (pkt->data[4] & 15) << 2; - checksum = *((unsigned short *) (pkt->data+14)); + iphdr = (pkt->data[4] & 15) << 2; + checksum = *((unsigned short *) (pkt->data+14)); if (checksum == 0xFFFF) { checksum = 0; } - + if (pkt->data[13] == 17) { pkt_checksum = *((unsigned short *) (pkt->data+10+iphdr)); - if (pkt_checksum) { + if (pkt_checksum) { cv = 1; if (pkt_checksum == 0xFFFF) { pkt_checksum = 0; @@ -359,71 +359,71 @@ demand_rexmit(proto, newip) } } - if (pkt->data[13] == 6) { - pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr)); - cv = 1; + if (pkt->data[13] == 6) { + pkt_checksum = *((unsigned short *) (pkt->data+20+iphdr)); + cv = 1; if (pkt_checksum == 0xFFFF) { pkt_checksum = 0; } - } + } - /* Delete old Source-IP-Address */ + /* Delete old Source-IP-Address */ checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; - pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; - pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; + pkt_checksum -= *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; + pkt_checksum -= *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; - /* Change Source-IP-Address */ + /* Change Source-IP-Address */ * ((u32_t *) (pkt->data + 16)) = newip; - /* Add new Source-IP-Address */ + /* Add new Source-IP-Address */ checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; pkt_checksum += *((unsigned short *) (pkt->data+16)) ^ 0xFFFF; pkt_checksum += *((unsigned short *) (pkt->data+18)) ^ 0xFFFF; - /* Write new checksum */ + /* Write new checksum */ if (!checksum) { checksum = 0xFFFF; } *((unsigned short *) (pkt->data+14)) = checksum; - if (pkt->data[13] == 6) { - *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum; - } - if (cv && (pkt->data[13] == 17) ) { - *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum; - } - - /* Log Packet */ - strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16)))); - if (pkt->data[13] == 1) { - syslog(LOG_INFO,"Open ICMP %s -> %s\n", - ipstr, - inet_ntoa(*( (struct in_addr *) (pkt->data+20)))); - } else { - syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n", - pkt->data[13] == 6 ? "TCP" : "UDP", - ipstr, - ntohs(*( (short *) (pkt->data+iphdr+4))), - inet_ntoa(*( (struct in_addr *) (pkt->data+20))), - ntohs(*( (short *) (pkt->data+iphdr+6)))); + if (pkt->data[13] == 6) { + *((unsigned short *) (pkt->data+20+iphdr)) = pkt_checksum; + } + if (cv && (pkt->data[13] == 17) ) { + *((unsigned short *) (pkt->data+10+iphdr)) = pkt_checksum; + } + + /* Log Packet */ + strcpy(ipstr,inet_ntoa(*( (struct in_addr *) (pkt->data+16)))); + if (pkt->data[13] == 1) { + syslog(LOG_INFO,"Open ICMP %s -> %s\n", + ipstr, + inet_ntoa(*( (struct in_addr *) (pkt->data+20)))); + } else { + syslog(LOG_INFO,"Open %s %s:%d -> %s:%d\n", + pkt->data[13] == 6 ? "TCP" : "UDP", + ipstr, + ntohs(*( (short *) (pkt->data+iphdr+4))), + inet_ntoa(*( (struct in_addr *) (pkt->data+20))), + ntohs(*( (short *) (pkt->data+iphdr+6)))); } } - output(pcb, pkt->data, pkt->length); - free(pkt); - } else { - if (prev == NULL) - pend_q = pkt; - else - prev->next = pkt; - prev = pkt; - } + output(pcb, 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; + prev->next = NULL; } /* @@ -439,27 +439,27 @@ active_packet(p, len) const struct protent *protp; if (len < PPP_HDRLEN) - return 0; + return 0; proto = PPP_PROTOCOL(p); #ifdef PPP_FILTER - p[0] = 1; /* outbound packet indicator */ + p[0] = 1; /* outbound packet indicator */ if ((pass_filter.bf_len != 0 - && bpf_filter(pass_filter.bf_insns, p, len, len) == 0) - || (active_filter.bf_len != 0 - && bpf_filter(active_filter.bf_insns, p, len, len) == 0)) { - p[0] = 0xff; - return 0; + && bpf_filter(pass_filter.bf_insns, p, len, len) == 0) + || (active_filter.bf_len != 0 + && bpf_filter(active_filter.bf_insns, p, len, len) == 0)) { + p[0] = 0xff; + return 0; } p[0] = 0xff; #endif for (i = 0; (protp = protocols[i]) != NULL; ++i) { - if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { - if (protp->active_pkt == NULL) - return 1; - return (*protp->active_pkt)(p, len); - } + if (protp->protocol < 0xC000 && (protp->protocol & ~0x8000) == proto) { + if (protp->active_pkt == NULL) + return 1; + return (*protp->active_pkt)(p, len); + } } - return 0; /* not a supported protocol !!?? */ + return 0; /* not a supported protocol !!?? */ } #endif /* PPP_SUPPORT && DEMAND_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/eap.c b/components/net/lwip-2.1.2/src/netif/ppp/eap.c index 8fb56368e7..8ca53d2a0d 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/eap.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/eap.c @@ -58,11 +58,11 @@ #endif /* USE_SRP */ #ifndef SHA_DIGESTSIZE -#define SHA_DIGESTSIZE 20 +#define SHA_DIGESTSIZE 20 #endif #ifdef USE_SRP -static char *pn_secret = NULL; /* Pseudonym generating secret */ +static char *pn_secret = NULL; /* Pseudonym generating secret */ #endif #if PPP_OPTIONS @@ -106,31 +106,31 @@ static int eap_printpkt(const u_char *inp, int inlen, #endif /* PRINTPKT_SUPPORT */ const struct protent eap_protent = { - PPP_EAP, /* protocol number */ - eap_init, /* initialization procedure */ - eap_input, /* process a received packet */ - eap_protrej, /* process a received protocol-reject */ - eap_lowerup, /* lower layer has gone up */ - eap_lowerdown, /* lower layer has gone down */ - NULL, /* open the protocol */ - NULL, /* close the protocol */ + PPP_EAP, /* protocol number */ + eap_init, /* initialization procedure */ + eap_input, /* process a received packet */ + eap_protrej, /* process a received protocol-reject */ + eap_lowerup, /* lower layer has gone up */ + eap_lowerdown, /* lower layer has gone down */ + NULL, /* open the protocol */ + NULL, /* close the protocol */ #if PRINTPKT_SUPPORT - eap_printpkt, /* print a packet in readable form */ + eap_printpkt, /* print a packet in readable form */ #endif /* PRINTPKT_SUPPORT */ #if PPP_DATAINPUT - NULL, /* process a received data packet */ + NULL, /* process a received data packet */ #endif /* PPP_DATAINPUT */ #if PRINTPKT_SUPPORT - "EAP", /* text name of protocol */ - NULL, /* text name of corresponding data protocol */ + "EAP", /* text name of protocol */ + NULL, /* text name of corresponding data protocol */ #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS - eap_option_list, /* list of command-line options */ - NULL, /* check requested options; assign defaults */ + eap_option_list, /* list of command-line options */ + NULL, /* check requested options; assign defaults */ #endif /* PPP_OPTIONS */ #if DEMAND_SUPPORT - NULL, /* configure interface for demand-dial */ - NULL /* say whether to bring up link for this pkt */ + NULL, /* configure interface for demand-dial */ + NULL /* say whether to bring up link for this pkt */ #endif /* DEMAND_SUPPORT */ }; @@ -139,38 +139,38 @@ const struct protent eap_protent = { * A well-known 2048 bit modulus. */ static const u_char wkmodulus[] = { - 0xAC, 0x6B, 0xDB, 0x41, 0x32, 0x4A, 0x9A, 0x9B, - 0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58, 0x2F, - 0xAF, 0x72, 0xB6, 0x65, 0x19, 0x87, 0xEE, 0x07, - 0xFC, 0x31, 0x92, 0x94, 0x3D, 0xB5, 0x60, 0x50, - 0xA3, 0x73, 0x29, 0xCB, 0xB4, 0xA0, 0x99, 0xED, - 0x81, 0x93, 0xE0, 0x75, 0x77, 0x67, 0xA1, 0x3D, - 0xD5, 0x23, 0x12, 0xAB, 0x4B, 0x03, 0x31, 0x0D, - 0xCD, 0x7F, 0x48, 0xA9, 0xDA, 0x04, 0xFD, 0x50, - 0xE8, 0x08, 0x39, 0x69, 0xED, 0xB7, 0x67, 0xB0, - 0xCF, 0x60, 0x95, 0x17, 0x9A, 0x16, 0x3A, 0xB3, - 0x66, 0x1A, 0x05, 0xFB, 0xD5, 0xFA, 0xAA, 0xE8, - 0x29, 0x18, 0xA9, 0x96, 0x2F, 0x0B, 0x93, 0xB8, - 0x55, 0xF9, 0x79, 0x93, 0xEC, 0x97, 0x5E, 0xEA, - 0xA8, 0x0D, 0x74, 0x0A, 0xDB, 0xF4, 0xFF, 0x74, - 0x73, 0x59, 0xD0, 0x41, 0xD5, 0xC3, 0x3E, 0xA7, - 0x1D, 0x28, 0x1E, 0x44, 0x6B, 0x14, 0x77, 0x3B, - 0xCA, 0x97, 0xB4, 0x3A, 0x23, 0xFB, 0x80, 0x16, - 0x76, 0xBD, 0x20, 0x7A, 0x43, 0x6C, 0x64, 0x81, - 0xF1, 0xD2, 0xB9, 0x07, 0x87, 0x17, 0x46, 0x1A, - 0x5B, 0x9D, 0x32, 0xE6, 0x88, 0xF8, 0x77, 0x48, - 0x54, 0x45, 0x23, 0xB5, 0x24, 0xB0, 0xD5, 0x7D, - 0x5E, 0xA7, 0x7A, 0x27, 0x75, 0xD2, 0xEC, 0xFA, - 0x03, 0x2C, 0xFB, 0xDB, 0xF5, 0x2F, 0xB3, 0x78, - 0x61, 0x60, 0x27, 0x90, 0x04, 0xE5, 0x7A, 0xE6, - 0xAF, 0x87, 0x4E, 0x73, 0x03, 0xCE, 0x53, 0x29, - 0x9C, 0xCC, 0x04, 0x1C, 0x7B, 0xC3, 0x08, 0xD8, - 0x2A, 0x56, 0x98, 0xF3, 0xA8, 0xD0, 0xC3, 0x82, - 0x71, 0xAE, 0x35, 0xF8, 0xE9, 0xDB, 0xFB, 0xB6, - 0x94, 0xB5, 0xC8, 0x03, 0xD8, 0x9F, 0x7A, 0xE4, - 0x35, 0xDE, 0x23, 0x6D, 0x52, 0x5F, 0x54, 0x75, - 0x9B, 0x65, 0xE3, 0x72, 0xFC, 0xD6, 0x8E, 0xF2, - 0x0F, 0xA7, 0x11, 0x1F, 0x9E, 0x4A, 0xFF, 0x73 + 0xAC, 0x6B, 0xDB, 0x41, 0x32, 0x4A, 0x9A, 0x9B, + 0xF1, 0x66, 0xDE, 0x5E, 0x13, 0x89, 0x58, 0x2F, + 0xAF, 0x72, 0xB6, 0x65, 0x19, 0x87, 0xEE, 0x07, + 0xFC, 0x31, 0x92, 0x94, 0x3D, 0xB5, 0x60, 0x50, + 0xA3, 0x73, 0x29, 0xCB, 0xB4, 0xA0, 0x99, 0xED, + 0x81, 0x93, 0xE0, 0x75, 0x77, 0x67, 0xA1, 0x3D, + 0xD5, 0x23, 0x12, 0xAB, 0x4B, 0x03, 0x31, 0x0D, + 0xCD, 0x7F, 0x48, 0xA9, 0xDA, 0x04, 0xFD, 0x50, + 0xE8, 0x08, 0x39, 0x69, 0xED, 0xB7, 0x67, 0xB0, + 0xCF, 0x60, 0x95, 0x17, 0x9A, 0x16, 0x3A, 0xB3, + 0x66, 0x1A, 0x05, 0xFB, 0xD5, 0xFA, 0xAA, 0xE8, + 0x29, 0x18, 0xA9, 0x96, 0x2F, 0x0B, 0x93, 0xB8, + 0x55, 0xF9, 0x79, 0x93, 0xEC, 0x97, 0x5E, 0xEA, + 0xA8, 0x0D, 0x74, 0x0A, 0xDB, 0xF4, 0xFF, 0x74, + 0x73, 0x59, 0xD0, 0x41, 0xD5, 0xC3, 0x3E, 0xA7, + 0x1D, 0x28, 0x1E, 0x44, 0x6B, 0x14, 0x77, 0x3B, + 0xCA, 0x97, 0xB4, 0x3A, 0x23, 0xFB, 0x80, 0x16, + 0x76, 0xBD, 0x20, 0x7A, 0x43, 0x6C, 0x64, 0x81, + 0xF1, 0xD2, 0xB9, 0x07, 0x87, 0x17, 0x46, 0x1A, + 0x5B, 0x9D, 0x32, 0xE6, 0x88, 0xF8, 0x77, 0x48, + 0x54, 0x45, 0x23, 0xB5, 0x24, 0xB0, 0xD5, 0x7D, + 0x5E, 0xA7, 0x7A, 0x27, 0x75, 0xD2, 0xEC, 0xFA, + 0x03, 0x2C, 0xFB, 0xDB, 0xF5, 0x2F, 0xB3, 0x78, + 0x61, 0x60, 0x27, 0x90, 0x04, 0xE5, 0x7A, 0xE6, + 0xAF, 0x87, 0x4E, 0x73, 0x03, 0xCE, 0x53, 0x29, + 0x9C, 0xCC, 0x04, 0x1C, 0x7B, 0xC3, 0x08, 0xD8, + 0x2A, 0x56, 0x98, 0xF3, 0xA8, 0xD0, 0xC3, 0x82, + 0x71, 0xAE, 0x35, 0xF8, 0xE9, 0xDB, 0xFB, 0xB6, + 0x94, 0xB5, 0xC8, 0x03, 0xD8, 0x9F, 0x7A, 0xE4, + 0x35, 0xDE, 0x23, 0x6D, 0x52, 0x5F, 0x54, 0x75, + 0x9B, 0x65, 0xE3, 0x72, 0xFC, 0xD6, 0x8E, 0xF2, + 0x0F, 0xA7, 0x11, 0x1F, 0x9E, 0x4A, 0xFF, 0x73 }; #endif @@ -184,9 +184,9 @@ static void eap_server_timeout(void *arg); */ static const char * eap_state_name(enum eap_state_code esc) { - static const char *state_names[] = { EAP_STATES }; + static const char *state_names[] = { EAP_STATES }; - return (state_names[(int)esc]); + return (state_names[(int)esc]); } /* @@ -195,9 +195,9 @@ static const char * eap_state_name(enum eap_state_code esc) */ static void eap_init(ppp_pcb *pcb) { - BZERO(&pcb->eap, sizeof(eap_state)); + BZERO(&pcb->eap, sizeof(eap_state)); #if PPP_SERVER - pcb->eap.es_server.ea_id = magic(); + pcb->eap.es_server.ea_id = magic(); #endif /* PPP_SERVER */ } @@ -206,14 +206,14 @@ static void eap_init(ppp_pcb *pcb) { * Request messages. */ static void eap_client_timeout(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (!eap_client_active(pcb)) - return; + if (!eap_client_active(pcb)) + return; - ppp_error("EAP: timeout waiting for Request from peer"); - auth_withpeer_fail(pcb, PPP_EAP); - pcb->eap.es_client.ea_state = eapBadAuth; + ppp_error("EAP: timeout waiting for Request from peer"); + auth_withpeer_fail(pcb, PPP_EAP); + pcb->eap.es_client.ea_state = eapBadAuth; } /* @@ -224,22 +224,22 @@ static void eap_client_timeout(void *arg) { */ void eap_authwithpeer(ppp_pcb *pcb, const char *localname) { - if(NULL == localname) - return; + if(NULL == localname) + return; - /* Save the peer name we're given */ - pcb->eap.es_client.ea_name = localname; - pcb->eap.es_client.ea_namelen = strlen(localname); + /* Save the peer name we're given */ + pcb->eap.es_client.ea_name = localname; + pcb->eap.es_client.ea_namelen = strlen(localname); - pcb->eap.es_client.ea_state = eapListen; + pcb->eap.es_client.ea_state = eapListen; - /* - * Start a timer so that if the other end just goes - * silent, we don't sit here waiting forever. - */ - if (pcb->settings.eap_req_time > 0) - TIMEOUT(eap_client_timeout, pcb, - pcb->settings.eap_req_time); + /* + * Start a timer so that if the other end just goes + * silent, we don't sit here waiting forever. + */ + if (pcb->settings.eap_req_time > 0) + TIMEOUT(eap_client_timeout, pcb, + pcb->settings.eap_req_time); } #if PPP_SERVER @@ -248,30 +248,30 @@ void eap_authwithpeer(ppp_pcb *pcb, const char *localname) { * (Server operation) */ static void eap_send_failure(ppp_pcb *pcb) { - struct pbuf *p; - u_char *outp; + struct pbuf *p; + u_char *outp; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } - outp = (u_char*)p->payload; + outp = (u_char*)p->payload; - MAKEHEADER(outp, PPP_EAP); + MAKEHEADER(outp, PPP_EAP); - PUTCHAR(EAP_FAILURE, outp); - pcb->eap.es_server.ea_id++; - PUTCHAR(pcb->eap.es_server.ea_id, outp); - PUTSHORT(EAP_HEADERLEN, outp); + PUTCHAR(EAP_FAILURE, outp); + pcb->eap.es_server.ea_id++; + PUTCHAR(pcb->eap.es_server.ea_id, outp); + PUTSHORT(EAP_HEADERLEN, outp); - ppp_write(pcb, p); + ppp_write(pcb, p); - pcb->eap.es_server.ea_state = eapBadAuth; - auth_peer_fail(pcb, PPP_EAP); + pcb->eap.es_server.ea_state = eapBadAuth; + auth_peer_fail(pcb, PPP_EAP); } /* @@ -279,30 +279,30 @@ static void eap_send_failure(ppp_pcb *pcb) { * (Server operation) */ static void eap_send_success(ppp_pcb *pcb) { - struct pbuf *p; - u_char *outp; - - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_SUCCESS, outp); - pcb->eap.es_server.ea_id++; - PUTCHAR(pcb->eap.es_server.ea_id, outp); - PUTSHORT(EAP_HEADERLEN, outp); - - ppp_write(pcb, p); - - auth_peer_success(pcb, PPP_EAP, 0, - pcb->eap.es_server.ea_peer, pcb->eap.es_server.ea_peerlen); + struct pbuf *p; + u_char *outp; + + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + EAP_HEADERLEN), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_SUCCESS, outp); + pcb->eap.es_server.ea_id++; + PUTCHAR(pcb->eap.es_server.ea_id, outp); + PUTSHORT(EAP_HEADERLEN, outp); + + ppp_write(pcb, p); + + auth_peer_success(pcb, PPP_EAP, 0, + pcb->eap.es_server.ea_peer, pcb->eap.es_server.ea_peerlen); } #endif /* PPP_SERVER */ @@ -314,31 +314,31 @@ static void eap_send_success(ppp_pcb *pcb) { static bool pncrypt_setkey(int timeoffs) { - struct tm *tp; - char tbuf[9]; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; - time_t reftime; - - if (pn_secret == NULL) - return (0); - reftime = time(NULL) + timeoffs; - tp = localtime(&reftime); - SHA1Init(&ctxt); - SHA1Update(&ctxt, pn_secret, strlen(pn_secret)); - strftime(tbuf, sizeof (tbuf), "%Y%m%d", tp); - SHA1Update(&ctxt, tbuf, strlen(tbuf)); - SHA1Final(dig, &ctxt); - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - return (DesSetkey(dig)); + struct tm *tp; + char tbuf[9]; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; + time_t reftime; + + if (pn_secret == NULL) + return (0); + reftime = time(NULL) + timeoffs; + tp = localtime(&reftime); + SHA1Init(&ctxt); + SHA1Update(&ctxt, pn_secret, strlen(pn_secret)); + strftime(tbuf, sizeof (tbuf), "%Y%m%d", tp); + SHA1Update(&ctxt, tbuf, strlen(tbuf)); + SHA1Final(dig, &ctxt); + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + return (DesSetkey(dig)); } static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; struct b64state { - u32_t bs_bits; - int bs_offs; + u32_t bs_bits; + int bs_offs; }; static int @@ -348,23 +348,23 @@ u_char *inp; int inlen; u_char *outp; { - int outlen = 0; - - while (inlen > 0) { - bs->bs_bits = (bs->bs_bits << 8) | *inp++; - inlen--; - bs->bs_offs += 8; - if (bs->bs_offs >= 24) { - *outp++ = base64[(bs->bs_bits >> 18) & 0x3F]; - *outp++ = base64[(bs->bs_bits >> 12) & 0x3F]; - *outp++ = base64[(bs->bs_bits >> 6) & 0x3F]; - *outp++ = base64[bs->bs_bits & 0x3F]; - outlen += 4; - bs->bs_offs = 0; - bs->bs_bits = 0; - } - } - return (outlen); + int outlen = 0; + + while (inlen > 0) { + bs->bs_bits = (bs->bs_bits << 8) | *inp++; + inlen--; + bs->bs_offs += 8; + if (bs->bs_offs >= 24) { + *outp++ = base64[(bs->bs_bits >> 18) & 0x3F]; + *outp++ = base64[(bs->bs_bits >> 12) & 0x3F]; + *outp++ = base64[(bs->bs_bits >> 6) & 0x3F]; + *outp++ = base64[bs->bs_bits & 0x3F]; + outlen += 4; + bs->bs_offs = 0; + bs->bs_bits = 0; + } + } + return (outlen); } static int @@ -372,21 +372,21 @@ b64flush(bs, outp) struct b64state *bs; u_char *outp; { - int outlen = 0; - - if (bs->bs_offs == 8) { - *outp++ = base64[(bs->bs_bits >> 2) & 0x3F]; - *outp++ = base64[(bs->bs_bits << 4) & 0x3F]; - outlen = 2; - } else if (bs->bs_offs == 16) { - *outp++ = base64[(bs->bs_bits >> 10) & 0x3F]; - *outp++ = base64[(bs->bs_bits >> 4) & 0x3F]; - *outp++ = base64[(bs->bs_bits << 2) & 0x3F]; - outlen = 3; - } - bs->bs_offs = 0; - bs->bs_bits = 0; - return (outlen); + int outlen = 0; + + if (bs->bs_offs == 8) { + *outp++ = base64[(bs->bs_bits >> 2) & 0x3F]; + *outp++ = base64[(bs->bs_bits << 4) & 0x3F]; + outlen = 2; + } else if (bs->bs_offs == 16) { + *outp++ = base64[(bs->bs_bits >> 10) & 0x3F]; + *outp++ = base64[(bs->bs_bits >> 4) & 0x3F]; + *outp++ = base64[(bs->bs_bits << 2) & 0x3F]; + outlen = 3; + } + bs->bs_offs = 0; + bs->bs_bits = 0; + return (outlen); } static int @@ -396,22 +396,22 @@ u_char *inp; int inlen; u_char *outp; { - int outlen = 0; - char *cp; - - while (inlen > 0) { - if ((cp = strchr(base64, *inp++)) == NULL) - break; - bs->bs_bits = (bs->bs_bits << 6) | (cp - base64); - inlen--; - bs->bs_offs += 6; - if (bs->bs_offs >= 8) { - *outp++ = bs->bs_bits >> (bs->bs_offs - 8); - outlen++; - bs->bs_offs -= 8; - } - } - return (outlen); + int outlen = 0; + char *cp; + + while (inlen > 0) { + if ((cp = strchr(base64, *inp++)) == NULL) + break; + bs->bs_bits = (bs->bs_bits << 6) | (cp - base64); + inlen--; + bs->bs_offs += 6; + if (bs->bs_offs >= 8) { + *outp++ = bs->bs_bits >> (bs->bs_offs - 8); + outlen++; + bs->bs_offs -= 8; + } + } + return (outlen); } #endif /* USE_SRP */ @@ -424,211 +424,211 @@ u_char *outp; */ static void eap_figure_next_state(ppp_pcb *pcb, int status) { #ifdef USE_SRP - unsigned char secbuf[MAXSECRETLEN], clear[8], *sp, *dp; - struct t_pw tpw; - struct t_confent *tce, mytce; - char *cp, *cp2; - struct t_server *ts; - int id, i, plen, toffs; - u_char vals[2]; - struct b64state bs; + unsigned char secbuf[MAXSECRETLEN], clear[8], *sp, *dp; + struct t_pw tpw; + struct t_confent *tce, mytce; + char *cp, *cp2; + struct t_server *ts; + int id, i, plen, toffs; + u_char vals[2]; + struct b64state bs; #endif /* USE_SRP */ - pcb->settings.eap_timeout_time = pcb->eap.es_savedtime; - switch (pcb->eap.es_server.ea_state) { - case eapBadAuth: - return; + pcb->settings.eap_timeout_time = pcb->eap.es_savedtime; + switch (pcb->eap.es_server.ea_state) { + case eapBadAuth: + return; - case eapIdentify: + case eapIdentify: #ifdef USE_SRP - /* Discard any previous session. */ - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + /* Discard any previous session. */ + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status != 0) { - pcb->eap.es_server.ea_state = eapBadAuth; - break; - } + if (status != 0) { + pcb->eap.es_server.ea_state = eapBadAuth; + break; + } #ifdef USE_SRP - /* If we've got a pseudonym, try to decode to real name. */ - if (pcb->eap.es_server.ea_peerlen > SRP_PSEUDO_LEN && - strncmp(pcb->eap.es_server.ea_peer, SRP_PSEUDO_ID, - SRP_PSEUDO_LEN) == 0 && - (pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN) * 3 / 4 < - sizeof (secbuf)) { - BZERO(&bs, sizeof (bs)); - plen = b64dec(&bs, - pcb->eap.es_server.ea_peer + SRP_PSEUDO_LEN, - pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN, - secbuf); - toffs = 0; - for (i = 0; i < 5; i++) { - pncrypt_setkey(toffs); - toffs -= 86400; - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - if (!DesDecrypt(secbuf, clear)) { - ppp_dbglog("no DES here; cannot decode " - "pseudonym"); - return; - } - id = *(unsigned char *)clear; - if (id + 1 <= plen && id + 9 > plen) - break; - } - if (plen % 8 == 0 && i < 5) { - /* - * Note that this is always shorter than the - * original stored string, so there's no need - * to realloc. - */ - if ((i = plen = *(unsigned char *)clear) > 7) - i = 7; - pcb->eap.es_server.ea_peerlen = plen; - dp = (unsigned char *)pcb->eap.es_server.ea_peer; - MEMCPY(dp, clear + 1, i); - plen -= i; - dp += i; - sp = secbuf + 8; - while (plen > 0) { - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - (void) DesDecrypt(sp, dp); - sp += 8; - dp += 8; - plen -= 8; - } - pcb->eap.es_server.ea_peer[ - pcb->eap.es_server.ea_peerlen] = '\0'; - ppp_dbglog("decoded pseudonym to \"%.*q\"", - pcb->eap.es_server.ea_peerlen, - pcb->eap.es_server.ea_peer); - } else { - ppp_dbglog("failed to decode real name"); - /* Stay in eapIdentfy state; requery */ - break; - } - } - /* Look up user in secrets database. */ - if (get_srp_secret(pcb->eap.es_unit, pcb->eap.es_server.ea_peer, - pcb->eap.es_server.ea_name, (char *)secbuf, 1) != 0) { - /* Set up default in case SRP entry is bad */ - pcb->eap.es_server.ea_state = eapMD5Chall; - /* Get t_confent based on index in srp-secrets */ - id = strtol((char *)secbuf, &cp, 10); - if (*cp++ != ':' || id < 0) - break; - if (id == 0) { - mytce.index = 0; - mytce.modulus.data = (u_char *)wkmodulus; - mytce.modulus.len = sizeof (wkmodulus); - mytce.generator.data = (u_char *)"\002"; - mytce.generator.len = 1; - tce = &mytce; - } else if ((tce = gettcid(id)) != NULL) { - /* - * Client will have to verify this modulus/ - * generator combination, and that will take - * a while. Lengthen the timeout here. - */ - if (pcb->settings.eap_timeout_time > 0 && - pcb->settings.eap_timeout_time < 30) - pcb->settings.eap_timeout_time = 30; - } else { - break; - } - if ((cp2 = strchr(cp, ':')) == NULL) - break; - *cp2++ = '\0'; - tpw.pebuf.name = pcb->eap.es_server.ea_peer; - tpw.pebuf.password.len = t_fromb64((char *)tpw.pwbuf, - cp); - tpw.pebuf.password.data = tpw.pwbuf; - tpw.pebuf.salt.len = t_fromb64((char *)tpw.saltbuf, - cp2); - tpw.pebuf.salt.data = tpw.saltbuf; - if ((ts = t_serveropenraw(&tpw.pebuf, tce)) == NULL) - break; - pcb->eap.es_server.ea_session = (void *)ts; - pcb->eap.es_server.ea_state = eapSRP1; - vals[0] = pcb->eap.es_server.ea_id + 1; - vals[1] = EAPT_SRP; - t_serveraddexdata(ts, vals, 2); - /* Generate B; must call before t_servergetkey() */ - t_servergenexp(ts); - break; - } + /* If we've got a pseudonym, try to decode to real name. */ + if (pcb->eap.es_server.ea_peerlen > SRP_PSEUDO_LEN && + strncmp(pcb->eap.es_server.ea_peer, SRP_PSEUDO_ID, + SRP_PSEUDO_LEN) == 0 && + (pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN) * 3 / 4 < + sizeof (secbuf)) { + BZERO(&bs, sizeof (bs)); + plen = b64dec(&bs, + pcb->eap.es_server.ea_peer + SRP_PSEUDO_LEN, + pcb->eap.es_server.ea_peerlen - SRP_PSEUDO_LEN, + secbuf); + toffs = 0; + for (i = 0; i < 5; i++) { + pncrypt_setkey(toffs); + toffs -= 86400; + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + if (!DesDecrypt(secbuf, clear)) { + ppp_dbglog("no DES here; cannot decode " + "pseudonym"); + return; + } + id = *(unsigned char *)clear; + if (id + 1 <= plen && id + 9 > plen) + break; + } + if (plen % 8 == 0 && i < 5) { + /* + * Note that this is always shorter than the + * original stored string, so there's no need + * to realloc. + */ + if ((i = plen = *(unsigned char *)clear) > 7) + i = 7; + pcb->eap.es_server.ea_peerlen = plen; + dp = (unsigned char *)pcb->eap.es_server.ea_peer; + MEMCPY(dp, clear + 1, i); + plen -= i; + dp += i; + sp = secbuf + 8; + while (plen > 0) { + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + (void) DesDecrypt(sp, dp); + sp += 8; + dp += 8; + plen -= 8; + } + pcb->eap.es_server.ea_peer[ + pcb->eap.es_server.ea_peerlen] = '\0'; + ppp_dbglog("decoded pseudonym to \"%.*q\"", + pcb->eap.es_server.ea_peerlen, + pcb->eap.es_server.ea_peer); + } else { + ppp_dbglog("failed to decode real name"); + /* Stay in eapIdentfy state; requery */ + break; + } + } + /* Look up user in secrets database. */ + if (get_srp_secret(pcb->eap.es_unit, pcb->eap.es_server.ea_peer, + pcb->eap.es_server.ea_name, (char *)secbuf, 1) != 0) { + /* Set up default in case SRP entry is bad */ + pcb->eap.es_server.ea_state = eapMD5Chall; + /* Get t_confent based on index in srp-secrets */ + id = strtol((char *)secbuf, &cp, 10); + if (*cp++ != ':' || id < 0) + break; + if (id == 0) { + mytce.index = 0; + mytce.modulus.data = (u_char *)wkmodulus; + mytce.modulus.len = sizeof (wkmodulus); + mytce.generator.data = (u_char *)"\002"; + mytce.generator.len = 1; + tce = &mytce; + } else if ((tce = gettcid(id)) != NULL) { + /* + * Client will have to verify this modulus/ + * generator combination, and that will take + * a while. Lengthen the timeout here. + */ + if (pcb->settings.eap_timeout_time > 0 && + pcb->settings.eap_timeout_time < 30) + pcb->settings.eap_timeout_time = 30; + } else { + break; + } + if ((cp2 = strchr(cp, ':')) == NULL) + break; + *cp2++ = '\0'; + tpw.pebuf.name = pcb->eap.es_server.ea_peer; + tpw.pebuf.password.len = t_fromb64((char *)tpw.pwbuf, + cp); + tpw.pebuf.password.data = tpw.pwbuf; + tpw.pebuf.salt.len = t_fromb64((char *)tpw.saltbuf, + cp2); + tpw.pebuf.salt.data = tpw.saltbuf; + if ((ts = t_serveropenraw(&tpw.pebuf, tce)) == NULL) + break; + pcb->eap.es_server.ea_session = (void *)ts; + pcb->eap.es_server.ea_state = eapSRP1; + vals[0] = pcb->eap.es_server.ea_id + 1; + vals[1] = EAPT_SRP; + t_serveraddexdata(ts, vals, 2); + /* Generate B; must call before t_servergetkey() */ + t_servergenexp(ts); + break; + } #endif /* USE_SRP */ - pcb->eap.es_server.ea_state = eapMD5Chall; - break; + pcb->eap.es_server.ea_state = eapMD5Chall; + break; - case eapSRP1: + case eapSRP1: #ifdef USE_SRP - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL && status != 0) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL && status != 0) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status == 1) { - pcb->eap.es_server.ea_state = eapMD5Chall; - } else if (status != 0 || pcb->eap.es_server.ea_session == NULL) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapSRP2; - } - break; - - case eapSRP2: + if (status == 1) { + pcb->eap.es_server.ea_state = eapMD5Chall; + } else if (status != 0 || pcb->eap.es_server.ea_session == NULL) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapSRP2; + } + break; + + case eapSRP2: #ifdef USE_SRP - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL && status != 0) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL && status != 0) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status != 0 || pcb->eap.es_server.ea_session == NULL) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapSRP3; - } - break; - - case eapSRP3: - case eapSRP4: + if (status != 0 || pcb->eap.es_server.ea_session == NULL) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapSRP3; + } + break; + + case eapSRP3: + case eapSRP4: #ifdef USE_SRP - ts = (struct t_server *)pcb->eap.es_server.ea_session; - if (ts != NULL && status != 0) { - t_serverclose(ts); - pcb->eap.es_server.ea_session = NULL; - pcb->eap.es_server.ea_skey = NULL; - } + ts = (struct t_server *)pcb->eap.es_server.ea_session; + if (ts != NULL && status != 0) { + t_serverclose(ts); + pcb->eap.es_server.ea_session = NULL; + pcb->eap.es_server.ea_skey = NULL; + } #endif /* USE_SRP */ - if (status != 0 || pcb->eap.es_server.ea_session == NULL) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapOpen; - } - break; - - case eapMD5Chall: - if (status != 0) { - pcb->eap.es_server.ea_state = eapBadAuth; - } else { - pcb->eap.es_server.ea_state = eapOpen; - } - break; - - default: - pcb->eap.es_server.ea_state = eapBadAuth; - break; - } - if (pcb->eap.es_server.ea_state == eapBadAuth) - eap_send_failure(pcb); + if (status != 0 || pcb->eap.es_server.ea_session == NULL) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapOpen; + } + break; + + case eapMD5Chall: + if (status != 0) { + pcb->eap.es_server.ea_state = eapBadAuth; + } else { + pcb->eap.es_server.ea_state = eapOpen; + } + break; + + default: + pcb->eap.es_server.ea_state = eapBadAuth; + break; + } + if (pcb->eap.es_server.ea_state == eapBadAuth) + eap_send_failure(pcb); } /* @@ -636,235 +636,235 @@ static void eap_figure_next_state(ppp_pcb *pcb, int status) { * type depends on current state. (Server operation) */ static void eap_send_request(ppp_pcb *pcb) { - struct pbuf *p; - u_char *outp; - u_char *lenloc; - int outlen; - int len; - const char *str; + struct pbuf *p; + u_char *outp; + u_char *lenloc; + int outlen; + int len; + const char *str; #ifdef USE_SRP - struct t_server *ts; - u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp; - int i, j; - struct b64state b64; - SHA1_CTX ctxt; + struct t_server *ts; + u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp; + int i, j; + struct b64state b64; + SHA1_CTX ctxt; #endif /* USE_SRP */ - /* Handle both initial auth and restart */ - if (pcb->eap.es_server.ea_state < eapIdentify && - pcb->eap.es_server.ea_state != eapInitial) { - pcb->eap.es_server.ea_state = eapIdentify; + /* Handle both initial auth and restart */ + if (pcb->eap.es_server.ea_state < eapIdentify && + pcb->eap.es_server.ea_state != eapInitial) { + pcb->eap.es_server.ea_state = eapIdentify; #if PPP_REMOTENAME - if (pcb->settings.explicit_remote && pcb->remote_name) { - /* - * If we already know the peer's - * unauthenticated name, then there's no - * reason to ask. Go to next state instead. - */ - int len = (int)strlen(pcb->remote_name); - if (len > MAXNAMELEN) { - len = MAXNAMELEN; - } - MEMCPY(pcb->eap.es_server.ea_peer, pcb->remote_name, len); - pcb->eap.es_server.ea_peer[len] = '\0'; - pcb->eap.es_server.ea_peerlen = len; - eap_figure_next_state(pcb, 0); - } + if (pcb->settings.explicit_remote && pcb->remote_name) { + /* + * If we already know the peer's + * unauthenticated name, then there's no + * reason to ask. Go to next state instead. + */ + int len = (int)strlen(pcb->remote_name); + if (len > MAXNAMELEN) { + len = MAXNAMELEN; + } + MEMCPY(pcb->eap.es_server.ea_peer, pcb->remote_name, len); + pcb->eap.es_server.ea_peer[len] = '\0'; + pcb->eap.es_server.ea_peerlen = len; + eap_figure_next_state(pcb, 0); + } #endif /* PPP_REMOTENAME */ - } - - if (pcb->settings.eap_max_transmits > 0 && - pcb->eap.es_server.ea_requests >= pcb->settings.eap_max_transmits) { - if (pcb->eap.es_server.ea_responses > 0) - ppp_error("EAP: too many Requests sent"); - else - ppp_error("EAP: no response to Requests"); - eap_send_failure(pcb); - return; - } - - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_CTRL_PBUF_MAX_SIZE), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_REQUEST, outp); - PUTCHAR(pcb->eap.es_server.ea_id, outp); - lenloc = outp; - INCPTR(2, outp); - - switch (pcb->eap.es_server.ea_state) { - case eapIdentify: - PUTCHAR(EAPT_IDENTITY, outp); - str = "Name"; - len = strlen(str); - MEMCPY(outp, str, len); - INCPTR(len, outp); - break; - - case eapMD5Chall: - PUTCHAR(EAPT_MD5CHAP, outp); - /* - * pick a random challenge length between - * EAP_MIN_CHALLENGE_LENGTH and EAP_MAX_CHALLENGE_LENGTH - */ - pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + - magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); - PUTCHAR(pcb->eap.es_challen, outp); - magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); - MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); - INCPTR(pcb->eap.es_challen, outp); - MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); - INCPTR(pcb->eap.es_server.ea_namelen, outp); - break; + } + + if (pcb->settings.eap_max_transmits > 0 && + pcb->eap.es_server.ea_requests >= pcb->settings.eap_max_transmits) { + if (pcb->eap.es_server.ea_responses > 0) + ppp_error("EAP: too many Requests sent"); + else + ppp_error("EAP: no response to Requests"); + eap_send_failure(pcb); + return; + } + + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_CTRL_PBUF_MAX_SIZE), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_REQUEST, outp); + PUTCHAR(pcb->eap.es_server.ea_id, outp); + lenloc = outp; + INCPTR(2, outp); + + switch (pcb->eap.es_server.ea_state) { + case eapIdentify: + PUTCHAR(EAPT_IDENTITY, outp); + str = "Name"; + len = strlen(str); + MEMCPY(outp, str, len); + INCPTR(len, outp); + break; + + case eapMD5Chall: + PUTCHAR(EAPT_MD5CHAP, outp); + /* + * pick a random challenge length between + * EAP_MIN_CHALLENGE_LENGTH and EAP_MAX_CHALLENGE_LENGTH + */ + pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + + magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); + PUTCHAR(pcb->eap.es_challen, outp); + magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); + MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); + INCPTR(pcb->eap.es_challen, outp); + MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); + INCPTR(pcb->eap.es_server.ea_namelen, outp); + break; #ifdef USE_SRP - case eapSRP1: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_CHALLENGE, outp); - - PUTCHAR(pcb->eap.es_server.ea_namelen, outp); - MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); - INCPTR(pcb->eap.es_server.ea_namelen, outp); - - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - PUTCHAR(ts->s.len, outp); - MEMCPY(outp, ts->s.data, ts->s.len); - INCPTR(ts->s.len, outp); - - if (ts->g.len == 1 && ts->g.data[0] == 2) { - PUTCHAR(0, outp); - } else { - PUTCHAR(ts->g.len, outp); - MEMCPY(outp, ts->g.data, ts->g.len); - INCPTR(ts->g.len, outp); - } - - if (ts->n.len != sizeof (wkmodulus) || - BCMP(ts->n.data, wkmodulus, sizeof (wkmodulus)) != 0) { - MEMCPY(outp, ts->n.data, ts->n.len); - INCPTR(ts->n.len, outp); - } - break; - - case eapSRP2: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_SKEY, outp); - - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - MEMCPY(outp, ts->B.data, ts->B.len); - INCPTR(ts->B.len, outp); - break; - - case eapSRP3: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_SVALIDATOR, outp); - PUTLONG(SRPVAL_EBIT, outp); - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - MEMCPY(outp, t_serverresponse(ts), SHA_DIGESTSIZE); - INCPTR(SHA_DIGESTSIZE, outp); - - if (pncrypt_setkey(0)) { - /* Generate pseudonym */ - optr = outp; - cp = (unsigned char *)pcb->eap.es_server.ea_peer; - if ((j = i = pcb->eap.es_server.ea_peerlen) > 7) - j = 7; - clear[0] = i; - MEMCPY(clear + 1, cp, j); - i -= j; - cp += j; - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - if (!DesEncrypt(clear, cipher)) { - ppp_dbglog("no DES here; not generating pseudonym"); - break; - } - BZERO(&b64, sizeof (b64)); - outp++; /* space for pseudonym length */ - outp += b64enc(&b64, cipher, 8, outp); - while (i >= 8) { - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - (void) DesEncrypt(cp, cipher); - outp += b64enc(&b64, cipher, 8, outp); - cp += 8; - i -= 8; - } - if (i > 0) { - MEMCPY(clear, cp, i); - cp += i; - magic_random_bytes(cp, 8-i); - /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ - (void) DesEncrypt(clear, cipher); - outp += b64enc(&b64, cipher, 8, outp); - } - outp += b64flush(&b64, outp); - - /* Set length and pad out to next 20 octet boundary */ - i = outp - optr - 1; - *optr = i; - i %= SHA_DIGESTSIZE; - if (i != 0) { - magic_random_bytes(outp, SHA_DIGESTSIZE-i); - INCPTR(SHA_DIGESTSIZE-i, outp); - } - - /* Obscure the pseudonym with SHA1 hash */ - SHA1Init(&ctxt); - SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); - SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, - pcb->eap.es_server.ea_peerlen); - while (optr < outp) { - SHA1Final(dig, &ctxt); - cp = dig; - while (cp < dig + SHA_DIGESTSIZE) - *optr++ ^= *cp++; - SHA1Init(&ctxt); - SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); - SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, optr - SHA_DIGESTSIZE, - SHA_DIGESTSIZE); - } - } - break; - - case eapSRP4: - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_LWRECHALLENGE, outp); - pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + - magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); - magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); - MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); - INCPTR(pcb->eap.es_challen, outp); - break; + case eapSRP1: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_CHALLENGE, outp); + + PUTCHAR(pcb->eap.es_server.ea_namelen, outp); + MEMCPY(outp, pcb->eap.es_server.ea_name, pcb->eap.es_server.ea_namelen); + INCPTR(pcb->eap.es_server.ea_namelen, outp); + + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + PUTCHAR(ts->s.len, outp); + MEMCPY(outp, ts->s.data, ts->s.len); + INCPTR(ts->s.len, outp); + + if (ts->g.len == 1 && ts->g.data[0] == 2) { + PUTCHAR(0, outp); + } else { + PUTCHAR(ts->g.len, outp); + MEMCPY(outp, ts->g.data, ts->g.len); + INCPTR(ts->g.len, outp); + } + + if (ts->n.len != sizeof (wkmodulus) || + BCMP(ts->n.data, wkmodulus, sizeof (wkmodulus)) != 0) { + MEMCPY(outp, ts->n.data, ts->n.len); + INCPTR(ts->n.len, outp); + } + break; + + case eapSRP2: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_SKEY, outp); + + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + MEMCPY(outp, ts->B.data, ts->B.len); + INCPTR(ts->B.len, outp); + break; + + case eapSRP3: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_SVALIDATOR, outp); + PUTLONG(SRPVAL_EBIT, outp); + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + MEMCPY(outp, t_serverresponse(ts), SHA_DIGESTSIZE); + INCPTR(SHA_DIGESTSIZE, outp); + + if (pncrypt_setkey(0)) { + /* Generate pseudonym */ + optr = outp; + cp = (unsigned char *)pcb->eap.es_server.ea_peer; + if ((j = i = pcb->eap.es_server.ea_peerlen) > 7) + j = 7; + clear[0] = i; + MEMCPY(clear + 1, cp, j); + i -= j; + cp += j; + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + if (!DesEncrypt(clear, cipher)) { + ppp_dbglog("no DES here; not generating pseudonym"); + break; + } + BZERO(&b64, sizeof (b64)); + outp++; /* space for pseudonym length */ + outp += b64enc(&b64, cipher, 8, outp); + while (i >= 8) { + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + (void) DesEncrypt(cp, cipher); + outp += b64enc(&b64, cipher, 8, outp); + cp += 8; + i -= 8; + } + if (i > 0) { + MEMCPY(clear, cp, i); + cp += i; + magic_random_bytes(cp, 8-i); + /* FIXME: if we want to do SRP, we need to find a way to pass the PolarSSL des_context instead of using static memory */ + (void) DesEncrypt(clear, cipher); + outp += b64enc(&b64, cipher, 8, outp); + } + outp += b64flush(&b64, outp); + + /* Set length and pad out to next 20 octet boundary */ + i = outp - optr - 1; + *optr = i; + i %= SHA_DIGESTSIZE; + if (i != 0) { + magic_random_bytes(outp, SHA_DIGESTSIZE-i); + INCPTR(SHA_DIGESTSIZE-i, outp); + } + + /* Obscure the pseudonym with SHA1 hash */ + SHA1Init(&ctxt); + SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); + SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, + pcb->eap.es_server.ea_peerlen); + while (optr < outp) { + SHA1Final(dig, &ctxt); + cp = dig; + while (cp < dig + SHA_DIGESTSIZE) + *optr++ ^= *cp++; + SHA1Init(&ctxt); + SHA1Update(&ctxt, &pcb->eap.es_server.ea_id, 1); + SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, optr - SHA_DIGESTSIZE, + SHA_DIGESTSIZE); + } + } + break; + + case eapSRP4: + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_LWRECHALLENGE, outp); + pcb->eap.es_challen = EAP_MIN_CHALLENGE_LENGTH + + magic_pow(EAP_MIN_MAX_POWER_OF_TWO_CHALLENGE_LENGTH); + magic_random_bytes(pcb->eap.es_challenge, pcb->eap.es_challen); + MEMCPY(outp, pcb->eap.es_challenge, pcb->eap.es_challen); + INCPTR(pcb->eap.es_challen, outp); + break; #endif /* USE_SRP */ - default: - return; - } + default: + return; + } - outlen = (outp - (unsigned char*)p->payload) - PPP_HDRLEN; - PUTSHORT(outlen, lenloc); + outlen = (outp - (unsigned char*)p->payload) - PPP_HDRLEN; + PUTSHORT(outlen, lenloc); - pbuf_realloc(p, outlen + PPP_HDRLEN); - ppp_write(pcb, p); + pbuf_realloc(p, outlen + PPP_HDRLEN); + ppp_write(pcb, p); - pcb->eap.es_server.ea_requests++; + pcb->eap.es_server.ea_requests++; - if (pcb->settings.eap_timeout_time > 0) - TIMEOUT(eap_server_timeout, pcb, pcb->settings.eap_timeout_time); + if (pcb->settings.eap_timeout_time > 0) + TIMEOUT(eap_server_timeout, pcb, pcb->settings.eap_timeout_time); } /* @@ -875,23 +875,23 @@ static void eap_send_request(ppp_pcb *pcb) { */ void eap_authpeer(ppp_pcb *pcb, const char *localname) { - /* Save the name we're given. */ - pcb->eap.es_server.ea_name = localname; - pcb->eap.es_server.ea_namelen = strlen(localname); + /* Save the name we're given. */ + pcb->eap.es_server.ea_name = localname; + pcb->eap.es_server.ea_namelen = strlen(localname); - pcb->eap.es_savedtime = pcb->settings.eap_timeout_time; + pcb->eap.es_savedtime = pcb->settings.eap_timeout_time; - /* Lower layer up yet? */ - if (pcb->eap.es_server.ea_state == eapInitial || - pcb->eap.es_server.ea_state == eapPending) { - pcb->eap.es_server.ea_state = eapPending; - return; - } + /* Lower layer up yet? */ + if (pcb->eap.es_server.ea_state == eapInitial || + pcb->eap.es_server.ea_state == eapPending) { + pcb->eap.es_server.ea_state = eapPending; + return; + } - pcb->eap.es_server.ea_state = eapPending; + pcb->eap.es_server.ea_state = eapPending; - /* ID number not updated here intentionally; hashed into M1 */ - eap_send_request(pcb); + /* ID number not updated here intentionally; hashed into M1 */ + eap_send_request(pcb); } /* @@ -899,13 +899,13 @@ void eap_authpeer(ppp_pcb *pcb, const char *localname) { * expired. */ static void eap_server_timeout(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (!eap_server_active(pcb)) - return; + if (!eap_server_active(pcb)) + return; - /* EAP ID number must not change on timeout. */ - eap_send_request(pcb); + /* EAP ID number must not change on timeout. */ + eap_send_request(pcb); } /* @@ -914,30 +914,30 @@ static void eap_server_timeout(void *arg) { * will restart the timer. If it fails, then the link is dropped. */ static void eap_rechallenge(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (pcb->eap.es_server.ea_state != eapOpen && - pcb->eap.es_server.ea_state != eapSRP4) - return; + if (pcb->eap.es_server.ea_state != eapOpen && + pcb->eap.es_server.ea_state != eapSRP4) + return; - pcb->eap.es_server.ea_requests = 0; - pcb->eap.es_server.ea_state = eapIdentify; - eap_figure_next_state(pcb, 0); - pcb->eap.es_server.ea_id++; - eap_send_request(pcb); + pcb->eap.es_server.ea_requests = 0; + pcb->eap.es_server.ea_state = eapIdentify; + eap_figure_next_state(pcb, 0); + pcb->eap.es_server.ea_id++; + eap_send_request(pcb); } static void srp_lwrechallenge(void *arg) { - ppp_pcb *pcb = (ppp_pcb*)arg; + ppp_pcb *pcb = (ppp_pcb*)arg; - if (pcb->eap.es_server.ea_state != eapOpen || - pcb->eap.es_server.ea_type != EAPT_SRP) - return; + if (pcb->eap.es_server.ea_state != eapOpen || + pcb->eap.es_server.ea_type != EAPT_SRP) + return; - pcb->eap.es_server.ea_requests = 0; - pcb->eap.es_server.ea_state = eapSRP4; - pcb->eap.es_server.ea_id++; - eap_send_request(pcb); + pcb->eap.es_server.ea_requests = 0; + pcb->eap.es_server.ea_state = eapSRP4; + pcb->eap.es_server.ea_id++; + eap_send_request(pcb); } #endif /* PPP_SERVER */ @@ -950,9 +950,9 @@ static void srp_lwrechallenge(void *arg) { * thing. */ static void eap_lowerup(ppp_pcb *pcb) { - pcb->eap.es_client.ea_state = eapClosed; + pcb->eap.es_client.ea_state = eapClosed; #if PPP_SERVER - pcb->eap.es_server.ea_state = eapClosed; + pcb->eap.es_server.ea_state = eapClosed; #endif /* PPP_SERVER */ } @@ -963,28 +963,28 @@ static void eap_lowerup(ppp_pcb *pcb) { */ static void eap_lowerdown(ppp_pcb *pcb) { - if (eap_client_active(pcb) && pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } + if (eap_client_active(pcb) && pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } #if PPP_SERVER - if (eap_server_active(pcb)) { - if (pcb->settings.eap_timeout_time > 0) { - UNTIMEOUT(eap_server_timeout, pcb); - } - } else { - if ((pcb->eap.es_server.ea_state == eapOpen || - pcb->eap.es_server.ea_state == eapSRP4) && - pcb->eap.es_rechallenge > 0) { - UNTIMEOUT(eap_rechallenge, (void *)pcb); - } - if (pcb->eap.es_server.ea_state == eapOpen && - pcb->eap.es_lwrechallenge > 0) { - UNTIMEOUT(srp_lwrechallenge, (void *)pcb); - } - } - - pcb->eap.es_client.ea_state = pcb->eap.es_server.ea_state = eapInitial; - pcb->eap.es_client.ea_requests = pcb->eap.es_server.ea_requests = 0; + if (eap_server_active(pcb)) { + if (pcb->settings.eap_timeout_time > 0) { + UNTIMEOUT(eap_server_timeout, pcb); + } + } else { + if ((pcb->eap.es_server.ea_state == eapOpen || + pcb->eap.es_server.ea_state == eapSRP4) && + pcb->eap.es_rechallenge > 0) { + UNTIMEOUT(eap_rechallenge, (void *)pcb); + } + if (pcb->eap.es_server.ea_state == eapOpen && + pcb->eap.es_lwrechallenge > 0) { + UNTIMEOUT(srp_lwrechallenge, (void *)pcb); + } + } + + pcb->eap.es_client.ea_state = pcb->eap.es_server.ea_state = eapInitial; + pcb->eap.es_client.ea_requests = pcb->eap.es_server.ea_requests = 0; #endif /* PPP_SERVER */ } @@ -996,87 +996,87 @@ static void eap_lowerdown(ppp_pcb *pcb) { */ static void eap_protrej(ppp_pcb *pcb) { - if (eap_client_active(pcb)) { - ppp_error("EAP authentication failed due to Protocol-Reject"); - auth_withpeer_fail(pcb, PPP_EAP); - } + if (eap_client_active(pcb)) { + ppp_error("EAP authentication failed due to Protocol-Reject"); + auth_withpeer_fail(pcb, PPP_EAP); + } #if PPP_SERVER - if (eap_server_active(pcb)) { - ppp_error("EAP authentication of peer failed on Protocol-Reject"); - auth_peer_fail(pcb, PPP_EAP); - } + if (eap_server_active(pcb)) { + ppp_error("EAP authentication of peer failed on Protocol-Reject"); + auth_peer_fail(pcb, PPP_EAP); + } #endif /* PPP_SERVER */ - eap_lowerdown(pcb); + eap_lowerdown(pcb); } /* * Format and send a regular EAP Response message. */ static void eap_send_response(ppp_pcb *pcb, u_char id, u_char typenum, const u_char *str, int lenstr) { - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + sizeof (u_char) + lenstr; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(typenum, outp); - if (lenstr > 0) { - MEMCPY(outp, str, lenstr); - } - - ppp_write(pcb, p); + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + sizeof (u_char) + lenstr; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(typenum, outp); + if (lenstr > 0) { + MEMCPY(outp, str, lenstr); + } + + ppp_write(pcb, p); } /* * Format and send an MD5-Challenge EAP Response message. */ static void eap_chap_response(ppp_pcb *pcb, u_char id, u_char *hash, const char *name, int namelen) { - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + MD5_SIGNATURE_SIZE + - namelen; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_MD5CHAP, outp); - PUTCHAR(MD5_SIGNATURE_SIZE, outp); - MEMCPY(outp, hash, MD5_SIGNATURE_SIZE); - INCPTR(MD5_SIGNATURE_SIZE, outp); - if (namelen > 0) { - MEMCPY(outp, name, namelen); - } - - ppp_write(pcb, p); + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + MD5_SIGNATURE_SIZE + + namelen; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_MD5CHAP, outp); + PUTCHAR(MD5_SIGNATURE_SIZE, outp); + MEMCPY(outp, hash, MD5_SIGNATURE_SIZE); + INCPTR(MD5_SIGNATURE_SIZE, outp); + if (namelen > 0) { + MEMCPY(outp, name, namelen); + } + + ppp_write(pcb, p); } #ifdef USE_SRP @@ -1091,35 +1091,35 @@ u_char subtypenum; u_char *str; int lenstr; { - ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + lenstr; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(subtypenum, outp); - if (lenstr > 0) { - MEMCPY(outp, str, lenstr); - } - - ppp_write(pcb, p); + ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + lenstr; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(subtypenum, outp); + if (lenstr > 0) { + MEMCPY(outp, str, lenstr); + } + + ppp_write(pcb, p); } /* @@ -1132,118 +1132,118 @@ u_char id; u32_t flags; u_char *str; { - ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + sizeof (u32_t) + - SHA_DIGESTSIZE; - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_SRP, outp); - PUTCHAR(EAPSRP_CVALIDATOR, outp); - PUTLONG(flags, outp); - MEMCPY(outp, str, SHA_DIGESTSIZE); - - ppp_write(pcb, p); + ppp_pcb *pcb = &ppp_pcb_list[pcb->eap.es_unit]; + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char) + sizeof (u32_t) + + SHA_DIGESTSIZE; + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_SRP, outp); + PUTCHAR(EAPSRP_CVALIDATOR, outp); + PUTLONG(flags, outp); + MEMCPY(outp, str, SHA_DIGESTSIZE); + + ppp_write(pcb, p); } #endif /* USE_SRP */ static void eap_send_nak(ppp_pcb *pcb, u_char id, u_char type) { - struct pbuf *p; - u_char *outp; - int msglen; - - msglen = EAP_HEADERLEN + 2 * sizeof (u_char); - p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); - if(NULL == p) - return; - if(p->tot_len != p->len) { - pbuf_free(p); - return; - } - - outp = (u_char*)p->payload; - - MAKEHEADER(outp, PPP_EAP); - - PUTCHAR(EAP_RESPONSE, outp); - PUTCHAR(id, outp); - pcb->eap.es_client.ea_id = id; - PUTSHORT(msglen, outp); - PUTCHAR(EAPT_NAK, outp); - PUTCHAR(type, outp); - - ppp_write(pcb, p); + struct pbuf *p; + u_char *outp; + int msglen; + + msglen = EAP_HEADERLEN + 2 * sizeof (u_char); + p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN + msglen), PPP_CTRL_PBUF_TYPE); + if(NULL == p) + return; + if(p->tot_len != p->len) { + pbuf_free(p); + return; + } + + outp = (u_char*)p->payload; + + MAKEHEADER(outp, PPP_EAP); + + PUTCHAR(EAP_RESPONSE, outp); + PUTCHAR(id, outp); + pcb->eap.es_client.ea_id = id; + PUTSHORT(msglen, outp); + PUTCHAR(EAPT_NAK, outp); + PUTCHAR(type, outp); + + ppp_write(pcb, p); } #ifdef USE_SRP static char * name_of_pn_file() { - char *user, *path, *file; - struct passwd *pw; - size_t pl; - static bool pnlogged = 0; - - pw = getpwuid(getuid()); - if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0) { - errno = EINVAL; - return (NULL); - } - file = _PATH_PSEUDONYM; - pl = strlen(user) + strlen(file) + 2; - path = malloc(pl); - if (path == NULL) - return (NULL); - (void) slprintf(path, pl, "%s/%s", user, file); - if (!pnlogged) { - ppp_dbglog("pseudonym file: %s", path); - pnlogged = 1; - } - return (path); + char *user, *path, *file; + struct passwd *pw; + size_t pl; + static bool pnlogged = 0; + + pw = getpwuid(getuid()); + if (pw == NULL || (user = pw->pw_dir) == NULL || user[0] == 0) { + errno = EINVAL; + return (NULL); + } + file = _PATH_PSEUDONYM; + pl = strlen(user) + strlen(file) + 2; + path = malloc(pl); + if (path == NULL) + return (NULL); + (void) slprintf(path, pl, "%s/%s", user, file); + if (!pnlogged) { + ppp_dbglog("pseudonym file: %s", path); + pnlogged = 1; + } + return (path); } static int open_pn_file(modebits) mode_t modebits; { - char *path; - int fd, err; - - if ((path = name_of_pn_file()) == NULL) - return (-1); - fd = open(path, modebits, S_IRUSR | S_IWUSR); - err = errno; - free(path); - errno = err; - return (fd); + char *path; + int fd, err; + + if ((path = name_of_pn_file()) == NULL) + return (-1); + fd = open(path, modebits, S_IRUSR | S_IWUSR); + err = errno; + free(path); + errno = err; + return (fd); } static void remove_pn_file() { - char *path; + char *path; - if ((path = name_of_pn_file()) != NULL) { - (void) unlink(path); - (void) free(path); - } + if ((path = name_of_pn_file()) != NULL) { + (void) unlink(path); + (void) free(path); + } } static void @@ -1252,56 +1252,56 @@ eap_state *esp; u_char *inp; int len, id; { - u_char val; - u_char *datp, *digp; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; - int dsize, fd, olen = len; - - /* - * Do the decoding by working backwards. This eliminates the need - * to save the decoded output in a separate buffer. - */ - val = id; - while (len > 0) { - if ((dsize = len % SHA_DIGESTSIZE) == 0) - dsize = SHA_DIGESTSIZE; - len -= dsize; - datp = inp + len; - SHA1Init(&ctxt); - SHA1Update(&ctxt, &val, 1); - SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, SESSION_KEY_LEN); - if (len > 0) { - SHA1Update(&ctxt, datp, SHA_DIGESTSIZE); - } else { - SHA1Update(&ctxt, pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - } - SHA1Final(dig, &ctxt); - for (digp = dig; digp < dig + SHA_DIGESTSIZE; digp++) - *datp++ ^= *digp; - } - - /* Now check that the result is sane */ - if (olen <= 0 || *inp + 1 > olen) { - ppp_dbglog("EAP: decoded pseudonym is unusable <%.*B>", olen, inp); - return; - } - - /* Save it away */ - fd = open_pn_file(O_WRONLY | O_CREAT | O_TRUNC); - if (fd < 0) { - ppp_dbglog("EAP: error saving pseudonym: %m"); - return; - } - len = write(fd, inp + 1, *inp); - if (close(fd) != -1 && len == *inp) { - ppp_dbglog("EAP: saved pseudonym"); - pcb->eap.es_usedpseudo = 0; - } else { - ppp_dbglog("EAP: failed to save pseudonym"); - remove_pn_file(); - } + u_char val; + u_char *datp, *digp; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; + int dsize, fd, olen = len; + + /* + * Do the decoding by working backwards. This eliminates the need + * to save the decoded output in a separate buffer. + */ + val = id; + while (len > 0) { + if ((dsize = len % SHA_DIGESTSIZE) == 0) + dsize = SHA_DIGESTSIZE; + len -= dsize; + datp = inp + len; + SHA1Init(&ctxt); + SHA1Update(&ctxt, &val, 1); + SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, SESSION_KEY_LEN); + if (len > 0) { + SHA1Update(&ctxt, datp, SHA_DIGESTSIZE); + } else { + SHA1Update(&ctxt, pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + } + SHA1Final(dig, &ctxt); + for (digp = dig; digp < dig + SHA_DIGESTSIZE; digp++) + *datp++ ^= *digp; + } + + /* Now check that the result is sane */ + if (olen <= 0 || *inp + 1 > olen) { + ppp_dbglog("EAP: decoded pseudonym is unusable <%.*B>", olen, inp); + return; + } + + /* Save it away */ + fd = open_pn_file(O_WRONLY | O_CREAT | O_TRUNC); + if (fd < 0) { + ppp_dbglog("EAP: error saving pseudonym: %m"); + return; + } + len = write(fd, inp + 1, *inp); + if (close(fd) != -1 && len == *inp) { + ppp_dbglog("EAP: saved pseudonym"); + pcb->eap.es_usedpseudo = 0; + } else { + ppp_dbglog("EAP: failed to save pseudonym"); + remove_pn_file(); + } } #endif /* USE_SRP */ @@ -1309,412 +1309,412 @@ int len, id; * eap_request - Receive EAP Request message (client mode). */ static void eap_request(ppp_pcb *pcb, u_char *inp, int id, int len) { - u_char typenum; - u_char vallen; - int secret_len; - char secret[MAXSECRETLEN]; - char rhostname[MAXNAMELEN]; - lwip_md5_context mdContext; - u_char hash[MD5_SIGNATURE_SIZE]; + u_char typenum; + u_char vallen; + int secret_len; + char secret[MAXSECRETLEN]; + char rhostname[MAXNAMELEN]; + lwip_md5_context mdContext; + u_char hash[MD5_SIGNATURE_SIZE]; #ifdef USE_SRP - struct t_client *tc; - struct t_num sval, gval, Nval, *Ap, Bval; - u_char vals[2]; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; - int fd; + struct t_client *tc; + struct t_num sval, gval, Nval, *Ap, Bval; + u_char vals[2]; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; + int fd; #endif /* USE_SRP */ - /* - * Note: we update es_client.ea_id *only if* a Response - * message is being generated. Otherwise, we leave it the - * same for duplicate detection purposes. - */ - - pcb->eap.es_client.ea_requests++; - if (pcb->settings.eap_allow_req != 0 && - pcb->eap.es_client.ea_requests > pcb->settings.eap_allow_req) { - ppp_info("EAP: received too many Request messages"); - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } - auth_withpeer_fail(pcb, PPP_EAP); - return; - } - - if (len <= 0) { - ppp_error("EAP: empty Request message discarded"); - return; - } - - GETCHAR(typenum, inp); - len--; - - switch (typenum) { - case EAPT_IDENTITY: - if (len > 0) - ppp_info("EAP: Identity prompt \"%.*q\"", len, inp); + /* + * Note: we update es_client.ea_id *only if* a Response + * message is being generated. Otherwise, we leave it the + * same for duplicate detection purposes. + */ + + pcb->eap.es_client.ea_requests++; + if (pcb->settings.eap_allow_req != 0 && + pcb->eap.es_client.ea_requests > pcb->settings.eap_allow_req) { + ppp_info("EAP: received too many Request messages"); + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } + auth_withpeer_fail(pcb, PPP_EAP); + return; + } + + if (len <= 0) { + ppp_error("EAP: empty Request message discarded"); + return; + } + + GETCHAR(typenum, inp); + len--; + + switch (typenum) { + case EAPT_IDENTITY: + if (len > 0) + ppp_info("EAP: Identity prompt \"%.*q\"", len, inp); #ifdef USE_SRP - if (pcb->eap.es_usepseudo && - (pcb->eap.es_usedpseudo == 0 || - (pcb->eap.es_usedpseudo == 1 && - id == pcb->eap.es_client.ea_id))) { - pcb->eap.es_usedpseudo = 1; - /* Try to get a pseudonym */ - if ((fd = open_pn_file(O_RDONLY)) >= 0) { - strcpy(rhostname, SRP_PSEUDO_ID); - len = read(fd, rhostname + SRP_PSEUDO_LEN, - sizeof (rhostname) - SRP_PSEUDO_LEN); - /* XXX NAI unsupported */ - if (len > 0) { - eap_send_response(pcb, id, typenum, - rhostname, len + SRP_PSEUDO_LEN); - } - (void) close(fd); - if (len > 0) - break; - } - } - /* Stop using pseudonym now. */ - if (pcb->eap.es_usepseudo && pcb->eap.es_usedpseudo != 2) { - remove_pn_file(); - pcb->eap.es_usedpseudo = 2; - } + if (pcb->eap.es_usepseudo && + (pcb->eap.es_usedpseudo == 0 || + (pcb->eap.es_usedpseudo == 1 && + id == pcb->eap.es_client.ea_id))) { + pcb->eap.es_usedpseudo = 1; + /* Try to get a pseudonym */ + if ((fd = open_pn_file(O_RDONLY)) >= 0) { + strcpy(rhostname, SRP_PSEUDO_ID); + len = read(fd, rhostname + SRP_PSEUDO_LEN, + sizeof (rhostname) - SRP_PSEUDO_LEN); + /* XXX NAI unsupported */ + if (len > 0) { + eap_send_response(pcb, id, typenum, + rhostname, len + SRP_PSEUDO_LEN); + } + (void) close(fd); + if (len > 0) + break; + } + } + /* Stop using pseudonym now. */ + if (pcb->eap.es_usepseudo && pcb->eap.es_usedpseudo != 2) { + remove_pn_file(); + pcb->eap.es_usedpseudo = 2; + } #endif /* USE_SRP */ - eap_send_response(pcb, id, typenum, (const u_char*)pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - break; - - case EAPT_NOTIFICATION: - if (len > 0) - ppp_info("EAP: Notification \"%.*q\"", len, inp); - eap_send_response(pcb, id, typenum, NULL, 0); - break; - - case EAPT_NAK: - /* - * Avoid the temptation to send Response Nak in reply - * to Request Nak here. It can only lead to trouble. - */ - ppp_warn("EAP: unexpected Nak in Request; ignored"); - /* Return because we're waiting for something real. */ - return; - - case EAPT_MD5CHAP: - if (len < 1) { - ppp_error("EAP: received MD5-Challenge with no data"); - /* Bogus request; wait for something real. */ - return; - } - GETCHAR(vallen, inp); - len--; - if (vallen < 8 || vallen > len) { - ppp_error("EAP: MD5-Challenge with bad length %d (8..%d)", - vallen, len); - /* Try something better. */ - eap_send_nak(pcb, id, EAPT_SRP); - break; - } - - /* Not so likely to happen. */ - if (vallen >= len + sizeof (rhostname)) { - ppp_dbglog("EAP: trimming really long peer name down"); - MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); - rhostname[sizeof (rhostname) - 1] = '\0'; - } else { - MEMCPY(rhostname, inp + vallen, len - vallen); - rhostname[len - vallen] = '\0'; - } + eap_send_response(pcb, id, typenum, (const u_char*)pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + break; + + case EAPT_NOTIFICATION: + if (len > 0) + ppp_info("EAP: Notification \"%.*q\"", len, inp); + eap_send_response(pcb, id, typenum, NULL, 0); + break; + + case EAPT_NAK: + /* + * Avoid the temptation to send Response Nak in reply + * to Request Nak here. It can only lead to trouble. + */ + ppp_warn("EAP: unexpected Nak in Request; ignored"); + /* Return because we're waiting for something real. */ + return; + + case EAPT_MD5CHAP: + if (len < 1) { + ppp_error("EAP: received MD5-Challenge with no data"); + /* Bogus request; wait for something real. */ + return; + } + GETCHAR(vallen, inp); + len--; + if (vallen < 8 || vallen > len) { + ppp_error("EAP: MD5-Challenge with bad length %d (8..%d)", + vallen, len); + /* Try something better. */ + eap_send_nak(pcb, id, EAPT_SRP); + break; + } + + /* Not so likely to happen. */ + if (vallen >= len + sizeof (rhostname)) { + ppp_dbglog("EAP: trimming really long peer name down"); + MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); + rhostname[sizeof (rhostname) - 1] = '\0'; + } else { + MEMCPY(rhostname, inp + vallen, len - vallen); + rhostname[len - vallen] = '\0'; + } #if PPP_REMOTENAME - /* In case the remote doesn't give us his name. */ - if (pcb->settings.explicit_remote || - (pcb->settings.remote_name[0] != '\0' && vallen == len)) - strlcpy(rhostname, pcb->settings.remote_name, sizeof (rhostname)); + /* In case the remote doesn't give us his name. */ + if (pcb->settings.explicit_remote || + (pcb->settings.remote_name[0] != '\0' && vallen == len)) + strlcpy(rhostname, pcb->settings.remote_name, sizeof (rhostname)); #endif /* PPP_REMOTENAME */ - /* - * Get the secret for authenticating ourselves with - * the specified host. - */ - if (!get_secret(pcb, pcb->eap.es_client.ea_name, - rhostname, secret, &secret_len, 0)) { - ppp_dbglog("EAP: no MD5 secret for auth to %q", rhostname); - eap_send_nak(pcb, id, EAPT_SRP); - break; - } - lwip_md5_init(&mdContext); - lwip_md5_starts(&mdContext); - typenum = id; - lwip_md5_update(&mdContext, &typenum, 1); - lwip_md5_update(&mdContext, (u_char *)secret, secret_len); - BZERO(secret, sizeof (secret)); - lwip_md5_update(&mdContext, inp, vallen); - lwip_md5_finish(&mdContext, hash); - lwip_md5_free(&mdContext); - eap_chap_response(pcb, id, hash, pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - break; + /* + * Get the secret for authenticating ourselves with + * the specified host. + */ + if (!get_secret(pcb, pcb->eap.es_client.ea_name, + rhostname, secret, &secret_len, 0)) { + ppp_dbglog("EAP: no MD5 secret for auth to %q", rhostname); + eap_send_nak(pcb, id, EAPT_SRP); + break; + } + lwip_md5_init(&mdContext); + lwip_md5_starts(&mdContext); + typenum = id; + lwip_md5_update(&mdContext, &typenum, 1); + lwip_md5_update(&mdContext, (u_char *)secret, secret_len); + BZERO(secret, sizeof (secret)); + lwip_md5_update(&mdContext, inp, vallen); + lwip_md5_finish(&mdContext, hash); + lwip_md5_free(&mdContext); + eap_chap_response(pcb, id, hash, pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + break; #ifdef USE_SRP - case EAPT_SRP: - if (len < 1) { - ppp_error("EAP: received empty SRP Request"); - /* Bogus request; wait for something real. */ - return; - } - - /* Get subtype */ - GETCHAR(vallen, inp); - len--; - switch (vallen) { - case EAPSRP_CHALLENGE: - tc = NULL; - if (pcb->eap.es_client.ea_session != NULL) { - tc = (struct t_client *)pcb->eap.es_client. - ea_session; - /* - * If this is a new challenge, then start - * over with a new client session context. - * Otherwise, just resend last response. - */ - if (id != pcb->eap.es_client.ea_id) { - t_clientclose(tc); - pcb->eap.es_client.ea_session = NULL; - tc = NULL; - } - } - /* No session key just yet */ - pcb->eap.es_client.ea_skey = NULL; - if (tc == NULL) { - int rhostnamelen; - - GETCHAR(vallen, inp); - len--; - if (vallen >= len) { - ppp_error("EAP: badly-formed SRP Challenge" - " (name)"); - /* Ignore badly-formed messages */ - return; - } - MEMCPY(rhostname, inp, vallen); - rhostname[vallen] = '\0'; - INCPTR(vallen, inp); - len -= vallen; - - /* - * In case the remote doesn't give us his name, - * use configured name. - */ - if (explicit_remote || - (remote_name[0] != '\0' && vallen == 0)) { - strlcpy(rhostname, remote_name, - sizeof (rhostname)); - } - - rhostnamelen = (int)strlen(rhostname); - if (rhostnamelen > MAXNAMELEN) { - rhostnamelen = MAXNAMELEN; - } - MEMCPY(pcb->eap.es_client.ea_peer, rhostname, rhostnamelen); - pcb->eap.es_client.ea_peer[rhostnamelen] = '\0'; - pcb->eap.es_client.ea_peerlen = rhostnamelen; - - GETCHAR(vallen, inp); - len--; - if (vallen >= len) { - ppp_error("EAP: badly-formed SRP Challenge" - " (s)"); - /* Ignore badly-formed messages */ - return; - } - sval.data = inp; - sval.len = vallen; - INCPTR(vallen, inp); - len -= vallen; - - GETCHAR(vallen, inp); - len--; - if (vallen > len) { - ppp_error("EAP: badly-formed SRP Challenge" - " (g)"); - /* Ignore badly-formed messages */ - return; - } - /* If no generator present, then use value 2 */ - if (vallen == 0) { - gval.data = (u_char *)"\002"; - gval.len = 1; - } else { - gval.data = inp; - gval.len = vallen; - } - INCPTR(vallen, inp); - len -= vallen; - - /* - * If no modulus present, then use well-known - * value. - */ - if (len == 0) { - Nval.data = (u_char *)wkmodulus; - Nval.len = sizeof (wkmodulus); - } else { - Nval.data = inp; - Nval.len = len; - } - tc = t_clientopen(pcb->eap.es_client.ea_name, - &Nval, &gval, &sval); - if (tc == NULL) { - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - pcb->eap.es_client.ea_session = (void *)tc; - - /* Add Challenge ID & type to verifier */ - vals[0] = id; - vals[1] = EAPT_SRP; - t_clientaddexdata(tc, vals, 2); - } - Ap = t_clientgenexp(tc); - eap_srp_response(esp, id, EAPSRP_CKEY, Ap->data, - Ap->len); - break; - - case EAPSRP_SKEY: - tc = (struct t_client *)pcb->eap.es_client.ea_session; - if (tc == NULL) { - ppp_warn("EAP: peer sent Subtype 2 without 1"); - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - if (pcb->eap.es_client.ea_skey != NULL) { - /* - * ID number should not change here. Warn - * if it does (but otherwise ignore). - */ - if (id != pcb->eap.es_client.ea_id) { - ppp_warn("EAP: ID changed from %d to %d " - "in SRP Subtype 2 rexmit", - pcb->eap.es_client.ea_id, id); - } - } else { - if (get_srp_secret(pcb->eap.es_unit, - pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_peer, secret, 0) == 0) { - /* - * Can't work with this peer because - * the secret is missing. Just give - * up. - */ - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - Bval.data = inp; - Bval.len = len; - t_clientpasswd(tc, secret); - BZERO(secret, sizeof (secret)); - pcb->eap.es_client.ea_skey = - t_clientgetkey(tc, &Bval); - if (pcb->eap.es_client.ea_skey == NULL) { - /* Server is rogue; stop now */ - ppp_error("EAP: SRP server is rogue"); - goto client_failure; - } - } - eap_srpval_response(esp, id, SRPVAL_EBIT, - t_clientresponse(tc)); - break; - - case EAPSRP_SVALIDATOR: - tc = (struct t_client *)pcb->eap.es_client.ea_session; - if (tc == NULL || pcb->eap.es_client.ea_skey == NULL) { - ppp_warn("EAP: peer sent Subtype 3 without 1/2"); - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - /* - * If we're already open, then this ought to be a - * duplicate. Otherwise, check that the server is - * who we think it is. - */ - if (pcb->eap.es_client.ea_state == eapOpen) { - if (id != pcb->eap.es_client.ea_id) { - ppp_warn("EAP: ID changed from %d to %d " - "in SRP Subtype 3 rexmit", - pcb->eap.es_client.ea_id, id); - } - } else { - len -= sizeof (u32_t) + SHA_DIGESTSIZE; - if (len < 0 || t_clientverify(tc, inp + - sizeof (u32_t)) != 0) { - ppp_error("EAP: SRP server verification " - "failed"); - goto client_failure; - } - GETLONG(pcb->eap.es_client.ea_keyflags, inp); - /* Save pseudonym if user wants it. */ - if (len > 0 && pcb->eap.es_usepseudo) { - INCPTR(SHA_DIGESTSIZE, inp); - write_pseudonym(esp, inp, len, id); - } - } - /* - * We've verified our peer. We're now mostly done, - * except for waiting on the regular EAP Success - * message. - */ - eap_srp_response(esp, id, EAPSRP_ACK, NULL, 0); - break; - - case EAPSRP_LWRECHALLENGE: - if (len < 4) { - ppp_warn("EAP: malformed Lightweight rechallenge"); - return; - } - SHA1Init(&ctxt); - vals[0] = id; - SHA1Update(&ctxt, vals, 1); - SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, inp, len); - SHA1Update(&ctxt, pcb->eap.es_client.ea_name, - pcb->eap.es_client.ea_namelen); - SHA1Final(dig, &ctxt); - eap_srp_response(esp, id, EAPSRP_LWRECHALLENGE, dig, - SHA_DIGESTSIZE); - break; - - default: - ppp_error("EAP: unknown SRP Subtype %d", vallen); - eap_send_nak(pcb, id, EAPT_MD5CHAP); - break; - } - break; + case EAPT_SRP: + if (len < 1) { + ppp_error("EAP: received empty SRP Request"); + /* Bogus request; wait for something real. */ + return; + } + + /* Get subtype */ + GETCHAR(vallen, inp); + len--; + switch (vallen) { + case EAPSRP_CHALLENGE: + tc = NULL; + if (pcb->eap.es_client.ea_session != NULL) { + tc = (struct t_client *)pcb->eap.es_client. + ea_session; + /* + * If this is a new challenge, then start + * over with a new client session context. + * Otherwise, just resend last response. + */ + if (id != pcb->eap.es_client.ea_id) { + t_clientclose(tc); + pcb->eap.es_client.ea_session = NULL; + tc = NULL; + } + } + /* No session key just yet */ + pcb->eap.es_client.ea_skey = NULL; + if (tc == NULL) { + int rhostnamelen; + + GETCHAR(vallen, inp); + len--; + if (vallen >= len) { + ppp_error("EAP: badly-formed SRP Challenge" + " (name)"); + /* Ignore badly-formed messages */ + return; + } + MEMCPY(rhostname, inp, vallen); + rhostname[vallen] = '\0'; + INCPTR(vallen, inp); + len -= vallen; + + /* + * In case the remote doesn't give us his name, + * use configured name. + */ + if (explicit_remote || + (remote_name[0] != '\0' && vallen == 0)) { + strlcpy(rhostname, remote_name, + sizeof (rhostname)); + } + + rhostnamelen = (int)strlen(rhostname); + if (rhostnamelen > MAXNAMELEN) { + rhostnamelen = MAXNAMELEN; + } + MEMCPY(pcb->eap.es_client.ea_peer, rhostname, rhostnamelen); + pcb->eap.es_client.ea_peer[rhostnamelen] = '\0'; + pcb->eap.es_client.ea_peerlen = rhostnamelen; + + GETCHAR(vallen, inp); + len--; + if (vallen >= len) { + ppp_error("EAP: badly-formed SRP Challenge" + " (s)"); + /* Ignore badly-formed messages */ + return; + } + sval.data = inp; + sval.len = vallen; + INCPTR(vallen, inp); + len -= vallen; + + GETCHAR(vallen, inp); + len--; + if (vallen > len) { + ppp_error("EAP: badly-formed SRP Challenge" + " (g)"); + /* Ignore badly-formed messages */ + return; + } + /* If no generator present, then use value 2 */ + if (vallen == 0) { + gval.data = (u_char *)"\002"; + gval.len = 1; + } else { + gval.data = inp; + gval.len = vallen; + } + INCPTR(vallen, inp); + len -= vallen; + + /* + * If no modulus present, then use well-known + * value. + */ + if (len == 0) { + Nval.data = (u_char *)wkmodulus; + Nval.len = sizeof (wkmodulus); + } else { + Nval.data = inp; + Nval.len = len; + } + tc = t_clientopen(pcb->eap.es_client.ea_name, + &Nval, &gval, &sval); + if (tc == NULL) { + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + pcb->eap.es_client.ea_session = (void *)tc; + + /* Add Challenge ID & type to verifier */ + vals[0] = id; + vals[1] = EAPT_SRP; + t_clientaddexdata(tc, vals, 2); + } + Ap = t_clientgenexp(tc); + eap_srp_response(esp, id, EAPSRP_CKEY, Ap->data, + Ap->len); + break; + + case EAPSRP_SKEY: + tc = (struct t_client *)pcb->eap.es_client.ea_session; + if (tc == NULL) { + ppp_warn("EAP: peer sent Subtype 2 without 1"); + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + if (pcb->eap.es_client.ea_skey != NULL) { + /* + * ID number should not change here. Warn + * if it does (but otherwise ignore). + */ + if (id != pcb->eap.es_client.ea_id) { + ppp_warn("EAP: ID changed from %d to %d " + "in SRP Subtype 2 rexmit", + pcb->eap.es_client.ea_id, id); + } + } else { + if (get_srp_secret(pcb->eap.es_unit, + pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_peer, secret, 0) == 0) { + /* + * Can't work with this peer because + * the secret is missing. Just give + * up. + */ + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + Bval.data = inp; + Bval.len = len; + t_clientpasswd(tc, secret); + BZERO(secret, sizeof (secret)); + pcb->eap.es_client.ea_skey = + t_clientgetkey(tc, &Bval); + if (pcb->eap.es_client.ea_skey == NULL) { + /* Server is rogue; stop now */ + ppp_error("EAP: SRP server is rogue"); + goto client_failure; + } + } + eap_srpval_response(esp, id, SRPVAL_EBIT, + t_clientresponse(tc)); + break; + + case EAPSRP_SVALIDATOR: + tc = (struct t_client *)pcb->eap.es_client.ea_session; + if (tc == NULL || pcb->eap.es_client.ea_skey == NULL) { + ppp_warn("EAP: peer sent Subtype 3 without 1/2"); + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + /* + * If we're already open, then this ought to be a + * duplicate. Otherwise, check that the server is + * who we think it is. + */ + if (pcb->eap.es_client.ea_state == eapOpen) { + if (id != pcb->eap.es_client.ea_id) { + ppp_warn("EAP: ID changed from %d to %d " + "in SRP Subtype 3 rexmit", + pcb->eap.es_client.ea_id, id); + } + } else { + len -= sizeof (u32_t) + SHA_DIGESTSIZE; + if (len < 0 || t_clientverify(tc, inp + + sizeof (u32_t)) != 0) { + ppp_error("EAP: SRP server verification " + "failed"); + goto client_failure; + } + GETLONG(pcb->eap.es_client.ea_keyflags, inp); + /* Save pseudonym if user wants it. */ + if (len > 0 && pcb->eap.es_usepseudo) { + INCPTR(SHA_DIGESTSIZE, inp); + write_pseudonym(esp, inp, len, id); + } + } + /* + * We've verified our peer. We're now mostly done, + * except for waiting on the regular EAP Success + * message. + */ + eap_srp_response(esp, id, EAPSRP_ACK, NULL, 0); + break; + + case EAPSRP_LWRECHALLENGE: + if (len < 4) { + ppp_warn("EAP: malformed Lightweight rechallenge"); + return; + } + SHA1Init(&ctxt); + vals[0] = id; + SHA1Update(&ctxt, vals, 1); + SHA1Update(&ctxt, pcb->eap.es_client.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, inp, len); + SHA1Update(&ctxt, pcb->eap.es_client.ea_name, + pcb->eap.es_client.ea_namelen); + SHA1Final(dig, &ctxt); + eap_srp_response(esp, id, EAPSRP_LWRECHALLENGE, dig, + SHA_DIGESTSIZE); + break; + + default: + ppp_error("EAP: unknown SRP Subtype %d", vallen); + eap_send_nak(pcb, id, EAPT_MD5CHAP); + break; + } + break; #endif /* USE_SRP */ - default: - ppp_info("EAP: unknown authentication type %d; Naking", typenum); - eap_send_nak(pcb, id, EAPT_SRP); - break; - } + default: + ppp_info("EAP: unknown authentication type %d; Naking", typenum); + eap_send_nak(pcb, id, EAPT_SRP); + break; + } - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - TIMEOUT(eap_client_timeout, pcb, - pcb->settings.eap_req_time); - } - return; + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + TIMEOUT(eap_client_timeout, pcb, + pcb->settings.eap_req_time); + } + return; #ifdef USE_SRP client_failure: - pcb->eap.es_client.ea_state = eapBadAuth; - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, (void *)esp); - } - pcb->eap.es_client.ea_session = NULL; - t_clientclose(tc); - auth_withpeer_fail(pcb, PPP_EAP); + pcb->eap.es_client.ea_state = eapBadAuth; + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, (void *)esp); + } + pcb->eap.es_client.ea_session = NULL; + t_clientclose(tc); + auth_withpeer_fail(pcb, PPP_EAP); #endif /* USE_SRP */ } @@ -1723,291 +1723,291 @@ client_failure: * eap_response - Receive EAP Response message (server mode). */ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) { - u_char typenum; - u_char vallen; - int secret_len; - char secret[MAXSECRETLEN]; - char rhostname[MAXNAMELEN]; - lwip_md5_context mdContext; - u_char hash[MD5_SIGNATURE_SIZE]; + u_char typenum; + u_char vallen; + int secret_len; + char secret[MAXSECRETLEN]; + char rhostname[MAXNAMELEN]; + lwip_md5_context mdContext; + u_char hash[MD5_SIGNATURE_SIZE]; #ifdef USE_SRP - struct t_server *ts; - struct t_num A; - SHA1_CTX ctxt; - u_char dig[SHA_DIGESTSIZE]; + struct t_server *ts; + struct t_num A; + SHA1_CTX ctxt; + u_char dig[SHA_DIGESTSIZE]; #endif /* USE_SRP */ - if (pcb->eap.es_server.ea_id != id) { - ppp_dbglog("EAP: discarding Response %d; expected ID %d", id, - pcb->eap.es_server.ea_id); - return; - } - - pcb->eap.es_server.ea_responses++; - - if (len <= 0) { - ppp_error("EAP: empty Response message discarded"); - return; - } - - GETCHAR(typenum, inp); - len--; - - switch (typenum) { - case EAPT_IDENTITY: - if (pcb->eap.es_server.ea_state != eapIdentify) { - ppp_dbglog("EAP discarding unwanted Identify \"%.q\"", len, - inp); - break; - } - ppp_info("EAP: unauthenticated peer name \"%.*q\"", len, inp); - if (len > MAXNAMELEN) { - len = MAXNAMELEN; - } - MEMCPY(pcb->eap.es_server.ea_peer, inp, len); - pcb->eap.es_server.ea_peer[len] = '\0'; - pcb->eap.es_server.ea_peerlen = len; - eap_figure_next_state(pcb, 0); - break; - - case EAPT_NOTIFICATION: - ppp_dbglog("EAP unexpected Notification; response discarded"); - break; - - case EAPT_NAK: - if (len < 1) { - ppp_info("EAP: Nak Response with no suggested protocol"); - eap_figure_next_state(pcb, 1); - break; - } - - GETCHAR(vallen, inp); - len--; - - if ( + if (pcb->eap.es_server.ea_id != id) { + ppp_dbglog("EAP: discarding Response %d; expected ID %d", id, + pcb->eap.es_server.ea_id); + return; + } + + pcb->eap.es_server.ea_responses++; + + if (len <= 0) { + ppp_error("EAP: empty Response message discarded"); + return; + } + + GETCHAR(typenum, inp); + len--; + + switch (typenum) { + case EAPT_IDENTITY: + if (pcb->eap.es_server.ea_state != eapIdentify) { + ppp_dbglog("EAP discarding unwanted Identify \"%.q\"", len, + inp); + break; + } + ppp_info("EAP: unauthenticated peer name \"%.*q\"", len, inp); + if (len > MAXNAMELEN) { + len = MAXNAMELEN; + } + MEMCPY(pcb->eap.es_server.ea_peer, inp, len); + pcb->eap.es_server.ea_peer[len] = '\0'; + pcb->eap.es_server.ea_peerlen = len; + eap_figure_next_state(pcb, 0); + break; + + case EAPT_NOTIFICATION: + ppp_dbglog("EAP unexpected Notification; response discarded"); + break; + + case EAPT_NAK: + if (len < 1) { + ppp_info("EAP: Nak Response with no suggested protocol"); + eap_figure_next_state(pcb, 1); + break; + } + + GETCHAR(vallen, inp); + len--; + + if ( #if PPP_REMOTENAME - !pcb->explicit_remote && + !pcb->explicit_remote && #endif /* PPP_REMOTENAME */ - pcb->eap.es_server.ea_state == eapIdentify){ - /* Peer cannot Nak Identify Request */ - eap_figure_next_state(pcb, 1); - break; - } - - switch (vallen) { - case EAPT_SRP: - /* Run through SRP validator selection again. */ - pcb->eap.es_server.ea_state = eapIdentify; - eap_figure_next_state(pcb, 0); - break; - - case EAPT_MD5CHAP: - pcb->eap.es_server.ea_state = eapMD5Chall; - break; - - default: - ppp_dbglog("EAP: peer requesting unknown Type %d", vallen); - switch (pcb->eap.es_server.ea_state) { - case eapSRP1: - case eapSRP2: - case eapSRP3: - pcb->eap.es_server.ea_state = eapMD5Chall; - break; - case eapMD5Chall: - case eapSRP4: - pcb->eap.es_server.ea_state = eapIdentify; - eap_figure_next_state(pcb, 0); - break; - default: - break; - } - break; - } - break; - - case EAPT_MD5CHAP: - if (pcb->eap.es_server.ea_state != eapMD5Chall) { - ppp_error("EAP: unexpected MD5-Response"); - eap_figure_next_state(pcb, 1); - break; - } - if (len < 1) { - ppp_error("EAP: received MD5-Response with no data"); - eap_figure_next_state(pcb, 1); - break; - } - GETCHAR(vallen, inp); - len--; - if (vallen != 16 || vallen > len) { - ppp_error("EAP: MD5-Response with bad length %d", vallen); - eap_figure_next_state(pcb, 1); - break; - } - - /* Not so likely to happen. */ - if (vallen >= len + sizeof (rhostname)) { - ppp_dbglog("EAP: trimming really long peer name down"); - MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); - rhostname[sizeof (rhostname) - 1] = '\0'; - } else { - MEMCPY(rhostname, inp + vallen, len - vallen); - rhostname[len - vallen] = '\0'; - } + pcb->eap.es_server.ea_state == eapIdentify){ + /* Peer cannot Nak Identify Request */ + eap_figure_next_state(pcb, 1); + break; + } + + switch (vallen) { + case EAPT_SRP: + /* Run through SRP validator selection again. */ + pcb->eap.es_server.ea_state = eapIdentify; + eap_figure_next_state(pcb, 0); + break; + + case EAPT_MD5CHAP: + pcb->eap.es_server.ea_state = eapMD5Chall; + break; + + default: + ppp_dbglog("EAP: peer requesting unknown Type %d", vallen); + switch (pcb->eap.es_server.ea_state) { + case eapSRP1: + case eapSRP2: + case eapSRP3: + pcb->eap.es_server.ea_state = eapMD5Chall; + break; + case eapMD5Chall: + case eapSRP4: + pcb->eap.es_server.ea_state = eapIdentify; + eap_figure_next_state(pcb, 0); + break; + default: + break; + } + break; + } + break; + + case EAPT_MD5CHAP: + if (pcb->eap.es_server.ea_state != eapMD5Chall) { + ppp_error("EAP: unexpected MD5-Response"); + eap_figure_next_state(pcb, 1); + break; + } + if (len < 1) { + ppp_error("EAP: received MD5-Response with no data"); + eap_figure_next_state(pcb, 1); + break; + } + GETCHAR(vallen, inp); + len--; + if (vallen != 16 || vallen > len) { + ppp_error("EAP: MD5-Response with bad length %d", vallen); + eap_figure_next_state(pcb, 1); + break; + } + + /* Not so likely to happen. */ + if (vallen >= len + sizeof (rhostname)) { + ppp_dbglog("EAP: trimming really long peer name down"); + MEMCPY(rhostname, inp + vallen, sizeof (rhostname) - 1); + rhostname[sizeof (rhostname) - 1] = '\0'; + } else { + MEMCPY(rhostname, inp + vallen, len - vallen); + rhostname[len - vallen] = '\0'; + } #if PPP_REMOTENAME - /* In case the remote doesn't give us his name. */ - if (explicit_remote || - (remote_name[0] != '\0' && vallen == len)) - strlcpy(rhostname, remote_name, sizeof (rhostname)); + /* In case the remote doesn't give us his name. */ + if (explicit_remote || + (remote_name[0] != '\0' && vallen == len)) + strlcpy(rhostname, remote_name, sizeof (rhostname)); #endif /* PPP_REMOTENAME */ - /* - * Get the secret for authenticating the specified - * host. - */ - if (!get_secret(pcb, rhostname, - pcb->eap.es_server.ea_name, secret, &secret_len, 1)) { - ppp_dbglog("EAP: no MD5 secret for auth of %q", rhostname); - eap_send_failure(pcb); - break; - } - lwip_md5_init(&mdContext); - lwip_md5_starts(&mdContext); - lwip_md5_update(&mdContext, &pcb->eap.es_server.ea_id, 1); - lwip_md5_update(&mdContext, (u_char *)secret, secret_len); - BZERO(secret, sizeof (secret)); - lwip_md5_update(&mdContext, pcb->eap.es_challenge, pcb->eap.es_challen); - lwip_md5_finish(&mdContext, hash); - lwip_md5_free(&mdContext); - if (BCMP(hash, inp, MD5_SIGNATURE_SIZE) != 0) { - eap_send_failure(pcb); - break; - } - pcb->eap.es_server.ea_type = EAPT_MD5CHAP; - eap_send_success(pcb); - eap_figure_next_state(pcb, 0); - if (pcb->eap.es_rechallenge != 0) - TIMEOUT(eap_rechallenge, pcb, pcb->eap.es_rechallenge); - break; + /* + * Get the secret for authenticating the specified + * host. + */ + if (!get_secret(pcb, rhostname, + pcb->eap.es_server.ea_name, secret, &secret_len, 1)) { + ppp_dbglog("EAP: no MD5 secret for auth of %q", rhostname); + eap_send_failure(pcb); + break; + } + lwip_md5_init(&mdContext); + lwip_md5_starts(&mdContext); + lwip_md5_update(&mdContext, &pcb->eap.es_server.ea_id, 1); + lwip_md5_update(&mdContext, (u_char *)secret, secret_len); + BZERO(secret, sizeof (secret)); + lwip_md5_update(&mdContext, pcb->eap.es_challenge, pcb->eap.es_challen); + lwip_md5_finish(&mdContext, hash); + lwip_md5_free(&mdContext); + if (BCMP(hash, inp, MD5_SIGNATURE_SIZE) != 0) { + eap_send_failure(pcb); + break; + } + pcb->eap.es_server.ea_type = EAPT_MD5CHAP; + eap_send_success(pcb); + eap_figure_next_state(pcb, 0); + if (pcb->eap.es_rechallenge != 0) + TIMEOUT(eap_rechallenge, pcb, pcb->eap.es_rechallenge); + break; #ifdef USE_SRP - case EAPT_SRP: - if (len < 1) { - ppp_error("EAP: empty SRP Response"); - eap_figure_next_state(pcb, 1); - break; - } - GETCHAR(typenum, inp); - len--; - switch (typenum) { - case EAPSRP_CKEY: - if (pcb->eap.es_server.ea_state != eapSRP1) { - ppp_error("EAP: unexpected SRP Subtype 1 Response"); - eap_figure_next_state(pcb, 1); - break; - } - A.data = inp; - A.len = len; - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - pcb->eap.es_server.ea_skey = t_servergetkey(ts, &A); - if (pcb->eap.es_server.ea_skey == NULL) { - /* Client's A value is bogus; terminate now */ - ppp_error("EAP: bogus A value from client"); - eap_send_failure(pcb); - } else { - eap_figure_next_state(pcb, 0); - } - break; - - case EAPSRP_CVALIDATOR: - if (pcb->eap.es_server.ea_state != eapSRP2) { - ppp_error("EAP: unexpected SRP Subtype 2 Response"); - eap_figure_next_state(pcb, 1); - break; - } - if (len < sizeof (u32_t) + SHA_DIGESTSIZE) { - ppp_error("EAP: M1 length %d < %d", len, - sizeof (u32_t) + SHA_DIGESTSIZE); - eap_figure_next_state(pcb, 1); - break; - } - GETLONG(pcb->eap.es_server.ea_keyflags, inp); - ts = (struct t_server *)pcb->eap.es_server.ea_session; - assert(ts != NULL); - if (t_serververify(ts, inp)) { - ppp_info("EAP: unable to validate client identity"); - eap_send_failure(pcb); - break; - } - eap_figure_next_state(pcb, 0); - break; - - case EAPSRP_ACK: - if (pcb->eap.es_server.ea_state != eapSRP3) { - ppp_error("EAP: unexpected SRP Subtype 3 Response"); - eap_send_failure(esp); - break; - } - pcb->eap.es_server.ea_type = EAPT_SRP; - eap_send_success(pcb, esp); - eap_figure_next_state(pcb, 0); - if (pcb->eap.es_rechallenge != 0) - TIMEOUT(eap_rechallenge, pcb, - pcb->eap.es_rechallenge); - if (pcb->eap.es_lwrechallenge != 0) - TIMEOUT(srp_lwrechallenge, pcb, - pcb->eap.es_lwrechallenge); - break; - - case EAPSRP_LWRECHALLENGE: - if (pcb->eap.es_server.ea_state != eapSRP4) { - ppp_info("EAP: unexpected SRP Subtype 4 Response"); - return; - } - if (len != SHA_DIGESTSIZE) { - ppp_error("EAP: bad Lightweight rechallenge " - "response"); - return; - } - SHA1Init(&ctxt); - vallen = id; - SHA1Update(&ctxt, &vallen, 1); - SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, - SESSION_KEY_LEN); - SHA1Update(&ctxt, pcb->eap.es_challenge, pcb->eap.es_challen); - SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, - pcb->eap.es_server.ea_peerlen); - SHA1Final(dig, &ctxt); - if (BCMP(dig, inp, SHA_DIGESTSIZE) != 0) { - ppp_error("EAP: failed Lightweight rechallenge"); - eap_send_failure(pcb); - break; - } - pcb->eap.es_server.ea_state = eapOpen; - if (pcb->eap.es_lwrechallenge != 0) - TIMEOUT(srp_lwrechallenge, esp, - pcb->eap.es_lwrechallenge); - break; - } - break; + case EAPT_SRP: + if (len < 1) { + ppp_error("EAP: empty SRP Response"); + eap_figure_next_state(pcb, 1); + break; + } + GETCHAR(typenum, inp); + len--; + switch (typenum) { + case EAPSRP_CKEY: + if (pcb->eap.es_server.ea_state != eapSRP1) { + ppp_error("EAP: unexpected SRP Subtype 1 Response"); + eap_figure_next_state(pcb, 1); + break; + } + A.data = inp; + A.len = len; + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + pcb->eap.es_server.ea_skey = t_servergetkey(ts, &A); + if (pcb->eap.es_server.ea_skey == NULL) { + /* Client's A value is bogus; terminate now */ + ppp_error("EAP: bogus A value from client"); + eap_send_failure(pcb); + } else { + eap_figure_next_state(pcb, 0); + } + break; + + case EAPSRP_CVALIDATOR: + if (pcb->eap.es_server.ea_state != eapSRP2) { + ppp_error("EAP: unexpected SRP Subtype 2 Response"); + eap_figure_next_state(pcb, 1); + break; + } + if (len < sizeof (u32_t) + SHA_DIGESTSIZE) { + ppp_error("EAP: M1 length %d < %d", len, + sizeof (u32_t) + SHA_DIGESTSIZE); + eap_figure_next_state(pcb, 1); + break; + } + GETLONG(pcb->eap.es_server.ea_keyflags, inp); + ts = (struct t_server *)pcb->eap.es_server.ea_session; + assert(ts != NULL); + if (t_serververify(ts, inp)) { + ppp_info("EAP: unable to validate client identity"); + eap_send_failure(pcb); + break; + } + eap_figure_next_state(pcb, 0); + break; + + case EAPSRP_ACK: + if (pcb->eap.es_server.ea_state != eapSRP3) { + ppp_error("EAP: unexpected SRP Subtype 3 Response"); + eap_send_failure(esp); + break; + } + pcb->eap.es_server.ea_type = EAPT_SRP; + eap_send_success(pcb, esp); + eap_figure_next_state(pcb, 0); + if (pcb->eap.es_rechallenge != 0) + TIMEOUT(eap_rechallenge, pcb, + pcb->eap.es_rechallenge); + if (pcb->eap.es_lwrechallenge != 0) + TIMEOUT(srp_lwrechallenge, pcb, + pcb->eap.es_lwrechallenge); + break; + + case EAPSRP_LWRECHALLENGE: + if (pcb->eap.es_server.ea_state != eapSRP4) { + ppp_info("EAP: unexpected SRP Subtype 4 Response"); + return; + } + if (len != SHA_DIGESTSIZE) { + ppp_error("EAP: bad Lightweight rechallenge " + "response"); + return; + } + SHA1Init(&ctxt); + vallen = id; + SHA1Update(&ctxt, &vallen, 1); + SHA1Update(&ctxt, pcb->eap.es_server.ea_skey, + SESSION_KEY_LEN); + SHA1Update(&ctxt, pcb->eap.es_challenge, pcb->eap.es_challen); + SHA1Update(&ctxt, pcb->eap.es_server.ea_peer, + pcb->eap.es_server.ea_peerlen); + SHA1Final(dig, &ctxt); + if (BCMP(dig, inp, SHA_DIGESTSIZE) != 0) { + ppp_error("EAP: failed Lightweight rechallenge"); + eap_send_failure(pcb); + break; + } + pcb->eap.es_server.ea_state = eapOpen; + if (pcb->eap.es_lwrechallenge != 0) + TIMEOUT(srp_lwrechallenge, esp, + pcb->eap.es_lwrechallenge); + break; + } + break; #endif /* USE_SRP */ - default: - /* This can't happen. */ - ppp_error("EAP: unknown Response type %d; ignored", typenum); - return; - } - - if (pcb->settings.eap_timeout_time > 0) { - UNTIMEOUT(eap_server_timeout, pcb); - } - - if (pcb->eap.es_server.ea_state != eapBadAuth && - pcb->eap.es_server.ea_state != eapOpen) { - pcb->eap.es_server.ea_id++; - eap_send_request(pcb); - } + default: + /* This can't happen. */ + ppp_error("EAP: unknown Response type %d; ignored", typenum); + return; + } + + if (pcb->settings.eap_timeout_time > 0) { + UNTIMEOUT(eap_server_timeout, pcb); + } + + if (pcb->eap.es_server.ea_state != eapBadAuth && + pcb->eap.es_server.ea_state != eapOpen) { + pcb->eap.es_server.ea_id++; + eap_send_request(pcb); + } } #endif /* PPP_SERVER */ @@ -2015,105 +2015,105 @@ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) { * eap_success - Receive EAP Success message (client mode). */ static void eap_success(ppp_pcb *pcb, u_char *inp, int id, int len) { - LWIP_UNUSED_ARG(id); - - if (pcb->eap.es_client.ea_state != eapOpen && !eap_client_active(pcb)) { - ppp_dbglog("EAP unexpected success message in state %s (%d)", - eap_state_name(pcb->eap.es_client.ea_state), - pcb->eap.es_client.ea_state); - return; - } - - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } - - if (len > 0) { - /* This is odd. The spec doesn't allow for this. */ - PRINTMSG(inp, len); - } - - pcb->eap.es_client.ea_state = eapOpen; - auth_withpeer_success(pcb, PPP_EAP, 0); + LWIP_UNUSED_ARG(id); + + if (pcb->eap.es_client.ea_state != eapOpen && !eap_client_active(pcb)) { + ppp_dbglog("EAP unexpected success message in state %s (%d)", + eap_state_name(pcb->eap.es_client.ea_state), + pcb->eap.es_client.ea_state); + return; + } + + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } + + if (len > 0) { + /* This is odd. The spec doesn't allow for this. */ + PRINTMSG(inp, len); + } + + pcb->eap.es_client.ea_state = eapOpen; + auth_withpeer_success(pcb, PPP_EAP, 0); } /* * eap_failure - Receive EAP Failure message (client mode). */ static void eap_failure(ppp_pcb *pcb, u_char *inp, int id, int len) { - LWIP_UNUSED_ARG(id); + LWIP_UNUSED_ARG(id); - if (!eap_client_active(pcb)) { - ppp_dbglog("EAP unexpected failure message in state %s (%d)", - eap_state_name(pcb->eap.es_client.ea_state), - pcb->eap.es_client.ea_state); - } + if (!eap_client_active(pcb)) { + ppp_dbglog("EAP unexpected failure message in state %s (%d)", + eap_state_name(pcb->eap.es_client.ea_state), + pcb->eap.es_client.ea_state); + } - if (pcb->settings.eap_req_time > 0) { - UNTIMEOUT(eap_client_timeout, pcb); - } + if (pcb->settings.eap_req_time > 0) { + UNTIMEOUT(eap_client_timeout, pcb); + } - if (len > 0) { - /* This is odd. The spec doesn't allow for this. */ - PRINTMSG(inp, len); - } + if (len > 0) { + /* This is odd. The spec doesn't allow for this. */ + PRINTMSG(inp, len); + } - pcb->eap.es_client.ea_state = eapBadAuth; + pcb->eap.es_client.ea_state = eapBadAuth; - ppp_error("EAP: peer reports authentication failure"); - auth_withpeer_fail(pcb, PPP_EAP); + ppp_error("EAP: peer reports authentication failure"); + auth_withpeer_fail(pcb, PPP_EAP); } /* * eap_input - Handle received EAP message. */ static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen) { - u_char code, id; - int len; - - /* - * Parse header (code, id and length). If packet too short, - * drop it. - */ - if (inlen < EAP_HEADERLEN) { - ppp_error("EAP: packet too short: %d < %d", inlen, EAP_HEADERLEN); - return; - } - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < EAP_HEADERLEN || len > inlen) { - ppp_error("EAP: packet has illegal length field %d (%d..%d)", len, - EAP_HEADERLEN, inlen); - return; - } - len -= EAP_HEADERLEN; - - /* Dispatch based on message code */ - switch (code) { - case EAP_REQUEST: - eap_request(pcb, inp, id, len); - break; + u_char code, id; + int len; + + /* + * Parse header (code, id and length). If packet too short, + * drop it. + */ + if (inlen < EAP_HEADERLEN) { + ppp_error("EAP: packet too short: %d < %d", inlen, EAP_HEADERLEN); + return; + } + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < EAP_HEADERLEN || len > inlen) { + ppp_error("EAP: packet has illegal length field %d (%d..%d)", len, + EAP_HEADERLEN, inlen); + return; + } + len -= EAP_HEADERLEN; + + /* Dispatch based on message code */ + switch (code) { + case EAP_REQUEST: + eap_request(pcb, inp, id, len); + break; #if PPP_SERVER - case EAP_RESPONSE: - eap_response(pcb, inp, id, len); - break; + case EAP_RESPONSE: + eap_response(pcb, inp, id, len); + break; #endif /* PPP_SERVER */ - case EAP_SUCCESS: - eap_success(pcb, inp, id, len); - break; + case EAP_SUCCESS: + eap_success(pcb, inp, id, len); + break; - case EAP_FAILURE: - eap_failure(pcb, inp, id, len); - break; + case EAP_FAILURE: + eap_failure(pcb, inp, id, len); + break; - default: /* XXX Need code reject */ - /* Note: it's not legal to send EAP Nak here. */ - ppp_warn("EAP: unknown code %d received", code); - break; - } + default: /* XXX Need code reject */ + /* Note: it's not legal to send EAP Nak here. */ + ppp_warn("EAP: unknown code %d received", code); + break; + } } #if PRINTPKT_SUPPORT @@ -2121,302 +2121,302 @@ static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen) { * eap_printpkt - print the contents of an EAP packet. */ static const char* const eap_codenames[] = { - "Request", "Response", "Success", "Failure" + "Request", "Response", "Success", "Failure" }; static const char* const eap_typenames[] = { - "Identity", "Notification", "Nak", "MD5-Challenge", - "OTP", "Generic-Token", NULL, NULL, - "RSA", "DSS", "KEA", "KEA-Validate", - "TLS", "Defender", "Windows 2000", "Arcot", - "Cisco", "Nokia", "SRP" + "Identity", "Notification", "Nak", "MD5-Challenge", + "OTP", "Generic-Token", NULL, NULL, + "RSA", "DSS", "KEA", "KEA-Validate", + "TLS", "Defender", "Windows 2000", "Arcot", + "Cisco", "Nokia", "SRP" }; static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, const char *, ...), void *arg) { - int code, id, len, rtype, vallen; - const u_char *pstart; - u32_t uval; - - if (inlen < EAP_HEADERLEN) - return (0); - pstart = inp; - GETCHAR(code, inp); - GETCHAR(id, inp); - GETSHORT(len, inp); - if (len < EAP_HEADERLEN || len > inlen) - return (0); - - if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(eap_codenames)) - printer(arg, " %s", eap_codenames[code-1]); - else - printer(arg, " code=0x%x", code); - printer(arg, " id=0x%x", id); - len -= EAP_HEADERLEN; - switch (code) { - case EAP_REQUEST: - if (len < 1) { - printer(arg, " "); - break; - } - GETCHAR(rtype, inp); - len--; - if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) - printer(arg, " %s", eap_typenames[rtype-1]); - else - printer(arg, " type=0x%x", rtype); - switch (rtype) { - case EAPT_IDENTITY: - case EAPT_NOTIFICATION: - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } else { - printer(arg, " "); - } - break; - - case EAPT_MD5CHAP: - if (len <= 0) - break; - GETCHAR(vallen, inp); - len--; - if (vallen > len) - goto truncated; - printer(arg, " ", vallen, inp); - INCPTR(vallen, inp); - len -= vallen; - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } else { - printer(arg, " "); - } - break; - - case EAPT_SRP: - if (len < 3) - goto truncated; - GETCHAR(vallen, inp); - len--; - printer(arg, "-%d", vallen); - switch (vallen) { - case EAPSRP_CHALLENGE: - GETCHAR(vallen, inp); - len--; - if (vallen >= len) - goto truncated; - if (vallen > 0) { - printer(arg, " "); - } else { - printer(arg, " "); - } - INCPTR(vallen, inp); - len -= vallen; - GETCHAR(vallen, inp); - len--; - if (vallen >= len) - goto truncated; - printer(arg, " ", vallen, inp); - INCPTR(vallen, inp); - len -= vallen; - GETCHAR(vallen, inp); - len--; - if (vallen > len) - goto truncated; - if (vallen == 0) { - printer(arg, " "); - } else { - printer(arg, " ", vallen, inp); - } - INCPTR(vallen, inp); - len -= vallen; - if (len == 0) { - printer(arg, " "); - } else { - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - } - break; - - case EAPSRP_SKEY: - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - break; - - case EAPSRP_SVALIDATOR: - if (len < (int)sizeof (u32_t)) - break; - GETLONG(uval, inp); - len -= sizeof (u32_t); - if (uval & SRPVAL_EBIT) { - printer(arg, " E"); - uval &= ~SRPVAL_EBIT; - } - if (uval != 0) { - printer(arg, " f<%X>", uval); - } - if ((vallen = len) > SHA_DIGESTSIZE) - vallen = SHA_DIGESTSIZE; - printer(arg, " ", len, inp, - len < SHA_DIGESTSIZE ? "?" : ""); - INCPTR(vallen, inp); - len -= vallen; - if (len > 0) { - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - } - break; - - case EAPSRP_LWRECHALLENGE: - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - break; - default: - break; - } - break; - default: - break; - } - break; - - case EAP_RESPONSE: - if (len < 1) - break; - GETCHAR(rtype, inp); - len--; - if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) - printer(arg, " %s", eap_typenames[rtype-1]); - else - printer(arg, " type=0x%x", rtype); - switch (rtype) { - case EAPT_IDENTITY: - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } - break; - - case EAPT_NAK: - if (len <= 0) { - printer(arg, " "); - break; - } - GETCHAR(rtype, inp); - len--; - printer(arg, " = 1 && rtype < (int)LWIP_ARRAYSIZE(eap_typenames)) - printer(arg, " (%s)", eap_typenames[rtype-1]); - printer(arg, ">"); - break; - - case EAPT_MD5CHAP: - if (len <= 0) { - printer(arg, " "); - break; - } - GETCHAR(vallen, inp); - len--; - if (vallen > len) - goto truncated; - printer(arg, " ", vallen, inp); - INCPTR(vallen, inp); - len -= vallen; - if (len > 0) { - printer(arg, " "); - INCPTR(len, inp); - len = 0; - } else { - printer(arg, " "); - } - break; - - case EAPT_SRP: - if (len < 1) - goto truncated; - GETCHAR(vallen, inp); - len--; - printer(arg, "-%d", vallen); - switch (vallen) { - case EAPSRP_CKEY: - printer(arg, " ", len, inp); - INCPTR(len, inp); - len = 0; - break; - - case EAPSRP_CVALIDATOR: - if (len < (int)sizeof (u32_t)) - break; - GETLONG(uval, inp); - len -= sizeof (u32_t); - if (uval & SRPVAL_EBIT) { - printer(arg, " E"); - uval &= ~SRPVAL_EBIT; - } - if (uval != 0) { - printer(arg, " f<%X>", uval); - } - printer(arg, " ", len, inp, - len == SHA_DIGESTSIZE ? "" : "?"); - INCPTR(len, inp); - len = 0; - break; - - case EAPSRP_ACK: - break; - - case EAPSRP_LWRECHALLENGE: - printer(arg, " ", len, inp, - len == SHA_DIGESTSIZE ? "" : "?"); - if ((vallen = len) > SHA_DIGESTSIZE) - vallen = SHA_DIGESTSIZE; - INCPTR(vallen, inp); - len -= vallen; - break; - default: - break; - } - break; - default: - break; - } - break; - - case EAP_SUCCESS: /* No payload expected for these! */ - case EAP_FAILURE: - default: - break; - - truncated: - printer(arg, " "); - break; - } - - if (len > 8) - printer(arg, "%8B...", inp); - else if (len > 0) - printer(arg, "%.*B", len, inp); - INCPTR(len, inp); - - return (inp - pstart); + int code, id, len, rtype, vallen; + const u_char *pstart; + u32_t uval; + + if (inlen < EAP_HEADERLEN) + return (0); + pstart = inp; + GETCHAR(code, inp); + GETCHAR(id, inp); + GETSHORT(len, inp); + if (len < EAP_HEADERLEN || len > inlen) + return (0); + + if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(eap_codenames)) + printer(arg, " %s", eap_codenames[code-1]); + else + printer(arg, " code=0x%x", code); + printer(arg, " id=0x%x", id); + len -= EAP_HEADERLEN; + switch (code) { + case EAP_REQUEST: + if (len < 1) { + printer(arg, " "); + break; + } + GETCHAR(rtype, inp); + len--; + if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) + printer(arg, " %s", eap_typenames[rtype-1]); + else + printer(arg, " type=0x%x", rtype); + switch (rtype) { + case EAPT_IDENTITY: + case EAPT_NOTIFICATION: + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } else { + printer(arg, " "); + } + break; + + case EAPT_MD5CHAP: + if (len <= 0) + break; + GETCHAR(vallen, inp); + len--; + if (vallen > len) + goto truncated; + printer(arg, " ", vallen, inp); + INCPTR(vallen, inp); + len -= vallen; + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } else { + printer(arg, " "); + } + break; + + case EAPT_SRP: + if (len < 3) + goto truncated; + GETCHAR(vallen, inp); + len--; + printer(arg, "-%d", vallen); + switch (vallen) { + case EAPSRP_CHALLENGE: + GETCHAR(vallen, inp); + len--; + if (vallen >= len) + goto truncated; + if (vallen > 0) { + printer(arg, " "); + } else { + printer(arg, " "); + } + INCPTR(vallen, inp); + len -= vallen; + GETCHAR(vallen, inp); + len--; + if (vallen >= len) + goto truncated; + printer(arg, " ", vallen, inp); + INCPTR(vallen, inp); + len -= vallen; + GETCHAR(vallen, inp); + len--; + if (vallen > len) + goto truncated; + if (vallen == 0) { + printer(arg, " "); + } else { + printer(arg, " ", vallen, inp); + } + INCPTR(vallen, inp); + len -= vallen; + if (len == 0) { + printer(arg, " "); + } else { + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + } + break; + + case EAPSRP_SKEY: + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + break; + + case EAPSRP_SVALIDATOR: + if (len < (int)sizeof (u32_t)) + break; + GETLONG(uval, inp); + len -= sizeof (u32_t); + if (uval & SRPVAL_EBIT) { + printer(arg, " E"); + uval &= ~SRPVAL_EBIT; + } + if (uval != 0) { + printer(arg, " f<%X>", uval); + } + if ((vallen = len) > SHA_DIGESTSIZE) + vallen = SHA_DIGESTSIZE; + printer(arg, " ", len, inp, + len < SHA_DIGESTSIZE ? "?" : ""); + INCPTR(vallen, inp); + len -= vallen; + if (len > 0) { + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + } + break; + + case EAPSRP_LWRECHALLENGE: + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + break; + default: + break; + } + break; + default: + break; + } + break; + + case EAP_RESPONSE: + if (len < 1) + break; + GETCHAR(rtype, inp); + len--; + if (rtype >= 1 && rtype <= (int)LWIP_ARRAYSIZE(eap_typenames)) + printer(arg, " %s", eap_typenames[rtype-1]); + else + printer(arg, " type=0x%x", rtype); + switch (rtype) { + case EAPT_IDENTITY: + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } + break; + + case EAPT_NAK: + if (len <= 0) { + printer(arg, " "); + break; + } + GETCHAR(rtype, inp); + len--; + printer(arg, " = 1 && rtype < (int)LWIP_ARRAYSIZE(eap_typenames)) + printer(arg, " (%s)", eap_typenames[rtype-1]); + printer(arg, ">"); + break; + + case EAPT_MD5CHAP: + if (len <= 0) { + printer(arg, " "); + break; + } + GETCHAR(vallen, inp); + len--; + if (vallen > len) + goto truncated; + printer(arg, " ", vallen, inp); + INCPTR(vallen, inp); + len -= vallen; + if (len > 0) { + printer(arg, " "); + INCPTR(len, inp); + len = 0; + } else { + printer(arg, " "); + } + break; + + case EAPT_SRP: + if (len < 1) + goto truncated; + GETCHAR(vallen, inp); + len--; + printer(arg, "-%d", vallen); + switch (vallen) { + case EAPSRP_CKEY: + printer(arg, " ", len, inp); + INCPTR(len, inp); + len = 0; + break; + + case EAPSRP_CVALIDATOR: + if (len < (int)sizeof (u32_t)) + break; + GETLONG(uval, inp); + len -= sizeof (u32_t); + if (uval & SRPVAL_EBIT) { + printer(arg, " E"); + uval &= ~SRPVAL_EBIT; + } + if (uval != 0) { + printer(arg, " f<%X>", uval); + } + printer(arg, " ", len, inp, + len == SHA_DIGESTSIZE ? "" : "?"); + INCPTR(len, inp); + len = 0; + break; + + case EAPSRP_ACK: + break; + + case EAPSRP_LWRECHALLENGE: + printer(arg, " ", len, inp, + len == SHA_DIGESTSIZE ? "" : "?"); + if ((vallen = len) > SHA_DIGESTSIZE) + vallen = SHA_DIGESTSIZE; + INCPTR(vallen, inp); + len -= vallen; + break; + default: + break; + } + break; + default: + break; + } + break; + + case EAP_SUCCESS: /* No payload expected for these! */ + case EAP_FAILURE: + default: + break; + + truncated: + printer(arg, " "); + break; + } + + if (len > 8) + printer(arg, "%8B...", inp); + else if (len > 0) + printer(arg, "%.*B", len, inp); + INCPTR(len, inp); + + return (inp - pstart); } #endif /* PRINTPKT_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/ecp.c b/components/net/lwip-2.1.2/src/netif/ppp/ecp.c index 4d84f60931..5b3b331560 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/ecp.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/ecp.c @@ -92,8 +92,8 @@ static void ecp_protrej (int unit); */ #if PRINTPKT_SUPPORT static int ecp_printpkt (const u_char *pkt, int len, - void (*printer) (void *, char *, ...), - void *arg); + void (*printer) (void *, char *, ...), + void *arg); #endif /* PRINTPKT_SUPPORT */ /* static void ecp_datainput (int unit, u_char *pkt, int len); @@ -129,10 +129,10 @@ const struct protent ecp_protent = { }; 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 */ +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 const fsm_callbacks ecp_callbacks = { NULL, /* ecp_resetci, */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/eui64.c b/components/net/lwip-2.1.2/src/netif/ppp/eui64.c index 01493bc1f8..9e25fc4c2f 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/eui64.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/eui64.c @@ -48,8 +48,8 @@ char *eui64_ntoa(eui64_t e) { static char buf[20]; sprintf(buf, "%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]); + 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; } diff --git a/components/net/lwip-2.1.2/src/netif/ppp/fsm.c b/components/net/lwip-2.1.2/src/netif/ppp/fsm.c index b1f08affff..9df98b1ef7 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/fsm.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/fsm.c @@ -68,7 +68,7 @@ static void fsm_rtermack(fsm *f); static void fsm_rcoderej(fsm *f, u_char *inp, int len); static void fsm_sconfreq(fsm *f, int retransmit); -#define PROTO_NAME(f) ((f)->callbacks->proto_name) +#define PROTO_NAME(f) ((f)->callbacks->proto_name) /* * fsm_init - Initialize fsm. @@ -79,7 +79,7 @@ void fsm_init(fsm *f) { ppp_pcb *pcb = f->pcb; f->state = PPP_FSM_INITIAL; f->flags = 0; - f->id = 0; /* XXX Start with random id? */ + f->id = 0; /* XXX Start with random id? */ f->maxnakloops = pcb->settings.fsm_max_nak_loops; f->term_reason_len = 0; } @@ -91,22 +91,22 @@ void fsm_init(fsm *f) { void fsm_lowerup(fsm *f) { switch( f->state ){ case PPP_FSM_INITIAL: - f->state = PPP_FSM_CLOSED; - break; + f->state = PPP_FSM_CLOSED; + break; case PPP_FSM_STARTING: - if( f->flags & OPT_SILENT ) - f->state = PPP_FSM_STOPPED; - else { - /* Send an initial configure-request */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - } - break; + if( f->flags & OPT_SILENT ) + f->state = PPP_FSM_STOPPED; + else { + /* Send an initial configure-request */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + } + break; default: - FSMDEBUG(("%s: Up event in state %d!", PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Up event in state %d!", PROTO_NAME(f), f->state)); + /* no break */ } } @@ -119,37 +119,37 @@ void fsm_lowerup(fsm *f) { void fsm_lowerdown(fsm *f) { switch( f->state ){ case PPP_FSM_CLOSED: - f->state = PPP_FSM_INITIAL; - break; + f->state = PPP_FSM_INITIAL; + break; case PPP_FSM_STOPPED: - f->state = PPP_FSM_STARTING; - if( f->callbacks->starting ) - (*f->callbacks->starting)(f); - break; + f->state = PPP_FSM_STARTING; + if( f->callbacks->starting ) + (*f->callbacks->starting)(f); + break; case PPP_FSM_CLOSING: - f->state = PPP_FSM_INITIAL; - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - break; + f->state = PPP_FSM_INITIAL; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + break; case PPP_FSM_STOPPING: case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - f->state = PPP_FSM_STARTING; - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - break; + f->state = PPP_FSM_STARTING; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + break; case PPP_FSM_OPENED: - if( f->callbacks->down ) - (*f->callbacks->down)(f); - f->state = PPP_FSM_STARTING; - break; + if( f->callbacks->down ) + (*f->callbacks->down)(f); + f->state = PPP_FSM_STARTING; + break; default: - FSMDEBUG(("%s: Down event in state %d!", PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Down event in state %d!", PROTO_NAME(f), f->state)); + /* no break */ } } @@ -160,34 +160,34 @@ void fsm_lowerdown(fsm *f) { void fsm_open(fsm *f) { switch( f->state ){ case PPP_FSM_INITIAL: - f->state = PPP_FSM_STARTING; - if( f->callbacks->starting ) - (*f->callbacks->starting)(f); - break; + f->state = PPP_FSM_STARTING; + if( f->callbacks->starting ) + (*f->callbacks->starting)(f); + break; case PPP_FSM_CLOSED: - if( f->flags & OPT_SILENT ) - f->state = PPP_FSM_STOPPED; - else { - /* Send an initial configure-request */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - } - break; + if( f->flags & OPT_SILENT ) + f->state = PPP_FSM_STOPPED; + else { + /* Send an initial configure-request */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + } + break; case PPP_FSM_CLOSING: - f->state = PPP_FSM_STOPPING; - /* fall through */ - /* no break */ + f->state = PPP_FSM_STOPPING; + /* fall through */ + /* no break */ case PPP_FSM_STOPPED: case PPP_FSM_OPENED: - if( f->flags & OPT_RESTART ){ - fsm_lowerdown(f); - fsm_lowerup(f); - } - break; + if( f->flags & OPT_RESTART ){ + fsm_lowerdown(f); + fsm_lowerup(f); + } + break; default: - break; + break; } } @@ -201,25 +201,25 @@ static void terminate_layer(fsm *f, int nextstate) { ppp_pcb *pcb = f->pcb; if( f->state != PPP_FSM_OPENED ) - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ else if( f->callbacks->down ) - (*f->callbacks->down)(f); /* Inform upper layers we're down */ + (*f->callbacks->down)(f); /* Inform upper layers we're down */ /* Init restart counter and send Terminate-Request */ f->retransmits = pcb->settings.fsm_max_term_transmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (const u_char *) f->term_reason, f->term_reason_len); + (const 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 == PPP_FSM_CLOSING ? PPP_FSM_CLOSED : PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - return; + /* + * 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 == PPP_FSM_CLOSING ? PPP_FSM_CLOSED : PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + return; } TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); @@ -239,23 +239,23 @@ void fsm_close(fsm *f, const char *reason) { f->term_reason_len = (reason == NULL? 0: (u8_t)LWIP_MIN(strlen(reason), 0xFF) ); switch( f->state ){ case PPP_FSM_STARTING: - f->state = PPP_FSM_INITIAL; - break; + f->state = PPP_FSM_INITIAL; + break; case PPP_FSM_STOPPED: - f->state = PPP_FSM_CLOSED; - break; + f->state = PPP_FSM_CLOSED; + break; case PPP_FSM_STOPPING: - f->state = PPP_FSM_CLOSING; - break; + f->state = PPP_FSM_CLOSING; + break; case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: case PPP_FSM_OPENED: - terminate_layer(f, PPP_FSM_CLOSING); - break; + terminate_layer(f, PPP_FSM_CLOSING); + break; default: - break; + break; } } @@ -270,44 +270,44 @@ static void fsm_timeout(void *arg) { switch (f->state) { case PPP_FSM_CLOSING: case PPP_FSM_STOPPING: - if( f->retransmits <= 0 ){ - /* - * We've waited for an ack long enough. Peer probably heard us. - */ - f->state = (f->state == PPP_FSM_CLOSING)? PPP_FSM_CLOSED: PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - } else { - /* Send Terminate-Request */ - fsm_sdata(f, TERMREQ, f->reqid = ++f->id, - (const u_char *) f->term_reason, f->term_reason_len); - TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); - --f->retransmits; - } - break; + if( f->retransmits <= 0 ){ + /* + * We've waited for an ack long enough. Peer probably heard us. + */ + f->state = (f->state == PPP_FSM_CLOSING)? PPP_FSM_CLOSED: PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + } else { + /* Send Terminate-Request */ + fsm_sdata(f, TERMREQ, f->reqid = ++f->id, + (const u_char *) f->term_reason, f->term_reason_len); + TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); + --f->retransmits; + } + break; case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - if (f->retransmits <= 0) { - ppp_warn("%s: timeout sending Config-Requests", PROTO_NAME(f)); - f->state = PPP_FSM_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 == PPP_FSM_ACKRCVD ) - f->state = PPP_FSM_REQSENT; - } - break; + if (f->retransmits <= 0) { + ppp_warn("%s: timeout sending Config-Requests", PROTO_NAME(f)); + f->state = PPP_FSM_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 == PPP_FSM_ACKRCVD ) + f->state = PPP_FSM_REQSENT; + } + break; default: - FSMDEBUG(("%s: Timeout event in state %d!", PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Timeout event in state %d!", PROTO_NAME(f), f->state)); + /* no break */ } } @@ -326,26 +326,26 @@ void fsm_input(fsm *f, u_char *inpacket, int l) { */ inp = inpacket; if (l < HEADERLEN) { - FSMDEBUG(("fsm_input(%x): Rcvd short header.", f->protocol)); - return; + 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; + FSMDEBUG(("fsm_input(%x): Rcvd illegal length.", f->protocol)); + return; } if (len > l) { - FSMDEBUG(("fsm_input(%x): Rcvd short packet.", f->protocol)); - return; + FSMDEBUG(("fsm_input(%x): Rcvd short packet.", f->protocol)); + return; } - len -= HEADERLEN; /* subtract header length */ + len -= HEADERLEN; /* subtract header length */ if( f->state == PPP_FSM_INITIAL || f->state == PPP_FSM_STARTING ){ - FSMDEBUG(("fsm_input(%x): Rcvd packet in state %d.", - f->protocol, f->state)); - return; + FSMDEBUG(("fsm_input(%x): Rcvd packet in state %d.", + f->protocol, f->state)); + return; } /* @@ -353,35 +353,35 @@ void fsm_input(fsm *f, u_char *inpacket, int l) { */ switch (code) { case CONFREQ: - fsm_rconfreq(f, id, inp, len); - break; - + fsm_rconfreq(f, id, inp, len); + break; + case CONFACK: - fsm_rconfack(f, id, inp, len); - break; - + fsm_rconfack(f, id, inp, len); + break; + case CONFNAK: case CONFREJ: - fsm_rconfnakrej(f, code, id, inp, len); - break; - + fsm_rconfnakrej(f, code, id, inp, len); + break; + case TERMREQ: - fsm_rtermreq(f, id, inp, len); - break; - + fsm_rtermreq(f, id, inp, len); + break; + case TERMACK: - fsm_rtermack(f); - break; - + fsm_rtermack(f); + break; + case CODEREJ: - fsm_rcoderej(f, inp, len); - break; - + 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; + if( !f->callbacks->extcode + || !(*f->callbacks->extcode)(f, code, id, inp, len) ) + fsm_sdata(f, CODEREJ, ++f->id, inpacket, len + HEADERLEN); + break; } } @@ -394,61 +394,61 @@ static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { switch( f->state ){ case PPP_FSM_CLOSED: - /* Go away, we're closed */ - fsm_sdata(f, TERMACK, id, NULL, 0); - return; + /* Go away, we're closed */ + fsm_sdata(f, TERMACK, id, NULL, 0); + return; case PPP_FSM_CLOSING: case PPP_FSM_STOPPING: - return; + return; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; case PPP_FSM_STOPPED: - /* Negotiation started by our peer */ - fsm_sconfreq(f, 0); /* Send initial Configure-Request */ - f->state = PPP_FSM_REQSENT; - break; + /* Negotiation started by our peer */ + fsm_sconfreq(f, 0); /* Send initial Configure-Request */ + f->state = PPP_FSM_REQSENT; + break; default: - break; + 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); + 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 */ + code = CONFREJ; /* Reject all CI */ else - code = CONFACK; + code = CONFACK; /* send the Ack, Nak or Rej to the peer */ fsm_sdata(f, code, id, inp, len); if (code == CONFACK) { - if (f->state == PPP_FSM_ACKRCVD) { - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - f->state = PPP_FSM_OPENED; - if (f->callbacks->up) - (*f->callbacks->up)(f); /* Inform upper layers */ - } else - f->state = PPP_FSM_ACKSENT; - f->nakloops = 0; + if (f->state == PPP_FSM_ACKRCVD) { + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + f->state = PPP_FSM_OPENED; + if (f->callbacks->up) + (*f->callbacks->up)(f); /* Inform upper layers */ + } else + f->state = PPP_FSM_ACKSENT; + f->nakloops = 0; } else { - /* we sent CONFACK or CONFREJ */ - if (f->state != PPP_FSM_ACKRCVD) - f->state = PPP_FSM_REQSENT; - if( code == CONFNAK ) - ++f->nakloops; + /* we sent CONFACK or CONFREJ */ + if (f->state != PPP_FSM_ACKRCVD) + f->state = PPP_FSM_REQSENT; + if( code == CONFNAK ) + ++f->nakloops; } } @@ -459,13 +459,13 @@ static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) { ppp_pcb *pcb = f->pcb; - if (id != f->reqid || f->seen_ack) /* Expected id? */ - return; /* Nope, toss... */ + 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 */ - ppp_error("Received bad configure-ack: %P", inp, len); - return; + (len == 0)) ){ + /* Ack is bad - ignore it */ + ppp_error("Received bad configure-ack: %P", inp, len); + return; } f->seen_ack = 1; f->rnakloops = 0; @@ -473,38 +473,38 @@ static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) { switch (f->state) { case PPP_FSM_CLOSED: case PPP_FSM_STOPPED: - fsm_sdata(f, TERMACK, id, NULL, 0); - break; + fsm_sdata(f, TERMACK, id, NULL, 0); + break; case PPP_FSM_REQSENT: - f->state = PPP_FSM_ACKRCVD; - f->retransmits = pcb->settings.fsm_max_conf_req_transmits; - break; + f->state = PPP_FSM_ACKRCVD; + f->retransmits = pcb->settings.fsm_max_conf_req_transmits; + break; case PPP_FSM_ACKRCVD: - /* Huh? an extra valid Ack? oh well... */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - break; + /* Huh? an extra valid Ack? oh well... */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + break; case PPP_FSM_ACKSENT: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - f->state = PPP_FSM_OPENED; - f->retransmits = pcb->settings.fsm_max_conf_req_transmits; - if (f->callbacks->up) - (*f->callbacks->up)(f); /* Inform upper layers */ - break; + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + f->state = PPP_FSM_OPENED; + f->retransmits = pcb->settings.fsm_max_conf_req_transmits; + if (f->callbacks->up) + (*f->callbacks->up)(f); /* Inform upper layers */ + break; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; default: - break; + break; } } @@ -516,24 +516,24 @@ static void fsm_rconfnakrej(fsm *f, int code, int 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 (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))) { - ppp_error("Received bad configure-nak: %P", inp, len); - return; - } + ++f->rnakloops; + treat_as_reject = (f->rnakloops >= f->maxnakloops); + if (f->callbacks->nakci == NULL + || !(ret = f->callbacks->nakci(f, inp, len, treat_as_reject))) { + ppp_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))) { - ppp_error("Received bad configure-rej: %P", inp, len); - return; - } + f->rnakloops = 0; + if (f->callbacks->rejci == NULL + || !(ret = f->callbacks->rejci(f, inp, len))) { + ppp_error("Received bad configure-rej: %P", inp, len); + return; + } } f->seen_ack = 1; @@ -541,35 +541,35 @@ static void fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) { switch (f->state) { case PPP_FSM_CLOSED: case PPP_FSM_STOPPED: - fsm_sdata(f, TERMACK, id, NULL, 0); - break; + fsm_sdata(f, TERMACK, id, NULL, 0); + break; case PPP_FSM_REQSENT: case PPP_FSM_ACKSENT: - /* They didn't agree to what we wanted - try another request */ - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - if (ret < 0) - f->state = PPP_FSM_STOPPED; /* kludge for stopping CCP */ - else - fsm_sconfreq(f, 0); /* Send Configure-Request */ - break; + /* They didn't agree to what we wanted - try another request */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + if (ret < 0) + f->state = PPP_FSM_STOPPED; /* kludge for stopping CCP */ + else + fsm_sconfreq(f, 0); /* Send Configure-Request */ + break; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; case PPP_FSM_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 = PPP_FSM_REQSENT; - break; + /* 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 = PPP_FSM_REQSENT; + break; default: - break; + break; } } @@ -583,22 +583,22 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) { switch (f->state) { case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - f->state = PPP_FSM_REQSENT; /* Start over but keep trying */ - break; + f->state = PPP_FSM_REQSENT; /* Start over but keep trying */ + break; case PPP_FSM_OPENED: - if (len > 0) { - ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p); - } else - ppp_info("%s terminated by peer", PROTO_NAME(f)); - f->retransmits = 0; - f->state = PPP_FSM_STOPPING; - if (f->callbacks->down) - (*f->callbacks->down)(f); /* Inform upper layers */ - TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); - break; + if (len > 0) { + ppp_info("%s terminated by peer (%0.*v)", PROTO_NAME(f), len, p); + } else + ppp_info("%s terminated by peer", PROTO_NAME(f)); + f->retransmits = 0; + f->state = PPP_FSM_STOPPING; + if (f->callbacks->down) + (*f->callbacks->down)(f); /* Inform upper layers */ + TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); + break; default: - break; + break; } fsm_sdata(f, TERMACK, id, NULL, 0); @@ -611,30 +611,30 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) { static void fsm_rtermack(fsm *f) { switch (f->state) { case PPP_FSM_CLOSING: - UNTIMEOUT(fsm_timeout, f); - f->state = PPP_FSM_CLOSED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + UNTIMEOUT(fsm_timeout, f); + f->state = PPP_FSM_CLOSED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_STOPPING: - UNTIMEOUT(fsm_timeout, f); - f->state = PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + UNTIMEOUT(fsm_timeout, f); + f->state = PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_ACKRCVD: - f->state = PPP_FSM_REQSENT; - break; + f->state = PPP_FSM_REQSENT; + break; case PPP_FSM_OPENED: - if (f->callbacks->down) - (*f->callbacks->down)(f); /* Inform upper layers */ - fsm_sconfreq(f, 0); - f->state = PPP_FSM_REQSENT; - break; + if (f->callbacks->down) + (*f->callbacks->down)(f); /* Inform upper layers */ + fsm_sconfreq(f, 0); + f->state = PPP_FSM_REQSENT; + break; default: - break; + break; } } @@ -646,15 +646,15 @@ static void fsm_rcoderej(fsm *f, u_char *inp, int len) { u_char code, id; if (len < HEADERLEN) { - FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!")); - return; + FSMDEBUG(("fsm_rcoderej: Rcvd short Code-Reject packet!")); + return; } GETCHAR(code, inp); GETCHAR(id, inp); ppp_warn("%s: Rcvd Code-Reject for code %d, id %d", PROTO_NAME(f), code, id); if( f->state == PPP_FSM_ACKRCVD ) - f->state = PPP_FSM_REQSENT; + f->state = PPP_FSM_REQSENT; } @@ -666,36 +666,36 @@ static void fsm_rcoderej(fsm *f, u_char *inp, int len) { void fsm_protreject(fsm *f) { switch( f->state ){ case PPP_FSM_CLOSING: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - /* fall through */ - /* no break */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + /* fall through */ + /* no break */ case PPP_FSM_CLOSED: - f->state = PPP_FSM_CLOSED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + f->state = PPP_FSM_CLOSED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_STOPPING: case PPP_FSM_REQSENT: case PPP_FSM_ACKRCVD: case PPP_FSM_ACKSENT: - UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ - /* fall through */ - /* no break */ + UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ + /* fall through */ + /* no break */ case PPP_FSM_STOPPED: - f->state = PPP_FSM_STOPPED; - if( f->callbacks->finished ) - (*f->callbacks->finished)(f); - break; + f->state = PPP_FSM_STOPPED; + if( f->callbacks->finished ) + (*f->callbacks->finished)(f); + break; case PPP_FSM_OPENED: - terminate_layer(f, PPP_FSM_STOPPING); - break; + terminate_layer(f, PPP_FSM_STOPPING); + break; default: - FSMDEBUG(("%s: Protocol-reject event in state %d!", - PROTO_NAME(f), f->state)); - /* no break */ + FSMDEBUG(("%s: Protocol-reject event in state %d!", + PROTO_NAME(f), f->state)); + /* no break */ } } @@ -710,17 +710,17 @@ static void fsm_sconfreq(fsm *f, int retransmit) { int cilen; if( f->state != PPP_FSM_REQSENT && f->state != PPP_FSM_ACKRCVD && f->state != PPP_FSM_ACKSENT ){ - /* Not currently negotiating - reset options */ - if( f->callbacks->resetci ) - (*f->callbacks->resetci)(f); - f->nakloops = 0; - f->rnakloops = 0; + /* 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 = pcb->settings.fsm_max_conf_req_transmits; - f->reqid = ++f->id; + /* New request - reset retransmission counter, use new ID */ + f->retransmits = pcb->settings.fsm_max_conf_req_transmits; + f->reqid = ++f->id; } f->seen_ack = 0; @@ -729,11 +729,11 @@ static void fsm_sconfreq(fsm *f, int retransmit) { * Make up the request packet */ if( f->callbacks->cilen && f->callbacks->addci ){ - cilen = (*f->callbacks->cilen)(f); - if( cilen > pcb->peer_mru - HEADERLEN ) - cilen = pcb->peer_mru - HEADERLEN; + cilen = (*f->callbacks->cilen)(f); + if( cilen > pcb->peer_mru - HEADERLEN ) + cilen = pcb->peer_mru - HEADERLEN; } else - cilen = 0; + cilen = 0; p = pbuf_alloc(PBUF_RAW, (u16_t)(cilen + HEADERLEN + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE); if(NULL == p) @@ -750,8 +750,8 @@ static void fsm_sconfreq(fsm *f, int retransmit) { PUTCHAR(f->reqid, outp); PUTSHORT(cilen + HEADERLEN, outp); if (cilen != 0) { - (*f->callbacks->addci)(f, outp, &cilen); - LWIP_ASSERT("cilen == p->len - HEADERLEN - PPP_HDRLEN", cilen == p->len - HEADERLEN - PPP_HDRLEN); + (*f->callbacks->addci)(f, outp, &cilen); + LWIP_ASSERT("cilen == p->len - HEADERLEN - PPP_HDRLEN", cilen == p->len - HEADERLEN - PPP_HDRLEN); } ppp_write(pcb, p); @@ -775,7 +775,7 @@ void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen) /* Adjust length to be smaller than MTU */ if (datalen > pcb->peer_mru - HEADERLEN) - datalen = pcb->peer_mru - HEADERLEN; + datalen = pcb->peer_mru - HEADERLEN; outlen = datalen + HEADERLEN; p = pbuf_alloc(PBUF_RAW, (u16_t)(outlen + PPP_HDRLEN), PPP_CTRL_PBUF_TYPE); @@ -788,7 +788,7 @@ void fsm_sdata(fsm *f, u_char code, u_char id, const u_char *data, int datalen) outp = (u_char*)p->payload; if (datalen) /* && data != outp + PPP_HDRLEN + HEADERLEN) -- was only for fsm_sconfreq() */ - MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen); + MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen); MAKEHEADER(outp, f->protocol); PUTCHAR(code, outp); PUTCHAR(id, outp); diff --git a/components/net/lwip-2.1.2/src/netif/ppp/ipcp.c b/components/net/lwip-2.1.2/src/netif/ppp/ipcp.c index b7c766eb0b..feb1f4becc 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/ipcp.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/ipcp.c @@ -66,15 +66,15 @@ #if 0 /* UNUSED */ /* global vars */ -u32_t netmask = 0; /* IP netmask to set on interface */ +u32_t netmask = 0; /* IP netmask to set on interface */ #endif /* UNUSED */ #if 0 /* UNUSED */ -bool disable_defaultip = 0; /* Don't use hostname for default IP adrs */ +bool disable_defaultip = 0; /* Don't use hostname for default IP adrs */ #endif /* UNUSED */ #if 0 /* moved to ppp_settings */ -bool noremoteip = 0; /* Let him have no IP address */ +bool noremoteip = 0; /* Let him have no IP address */ #endif /* moved to ppp_setting */ #if 0 /* UNUSED */ @@ -96,47 +96,47 @@ struct notifier *ip_down_notifier = NULL; /* local vars */ #if 0 /* moved to ppp_pcb */ -static int default_route_set[NUM_PPP]; /* Have set up a default route */ -static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ -static int ipcp_is_up; /* have called np_up() */ -static int ipcp_is_open; /* haven't called np_finished() */ -static bool ask_for_local; /* request our address from peer */ +static int default_route_set[NUM_PPP]; /* Have set up a default route */ +static int proxy_arp_set[NUM_PPP]; /* Have created proxy arp entry */ +static int ipcp_is_up; /* have called np_up() */ +static int ipcp_is_open; /* haven't called np_finished() */ +static bool ask_for_local; /* request our address from peer */ #endif /* moved to ppp_pcb */ #if 0 /* UNUSED */ -static char vj_value[8]; /* string form of vj option value */ -static char netmask_str[20]; /* string form of netmask value */ +static char vj_value[8]; /* string form of vj option value */ +static char netmask_str[20]; /* string form of netmask value */ #endif /* UNUSED */ /* * Callbacks for fsm code. (CI = Configuration Information) */ -static void ipcp_resetci(fsm *f); /* Reset our CI */ -static int ipcp_cilen(fsm *f); /* Return length of our CI */ +static void ipcp_resetci(fsm *f); /* Reset our CI */ +static int ipcp_cilen(fsm *f); /* Return length of our CI */ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI */ -static int ipcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */ +static int ipcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject);/* Peer nak'd our CI */ -static int ipcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */ +static int ipcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree); /* Rcv CI */ -static void ipcp_up(fsm *f); /* We're UP */ -static void ipcp_down(fsm *f); /* We're DOWN */ -static void ipcp_finished(fsm *f); /* Don't need lower layer */ +static void ipcp_up(fsm *f); /* We're UP */ +static void ipcp_down(fsm *f); /* We're DOWN */ +static void ipcp_finished(fsm *f); /* Don't need lower layer */ static const fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */ - ipcp_resetci, /* Reset our Configuration Information */ - ipcp_cilen, /* Length of our Configuration Information */ - ipcp_addci, /* Add our Configuration Information */ - ipcp_ackci, /* ACK our Configuration Information */ - ipcp_nakci, /* NAK our Configuration Information */ - ipcp_rejci, /* Reject our Configuration Information */ - ipcp_reqci, /* Request peer's Configuration Information */ - ipcp_up, /* Called when fsm reaches OPENED state */ - ipcp_down, /* Called when fsm leaves OPENED state */ - NULL, /* Called when we want the lower layer up */ - ipcp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - NULL, /* Called to handle protocol-specific codes */ - "IPCP" /* String name of protocol */ + ipcp_resetci, /* Reset our Configuration Information */ + ipcp_cilen, /* Length of our Configuration Information */ + ipcp_addci, /* Add our Configuration Information */ + ipcp_ackci, /* ACK our Configuration Information */ + ipcp_nakci, /* NAK our Configuration Information */ + ipcp_rejci, /* Reject our Configuration Information */ + ipcp_reqci, /* Request peer's Configuration Information */ + ipcp_up, /* Called when fsm reaches OPENED state */ + ipcp_down, /* Called when fsm leaves OPENED state */ + NULL, /* Called when we want the lower layer up */ + ipcp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + NULL, /* Called to handle protocol-specific codes */ + "IPCP" /* String name of protocol */ }; /* @@ -209,13 +209,13 @@ static option_t ipcp_option_list[] = { &ipcp_wantoptions[0].default_route }, { "replacedefaultroute", o_bool, - &ipcp_wantoptions[0].replace_default_route, + &ipcp_wantoptions[0].replace_default_route, "Replace default route", 1 }, { "noreplacedefaultroute", o_bool, - &ipcp_allowoptions[0].replace_default_route, + &ipcp_allowoptions[0].replace_default_route, "Never replace default route", OPT_A2COPY, - &ipcp_wantoptions[0].replace_default_route }, + &ipcp_wantoptions[0].replace_default_route }, { "proxyarp", o_bool, &ipcp_wantoptions[0].proxy_arp, "Add proxy ARP entry", OPT_ENABLE|1, &ipcp_allowoptions[0].proxy_arp }, { "noproxyarp", o_bool, &ipcp_allowoptions[0].proxy_arp, @@ -265,7 +265,7 @@ static void ipcp_input(ppp_pcb *pcb, u_char *p, int len); static void ipcp_protrej(ppp_pcb *pcb); #if PRINTPKT_SUPPORT static int ipcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ #if PPP_OPTIONS static void ip_check_options (void); @@ -312,15 +312,15 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re /* * Lengths of configuration options. */ -#define CILEN_VOID 2 -#define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ -#define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ -#define CILEN_ADDR 6 /* new-style single address option */ -#define CILEN_ADDRS 10 /* old-style dual address option */ +#define CILEN_VOID 2 +#define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ +#define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ +#define CILEN_ADDR 6 /* new-style single address option */ +#define CILEN_ADDRS 10 /* old-style dual address option */ -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") #if 0 /* UNUSED, already defined by lwIP */ /* @@ -351,11 +351,11 @@ setvjslots(argv) int value; if (!int_option(*argv, &value)) - return 0; + return 0; if (value < 2 || value > 16) { - option_error("vj-max-slots value must be between 2 and 16"); - return 0; + option_error("vj-max-slots value must be between 2 and 16"); + return 0; } ipcp_wantoptions [0].maxslotindex = ipcp_allowoptions[0].maxslotindex = value - 1; @@ -375,21 +375,21 @@ setdnsaddr(argv) dns = inet_addr(*argv); if (dns == (u32_t) -1) { - if ((hp = gethostbyname(*argv)) == NULL) { - option_error("invalid address parameter '%s' for ms-dns option", - *argv); - return 0; - } - dns = *(u32_t *)hp->h_addr; + if ((hp = gethostbyname(*argv)) == NULL) { + option_error("invalid address parameter '%s' for ms-dns option", + *argv); + return 0; + } + dns = *(u32_t *)hp->h_addr; } /* We take the last 2 values given, the 2nd-last as the primary and the last as the secondary. If only one is given it becomes both primary and secondary. */ if (ipcp_allowoptions[0].dnsaddr[1] == 0) - ipcp_allowoptions[0].dnsaddr[0] = dns; + ipcp_allowoptions[0].dnsaddr[0] = dns; else - ipcp_allowoptions[0].dnsaddr[0] = ipcp_allowoptions[0].dnsaddr[1]; + ipcp_allowoptions[0].dnsaddr[0] = ipcp_allowoptions[0].dnsaddr[1]; /* always set the secondary address value. */ ipcp_allowoptions[0].dnsaddr[1] = dns; @@ -411,21 +411,21 @@ setwinsaddr(argv) wins = inet_addr(*argv); if (wins == (u32_t) -1) { - if ((hp = gethostbyname(*argv)) == NULL) { - option_error("invalid address parameter '%s' for ms-wins option", - *argv); - return 0; - } - wins = *(u32_t *)hp->h_addr; + if ((hp = gethostbyname(*argv)) == NULL) { + option_error("invalid address parameter '%s' for ms-wins option", + *argv); + return 0; + } + wins = *(u32_t *)hp->h_addr; } /* We take the last 2 values given, the 2nd-last as the primary and the last as the secondary. If only one is given it becomes both primary and secondary. */ if (ipcp_allowoptions[0].winsaddr[1] == 0) - ipcp_allowoptions[0].winsaddr[0] = wins; + ipcp_allowoptions[0].winsaddr[0] = wins; else - ipcp_allowoptions[0].winsaddr[0] = ipcp_allowoptions[0].winsaddr[1]; + ipcp_allowoptions[0].winsaddr[0] = ipcp_allowoptions[0].winsaddr[1]; /* always set the secondary address value. */ ipcp_allowoptions[0].winsaddr[1] = wins; @@ -455,52 +455,52 @@ setipaddr(arg, argv, doit) * IP address pair separated by ":". */ if ((colon = strchr(arg, ':')) == NULL) - return 0; + return 0; if (!doit) - return 1; - + return 1; + /* * If colon first character, then no local addr. */ if (colon != arg && option_priority >= prio_local) { - *colon = '\0'; - if ((local = inet_addr(arg)) == (u32_t) -1) { - if ((hp = gethostbyname(arg)) == NULL) { - option_error("unknown host: %s", arg); - return 0; - } - local = *(u32_t *)hp->h_addr; - } - if (bad_ip_adrs(local)) { - option_error("bad local IP address %s", ip_ntoa(local)); - return 0; - } - if (local != 0) - wo->ouraddr = local; - *colon = ':'; - prio_local = option_priority; - } - + *colon = '\0'; + if ((local = inet_addr(arg)) == (u32_t) -1) { + if ((hp = gethostbyname(arg)) == NULL) { + option_error("unknown host: %s", arg); + return 0; + } + local = *(u32_t *)hp->h_addr; + } + if (bad_ip_adrs(local)) { + option_error("bad local IP address %s", ip_ntoa(local)); + return 0; + } + if (local != 0) + wo->ouraddr = local; + *colon = ':'; + prio_local = option_priority; + } + /* * If colon last character, then no remote addr. */ if (*++colon != '\0' && option_priority >= prio_remote) { - if ((remote = inet_addr(colon)) == (u32_t) -1) { - if ((hp = gethostbyname(colon)) == NULL) { - option_error("unknown host: %s", colon); - return 0; - } - remote = *(u32_t *)hp->h_addr; - if (remote_name[0] == 0) - strlcpy(remote_name, colon, sizeof(remote_name)); - } - if (bad_ip_adrs(remote)) { - option_error("bad remote IP address %s", ip_ntoa(remote)); - return 0; - } - if (remote != 0) - wo->hisaddr = remote; - prio_remote = option_priority; + if ((remote = inet_addr(colon)) == (u32_t) -1) { + if ((hp = gethostbyname(colon)) == NULL) { + option_error("unknown host: %s", colon); + return 0; + } + remote = *(u32_t *)hp->h_addr; + if (remote_name[0] == 0) + strlcpy(remote_name, colon, sizeof(remote_name)); + } + if (bad_ip_adrs(remote)) { + option_error("bad remote IP address %s", ip_ntoa(remote)); + return 0; + } + if (remote != 0) + wo->hisaddr = remote; + prio_remote = option_priority; } return 1; @@ -512,13 +512,13 @@ printipaddr(opt, printer, arg) void (*printer) (void *, char *, ...); void *arg; { - ipcp_options *wo = &ipcp_wantoptions[0]; + ipcp_options *wo = &ipcp_wantoptions[0]; - if (wo->ouraddr != 0) - printer(arg, "%I", wo->ouraddr); - printer(arg, ":"); - if (wo->hisaddr != 0) - printer(arg, "%I", wo->hisaddr); + if (wo->ouraddr != 0) + printer(arg, "%I", wo->ouraddr); + printer(arg, ":"); + if (wo->hisaddr != 0) + printer(arg, "%I", wo->hisaddr); } /* @@ -542,8 +542,8 @@ setnetmask(argv) mask = lwip_htonl(mask); if (n == 0 || p[n] != 0 || (netmask & ~mask) != 0) { - option_error("invalid netmask value '%s'", *argv); - return 0; + option_error("invalid netmask value '%s'", *argv); + return 0; } netmask = mask; @@ -563,23 +563,23 @@ parse_dotted_ip(p, vp) v = 0; for (n = 3;; --n) { - b = strtoul(p, &endp, 0); - if (endp == p) - return 0; - if (b > 255) { - if (n < 3) - return 0; - /* accept e.g. 0xffffff00 */ - *vp = b; - return endp - p0; - } - v |= b << (n * 8); - p = endp; - if (n == 0) - break; - if (*p != '.') - return 0; - ++p; + b = strtoul(p, &endp, 0); + if (endp == p) + return 0; + if (b > 255) { + if (n < 3) + return 0; + /* accept e.g. 0xffffff00 */ + *vp = b; + return endp - p0; + } + v |= b << (n * 8); + p = endp; + if (n == 0) + break; + if (*p != '.') + return 0; + ++p; } *vp = v; return p - p0; @@ -716,23 +716,23 @@ static void ipcp_resetci(fsm *f) { ipcp_options *ao = &pcb->ipcp_allowoptions; wo->req_addr = (wo->neg_addr || wo->old_addrs) && - (ao->neg_addr || ao->old_addrs); + (ao->neg_addr || ao->old_addrs); if (wo->ouraddr == 0) - wo->accept_local = 1; + wo->accept_local = 1; if (wo->hisaddr == 0) - wo->accept_remote = 1; + wo->accept_remote = 1; #if LWIP_DNS - wo->req_dns1 = wo->req_dns2 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */ + wo->req_dns1 = wo->req_dns2 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */ #endif /* LWIP_DNS */ *go = *wo; if (!pcb->ask_for_local) - go->ouraddr = 0; + go->ouraddr = 0; #if 0 /* UNUSED */ if (ip_choose_hook) { - ip_choose_hook(&wo->hisaddr); - if (wo->hisaddr) { - wo->accept_remote = 0; - } + ip_choose_hook(&wo->hisaddr); + if (wo->hisaddr) { + wo->accept_remote = 0; + } } #endif /* UNUSED */ BZERO(&pcb->ipcp_hisoptions, sizeof(ipcp_options)); @@ -751,16 +751,16 @@ static int ipcp_cilen(fsm *f) { #endif /* VJ_SUPPORT */ ipcp_options *ho = &pcb->ipcp_hisoptions; -#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0) +#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0) #if VJ_SUPPORT -#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) +#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) #endif /* VJ_SUPPORT */ -#define LENCIADDR(neg) (neg ? CILEN_ADDR : 0) +#define LENCIADDR(neg) (neg ? CILEN_ADDR : 0) #if LWIP_DNS -#define LENCIDNS(neg) LENCIADDR(neg) +#define LENCIDNS(neg) LENCIADDR(neg) #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ -#define LENCIWINS(neg) LENCIADDR(neg) +#define LENCIWINS(neg) LENCIADDR(neg) #endif /* UNUSED - WINS */ /* @@ -768,34 +768,34 @@ static int ipcp_cilen(fsm *f) { * forms because we have received old forms from the peer. */ if (go->neg_addr && go->old_addrs && !ho->neg_addr && ho->old_addrs) - go->neg_addr = 0; + go->neg_addr = 0; #if VJ_SUPPORT if (wo->neg_vj && !go->neg_vj && !go->old_vj) { - /* try an older style of VJ negotiation */ - /* use the old style only if the peer did */ - if (ho->neg_vj && ho->old_vj) { - go->neg_vj = 1; - go->old_vj = 1; - go->vj_protocol = ho->vj_protocol; - } + /* try an older style of VJ negotiation */ + /* use the old style only if the peer did */ + if (ho->neg_vj && ho->old_vj) { + go->neg_vj = 1; + go->old_vj = 1; + go->vj_protocol = ho->vj_protocol; + } } #endif /* VJ_SUPPORT */ return (LENCIADDRS(!go->neg_addr && go->old_addrs) + #if VJ_SUPPORT - LENCIVJ(go->neg_vj, go->old_vj) + + LENCIVJ(go->neg_vj, go->old_vj) + #endif /* VJ_SUPPORT */ - LENCIADDR(go->neg_addr) + + LENCIADDR(go->neg_addr) + #if LWIP_DNS - LENCIDNS(go->req_dns1) + - LENCIDNS(go->req_dns2) + + LENCIDNS(go->req_dns1) + + LENCIDNS(go->req_dns2) + #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - LENCIWINS(go->winsaddr[0]) + - LENCIWINS(go->winsaddr[1]) + + LENCIWINS(go->winsaddr[0]) + + LENCIWINS(go->winsaddr[1]) + #endif /* UNUSED - WINS */ - 0); + 0); } @@ -810,86 +810,86 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { #define ADDCIADDRS(opt, neg, val1, val2) \ if (neg) { \ - if (len >= CILEN_ADDRS) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDRS, ucp); \ - l = lwip_ntohl(val1); \ - PUTLONG(l, ucp); \ - l = lwip_ntohl(val2); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDRS; \ - } else \ - go->old_addrs = 0; \ + if (len >= CILEN_ADDRS) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDRS, ucp); \ + l = lwip_ntohl(val1); \ + PUTLONG(l, ucp); \ + l = lwip_ntohl(val2); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDRS; \ + } else \ + go->old_addrs = 0; \ } #if VJ_SUPPORT #define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ - int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ - if (len >= vjlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(vjlen, ucp); \ - PUTSHORT(val, ucp); \ - if (!old) { \ - PUTCHAR(maxslotindex, ucp); \ - PUTCHAR(cflag, ucp); \ - } \ - len -= vjlen; \ - } else \ - neg = 0; \ + int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ + if (len >= vjlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(vjlen, ucp); \ + PUTSHORT(val, ucp); \ + if (!old) { \ + PUTCHAR(maxslotindex, ucp); \ + PUTCHAR(cflag, ucp); \ + } \ + len -= vjlen; \ + } else \ + neg = 0; \ } #endif /* VJ_SUPPORT */ #define ADDCIADDR(opt, neg, val) \ if (neg) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = lwip_ntohl(val); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else \ - neg = 0; \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = lwip_ntohl(val); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else \ + neg = 0; \ } #if LWIP_DNS #define ADDCIDNS(opt, neg, addr) \ if (neg) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = lwip_ntohl(addr); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else \ - neg = 0; \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = lwip_ntohl(addr); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else \ + neg = 0; \ } #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define ADDCIWINS(opt, addr) \ if (addr) { \ - if (len >= CILEN_ADDR) { \ - u32_t l; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_ADDR, ucp); \ - l = lwip_ntohl(addr); \ - PUTLONG(l, ucp); \ - len -= CILEN_ADDR; \ - } else \ - addr = 0; \ + if (len >= CILEN_ADDR) { \ + u32_t l; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_ADDR, ucp); \ + l = lwip_ntohl(addr); \ + PUTLONG(l, ucp); \ + len -= CILEN_ADDR; \ + } else \ + addr = 0; \ } #endif /* UNUSED - WINS */ ADDCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, - go->hisaddr); + go->hisaddr); #if VJ_SUPPORT ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); + go->maxslotindex, go->cflag); #endif /* VJ_SUPPORT */ ADDCIADDR(CI_ADDR, go->neg_addr, go->ouraddr); @@ -905,7 +905,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { ADDCIWINS(CI_MS_WINS2, go->winsaddr[1]); #endif /* UNUSED - WINS */ - + *lenp -= len; } @@ -915,8 +915,8 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { * Called by fsm_rconfack, Receive Configure ACK. * * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. + * 0 - Ack was bad. + * 1 - Ack was good. */ static int ipcp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -936,105 +936,105 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { #define ACKCIADDRS(opt, neg, val1, val2) \ if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDRS) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDRS || \ - citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (val1 != cilong) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (val2 != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDRS) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDRS || \ + citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (val1 != cilong) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (val2 != cilong) \ + goto bad; \ } #if VJ_SUPPORT #define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ - int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ - if ((len -= vjlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != vjlen || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ - if (!old) { \ - GETCHAR(cimaxslotindex, p); \ - if (cimaxslotindex != maxslotindex) \ - goto bad; \ - GETCHAR(cicflag, p); \ - if (cicflag != cflag) \ - goto bad; \ - } \ + int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ + if ((len -= vjlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != vjlen || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ + if (!old) { \ + GETCHAR(cimaxslotindex, p); \ + if (cimaxslotindex != maxslotindex) \ + goto bad; \ + GETCHAR(cicflag, p); \ + if (cicflag != cflag) \ + goto bad; \ + } \ } #endif /* VJ_SUPPORT */ #define ACKCIADDR(opt, neg, val) \ if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || \ - citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (val != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || \ + citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (val != cilong) \ + goto bad; \ } #if LWIP_DNS #define ACKCIDNS(opt, neg, addr) \ if (neg) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (addr != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (addr != cilong) \ + goto bad; \ } #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define ACKCIWINS(opt, addr) \ if (addr) { \ - u32_t l; \ - if ((len -= CILEN_ADDR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_ADDR || citype != opt) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - if (addr != cilong) \ - goto bad; \ + u32_t l; \ + if ((len -= CILEN_ADDR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_ADDR || citype != opt) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + if (addr != cilong) \ + goto bad; \ } #endif /* UNUSED - WINS */ ACKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, go->ouraddr, - go->hisaddr); + go->hisaddr); #if VJ_SUPPORT ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); + go->maxslotindex, go->cflag); #endif /* VJ_SUPPORT */ ACKCIADDR(CI_ADDR, go->neg_addr, go->ouraddr); @@ -1055,7 +1055,7 @@ static int ipcp_ackci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; return (1); bad: @@ -1070,8 +1070,8 @@ bad: * Calback from fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. * * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. + * 0 - Nak was bad. + * 1 - Nak was good. */ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; @@ -1085,8 +1085,8 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { #if LWIP_DNS u32_t cidnsaddr; #endif /* LWIP_DNS */ - ipcp_options no; /* options we've seen Naks for */ - ipcp_options try_; /* options to request next time */ + ipcp_options no; /* options we've seen Naks for */ + ipcp_options try_; /* options to request next time */ BZERO(&no, sizeof(no)); try_ = *go; @@ -1098,58 +1098,58 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ #define NAKCIADDRS(opt, neg, code) \ if ((neg) && \ - (cilen = p[1]) == CILEN_ADDRS && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - ciaddr1 = lwip_htonl(l); \ - GETLONG(l, p); \ - ciaddr2 = lwip_htonl(l); \ - no.old_addrs = 1; \ - code \ + (cilen = p[1]) == CILEN_ADDRS && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + ciaddr1 = lwip_htonl(l); \ + GETLONG(l, p); \ + ciaddr2 = lwip_htonl(l); \ + no.old_addrs = 1; \ + code \ } #if VJ_SUPPORT #define NAKCIVJ(opt, neg, code) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ + ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ code \ } #endif /* VJ_SUPPORT */ #define NAKCIADDR(opt, neg, code) \ if (go->neg && \ - (cilen = p[1]) == CILEN_ADDR && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - ciaddr1 = lwip_htonl(l); \ - no.neg = 1; \ - code \ + (cilen = p[1]) == CILEN_ADDR && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + ciaddr1 = lwip_htonl(l); \ + no.neg = 1; \ + code \ } #if LWIP_DNS #define NAKCIDNS(opt, neg, code) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cidnsaddr = lwip_htonl(l); \ - no.neg = 1; \ - code \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cidnsaddr = lwip_htonl(l); \ + no.neg = 1; \ + code \ } #endif /* LWIP_DNS */ @@ -1158,19 +1158,19 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * from our idea, only if the accept_{local,remote} flag is set. */ NAKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, - if (treat_as_reject) { - try_.old_addrs = 0; - } else { - if (go->accept_local && ciaddr1) { - /* take his idea of our address */ - try_.ouraddr = ciaddr1; - } - if (go->accept_remote && ciaddr2) { - /* take his idea of his address */ - try_.hisaddr = ciaddr2; - } - } - ); + if (treat_as_reject) { + try_.old_addrs = 0; + } else { + if (go->accept_local && ciaddr1) { + /* take his idea of our address */ + try_.ouraddr = ciaddr1; + } + if (go->accept_remote && ciaddr2) { + /* take his idea of his address */ + try_.hisaddr = ciaddr2; + } + } + ); #if VJ_SUPPORT /* @@ -1180,57 +1180,57 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * the peer wants. */ NAKCIVJ(CI_COMPRESSTYPE, neg_vj, - if (treat_as_reject) { - try_.neg_vj = 0; - } else if (cilen == CILEN_VJ) { - GETCHAR(cimaxslotindex, p); - GETCHAR(cicflag, p); - if (cishort == IPCP_VJ_COMP) { - try_.old_vj = 0; - if (cimaxslotindex < go->maxslotindex) - try_.maxslotindex = cimaxslotindex; - if (!cicflag) - try_.cflag = 0; - } else { - try_.neg_vj = 0; - } - } else { - if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { - try_.old_vj = 1; - try_.vj_protocol = cishort; - } else { - try_.neg_vj = 0; - } - } - ); + if (treat_as_reject) { + try_.neg_vj = 0; + } else if (cilen == CILEN_VJ) { + GETCHAR(cimaxslotindex, p); + GETCHAR(cicflag, p); + if (cishort == IPCP_VJ_COMP) { + try_.old_vj = 0; + if (cimaxslotindex < go->maxslotindex) + try_.maxslotindex = cimaxslotindex; + if (!cicflag) + try_.cflag = 0; + } else { + try_.neg_vj = 0; + } + } else { + if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { + try_.old_vj = 1; + try_.vj_protocol = cishort; + } else { + try_.neg_vj = 0; + } + } + ); #endif /* VJ_SUPPORT */ NAKCIADDR(CI_ADDR, neg_addr, - if (treat_as_reject) { - try_.neg_addr = 0; - try_.old_addrs = 0; - } else if (go->accept_local && ciaddr1) { - /* take his idea of our address */ - try_.ouraddr = ciaddr1; - } - ); + if (treat_as_reject) { + try_.neg_addr = 0; + try_.old_addrs = 0; + } else if (go->accept_local && ciaddr1) { + /* take his idea of our address */ + try_.ouraddr = ciaddr1; + } + ); #if LWIP_DNS NAKCIDNS(CI_MS_DNS1, req_dns1, - if (treat_as_reject) { - try_.req_dns1 = 0; - } else { - try_.dnsaddr[0] = cidnsaddr; - } - ); + if (treat_as_reject) { + try_.req_dns1 = 0; + } else { + try_.dnsaddr[0] = cidnsaddr; + } + ); NAKCIDNS(CI_MS_DNS2, req_dns2, - if (treat_as_reject) { - try_.req_dns2 = 0; - } else { - try_.dnsaddr[1] = cidnsaddr; - } - ); + if (treat_as_reject) { + try_.req_dns2 = 0; + } else { + try_.dnsaddr[1] = cidnsaddr; + } + ); #endif /* #if LWIP_DNS */ /* @@ -1242,81 +1242,81 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * peers get huffy if we don't. */ while (len >= CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) - goto bad; - next = p + cilen - 2; + GETCHAR(citype, p); + GETCHAR(cilen, p); + if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) + goto bad; + next = p + cilen - 2; - switch (citype) { + switch (citype) { #if VJ_SUPPORT - case CI_COMPRESSTYPE: - if (go->neg_vj || no.neg_vj || - (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) - goto bad; - no.neg_vj = 1; - break; + case CI_COMPRESSTYPE: + if (go->neg_vj || no.neg_vj || + (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) + goto bad; + no.neg_vj = 1; + break; #endif /* VJ_SUPPORT */ - case CI_ADDRS: - if ((!go->neg_addr && go->old_addrs) || no.old_addrs - || cilen != CILEN_ADDRS) - goto bad; - try_.neg_addr = 0; - GETLONG(l, p); - ciaddr1 = lwip_htonl(l); - if (ciaddr1 && go->accept_local) - try_.ouraddr = ciaddr1; - GETLONG(l, p); - ciaddr2 = lwip_htonl(l); - if (ciaddr2 && go->accept_remote) - try_.hisaddr = ciaddr2; - no.old_addrs = 1; - break; - case CI_ADDR: - if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) - goto bad; - try_.old_addrs = 0; - GETLONG(l, p); - ciaddr1 = lwip_htonl(l); - if (ciaddr1 && go->accept_local) - try_.ouraddr = ciaddr1; - if (try_.ouraddr != 0) - try_.neg_addr = 1; - no.neg_addr = 1; - break; + case CI_ADDRS: + if ((!go->neg_addr && go->old_addrs) || no.old_addrs + || cilen != CILEN_ADDRS) + goto bad; + try_.neg_addr = 0; + GETLONG(l, p); + ciaddr1 = lwip_htonl(l); + if (ciaddr1 && go->accept_local) + try_.ouraddr = ciaddr1; + GETLONG(l, p); + ciaddr2 = lwip_htonl(l); + if (ciaddr2 && go->accept_remote) + try_.hisaddr = ciaddr2; + no.old_addrs = 1; + break; + case CI_ADDR: + if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) + goto bad; + try_.old_addrs = 0; + GETLONG(l, p); + ciaddr1 = lwip_htonl(l); + if (ciaddr1 && go->accept_local) + try_.ouraddr = ciaddr1; + if (try_.ouraddr != 0) + try_.neg_addr = 1; + no.neg_addr = 1; + break; #if LWIP_DNS - case CI_MS_DNS1: - if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR) - goto bad; - GETLONG(l, p); - try_.dnsaddr[0] = lwip_htonl(l); - try_.req_dns1 = 1; - no.req_dns1 = 1; - break; - case CI_MS_DNS2: - if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR) - goto bad; - GETLONG(l, p); - try_.dnsaddr[1] = lwip_htonl(l); - try_.req_dns2 = 1; - no.req_dns2 = 1; - break; + case CI_MS_DNS1: + if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR) + goto bad; + GETLONG(l, p); + try_.dnsaddr[0] = lwip_htonl(l); + try_.req_dns1 = 1; + no.req_dns1 = 1; + break; + case CI_MS_DNS2: + if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR) + goto bad; + GETLONG(l, p); + try_.dnsaddr[1] = lwip_htonl(l); + try_.req_dns2 = 1; + no.req_dns2 = 1; + break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - case CI_MS_WINS1: - case CI_MS_WINS2: - if (cilen != CILEN_ADDR) - goto bad; - GETLONG(l, p); - ciaddr1 = lwip_htonl(l); - if (ciaddr1) - try_.winsaddr[citype == CI_MS_WINS2] = ciaddr1; - break; + case CI_MS_WINS1: + case CI_MS_WINS2: + if (cilen != CILEN_ADDR) + goto bad; + GETLONG(l, p); + ciaddr1 = lwip_htonl(l); + if (ciaddr1) + try_.winsaddr[citype == CI_MS_WINS2] = ciaddr1; + break; #endif /* UNUSED - WINS */ - default: - break; - } - p = next; + default: + break; + } + p = next; } /* @@ -1324,7 +1324,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If there are any remaining options, we ignore them. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; @@ -1347,7 +1347,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { u_short cishort; #endif /* VJ_SUPPORT */ u32_t cilong; - ipcp_options try_; /* options to request next time */ + ipcp_options try_; /* options to request next time */ try_ = *go; /* @@ -1357,107 +1357,107 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { */ #define REJCIADDRS(opt, neg, val1, val2) \ if ((neg) && \ - (cilen = p[1]) == CILEN_ADDRS && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val1) \ - goto bad; \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val2) \ - goto bad; \ - try_.old_addrs = 0; \ + (cilen = p[1]) == CILEN_ADDRS && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val1) \ + goto bad; \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val2) \ + goto bad; \ + try_.old_addrs = 0; \ } #if VJ_SUPPORT #define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ if (go->neg && \ - p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ - len >= p[1] && \ - p[0] == opt) { \ - len -= p[1]; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) \ - goto bad; \ - if (!old) { \ - GETCHAR(cimaxslotindex, p); \ - if (cimaxslotindex != maxslot) \ - goto bad; \ - GETCHAR(ciflag, p); \ - if (ciflag != cflag) \ - goto bad; \ + p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ + len >= p[1] && \ + p[0] == opt) { \ + len -= p[1]; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) \ + goto bad; \ + if (!old) { \ + GETCHAR(cimaxslotindex, p); \ + if (cimaxslotindex != maxslot) \ + goto bad; \ + GETCHAR(ciflag, p); \ + if (ciflag != cflag) \ + goto bad; \ } \ - try_.neg = 0; \ + try_.neg = 0; \ } #endif /* VJ_SUPPORT */ #define REJCIADDR(opt, neg, val) \ if (go->neg && \ - (cilen = p[1]) == CILEN_ADDR && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != val) \ - goto bad; \ - try_.neg = 0; \ + (cilen = p[1]) == CILEN_ADDR && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != val) \ + goto bad; \ + try_.neg = 0; \ } #if LWIP_DNS #define REJCIDNS(opt, neg, dnsaddr) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != dnsaddr) \ - goto bad; \ - try_.neg = 0; \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != dnsaddr) \ + goto bad; \ + try_.neg = 0; \ } #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ #define REJCIWINS(opt, addr) \ if (addr && \ - ((cilen = p[1]) == CILEN_ADDR) && \ - len >= cilen && \ - p[0] == opt) { \ - u32_t l; \ - len -= cilen; \ - INCPTR(2, p); \ - GETLONG(l, p); \ - cilong = lwip_htonl(l); \ - /* Check rejected value. */ \ - if (cilong != addr) \ - goto bad; \ - try_.winsaddr[opt == CI_MS_WINS2] = 0; \ + ((cilen = p[1]) == CILEN_ADDR) && \ + len >= cilen && \ + p[0] == opt) { \ + u32_t l; \ + len -= cilen; \ + INCPTR(2, p); \ + GETLONG(l, p); \ + cilong = lwip_htonl(l); \ + /* Check rejected value. */ \ + if (cilong != addr) \ + goto bad; \ + try_.winsaddr[opt == CI_MS_WINS2] = 0; \ } #endif /* UNUSED - WINS */ REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, - go->ouraddr, go->hisaddr); + go->ouraddr, go->hisaddr); #if VJ_SUPPORT REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, - go->maxslotindex, go->cflag); + go->maxslotindex, go->cflag); #endif /* VJ_SUPPORT */ REJCIADDR(CI_ADDR, neg_addr, go->ouraddr); @@ -1478,12 +1478,12 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; bad: @@ -1508,17 +1508,17 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { ipcp_options *wo = &pcb->ipcp_wantoptions; ipcp_options *ho = &pcb->ipcp_hisoptions; ipcp_options *ao = &pcb->ipcp_allowoptions; - u_char *cip, *next; /* Pointer to current and next CIs */ - u_short cilen, citype; /* Parsed len, type */ + u_char *cip, *next; /* Pointer to current and next CIs */ + u_short cilen, citype; /* Parsed len, type */ #if VJ_SUPPORT - u_short cishort; /* Parsed short value */ + u_short cishort; /* Parsed short value */ #endif /* VJ_SUPPORT */ u32_t tl, ciaddr1, ciaddr2;/* Parsed address values */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *ucp = inp; /* Pointer to current output char */ - int l = *len; /* Length left */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *ucp = inp; /* Pointer to current output char */ + int l = *len; /* Length left */ #if VJ_SUPPORT u_char maxslotindex, cflag; #endif /* VJ_SUPPORT */ @@ -1530,243 +1530,243 @@ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { * Reset all his options. */ BZERO(ho, sizeof(*ho)); - + /* * Process all his options. */ next = inp; while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - IPCPDEBUG(("ipcp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_ADDRS: - if (!ao->old_addrs || ho->neg_addr || - cilen != CILEN_ADDRS) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no address, or if we both have his address but - * disagree about it, then NAK it with our idea. - * In particular, if we don't know his address, but he does, - * then accept it. - */ - GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = lwip_htonl(tl); - if (ciaddr1 != wo->hisaddr - && (ciaddr1 == 0 || !wo->accept_remote)) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(wo->hisaddr); - PUTLONG(tl, p); - } - } else if (ciaddr1 == 0 && wo->hisaddr == 0) { - /* - * If neither we nor he knows his address, reject the option. - */ - orc = CONFREJ; - wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ - break; - } - - /* - * If he doesn't know our address, or if we both have our address - * but disagree about it, then NAK it with our idea. - */ - GETLONG(tl, p); /* Parse desination address (ours) */ - ciaddr2 = lwip_htonl(tl); - if (ciaddr2 != wo->ouraddr) { - if (ciaddr2 == 0 || !wo->accept_local) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(wo->ouraddr); - PUTLONG(tl, p); - } - } else { - wo->ouraddr = ciaddr2; /* accept peer's idea */ - } - } - - ho->old_addrs = 1; - ho->hisaddr = ciaddr1; - ho->ouraddr = ciaddr2; - break; - - case CI_ADDR: - if (!ao->neg_addr || ho->old_addrs || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no address, or if we both have his address but - * disagree about it, then NAK it with our idea. - * In particular, if we don't know his address, but he does, - * then accept it. - */ - GETLONG(tl, p); /* Parse source address (his) */ - ciaddr1 = lwip_htonl(tl); - if (ciaddr1 != wo->hisaddr - && (ciaddr1 == 0 || !wo->accept_remote)) { - orc = CONFNAK; - if (!reject_if_disagree) { - DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(wo->hisaddr); - PUTLONG(tl, p); - } - } else if (ciaddr1 == 0 && wo->hisaddr == 0) { - /* - * Don't ACK an address of 0.0.0.0 - reject it instead. - */ - orc = CONFREJ; - wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ - break; - } - - ho->neg_addr = 1; - ho->hisaddr = ciaddr1; - break; + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + IPCPDEBUG(("ipcp_reqci: bad CI length!")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_ADDRS: + if (!ao->old_addrs || ho->neg_addr || + cilen != CILEN_ADDRS) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no address, or if we both have his address but + * disagree about it, then NAK it with our idea. + * In particular, if we don't know his address, but he does, + * then accept it. + */ + GETLONG(tl, p); /* Parse source address (his) */ + ciaddr1 = lwip_htonl(tl); + if (ciaddr1 != wo->hisaddr + && (ciaddr1 == 0 || !wo->accept_remote)) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = lwip_ntohl(wo->hisaddr); + PUTLONG(tl, p); + } + } else if (ciaddr1 == 0 && wo->hisaddr == 0) { + /* + * If neither we nor he knows his address, reject the option. + */ + orc = CONFREJ; + wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ + break; + } + + /* + * If he doesn't know our address, or if we both have our address + * but disagree about it, then NAK it with our idea. + */ + GETLONG(tl, p); /* Parse desination address (ours) */ + ciaddr2 = lwip_htonl(tl); + if (ciaddr2 != wo->ouraddr) { + if (ciaddr2 == 0 || !wo->accept_local) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = lwip_ntohl(wo->ouraddr); + PUTLONG(tl, p); + } + } else { + wo->ouraddr = ciaddr2; /* accept peer's idea */ + } + } + + ho->old_addrs = 1; + ho->hisaddr = ciaddr1; + ho->ouraddr = ciaddr2; + break; + + case CI_ADDR: + if (!ao->neg_addr || ho->old_addrs || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no address, or if we both have his address but + * disagree about it, then NAK it with our idea. + * In particular, if we don't know his address, but he does, + * then accept it. + */ + GETLONG(tl, p); /* Parse source address (his) */ + ciaddr1 = lwip_htonl(tl); + if (ciaddr1 != wo->hisaddr + && (ciaddr1 == 0 || !wo->accept_remote)) { + orc = CONFNAK; + if (!reject_if_disagree) { + DECPTR(sizeof(u32_t), p); + tl = lwip_ntohl(wo->hisaddr); + PUTLONG(tl, p); + } + } else if (ciaddr1 == 0 && wo->hisaddr == 0) { + /* + * Don't ACK an address of 0.0.0.0 - reject it instead. + */ + orc = CONFREJ; + wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ + break; + } + + ho->neg_addr = 1; + ho->hisaddr = ciaddr1; + break; #if LWIP_DNS - case CI_MS_DNS1: - case CI_MS_DNS2: - /* Microsoft primary or secondary DNS request */ - d = citype == CI_MS_DNS2; - - /* If we do not have a DNS address then we cannot send it */ - if (ao->dnsaddr[d] == 0 || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETLONG(tl, p); - if (lwip_htonl(tl) != ao->dnsaddr[d]) { + case CI_MS_DNS1: + case CI_MS_DNS2: + /* Microsoft primary or secondary DNS request */ + d = citype == CI_MS_DNS2; + + /* If we do not have a DNS address then we cannot send it */ + if (ao->dnsaddr[d] == 0 || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETLONG(tl, p); + if (lwip_htonl(tl) != ao->dnsaddr[d]) { DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(ao->dnsaddr[d]); - PUTLONG(tl, p); - orc = CONFNAK; + tl = lwip_ntohl(ao->dnsaddr[d]); + PUTLONG(tl, p); + orc = CONFNAK; } break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - case CI_MS_WINS1: - case CI_MS_WINS2: - /* Microsoft primary or secondary WINS request */ - d = citype == CI_MS_WINS2; - - /* If we do not have a DNS address then we cannot send it */ - if (ao->winsaddr[d] == 0 || - cilen != CILEN_ADDR) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETLONG(tl, p); - if (lwip_htonl(tl) != ao->winsaddr[d]) { + case CI_MS_WINS1: + case CI_MS_WINS2: + /* Microsoft primary or secondary WINS request */ + d = citype == CI_MS_WINS2; + + /* If we do not have a DNS address then we cannot send it */ + if (ao->winsaddr[d] == 0 || + cilen != CILEN_ADDR) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETLONG(tl, p); + if (lwip_htonl(tl) != ao->winsaddr[d]) { DECPTR(sizeof(u32_t), p); - tl = lwip_ntohl(ao->winsaddr[d]); - PUTLONG(tl, p); - orc = CONFNAK; + tl = lwip_ntohl(ao->winsaddr[d]); + PUTLONG(tl, p); + orc = CONFNAK; } break; #endif /* UNUSED - WINS */ #if VJ_SUPPORT - case CI_COMPRESSTYPE: - if (!ao->neg_vj || - (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - - if (!(cishort == IPCP_VJ_COMP || - (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { - orc = CONFREJ; - break; - } - - ho->neg_vj = 1; - ho->vj_protocol = cishort; - if (cilen == CILEN_VJ) { - GETCHAR(maxslotindex, p); - if (maxslotindex > ao->maxslotindex) { - orc = CONFNAK; - if (!reject_if_disagree){ - DECPTR(1, p); - PUTCHAR(ao->maxslotindex, p); - } - } - GETCHAR(cflag, p); - if (cflag && !ao->cflag) { - orc = CONFNAK; - if (!reject_if_disagree){ - DECPTR(1, p); - PUTCHAR(wo->cflag, p); - } - } - ho->maxslotindex = maxslotindex; - ho->cflag = cflag; - } else { - ho->old_vj = 1; - ho->maxslotindex = MAX_STATES - 1; - ho->cflag = 1; - } - break; + case CI_COMPRESSTYPE: + if (!ao->neg_vj || + (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) { + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + + if (!(cishort == IPCP_VJ_COMP || + (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { + orc = CONFREJ; + break; + } + + ho->neg_vj = 1; + ho->vj_protocol = cishort; + if (cilen == CILEN_VJ) { + GETCHAR(maxslotindex, p); + if (maxslotindex > ao->maxslotindex) { + orc = CONFNAK; + if (!reject_if_disagree){ + DECPTR(1, p); + PUTCHAR(ao->maxslotindex, p); + } + } + GETCHAR(cflag, p); + if (cflag && !ao->cflag) { + orc = CONFNAK; + if (!reject_if_disagree){ + DECPTR(1, p); + PUTCHAR(wo->cflag, p); + } + } + ho->maxslotindex = maxslotindex; + ho->cflag = cflag; + } else { + ho->old_vj = 1; + ho->maxslotindex = MAX_STATES - 1; + ho->cflag = 1; + } + break; #endif /* VJ_SUPPORT */ - default: - orc = CONFREJ; - break; - } + default: + orc = CONFREJ; + break; + } endswitch: - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree) /* Getting fed up with sending NAKs? */ - orc = CONFREJ; /* Get tough if so */ - else { - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - if (rc == CONFACK) { /* Ack'd all prior CIs? */ - rc = CONFNAK; /* Not anymore... */ - ucp = inp; /* Backup */ - } - } - } - - if (orc == CONFREJ && /* Reject this CI */ - rc != CONFREJ) { /* but no prior ones? */ - rc = CONFREJ; - ucp = inp; /* Backup */ - } - - /* Need to move CI? */ - if (ucp != cip) - MEMCPY(ucp, cip, cilen); /* Move it */ - - /* Update output pointer */ - INCPTR(cilen, ucp); + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) /* but prior CI wasnt? */ + continue; /* Don't send this one */ + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree) /* Getting fed up with sending NAKs? */ + orc = CONFREJ; /* Get tough if so */ + else { + if (rc == CONFREJ) /* Rejecting prior CI? */ + continue; /* Don't send this one */ + if (rc == CONFACK) { /* Ack'd all prior CIs? */ + rc = CONFNAK; /* Not anymore... */ + ucp = inp; /* Backup */ + } + } + } + + if (orc == CONFREJ && /* Reject this CI */ + rc != CONFREJ) { /* but no prior ones? */ + rc = CONFREJ; + ucp = inp; /* Backup */ + } + + /* Need to move CI? */ + if (ucp != cip) + MEMCPY(ucp, cip, cilen); /* Move it */ + + /* Update output pointer */ + INCPTR(cilen, ucp); } /* @@ -1777,21 +1777,21 @@ endswitch: * option safely. */ if (rc != CONFREJ && !ho->neg_addr && !ho->old_addrs && - wo->req_addr && !reject_if_disagree && !pcb->settings.noremoteip) { - if (rc == CONFACK) { - rc = CONFNAK; - ucp = inp; /* reset pointer */ - wo->req_addr = 0; /* don't ask again */ - } - PUTCHAR(CI_ADDR, ucp); - PUTCHAR(CILEN_ADDR, ucp); - tl = lwip_ntohl(wo->hisaddr); - PUTLONG(tl, ucp); - } - - *len = ucp - inp; /* Compute output length */ + wo->req_addr && !reject_if_disagree && !pcb->settings.noremoteip) { + if (rc == CONFACK) { + rc = CONFNAK; + ucp = inp; /* reset pointer */ + wo->req_addr = 0; /* don't ask again */ + } + PUTCHAR(CI_ADDR, ucp); + PUTCHAR(CILEN_ADDR, ucp); + tl = lwip_ntohl(wo->hisaddr); + PUTLONG(tl, ucp); + } + + *len = ucp - inp; /* Compute output length */ IPCPDEBUG(("ipcp: returning Configure-%s", CODENAME(rc))); - return (rc); /* Return final code */ + return (rc); /* Return final code */ } @@ -1812,17 +1812,17 @@ ip_check_options() * If local IP address already given, don't bother. */ if (wo->ouraddr == 0 && !disable_defaultip) { - /* - * Look up our hostname (possibly with domain name appended) - * and take the first IP address as our local IP address. - * If there isn't an IP address for our hostname, too bad. - */ - wo->accept_local = 1; /* don't insist on this default value */ - if ((hp = gethostbyname(hostname)) != NULL) { - local = *(u32_t *)hp->h_addr; - if (local != 0 && !bad_ip_adrs(local)) - wo->ouraddr = local; - } + /* + * Look up our hostname (possibly with domain name appended) + * and take the first IP address as our local IP address. + * If there isn't an IP address for our hostname, too bad. + */ + wo->accept_local = 1; /* don't insist on this default value */ + if ((hp = gethostbyname(hostname)) != NULL) { + local = *(u32_t *)hp->h_addr; + if (local != 0 && !bad_ip_adrs(local)) + wo->ouraddr = local; + } } ask_for_local = wo->ouraddr != 0 || !disable_defaultip; } @@ -1841,37 +1841,37 @@ ip_demand_conf(u) ipcp_options *wo = &ipcp_wantoptions[u]; if (wo->hisaddr == 0 && !pcb->settings.noremoteip) { - /* make up an arbitrary address for the peer */ - wo->hisaddr = lwip_htonl(0x0a707070 + ifunit); - wo->accept_remote = 1; + /* make up an arbitrary address for the peer */ + wo->hisaddr = lwip_htonl(0x0a707070 + ifunit); + wo->accept_remote = 1; } if (wo->ouraddr == 0) { - /* make up an arbitrary address for us */ - wo->ouraddr = lwip_htonl(0x0a404040 + ifunit); - wo->accept_local = 1; - ask_for_local = 0; /* don't tell the peer this address */ + /* make up an arbitrary address for us */ + wo->ouraddr = lwip_htonl(0x0a404040 + ifunit); + wo->accept_local = 1; + ask_for_local = 0; /* don't tell the peer this address */ } if (!sifaddr(pcb, wo->ouraddr, wo->hisaddr, get_mask(wo->ouraddr))) - return 0; + return 0; if (!sifup(pcb)) - return 0; + return 0; if (!sifnpmode(pcb, PPP_IP, NPMODE_QUEUE)) - return 0; + return 0; #if 0 /* UNUSED */ if (wo->default_route) - if (sifdefaultroute(pcb, wo->ouraddr, wo->hisaddr, - wo->replace_default_route)) - default_route_set[u] = 1; + if (sifdefaultroute(pcb, wo->ouraddr, wo->hisaddr, + wo->replace_default_route)) + default_route_set[u] = 1; #endif /* UNUSED */ #if 0 /* UNUSED - PROXY ARP */ if (wo->proxy_arp) - if (sifproxyarp(pcb, wo->hisaddr)) - proxy_arp_set[u] = 1; + if (sifproxyarp(pcb, wo->hisaddr)) + proxy_arp_set[u] = 1; #endif /* UNUSED - PROXY ARP */ ppp_notice("local IP address %I", wo->ouraddr); if (wo->hisaddr) - ppp_notice("remote IP address %I", wo->hisaddr); + ppp_notice("remote IP address %I", wo->hisaddr); return 1; } @@ -1895,46 +1895,46 @@ static void ipcp_up(fsm *f) { * We must have a non-zero IP address for both ends of the link. */ if (!ho->neg_addr && !ho->old_addrs) - ho->hisaddr = wo->hisaddr; + ho->hisaddr = wo->hisaddr; if (!(go->neg_addr || go->old_addrs) && (wo->neg_addr || wo->old_addrs) - && wo->ouraddr != 0) { - ppp_error("Peer refused to agree to our IP address"); - ipcp_close(f->pcb, "Refused our IP address"); - return; + && wo->ouraddr != 0) { + ppp_error("Peer refused to agree to our IP address"); + ipcp_close(f->pcb, "Refused our IP address"); + return; } if (go->ouraddr == 0) { - ppp_error("Could not determine local IP address"); - ipcp_close(f->pcb, "Could not determine local IP address"); - return; + ppp_error("Could not determine local IP address"); + ipcp_close(f->pcb, "Could not determine local IP address"); + return; } if (ho->hisaddr == 0 && !pcb->settings.noremoteip) { - ho->hisaddr = lwip_htonl(0x0a404040); - ppp_warn("Could not determine remote IP address: defaulting to %I", - ho->hisaddr); + ho->hisaddr = lwip_htonl(0x0a404040); + ppp_warn("Could not determine remote IP address: defaulting to %I", + ho->hisaddr); } #if 0 /* UNUSED */ script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0); if (ho->hisaddr != 0) - script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); + script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); #endif /* UNUSED */ #if LWIP_DNS if (!go->req_dns1) - go->dnsaddr[0] = 0; + go->dnsaddr[0] = 0; if (!go->req_dns2) - go->dnsaddr[1] = 0; + go->dnsaddr[1] = 0; #if 0 /* UNUSED */ if (go->dnsaddr[0]) - script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); + script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); if (go->dnsaddr[1]) - script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); + script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); #endif /* UNUSED */ if (pcb->settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { - sdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); + sdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); #if 0 /* UNUSED */ - script_setenv("USEPEERDNS", "1", 0); - create_resolv(go->dnsaddr[0], go->dnsaddr[1]); + script_setenv("USEPEERDNS", "1", 0); + create_resolv(go->dnsaddr[0], go->dnsaddr[1]); #endif /* UNUSED */ } #endif /* LWIP_DNS */ @@ -1943,29 +1943,29 @@ static void ipcp_up(fsm *f) { * Check that the peer is allowed to use the IP address it wants. */ if (ho->hisaddr != 0) { - u32_t addr = lwip_ntohl(ho->hisaddr); - if ((addr >> IP_CLASSA_NSHIFT) == IP_LOOPBACKNET - || IP_MULTICAST(addr) || IP_BADCLASS(addr) - /* - * For now, consider that PPP in server mode with peer required - * to authenticate must provide the peer IP address, reject any - * IP address wanted by peer different than the one we wanted. - */ + u32_t addr = lwip_ntohl(ho->hisaddr); + if ((addr >> IP_CLASSA_NSHIFT) == IP_LOOPBACKNET + || IP_MULTICAST(addr) || IP_BADCLASS(addr) + /* + * For now, consider that PPP in server mode with peer required + * to authenticate must provide the peer IP address, reject any + * IP address wanted by peer different than the one we wanted. + */ #if PPP_SERVER && PPP_AUTH_SUPPORT - || (pcb->settings.auth_required && wo->hisaddr != ho->hisaddr) + || (pcb->settings.auth_required && wo->hisaddr != ho->hisaddr) #endif /* PPP_SERVER && PPP_AUTH_SUPPORT */ - ) { - ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); - ipcp_close(pcb, "Unauthorized remote IP address"); - return; - } + ) { + ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); + ipcp_close(pcb, "Unauthorized remote IP address"); + return; + } } #if 0 /* Unused */ /* Upstream checking code */ if (ho->hisaddr != 0 && !auth_ip_addr(f->unit, ho->hisaddr)) { - ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); - ipcp_close(f->unit, "Unauthorized remote IP address"); - return; + ppp_error("Peer is not authorized to use remote address %I", ho->hisaddr); + ipcp_close(f->unit, "Unauthorized remote IP address"); + return; } #endif /* Unused */ @@ -1981,114 +1981,114 @@ static void ipcp_up(fsm *f) { * interface to pass IP packets. */ if (demand) { - if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) { - ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr, - wo->replace_default_route); - if (go->ouraddr != wo->ouraddr) { - ppp_warn("Local IP address changed to %I", go->ouraddr); - script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0); - wo->ouraddr = go->ouraddr; - } else - script_unsetenv("OLDIPLOCAL"); - if (ho->hisaddr != wo->hisaddr && wo->hisaddr != 0) { - ppp_warn("Remote IP address changed to %I", ho->hisaddr); - script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0); - wo->hisaddr = ho->hisaddr; - } else - script_unsetenv("OLDIPREMOTE"); - - /* Set the interface to the new addresses */ - mask = get_mask(go->ouraddr); - if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { + if (go->ouraddr != wo->ouraddr || ho->hisaddr != wo->hisaddr) { + ipcp_clear_addrs(f->unit, wo->ouraddr, wo->hisaddr, + wo->replace_default_route); + if (go->ouraddr != wo->ouraddr) { + ppp_warn("Local IP address changed to %I", go->ouraddr); + script_setenv("OLDIPLOCAL", ip_ntoa(wo->ouraddr), 0); + wo->ouraddr = go->ouraddr; + } else + script_unsetenv("OLDIPLOCAL"); + if (ho->hisaddr != wo->hisaddr && wo->hisaddr != 0) { + ppp_warn("Remote IP address changed to %I", ho->hisaddr); + script_setenv("OLDIPREMOTE", ip_ntoa(wo->hisaddr), 0); + wo->hisaddr = ho->hisaddr; + } else + script_unsetenv("OLDIPREMOTE"); + + /* Set the interface to the new addresses */ + mask = get_mask(go->ouraddr); + if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { #if PPP_DEBUG - ppp_warn("Interface configuration failed"); + ppp_warn("Interface configuration failed"); #endif /* PPP_DEBUG */ - ipcp_close(f->unit, "Interface configuration failed"); - return; - } + ipcp_close(f->unit, "Interface configuration failed"); + return; + } - /* assign a default route through the interface if required */ - if (ipcp_wantoptions[f->unit].default_route) - if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, - wo->replace_default_route)) - default_route_set[f->unit] = 1; + /* assign a default route through the interface if required */ + if (ipcp_wantoptions[f->unit].default_route) + if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, + wo->replace_default_route)) + default_route_set[f->unit] = 1; #if 0 /* UNUSED - PROXY ARP */ - /* Make a proxy ARP entry if requested. */ - if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp) - if (sifproxyarp(pcb, ho->hisaddr)) - proxy_arp_set[f->unit] = 1; + /* Make a proxy ARP entry if requested. */ + if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp) + if (sifproxyarp(pcb, ho->hisaddr)) + proxy_arp_set[f->unit] = 1; #endif /* UNUSED - PROXY ARP */ - } - demand_rexmit(PPP_IP,go->ouraddr); - sifnpmode(pcb, PPP_IP, NPMODE_PASS); + } + demand_rexmit(PPP_IP,go->ouraddr); + sifnpmode(pcb, PPP_IP, NPMODE_PASS); } else #endif /* DEMAND_SUPPORT */ { - /* - * Set IP addresses and (if specified) netmask. - */ - mask = get_mask(go->ouraddr); + /* + * Set IP addresses and (if specified) netmask. + */ + mask = get_mask(go->ouraddr); #if !(defined(SVR4) && (defined(SNI) || defined(__USLC__))) - if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { + if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { #if PPP_DEBUG - ppp_warn("Interface configuration failed"); + ppp_warn("Interface configuration failed"); #endif /* PPP_DEBUG */ - ipcp_close(f->pcb, "Interface configuration failed"); - return; - } + ipcp_close(f->pcb, "Interface configuration failed"); + return; + } #endif - /* bring the interface up for IP */ - if (!sifup(pcb)) { + /* bring the interface up for IP */ + if (!sifup(pcb)) { #if PPP_DEBUG - ppp_warn("Interface failed to come up"); + ppp_warn("Interface failed to come up"); #endif /* PPP_DEBUG */ - ipcp_close(f->pcb, "Interface configuration failed"); - return; - } + ipcp_close(f->pcb, "Interface configuration failed"); + return; + } #if (defined(SVR4) && (defined(SNI) || defined(__USLC__))) - if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { + if (!sifaddr(pcb, go->ouraddr, ho->hisaddr, mask)) { #if PPP_DEBUG - ppp_warn("Interface configuration failed"); + ppp_warn("Interface configuration failed"); #endif /* PPP_DEBUG */ - ipcp_close(f->unit, "Interface configuration failed"); - return; - } + ipcp_close(f->unit, "Interface configuration failed"); + return; + } #endif #if DEMAND_SUPPORT - sifnpmode(pcb, PPP_IP, NPMODE_PASS); + sifnpmode(pcb, PPP_IP, NPMODE_PASS); #endif /* DEMAND_SUPPORT */ #if 0 /* UNUSED */ - /* assign a default route through the interface if required */ - if (wo->default_route) - if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, - wo->replace_default_route)) - pcb->default_route_set = 1; + /* assign a default route through the interface if required */ + if (wo->default_route) + if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr, + wo->replace_default_route)) + pcb->default_route_set = 1; #endif /* UNUSED */ #if 0 /* UNUSED - PROXY ARP */ - /* Make a proxy ARP entry if requested. */ - if (ho->hisaddr != 0 && wo->proxy_arp) - if (sifproxyarp(pcb, ho->hisaddr)) - pcb->proxy_arp_set = 1; + /* Make a proxy ARP entry if requested. */ + if (ho->hisaddr != 0 && wo->proxy_arp) + if (sifproxyarp(pcb, ho->hisaddr)) + pcb->proxy_arp_set = 1; #endif /* UNUSED - PROXY ARP */ - wo->ouraddr = go->ouraddr; + wo->ouraddr = go->ouraddr; - ppp_notice("local IP address %I", go->ouraddr); - if (ho->hisaddr != 0) - ppp_notice("remote IP address %I", ho->hisaddr); + ppp_notice("local IP address %I", go->ouraddr); + if (ho->hisaddr != 0) + ppp_notice("remote IP address %I", ho->hisaddr); #if LWIP_DNS - if (go->dnsaddr[0]) - ppp_notice("primary DNS address %I", go->dnsaddr[0]); - if (go->dnsaddr[1]) - ppp_notice("secondary DNS address %I", go->dnsaddr[1]); + if (go->dnsaddr[0]) + ppp_notice("primary DNS address %I", go->dnsaddr[0]); + if (go->dnsaddr[1]) + ppp_notice("secondary DNS address %I", go->dnsaddr[1]); #endif /* LWIP_DNS */ } @@ -2104,7 +2104,7 @@ static void ipcp_up(fsm *f) { #endif /* PPP_NOTIFY */ #if 0 /* UNUSED */ if (ip_up_hook) - ip_up_hook(); + ip_up_hook(); #endif /* UNUSED */ } @@ -2133,11 +2133,11 @@ static void ipcp_down(fsm *f) { #endif /* PPP_NOTIFY */ #if 0 /* UNUSED */ if (ip_down_hook) - ip_down_hook(); + ip_down_hook(); #endif /* UNUSED */ if (pcb->ipcp_is_up) { - pcb->ipcp_is_up = 0; - np_down(pcb, PPP_IP); + pcb->ipcp_is_up = 0; + np_down(pcb, PPP_IP); } #if VJ_SUPPORT sifvjcomp(pcb, 0, 0, 0); @@ -2145,8 +2145,8 @@ static void ipcp_down(fsm *f) { #if PPP_STATS_SUPPORT print_link_stats(); /* _after_ running the notifiers and ip_down_hook(), - * because print_link_stats() sets link_stats_valid - * to 0 (zero) */ + * because print_link_stats() sets link_stats_valid + * to 0 (zero) */ #endif /* PPP_STATS_SUPPORT */ #if DEMAND_SUPPORT @@ -2155,18 +2155,18 @@ static void ipcp_down(fsm *f) { * to queue up outgoing packets (for now). */ if (demand) { - sifnpmode(pcb, PPP_IP, NPMODE_QUEUE); + sifnpmode(pcb, PPP_IP, NPMODE_QUEUE); } else #endif /* DEMAND_SUPPORT */ { #if DEMAND_SUPPORT - sifnpmode(pcb, PPP_IP, NPMODE_DROP); + sifnpmode(pcb, PPP_IP, NPMODE_DROP); #endif /* DEMAND_SUPPORT */ - sifdown(pcb); - ipcp_clear_addrs(pcb, go->ouraddr, - ho->hisaddr, 0); + sifdown(pcb); + ipcp_clear_addrs(pcb, go->ouraddr, + ho->hisaddr, 0); #if LWIP_DNS - cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); + cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]); #endif /* LWIP_DNS */ } } @@ -2181,8 +2181,8 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re #if 0 /* UNUSED - PROXY ARP */ if (pcb->proxy_arp_set) { - cifproxyarp(pcb, hisaddr); - pcb->proxy_arp_set = 0; + cifproxyarp(pcb, hisaddr); + pcb->proxy_arp_set = 0; } #endif /* UNUSED - PROXY ARP */ #if 0 /* UNUSED */ @@ -2195,8 +2195,8 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re * is one saved by an sifdefaultroute with replacedefaultroute. */ if (!replacedefaultroute && pcb->default_route_set) { - cifdefaultroute(pcb, ouraddr, hisaddr); - pcb->default_route_set = 0; + cifdefaultroute(pcb, ouraddr, hisaddr); + pcb->default_route_set = 0; } #endif /* UNUSED */ cifaddr(pcb, ouraddr, hisaddr); @@ -2207,11 +2207,11 @@ static void ipcp_clear_addrs(ppp_pcb *pcb, u32_t ouraddr, u32_t hisaddr, u8_t re * ipcp_finished - possibly shut down the lower layers. */ static void ipcp_finished(fsm *f) { - ppp_pcb *pcb = f->pcb; - if (pcb->ipcp_is_open) { - pcb->ipcp_is_open = 0; - np_finished(pcb, PPP_IP); - } + ppp_pcb *pcb = f->pcb; + if (pcb->ipcp_is_open) { + pcb->ipcp_is_open = 0; + np_finished(pcb, PPP_IP); + } } @@ -2237,7 +2237,7 @@ static const char* const ipcp_codenames[] = { }; static int ipcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg) { + void (*printer) (void *, const char *, ...), void *arg) { int code, id, len, olen; const u_char *pstart, *optend; #if VJ_SUPPORT @@ -2246,18 +2246,18 @@ static int ipcp_printpkt(const u_char *p, int plen, u32_t cilong; if (plen < HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(ipcp_codenames)) - printer(arg, " %s", ipcp_codenames[code-1]); + printer(arg, " %s", ipcp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { @@ -2265,98 +2265,98 @@ static int ipcp_printpkt(const u_char *p, int plen, case CONFACK: case CONFNAK: case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { - case CI_ADDRS: - if (olen == CILEN_ADDRS) { - p += 2; - GETLONG(cilong, p); - printer(arg, "addrs %I", lwip_htonl(cilong)); - GETLONG(cilong, p); - printer(arg, " %I", lwip_htonl(cilong)); - } - break; + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { + case CI_ADDRS: + if (olen == CILEN_ADDRS) { + p += 2; + GETLONG(cilong, p); + printer(arg, "addrs %I", lwip_htonl(cilong)); + GETLONG(cilong, p); + printer(arg, " %I", lwip_htonl(cilong)); + } + break; #if VJ_SUPPORT - case CI_COMPRESSTYPE: - if (olen >= CILEN_COMPRESS) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "compress "); - switch (cishort) { - case IPCP_VJ_COMP: - printer(arg, "VJ"); - break; - case IPCP_VJ_COMP_OLD: - printer(arg, "old-VJ"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; + case CI_COMPRESSTYPE: + if (olen >= CILEN_COMPRESS) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "compress "); + switch (cishort) { + case IPCP_VJ_COMP: + printer(arg, "VJ"); + break; + case IPCP_VJ_COMP_OLD: + printer(arg, "old-VJ"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; #endif /* VJ_SUPPORT */ - case CI_ADDR: - if (olen == CILEN_ADDR) { - p += 2; - GETLONG(cilong, p); - printer(arg, "addr %I", lwip_htonl(cilong)); - } - break; + case CI_ADDR: + if (olen == CILEN_ADDR) { + p += 2; + GETLONG(cilong, p); + printer(arg, "addr %I", lwip_htonl(cilong)); + } + break; #if LWIP_DNS - case CI_MS_DNS1: - case CI_MS_DNS2: - p += 2; - GETLONG(cilong, p); - printer(arg, "ms-dns%d %I", (code == CI_MS_DNS1? 1: 2), - htonl(cilong)); - break; + case CI_MS_DNS1: + case CI_MS_DNS2: + p += 2; + GETLONG(cilong, p); + printer(arg, "ms-dns%d %I", (code == CI_MS_DNS1? 1: 2), + htonl(cilong)); + break; #endif /* LWIP_DNS */ #if 0 /* UNUSED - WINS */ - case CI_MS_WINS1: - case CI_MS_WINS2: - p += 2; - GETLONG(cilong, p); - printer(arg, "ms-wins %I", lwip_htonl(cilong)); - break; + case CI_MS_WINS1: + case CI_MS_WINS2: + p += 2; + GETLONG(cilong, p); + printer(arg, "ms-wins %I", lwip_htonl(cilong)); + break; #endif /* UNUSED - WINS */ - default: - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; + default: + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } return p - pstart; @@ -2369,25 +2369,25 @@ static int ipcp_printpkt(const u_char *p, int plen, * We don't bring the link up for IP fragments or for TCP FIN packets * with no data. */ -#define IP_HDRLEN 20 /* bytes */ -#define IP_OFFMASK 0x1fff +#define IP_HDRLEN 20 /* bytes */ +#define IP_OFFMASK 0x1fff #ifndef IPPROTO_TCP -#define IPPROTO_TCP 6 +#define IPPROTO_TCP 6 #endif -#define TCP_HDRLEN 20 -#define TH_FIN 0x01 +#define TCP_HDRLEN 20 +#define TH_FIN 0x01 /* * We use these macros because the IP header may be at an odd address, * and some compilers might use word loads to get th_off or ip_hl. */ -#define net_short(x) (((x)[0] << 8) + (x)[1]) -#define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) -#define get_ipoff(x) net_short((unsigned char *)(x) + 6) -#define get_ipproto(x) (((unsigned char *)(x))[9]) -#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) -#define get_tcpflags(x) (((unsigned char *)(x))[13]) +#define net_short(x) (((x)[0] << 8) + (x)[1]) +#define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) +#define get_ipoff(x) net_short((unsigned char *)(x) + 6) +#define get_ipproto(x) (((unsigned char *)(x))[9]) +#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) +#define get_tcpflags(x) (((unsigned char *)(x))[13]) static int ip_active_pkt(pkt, len) @@ -2400,17 +2400,17 @@ ip_active_pkt(pkt, len) len -= PPP_HDRLEN; pkt += PPP_HDRLEN; if (len < IP_HDRLEN) - return 0; + return 0; if ((get_ipoff(pkt) & IP_OFFMASK) != 0) - return 0; + return 0; if (get_ipproto(pkt) != IPPROTO_TCP) - return 1; + return 1; hlen = get_iphl(pkt) * 4; if (len < hlen + TCP_HDRLEN) - return 0; + return 0; tcp = pkt + hlen; if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4) - return 0; + return 0; return 1; } #endif /* DEMAND_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/ipv6cp.c b/components/net/lwip-2.1.2/src/netif/ppp/ipv6cp.c index 11c18df743..47521eeb02 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/ipv6cp.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/ipv6cp.c @@ -73,7 +73,7 @@ between BULL S.A. and INRIA). This software is available with usual "research" terms - with the aim of retain credits of the software. + 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, @@ -135,11 +135,11 @@ * 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.c,v 1.21 2005/08/25 23:59:34 paulus Exp $ + * $Id: ipv6cp.c,v 1.21 2005/08/25 23:59:34 paulus Exp $ */ /* - * @todo: + * @todo: * * Proxy Neighbour Discovery. * @@ -188,21 +188,21 @@ static void ipv6cp_down(fsm *f); /* We're DOWN */ static void ipv6cp_finished(fsm *f); /* Don't need lower layer */ static const fsm_callbacks ipv6cp_callbacks = { /* IPV6CP callback routines */ - ipv6cp_resetci, /* Reset our Configuration Information */ - ipv6cp_cilen, /* Length of our Configuration Information */ - ipv6cp_addci, /* Add our Configuration Information */ - ipv6cp_ackci, /* ACK our Configuration Information */ - ipv6cp_nakci, /* NAK our Configuration Information */ - ipv6cp_rejci, /* Reject our Configuration Information */ - ipv6cp_reqci, /* Request peer's Configuration Information */ - ipv6cp_up, /* Called when fsm reaches OPENED state */ - ipv6cp_down, /* Called when fsm leaves OPENED state */ - NULL, /* Called when we want the lower layer up */ - ipv6cp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - NULL, /* Called to handle protocol-specific codes */ - "IPV6CP" /* String name of protocol */ + ipv6cp_resetci, /* Reset our Configuration Information */ + ipv6cp_cilen, /* Length of our Configuration Information */ + ipv6cp_addci, /* Add our Configuration Information */ + ipv6cp_ackci, /* ACK our Configuration Information */ + ipv6cp_nakci, /* NAK our Configuration Information */ + ipv6cp_rejci, /* Reject our Configuration Information */ + ipv6cp_reqci, /* Request peer's Configuration Information */ + ipv6cp_up, /* Called when fsm reaches OPENED state */ + ipv6cp_down, /* Called when fsm leaves OPENED state */ + NULL, /* Called when we want the lower layer up */ + ipv6cp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + NULL, /* Called to handle protocol-specific codes */ + "IPV6CP" /* String name of protocol */ }; #if PPP_OPTIONS @@ -211,7 +211,7 @@ static const fsm_callbacks ipv6cp_callbacks = { /* IPV6CP callback routines */ */ static int setifaceid(char **arg)); static void printifaceid(option_t *, - void (*)(void *, char *, ...), void *)); + void (*)(void *, char *, ...), void *)); static option_t ipv6cp_option_list[] = { { "ipv6", o_special, (void *)setifaceid, @@ -265,7 +265,7 @@ static int ipv6_demand_conf(int u); #endif /* DEMAND_SUPPORT */ #if PRINTPKT_SUPPORT static int ipv6cp_printpkt(const u_char *p, int plen, - void (*printer)(void *, const char *, ...), void *arg); + void (*printer)(void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ #if DEMAND_SUPPORT static int ipv6_active_pkt(u_char *pkt, int len); @@ -309,12 +309,12 @@ static void ipv6cp_script_done(void *)); /* * Lengths of configuration options. */ -#define CILEN_VOID 2 -#define CILEN_COMPRESS 4 /* length for RFC2023 compress opt. */ -#define CILEN_IFACEID 10 /* RFC2472, interface identifier */ +#define CILEN_VOID 2 +#define CILEN_COMPRESS 4 /* length for RFC2023 compress opt. */ +#define CILEN_IFACEID 10 /* RFC2472, interface identifier */ -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") #if 0 /* UNUSED */ /* @@ -344,49 +344,49 @@ setifaceid(argv) static int prio_local, prio_remote; #define VALIDID(a) ( (((a).s6_addr32[0] == 0) && ((a).s6_addr32[1] == 0)) && \ - (((a).s6_addr32[2] != 0) || ((a).s6_addr32[3] != 0)) ) - + (((a).s6_addr32[2] != 0) || ((a).s6_addr32[3] != 0)) ) + arg = *argv; if ((comma = strchr(arg, ',')) == NULL) - comma = arg + strlen(arg); - - /* + comma = arg + strlen(arg); + + /* * If comma first character, then no local identifier */ if (comma != arg) { - c = *comma; - *comma = '\0'; - - if (inet_pton(AF_INET6, arg, &addr) == 0 || !VALIDID(addr)) { - option_error("Illegal interface identifier (local): %s", arg); - return 0; - } - - if (option_priority >= prio_local) { - eui64_copy(addr.s6_addr32[2], wo->ourid); - wo->opt_local = 1; - prio_local = option_priority; - } - *comma = c; + c = *comma; + *comma = '\0'; + + if (inet_pton(AF_INET6, arg, &addr) == 0 || !VALIDID(addr)) { + option_error("Illegal interface identifier (local): %s", arg); + return 0; + } + + if (option_priority >= prio_local) { + eui64_copy(addr.s6_addr32[2], wo->ourid); + wo->opt_local = 1; + prio_local = option_priority; + } + *comma = c; } - + /* * If comma last character, the no remote identifier */ if (*comma != 0 && *++comma != '\0') { - if (inet_pton(AF_INET6, comma, &addr) == 0 || !VALIDID(addr)) { - option_error("Illegal interface identifier (remote): %s", comma); - return 0; - } - if (option_priority >= prio_remote) { - eui64_copy(addr.s6_addr32[2], wo->hisid); - wo->opt_remote = 1; - prio_remote = option_priority; - } + if (inet_pton(AF_INET6, comma, &addr) == 0 || !VALIDID(addr)) { + option_error("Illegal interface identifier (remote): %s", comma); + return 0; + } + if (option_priority >= prio_remote) { + eui64_copy(addr.s6_addr32[2], wo->hisid); + wo->opt_remote = 1; + prio_remote = option_priority; + } } if (override_value("+ipv6", option_priority, option_source)) - ipv6cp_protent.enabled_flag = 1; + ipv6cp_protent.enabled_flag = 1; return 1; } @@ -396,13 +396,13 @@ printifaceid(opt, printer, arg) void (*printer)(void *, char *, ...)); void *arg; { - ipv6cp_options *wo = &ipv6cp_wantoptions[0]; + ipv6cp_options *wo = &ipv6cp_wantoptions[0]; - if (wo->opt_local) - printer(arg, "%s", llv6_ntoa(wo->ourid)); - printer(arg, ","); - if (wo->opt_remote) - printer(arg, "%s", llv6_ntoa(wo->hisid)); + if (wo->opt_local) + printer(arg, "%s", llv6_ntoa(wo->ourid)); + printer(arg, ","); + if (wo->opt_remote) + printer(arg, "%s", llv6_ntoa(wo->hisid)); } #endif /* PPP_OPTIONS */ @@ -513,13 +513,13 @@ static void ipv6cp_resetci(fsm *f) { ipv6cp_options *ao = &pcb->ipv6cp_allowoptions; wo->req_ifaceid = wo->neg_ifaceid && ao->neg_ifaceid; - + if (!wo->opt_local) { - eui64_magic_nz(wo->ourid); + eui64_magic_nz(wo->ourid); } - + *go = *wo; - eui64_zero(go->hisid); /* last proposed interface identifier */ + eui64_zero(go->hisid); /* last proposed interface identifier */ } @@ -531,15 +531,15 @@ static int ipv6cp_cilen(fsm *f) { ipv6cp_options *go = &pcb->ipv6cp_gotoptions; #ifdef IPV6CP_COMP -#define LENCIVJ(neg) (neg ? CILEN_COMPRESS : 0) +#define LENCIVJ(neg) (neg ? CILEN_COMPRESS : 0) #endif /* IPV6CP_COMP */ -#define LENCIIFACEID(neg) (neg ? CILEN_IFACEID : 0) +#define LENCIIFACEID(neg) (neg ? CILEN_IFACEID : 0) return (LENCIIFACEID(go->neg_ifaceid) + #ifdef IPV6CP_COMP - LENCIVJ(go->neg_vj) + + LENCIVJ(go->neg_vj) + #endif /* IPV6CP_COMP */ - 0); + 0); } @@ -554,27 +554,27 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) { #ifdef IPV6CP_COMP #define ADDCIVJ(opt, neg, val) \ if (neg) { \ - int vjlen = CILEN_COMPRESS; \ - if (len >= vjlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(vjlen, ucp); \ - PUTSHORT(val, ucp); \ - len -= vjlen; \ - } else \ - neg = 0; \ + int vjlen = CILEN_COMPRESS; \ + if (len >= vjlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(vjlen, ucp); \ + PUTSHORT(val, ucp); \ + len -= vjlen; \ + } else \ + neg = 0; \ } #endif /* IPV6CP_COMP */ #define ADDCIIFACEID(opt, neg, val1) \ if (neg) { \ - int idlen = CILEN_IFACEID; \ - if (len >= idlen) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(idlen, ucp); \ - eui64_put(val1, ucp); \ - len -= idlen; \ - } else \ - neg = 0; \ + int idlen = CILEN_IFACEID; \ + if (len >= idlen) { \ + PUTCHAR(opt, ucp); \ + PUTCHAR(idlen, ucp); \ + eui64_put(val1, ucp); \ + len -= idlen; \ + } else \ + neg = 0; \ } ADDCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid); @@ -591,8 +591,8 @@ static void ipv6cp_addci(fsm *f, u_char *ucp, int *lenp) { * ipv6cp_ackci - Ack our CIs. * * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. + * 0 - Ack was bad. + * 1 - Ack was good. */ static int ipv6cp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -612,33 +612,33 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) { #ifdef IPV6CP_COMP #define ACKCIVJ(opt, neg, val) \ if (neg) { \ - int vjlen = CILEN_COMPRESS; \ - if ((len -= vjlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != vjlen || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ + int vjlen = CILEN_COMPRESS; \ + if ((len -= vjlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != vjlen || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ } #endif /* IPV6CP_COMP */ #define ACKCIIFACEID(opt, neg, val1) \ if (neg) { \ - int idlen = CILEN_IFACEID; \ - if ((len -= idlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != idlen || \ - citype != opt) \ - goto bad; \ - eui64_get(ifaceid, p); \ - if (! eui64_equals(val1, ifaceid)) \ - goto bad; \ + int idlen = CILEN_IFACEID; \ + if ((len -= idlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != idlen || \ + citype != opt) \ + goto bad; \ + eui64_get(ifaceid, p); \ + if (! eui64_equals(val1, ifaceid)) \ + goto bad; \ } ACKCIIFACEID(CI_IFACEID, go->neg_ifaceid, go->ourid); @@ -651,7 +651,7 @@ static int ipv6cp_ackci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; return (1); bad: @@ -665,8 +665,8 @@ bad: * or if IPV6CP is in the OPENED state. * * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. + * 0 - Nak was bad. + * 1 - Nak was good. */ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; @@ -676,8 +676,8 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { u_short cishort; #endif /* IPV6CP_COMP */ eui64_t ifaceid; - ipv6cp_options no; /* options we've seen Naks for */ - ipv6cp_options try_; /* options to request next time */ + ipv6cp_options no; /* options we've seen Naks for */ + ipv6cp_options try_; /* options to request next time */ BZERO(&no, sizeof(no)); try_ = *go; @@ -689,26 +689,26 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ #define NAKCIIFACEID(opt, neg, code) \ if (go->neg && \ - len >= (cilen = CILEN_IFACEID) && \ - p[1] == cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - eui64_get(ifaceid, p); \ - no.neg = 1; \ - code \ + len >= (cilen = CILEN_IFACEID) && \ + p[1] == cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + eui64_get(ifaceid, p); \ + no.neg = 1; \ + code \ } #ifdef IPV6CP_COMP #define NAKCIVJ(opt, neg, code) \ if (go->neg && \ - ((cilen = p[1]) == CILEN_COMPRESS) && \ - len >= cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ + ((cilen = p[1]) == CILEN_COMPRESS) && \ + len >= cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ code \ } #endif /* IPV6CP_COMP */ @@ -718,27 +718,27 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * from our idea, only if the accept_{local,remote} flag is set. */ NAKCIIFACEID(CI_IFACEID, neg_ifaceid, - if (treat_as_reject) { - try_.neg_ifaceid = 0; - } else if (go->accept_local) { - while (eui64_iszero(ifaceid) || - eui64_equals(ifaceid, go->hisid)) /* bad luck */ - eui64_magic(ifaceid); - try_.ourid = ifaceid; - IPV6CPDEBUG(("local LL address %s", llv6_ntoa(ifaceid))); - } - ); + if (treat_as_reject) { + try_.neg_ifaceid = 0; + } else if (go->accept_local) { + while (eui64_iszero(ifaceid) || + eui64_equals(ifaceid, go->hisid)) /* bad luck */ + eui64_magic(ifaceid); + try_.ourid = ifaceid; + IPV6CPDEBUG(("local LL address %s", llv6_ntoa(ifaceid))); + } + ); #ifdef IPV6CP_COMP NAKCIVJ(CI_COMPRESSTYPE, neg_vj, - { - if (cishort == IPV6CP_COMP && !treat_as_reject) { - try_.vj_protocol = cishort; - } else { - try_.neg_vj = 0; - } - } - ); + { + if (cishort == IPV6CP_COMP && !treat_as_reject) { + try_.vj_protocol = cishort; + } else { + try_.neg_vj = 0; + } + } + ); #endif /* IPV6CP_COMP */ /* @@ -748,49 +748,49 @@ static int ipv6cp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If they want us to ask for compression, we refuse. */ while (len >= CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) - goto bad; - next = p + cilen - 2; + GETCHAR(citype, p); + GETCHAR(cilen, p); + if ( cilen < CILEN_VOID || (len -= cilen) < 0 ) + goto bad; + next = p + cilen - 2; - switch (citype) { + switch (citype) { #ifdef IPV6CP_COMP - case CI_COMPRESSTYPE: - if (go->neg_vj || no.neg_vj || - (cilen != CILEN_COMPRESS)) - goto bad; - no.neg_vj = 1; - break; + case CI_COMPRESSTYPE: + if (go->neg_vj || no.neg_vj || + (cilen != CILEN_COMPRESS)) + goto bad; + no.neg_vj = 1; + break; #endif /* IPV6CP_COMP */ - case CI_IFACEID: - if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID) - goto bad; - try_.neg_ifaceid = 1; - eui64_get(ifaceid, p); - if (go->accept_local) { - while (eui64_iszero(ifaceid) || - eui64_equals(ifaceid, go->hisid)) /* bad luck */ - eui64_magic(ifaceid); - try_.ourid = ifaceid; - } - no.neg_ifaceid = 1; - break; - default: - break; - } - p = next; + case CI_IFACEID: + if (go->neg_ifaceid || no.neg_ifaceid || cilen != CILEN_IFACEID) + goto bad; + try_.neg_ifaceid = 1; + eui64_get(ifaceid, p); + if (go->accept_local) { + while (eui64_iszero(ifaceid) || + eui64_equals(ifaceid, go->hisid)) /* bad luck */ + eui64_magic(ifaceid); + try_.ourid = ifaceid; + } + no.neg_ifaceid = 1; + break; + default: + break; + } + p = next; } /* If there is still anything left, this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * OK, the Nak is good. Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; @@ -811,7 +811,7 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) { u_short cishort; #endif /* IPV6CP_COMP */ eui64_t ifaceid; - ipv6cp_options try_; /* options to request next time */ + ipv6cp_options try_; /* options to request next time */ try_ = *go; /* @@ -821,31 +821,31 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) { */ #define REJCIIFACEID(opt, neg, val1) \ if (go->neg && \ - len >= (cilen = CILEN_IFACEID) && \ - p[1] == cilen && \ - p[0] == opt) { \ - len -= cilen; \ - INCPTR(2, p); \ - eui64_get(ifaceid, p); \ - /* Check rejected value. */ \ - if (! eui64_equals(ifaceid, val1)) \ - goto bad; \ - try_.neg = 0; \ + len >= (cilen = CILEN_IFACEID) && \ + p[1] == cilen && \ + p[0] == opt) { \ + len -= cilen; \ + INCPTR(2, p); \ + eui64_get(ifaceid, p); \ + /* Check rejected value. */ \ + if (! eui64_equals(ifaceid, val1)) \ + goto bad; \ + try_.neg = 0; \ } #ifdef IPV6CP_COMP #define REJCIVJ(opt, neg, val) \ if (go->neg && \ - p[1] == CILEN_COMPRESS && \ - len >= p[1] && \ - p[0] == opt) { \ - len -= p[1]; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) \ - goto bad; \ - try_.neg = 0; \ + p[1] == CILEN_COMPRESS && \ + len >= p[1] && \ + p[0] == opt) { \ + len -= p[1]; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) \ + goto bad; \ + try_.neg = 0; \ } #endif /* IPV6CP_COMP */ @@ -859,12 +859,12 @@ static int ipv6cp_rejci(fsm *f, u_char *p, int len) { * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; bad: @@ -890,150 +890,150 @@ static int ipv6cp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) { ipv6cp_options *ho = &pcb->ipv6cp_hisoptions; ipv6cp_options *ao = &pcb->ipv6cp_allowoptions; ipv6cp_options *go = &pcb->ipv6cp_gotoptions; - u_char *cip, *next; /* Pointer to current and next CIs */ - u_short cilen, citype; /* Parsed len, type */ + u_char *cip, *next; /* Pointer to current and next CIs */ + u_short cilen, citype; /* Parsed len, type */ #ifdef IPV6CP_COMP - u_short cishort; /* Parsed short value */ + u_short cishort; /* Parsed short value */ #endif /* IPV6CP_COMP */ - eui64_t ifaceid; /* Parsed interface identifier */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *ucp = inp; /* Pointer to current output char */ - int l = *len; /* Length left */ + eui64_t ifaceid; /* Parsed interface identifier */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *ucp = inp; /* Pointer to current output char */ + int l = *len; /* Length left */ /* * Reset all his options. */ BZERO(ho, sizeof(*ho)); - + /* * Process all his options. */ next = inp; while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - IPV6CPDEBUG(("ipv6cp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_IFACEID: - IPV6CPDEBUG(("ipv6cp: received interface identifier ")); - - if (!ao->neg_ifaceid || - cilen != CILEN_IFACEID) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - - /* - * If he has no interface identifier, or if we both have same - * identifier then NAK it with new idea. - * In particular, if we don't know his identifier, but he does, - * then accept it. - */ - eui64_get(ifaceid, p); - IPV6CPDEBUG(("(%s)", llv6_ntoa(ifaceid))); - if (eui64_iszero(ifaceid) && eui64_iszero(go->ourid)) { - orc = CONFREJ; /* Reject CI */ - break; - } - if (!eui64_iszero(wo->hisid) && - !eui64_equals(ifaceid, wo->hisid) && - eui64_iszero(go->hisid)) { - - orc = CONFNAK; - ifaceid = wo->hisid; - go->hisid = ifaceid; - DECPTR(sizeof(ifaceid), p); - eui64_put(ifaceid, p); - } else - if (eui64_iszero(ifaceid) || eui64_equals(ifaceid, go->ourid)) { - orc = CONFNAK; - if (eui64_iszero(go->hisid)) /* first time, try option */ - ifaceid = wo->hisid; - while (eui64_iszero(ifaceid) || - eui64_equals(ifaceid, go->ourid)) /* bad luck */ - eui64_magic(ifaceid); - go->hisid = ifaceid; - DECPTR(sizeof(ifaceid), p); - eui64_put(ifaceid, p); - } - - ho->neg_ifaceid = 1; - ho->hisid = ifaceid; - break; + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + IPV6CPDEBUG(("ipv6cp_reqci: bad CI length!")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_IFACEID: + IPV6CPDEBUG(("ipv6cp: received interface identifier ")); + + if (!ao->neg_ifaceid || + cilen != CILEN_IFACEID) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + + /* + * If he has no interface identifier, or if we both have same + * identifier then NAK it with new idea. + * In particular, if we don't know his identifier, but he does, + * then accept it. + */ + eui64_get(ifaceid, p); + IPV6CPDEBUG(("(%s)", llv6_ntoa(ifaceid))); + if (eui64_iszero(ifaceid) && eui64_iszero(go->ourid)) { + orc = CONFREJ; /* Reject CI */ + break; + } + if (!eui64_iszero(wo->hisid) && + !eui64_equals(ifaceid, wo->hisid) && + eui64_iszero(go->hisid)) { + + orc = CONFNAK; + ifaceid = wo->hisid; + go->hisid = ifaceid; + DECPTR(sizeof(ifaceid), p); + eui64_put(ifaceid, p); + } else + if (eui64_iszero(ifaceid) || eui64_equals(ifaceid, go->ourid)) { + orc = CONFNAK; + if (eui64_iszero(go->hisid)) /* first time, try option */ + ifaceid = wo->hisid; + while (eui64_iszero(ifaceid) || + eui64_equals(ifaceid, go->ourid)) /* bad luck */ + eui64_magic(ifaceid); + go->hisid = ifaceid; + DECPTR(sizeof(ifaceid), p); + eui64_put(ifaceid, p); + } + + ho->neg_ifaceid = 1; + ho->hisid = ifaceid; + break; #ifdef IPV6CP_COMP - case CI_COMPRESSTYPE: - IPV6CPDEBUG(("ipv6cp: received COMPRESSTYPE ")); - if (!ao->neg_vj || - (cilen != CILEN_COMPRESS)) { - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - IPV6CPDEBUG(("(%d)", cishort)); - - if (!(cishort == IPV6CP_COMP)) { - orc = CONFREJ; - break; - } - - ho->neg_vj = 1; - ho->vj_protocol = cishort; - break; + case CI_COMPRESSTYPE: + IPV6CPDEBUG(("ipv6cp: received COMPRESSTYPE ")); + if (!ao->neg_vj || + (cilen != CILEN_COMPRESS)) { + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + IPV6CPDEBUG(("(%d)", cishort)); + + if (!(cishort == IPV6CP_COMP)) { + orc = CONFREJ; + break; + } + + ho->neg_vj = 1; + ho->vj_protocol = cishort; + break; #endif /* IPV6CP_COMP */ - default: - orc = CONFREJ; - break; - } + default: + orc = CONFREJ; + break; + } endswitch: - IPV6CPDEBUG((" (%s)\n", CODENAME(orc))); - - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree) /* Getting fed up with sending NAKs? */ - orc = CONFREJ; /* Get tough if so */ - else { - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - if (rc == CONFACK) { /* Ack'd all prior CIs? */ - rc = CONFNAK; /* Not anymore... */ - ucp = inp; /* Backup */ - } - } - } - - if (orc == CONFREJ && /* Reject this CI */ - rc != CONFREJ) { /* but no prior ones? */ - rc = CONFREJ; - ucp = inp; /* Backup */ - } - - /* Need to move CI? */ - if (ucp != cip) - MEMCPY(ucp, cip, cilen); /* Move it */ - - /* Update output pointer */ - INCPTR(cilen, ucp); + IPV6CPDEBUG((" (%s)\n", CODENAME(orc))); + + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) /* but prior CI wasnt? */ + continue; /* Don't send this one */ + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree) /* Getting fed up with sending NAKs? */ + orc = CONFREJ; /* Get tough if so */ + else { + if (rc == CONFREJ) /* Rejecting prior CI? */ + continue; /* Don't send this one */ + if (rc == CONFACK) { /* Ack'd all prior CIs? */ + rc = CONFNAK; /* Not anymore... */ + ucp = inp; /* Backup */ + } + } + } + + if (orc == CONFREJ && /* Reject this CI */ + rc != CONFREJ) { /* but no prior ones? */ + rc = CONFREJ; + ucp = inp; /* Backup */ + } + + /* Need to move CI? */ + if (ucp != cip) + MEMCPY(ucp, cip, cilen); /* Move it */ + + /* Update output pointer */ + INCPTR(cilen, ucp); } /* @@ -1044,20 +1044,20 @@ endswitch: * option safely. */ if (rc != CONFREJ && !ho->neg_ifaceid && - wo->req_ifaceid && !reject_if_disagree) { - if (rc == CONFACK) { - rc = CONFNAK; - ucp = inp; /* reset pointer */ - wo->req_ifaceid = 0; /* don't ask again */ - } - PUTCHAR(CI_IFACEID, ucp); - PUTCHAR(CILEN_IFACEID, ucp); - eui64_put(wo->hisid, ucp); + wo->req_ifaceid && !reject_if_disagree) { + if (rc == CONFACK) { + rc = CONFNAK; + ucp = inp; /* reset pointer */ + wo->req_ifaceid = 0; /* don't ask again */ + } + PUTCHAR(CI_IFACEID, ucp); + PUTCHAR(CILEN_IFACEID, ucp); + eui64_put(wo->hisid, ucp); } - *len = ucp - inp; /* Compute output length */ + *len = ucp - inp; /* Compute output length */ IPV6CPDEBUG(("ipv6cp: returning Configure-%s", CODENAME(rc))); - return (rc); /* Return final code */ + return (rc); /* Return final code */ } #if PPP_OPTIONS @@ -1069,7 +1069,7 @@ static void ipv6_check_options() { ipv6cp_options *wo = &ipv6cp_wantoptions[0]; if (!ipv6cp_protent.enabled_flag) - return; + return; /* * Persistent link-local id is only used when user has not explicitly @@ -1077,42 +1077,42 @@ static void ipv6_check_options() { */ if ((wo->use_persistent) && (!wo->opt_local) && (!wo->opt_remote)) { - /* - * On systems where there are no Ethernet interfaces used, there - * may be other ways to obtain a persistent id. Right now, it - * will fall back to using magic [see eui64_magic] below when - * an EUI-48 from MAC address can't be obtained. Other possibilities - * include obtaining EEPROM serial numbers, or some other unique - * yet persistent number. On Sparc platforms, this is possible, - * but too bad there's no standards yet for x86 machines. - */ - if (ether_to_eui64(&wo->ourid)) { - wo->opt_local = 1; - } + /* + * On systems where there are no Ethernet interfaces used, there + * may be other ways to obtain a persistent id. Right now, it + * will fall back to using magic [see eui64_magic] below when + * an EUI-48 from MAC address can't be obtained. Other possibilities + * include obtaining EEPROM serial numbers, or some other unique + * yet persistent number. On Sparc platforms, this is possible, + * but too bad there's no standards yet for x86 machines. + */ + if (ether_to_eui64(&wo->ourid)) { + wo->opt_local = 1; + } + } + + if (!wo->opt_local) { /* init interface identifier */ + if (wo->use_ip && eui64_iszero(wo->ourid)) { + eui64_setlo32(wo->ourid, lwip_ntohl(ipcp_wantoptions[0].ouraddr)); + if (!eui64_iszero(wo->ourid)) + wo->opt_local = 1; } - if (!wo->opt_local) { /* init interface identifier */ - if (wo->use_ip && eui64_iszero(wo->ourid)) { - eui64_setlo32(wo->ourid, lwip_ntohl(ipcp_wantoptions[0].ouraddr)); - if (!eui64_iszero(wo->ourid)) - wo->opt_local = 1; - } - - while (eui64_iszero(wo->ourid)) - eui64_magic(wo->ourid); + while (eui64_iszero(wo->ourid)) + eui64_magic(wo->ourid); } if (!wo->opt_remote) { - if (wo->use_ip && eui64_iszero(wo->hisid)) { - eui64_setlo32(wo->hisid, lwip_ntohl(ipcp_wantoptions[0].hisaddr)); - if (!eui64_iszero(wo->hisid)) - wo->opt_remote = 1; - } + if (wo->use_ip && eui64_iszero(wo->hisid)) { + eui64_setlo32(wo->hisid, lwip_ntohl(ipcp_wantoptions[0].hisaddr)); + if (!eui64_iszero(wo->hisid)) + wo->opt_remote = 1; + } } if (demand && (eui64_iszero(wo->ourid) || eui64_iszero(wo->hisid))) { - option_error("local/remote LL address required for demand-dialling\n"); - exit(1); + option_error("local/remote LL address required for demand-dialling\n"); + exit(1); } } #endif /* PPP_OPTIONS */ @@ -1126,13 +1126,13 @@ static int ipv6_demand_conf(int u) { ipv6cp_options *wo = &ipv6cp_wantoptions[u]; if (!sif6up(u)) - return 0; + return 0; if (!sif6addr(u, wo->ourid, wo->hisid)) - return 0; + return 0; if (!sifnpmode(u, PPP_IPV6, NPMODE_QUEUE)) - return 0; + return 0; ppp_notice("ipv6_demand_conf"); ppp_notice("local LL address %s", llv6_ntoa(wo->ourid)); @@ -1160,26 +1160,26 @@ static void ipv6cp_up(fsm *f) { * We must have a non-zero LL address for both ends of the link. */ if (!ho->neg_ifaceid) - ho->hisid = wo->hisid; + ho->hisid = wo->hisid; #if 0 /* UNUSED */ if(!no_ifaceid_neg) { #endif /* UNUSED */ - if (eui64_iszero(ho->hisid)) { - ppp_error("Could not determine remote LL address"); - ipv6cp_close(f->pcb, "Could not determine remote LL address"); - return; - } - if (eui64_iszero(go->ourid)) { - ppp_error("Could not determine local LL address"); - ipv6cp_close(f->pcb, "Could not determine local LL address"); - return; - } - if (eui64_equals(go->ourid, ho->hisid)) { - ppp_error("local and remote LL addresses are equal"); - ipv6cp_close(f->pcb, "local and remote LL addresses are equal"); - return; - } + if (eui64_iszero(ho->hisid)) { + ppp_error("Could not determine remote LL address"); + ipv6cp_close(f->pcb, "Could not determine remote LL address"); + return; + } + if (eui64_iszero(go->ourid)) { + ppp_error("Could not determine local LL address"); + ipv6cp_close(f->pcb, "Could not determine local LL address"); + return; + } + if (eui64_equals(go->ourid, ho->hisid)) { + ppp_error("local and remote LL addresses are equal"); + ipv6cp_close(f->pcb, "local and remote LL addresses are equal"); + return; + } #if 0 /* UNUSED */ } #endif /* UNUSED */ @@ -1200,52 +1200,52 @@ static void ipv6cp_up(fsm *f) { * interface to pass IPv6 packets. */ if (demand) { - if (! eui64_equals(go->ourid, wo->ourid) || - ! eui64_equals(ho->hisid, wo->hisid)) { - if (! eui64_equals(go->ourid, wo->ourid)) - warn("Local LL address changed to %s", - llv6_ntoa(go->ourid)); - if (! eui64_equals(ho->hisid, wo->hisid)) - warn("Remote LL address changed to %s", - llv6_ntoa(ho->hisid)); - ipv6cp_clear_addrs(f->pcb, go->ourid, ho->hisid); - - /* Set the interface to the new addresses */ - if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { - if (debug) - warn("sif6addr failed"); - ipv6cp_close(f->unit, "Interface configuration failed"); - return; - } - - } - demand_rexmit(PPP_IPV6); - sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); + if (! eui64_equals(go->ourid, wo->ourid) || + ! eui64_equals(ho->hisid, wo->hisid)) { + if (! eui64_equals(go->ourid, wo->ourid)) + warn("Local LL address changed to %s", + llv6_ntoa(go->ourid)); + if (! eui64_equals(ho->hisid, wo->hisid)) + warn("Remote LL address changed to %s", + llv6_ntoa(ho->hisid)); + ipv6cp_clear_addrs(f->pcb, go->ourid, ho->hisid); + + /* Set the interface to the new addresses */ + if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { + if (debug) + warn("sif6addr failed"); + ipv6cp_close(f->unit, "Interface configuration failed"); + return; + } + + } + demand_rexmit(PPP_IPV6); + sifnpmode(f->unit, PPP_IPV6, NPMODE_PASS); } else #endif /* DEMAND_SUPPORT */ { - /* - * Set LL addresses - */ - if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { - PPPDEBUG(LOG_DEBUG, ("sif6addr failed")); - ipv6cp_close(f->pcb, "Interface configuration failed"); - return; - } - - /* bring the interface up for IPv6 */ - if (!sif6up(f->pcb)) { - PPPDEBUG(LOG_DEBUG, ("sif6up failed (IPV6)")); - ipv6cp_close(f->pcb, "Interface configuration failed"); - return; - } + /* + * Set LL addresses + */ + if (!sif6addr(f->pcb, go->ourid, ho->hisid)) { + PPPDEBUG(LOG_DEBUG, ("sif6addr failed")); + ipv6cp_close(f->pcb, "Interface configuration failed"); + return; + } + + /* bring the interface up for IPv6 */ + if (!sif6up(f->pcb)) { + PPPDEBUG(LOG_DEBUG, ("sif6up failed (IPV6)")); + ipv6cp_close(f->pcb, "Interface configuration failed"); + return; + } #if DEMAND_SUPPORT - sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS); + sifnpmode(f->pcb, PPP_IPV6, NPMODE_PASS); #endif /* DEMAND_SUPPORT */ - ppp_notice("local LL address %s", llv6_ntoa(go->ourid)); - ppp_notice("remote LL address %s", llv6_ntoa(ho->hisid)); + ppp_notice("local LL address %s", llv6_ntoa(go->ourid)); + ppp_notice("remote LL address %s", llv6_ntoa(ho->hisid)); } np_up(f->pcb, PPP_IPV6); @@ -1254,11 +1254,11 @@ static void ipv6cp_up(fsm *f) { #if 0 /* UNUSED */ /* * Execute the ipv6-up script, like this: - * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL + * /etc/ppp/ipv6-up interface tty speed local-LL remote-LL */ if (ipv6cp_script_state == s_down && ipv6cp_script_pid == 0) { - ipv6cp_script_state = s_up; - ipv6cp_script(_PATH_IPV6UP); + ipv6cp_script_state = s_up; + ipv6cp_script(_PATH_IPV6UP); } #endif /* UNUSED */ } @@ -1280,8 +1280,8 @@ static void ipv6cp_down(fsm *f) { update_link_stats(f->unit); #endif /* PPP_STATS_SUPPORT */ if (pcb->ipv6cp_is_up) { - pcb->ipv6cp_is_up = 0; - np_down(f->pcb, PPP_IPV6); + pcb->ipv6cp_is_up = 0; + np_down(f->pcb, PPP_IPV6); } #ifdef IPV6CP_COMP sif6comp(f->unit, 0); @@ -1293,24 +1293,24 @@ static void ipv6cp_down(fsm *f) { * to queue up outgoing packets (for now). */ if (demand) { - sifnpmode(f->pcb, PPP_IPV6, NPMODE_QUEUE); + sifnpmode(f->pcb, PPP_IPV6, NPMODE_QUEUE); } else #endif /* DEMAND_SUPPORT */ { #if DEMAND_SUPPORT - sifnpmode(f->pcb, PPP_IPV6, NPMODE_DROP); + sifnpmode(f->pcb, PPP_IPV6, NPMODE_DROP); #endif /* DEMAND_SUPPORT */ - ipv6cp_clear_addrs(f->pcb, - go->ourid, - ho->hisid); - sif6down(f->pcb); + ipv6cp_clear_addrs(f->pcb, + go->ourid, + ho->hisid); + sif6down(f->pcb); } #if 0 /* UNUSED */ /* Execute the ipv6-down script */ if (ipv6cp_script_state == s_up && ipv6cp_script_pid == 0) { - ipv6cp_script_state = s_down; - ipv6cp_script(_PATH_IPV6DOWN); + ipv6cp_script_state = s_down; + ipv6cp_script(_PATH_IPV6DOWN); } #endif /* UNUSED */ } @@ -1345,17 +1345,17 @@ ipv6cp_script_done(arg) ipv6cp_script_pid = 0; switch (ipv6cp_script_state) { case s_up: - if (ipv6cp_fsm[0].state != PPP_FSM_OPENED) { - ipv6cp_script_state = s_down; - ipv6cp_script(_PATH_IPV6DOWN); - } - break; + if (ipv6cp_fsm[0].state != PPP_FSM_OPENED) { + ipv6cp_script_state = s_down; + ipv6cp_script(_PATH_IPV6DOWN); + } + break; case s_down: - if (ipv6cp_fsm[0].state == PPP_FSM_OPENED) { - ipv6cp_script_state = s_up; - ipv6cp_script(_PATH_IPV6UP); - } - break; + if (ipv6cp_fsm[0].state == PPP_FSM_OPENED) { + ipv6cp_script_state = s_up; + ipv6cp_script(_PATH_IPV6UP); + } + break; } } @@ -1385,7 +1385,7 @@ ipv6cp_script(script) argv[7] = NULL; ipv6cp_script_pid = run_program(script, argv, 0, ipv6cp_script_done, - NULL, 0); + NULL, 0); } #endif /* UNUSED */ @@ -1399,7 +1399,7 @@ static const char* const ipv6cp_codenames[] = { }; static int ipv6cp_printpkt(const u_char *p, int plen, - void (*printer)(void *, const char *, ...), void *arg) { + void (*printer)(void *, const char *, ...), void *arg) { int code, id, len, olen; const u_char *pstart, *optend; #ifdef IPV6CP_COMP @@ -1408,18 +1408,18 @@ static int ipv6cp_printpkt(const u_char *p, int plen, eui64_t ifaceid; if (plen < HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(ipv6cp_codenames)) - printer(arg, " %s", ipv6cp_codenames[code-1]); + printer(arg, " %s", ipv6cp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { @@ -1427,63 +1427,63 @@ static int ipv6cp_printpkt(const u_char *p, int plen, case CONFACK: case CONFNAK: case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { #ifdef IPV6CP_COMP - case CI_COMPRESSTYPE: - if (olen >= CILEN_COMPRESS) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "compress "); - printer(arg, "0x%x", cishort); - } - break; + case CI_COMPRESSTYPE: + if (olen >= CILEN_COMPRESS) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "compress "); + printer(arg, "0x%x", cishort); + } + break; #endif /* IPV6CP_COMP */ - case CI_IFACEID: - if (olen == CILEN_IFACEID) { - p += 2; - eui64_get(ifaceid, p); - printer(arg, "addr %s", llv6_ntoa(ifaceid)); - } - break; - default: - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; + case CI_IFACEID: + if (olen == CILEN_IFACEID) { + p += 2; + eui64_get(ifaceid, p); + printer(arg, "addr %s", llv6_ntoa(ifaceid)); + } + break; + default: + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } return p - pstart; @@ -1496,19 +1496,19 @@ static int ipv6cp_printpkt(const u_char *p, int plen, * We don't bring the link up for IP fragments or for TCP FIN packets * with no data. */ -#define IP6_HDRLEN 40 /* bytes */ -#define IP6_NHDR_FRAG 44 /* fragment IPv6 header */ -#define TCP_HDRLEN 20 -#define TH_FIN 0x01 +#define IP6_HDRLEN 40 /* bytes */ +#define IP6_NHDR_FRAG 44 /* fragment IPv6 header */ +#define TCP_HDRLEN 20 +#define TH_FIN 0x01 /* * We use these macros because the IP header may be at an odd address, * and some compilers might use word loads to get th_off or ip_hl. */ -#define get_ip6nh(x) (((unsigned char *)(x))[6]) -#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) -#define get_tcpflags(x) (((unsigned char *)(x))[13]) +#define get_ip6nh(x) (((unsigned char *)(x))[6]) +#define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) +#define get_tcpflags(x) (((unsigned char *)(x))[13]) static int ipv6_active_pkt(u_char *pkt, int len) { u_char *tcp; @@ -1516,16 +1516,16 @@ static int ipv6_active_pkt(u_char *pkt, int len) { len -= PPP_HDRLEN; pkt += PPP_HDRLEN; if (len < IP6_HDRLEN) - return 0; + return 0; if (get_ip6nh(pkt) == IP6_NHDR_FRAG) - return 0; + return 0; if (get_ip6nh(pkt) != IPPROTO_TCP) - return 1; + return 1; if (len < IP6_HDRLEN + TCP_HDRLEN) - return 0; + return 0; tcp = pkt + IP6_HDRLEN; if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == IP6_HDRLEN + get_tcpoff(tcp) * 4) - return 0; + return 0; return 1; } #endif /* DEMAND_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/lcp.c b/components/net/lwip-2.1.2/src/netif/ppp/lcp.c index 90ed183b75..040135637c 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/lcp.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/lcp.c @@ -68,7 +68,7 @@ * configure-requests. We do this by delaying the fsm_lowerup call. */ /* steal a bit in fsm flags word */ -#define DELAYED_UP 0x80 +#define DELAYED_UP 0x80 static void lcp_delayed_up(void *arg); @@ -76,8 +76,8 @@ static void lcp_delayed_up(void *arg); * LCP-related command-line options. */ #if 0 /* UNUSED */ -int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ -int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ +int lcp_echo_interval = 0; /* Interval between LCP echo-requests */ +int lcp_echo_fails = 0; /* Tolerance to unanswered echo-requests */ #endif /* UNUSED */ #if 0 /* UNUSED */ @@ -88,10 +88,10 @@ static u_int lcp_echo_fails = LCP_MAXECHOFAILS; /* Tolerance to unanswer #if 0 /* UNUSED */ #if PPP_LCP_ADAPTIVE -bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */ +bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */ #endif -bool lax_recv = 0; /* accept control chars in asyncmap */ -bool noendpoint = 0; /* don't send/accept endpoint discriminator */ +bool lax_recv = 0; /* accept control chars in asyncmap */ +bool noendpoint = 0; /* don't send/accept endpoint discriminator */ #endif /* UNUSED */ #if PPP_OPTIONS @@ -101,7 +101,7 @@ static int noopt (char **); #ifdef HAVE_MULTILINK static int setendpoint (char **); static void printendpoint (option_t *, void (*)(void *, char *, ...), - void *); + void *); #endif /* HAVE_MULTILINK */ #if PPP_OPTIONS @@ -215,17 +215,17 @@ static option_t lcp_option_list[] = { /* * Callbacks for fsm code. (CI = Configuration Information) */ -static void lcp_resetci(fsm *f); /* Reset our CI */ -static int lcp_cilen(fsm *f); /* Return length of our CI */ +static void lcp_resetci(fsm *f); /* Reset our CI */ +static int lcp_cilen(fsm *f); /* Return length of our CI */ static void lcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI to pkt */ static int lcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject); /* Peer nak'd our CI */ static int lcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree); /* Rcv peer CI */ -static void lcp_up(fsm *f); /* We're UP */ -static void lcp_down(fsm *f); /* We're DOWN */ -static void lcp_starting (fsm *); /* We need lower layer up */ -static void lcp_finished (fsm *); /* We need lower layer down */ +static void lcp_up(fsm *f); /* We're UP */ +static void lcp_down(fsm *f); /* We're DOWN */ +static void lcp_starting (fsm *); /* We need lower layer up */ +static void lcp_finished (fsm *); /* We need lower layer down */ static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len); static void lcp_rprotrej(fsm *f, u_char *inp, int len); @@ -241,22 +241,22 @@ static void LcpSendEchoRequest(fsm *f); static void LcpLinkFailure(fsm *f); static void LcpEchoCheck(fsm *f); -static const fsm_callbacks lcp_callbacks = { /* LCP callback routines */ - lcp_resetci, /* Reset our Configuration Information */ - lcp_cilen, /* Length of our Configuration Information */ - lcp_addci, /* Add our Configuration Information */ - lcp_ackci, /* ACK our Configuration Information */ - lcp_nakci, /* NAK our Configuration Information */ - lcp_rejci, /* Reject our Configuration Information */ - lcp_reqci, /* Request peer's Configuration Information */ - lcp_up, /* Called when fsm reaches OPENED state */ - lcp_down, /* Called when fsm leaves OPENED state */ - lcp_starting, /* Called when we want the lower layer up */ - lcp_finished, /* Called when we want the lower layer down */ - NULL, /* Called when Protocol-Reject received */ - NULL, /* Retransmission is necessary */ - lcp_extcode, /* Called to handle LCP-specific codes */ - "LCP" /* String name of protocol */ +static const fsm_callbacks lcp_callbacks = { /* LCP callback routines */ + lcp_resetci, /* Reset our Configuration Information */ + lcp_cilen, /* Length of our Configuration Information */ + lcp_addci, /* Add our Configuration Information */ + lcp_ackci, /* ACK our Configuration Information */ + lcp_nakci, /* NAK our Configuration Information */ + lcp_rejci, /* Reject our Configuration Information */ + lcp_reqci, /* Request peer's Configuration Information */ + lcp_up, /* Called when fsm reaches OPENED state */ + lcp_down, /* Called when fsm leaves OPENED state */ + lcp_starting, /* Called when we want the lower layer up */ + lcp_finished, /* Called when we want the lower layer down */ + NULL, /* Called when Protocol-Reject received */ + NULL, /* Retransmission is necessary */ + lcp_extcode, /* Called to handle LCP-specific codes */ + "LCP" /* String name of protocol */ }; /* @@ -269,7 +269,7 @@ static void lcp_input(ppp_pcb *pcb, u_char *p, int len); static void lcp_protrej(ppp_pcb *pcb); #if PRINTPKT_SUPPORT static int lcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); #endif /* PRINTPKT_SUPPORT */ const struct protent lcp_protent = { @@ -304,20 +304,20 @@ const struct protent lcp_protent = { /* * Length of each type of configuration option (in octets) */ -#define CILEN_VOID 2 -#define CILEN_CHAR 3 -#define CILEN_SHORT 4 /* CILEN_VOID + 2 */ +#define CILEN_VOID 2 +#define CILEN_CHAR 3 +#define CILEN_SHORT 4 /* CILEN_VOID + 2 */ #if CHAP_SUPPORT -#define CILEN_CHAP 5 /* CILEN_VOID + 2 + 1 */ +#define CILEN_CHAP 5 /* CILEN_VOID + 2 + 1 */ #endif /* CHAP_SUPPORT */ -#define CILEN_LONG 6 /* CILEN_VOID + 4 */ +#define CILEN_LONG 6 /* CILEN_VOID + 4 */ #if LQR_SUPPORT -#define CILEN_LQR 8 /* CILEN_VOID + 2 + 4 */ +#define CILEN_LQR 8 /* CILEN_VOID + 2 + 4 */ #endif /* LQR_SUPPORT */ -#define CILEN_CBCP 3 +#define CILEN_CBCP 3 -#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ - (x) == CONFNAK ? "NAK" : "REJ") +#define CODENAME(x) ((x) == CONFACK ? "ACK" : \ + (x) == CONFNAK ? "NAK" : "REJ") #if PPP_OPTIONS /* @@ -340,8 +340,8 @@ setendpoint(argv) char **argv; { if (str_to_epdisc(&lcp_wantoptions[0].endpoint, *argv)) { - lcp_wantoptions[0].neg_endpoint = 1; - return 1; + lcp_wantoptions[0].neg_endpoint = 1; + return 1; } option_error("Can't parse '%s' as an endpoint discriminator", *argv); return 0; @@ -353,7 +353,7 @@ printendpoint(opt, printer, arg) void (*printer) (void *, char *, ...); void *arg; { - printer(arg, "%s", epdisc_to_str(&lcp_wantoptions[0].endpoint)); + printer(arg, "%s", epdisc_to_str(&lcp_wantoptions[0].endpoint)); } #endif /* HAVE_MULTILINK */ @@ -409,9 +409,9 @@ void lcp_open(ppp_pcb *pcb) { f->flags &= ~(OPT_PASSIVE | OPT_SILENT); if (wo->passive) - f->flags |= OPT_PASSIVE; + f->flags |= OPT_PASSIVE; if (wo->silent) - f->flags |= OPT_SILENT; + f->flags |= OPT_SILENT; fsm_open(f); } @@ -428,25 +428,25 @@ void lcp_close(ppp_pcb *pcb, const char *reason) { && pcb->phase != PPP_PHASE_MASTER #endif /* HAVE_MULTILINK */ ) - new_phase(pcb, PPP_PHASE_TERMINATE); + new_phase(pcb, PPP_PHASE_TERMINATE); if (f->flags & DELAYED_UP) { - UNTIMEOUT(lcp_delayed_up, f); - f->state = PPP_FSM_STOPPED; + UNTIMEOUT(lcp_delayed_up, f); + f->state = PPP_FSM_STOPPED; } oldstate = f->state; fsm_close(f, reason); if (oldstate == PPP_FSM_STOPPED && (f->flags & (OPT_PASSIVE|OPT_SILENT|DELAYED_UP))) { - /* - * This action is not strictly according to the FSM in RFC1548, - * but it does mean that the program terminates if you do a - * lcp_close() when a connection hasn't been established - * because we are in passive/silent mode or because we have - * delayed the fsm_lowerup() call and it hasn't happened yet. - */ - f->flags &= ~DELAYED_UP; - lcp_finished(f); + /* + * This action is not strictly according to the FSM in RFC1548, + * but it does mean that the program terminates if you do a + * lcp_close() when a connection hasn't been established + * because we are in passive/silent mode or because we have + * delayed the fsm_lowerup() call and it hasn't happened yet. + */ + f->flags &= ~DELAYED_UP; + lcp_finished(f); } } @@ -463,16 +463,16 @@ void lcp_lowerup(ppp_pcb *pcb) { * if we are going to ask for A/C and protocol compression. */ if (ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0) < 0 - || ppp_recv_config(pcb, PPP_MRU, (pcb->settings.lax_recv? 0: 0xffffffff), - wo->neg_pcompression, wo->neg_accompression) < 0) - return; + || ppp_recv_config(pcb, PPP_MRU, (pcb->settings.lax_recv? 0: 0xffffffff), + wo->neg_pcompression, wo->neg_accompression) < 0) + return; pcb->peer_mru = PPP_MRU; if (pcb->settings.listen_time != 0) { - f->flags |= DELAYED_UP; - TIMEOUTMS(lcp_delayed_up, f, pcb->settings.listen_time); + f->flags |= DELAYED_UP; + TIMEOUTMS(lcp_delayed_up, f, pcb->settings.listen_time); } else - fsm_lowerup(f); + fsm_lowerup(f); } @@ -483,10 +483,10 @@ void lcp_lowerdown(ppp_pcb *pcb) { fsm *f = &pcb->lcp_fsm; if (f->flags & DELAYED_UP) { - f->flags &= ~DELAYED_UP; - UNTIMEOUT(lcp_delayed_up, f); + f->flags &= ~DELAYED_UP; + UNTIMEOUT(lcp_delayed_up, f); } else - fsm_lowerdown(f); + fsm_lowerdown(f); } @@ -497,8 +497,8 @@ static void lcp_delayed_up(void *arg) { fsm *f = (fsm*)arg; if (f->flags & DELAYED_UP) { - f->flags &= ~DELAYED_UP; - fsm_lowerup(f); + f->flags &= ~DELAYED_UP; + fsm_lowerup(f); } } @@ -510,9 +510,9 @@ static void lcp_input(ppp_pcb *pcb, u_char *p, int len) { fsm *f = &pcb->lcp_fsm; if (f->flags & DELAYED_UP) { - f->flags &= ~DELAYED_UP; - UNTIMEOUT(lcp_delayed_up, f); - fsm_lowerup(f); + f->flags &= ~DELAYED_UP; + UNTIMEOUT(lcp_delayed_up, f); + fsm_lowerup(f); } fsm_input(f, p, len); } @@ -527,33 +527,33 @@ static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len) { switch( code ){ case PROTREJ: - lcp_rprotrej(f, inp, len); - break; - + lcp_rprotrej(f, inp, len); + break; + case ECHOREQ: - if (f->state != PPP_FSM_OPENED) - break; - magp = inp; - PUTLONG(go->magicnumber, magp); - fsm_sdata(f, ECHOREP, id, inp, len); - break; - + if (f->state != PPP_FSM_OPENED) + break; + magp = inp; + PUTLONG(go->magicnumber, magp); + fsm_sdata(f, ECHOREP, id, inp, len); + break; + case ECHOREP: - lcp_received_echo_reply(f, id, inp, len); - break; + lcp_received_echo_reply(f, id, inp, len); + break; case DISCREQ: case IDENTIF: case TIMEREM: - break; + break; default: - return 0; + return 0; } return 1; } - + /* * lcp_rprotrej - Receive an Protocol-Reject. * @@ -568,8 +568,8 @@ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { #endif /* PPP_PROTOCOLNAME */ if (len < 2) { - LCPDEBUG(("lcp_rprotrej: Rcvd short Protocol-Reject packet!")); - return; + LCPDEBUG(("lcp_rprotrej: Rcvd short Protocol-Reject packet!")); + return; } GETSHORT(prot, inp); @@ -579,8 +579,8 @@ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { * OPENED state SHOULD be silently discarded. */ if( f->state != PPP_FSM_OPENED ){ - LCPDEBUG(("Protocol-Reject discarded: LCP in state %d", f->state)); - return; + LCPDEBUG(("Protocol-Reject discarded: LCP in state %d", f->state)); + return; } #if PPP_PROTOCOLNAME @@ -591,25 +591,25 @@ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { * Upcall the proper Protocol-Reject routine. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (protp->protocol == prot) { + if (protp->protocol == prot) { #if PPP_PROTOCOLNAME - if (pname != NULL) - ppp_dbglog("Protocol-Reject for '%s' (0x%x) received", pname, - prot); - else + if (pname != NULL) + ppp_dbglog("Protocol-Reject for '%s' (0x%x) received", pname, + prot); + else #endif /* PPP_PROTOCOLNAME */ - ppp_dbglog("Protocol-Reject for 0x%x received", prot); - (*protp->protrej)(f->pcb); - return; - } + ppp_dbglog("Protocol-Reject for 0x%x received", prot); + (*protp->protrej)(f->pcb); + return; + } #if PPP_PROTOCOLNAME if (pname != NULL) - ppp_warn("Protocol-Reject for unsupported protocol '%s' (0x%x)", pname, - prot); + ppp_warn("Protocol-Reject for unsupported protocol '%s' (0x%x)", pname, + prot); else #endif /* #if PPP_PROTOCOLNAME */ - ppp_warn("Protocol-Reject for unsupported protocol 0x%x", prot); + ppp_warn("Protocol-Reject for unsupported protocol 0x%x", prot); } @@ -641,7 +641,7 @@ void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len) { #endif fsm_sdata(f, PROTREJ, ++f->id, - p, len); + p, len); } @@ -748,15 +748,15 @@ static void lcp_resetci(fsm *f) { *go = *wo; #ifdef HAVE_MULTILINK if (!multilink) { - go->neg_mrru = 0; + go->neg_mrru = 0; #endif /* HAVE_MULTILINK */ - go->neg_ssnhf = 0; - go->neg_endpoint = 0; + go->neg_ssnhf = 0; + go->neg_endpoint = 0; #ifdef HAVE_MULTILINK } #endif /* HAVE_MULTILINK */ if (pcb->settings.noendpoint) - ao->neg_endpoint = 0; + ao->neg_endpoint = 0; pcb->peer_mru = PPP_MRU; #if 0 /* UNUSED */ auth_reset(pcb); @@ -771,60 +771,60 @@ static int lcp_cilen(fsm *f) { ppp_pcb *pcb = f->pcb; lcp_options *go = &pcb->lcp_gotoptions; -#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) +#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) #if CHAP_SUPPORT -#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) +#define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) #endif /* CHAP_SUPPORT */ -#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) -#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) +#define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) +#define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) #if LQR_SUPPORT -#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) +#define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) #endif /* LQR_SUPPORT */ -#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) +#define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) /* * NB: we only ask for one of CHAP, UPAP, or EAP, even if we will * accept more than one. We prefer EAP first, then CHAP, then * PAP. */ return (LENCISHORT(go->neg_mru && go->mru != PPP_DEFMRU) + - LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + + LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + #if EAP_SUPPORT - LENCISHORT(go->neg_eap) + + LENCISHORT(go->neg_eap) + #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT /* cannot be improved, embedding a directive within macro arguments is not portable */ #if EAP_SUPPORT - LENCICHAP(!go->neg_eap && go->neg_chap) + + LENCICHAP(!go->neg_eap && go->neg_chap) + #endif /* EAP_SUPPORT */ #if !EAP_SUPPORT - LENCICHAP(go->neg_chap) + + LENCICHAP(go->neg_chap) + #endif /* !EAP_SUPPORT */ #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT /* cannot be improved, embedding a directive within macro arguments is not portable */ #if EAP_SUPPORT && CHAP_SUPPORT - LENCISHORT(!go->neg_eap && !go->neg_chap && go->neg_upap) + + LENCISHORT(!go->neg_eap && !go->neg_chap && go->neg_upap) + #endif /* EAP_SUPPORT && CHAP_SUPPORT */ #if EAP_SUPPORT && !CHAP_SUPPORT - LENCISHORT(!go->neg_eap && go->neg_upap) + + LENCISHORT(!go->neg_eap && go->neg_upap) + #endif /* EAP_SUPPORT && !CHAP_SUPPORT */ #if !EAP_SUPPORT && CHAP_SUPPORT - LENCISHORT(!go->neg_chap && go->neg_upap) + + LENCISHORT(!go->neg_chap && go->neg_upap) + #endif /* !EAP_SUPPORT && CHAP_SUPPORT */ #if !EAP_SUPPORT && !CHAP_SUPPORT - LENCISHORT(go->neg_upap) + + LENCISHORT(go->neg_upap) + #endif /* !EAP_SUPPORT && !CHAP_SUPPORT */ #endif /* PAP_SUPPORT */ #if LQR_SUPPORT - LENCILQR(go->neg_lqr) + + LENCILQR(go->neg_lqr) + #endif /* LQR_SUPPORT */ - LENCICBCP(go->neg_cbcp) + - LENCILONG(go->neg_magicnumber) + - LENCIVOID(go->neg_pcompression) + - LENCIVOID(go->neg_accompression) + + LENCICBCP(go->neg_cbcp) + + LENCILONG(go->neg_magicnumber) + + LENCIVOID(go->neg_pcompression) + + LENCIVOID(go->neg_accompression) + #ifdef HAVE_MULTILINK - LENCISHORT(go->neg_mrru) + + LENCISHORT(go->neg_mrru) + #endif /* HAVE_MULTILINK */ - LENCIVOID(go->neg_ssnhf) + - (go->neg_endpoint? CILEN_CHAR + go->endpoint.length: 0)); + LENCIVOID(go->neg_ssnhf) + + (go->neg_endpoint? CILEN_CHAR + go->endpoint.length: 0)); } @@ -838,58 +838,58 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { #define ADDCIVOID(opt, neg) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_VOID, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_VOID, ucp); \ } #define ADDCISHORT(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_SHORT, ucp); \ - PUTSHORT(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_SHORT, ucp); \ + PUTSHORT(val, ucp); \ } #if CHAP_SUPPORT #define ADDCICHAP(opt, neg, val) \ if (neg) { \ - PUTCHAR((opt), ucp); \ - PUTCHAR(CILEN_CHAP, ucp); \ - PUTSHORT(PPP_CHAP, ucp); \ - PUTCHAR((CHAP_DIGEST(val)), ucp); \ + PUTCHAR((opt), ucp); \ + PUTCHAR(CILEN_CHAP, ucp); \ + PUTSHORT(PPP_CHAP, ucp); \ + PUTCHAR((CHAP_DIGEST(val)), ucp); \ } #endif /* CHAP_SUPPORT */ #define ADDCILONG(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_LONG, ucp); \ - PUTLONG(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_LONG, ucp); \ + PUTLONG(val, ucp); \ } #if LQR_SUPPORT #define ADDCILQR(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_LQR, ucp); \ - PUTSHORT(PPP_LQR, ucp); \ - PUTLONG(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_LQR, ucp); \ + PUTSHORT(PPP_LQR, ucp); \ + PUTLONG(val, ucp); \ } #endif /* LQR_SUPPORT */ #define ADDCICHAR(opt, neg, val) \ if (neg) { \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_CHAR, ucp); \ - PUTCHAR(val, ucp); \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_CHAR, ucp); \ + PUTCHAR(val, ucp); \ } #define ADDCIENDP(opt, neg, class, val, len) \ if (neg) { \ - int i; \ - PUTCHAR(opt, ucp); \ - PUTCHAR(CILEN_CHAR + len, ucp); \ - PUTCHAR(class, ucp); \ - for (i = 0; i < len; ++i) \ - PUTCHAR(val[i], ucp); \ + int i; \ + PUTCHAR(opt, ucp); \ + PUTCHAR(CILEN_CHAR + len, ucp); \ + PUTCHAR(class, ucp); \ + for (i = 0; i < len; ++i) \ + PUTCHAR(val[i], ucp); \ } ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF, - go->asyncmap); + go->asyncmap); #if EAP_SUPPORT ADDCISHORT(CI_AUTHTYPE, go->neg_eap, PPP_EAP); #endif /* EAP_SUPPORT */ @@ -927,11 +927,11 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { #endif ADDCIVOID(CI_SSNHF, go->neg_ssnhf); ADDCIENDP(CI_EPDISC, go->neg_endpoint, go->endpoint.class_, - go->endpoint.value, go->endpoint.length); + go->endpoint.value, go->endpoint.length); if (ucp - start_ucp != *lenp) { - /* this should never happen, because peer_mtu should be 1500 */ - ppp_error("Bug in lcp_addci: wrong length"); + /* this should never happen, because peer_mtu should be 1500 */ + ppp_error("Bug in lcp_addci: wrong length"); } } @@ -941,8 +941,8 @@ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { * This should not modify any state if the Ack is bad. * * Returns: - * 0 - Ack was bad. - * 1 - Ack was good. + * 0 - Ack was bad. + * 1 - Ack was good. */ static int lcp_ackci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -958,112 +958,112 @@ static int lcp_ackci(fsm *f, u_char *p, int len) { */ #define ACKCIVOID(opt, neg) \ if (neg) { \ - if ((len -= CILEN_VOID) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_VOID || \ - citype != opt) \ - goto bad; \ + if ((len -= CILEN_VOID) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_VOID || \ + citype != opt) \ + goto bad; \ } #define ACKCISHORT(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_SHORT) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_SHORT || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != val) \ - goto bad; \ + if ((len -= CILEN_SHORT) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_SHORT || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != val) \ + goto bad; \ } #define ACKCICHAR(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_CHAR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAR || \ - citype != opt) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != val) \ - goto bad; \ + if ((len -= CILEN_CHAR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAR || \ + citype != opt) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != val) \ + goto bad; \ } #if CHAP_SUPPORT #define ACKCICHAP(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_CHAP) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAP || \ - citype != (opt)) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != PPP_CHAP) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != (CHAP_DIGEST(val))) \ - goto bad; \ + if ((len -= CILEN_CHAP) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAP || \ + citype != (opt)) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != PPP_CHAP) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != (CHAP_DIGEST(val))) \ + goto bad; \ } #endif /* CHAP_SUPPORT */ #define ACKCILONG(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_LONG) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_LONG || \ - citype != opt) \ - goto bad; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - goto bad; \ + if ((len -= CILEN_LONG) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_LONG || \ + citype != opt) \ + goto bad; \ + GETLONG(cilong, p); \ + if (cilong != val) \ + goto bad; \ } #if LQR_SUPPORT #define ACKCILQR(opt, neg, val) \ if (neg) { \ - if ((len -= CILEN_LQR) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_LQR || \ - citype != opt) \ - goto bad; \ - GETSHORT(cishort, p); \ - if (cishort != PPP_LQR) \ - goto bad; \ - GETLONG(cilong, p); \ - if (cilong != val) \ - goto bad; \ + if ((len -= CILEN_LQR) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_LQR || \ + citype != opt) \ + goto bad; \ + GETSHORT(cishort, p); \ + if (cishort != PPP_LQR) \ + goto bad; \ + GETLONG(cilong, p); \ + if (cilong != val) \ + goto bad; \ } #endif /* LQR_SUPPORT */ #define ACKCIENDP(opt, neg, class, val, vlen) \ if (neg) { \ - int i; \ - if ((len -= CILEN_CHAR + vlen) < 0) \ - goto bad; \ - GETCHAR(citype, p); \ - GETCHAR(cilen, p); \ - if (cilen != CILEN_CHAR + vlen || \ - citype != opt) \ - goto bad; \ - GETCHAR(cichar, p); \ - if (cichar != class) \ - goto bad; \ - for (i = 0; i < vlen; ++i) { \ - GETCHAR(cichar, p); \ - if (cichar != val[i]) \ - goto bad; \ - } \ + int i; \ + if ((len -= CILEN_CHAR + vlen) < 0) \ + goto bad; \ + GETCHAR(citype, p); \ + GETCHAR(cilen, p); \ + if (cilen != CILEN_CHAR + vlen || \ + citype != opt) \ + goto bad; \ + GETCHAR(cichar, p); \ + if (cichar != class) \ + goto bad; \ + for (i = 0; i < vlen; ++i) { \ + GETCHAR(cichar, p); \ + if (cichar != val[i]) \ + goto bad; \ + } \ } ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF, - go->asyncmap); + go->asyncmap); #if EAP_SUPPORT ACKCISHORT(CI_AUTHTYPE, go->neg_eap, PPP_EAP); #endif /* EAP_SUPPORT */ @@ -1101,13 +1101,13 @@ static int lcp_ackci(fsm *f, u_char *p, int len) { #endif /* HAVE_MULTILINK */ ACKCIVOID(CI_SSNHF, go->neg_ssnhf); ACKCIENDP(CI_EPDISC, go->neg_endpoint, go->endpoint.class_, - go->endpoint.value, go->endpoint.length); + go->endpoint.value, go->endpoint.length); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; return (1); bad: LCPDEBUG(("lcp_acki: received bad Ack!")); @@ -1121,8 +1121,8 @@ bad: * or if LCP is in the OPENED state. * * Returns: - * 0 - Nak was bad. - * 1 - Nak was good. + * 0 - Nak was bad. + * 1 - Nak was good. */ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { ppp_pcb *pcb = f->pcb; @@ -1131,8 +1131,8 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { u_char citype, cichar, *next; u_short cishort; u32_t cilong; - lcp_options no; /* options we've seen Naks for */ - lcp_options try_; /* options to request next time */ + lcp_options no; /* options we've seen Naks for */ + lcp_options try_; /* options to request next time */ int looped_back = 0; int cilen; @@ -1146,85 +1146,85 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { */ #define NAKCIVOID(opt, neg) \ if (go->neg && \ - len >= CILEN_VOID && \ - p[1] == CILEN_VOID && \ - p[0] == opt) { \ - len -= CILEN_VOID; \ - INCPTR(CILEN_VOID, p); \ - no.neg = 1; \ - try_.neg = 0; \ + len >= CILEN_VOID && \ + p[1] == CILEN_VOID && \ + p[0] == opt) { \ + len -= CILEN_VOID; \ + INCPTR(CILEN_VOID, p); \ + no.neg = 1; \ + try_.neg = 0; \ } #if CHAP_SUPPORT #define NAKCICHAP(opt, neg, code) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - no.neg = 1; \ - code \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + no.neg = 1; \ + code \ } #endif /* CHAP_SUPPORT */ #define NAKCICHAR(opt, neg, code) \ if (go->neg && \ - len >= CILEN_CHAR && \ - p[1] == CILEN_CHAR && \ - p[0] == opt) { \ - len -= CILEN_CHAR; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - no.neg = 1; \ - code \ + len >= CILEN_CHAR && \ + p[1] == CILEN_CHAR && \ + p[0] == opt) { \ + len -= CILEN_CHAR; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + no.neg = 1; \ + code \ } #define NAKCISHORT(opt, neg, code) \ if (go->neg && \ - len >= CILEN_SHORT && \ - p[1] == CILEN_SHORT && \ - p[0] == opt) { \ - len -= CILEN_SHORT; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - no.neg = 1; \ - code \ + len >= CILEN_SHORT && \ + p[1] == CILEN_SHORT && \ + p[0] == opt) { \ + len -= CILEN_SHORT; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + no.neg = 1; \ + code \ } #define NAKCILONG(opt, neg, code) \ if (go->neg && \ - len >= CILEN_LONG && \ - p[1] == CILEN_LONG && \ - p[0] == opt) { \ - len -= CILEN_LONG; \ - INCPTR(2, p); \ - GETLONG(cilong, p); \ - no.neg = 1; \ - code \ + len >= CILEN_LONG && \ + p[1] == CILEN_LONG && \ + p[0] == opt) { \ + len -= CILEN_LONG; \ + INCPTR(2, p); \ + GETLONG(cilong, p); \ + no.neg = 1; \ + code \ } #if LQR_SUPPORT #define NAKCILQR(opt, neg, code) \ if (go->neg && \ - len >= CILEN_LQR && \ - p[1] == CILEN_LQR && \ - p[0] == opt) { \ - len -= CILEN_LQR; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETLONG(cilong, p); \ - no.neg = 1; \ - code \ + len >= CILEN_LQR && \ + p[1] == CILEN_LQR && \ + p[0] == opt) { \ + len -= CILEN_LQR; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETLONG(cilong, p); \ + no.neg = 1; \ + code \ } #endif /* LQR_SUPPORT */ #define NAKCIENDP(opt, neg) \ if (go->neg && \ - len >= CILEN_CHAR && \ - p[0] == opt && \ - p[1] >= CILEN_CHAR && \ - p[1] <= len) { \ - len -= p[1]; \ - INCPTR(p[1], p); \ - no.neg = 1; \ - try_.neg = 0; \ + len >= CILEN_CHAR && \ + p[0] == opt && \ + p[1] >= CILEN_CHAR && \ + p[1] <= len) { \ + len -= p[1]; \ + INCPTR(p[1], p); \ + no.neg = 1; \ + try_.neg = 0; \ } /* @@ -1239,19 +1239,19 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * the limit of the default MRU we'd get if we didn't negotiate. */ if (go->neg_mru && go->mru != PPP_DEFMRU) { - NAKCISHORT(CI_MRU, neg_mru, - if (cishort <= wo->mru || cishort <= PPP_DEFMRU) - try_.mru = cishort; - ); + NAKCISHORT(CI_MRU, neg_mru, + if (cishort <= wo->mru || cishort <= PPP_DEFMRU) + try_.mru = cishort; + ); } /* * Add any characters they want to our (receive-side) asyncmap. */ if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) { - NAKCILONG(CI_ASYNCMAP, neg_asyncmap, - try_.asyncmap = go->asyncmap | cilong; - ); + NAKCILONG(CI_ASYNCMAP, neg_asyncmap, + try_.asyncmap = go->asyncmap | cilong; + ); } /* @@ -1270,125 +1270,125 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { || go->neg_eap #endif /* EAP_SUPPORT */ ) - && len >= CILEN_SHORT - && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { - cilen = p[1]; - len -= cilen; + && len >= CILEN_SHORT + && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { + cilen = p[1]; + len -= cilen; #if CHAP_SUPPORT - no.neg_chap = go->neg_chap; + no.neg_chap = go->neg_chap; #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - no.neg_upap = go->neg_upap; + no.neg_upap = go->neg_upap; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - no.neg_eap = go->neg_eap; + no.neg_eap = go->neg_eap; #endif /* EAP_SUPPORT */ - INCPTR(2, p); - GETSHORT(cishort, p); + INCPTR(2, p); + GETSHORT(cishort, p); #if PAP_SUPPORT - if (cishort == PPP_PAP && cilen == CILEN_SHORT) { + if (cishort == PPP_PAP && cilen == CILEN_SHORT) { #if EAP_SUPPORT - /* If we were asking for EAP, then we need to stop that. */ - if (go->neg_eap) - try_.neg_eap = 0; - else + /* If we were asking for EAP, then we need to stop that. */ + if (go->neg_eap) + try_.neg_eap = 0; + else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - /* If we were asking for CHAP, then we need to stop that. */ - if (go->neg_chap) - try_.neg_chap = 0; - else + /* If we were asking for CHAP, then we need to stop that. */ + if (go->neg_chap) + try_.neg_chap = 0; + else #endif /* CHAP_SUPPORT */ - /* - * If we weren't asking for CHAP or EAP, then we were asking for - * PAP, in which case this Nak is bad. - */ - goto bad; - } else + /* + * If we weren't asking for CHAP or EAP, then we were asking for + * PAP, in which case this Nak is bad. + */ + goto bad; + } else #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { - GETCHAR(cichar, p); + if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { + GETCHAR(cichar, p); #if EAP_SUPPORT - /* Stop asking for EAP, if we were. */ - if (go->neg_eap) { - try_.neg_eap = 0; - /* Try to set up to use their suggestion, if possible */ - if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) - try_.chap_mdtype = CHAP_MDTYPE_D(cichar); - } else + /* Stop asking for EAP, if we were. */ + if (go->neg_eap) { + try_.neg_eap = 0; + /* Try to set up to use their suggestion, if possible */ + if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) + try_.chap_mdtype = CHAP_MDTYPE_D(cichar); + } else #endif /* EAP_SUPPORT */ - if (go->neg_chap) { - /* - * We were asking for our preferred algorithm, they must - * want something different. - */ - if (cichar != CHAP_DIGEST(go->chap_mdtype)) { - if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) { - /* Use their suggestion if we support it ... */ - try_.chap_mdtype = CHAP_MDTYPE_D(cichar); - } else { - /* ... otherwise, try our next-preferred algorithm. */ - try_.chap_mdtype &= ~(CHAP_MDTYPE(try_.chap_mdtype)); - if (try_.chap_mdtype == MDTYPE_NONE) /* out of algos */ - try_.neg_chap = 0; - } - } else { - /* - * Whoops, they Nak'd our algorithm of choice - * but then suggested it back to us. - */ - goto bad; - } - } else { - /* - * Stop asking for PAP if we were asking for it. - */ + if (go->neg_chap) { + /* + * We were asking for our preferred algorithm, they must + * want something different. + */ + if (cichar != CHAP_DIGEST(go->chap_mdtype)) { + if (CHAP_CANDIGEST(go->chap_mdtype, cichar)) { + /* Use their suggestion if we support it ... */ + try_.chap_mdtype = CHAP_MDTYPE_D(cichar); + } else { + /* ... otherwise, try our next-preferred algorithm. */ + try_.chap_mdtype &= ~(CHAP_MDTYPE(try_.chap_mdtype)); + if (try_.chap_mdtype == MDTYPE_NONE) /* out of algos */ + try_.neg_chap = 0; + } + } else { + /* + * Whoops, they Nak'd our algorithm of choice + * but then suggested it back to us. + */ + goto bad; + } + } else { + /* + * Stop asking for PAP if we were asking for it. + */ #if PAP_SUPPORT - try_.neg_upap = 0; + try_.neg_upap = 0; #endif /* PAP_SUPPORT */ - } + } - } else + } else #endif /* CHAP_SUPPORT */ - { + { #if EAP_SUPPORT - /* - * If we were asking for EAP, and they're Conf-Naking EAP, - * well, that's just strange. Nobody should do that. - */ - if (cishort == PPP_EAP && cilen == CILEN_SHORT && go->neg_eap) - ppp_dbglog("Unexpected Conf-Nak for EAP"); - - /* - * We don't recognize what they're suggesting. - * Stop asking for what we were asking for. - */ - if (go->neg_eap) - try_.neg_eap = 0; - else + /* + * If we were asking for EAP, and they're Conf-Naking EAP, + * well, that's just strange. Nobody should do that. + */ + if (cishort == PPP_EAP && cilen == CILEN_SHORT && go->neg_eap) + ppp_dbglog("Unexpected Conf-Nak for EAP"); + + /* + * We don't recognize what they're suggesting. + * Stop asking for what we were asking for. + */ + if (go->neg_eap) + try_.neg_eap = 0; + else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - if (go->neg_chap) - try_.neg_chap = 0; - else + if (go->neg_chap) + try_.neg_chap = 0; + else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - if(1) - try_.neg_upap = 0; - else + if(1) + try_.neg_upap = 0; + else #endif /* PAP_SUPPORT */ - {} + {} - p += cilen - CILEN_SHORT; - } + p += cilen - CILEN_SHORT; + } } #if LQR_SUPPORT @@ -1398,11 +1398,11 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If they Nak the reporting period, take their value XXX ? */ NAKCILQR(CI_QUALITY, neg_lqr, - if (cishort != PPP_LQR) - try_.neg_lqr = 0; - else - try_.lqr_period = cilong; - ); + if (cishort != PPP_LQR) + try_.neg_lqr = 0; + else + try_.lqr_period = cilong; + ); #endif /* LQR_SUPPORT */ /* @@ -1417,9 +1417,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * Check for a looped-back line. */ NAKCILONG(CI_MAGICNUMBER, neg_magicnumber, - try_.magicnumber = magic(); - looped_back = 1; - ); + try_.magicnumber = magic(); + looped_back = 1; + ); /* * Peer shouldn't send Nak for protocol compression or @@ -1435,12 +1435,12 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * than the one we want. */ if (go->neg_mrru) { - NAKCISHORT(CI_MRRU, neg_mrru, - if (treat_as_reject) - try_.neg_mrru = 0; - else if (cishort <= wo->mrru) - try_.mrru = cishort; - ); + NAKCISHORT(CI_MRRU, neg_mrru, + if (treat_as_reject) + try_.neg_mrru = 0; + else if (cishort <= wo->mrru) + try_.mrru = cishort; + ); } #else /* HAVE_MULTILINK */ LWIP_UNUSED_ARG(treat_as_reject); @@ -1475,30 +1475,30 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * negotiate some option we don't support, so ignore it. */ while (len >= CILEN_VOID) { - GETCHAR(citype, p); - GETCHAR(cilen, p); - if (cilen < CILEN_VOID || (len -= cilen) < 0) - goto bad; - next = p + cilen - 2; - - switch (citype) { - case CI_MRU: - if ((go->neg_mru && go->mru != PPP_DEFMRU) - || no.neg_mru || cilen != CILEN_SHORT) - goto bad; - GETSHORT(cishort, p); - if (cishort < PPP_DEFMRU) { - try_.neg_mru = 1; - try_.mru = cishort; - } - break; - case CI_ASYNCMAP: - if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) - || no.neg_asyncmap || cilen != CILEN_LONG) - goto bad; - break; - case CI_AUTHTYPE: - if (0 + GETCHAR(citype, p); + GETCHAR(cilen, p); + if (cilen < CILEN_VOID || (len -= cilen) < 0) + goto bad; + next = p + cilen - 2; + + switch (citype) { + case CI_MRU: + if ((go->neg_mru && go->mru != PPP_DEFMRU) + || no.neg_mru || cilen != CILEN_SHORT) + goto bad; + GETSHORT(cishort, p); + if (cishort < PPP_DEFMRU) { + try_.neg_mru = 1; + try_.mru = cishort; + } + break; + case CI_ASYNCMAP: + if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFF) + || no.neg_asyncmap || cilen != CILEN_LONG) + goto bad; + break; + case CI_AUTHTYPE: + if (0 #if CHAP_SUPPORT || go->neg_chap || no.neg_chap #endif /* CHAP_SUPPORT */ @@ -1506,51 +1506,51 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { || go->neg_upap || no.neg_upap #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - || go->neg_eap || no.neg_eap + || go->neg_eap || no.neg_eap #endif /* EAP_SUPPORT */ - ) - goto bad; - break; - case CI_MAGICNUMBER: - if (go->neg_magicnumber || no.neg_magicnumber || - cilen != CILEN_LONG) - goto bad; - break; - case CI_PCOMPRESSION: - if (go->neg_pcompression || no.neg_pcompression - || cilen != CILEN_VOID) - goto bad; - break; - case CI_ACCOMPRESSION: - if (go->neg_accompression || no.neg_accompression - || cilen != CILEN_VOID) - goto bad; - break; + ) + goto bad; + break; + case CI_MAGICNUMBER: + if (go->neg_magicnumber || no.neg_magicnumber || + cilen != CILEN_LONG) + goto bad; + break; + case CI_PCOMPRESSION: + if (go->neg_pcompression || no.neg_pcompression + || cilen != CILEN_VOID) + goto bad; + break; + case CI_ACCOMPRESSION: + if (go->neg_accompression || no.neg_accompression + || cilen != CILEN_VOID) + goto bad; + break; #if LQR_SUPPORT - case CI_QUALITY: - if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) - goto bad; - break; + case CI_QUALITY: + if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) + goto bad; + break; #endif /* LQR_SUPPORT */ #ifdef HAVE_MULTILINK - case CI_MRRU: - if (go->neg_mrru || no.neg_mrru || cilen != CILEN_SHORT) - goto bad; - break; + case CI_MRRU: + if (go->neg_mrru || no.neg_mrru || cilen != CILEN_SHORT) + goto bad; + break; #endif /* HAVE_MULTILINK */ - case CI_SSNHF: - if (go->neg_ssnhf || no.neg_ssnhf || cilen != CILEN_VOID) - goto bad; - try_.neg_ssnhf = 1; - break; - case CI_EPDISC: - if (go->neg_endpoint || no.neg_endpoint || cilen < CILEN_CHAR) - goto bad; - break; - default: - break; - } - p = next; + case CI_SSNHF: + if (go->neg_ssnhf || no.neg_ssnhf || cilen != CILEN_VOID) + goto bad; + try_.neg_ssnhf = 1; + break; + case CI_EPDISC: + if (go->neg_endpoint || no.neg_endpoint || cilen < CILEN_CHAR) + goto bad; + break; + default: + break; + } + p = next; } /* @@ -1558,15 +1558,15 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) { * If there are any options left we ignore them. */ if (f->state != PPP_FSM_OPENED) { - if (looped_back) { - if (++try_.numloops >= pcb->settings.lcp_loopbackfail) { - ppp_notice("Serial line is looped back."); - pcb->err_code = PPPERR_LOOPBACK; - lcp_close(f->pcb, "Loopback detected"); - } - } else - try_.numloops = 0; - *go = try_; + if (looped_back) { + if (++try_.numloops >= pcb->settings.lcp_loopbackfail) { + ppp_notice("Serial line is looped back."); + pcb->err_code = PPPERR_LOOPBACK; + lcp_close(f->pcb, "Loopback detected"); + } + } else + try_.numloops = 0; + *go = try_; } return 1; @@ -1583,8 +1583,8 @@ bad: * or if LCP is in the OPENED state. * * Returns: - * 0 - Reject was bad. - * 1 - Reject was good. + * 0 - Reject was bad. + * 1 - Reject was good. */ static int lcp_rejci(fsm *f, u_char *p, int len) { ppp_pcb *pcb = f->pcb; @@ -1592,7 +1592,7 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { u_char cichar; u_short cishort; u32_t cilong; - lcp_options try_; /* options to request next time */ + lcp_options try_; /* options to request next time */ try_ = *go; @@ -1603,157 +1603,157 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { */ #define REJCIVOID(opt, neg) \ if (go->neg && \ - len >= CILEN_VOID && \ - p[1] == CILEN_VOID && \ - p[0] == opt) { \ - len -= CILEN_VOID; \ - INCPTR(CILEN_VOID, p); \ - try_.neg = 0; \ + len >= CILEN_VOID && \ + p[1] == CILEN_VOID && \ + p[0] == opt) { \ + len -= CILEN_VOID; \ + INCPTR(CILEN_VOID, p); \ + try_.neg = 0; \ } #define REJCISHORT(opt, neg, val) \ if (go->neg && \ - len >= CILEN_SHORT && \ - p[1] == CILEN_SHORT && \ - p[0] == opt) { \ - len -= CILEN_SHORT; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - /* Check rejected value. */ \ - if (cishort != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_SHORT && \ + p[1] == CILEN_SHORT && \ + p[0] == opt) { \ + len -= CILEN_SHORT; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + /* Check rejected value. */ \ + if (cishort != val) \ + goto bad; \ + try_.neg = 0; \ } #if CHAP_SUPPORT && EAP_SUPPORT && PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ - try_.neg_eap = try_.neg_upap = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ + try_.neg_eap = try_.neg_upap = 0; \ } #endif /* CHAP_SUPPORT && EAP_SUPPORT && PAP_SUPPORT */ #if CHAP_SUPPORT && !EAP_SUPPORT && PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ - try_.neg_upap = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ + try_.neg_upap = 0; \ } #endif /* CHAP_SUPPORT && !EAP_SUPPORT && PAP_SUPPORT */ #if CHAP_SUPPORT && EAP_SUPPORT && !PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ - try_.neg_eap = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ + try_.neg_eap = 0; \ } #endif /* CHAP_SUPPORT && EAP_SUPPORT && !PAP_SUPPORT */ #if CHAP_SUPPORT && !EAP_SUPPORT && !PAP_SUPPORT #define REJCICHAP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CHAP && \ - p[1] == CILEN_CHAP && \ - p[0] == opt) { \ - len -= CILEN_CHAP; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_CHAP && \ + p[1] == CILEN_CHAP && \ + p[0] == opt) { \ + len -= CILEN_CHAP; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if ((cishort != PPP_CHAP) || (cichar != (CHAP_DIGEST(val)))) \ + goto bad; \ + try_.neg = 0; \ } #endif /* CHAP_SUPPORT && !EAP_SUPPORT && !PAP_SUPPORT */ #define REJCILONG(opt, neg, val) \ if (go->neg && \ - len >= CILEN_LONG && \ - p[1] == CILEN_LONG && \ - p[0] == opt) { \ - len -= CILEN_LONG; \ - INCPTR(2, p); \ - GETLONG(cilong, p); \ - /* Check rejected value. */ \ - if (cilong != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_LONG && \ + p[1] == CILEN_LONG && \ + p[0] == opt) { \ + len -= CILEN_LONG; \ + INCPTR(2, p); \ + GETLONG(cilong, p); \ + /* Check rejected value. */ \ + if (cilong != val) \ + goto bad; \ + try_.neg = 0; \ } #if LQR_SUPPORT #define REJCILQR(opt, neg, val) \ if (go->neg && \ - len >= CILEN_LQR && \ - p[1] == CILEN_LQR && \ - p[0] == opt) { \ - len -= CILEN_LQR; \ - INCPTR(2, p); \ - GETSHORT(cishort, p); \ - GETLONG(cilong, p); \ - /* Check rejected value. */ \ - if (cishort != PPP_LQR || cilong != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_LQR && \ + p[1] == CILEN_LQR && \ + p[0] == opt) { \ + len -= CILEN_LQR; \ + INCPTR(2, p); \ + GETSHORT(cishort, p); \ + GETLONG(cilong, p); \ + /* Check rejected value. */ \ + if (cishort != PPP_LQR || cilong != val) \ + goto bad; \ + try_.neg = 0; \ } #endif /* LQR_SUPPORT */ #define REJCICBCP(opt, neg, val) \ if (go->neg && \ - len >= CILEN_CBCP && \ - p[1] == CILEN_CBCP && \ - p[0] == opt) { \ - len -= CILEN_CBCP; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - /* Check rejected value. */ \ - if (cichar != val) \ - goto bad; \ - try_.neg = 0; \ + len >= CILEN_CBCP && \ + p[1] == CILEN_CBCP && \ + p[0] == opt) { \ + len -= CILEN_CBCP; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + /* Check rejected value. */ \ + if (cichar != val) \ + goto bad; \ + try_.neg = 0; \ } #define REJCIENDP(opt, neg, class, val, vlen) \ if (go->neg && \ - len >= CILEN_CHAR + vlen && \ - p[0] == opt && \ - p[1] == CILEN_CHAR + vlen) { \ - int i; \ - len -= CILEN_CHAR + vlen; \ - INCPTR(2, p); \ - GETCHAR(cichar, p); \ - if (cichar != class) \ - goto bad; \ - for (i = 0; i < vlen; ++i) { \ - GETCHAR(cichar, p); \ - if (cichar != val[i]) \ - goto bad; \ - } \ - try_.neg = 0; \ + len >= CILEN_CHAR + vlen && \ + p[0] == opt && \ + p[1] == CILEN_CHAR + vlen) { \ + int i; \ + len -= CILEN_CHAR + vlen; \ + INCPTR(2, p); \ + GETCHAR(cichar, p); \ + if (cichar != class) \ + goto bad; \ + for (i = 0; i < vlen; ++i) { \ + GETCHAR(cichar, p); \ + if (cichar != val[i]) \ + goto bad; \ + } \ + try_.neg = 0; \ } REJCISHORT(CI_MRU, neg_mru, go->mru); @@ -1763,14 +1763,14 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { if (!go->neg_eap) { #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - REJCICHAP(CI_AUTHTYPE, neg_chap, go->chap_mdtype); - if (!go->neg_chap) { + REJCICHAP(CI_AUTHTYPE, neg_chap, go->chap_mdtype); + if (!go->neg_chap) { #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); + REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - } + } #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT } @@ -1787,18 +1787,18 @@ static int lcp_rejci(fsm *f, u_char *p, int len) { #endif /* HAVE_MULTILINK */ REJCIVOID(CI_SSNHF, neg_ssnhf); REJCIENDP(CI_EPDISC, neg_endpoint, go->endpoint.class_, - go->endpoint.value, go->endpoint.length); + go->endpoint.value, go->endpoint.length); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) - goto bad; + goto bad; /* * Now we can update state. */ if (f->state != PPP_FSM_OPENED) - *go = try_; + *go = try_; return 1; bad: @@ -1822,17 +1822,17 @@ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree) { lcp_options *go = &pcb->lcp_gotoptions; lcp_options *ho = &pcb->lcp_hisoptions; lcp_options *ao = &pcb->lcp_allowoptions; - u_char *cip, *next; /* Pointer to current and next CIs */ - int cilen, citype, cichar; /* Parsed len, type, char value */ - u_short cishort; /* Parsed short value */ - u32_t cilong; /* Parse long value */ - int rc = CONFACK; /* Final packet return code */ - int orc; /* Individual option return code */ - u_char *p; /* Pointer to next char to parse */ - u_char *rejp; /* Pointer to next char in reject frame */ + u_char *cip, *next; /* Pointer to current and next CIs */ + int cilen, citype, cichar; /* Parsed len, type, char value */ + u_short cishort; /* Parsed short value */ + u32_t cilong; /* Parse long value */ + int rc = CONFACK; /* Final packet return code */ + int orc; /* Individual option return code */ + u_char *p; /* Pointer to next char to parse */ + u_char *rejp; /* Pointer to next char in reject frame */ struct pbuf *nakp; /* Nak buffer */ - u_char *nakoutp; /* Pointer to next char in Nak frame */ - int l = *lenp; /* Length left */ + u_char *nakoutp; /* Pointer to next char in Nak frame */ + int l = *lenp; /* Length left */ /* * Reset all his options. @@ -1854,403 +1854,403 @@ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree) { nakoutp = (u_char*)nakp->payload; rejp = inp; while (l) { - orc = CONFACK; /* Assume success */ - cip = p = next; /* Remember begining of CI */ - if (l < 2 || /* Not enough data for CI header or */ - p[1] < 2 || /* CI length too small or */ - p[1] > l) { /* CI length too big? */ - LCPDEBUG(("lcp_reqci: bad CI length!")); - orc = CONFREJ; /* Reject bad CI */ - cilen = l; /* Reject till end of packet */ - l = 0; /* Don't loop again */ - citype = 0; - goto endswitch; - } - GETCHAR(citype, p); /* Parse CI type */ - GETCHAR(cilen, p); /* Parse CI length */ - l -= cilen; /* Adjust remaining length */ - next += cilen; /* Step to next CI */ - - switch (citype) { /* Check CI type */ - case CI_MRU: - if (!ao->neg_mru || /* Allow option? */ - cilen != CILEN_SHORT) { /* Check CI length */ - orc = CONFREJ; /* Reject CI */ - break; - } - GETSHORT(cishort, p); /* Parse MRU */ - - /* - * He must be able to receive at least our minimum. - * No need to check a maximum. If he sends a large number, - * we'll just ignore it. - */ - if (cishort < PPP_MINMRU) { - orc = CONFNAK; /* Nak CI */ - PUTCHAR(CI_MRU, nakoutp); - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_MINMRU, nakoutp); /* Give him a hint */ - break; - } - ho->neg_mru = 1; /* Remember he sent MRU */ - ho->mru = cishort; /* And remember value */ - break; - - case CI_ASYNCMAP: - if (!ao->neg_asyncmap || - cilen != CILEN_LONG) { - orc = CONFREJ; - break; - } - GETLONG(cilong, p); - - /* - * Asyncmap must have set at least the bits - * which are set in lcp_allowoptions[unit].asyncmap. - */ - if ((ao->asyncmap & ~cilong) != 0) { - orc = CONFNAK; - PUTCHAR(CI_ASYNCMAP, nakoutp); - PUTCHAR(CILEN_LONG, nakoutp); - PUTLONG(ao->asyncmap | cilong, nakoutp); - break; - } - ho->neg_asyncmap = 1; - ho->asyncmap = cilong; - break; - - case CI_AUTHTYPE: - if (cilen < CILEN_SHORT || - !(0 + orc = CONFACK; /* Assume success */ + cip = p = next; /* Remember begining of CI */ + if (l < 2 || /* Not enough data for CI header or */ + p[1] < 2 || /* CI length too small or */ + p[1] > l) { /* CI length too big? */ + LCPDEBUG(("lcp_reqci: bad CI length!")); + orc = CONFREJ; /* Reject bad CI */ + cilen = l; /* Reject till end of packet */ + l = 0; /* Don't loop again */ + citype = 0; + goto endswitch; + } + GETCHAR(citype, p); /* Parse CI type */ + GETCHAR(cilen, p); /* Parse CI length */ + l -= cilen; /* Adjust remaining length */ + next += cilen; /* Step to next CI */ + + switch (citype) { /* Check CI type */ + case CI_MRU: + if (!ao->neg_mru || /* Allow option? */ + cilen != CILEN_SHORT) { /* Check CI length */ + orc = CONFREJ; /* Reject CI */ + break; + } + GETSHORT(cishort, p); /* Parse MRU */ + + /* + * He must be able to receive at least our minimum. + * No need to check a maximum. If he sends a large number, + * we'll just ignore it. + */ + if (cishort < PPP_MINMRU) { + orc = CONFNAK; /* Nak CI */ + PUTCHAR(CI_MRU, nakoutp); + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_MINMRU, nakoutp); /* Give him a hint */ + break; + } + ho->neg_mru = 1; /* Remember he sent MRU */ + ho->mru = cishort; /* And remember value */ + break; + + case CI_ASYNCMAP: + if (!ao->neg_asyncmap || + cilen != CILEN_LONG) { + orc = CONFREJ; + break; + } + GETLONG(cilong, p); + + /* + * Asyncmap must have set at least the bits + * which are set in lcp_allowoptions[unit].asyncmap. + */ + if ((ao->asyncmap & ~cilong) != 0) { + orc = CONFNAK; + PUTCHAR(CI_ASYNCMAP, nakoutp); + PUTCHAR(CILEN_LONG, nakoutp); + PUTLONG(ao->asyncmap | cilong, nakoutp); + break; + } + ho->neg_asyncmap = 1; + ho->asyncmap = cilong; + break; + + case CI_AUTHTYPE: + if (cilen < CILEN_SHORT || + !(0 #if PAP_SUPPORT - || ao->neg_upap + || ao->neg_upap #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - || ao->neg_chap + || ao->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || ao->neg_eap + || ao->neg_eap #endif /* EAP_SUPPORT */ - )) { - /* - * Reject the option if we're not willing to authenticate. - */ - ppp_dbglog("No auth is possible"); - orc = CONFREJ; - break; - } - GETSHORT(cishort, p); - - /* - * Authtype must be PAP, CHAP, or EAP. - * - * Note: if more than one of ao->neg_upap, ao->neg_chap, and - * ao->neg_eap are set, and the peer sends a Configure-Request - * with two or more authenticate-protocol requests, then we will - * reject the second request. - * Whether we end up doing CHAP, UPAP, or EAP depends then on - * the ordering of the CIs in the peer's Configure-Request. + )) { + /* + * Reject the option if we're not willing to authenticate. + */ + ppp_dbglog("No auth is possible"); + orc = CONFREJ; + break; + } + GETSHORT(cishort, p); + + /* + * Authtype must be PAP, CHAP, or EAP. + * + * Note: if more than one of ao->neg_upap, ao->neg_chap, and + * ao->neg_eap are set, and the peer sends a Configure-Request + * with two or more authenticate-protocol requests, then we will + * reject the second request. + * Whether we end up doing CHAP, UPAP, or EAP depends then on + * the ordering of the CIs in the peer's Configure-Request. */ #if PAP_SUPPORT - if (cishort == PPP_PAP) { - /* we've already accepted CHAP or EAP */ - if (0 + if (cishort == PPP_PAP) { + /* we've already accepted CHAP or EAP */ + if (0 #if CHAP_SUPPORT - || ho->neg_chap + || ho->neg_chap #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - || ho->neg_eap + || ho->neg_eap #endif /* EAP_SUPPORT */ - || cilen != CILEN_SHORT) { - LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE PAP, rejecting...")); - orc = CONFREJ; - break; - } - if (!ao->neg_upap) { /* we don't want to do PAP */ - orc = CONFNAK; /* NAK it and suggest CHAP or EAP */ - PUTCHAR(CI_AUTHTYPE, nakoutp); + || cilen != CILEN_SHORT) { + LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE PAP, rejecting...")); + orc = CONFREJ; + break; + } + if (!ao->neg_upap) { /* we don't want to do PAP */ + orc = CONFNAK; /* NAK it and suggest CHAP or EAP */ + PUTCHAR(CI_AUTHTYPE, nakoutp); #if EAP_SUPPORT - if (ao->neg_eap) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_EAP, nakoutp); - } else { + if (ao->neg_eap) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_EAP, nakoutp); + } else { #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - } + } #endif /* EAP_SUPPORT */ - break; - } - ho->neg_upap = 1; - break; - } + break; + } + ho->neg_upap = 1; + break; + } #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - if (cishort == PPP_CHAP) { - /* we've already accepted PAP or EAP */ - if ( + if (cishort == PPP_CHAP) { + /* we've already accepted PAP or EAP */ + if ( #if PAP_SUPPORT - ho->neg_upap || + ho->neg_upap || #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - ho->neg_eap || + ho->neg_eap || #endif /* EAP_SUPPORT */ - cilen != CILEN_CHAP) { - LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE CHAP, rejecting...")); - orc = CONFREJ; - break; - } - if (!ao->neg_chap) { /* we don't want to do CHAP */ - orc = CONFNAK; /* NAK it and suggest EAP or PAP */ - PUTCHAR(CI_AUTHTYPE, nakoutp); - PUTCHAR(CILEN_SHORT, nakoutp); + cilen != CILEN_CHAP) { + LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE CHAP, rejecting...")); + orc = CONFREJ; + break; + } + if (!ao->neg_chap) { /* we don't want to do CHAP */ + orc = CONFNAK; /* NAK it and suggest EAP or PAP */ + PUTCHAR(CI_AUTHTYPE, nakoutp); + PUTCHAR(CILEN_SHORT, nakoutp); #if EAP_SUPPORT - if (ao->neg_eap) { - PUTSHORT(PPP_EAP, nakoutp); - } else + if (ao->neg_eap) { + PUTSHORT(PPP_EAP, nakoutp); + } else #endif /* EAP_SUPPORT */ #if PAP_SUPPORT - if(1) { - PUTSHORT(PPP_PAP, nakoutp); - } - else + if(1) { + PUTSHORT(PPP_PAP, nakoutp); + } + else #endif /* PAP_SUPPORT */ - {} - break; - } - GETCHAR(cichar, p); /* get digest type */ - if (!(CHAP_CANDIGEST(ao->chap_mdtype, cichar))) { - /* - * We can't/won't do the requested type, - * suggest something else. - */ - orc = CONFNAK; - PUTCHAR(CI_AUTHTYPE, nakoutp); - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); - break; - } - ho->chap_mdtype = CHAP_MDTYPE_D(cichar); /* save md type */ - ho->neg_chap = 1; - break; - } + {} + break; + } + GETCHAR(cichar, p); /* get digest type */ + if (!(CHAP_CANDIGEST(ao->chap_mdtype, cichar))) { + /* + * We can't/won't do the requested type, + * suggest something else. + */ + orc = CONFNAK; + PUTCHAR(CI_AUTHTYPE, nakoutp); + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + break; + } + ho->chap_mdtype = CHAP_MDTYPE_D(cichar); /* save md type */ + ho->neg_chap = 1; + break; + } #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - if (cishort == PPP_EAP) { - /* we've already accepted CHAP or PAP */ - if ( + if (cishort == PPP_EAP) { + /* we've already accepted CHAP or PAP */ + if ( #if CHAP_SUPPORT - ho->neg_chap || + ho->neg_chap || #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - ho->neg_upap || + ho->neg_upap || #endif /* PAP_SUPPORT */ - cilen != CILEN_SHORT) { - LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE EAP, rejecting...")); - orc = CONFREJ; - break; - } - if (!ao->neg_eap) { /* we don't want to do EAP */ - orc = CONFNAK; /* NAK it and suggest CHAP or PAP */ - PUTCHAR(CI_AUTHTYPE, nakoutp); + cilen != CILEN_SHORT) { + LCPDEBUG(("lcp_reqci: rcvd AUTHTYPE EAP, rejecting...")); + orc = CONFREJ; + break; + } + if (!ao->neg_eap) { /* we don't want to do EAP */ + orc = CONFNAK; /* NAK it and suggest CHAP or PAP */ + PUTCHAR(CI_AUTHTYPE, nakoutp); #if CHAP_SUPPORT - if (ao->neg_chap) { - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); - } else + if (ao->neg_chap) { + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - if(1) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_PAP, nakoutp); - } else + if(1) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_PAP, nakoutp); + } else #endif /* PAP_SUPPORT */ - {} - break; - } - ho->neg_eap = 1; - break; - } + {} + break; + } + ho->neg_eap = 1; + break; + } #endif /* EAP_SUPPORT */ - /* - * We don't recognize the protocol they're asking for. - * Nak it with something we're willing to do. - * (At this point we know ao->neg_upap || ao->neg_chap || - * ao->neg_eap.) - */ - orc = CONFNAK; - PUTCHAR(CI_AUTHTYPE, nakoutp); + /* + * We don't recognize the protocol they're asking for. + * Nak it with something we're willing to do. + * (At this point we know ao->neg_upap || ao->neg_chap || + * ao->neg_eap.) + */ + orc = CONFNAK; + PUTCHAR(CI_AUTHTYPE, nakoutp); #if EAP_SUPPORT - if (ao->neg_eap) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_EAP, nakoutp); - } else + if (ao->neg_eap) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_EAP, nakoutp); + } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT - if (ao->neg_chap) { - PUTCHAR(CILEN_CHAP, nakoutp); - PUTSHORT(PPP_CHAP, nakoutp); - PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); - } else + if (ao->neg_chap) { + PUTCHAR(CILEN_CHAP, nakoutp); + PUTSHORT(PPP_CHAP, nakoutp); + PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakoutp); + } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT - if(1) { - PUTCHAR(CILEN_SHORT, nakoutp); - PUTSHORT(PPP_PAP, nakoutp); - } else + if(1) { + PUTCHAR(CILEN_SHORT, nakoutp); + PUTSHORT(PPP_PAP, nakoutp); + } else #endif /* PAP_SUPPORT */ - {} - break; + {} + break; #if LQR_SUPPORT - case CI_QUALITY: - if (!ao->neg_lqr || - cilen != CILEN_LQR) { - orc = CONFREJ; - break; - } - - GETSHORT(cishort, p); - GETLONG(cilong, p); - - /* - * Check the protocol and the reporting period. - * XXX When should we Nak this, and what with? - */ - if (cishort != PPP_LQR) { - orc = CONFNAK; - PUTCHAR(CI_QUALITY, nakoutp); - PUTCHAR(CILEN_LQR, nakoutp); - PUTSHORT(PPP_LQR, nakoutp); - PUTLONG(ao->lqr_period, nakoutp); - break; - } - break; + case CI_QUALITY: + if (!ao->neg_lqr || + cilen != CILEN_LQR) { + orc = CONFREJ; + break; + } + + GETSHORT(cishort, p); + GETLONG(cilong, p); + + /* + * Check the protocol and the reporting period. + * XXX When should we Nak this, and what with? + */ + if (cishort != PPP_LQR) { + orc = CONFNAK; + PUTCHAR(CI_QUALITY, nakoutp); + PUTCHAR(CILEN_LQR, nakoutp); + PUTSHORT(PPP_LQR, nakoutp); + PUTLONG(ao->lqr_period, nakoutp); + break; + } + break; #endif /* LQR_SUPPORT */ - case CI_MAGICNUMBER: - if (!(ao->neg_magicnumber || go->neg_magicnumber) || - cilen != CILEN_LONG) { - orc = CONFREJ; - break; - } - GETLONG(cilong, p); - - /* - * He must have a different magic number. - */ - if (go->neg_magicnumber && - cilong == go->magicnumber) { - cilong = magic(); /* Don't put magic() inside macro! */ - orc = CONFNAK; - PUTCHAR(CI_MAGICNUMBER, nakoutp); - PUTCHAR(CILEN_LONG, nakoutp); - PUTLONG(cilong, nakoutp); - break; - } - ho->neg_magicnumber = 1; - ho->magicnumber = cilong; - break; - - - case CI_PCOMPRESSION: - if (!ao->neg_pcompression || - cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_pcompression = 1; - break; - - case CI_ACCOMPRESSION: - if (!ao->neg_accompression || - cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_accompression = 1; - break; + case CI_MAGICNUMBER: + if (!(ao->neg_magicnumber || go->neg_magicnumber) || + cilen != CILEN_LONG) { + orc = CONFREJ; + break; + } + GETLONG(cilong, p); + + /* + * He must have a different magic number. + */ + if (go->neg_magicnumber && + cilong == go->magicnumber) { + cilong = magic(); /* Don't put magic() inside macro! */ + orc = CONFNAK; + PUTCHAR(CI_MAGICNUMBER, nakoutp); + PUTCHAR(CILEN_LONG, nakoutp); + PUTLONG(cilong, nakoutp); + break; + } + ho->neg_magicnumber = 1; + ho->magicnumber = cilong; + break; + + + case CI_PCOMPRESSION: + if (!ao->neg_pcompression || + cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_pcompression = 1; + break; + + case CI_ACCOMPRESSION: + if (!ao->neg_accompression || + cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_accompression = 1; + break; #ifdef HAVE_MULTILINK - case CI_MRRU: - if (!ao->neg_mrru - || !multilink - || cilen != CILEN_SHORT) { - orc = CONFREJ; - break; - } - - GETSHORT(cishort, p); - /* possibly should insist on a minimum/maximum MRRU here */ - ho->neg_mrru = 1; - ho->mrru = cishort; - break; + case CI_MRRU: + if (!ao->neg_mrru + || !multilink + || cilen != CILEN_SHORT) { + orc = CONFREJ; + break; + } + + GETSHORT(cishort, p); + /* possibly should insist on a minimum/maximum MRRU here */ + ho->neg_mrru = 1; + ho->mrru = cishort; + break; #endif /* HAVE_MULTILINK */ - case CI_SSNHF: - if (!ao->neg_ssnhf + case CI_SSNHF: + if (!ao->neg_ssnhf #ifdef HAVE_MULTILINK - || !multilink + || !multilink #endif /* HAVE_MULTILINK */ - || cilen != CILEN_VOID) { - orc = CONFREJ; - break; - } - ho->neg_ssnhf = 1; - break; - - case CI_EPDISC: - if (!ao->neg_endpoint || - cilen < CILEN_CHAR || - cilen > CILEN_CHAR + MAX_ENDP_LEN) { - orc = CONFREJ; - break; - } - GETCHAR(cichar, p); - cilen -= CILEN_CHAR; - ho->neg_endpoint = 1; - ho->endpoint.class_ = cichar; - ho->endpoint.length = cilen; - MEMCPY(ho->endpoint.value, p, cilen); - INCPTR(cilen, p); - break; - - default: - LCPDEBUG(("lcp_reqci: rcvd unknown option %d", citype)); - orc = CONFREJ; - break; - } + || cilen != CILEN_VOID) { + orc = CONFREJ; + break; + } + ho->neg_ssnhf = 1; + break; + + case CI_EPDISC: + if (!ao->neg_endpoint || + cilen < CILEN_CHAR || + cilen > CILEN_CHAR + MAX_ENDP_LEN) { + orc = CONFREJ; + break; + } + GETCHAR(cichar, p); + cilen -= CILEN_CHAR; + ho->neg_endpoint = 1; + ho->endpoint.class_ = cichar; + ho->endpoint.length = cilen; + MEMCPY(ho->endpoint.value, p, cilen); + INCPTR(cilen, p); + break; + + default: + LCPDEBUG(("lcp_reqci: rcvd unknown option %d", citype)); + orc = CONFREJ; + break; + } endswitch: - if (orc == CONFACK && /* Good CI */ - rc != CONFACK) /* but prior CI wasnt? */ - continue; /* Don't send this one */ - - if (orc == CONFNAK) { /* Nak this CI? */ - if (reject_if_disagree /* Getting fed up with sending NAKs? */ - && citype != CI_MAGICNUMBER) { - orc = CONFREJ; /* Get tough if so */ - } else { - if (rc == CONFREJ) /* Rejecting prior CI? */ - continue; /* Don't send this one */ - rc = CONFNAK; - } - } - if (orc == CONFREJ) { /* Reject this CI */ - rc = CONFREJ; - if (cip != rejp) /* Need to move rejected CI? */ - MEMCPY(rejp, cip, cilen); /* Move it */ - INCPTR(cilen, rejp); /* Update output pointer */ - } + if (orc == CONFACK && /* Good CI */ + rc != CONFACK) /* but prior CI wasnt? */ + continue; /* Don't send this one */ + + if (orc == CONFNAK) { /* Nak this CI? */ + if (reject_if_disagree /* Getting fed up with sending NAKs? */ + && citype != CI_MAGICNUMBER) { + orc = CONFREJ; /* Get tough if so */ + } else { + if (rc == CONFREJ) /* Rejecting prior CI? */ + continue; /* Don't send this one */ + rc = CONFNAK; + } + } + if (orc == CONFREJ) { /* Reject this CI */ + rc = CONFREJ; + if (cip != rejp) /* Need to move rejected CI? */ + MEMCPY(rejp, cip, cilen); /* Move it */ + INCPTR(cilen, rejp); /* Update output pointer */ + } } /* @@ -2262,25 +2262,25 @@ endswitch: switch (rc) { case CONFACK: - *lenp = next - inp; - break; + *lenp = next - inp; + break; case CONFNAK: - /* - * Copy the Nak'd options from the nak buffer to the caller's buffer. - */ - *lenp = nakoutp - (u_char*)nakp->payload; - MEMCPY(inp, nakp->payload, *lenp); - break; + /* + * Copy the Nak'd options from the nak buffer to the caller's buffer. + */ + *lenp = nakoutp - (u_char*)nakp->payload; + MEMCPY(inp, nakp->payload, *lenp); + break; case CONFREJ: - *lenp = rejp - inp; - break; + *lenp = rejp - inp; + break; default: - break; + break; } pbuf_free(nakp); LCPDEBUG(("lcp_reqci: returning CONF%s.", CODENAME(rc))); - return (rc); /* Return final code */ + return (rc); /* Return final code */ } @@ -2296,9 +2296,9 @@ static void lcp_up(fsm *f) { int mtu, mru; if (!go->neg_magicnumber) - go->magicnumber = 0; + go->magicnumber = 0; if (!ho->neg_magicnumber) - ho->magicnumber = 0; + ho->magicnumber = 0; /* * Set our MTU to the smaller of the MTU we wanted and @@ -2314,16 +2314,16 @@ static void lcp_up(fsm *f) { #ifdef HAVE_MULTILINK if (!(multilink && go->neg_mrru && ho->neg_mrru)) #endif /* HAVE_MULTILINK */ - netif_set_mtu(pcb, LWIP_MIN(LWIP_MIN(mtu, mru), ao->mru)); + netif_set_mtu(pcb, LWIP_MIN(LWIP_MIN(mtu, mru), ao->mru)); ppp_send_config(pcb, mtu, - (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), - ho->neg_pcompression, ho->neg_accompression); + (ho->neg_asyncmap? ho->asyncmap: 0xffffffff), + ho->neg_pcompression, ho->neg_accompression); ppp_recv_config(pcb, mru, - (pcb->settings.lax_recv? 0: go->neg_asyncmap? go->asyncmap: 0xffffffff), - go->neg_pcompression, go->neg_accompression); + (pcb->settings.lax_recv? 0: go->neg_asyncmap? go->asyncmap: 0xffffffff), + go->neg_pcompression, go->neg_accompression); if (ho->neg_mru) - pcb->peer_mru = ho->mru; + pcb->peer_mru = ho->mru; lcp_echo_lowerup(f->pcb); /* Enable echo messages */ @@ -2346,8 +2346,8 @@ static void lcp_down(fsm *f) { ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0); ppp_recv_config(pcb, PPP_MRU, - (go->neg_asyncmap? go->asyncmap: 0xffffffff), - go->neg_pcompression, go->neg_accompression); + (go->neg_asyncmap? go->asyncmap: 0xffffffff), + go->neg_pcompression, go->neg_accompression); pcb->peer_mru = PPP_MRU; } @@ -2382,25 +2382,25 @@ static const char* const lcp_codenames[] = { }; static int lcp_printpkt(const u_char *p, int plen, - void (*printer) (void *, const char *, ...), void *arg) { + void (*printer) (void *, const char *, ...), void *arg) { int code, id, len, olen, i; const u_char *pstart, *optend; u_short cishort; u32_t cilong; if (plen < HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(lcp_codenames)) - printer(arg, " %s", lcp_codenames[code-1]); + printer(arg, " %s", lcp_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { @@ -2408,224 +2408,224 @@ static int lcp_printpkt(const u_char *p, int plen, case CONFACK: case CONFNAK: case CONFREJ: - /* print option list */ - while (len >= 2) { - GETCHAR(code, p); - GETCHAR(olen, p); - p -= 2; - if (olen < 2 || olen > len) { - break; - } - printer(arg, " <"); - len -= olen; - optend = p + olen; - switch (code) { - case CI_MRU: - if (olen == CILEN_SHORT) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "mru %d", cishort); - } - break; - case CI_ASYNCMAP: - if (olen == CILEN_LONG) { - p += 2; - GETLONG(cilong, p); - printer(arg, "asyncmap 0x%x", cilong); - } - break; - case CI_AUTHTYPE: - if (olen >= CILEN_SHORT) { - p += 2; - printer(arg, "auth "); - GETSHORT(cishort, p); - switch (cishort) { + /* print option list */ + while (len >= 2) { + GETCHAR(code, p); + GETCHAR(olen, p); + p -= 2; + if (olen < 2 || olen > len) { + break; + } + printer(arg, " <"); + len -= olen; + optend = p + olen; + switch (code) { + case CI_MRU: + if (olen == CILEN_SHORT) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "mru %d", cishort); + } + break; + case CI_ASYNCMAP: + if (olen == CILEN_LONG) { + p += 2; + GETLONG(cilong, p); + printer(arg, "asyncmap 0x%x", cilong); + } + break; + case CI_AUTHTYPE: + if (olen >= CILEN_SHORT) { + p += 2; + printer(arg, "auth "); + GETSHORT(cishort, p); + switch (cishort) { #if PAP_SUPPORT - case PPP_PAP: - printer(arg, "pap"); - break; + case PPP_PAP: + printer(arg, "pap"); + break; #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT - case PPP_CHAP: - printer(arg, "chap"); - if (p < optend) { - switch (*p) { - case CHAP_MD5: - printer(arg, " MD5"); - ++p; - break; + case PPP_CHAP: + printer(arg, "chap"); + if (p < optend) { + switch (*p) { + case CHAP_MD5: + printer(arg, " MD5"); + ++p; + break; #if MSCHAP_SUPPORT - case CHAP_MICROSOFT: - printer(arg, " MS"); - ++p; - break; - - case CHAP_MICROSOFT_V2: - printer(arg, " MS-v2"); - ++p; - break; + case CHAP_MICROSOFT: + printer(arg, " MS"); + ++p; + break; + + case CHAP_MICROSOFT_V2: + printer(arg, " MS-v2"); + ++p; + break; #endif /* MSCHAP_SUPPORT */ - default: - break; - } - } - break; + default: + break; + } + } + break; #endif /* CHAP_SUPPORT */ #if EAP_SUPPORT - case PPP_EAP: - printer(arg, "eap"); - break; + case PPP_EAP: + printer(arg, "eap"); + break; #endif /* EAP_SUPPORT */ - default: - printer(arg, "0x%x", cishort); - } - } - break; + default: + printer(arg, "0x%x", cishort); + } + } + break; #if LQR_SUPPORT - case CI_QUALITY: - if (olen >= CILEN_SHORT) { - p += 2; - printer(arg, "quality "); - GETSHORT(cishort, p); - switch (cishort) { - case PPP_LQR: - printer(arg, "lqr"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; + case CI_QUALITY: + if (olen >= CILEN_SHORT) { + p += 2; + printer(arg, "quality "); + GETSHORT(cishort, p); + switch (cishort) { + case PPP_LQR: + printer(arg, "lqr"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; #endif /* LQR_SUPPORT */ - case CI_CALLBACK: - if (olen >= CILEN_CHAR) { - p += 2; - printer(arg, "callback "); - GETCHAR(cishort, p); - switch (cishort) { - case CBCP_OPT: - printer(arg, "CBCP"); - break; - default: - printer(arg, "0x%x", cishort); - } - } - break; - case CI_MAGICNUMBER: - if (olen == CILEN_LONG) { - p += 2; - GETLONG(cilong, p); - printer(arg, "magic 0x%x", cilong); - } - break; - case CI_PCOMPRESSION: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "pcomp"); - } - break; - case CI_ACCOMPRESSION: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "accomp"); - } - break; - case CI_MRRU: - if (olen == CILEN_SHORT) { - p += 2; - GETSHORT(cishort, p); - printer(arg, "mrru %d", cishort); - } - break; - case CI_SSNHF: - if (olen == CILEN_VOID) { - p += 2; - printer(arg, "ssnhf"); - } - break; - case CI_EPDISC: + case CI_CALLBACK: + if (olen >= CILEN_CHAR) { + p += 2; + printer(arg, "callback "); + GETCHAR(cishort, p); + switch (cishort) { + case CBCP_OPT: + printer(arg, "CBCP"); + break; + default: + printer(arg, "0x%x", cishort); + } + } + break; + case CI_MAGICNUMBER: + if (olen == CILEN_LONG) { + p += 2; + GETLONG(cilong, p); + printer(arg, "magic 0x%x", cilong); + } + break; + case CI_PCOMPRESSION: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "pcomp"); + } + break; + case CI_ACCOMPRESSION: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "accomp"); + } + break; + case CI_MRRU: + if (olen == CILEN_SHORT) { + p += 2; + GETSHORT(cishort, p); + printer(arg, "mrru %d", cishort); + } + break; + case CI_SSNHF: + if (olen == CILEN_VOID) { + p += 2; + printer(arg, "ssnhf"); + } + break; + case CI_EPDISC: #ifdef HAVE_MULTILINK - if (olen >= CILEN_CHAR) { - struct epdisc epd; - p += 2; - GETCHAR(epd.class, p); - epd.length = olen - CILEN_CHAR; - if (epd.length > MAX_ENDP_LEN) - epd.length = MAX_ENDP_LEN; - if (epd.length > 0) { - MEMCPY(epd.value, p, epd.length); - p += epd.length; - } - printer(arg, "endpoint [%s]", epdisc_to_str(&epd)); - } + if (olen >= CILEN_CHAR) { + struct epdisc epd; + p += 2; + GETCHAR(epd.class, p); + epd.length = olen - CILEN_CHAR; + if (epd.length > MAX_ENDP_LEN) + epd.length = MAX_ENDP_LEN; + if (epd.length > 0) { + MEMCPY(epd.value, p, epd.length); + p += epd.length; + } + printer(arg, "endpoint [%s]", epdisc_to_str(&epd)); + } #else - printer(arg, "endpoint"); + printer(arg, "endpoint"); #endif - break; - default: - break; - } - while (p < optend) { - GETCHAR(code, p); - printer(arg, " %.2x", code); - } - printer(arg, ">"); - } - break; + break; + default: + break; + } + while (p < optend) { + GETCHAR(code, p); + printer(arg, " %.2x", code); + } + printer(arg, ">"); + } + break; case TERMACK: case TERMREQ: - if (len > 0 && *p >= ' ' && *p < 0x7f) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len > 0 && *p >= ' ' && *p < 0x7f) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; case ECHOREQ: case ECHOREP: case DISCREQ: - if (len >= 4) { - GETLONG(cilong, p); - printer(arg, " magic=0x%x", cilong); - len -= 4; - } - break; + if (len >= 4) { + GETLONG(cilong, p); + printer(arg, " magic=0x%x", cilong); + len -= 4; + } + break; case IDENTIF: case TIMEREM: - if (len >= 4) { - GETLONG(cilong, p); - printer(arg, " magic=0x%x", cilong); - len -= 4; - } - if (code == TIMEREM) { - if (len < 4) - break; - GETLONG(cilong, p); - printer(arg, " seconds=%u", cilong); - len -= 4; - } - if (len > 0) { - printer(arg, " "); - ppp_print_string(p, len, printer, arg); - p += len; - len = 0; - } - break; + if (len >= 4) { + GETLONG(cilong, p); + printer(arg, " magic=0x%x", cilong); + len -= 4; + } + if (code == TIMEREM) { + if (len < 4) + break; + GETLONG(cilong, p); + printer(arg, " seconds=%u", cilong); + len -= 4; + } + if (len > 0) { + printer(arg, " "); + ppp_print_string(p, len, printer, arg); + p += len; + len = 0; + } + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (i = 0; i < len && i < 32; ++i) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } if (i < len) { - printer(arg, " ..."); - p += len - i; + printer(arg, " ..."); + p += len - i; } return p - pstart; @@ -2639,10 +2639,10 @@ static int lcp_printpkt(const u_char *p, int plen, static void LcpLinkFailure(fsm *f) { ppp_pcb *pcb = f->pcb; if (f->state == PPP_FSM_OPENED) { - ppp_info("No response to %d echo-requests", pcb->lcp_echos_pending); + ppp_info("No response to %d echo-requests", pcb->lcp_echos_pending); ppp_notice("Serial link appears to be disconnected."); - pcb->err_code = PPPERR_PEERDEAD; - lcp_close(pcb, "Peer not responding"); + pcb->err_code = PPPERR_PEERDEAD; + lcp_close(pcb, "Peer not responding"); } } @@ -2655,13 +2655,13 @@ static void LcpEchoCheck(fsm *f) { LcpSendEchoRequest (f); if (f->state != PPP_FSM_OPENED) - return; + return; /* * Start the timer for the next interval. */ if (pcb->lcp_echo_timer_running) - ppp_warn("assertion lcp_echo_timer_running==0 failed"); + ppp_warn("assertion lcp_echo_timer_running==0 failed"); TIMEOUT (LcpEchoTimeout, f, pcb->settings.lcp_echo_interval); pcb->lcp_echo_timer_running = 1; } @@ -2691,14 +2691,14 @@ static void lcp_received_echo_reply(fsm *f, int id, u_char *inp, int len) { /* Check the magic number - don't count replies from ourselves. */ if (len < 4) { - ppp_dbglog("lcp: received short Echo-Reply, length %d", len); - return; + ppp_dbglog("lcp: received short Echo-Reply, length %d", len); + return; } GETLONG(magic_val, inp); if (go->neg_magicnumber - && magic_val == go->magicnumber) { - ppp_warn("appear to have received our own echo-reply!"); - return; + && magic_val == go->magicnumber) { + ppp_warn("appear to have received our own echo-reply!"); + return; } /* Reset the number of outstanding echo frames */ @@ -2722,7 +2722,7 @@ static void LcpSendEchoRequest(fsm *f) { if (pcb->lcp_echos_pending >= pcb->settings.lcp_echo_fails) { LcpLinkFailure(f); pcb->lcp_echos_pending = 0; - } + } } #if PPP_LCP_ADAPTIVE @@ -2731,17 +2731,17 @@ static void LcpSendEchoRequest(fsm *f) { * no traffic was received since the last one. */ if (pcb->settings.lcp_echo_adaptive) { - static unsigned int last_pkts_in = 0; + static unsigned int last_pkts_in = 0; #if PPP_STATS_SUPPORT - update_link_stats(f->unit); - link_stats_valid = 0; + update_link_stats(f->unit); + link_stats_valid = 0; #endif /* PPP_STATS_SUPPORT */ - if (link_stats.pkts_in != last_pkts_in) { - last_pkts_in = link_stats.pkts_in; - return; - } + if (link_stats.pkts_in != last_pkts_in) { + last_pkts_in = link_stats.pkts_in; + return; + } } #endif @@ -2750,10 +2750,10 @@ static void LcpSendEchoRequest(fsm *f) { */ if (f->state == PPP_FSM_OPENED) { lcp_magic = go->magicnumber; - pktp = pkt; - PUTLONG(lcp_magic, pktp); + pktp = pkt; + PUTLONG(lcp_magic, pktp); fsm_sdata(f, ECHOREQ, pcb->lcp_echo_number++, pkt, pktp - pkt); - ++pcb->lcp_echos_pending; + ++pcb->lcp_echos_pending; } } @@ -2768,7 +2768,7 @@ static void lcp_echo_lowerup(ppp_pcb *pcb) { pcb->lcp_echos_pending = 0; pcb->lcp_echo_number = 0; pcb->lcp_echo_timer_running = 0; - + /* If a timeout interval is specified then start the timer */ if (pcb->settings.lcp_echo_interval != 0) LcpEchoCheck (f); diff --git a/components/net/lwip-2.1.2/src/netif/ppp/mppe.c b/components/net/lwip-2.1.2/src/netif/ppp/mppe.c index 4cca89dec1..6e9ffe674e 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/mppe.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/mppe.c @@ -39,20 +39,20 @@ #define SHA1_SIGNATURE_SIZE 20 /* ppp_mppe_state.bits definitions */ -#define MPPE_BIT_A 0x80 /* Encryption table were (re)inititalized */ -#define MPPE_BIT_B 0x40 /* MPPC only (not implemented) */ -#define MPPE_BIT_C 0x20 /* MPPC only (not implemented) */ -#define MPPE_BIT_D 0x10 /* This is an encrypted frame */ +#define MPPE_BIT_A 0x80 /* Encryption table were (re)inititalized */ +#define MPPE_BIT_B 0x40 /* MPPC only (not implemented) */ +#define MPPE_BIT_C 0x20 /* MPPC only (not implemented) */ +#define MPPE_BIT_D 0x10 /* This is an encrypted frame */ -#define MPPE_BIT_FLUSHED MPPE_BIT_A -#define MPPE_BIT_ENCRYPTED MPPE_BIT_D +#define MPPE_BIT_FLUSHED MPPE_BIT_A +#define MPPE_BIT_ENCRYPTED MPPE_BIT_D #define MPPE_BITS(p) ((p)[0] & 0xf0) #define MPPE_CCOUNT(p) ((((p)[0] & 0x0f) << 8) + (p)[1]) -#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */ +#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */ -#define MPPE_OVHD 2 /* MPPE overhead/packet */ -#define SANITY_MAX 1600 /* Max bogon factor we will tolerate */ +#define MPPE_OVHD 2 /* MPPE overhead/packet */ +#define SANITY_MAX 1600 /* Max bogon factor we will tolerate */ /* * Perform the MPPE rekey algorithm, from RFC 3078, sec. 7.3. @@ -60,37 +60,37 @@ */ static void mppe_rekey(ppp_mppe_state * state, int initial_key) { - lwip_sha1_context sha1_ctx; - u8_t sha1_digest[SHA1_SIGNATURE_SIZE]; - - /* - * Key Derivation, from RFC 3078, RFC 3079. - * Equivalent to Get_Key() for MS-CHAP as described in RFC 3079. - */ - lwip_sha1_init(&sha1_ctx); - lwip_sha1_starts(&sha1_ctx); - lwip_sha1_update(&sha1_ctx, state->master_key, state->keylen); - lwip_sha1_update(&sha1_ctx, mppe_sha1_pad1, SHA1_PAD_SIZE); - lwip_sha1_update(&sha1_ctx, state->session_key, state->keylen); - lwip_sha1_update(&sha1_ctx, mppe_sha1_pad2, SHA1_PAD_SIZE); - lwip_sha1_finish(&sha1_ctx, sha1_digest); - lwip_sha1_free(&sha1_ctx); - MEMCPY(state->session_key, sha1_digest, state->keylen); - - if (!initial_key) { - lwip_arc4_init(&state->arc4); - lwip_arc4_setup(&state->arc4, sha1_digest, state->keylen); - lwip_arc4_crypt(&state->arc4, state->session_key, state->keylen); - lwip_arc4_free(&state->arc4); - } - if (state->keylen == 8) { - /* See RFC 3078 */ - state->session_key[0] = 0xd1; - state->session_key[1] = 0x26; - state->session_key[2] = 0x9e; - } - lwip_arc4_init(&state->arc4); - lwip_arc4_setup(&state->arc4, state->session_key, state->keylen); + lwip_sha1_context sha1_ctx; + u8_t sha1_digest[SHA1_SIGNATURE_SIZE]; + + /* + * Key Derivation, from RFC 3078, RFC 3079. + * Equivalent to Get_Key() for MS-CHAP as described in RFC 3079. + */ + lwip_sha1_init(&sha1_ctx); + lwip_sha1_starts(&sha1_ctx); + lwip_sha1_update(&sha1_ctx, state->master_key, state->keylen); + lwip_sha1_update(&sha1_ctx, mppe_sha1_pad1, SHA1_PAD_SIZE); + lwip_sha1_update(&sha1_ctx, state->session_key, state->keylen); + lwip_sha1_update(&sha1_ctx, mppe_sha1_pad2, SHA1_PAD_SIZE); + lwip_sha1_finish(&sha1_ctx, sha1_digest); + lwip_sha1_free(&sha1_ctx); + MEMCPY(state->session_key, sha1_digest, state->keylen); + + if (!initial_key) { + lwip_arc4_init(&state->arc4); + lwip_arc4_setup(&state->arc4, sha1_digest, state->keylen); + lwip_arc4_crypt(&state->arc4, state->session_key, state->keylen); + lwip_arc4_free(&state->arc4); + } + if (state->keylen == 8) { + /* See RFC 3078 */ + state->session_key[0] = 0xd1; + state->session_key[1] = 0x26; + state->session_key[2] = 0x9e; + } + lwip_arc4_init(&state->arc4); + lwip_arc4_setup(&state->arc4, state->session_key, state->keylen); } /* @@ -98,8 +98,8 @@ static void mppe_rekey(ppp_mppe_state * state, int initial_key) * don't have to keep multiple copies of keys. */ void mppe_set_key(ppp_pcb *pcb, ppp_mppe_state *state, u8_t *key) { - LWIP_UNUSED_ARG(pcb); - MEMCPY(state->master_key, key, MPPE_MAX_KEY_LEN); + LWIP_UNUSED_ARG(pcb); + MEMCPY(state->master_key, key, MPPE_MAX_KEY_LEN); } /* @@ -109,64 +109,64 @@ void mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) { #if PPP_DEBUG - const u8_t *debugstr = (const u8_t*)"mppe_comp_init"; - if (&pcb->mppe_decomp == state) { - debugstr = (const u8_t*)"mppe_decomp_init"; - } + const u8_t *debugstr = (const u8_t*)"mppe_comp_init"; + if (&pcb->mppe_decomp == state) { + debugstr = (const u8_t*)"mppe_decomp_init"; + } #endif /* PPP_DEBUG */ - /* Save keys. */ - MEMCPY(state->session_key, state->master_key, sizeof(state->master_key)); - - if (options & MPPE_OPT_128) - state->keylen = 16; - else if (options & MPPE_OPT_40) - state->keylen = 8; - else { - PPPDEBUG(LOG_DEBUG, ("%s[%d]: unknown key length\n", debugstr, - pcb->netif->num)); - lcp_close(pcb, "MPPE required but peer negotiation failed"); - return; - } - if (options & MPPE_OPT_STATEFUL) - state->stateful = 1; - - /* Generate the initial session key. */ - mppe_rekey(state, 1); + /* Save keys. */ + MEMCPY(state->session_key, state->master_key, sizeof(state->master_key)); + + if (options & MPPE_OPT_128) + state->keylen = 16; + else if (options & MPPE_OPT_40) + state->keylen = 8; + else { + PPPDEBUG(LOG_DEBUG, ("%s[%d]: unknown key length\n", debugstr, + pcb->netif->num)); + lcp_close(pcb, "MPPE required but peer negotiation failed"); + return; + } + if (options & MPPE_OPT_STATEFUL) + state->stateful = 1; + + /* Generate the initial session key. */ + mppe_rekey(state, 1); #if PPP_DEBUG - { - int i; - char mkey[sizeof(state->master_key) * 2 + 1]; - char skey[sizeof(state->session_key) * 2 + 1]; - - PPPDEBUG(LOG_DEBUG, ("%s[%d]: initialized with %d-bit %s mode\n", - debugstr, pcb->netif->num, (state->keylen == 16) ? 128 : 40, - (state->stateful) ? "stateful" : "stateless")); - - for (i = 0; i < (int)sizeof(state->master_key); i++) - sprintf(mkey + i * 2, "%02x", state->master_key[i]); - for (i = 0; i < (int)sizeof(state->session_key); i++) - sprintf(skey + i * 2, "%02x", state->session_key[i]); - PPPDEBUG(LOG_DEBUG, - ("%s[%d]: keys: master: %s initial session: %s\n", - debugstr, pcb->netif->num, mkey, skey)); - } + { + int i; + char mkey[sizeof(state->master_key) * 2 + 1]; + char skey[sizeof(state->session_key) * 2 + 1]; + + PPPDEBUG(LOG_DEBUG, ("%s[%d]: initialized with %d-bit %s mode\n", + debugstr, pcb->netif->num, (state->keylen == 16) ? 128 : 40, + (state->stateful) ? "stateful" : "stateless")); + + for (i = 0; i < (int)sizeof(state->master_key); i++) + sprintf(mkey + i * 2, "%02x", state->master_key[i]); + for (i = 0; i < (int)sizeof(state->session_key); i++) + sprintf(skey + i * 2, "%02x", state->session_key[i]); + PPPDEBUG(LOG_DEBUG, + ("%s[%d]: keys: master: %s initial session: %s\n", + debugstr, pcb->netif->num, mkey, skey)); + } #endif /* PPP_DEBUG */ - /* - * Initialize the coherency count. The initial value is not specified - * in RFC 3078, but we can make a reasonable assumption that it will - * start at 0. Setting it to the max here makes the comp/decomp code - * do the right thing (determined through experiment). - */ - state->ccount = MPPE_CCOUNT_SPACE - 1; - - /* - * Note that even though we have initialized the key table, we don't - * set the FLUSHED bit. This is contrary to RFC 3078, sec. 3.1. - */ - state->bits = MPPE_BIT_ENCRYPTED; + /* + * Initialize the coherency count. The initial value is not specified + * in RFC 3078, but we can make a reasonable assumption that it will + * start at 0. Setting it to the max here makes the comp/decomp code + * do the right thing (determined through experiment). + */ + state->ccount = MPPE_CCOUNT_SPACE - 1; + + /* + * Note that even though we have initialized the key table, we don't + * set the FLUSHED bit. This is contrary to RFC 3078, sec. 3.1. + */ + state->bits = MPPE_BIT_ENCRYPTED; } /* @@ -180,8 +180,8 @@ mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) */ void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state) { - LWIP_UNUSED_ARG(pcb); - state->bits |= MPPE_BIT_FLUSHED; + LWIP_UNUSED_ARG(pcb); + state->bits |= MPPE_BIT_FLUSHED; } /* @@ -192,74 +192,74 @@ void mppe_comp_reset(ppp_pcb *pcb, ppp_mppe_state *state) err_t mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t protocol) { - struct pbuf *n, *np; - u8_t *pl; - err_t err; - - LWIP_UNUSED_ARG(pcb); - - /* TCP stack requires that we don't change the packet payload, therefore we copy - * the whole packet before encryption. - */ - np = pbuf_alloc(PBUF_RAW, MPPE_OVHD + sizeof(protocol) + (*pb)->tot_len, PBUF_RAM); - if (!np) { - return ERR_MEM; - } - - /* Hide MPPE header + protocol */ - pbuf_remove_header(np, MPPE_OVHD + sizeof(protocol)); - - if ((err = pbuf_copy(np, *pb)) != ERR_OK) { - pbuf_free(np); - return err; - } - - /* Reveal MPPE header + protocol */ - pbuf_add_header(np, MPPE_OVHD + sizeof(protocol)); - - *pb = np; - pl = (u8_t*)np->payload; - - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; - PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", pcb->netif->num, state->ccount)); - /* FIXME: use PUT* macros */ - pl[0] = state->ccount>>8; - pl[1] = state->ccount; - - if (!state->stateful || /* stateless mode */ - ((state->ccount & 0xff) == 0xff) || /* "flag" packet */ - (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */ - /* We must rekey */ - if (state->stateful) { - PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: rekeying\n", pcb->netif->num)); - } - mppe_rekey(state, 0); - state->bits |= MPPE_BIT_FLUSHED; - } - pl[0] |= state->bits; - state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */ - pl += MPPE_OVHD; - - /* Add protocol */ - /* FIXME: add PFC support */ - pl[0] = protocol >> 8; - pl[1] = protocol; - - /* Hide MPPE header */ - pbuf_remove_header(np, MPPE_OVHD); - - /* Encrypt packet */ - for (n = np; n != NULL; n = n->next) { - lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); - if (n->tot_len == n->len) { - break; - } - } - - /* Reveal MPPE header */ - pbuf_add_header(np, MPPE_OVHD); - - return ERR_OK; + struct pbuf *n, *np; + u8_t *pl; + err_t err; + + LWIP_UNUSED_ARG(pcb); + + /* TCP stack requires that we don't change the packet payload, therefore we copy + * the whole packet before encryption. + */ + np = pbuf_alloc(PBUF_RAW, MPPE_OVHD + sizeof(protocol) + (*pb)->tot_len, PBUF_RAM); + if (!np) { + return ERR_MEM; + } + + /* Hide MPPE header + protocol */ + pbuf_remove_header(np, MPPE_OVHD + sizeof(protocol)); + + if ((err = pbuf_copy(np, *pb)) != ERR_OK) { + pbuf_free(np); + return err; + } + + /* Reveal MPPE header + protocol */ + pbuf_add_header(np, MPPE_OVHD + sizeof(protocol)); + + *pb = np; + pl = (u8_t*)np->payload; + + state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; + PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", pcb->netif->num, state->ccount)); + /* FIXME: use PUT* macros */ + pl[0] = state->ccount>>8; + pl[1] = state->ccount; + + if (!state->stateful || /* stateless mode */ + ((state->ccount & 0xff) == 0xff) || /* "flag" packet */ + (state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */ + /* We must rekey */ + if (state->stateful) { + PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: rekeying\n", pcb->netif->num)); + } + mppe_rekey(state, 0); + state->bits |= MPPE_BIT_FLUSHED; + } + pl[0] |= state->bits; + state->bits &= ~MPPE_BIT_FLUSHED; /* reset for next xmit */ + pl += MPPE_OVHD; + + /* Add protocol */ + /* FIXME: add PFC support */ + pl[0] = protocol >> 8; + pl[1] = protocol; + + /* Hide MPPE header */ + pbuf_remove_header(np, MPPE_OVHD); + + /* Encrypt packet */ + for (n = np; n != NULL; n = n->next) { + lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); + if (n->tot_len == n->len) { + break; + } + } + + /* Reveal MPPE header */ + pbuf_add_header(np, MPPE_OVHD); + + return ERR_OK; } /* @@ -267,9 +267,9 @@ mppe_compress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb, u16_t proto */ void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state) { - LWIP_UNUSED_ARG(pcb); - LWIP_UNUSED_ARG(state); - return; + LWIP_UNUSED_ARG(pcb); + LWIP_UNUSED_ARG(state); + return; } /* @@ -278,135 +278,135 @@ void mppe_decomp_reset(ppp_pcb *pcb, ppp_mppe_state *state) err_t mppe_decompress(ppp_pcb *pcb, ppp_mppe_state *state, struct pbuf **pb) { - struct pbuf *n0 = *pb, *n; - u8_t *pl; - u16_t ccount; - u8_t flushed; - - /* MPPE Header */ - if (n0->len < MPPE_OVHD) { - PPPDEBUG(LOG_DEBUG, - ("mppe_decompress[%d]: short pkt (%d)\n", - pcb->netif->num, n0->len)); - state->sanity_errors += 100; - goto sanity_error; - } - - pl = (u8_t*)n0->payload; - flushed = MPPE_BITS(pl) & MPPE_BIT_FLUSHED; - ccount = MPPE_CCOUNT(pl); - PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n", - pcb->netif->num, ccount)); - - /* sanity checks -- terminate with extreme prejudice */ - if (!(MPPE_BITS(pl) & MPPE_BIT_ENCRYPTED)) { - PPPDEBUG(LOG_DEBUG, - ("mppe_decompress[%d]: ENCRYPTED bit not set!\n", - pcb->netif->num)); - state->sanity_errors += 100; - goto sanity_error; - } - if (!state->stateful && !flushed) { - PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in " - "stateless mode!\n", pcb->netif->num)); - state->sanity_errors += 100; - goto sanity_error; - } - if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { - PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on " - "flag packet!\n", pcb->netif->num)); - state->sanity_errors += 100; - goto sanity_error; - } - - /* - * Check the coherency count. - */ - - if (!state->stateful) { - /* Discard late packet */ - if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE > MPPE_CCOUNT_SPACE / 2) { - state->sanity_errors++; - goto sanity_error; - } - - /* RFC 3078, sec 8.1. Rekey for every packet. */ - while (state->ccount != ccount) { - mppe_rekey(state, 0); - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; - } - } else { - /* RFC 3078, sec 8.2. */ - if (!state->discard) { - /* normal state */ - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; - if (ccount != state->ccount) { - /* - * (ccount > state->ccount) - * Packet loss detected, enter the discard state. - * Signal the peer to rekey (by sending a CCP Reset-Request). - */ - state->discard = 1; - ccp_resetrequest(pcb); - return ERR_BUF; - } - } else { - /* discard state */ - if (!flushed) { - /* ccp.c will be silent (no additional CCP Reset-Requests). */ - return ERR_BUF; - } else { - /* Rekey for every missed "flag" packet. */ - while ((ccount & ~0xff) != - (state->ccount & ~0xff)) { - mppe_rekey(state, 0); - state->ccount = - (state->ccount + - 256) % MPPE_CCOUNT_SPACE; - } - - /* reset */ - state->discard = 0; - state->ccount = ccount; - /* - * Another problem with RFC 3078 here. It implies that the - * peer need not send a Reset-Ack packet. But RFC 1962 - * requires it. Hopefully, M$ does send a Reset-Ack; even - * though it isn't required for MPPE synchronization, it is - * required to reset CCP state. - */ - } - } - if (flushed) - mppe_rekey(state, 0); - } - - /* Hide MPPE header */ - pbuf_remove_header(n0, MPPE_OVHD); - - /* Decrypt the packet. */ - for (n = n0; n != NULL; n = n->next) { - lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); - if (n->tot_len == n->len) { - break; - } - } - - /* good packet credit */ - state->sanity_errors >>= 1; - - return ERR_OK; + struct pbuf *n0 = *pb, *n; + u8_t *pl; + u16_t ccount; + u8_t flushed; + + /* MPPE Header */ + if (n0->len < MPPE_OVHD) { + PPPDEBUG(LOG_DEBUG, + ("mppe_decompress[%d]: short pkt (%d)\n", + pcb->netif->num, n0->len)); + state->sanity_errors += 100; + goto sanity_error; + } + + pl = (u8_t*)n0->payload; + flushed = MPPE_BITS(pl) & MPPE_BIT_FLUSHED; + ccount = MPPE_CCOUNT(pl); + PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n", + pcb->netif->num, ccount)); + + /* sanity checks -- terminate with extreme prejudice */ + if (!(MPPE_BITS(pl) & MPPE_BIT_ENCRYPTED)) { + PPPDEBUG(LOG_DEBUG, + ("mppe_decompress[%d]: ENCRYPTED bit not set!\n", + pcb->netif->num)); + state->sanity_errors += 100; + goto sanity_error; + } + if (!state->stateful && !flushed) { + PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in " + "stateless mode!\n", pcb->netif->num)); + state->sanity_errors += 100; + goto sanity_error; + } + if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) { + PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on " + "flag packet!\n", pcb->netif->num)); + state->sanity_errors += 100; + goto sanity_error; + } + + /* + * Check the coherency count. + */ + + if (!state->stateful) { + /* Discard late packet */ + if ((ccount - state->ccount) % MPPE_CCOUNT_SPACE > MPPE_CCOUNT_SPACE / 2) { + state->sanity_errors++; + goto sanity_error; + } + + /* RFC 3078, sec 8.1. Rekey for every packet. */ + while (state->ccount != ccount) { + mppe_rekey(state, 0); + state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; + } + } else { + /* RFC 3078, sec 8.2. */ + if (!state->discard) { + /* normal state */ + state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; + if (ccount != state->ccount) { + /* + * (ccount > state->ccount) + * Packet loss detected, enter the discard state. + * Signal the peer to rekey (by sending a CCP Reset-Request). + */ + state->discard = 1; + ccp_resetrequest(pcb); + return ERR_BUF; + } + } else { + /* discard state */ + if (!flushed) { + /* ccp.c will be silent (no additional CCP Reset-Requests). */ + return ERR_BUF; + } else { + /* Rekey for every missed "flag" packet. */ + while ((ccount & ~0xff) != + (state->ccount & ~0xff)) { + mppe_rekey(state, 0); + state->ccount = + (state->ccount + + 256) % MPPE_CCOUNT_SPACE; + } + + /* reset */ + state->discard = 0; + state->ccount = ccount; + /* + * Another problem with RFC 3078 here. It implies that the + * peer need not send a Reset-Ack packet. But RFC 1962 + * requires it. Hopefully, M$ does send a Reset-Ack; even + * though it isn't required for MPPE synchronization, it is + * required to reset CCP state. + */ + } + } + if (flushed) + mppe_rekey(state, 0); + } + + /* Hide MPPE header */ + pbuf_remove_header(n0, MPPE_OVHD); + + /* Decrypt the packet. */ + for (n = n0; n != NULL; n = n->next) { + lwip_arc4_crypt(&state->arc4, (u8_t*)n->payload, n->len); + if (n->tot_len == n->len) { + break; + } + } + + /* good packet credit */ + state->sanity_errors >>= 1; + + return ERR_OK; sanity_error: - if (state->sanity_errors >= SANITY_MAX) { - /* - * Take LCP down if the peer is sending too many bogons. - * We don't want to do this for a single or just a few - * instances since it could just be due to packet corruption. - */ - lcp_close(pcb, "Too many MPPE errors"); - } - return ERR_BUF; + if (state->sanity_errors >= SANITY_MAX) { + /* + * Take LCP down if the peer is sending too many bogons. + * We don't want to do this for a single or just a few + * instances since it could just be due to packet corruption. + */ + lcp_close(pcb, "Too many MPPE errors"); + } + return ERR_BUF; } #endif /* PPP_SUPPORT && MPPE_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/multilink.c b/components/net/lwip-2.1.2/src/netif/ppp/multilink.c index 62014e8c87..08e8130d48 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/multilink.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/multilink.c @@ -55,11 +55,11 @@ #include "netif/ppp/lcp.h" #include "netif/ppp/tdb.h" -bool endpoint_specified; /* user gave explicit endpoint discriminator */ -char *bundle_id; /* identifier for our bundle */ -char *blinks_id; /* key for the list of links */ -bool doing_multilink; /* multilink was enabled and agreed to */ -bool multilink_master; /* we own the multilink bundle */ +bool endpoint_specified; /* user gave explicit endpoint discriminator */ +char *bundle_id; /* identifier for our bundle */ +char *blinks_id; /* key for the list of links */ +bool doing_multilink; /* multilink was enabled and agreed to */ +bool multilink_master; /* we own the multilink bundle */ extern TDB_CONTEXT *pppdb; extern char db_key[]; @@ -72,43 +72,43 @@ static int get_default_epdisc (struct epdisc *); static int parse_num (char *str, const char *key, int *valp); static int owns_unit (TDB_DATA pid, int unit); -#define set_ip_epdisc(ep, addr) do { \ - ep->length = 4; \ - ep->value[0] = addr >> 24; \ - ep->value[1] = addr >> 16; \ - ep->value[2] = addr >> 8; \ - ep->value[3] = addr; \ +#define set_ip_epdisc(ep, addr) do { \ + ep->length = 4; \ + ep->value[0] = addr >> 24; \ + ep->value[1] = addr >> 16; \ + ep->value[2] = addr >> 8; \ + ep->value[3] = addr; \ } while (0) -#define LOCAL_IP_ADDR(addr) \ - (((addr) & 0xff000000) == 0x0a000000 /* 10.x.x.x */ \ - || ((addr) & 0xfff00000) == 0xac100000 /* 172.16.x.x */ \ - || ((addr) & 0xffff0000) == 0xc0a80000) /* 192.168.x.x */ +#define LOCAL_IP_ADDR(addr) \ + (((addr) & 0xff000000) == 0x0a000000 /* 10.x.x.x */ \ + || ((addr) & 0xfff00000) == 0xac100000 /* 172.16.x.x */ \ + || ((addr) & 0xffff0000) == 0xc0a80000) /* 192.168.x.x */ -#define process_exists(n) (kill((n), 0) == 0 || errno != ESRCH) +#define process_exists(n) (kill((n), 0) == 0 || errno != ESRCH) void mp_check_options() { - lcp_options *wo = &lcp_wantoptions[0]; - lcp_options *ao = &lcp_allowoptions[0]; - - doing_multilink = 0; - if (!multilink) - return; - /* if we're doing multilink, we have to negotiate MRRU */ - if (!wo->neg_mrru) { - /* mrru not specified, default to mru */ - wo->mrru = wo->mru; - wo->neg_mrru = 1; - } - ao->mrru = ao->mru; - ao->neg_mrru = 1; - - if (!wo->neg_endpoint && !noendpoint) { - /* get a default endpoint value */ - wo->neg_endpoint = get_default_epdisc(&wo->endpoint); - } + lcp_options *wo = &lcp_wantoptions[0]; + lcp_options *ao = &lcp_allowoptions[0]; + + doing_multilink = 0; + if (!multilink) + return; + /* if we're doing multilink, we have to negotiate MRRU */ + if (!wo->neg_mrru) { + /* mrru not specified, default to mru */ + wo->mrru = wo->mru; + wo->neg_mrru = 1; + } + ao->mrru = ao->mru; + ao->neg_mrru = 1; + + if (!wo->neg_endpoint && !noendpoint) { + /* get a default endpoint value */ + wo->neg_endpoint = get_default_epdisc(&wo->endpoint); + } } /* @@ -118,289 +118,289 @@ mp_check_options() int mp_join_bundle() { - lcp_options *go = &lcp_gotoptions[0]; - lcp_options *ho = &lcp_hisoptions[0]; - lcp_options *ao = &lcp_allowoptions[0]; - int unit, pppd_pid; - int l, mtu; - char *p; - TDB_DATA key, pid, rec; - - if (doing_multilink) { - /* have previously joined a bundle */ - if (!go->neg_mrru || !ho->neg_mrru) { - notice("oops, didn't get multilink on renegotiation"); - lcp_close(pcb, "multilink required"); - return 0; - } - /* XXX should check the peer_authname and ho->endpoint - are the same as previously */ - return 0; - } - - if (!go->neg_mrru || !ho->neg_mrru) { - /* not doing multilink */ - if (go->neg_mrru) - notice("oops, multilink negotiated only for receive"); - mtu = ho->neg_mru? ho->mru: PPP_MRU; - if (mtu > ao->mru) - mtu = ao->mru; - if (demand) { - /* already have a bundle */ - cfg_bundle(0, 0, 0, 0); - netif_set_mtu(pcb, mtu); - return 0; - } - make_new_bundle(0, 0, 0, 0); - set_ifunit(1); - netif_set_mtu(pcb, mtu); - return 0; - } - - doing_multilink = 1; - - /* - * Find the appropriate bundle or join a new one. - * First we make up a name for the bundle. - * The length estimate is worst-case assuming every - * character has to be quoted. - */ - l = 4 * strlen(peer_authname) + 10; - if (ho->neg_endpoint) - l += 3 * ho->endpoint.length + 8; - if (bundle_name) - l += 3 * strlen(bundle_name) + 2; - bundle_id = malloc(l); - if (bundle_id == 0) - novm("bundle identifier"); - - p = bundle_id; - p += slprintf(p, l-1, "BUNDLE=\"%q\"", peer_authname); - if (ho->neg_endpoint || bundle_name) - *p++ = '/'; - if (ho->neg_endpoint) - p += slprintf(p, bundle_id+l-p, "%s", - epdisc_to_str(&ho->endpoint)); - if (bundle_name) - p += slprintf(p, bundle_id+l-p, "/%v", bundle_name); - - /* Make the key for the list of links belonging to the bundle */ - l = p - bundle_id; - blinks_id = malloc(l + 7); - if (blinks_id == NULL) - novm("bundle links key"); - slprintf(blinks_id, l + 7, "BUNDLE_LINKS=%s", bundle_id + 7); - - /* - * For demand mode, we only need to configure the bundle - * and attach the link. - */ - mtu = LWIP_MIN(ho->mrru, ao->mru); - if (demand) { - cfg_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); - netif_set_mtu(pcb, mtu); - script_setenv("BUNDLE", bundle_id + 7, 1); - return 0; - } - - /* - * Check if the bundle ID is already in the database. - */ - unit = -1; - lock_db(); - key.dptr = bundle_id; - key.dsize = p - bundle_id; - pid = tdb_fetch(pppdb, key); - if (pid.dptr != NULL) { - /* bundle ID exists, see if the pppd record exists */ - rec = tdb_fetch(pppdb, pid); - if (rec.dptr != NULL && rec.dsize > 0) { - /* make sure the string is null-terminated */ - rec.dptr[rec.dsize-1] = 0; - /* parse the interface number */ - parse_num(rec.dptr, "IFNAME=ppp", &unit); - /* check the pid value */ - if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid) - || !process_exists(pppd_pid) - || !owns_unit(pid, unit)) - unit = -1; - free(rec.dptr); - } - free(pid.dptr); - } - - if (unit >= 0) { - /* attach to existing unit */ - if (bundle_attach(unit)) { - set_ifunit(0); - script_setenv("BUNDLE", bundle_id + 7, 0); - make_bundle_links(1); - unlock_db(); - info("Link attached to %s", ifname); - return 1; - } - /* attach failed because bundle doesn't exist */ - } - - /* we have to make a new bundle */ - make_new_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); - set_ifunit(1); - netif_set_mtu(pcb, mtu); - script_setenv("BUNDLE", bundle_id + 7, 1); - make_bundle_links(pcb); - unlock_db(); - info("New bundle %s created", ifname); - multilink_master = 1; - return 0; + lcp_options *go = &lcp_gotoptions[0]; + lcp_options *ho = &lcp_hisoptions[0]; + lcp_options *ao = &lcp_allowoptions[0]; + int unit, pppd_pid; + int l, mtu; + char *p; + TDB_DATA key, pid, rec; + + if (doing_multilink) { + /* have previously joined a bundle */ + if (!go->neg_mrru || !ho->neg_mrru) { + notice("oops, didn't get multilink on renegotiation"); + lcp_close(pcb, "multilink required"); + return 0; + } + /* XXX should check the peer_authname and ho->endpoint + are the same as previously */ + return 0; + } + + if (!go->neg_mrru || !ho->neg_mrru) { + /* not doing multilink */ + if (go->neg_mrru) + notice("oops, multilink negotiated only for receive"); + mtu = ho->neg_mru? ho->mru: PPP_MRU; + if (mtu > ao->mru) + mtu = ao->mru; + if (demand) { + /* already have a bundle */ + cfg_bundle(0, 0, 0, 0); + netif_set_mtu(pcb, mtu); + return 0; + } + make_new_bundle(0, 0, 0, 0); + set_ifunit(1); + netif_set_mtu(pcb, mtu); + return 0; + } + + doing_multilink = 1; + + /* + * Find the appropriate bundle or join a new one. + * First we make up a name for the bundle. + * The length estimate is worst-case assuming every + * character has to be quoted. + */ + l = 4 * strlen(peer_authname) + 10; + if (ho->neg_endpoint) + l += 3 * ho->endpoint.length + 8; + if (bundle_name) + l += 3 * strlen(bundle_name) + 2; + bundle_id = malloc(l); + if (bundle_id == 0) + novm("bundle identifier"); + + p = bundle_id; + p += slprintf(p, l-1, "BUNDLE=\"%q\"", peer_authname); + if (ho->neg_endpoint || bundle_name) + *p++ = '/'; + if (ho->neg_endpoint) + p += slprintf(p, bundle_id+l-p, "%s", + epdisc_to_str(&ho->endpoint)); + if (bundle_name) + p += slprintf(p, bundle_id+l-p, "/%v", bundle_name); + + /* Make the key for the list of links belonging to the bundle */ + l = p - bundle_id; + blinks_id = malloc(l + 7); + if (blinks_id == NULL) + novm("bundle links key"); + slprintf(blinks_id, l + 7, "BUNDLE_LINKS=%s", bundle_id + 7); + + /* + * For demand mode, we only need to configure the bundle + * and attach the link. + */ + mtu = LWIP_MIN(ho->mrru, ao->mru); + if (demand) { + cfg_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); + netif_set_mtu(pcb, mtu); + script_setenv("BUNDLE", bundle_id + 7, 1); + return 0; + } + + /* + * Check if the bundle ID is already in the database. + */ + unit = -1; + lock_db(); + key.dptr = bundle_id; + key.dsize = p - bundle_id; + pid = tdb_fetch(pppdb, key); + if (pid.dptr != NULL) { + /* bundle ID exists, see if the pppd record exists */ + rec = tdb_fetch(pppdb, pid); + if (rec.dptr != NULL && rec.dsize > 0) { + /* make sure the string is null-terminated */ + rec.dptr[rec.dsize-1] = 0; + /* parse the interface number */ + parse_num(rec.dptr, "IFNAME=ppp", &unit); + /* check the pid value */ + if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid) + || !process_exists(pppd_pid) + || !owns_unit(pid, unit)) + unit = -1; + free(rec.dptr); + } + free(pid.dptr); + } + + if (unit >= 0) { + /* attach to existing unit */ + if (bundle_attach(unit)) { + set_ifunit(0); + script_setenv("BUNDLE", bundle_id + 7, 0); + make_bundle_links(1); + unlock_db(); + info("Link attached to %s", ifname); + return 1; + } + /* attach failed because bundle doesn't exist */ + } + + /* we have to make a new bundle */ + make_new_bundle(go->mrru, ho->mrru, go->neg_ssnhf, ho->neg_ssnhf); + set_ifunit(1); + netif_set_mtu(pcb, mtu); + script_setenv("BUNDLE", bundle_id + 7, 1); + make_bundle_links(pcb); + unlock_db(); + info("New bundle %s created", ifname); + multilink_master = 1; + return 0; } void mp_exit_bundle() { - lock_db(); - remove_bundle_link(); - unlock_db(); + lock_db(); + remove_bundle_link(); + unlock_db(); } static void sendhup(char *str) { - int pid; + int pid; - if (parse_num(str, "PPPD_PID=", &pid) && pid != getpid()) { - if (debug) - dbglog("sending SIGHUP to process %d", pid); - kill(pid, SIGHUP); - } + if (parse_num(str, "PPPD_PID=", &pid) && pid != getpid()) { + if (debug) + dbglog("sending SIGHUP to process %d", pid); + kill(pid, SIGHUP); + } } void mp_bundle_terminated() { - TDB_DATA key; + TDB_DATA key; - bundle_terminating = 1; - upper_layers_down(pcb); - notice("Connection terminated."); + bundle_terminating = 1; + upper_layers_down(pcb); + notice("Connection terminated."); #if PPP_STATS_SUPPORT - print_link_stats(); + print_link_stats(); #endif /* PPP_STATS_SUPPORT */ - if (!demand) { - remove_pidfiles(); - script_unsetenv("IFNAME"); - } - - lock_db(); - destroy_bundle(); - iterate_bundle_links(sendhup); - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - tdb_delete(pppdb, key); - unlock_db(); - - new_phase(PPP_PHASE_DEAD); - - doing_multilink = 0; - multilink_master = 0; + if (!demand) { + remove_pidfiles(); + script_unsetenv("IFNAME"); + } + + lock_db(); + destroy_bundle(); + iterate_bundle_links(sendhup); + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + tdb_delete(pppdb, key); + unlock_db(); + + new_phase(PPP_PHASE_DEAD); + + doing_multilink = 0; + multilink_master = 0; } static void make_bundle_links(int append) { - TDB_DATA key, rec; - char *p; - char entry[32]; - int l; - - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - slprintf(entry, sizeof(entry), "%s;", db_key); - p = entry; - if (append) { - rec = tdb_fetch(pppdb, key); - if (rec.dptr != NULL && rec.dsize > 0) { - rec.dptr[rec.dsize-1] = 0; - if (strstr(rec.dptr, db_key) != NULL) { - /* already in there? strange */ - warn("link entry already exists in tdb"); - return; - } - l = rec.dsize + strlen(entry); - p = malloc(l); - if (p == NULL) - novm("bundle link list"); - slprintf(p, l, "%s%s", rec.dptr, entry); - } else { - warn("bundle link list not found"); - } - if (rec.dptr != NULL) - free(rec.dptr); - } - rec.dptr = p; - rec.dsize = strlen(p) + 1; - if (tdb_store(pppdb, key, rec, TDB_REPLACE)) - error("couldn't %s bundle link list", - append? "update": "create"); - if (p != entry) - free(p); + TDB_DATA key, rec; + char *p; + char entry[32]; + int l; + + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + slprintf(entry, sizeof(entry), "%s;", db_key); + p = entry; + if (append) { + rec = tdb_fetch(pppdb, key); + if (rec.dptr != NULL && rec.dsize > 0) { + rec.dptr[rec.dsize-1] = 0; + if (strstr(rec.dptr, db_key) != NULL) { + /* already in there? strange */ + warn("link entry already exists in tdb"); + return; + } + l = rec.dsize + strlen(entry); + p = malloc(l); + if (p == NULL) + novm("bundle link list"); + slprintf(p, l, "%s%s", rec.dptr, entry); + } else { + warn("bundle link list not found"); + } + if (rec.dptr != NULL) + free(rec.dptr); + } + rec.dptr = p; + rec.dsize = strlen(p) + 1; + if (tdb_store(pppdb, key, rec, TDB_REPLACE)) + error("couldn't %s bundle link list", + append? "update": "create"); + if (p != entry) + free(p); } static void remove_bundle_link() { - TDB_DATA key, rec; - char entry[32]; - char *p, *q; - int l; - - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - slprintf(entry, sizeof(entry), "%s;", db_key); - - rec = tdb_fetch(pppdb, key); - if (rec.dptr == NULL || rec.dsize <= 0) { - if (rec.dptr != NULL) - free(rec.dptr); - return; - } - rec.dptr[rec.dsize-1] = 0; - p = strstr(rec.dptr, entry); - if (p != NULL) { - q = p + strlen(entry); - l = strlen(q) + 1; - memmove(p, q, l); - rec.dsize = p - rec.dptr + l; - if (tdb_store(pppdb, key, rec, TDB_REPLACE)) - error("couldn't update bundle link list (removal)"); - } - free(rec.dptr); + TDB_DATA key, rec; + char entry[32]; + char *p, *q; + int l; + + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + slprintf(entry, sizeof(entry), "%s;", db_key); + + rec = tdb_fetch(pppdb, key); + if (rec.dptr == NULL || rec.dsize <= 0) { + if (rec.dptr != NULL) + free(rec.dptr); + return; + } + rec.dptr[rec.dsize-1] = 0; + p = strstr(rec.dptr, entry); + if (p != NULL) { + q = p + strlen(entry); + l = strlen(q) + 1; + memmove(p, q, l); + rec.dsize = p - rec.dptr + l; + if (tdb_store(pppdb, key, rec, TDB_REPLACE)) + error("couldn't update bundle link list (removal)"); + } + free(rec.dptr); } static void iterate_bundle_links(void (*func)(char *)) { - TDB_DATA key, rec, pp; - char *p, *q; - - key.dptr = blinks_id; - key.dsize = strlen(blinks_id); - rec = tdb_fetch(pppdb, key); - if (rec.dptr == NULL || rec.dsize <= 0) { - error("bundle link list not found (iterating list)"); - if (rec.dptr != NULL) - free(rec.dptr); - return; - } - p = rec.dptr; - p[rec.dsize-1] = 0; - while ((q = strchr(p, ';')) != NULL) { - *q = 0; - key.dptr = p; - key.dsize = q - p; - pp = tdb_fetch(pppdb, key); - if (pp.dptr != NULL && pp.dsize > 0) { - pp.dptr[pp.dsize-1] = 0; - func(pp.dptr); - } - if (pp.dptr != NULL) - free(pp.dptr); - p = q + 1; - } - free(rec.dptr); + TDB_DATA key, rec, pp; + char *p, *q; + + key.dptr = blinks_id; + key.dsize = strlen(blinks_id); + rec = tdb_fetch(pppdb, key); + if (rec.dptr == NULL || rec.dsize <= 0) { + error("bundle link list not found (iterating list)"); + if (rec.dptr != NULL) + free(rec.dptr); + return; + } + p = rec.dptr; + p[rec.dsize-1] = 0; + while ((q = strchr(p, ';')) != NULL) { + *q = 0; + key.dptr = p; + key.dsize = q - p; + pp = tdb_fetch(pppdb, key); + if (pp.dptr != NULL && pp.dsize > 0) { + pp.dptr[pp.dsize-1] = 0; + func(pp.dptr); + } + if (pp.dptr != NULL) + free(pp.dptr); + p = q + 1; + } + free(rec.dptr); } static int @@ -409,19 +409,19 @@ parse_num(str, key, valp) const char *key; int *valp; { - char *p, *endp; - int i; - - p = strstr(str, key); - if (p != 0) { - p += strlen(key); - i = strtol(p, &endp, 10); - if (endp != p && (*endp == 0 || *endp == ';')) { - *valp = i; - return 1; - } - } - return 0; + char *p, *endp; + int i; + + p = strstr(str, key); + if (p != 0) { + p += strlen(key); + i = strtol(p, &endp, 10); + if (endp != p && (*endp == 0 || *endp == ';')) { + *valp = i; + return 1; + } + } + return 0; } /* @@ -432,53 +432,53 @@ owns_unit(key, unit) TDB_DATA key; int unit; { - char ifkey[32]; - TDB_DATA kd, vd; - int ret = 0; - - slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit); - kd.dptr = ifkey; - kd.dsize = strlen(ifkey); - vd = tdb_fetch(pppdb, kd); - if (vd.dptr != NULL) { - ret = vd.dsize == key.dsize - && memcmp(vd.dptr, key.dptr, vd.dsize) == 0; - free(vd.dptr); - } - return ret; + char ifkey[32]; + TDB_DATA kd, vd; + int ret = 0; + + slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit); + kd.dptr = ifkey; + kd.dsize = strlen(ifkey); + vd = tdb_fetch(pppdb, kd); + if (vd.dptr != NULL) { + ret = vd.dsize == key.dsize + && memcmp(vd.dptr, key.dptr, vd.dsize) == 0; + free(vd.dptr); + } + return ret; } static int get_default_epdisc(ep) struct epdisc *ep; { - char *p; - struct hostent *hp; - u32_t addr; - - /* First try for an ethernet MAC address */ - p = get_first_ethernet(); - if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) { - ep->class = EPD_MAC; - ep->length = 6; - return 1; - } - - /* see if our hostname corresponds to a reasonable IP address */ - hp = gethostbyname(hostname); - if (hp != NULL) { - addr = *(u32_t *)hp->h_addr; - if (!bad_ip_adrs(addr)) { - addr = lwip_ntohl(addr); - if (!LOCAL_IP_ADDR(addr)) { - ep->class = EPD_IP; - set_ip_epdisc(ep, addr); - return 1; - } - } - } - - return 0; + char *p; + struct hostent *hp; + u32_t addr; + + /* First try for an ethernet MAC address */ + p = get_first_ethernet(); + if (p != 0 && get_if_hwaddr(ep->value, p) >= 0) { + ep->class = EPD_MAC; + ep->length = 6; + return 1; + } + + /* see if our hostname corresponds to a reasonable IP address */ + hp = gethostbyname(hostname); + if (hp != NULL) { + addr = *(u32_t *)hp->h_addr; + if (!bad_ip_adrs(addr)) { + addr = lwip_ntohl(addr); + if (!LOCAL_IP_ADDR(addr)) { + ep->class = EPD_IP; + set_ip_epdisc(ep, addr); + return 1; + } + } + } + + return 0; } /* @@ -493,51 +493,51 @@ char * epdisc_to_str(ep) struct epdisc *ep; { - static char str[MAX_ENDP_LEN*3+8]; - u_char *p = ep->value; - int i, mask = 0; - char *q, c, c2; - - if (ep->class == EPD_NULL && ep->length == 0) - return "null"; - if (ep->class == EPD_IP && ep->length == 4) { - u32_t addr; - - GETLONG(addr, p); - slprintf(str, sizeof(str), "IP:%I", lwip_htonl(addr)); - return str; - } - - c = ':'; - c2 = '.'; - if (ep->class == EPD_MAC && ep->length == 6) - c2 = ':'; - else if (ep->class == EPD_MAGIC && (ep->length % 4) == 0) - mask = 3; - q = str; - if (ep->class <= EPD_PHONENUM) - q += slprintf(q, sizeof(str)-1, "%s", - endp_class_names[ep->class]); - else - q += slprintf(q, sizeof(str)-1, "%d", ep->class); - c = ':'; - for (i = 0; i < ep->length && i < MAX_ENDP_LEN; ++i) { - if ((i & mask) == 0) { - *q++ = c; - c = c2; - } - q += slprintf(q, str + sizeof(str) - q, "%.2x", ep->value[i]); - } - return str; + static char str[MAX_ENDP_LEN*3+8]; + u_char *p = ep->value; + int i, mask = 0; + char *q, c, c2; + + if (ep->class == EPD_NULL && ep->length == 0) + return "null"; + if (ep->class == EPD_IP && ep->length == 4) { + u32_t addr; + + GETLONG(addr, p); + slprintf(str, sizeof(str), "IP:%I", lwip_htonl(addr)); + return str; + } + + c = ':'; + c2 = '.'; + if (ep->class == EPD_MAC && ep->length == 6) + c2 = ':'; + else if (ep->class == EPD_MAGIC && (ep->length % 4) == 0) + mask = 3; + q = str; + if (ep->class <= EPD_PHONENUM) + q += slprintf(q, sizeof(str)-1, "%s", + endp_class_names[ep->class]); + else + q += slprintf(q, sizeof(str)-1, "%d", ep->class); + c = ':'; + for (i = 0; i < ep->length && i < MAX_ENDP_LEN; ++i) { + if ((i & mask) == 0) { + *q++ = c; + c = c2; + } + q += slprintf(q, str + sizeof(str) - q, "%.2x", ep->value[i]); + } + return str; } static int hexc_val(int c) { - if (c >= 'a') - return c - 'a' + 10; - if (c >= 'A') - return c - 'A' + 10; - return c - '0'; + if (c >= 'a') + return c - 'a' + 10; + if (c >= 'A') + return c - 'A' + 10; + return c - '0'; } int @@ -545,65 +545,65 @@ str_to_epdisc(ep, str) struct epdisc *ep; char *str; { - int i, l; - char *p, *endp; - - for (i = EPD_NULL; i <= EPD_PHONENUM; ++i) { - int sl = strlen(endp_class_names[i]); - if (strncasecmp(str, endp_class_names[i], sl) == 0) { - str += sl; - break; - } - } - if (i > EPD_PHONENUM) { - /* not a class name, try a decimal class number */ - i = strtol(str, &endp, 10); - if (endp == str) - return 0; /* can't parse class number */ - str = endp; - } - ep->class = i; - if (*str == 0) { - ep->length = 0; - return 1; - } - if (*str != ':' && *str != '.') - return 0; - ++str; - - if (i == EPD_IP) { - u32_t addr; - i = parse_dotted_ip(str, &addr); - if (i == 0 || str[i] != 0) - return 0; - set_ip_epdisc(ep, addr); - return 1; - } - if (i == EPD_MAC && get_if_hwaddr(ep->value, str) >= 0) { - ep->length = 6; - return 1; - } - - p = str; - for (l = 0; l < MAX_ENDP_LEN; ++l) { - if (*str == 0) - break; - if (p <= str) - for (p = str; isxdigit(*p); ++p) - ; - i = p - str; - if (i == 0) - return 0; - ep->value[l] = hexc_val(*str++); - if ((i & 1) == 0) - ep->value[l] = (ep->value[l] << 4) + hexc_val(*str++); - if (*str == ':' || *str == '.') - ++str; - } - if (*str != 0 || (ep->class == EPD_MAC && l != 6)) - return 0; - ep->length = l; - return 1; + int i, l; + char *p, *endp; + + for (i = EPD_NULL; i <= EPD_PHONENUM; ++i) { + int sl = strlen(endp_class_names[i]); + if (strncasecmp(str, endp_class_names[i], sl) == 0) { + str += sl; + break; + } + } + if (i > EPD_PHONENUM) { + /* not a class name, try a decimal class number */ + i = strtol(str, &endp, 10); + if (endp == str) + return 0; /* can't parse class number */ + str = endp; + } + ep->class = i; + if (*str == 0) { + ep->length = 0; + return 1; + } + if (*str != ':' && *str != '.') + return 0; + ++str; + + if (i == EPD_IP) { + u32_t addr; + i = parse_dotted_ip(str, &addr); + if (i == 0 || str[i] != 0) + return 0; + set_ip_epdisc(ep, addr); + return 1; + } + if (i == EPD_MAC && get_if_hwaddr(ep->value, str) >= 0) { + ep->length = 6; + return 1; + } + + p = str; + for (l = 0; l < MAX_ENDP_LEN; ++l) { + if (*str == 0) + break; + if (p <= str) + for (p = str; isxdigit(*p); ++p) + ; + i = p - str; + if (i == 0) + return 0; + ep->value[l] = hexc_val(*str++); + if ((i & 1) == 0) + ep->value[l] = (ep->value[l] << 4) + hexc_val(*str++); + if (*str == ':' || *str == '.') + ++str; + } + if (*str != 0 || (ep->class == EPD_MAC && l != 6)) + return 0; + ep->length = l; + return 1; } #endif /* PPP_SUPPORT && HAVE_MULTILINK */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/arc4.c b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/arc4.c index 6e17ec421b..cb31b8761e 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/arc4.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/arc4.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/des.c b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/des.c index 9a89d007bd..b01e07fa5c 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/des.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/des.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md4.c b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md4.c index b1701a07b9..34e5b10cd4 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md4.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md4.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md5.c b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md5.c index 1ec4d81a69..fa6365848f 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md5.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/md5.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS @@ -156,7 +156,7 @@ static void md5_process( md5_context *ctx, const unsigned char data[64] ) P( B, C, D, A, 12, 20, 0x8D2A4C8A ); #undef F - + #define F(x,y,z) (x ^ y ^ z) P( A, B, C, D, 5, 4, 0xFFFA3942 ); diff --git a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/sha1.c b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/sha1.c index c2192eac54..6079af3ba2 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/polarssl/sha1.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/polarssl/sha1.c @@ -10,7 +10,7 @@ * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright @@ -19,7 +19,7 @@ * * Neither the names of PolarSSL or XySSL nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS diff --git a/components/net/lwip-2.1.2/src/netif/ppp/ppp.c b/components/net/lwip-2.1.2/src/netif/ppp/ppp.c index a9c18e304f..d2eaf5594e 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/ppp.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/ppp.c @@ -633,7 +633,7 @@ int ppp_init(void) return 0; } - + /* * Create a new PPP control block. * diff --git a/components/net/lwip-2.1.2/src/netif/ppp/pppapi.c b/components/net/lwip-2.1.2/src/netif/ppp/pppapi.c index 947f7ba8c1..0ad8e986b4 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/pppapi.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/pppapi.c @@ -57,10 +57,10 @@ LWIP_MEMPOOL_DECLARE(PPPAPI_MSG, MEMP_NUM_PPP_API_MSG, sizeof(struct pppapi_msg) static err_t pppapi_do_ppp_set_default(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; - + ppp_set_default(msg->msg.ppp); return ERR_OK; } @@ -90,7 +90,7 @@ pppapi_set_default(ppp_pcb *pcb) static err_t pppapi_do_ppp_set_notify_phase_callback(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -125,7 +125,7 @@ pppapi_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_pha static err_t pppapi_do_pppos_create(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -166,7 +166,7 @@ pppapi_pppos_create(struct netif *pppif, pppos_output_cb_fn output_cb, static err_t pppapi_do_pppoe_create(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -211,7 +211,7 @@ pppapi_pppoe_create(struct netif *pppif, struct netif *ethif, const char *servic static err_t pppapi_do_pppol2tp_create(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -270,7 +270,7 @@ pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipad static err_t pppapi_do_ppp_connect(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -303,7 +303,7 @@ pppapi_connect(ppp_pcb *pcb, u16_t holdoff) static err_t pppapi_do_ppp_listen(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -335,7 +335,7 @@ pppapi_listen(ppp_pcb *pcb) static err_t pppapi_do_ppp_close(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -367,7 +367,7 @@ pppapi_close(ppp_pcb *pcb, u8_t nocarrier) static err_t pppapi_do_ppp_free(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; @@ -398,7 +398,7 @@ pppapi_free(ppp_pcb *pcb) static err_t pppapi_do_ppp_ioctl(struct tcpip_api_call_data *m) { - /* cast through void* to silence alignment warnings. + /* cast through void* to silence alignment warnings. * We know it works because the structs have been instantiated as struct pppapi_msg */ struct pppapi_msg *msg = (struct pppapi_msg *)(void*)m; diff --git a/components/net/lwip-2.1.2/src/netif/ppp/pppcrypt.c b/components/net/lwip-2.1.2/src/netif/ppp/pppcrypt.c index 82d78c13ac..81e4008d3d 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/pppcrypt.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/pppcrypt.c @@ -39,28 +39,28 @@ static u_char pppcrypt_get_7bits(u_char *input, int startBit) { - unsigned int word; + unsigned int word; - word = (unsigned)input[startBit / 8] << 8; - word |= (unsigned)input[startBit / 8 + 1]; + word = (unsigned)input[startBit / 8] << 8; + word |= (unsigned)input[startBit / 8 + 1]; - word >>= 15 - (startBit % 8 + 7); + word >>= 15 - (startBit % 8 + 7); - return word & 0xFE; + return word & 0xFE; } /* IN 56 bit DES key missing parity bits * OUT 64 bit DES key with parity bits added */ void pppcrypt_56_to_64_bit_key(u_char *key, u_char * des_key) { - des_key[0] = pppcrypt_get_7bits(key, 0); - des_key[1] = pppcrypt_get_7bits(key, 7); - des_key[2] = pppcrypt_get_7bits(key, 14); - des_key[3] = pppcrypt_get_7bits(key, 21); - des_key[4] = pppcrypt_get_7bits(key, 28); - des_key[5] = pppcrypt_get_7bits(key, 35); - des_key[6] = pppcrypt_get_7bits(key, 42); - des_key[7] = pppcrypt_get_7bits(key, 49); + des_key[0] = pppcrypt_get_7bits(key, 0); + des_key[1] = pppcrypt_get_7bits(key, 7); + des_key[2] = pppcrypt_get_7bits(key, 14); + des_key[3] = pppcrypt_get_7bits(key, 21); + des_key[4] = pppcrypt_get_7bits(key, 28); + des_key[5] = pppcrypt_get_7bits(key, 35); + des_key[6] = pppcrypt_get_7bits(key, 42); + des_key[7] = pppcrypt_get_7bits(key, 49); } #endif /* PPP_SUPPORT && MSCHAP_SUPPORT */ diff --git a/components/net/lwip-2.1.2/src/netif/ppp/pppoe.c b/components/net/lwip-2.1.2/src/netif/ppp/pppoe.c index 8ed2d638fd..461e8bce56 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/pppoe.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/pppoe.c @@ -6,13 +6,13 @@ * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this -* notice and the following disclaimer are included verbatim in any +* notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE 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. +* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE 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, @@ -666,7 +666,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_remove_header failed\n")); LINK_STATS_INC(link.lenerr); goto drop; - } + } if (pb->len < sizeof(*ph)) { PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: could not get PPPoE header\n")); @@ -699,7 +699,7 @@ pppoe_data_input(struct netif *netif, struct pbuf *pb) PPPDEBUG(LOG_ERR, ("pppoe_data_input: pbuf_remove_header PPPOE_HEADERLEN failed\n")); LINK_STATS_INC(link.lenerr); goto drop; - } + } PPPDEBUG(LOG_DEBUG, ("pppoe_data_input: %c%c%"U16_F": pkthdr.len=%d, pppoe.len=%d\n", sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, diff --git a/components/net/lwip-2.1.2/src/netif/ppp/upap.c b/components/net/lwip-2.1.2/src/netif/ppp/upap.c index 3b2399dc23..23891284e5 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/upap.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/upap.c @@ -166,12 +166,12 @@ void upap_authwithpeer(ppp_pcb *pcb, const char *user, const char *password) { /* Lower layer up yet? */ if (pcb->upap.us_clientstate == UPAPCS_INITIAL || - pcb->upap.us_clientstate == UPAPCS_PENDING) { - pcb->upap.us_clientstate = UPAPCS_PENDING; - return; + pcb->upap.us_clientstate == UPAPCS_PENDING) { + pcb->upap.us_clientstate = UPAPCS_PENDING; + return; } - upap_sauthreq(pcb); /* Start protocol */ + upap_sauthreq(pcb); /* Start protocol */ } #if PPP_SERVER @@ -184,14 +184,14 @@ void upap_authpeer(ppp_pcb *pcb) { /* Lower layer up yet? */ if (pcb->upap.us_serverstate == UPAPSS_INITIAL || - pcb->upap.us_serverstate == UPAPSS_PENDING) { - pcb->upap.us_serverstate = UPAPSS_PENDING; - return; + pcb->upap.us_serverstate == UPAPSS_PENDING) { + pcb->upap.us_serverstate = UPAPSS_PENDING; + return; } pcb->upap.us_serverstate = UPAPSS_LISTEN; if (pcb->settings.pap_req_timeout > 0) - TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); + TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); } #endif /* PPP_SERVER */ @@ -202,17 +202,17 @@ static void upap_timeout(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) - return; + return; if (pcb->upap.us_transmits >= pcb->settings.pap_max_transmits) { - /* give up in disgust */ - ppp_error("No response to PAP authenticate-requests"); - pcb->upap.us_clientstate = UPAPCS_BADAUTH; - auth_withpeer_fail(pcb, PPP_PAP); - return; + /* give up in disgust */ + ppp_error("No response to PAP authenticate-requests"); + pcb->upap.us_clientstate = UPAPCS_BADAUTH; + auth_withpeer_fail(pcb, PPP_PAP); + return; } - upap_sauthreq(pcb); /* Send Authenticate-Request */ + upap_sauthreq(pcb); /* Send Authenticate-Request */ } @@ -224,7 +224,7 @@ static void upap_reqtimeout(void *arg) { ppp_pcb *pcb = (ppp_pcb*)arg; if (pcb->upap.us_serverstate != UPAPSS_LISTEN) - return; /* huh?? */ + return; /* huh?? */ auth_peer_fail(pcb, PPP_PAP); pcb->upap.us_serverstate = UPAPSS_BADAUTH; @@ -240,18 +240,18 @@ static void upap_reqtimeout(void *arg) { static void upap_lowerup(ppp_pcb *pcb) { if (pcb->upap.us_clientstate == UPAPCS_INITIAL) - pcb->upap.us_clientstate = UPAPCS_CLOSED; + pcb->upap.us_clientstate = UPAPCS_CLOSED; else if (pcb->upap.us_clientstate == UPAPCS_PENDING) { - upap_sauthreq(pcb); /* send an auth-request */ + upap_sauthreq(pcb); /* send an auth-request */ } #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_INITIAL) - pcb->upap.us_serverstate = UPAPSS_CLOSED; + pcb->upap.us_serverstate = UPAPSS_CLOSED; else if (pcb->upap.us_serverstate == UPAPSS_PENDING) { - pcb->upap.us_serverstate = UPAPSS_LISTEN; - if (pcb->settings.pap_req_timeout > 0) - TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); + pcb->upap.us_serverstate = UPAPSS_LISTEN; + if (pcb->settings.pap_req_timeout > 0) + TIMEOUT(upap_reqtimeout, pcb, pcb->settings.pap_req_timeout); } #endif /* PPP_SERVER */ } @@ -264,11 +264,11 @@ static void upap_lowerup(ppp_pcb *pcb) { */ static void upap_lowerdown(ppp_pcb *pcb) { - if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */ - UNTIMEOUT(upap_timeout, pcb); /* Cancel timeout */ + if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */ + UNTIMEOUT(upap_timeout, pcb); /* Cancel timeout */ #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_LISTEN && pcb->settings.pap_req_timeout > 0) - UNTIMEOUT(upap_reqtimeout, pcb); + UNTIMEOUT(upap_reqtimeout, pcb); #endif /* PPP_SERVER */ pcb->upap.us_clientstate = UPAPCS_INITIAL; @@ -286,13 +286,13 @@ static void upap_lowerdown(ppp_pcb *pcb) { static void upap_protrej(ppp_pcb *pcb) { if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) { - ppp_error("PAP authentication failed due to protocol-reject"); - auth_withpeer_fail(pcb, PPP_PAP); + ppp_error("PAP authentication failed due to protocol-reject"); + auth_withpeer_fail(pcb, PPP_PAP); } #if PPP_SERVER if (pcb->upap.us_serverstate == UPAPSS_LISTEN) { - ppp_error("PAP authentication of peer failed (protocol-reject)"); - auth_peer_fail(pcb, PPP_PAP); + ppp_error("PAP authentication of peer failed (protocol-reject)"); + auth_peer_fail(pcb, PPP_PAP); } #endif /* PPP_SERVER */ upap_lowerdown(pcb); @@ -313,19 +313,19 @@ static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l) { */ inp = inpacket; if (l < UPAP_HEADERLEN) { - UPAPDEBUG(("pap_input: rcvd short header.")); - return; + UPAPDEBUG(("pap_input: rcvd short header.")); + return; } GETCHAR(code, inp); GETCHAR(id, inp); GETSHORT(len, inp); if (len < UPAP_HEADERLEN) { - UPAPDEBUG(("pap_input: rcvd illegal length.")); - return; + UPAPDEBUG(("pap_input: rcvd illegal length.")); + return; } if (len > l) { - UPAPDEBUG(("pap_input: rcvd short packet.")); - return; + UPAPDEBUG(("pap_input: rcvd short packet.")); + return; } len -= UPAP_HEADERLEN; @@ -335,20 +335,20 @@ static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l) { switch (code) { case UPAP_AUTHREQ: #if PPP_SERVER - upap_rauthreq(pcb, inp, id, len); + upap_rauthreq(pcb, inp, id, len); #endif /* PPP_SERVER */ - break; + break; case UPAP_AUTHACK: - upap_rauthack(pcb, inp, id, len); - break; + upap_rauthack(pcb, inp, id, len); + break; case UPAP_AUTHNAK: - upap_rauthnak(pcb, inp, id, len); - break; + upap_rauthnak(pcb, inp, id, len); + break; - default: /* XXX Need code reject */ - break; + default: /* XXX Need code reject */ + break; } } @@ -366,40 +366,40 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) { int msglen; if (pcb->upap.us_serverstate < UPAPSS_LISTEN) - return; + return; /* * If we receive a duplicate authenticate-request, we are * supposed to return the same status as for the first request. */ if (pcb->upap.us_serverstate == UPAPSS_OPEN) { - upap_sresp(pcb, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ - return; + upap_sresp(pcb, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ + return; } if (pcb->upap.us_serverstate == UPAPSS_BADAUTH) { - upap_sresp(pcb, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ - return; + upap_sresp(pcb, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ + return; } /* * Parse user/passwd. */ if (len < 1) { - UPAPDEBUG(("pap_rauth: rcvd short packet.")); - return; + UPAPDEBUG(("pap_rauth: rcvd short packet.")); + return; } GETCHAR(ruserlen, inp); len -= sizeof (u_char) + ruserlen + sizeof (u_char); if (len < 0) { - UPAPDEBUG(("pap_rauth: rcvd short packet.")); - return; + UPAPDEBUG(("pap_rauth: rcvd short packet.")); + return; } ruser = (char *) inp; INCPTR(ruserlen, inp); GETCHAR(rpasswdlen, inp); if (len < rpasswdlen) { - UPAPDEBUG(("pap_rauth: rcvd short packet.")); - return; + UPAPDEBUG(("pap_rauth: rcvd short packet.")); + return; } rpasswd = (char *) inp; @@ -420,16 +420,16 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) { * return an authenticate failure, is leaving it for us to verify. */ if (retcode == UPAP_AUTHACK) { - if (!auth_number()) { - /* We do not want to leak info about the pap result. */ - retcode = UPAP_AUTHNAK; /* XXX exit value will be "wrong" */ - warn("calling number %q is not authorized", remote_number); - } + if (!auth_number()) { + /* We do not want to leak info about the pap result. */ + retcode = UPAP_AUTHNAK; /* XXX exit value will be "wrong" */ + warn("calling number %q is not authorized", remote_number); + } } msglen = strlen(msg); if (msglen > 255) - msglen = 255; + msglen = 255; #endif /* UNUSED */ upap_sresp(pcb, retcode, id, msg, msglen); @@ -438,17 +438,17 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) { ppp_slprintf(rhostname, sizeof(rhostname), "%.*v", ruserlen, ruser); if (retcode == UPAP_AUTHACK) { - pcb->upap.us_serverstate = UPAPSS_OPEN; - ppp_notice("PAP peer authentication succeeded for %q", rhostname); - auth_peer_success(pcb, PPP_PAP, 0, ruser, ruserlen); + pcb->upap.us_serverstate = UPAPSS_OPEN; + ppp_notice("PAP peer authentication succeeded for %q", rhostname); + auth_peer_success(pcb, PPP_PAP, 0, ruser, ruserlen); } else { - pcb->upap.us_serverstate = UPAPSS_BADAUTH; - ppp_warn("PAP peer authentication failed for %q", rhostname); - auth_peer_fail(pcb, PPP_PAP); + pcb->upap.us_serverstate = UPAPSS_BADAUTH; + ppp_warn("PAP peer authentication failed for %q", rhostname); + auth_peer_fail(pcb, PPP_PAP); } if (pcb->settings.pap_req_timeout > 0) - UNTIMEOUT(upap_reqtimeout, pcb); + UNTIMEOUT(upap_reqtimeout, pcb); } #endif /* PPP_SERVER */ @@ -461,24 +461,24 @@ static void upap_rauthack(ppp_pcb *pcb, u_char *inp, int id, int len) { LWIP_UNUSED_ARG(id); if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */ - return; + return; /* * Parse message. */ if (len < 1) { - UPAPDEBUG(("pap_rauthack: ignoring missing msg-length.")); + UPAPDEBUG(("pap_rauthack: ignoring missing msg-length.")); } else { - GETCHAR(msglen, inp); - if (msglen > 0) { - len -= sizeof (u_char); - if (len < msglen) { - UPAPDEBUG(("pap_rauthack: rcvd short packet.")); - return; - } - msg = (char *) inp; - PRINTMSG(msg, msglen); - } + GETCHAR(msglen, inp); + if (msglen > 0) { + len -= sizeof (u_char); + if (len < msglen) { + UPAPDEBUG(("pap_rauthack: rcvd short packet.")); + return; + } + msg = (char *) inp; + PRINTMSG(msg, msglen); + } } pcb->upap.us_clientstate = UPAPCS_OPEN; @@ -496,24 +496,24 @@ static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len) { LWIP_UNUSED_ARG(id); if (pcb->upap.us_clientstate != UPAPCS_AUTHREQ) /* XXX */ - return; + return; /* * Parse message. */ if (len < 1) { - UPAPDEBUG(("pap_rauthnak: ignoring missing msg-length.")); + UPAPDEBUG(("pap_rauthnak: ignoring missing msg-length.")); } else { - GETCHAR(msglen, inp); - if (msglen > 0) { - len -= sizeof (u_char); - if (len < msglen) { - UPAPDEBUG(("pap_rauthnak: rcvd short packet.")); - return; - } - msg = (char *) inp; - PRINTMSG(msg, msglen); - } + GETCHAR(msglen, inp); + if (msglen > 0) { + len -= sizeof (u_char); + if (len < msglen) { + UPAPDEBUG(("pap_rauthnak: rcvd short packet.")); + return; + } + msg = (char *) inp; + PRINTMSG(msg, msglen); + } } pcb->upap.us_clientstate = UPAPCS_BADAUTH; @@ -532,7 +532,7 @@ static void upap_sauthreq(ppp_pcb *pcb) { int outlen; outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + - pcb->upap.us_userlen + pcb->upap.us_passwdlen; + pcb->upap.us_userlen + pcb->upap.us_passwdlen; p = pbuf_alloc(PBUF_RAW, (u16_t)(PPP_HDRLEN +outlen), PPP_CTRL_PBUF_TYPE); if(NULL == p) return; @@ -606,68 +606,68 @@ static int upap_printpkt(const u_char *p, int plen, void (*printer) (void *, con const u_char *pstart; if (plen < UPAP_HEADERLEN) - return 0; + return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < UPAP_HEADERLEN || len > plen) - return 0; + return 0; if (code >= 1 && code <= (int)LWIP_ARRAYSIZE(upap_codenames)) - printer(arg, " %s", upap_codenames[code-1]); + printer(arg, " %s", upap_codenames[code-1]); else - printer(arg, " code=0x%x", code); + printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= UPAP_HEADERLEN; switch (code) { case UPAP_AUTHREQ: - if (len < 1) - break; - ulen = p[0]; - if (len < ulen + 2) - break; - wlen = p[ulen + 1]; - if (len < ulen + wlen + 2) - break; - user = (const u_char *) (p + 1); - pwd = (const u_char *) (p + ulen + 2); - p += ulen + wlen + 2; - len -= ulen + wlen + 2; - printer(arg, " user="); - ppp_print_string(user, ulen, printer, arg); - printer(arg, " password="); + if (len < 1) + break; + ulen = p[0]; + if (len < ulen + 2) + break; + wlen = p[ulen + 1]; + if (len < ulen + wlen + 2) + break; + user = (const u_char *) (p + 1); + pwd = (const u_char *) (p + ulen + 2); + p += ulen + wlen + 2; + len -= ulen + wlen + 2; + printer(arg, " user="); + ppp_print_string(user, ulen, printer, arg); + printer(arg, " password="); /* FIXME: require ppp_pcb struct as printpkt() argument */ #if 0 - if (!pcb->settings.hide_password) + if (!pcb->settings.hide_password) #endif - ppp_print_string(pwd, wlen, printer, arg); + ppp_print_string(pwd, wlen, printer, arg); #if 0 - else - printer(arg, ""); + else + printer(arg, ""); #endif - break; + break; case UPAP_AUTHACK: case UPAP_AUTHNAK: - if (len < 1) - break; - mlen = p[0]; - if (len < mlen + 1) - break; - msg = (const u_char *) (p + 1); - p += mlen + 1; - len -= mlen + 1; - printer(arg, " "); - ppp_print_string(msg, mlen, printer, arg); - break; + if (len < 1) + break; + mlen = p[0]; + if (len < mlen + 1) + break; + msg = (const u_char *) (p + 1); + p += mlen + 1; + len -= mlen + 1; + printer(arg, " "); + ppp_print_string(msg, mlen, printer, arg); + break; default: - break; + break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { - GETCHAR(code, p); - printer(arg, " %.2x", code); + GETCHAR(code, p); + printer(arg, " %.2x", code); } return p - pstart; diff --git a/components/net/lwip-2.1.2/src/netif/ppp/utils.c b/components/net/lwip-2.1.2/src/netif/ppp/utils.c index f1366dae45..e9c8ba1cc4 100644 --- a/components/net/lwip-2.1.2/src/netif/ppp/utils.c +++ b/components/net/lwip-2.1.2/src/netif/ppp/utils.c @@ -72,7 +72,7 @@ static void ppp_log_write(int level, char *buf); #if PRINTPKT_SUPPORT static void ppp_vslp_printer(void *arg, const char *fmt, ...); static void ppp_format_packet(const u_char *p, int len, - void (*printer) (void *, const char *, ...), void *arg); + void (*printer) (void *, const char *, ...), void *arg); struct buffer_info { char *ptr; @@ -88,12 +88,12 @@ size_t ppp_strlcpy(char *dest, const char *src, size_t len) { size_t ret = strlen(src); if (len != 0) { - if (ret < len) - strcpy(dest, src); - else { - strncpy(dest, src, len - 1); - dest[len-1] = 0; - } + if (ret < len) + strcpy(dest, src); + else { + strncpy(dest, src, len - 1); + dest[len-1] = 0; + } } return ret; } @@ -130,7 +130,7 @@ int ppp_slprintf(char *buf, int buflen, const char *fmt, ...) { /* * ppp_vslprintf - like ppp_slprintf, takes a va_list instead of a list of args. */ -#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) +#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { int c, i, n; @@ -153,249 +153,249 @@ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) { buf0 = buf; --buflen; while (buflen > 0) { - for (f = fmt; *f != '%' && *f != 0; ++f) - ; - if (f > fmt) { - len = f - fmt; - if (len > buflen) - len = buflen; - memcpy(buf, fmt, len); - buf += len; - buflen -= len; - fmt = f; - } - if (*fmt == 0) - break; - c = *++fmt; - width = 0; - prec = -1; - fillch = ' '; - if (c == '0') { - fillch = '0'; - c = *++fmt; - } - if (c == '*') { - width = va_arg(args, int); - c = *++fmt; - } else { - while (lwip_isdigit(c)) { - width = width * 10 + c - '0'; - c = *++fmt; - } - } - if (c == '.') { - c = *++fmt; - if (c == '*') { - prec = va_arg(args, int); - c = *++fmt; - } else { - prec = 0; - while (lwip_isdigit(c)) { - prec = prec * 10 + c - '0'; - c = *++fmt; - } - } - } - str = 0; - base = 0; - neg = 0; - ++fmt; - switch (c) { - case 'l': - c = *fmt++; - switch (c) { - case 'd': - val = va_arg(args, long); - if ((long)val < 0) { - neg = 1; - val = (unsigned long)-(long)val; - } - base = 10; - break; - case 'u': - val = va_arg(args, unsigned long); - base = 10; - break; - default: - OUTCHAR('%'); - OUTCHAR('l'); - --fmt; /* so %lz outputs %lz etc. */ - continue; - } - break; - case 'd': - i = va_arg(args, int); - if (i < 0) { - neg = 1; - val = -i; - } else - val = i; - base = 10; - break; - case 'u': - val = va_arg(args, unsigned int); - base = 10; - break; - case 'o': - val = va_arg(args, unsigned int); - base = 8; - break; - case 'x': - case 'X': - val = va_arg(args, unsigned int); - base = 16; - break; + for (f = fmt; *f != '%' && *f != 0; ++f) + ; + if (f > fmt) { + len = f - fmt; + if (len > buflen) + len = buflen; + memcpy(buf, fmt, len); + buf += len; + buflen -= len; + fmt = f; + } + if (*fmt == 0) + break; + c = *++fmt; + width = 0; + prec = -1; + fillch = ' '; + if (c == '0') { + fillch = '0'; + c = *++fmt; + } + if (c == '*') { + width = va_arg(args, int); + c = *++fmt; + } else { + while (lwip_isdigit(c)) { + width = width * 10 + c - '0'; + c = *++fmt; + } + } + if (c == '.') { + c = *++fmt; + if (c == '*') { + prec = va_arg(args, int); + c = *++fmt; + } else { + prec = 0; + while (lwip_isdigit(c)) { + prec = prec * 10 + c - '0'; + c = *++fmt; + } + } + } + str = 0; + base = 0; + neg = 0; + ++fmt; + switch (c) { + case 'l': + c = *fmt++; + switch (c) { + case 'd': + val = va_arg(args, long); + if ((long)val < 0) { + neg = 1; + val = (unsigned long)-(long)val; + } + base = 10; + break; + case 'u': + val = va_arg(args, unsigned long); + base = 10; + break; + default: + OUTCHAR('%'); + OUTCHAR('l'); + --fmt; /* so %lz outputs %lz etc. */ + continue; + } + break; + case 'd': + i = va_arg(args, int); + if (i < 0) { + neg = 1; + val = -i; + } else + val = i; + base = 10; + break; + case 'u': + val = va_arg(args, unsigned int); + base = 10; + break; + case 'o': + val = va_arg(args, unsigned int); + base = 8; + break; + case 'x': + case 'X': + val = va_arg(args, unsigned int); + base = 16; + break; #if 0 /* unused (and wrong on LLP64 systems) */ - case 'p': - val = (unsigned long) va_arg(args, void *); - base = 16; - neg = 2; - break; + case 'p': + val = (unsigned long) va_arg(args, void *); + base = 16; + neg = 2; + break; #endif /* unused (and wrong on LLP64 systems) */ - case 's': - str = va_arg(args, char *); - break; - case 'c': - num[0] = va_arg(args, int); - num[1] = 0; - str = num; - break; + case 's': + str = va_arg(args, char *); + break; + case 'c': + num[0] = va_arg(args, int); + num[1] = 0; + str = num; + break; #if 0 /* do we always have strerror() in embedded ? */ - case 'm': - str = strerror(errno); - break; + case 'm': + str = strerror(errno); + break; #endif /* do we always have strerror() in embedded ? */ - case 'I': - ip = va_arg(args, u32_t); - ip = lwip_ntohl(ip); - ppp_slprintf(num, sizeof(num), "%d.%d.%d.%d", (ip >> 24) & 0xff, - (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); - str = num; - break; + case 'I': + ip = va_arg(args, u32_t); + ip = lwip_ntohl(ip); + ppp_slprintf(num, sizeof(num), "%d.%d.%d.%d", (ip >> 24) & 0xff, + (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); + str = num; + break; #if 0 /* need port */ - case 't': - time(&t); - str = ctime(&t); - str += 4; /* chop off the day name */ - str[15] = 0; /* chop off year and newline */ - break; + case 't': + time(&t); + str = ctime(&t); + str += 4; /* chop off the day name */ + str[15] = 0; /* chop off year and newline */ + break; #endif /* need port */ - case 'v': /* "visible" string */ - case 'q': /* quoted string */ - quoted = c == 'q'; - p = va_arg(args, unsigned char *); - if (p == NULL) - p = (const unsigned char *)""; - if (fillch == '0' && prec >= 0) { - n = prec; - } else { - n = strlen((const char *)p); - if (prec >= 0 && n > prec) - n = prec; - } - while (n > 0 && buflen > 0) { - c = *p++; - --n; - if (!quoted && c >= 0x80) { - OUTCHAR('M'); - OUTCHAR('-'); - c -= 0x80; - } - if (quoted && (c == '"' || c == '\\')) - OUTCHAR('\\'); - if (c < 0x20 || (0x7f <= c && c < 0xa0)) { - if (quoted) { - OUTCHAR('\\'); - switch (c) { - case '\t': OUTCHAR('t'); break; - case '\n': OUTCHAR('n'); break; - case '\b': OUTCHAR('b'); break; - case '\f': OUTCHAR('f'); break; - default: - OUTCHAR('x'); - OUTCHAR(hexchars[c >> 4]); - OUTCHAR(hexchars[c & 0xf]); - } - } else { - if (c == '\t') - OUTCHAR(c); - else { - OUTCHAR('^'); - OUTCHAR(c ^ 0x40); - } - } - } else - OUTCHAR(c); - } - continue; + case 'v': /* "visible" string */ + case 'q': /* quoted string */ + quoted = c == 'q'; + p = va_arg(args, unsigned char *); + if (p == NULL) + p = (const unsigned char *)""; + if (fillch == '0' && prec >= 0) { + n = prec; + } else { + n = strlen((const char *)p); + if (prec >= 0 && n > prec) + n = prec; + } + while (n > 0 && buflen > 0) { + c = *p++; + --n; + if (!quoted && c >= 0x80) { + OUTCHAR('M'); + OUTCHAR('-'); + c -= 0x80; + } + if (quoted && (c == '"' || c == '\\')) + OUTCHAR('\\'); + if (c < 0x20 || (0x7f <= c && c < 0xa0)) { + if (quoted) { + OUTCHAR('\\'); + switch (c) { + case '\t': OUTCHAR('t'); break; + case '\n': OUTCHAR('n'); break; + case '\b': OUTCHAR('b'); break; + case '\f': OUTCHAR('f'); break; + default: + OUTCHAR('x'); + OUTCHAR(hexchars[c >> 4]); + OUTCHAR(hexchars[c & 0xf]); + } + } else { + if (c == '\t') + OUTCHAR(c); + else { + OUTCHAR('^'); + OUTCHAR(c ^ 0x40); + } + } + } else + OUTCHAR(c); + } + continue; #if PRINTPKT_SUPPORT - case 'P': /* print PPP packet */ - bufinfo.ptr = buf; - bufinfo.len = buflen + 1; - p = va_arg(args, unsigned char *); - n = va_arg(args, int); - ppp_format_packet(p, n, ppp_vslp_printer, &bufinfo); - buf = bufinfo.ptr; - buflen = bufinfo.len - 1; - continue; + case 'P': /* print PPP packet */ + bufinfo.ptr = buf; + bufinfo.len = buflen + 1; + p = va_arg(args, unsigned char *); + n = va_arg(args, int); + ppp_format_packet(p, n, ppp_vslp_printer, &bufinfo); + buf = bufinfo.ptr; + buflen = bufinfo.len - 1; + continue; #endif /* PRINTPKT_SUPPORT */ - case 'B': - p = va_arg(args, unsigned char *); - for (n = prec; n > 0; --n) { - c = *p++; - if (fillch == ' ') - OUTCHAR(' '); - OUTCHAR(hexchars[(c >> 4) & 0xf]); - OUTCHAR(hexchars[c & 0xf]); - } - continue; - default: - *buf++ = '%'; - if (c != '%') - --fmt; /* so %z outputs %z etc. */ - --buflen; - continue; - } - if (base != 0) { - str = num + sizeof(num); - *--str = 0; - while (str > num + neg) { - *--str = hexchars[val % base]; - val = val / base; - if (--prec <= 0 && val == 0) - break; - } - switch (neg) { - case 1: - *--str = '-'; - break; - case 2: - *--str = 'x'; - *--str = '0'; - break; - default: - break; - } - len = num + sizeof(num) - 1 - str; - } else { - len = strlen(str); - if (prec >= 0 && len > prec) - len = prec; - } - if (width > 0) { - if (width > buflen) - width = buflen; - if ((n = width - len) > 0) { - buflen -= n; - for (; n > 0; --n) - *buf++ = fillch; - } - } - if (len > buflen) - len = buflen; - memcpy(buf, str, len); - buf += len; - buflen -= len; + case 'B': + p = va_arg(args, unsigned char *); + for (n = prec; n > 0; --n) { + c = *p++; + if (fillch == ' ') + OUTCHAR(' '); + OUTCHAR(hexchars[(c >> 4) & 0xf]); + OUTCHAR(hexchars[c & 0xf]); + } + continue; + default: + *buf++ = '%'; + if (c != '%') + --fmt; /* so %z outputs %z etc. */ + --buflen; + continue; + } + if (base != 0) { + str = num + sizeof(num); + *--str = 0; + while (str > num + neg) { + *--str = hexchars[val % base]; + val = val / base; + if (--prec <= 0 && val == 0) + break; + } + switch (neg) { + case 1: + *--str = '-'; + break; + case 2: + *--str = 'x'; + *--str = '0'; + break; + default: + break; + } + len = num + sizeof(num) - 1 - str; + } else { + len = strlen(str); + if (prec >= 0 && len > prec) + len = prec; + } + if (width > 0) { + if (width > buflen) + width = buflen; + if ((n = width - len) > 0) { + buflen -= n; + for (; n > 0; --n) + *buf++ = fillch; + } + } + if (len > buflen) + len = buflen; + memcpy(buf, str, len); + buf += len; + buflen -= len; } *buf = 0; return buf - buf0; @@ -432,9 +432,9 @@ log_packet(p, len, prefix, level) char *prefix; int level; { - init_pr_log(prefix, level); - ppp_format_packet(p, len, pr_log, &level); - end_pr_log(); + init_pr_log(prefix, level); + ppp_format_packet(p, len, pr_log, &level); + end_pr_log(); } #endif /* UNUSED */ @@ -444,43 +444,43 @@ log_packet(p, len, prefix, level) * calling `printer(arg, format, ...)' to output it. */ static void ppp_format_packet(const u_char *p, int len, - void (*printer) (void *, const char *, ...), void *arg) { + void (*printer) (void *, const char *, ...), void *arg) { int i, n; u_short proto; const struct protent *protp; if (len >= 2) { - GETSHORT(proto, p); - len -= 2; - for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (proto == protp->protocol) - break; - if (protp != NULL) { - printer(arg, "[%s", protp->name); - n = (*protp->printpkt)(p, len, printer, arg); - printer(arg, "]"); - p += n; - len -= n; - } else { - for (i = 0; (protp = protocols[i]) != NULL; ++i) - if (proto == (protp->protocol & ~0x8000)) - break; - if (protp != 0 && protp->data_name != 0) { - printer(arg, "[%s data]", protp->data_name); - if (len > 8) - printer(arg, "%.8B ...", p); - else - printer(arg, "%.*B", len, p); - len = 0; - } else - printer(arg, "[proto=0x%x]", proto); - } + GETSHORT(proto, p); + len -= 2; + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (proto == protp->protocol) + break; + if (protp != NULL) { + printer(arg, "[%s", protp->name); + n = (*protp->printpkt)(p, len, printer, arg); + printer(arg, "]"); + p += n; + len -= n; + } else { + for (i = 0; (protp = protocols[i]) != NULL; ++i) + if (proto == (protp->protocol & ~0x8000)) + break; + if (protp != 0 && protp->data_name != 0) { + printer(arg, "[%s data]", protp->data_name); + if (len > 8) + printer(arg, "%.8B ...", p); + else + printer(arg, "%.*B", len, p); + len = 0; + } else + printer(arg, "[proto=0x%x]", proto); + } } if (len > 32) - printer(arg, "%.32B ...", p); + printer(arg, "%.32B ...", p); else - printer(arg, "%.*B", len, p); + printer(arg, "%.*B", len, p); } #endif /* PRINTPKT_SUPPORT */ @@ -489,30 +489,30 @@ static void ppp_format_packet(const u_char *p, int len, * init_pr_log, end_pr_log - initialize and finish use of pr_log. */ -static char line[256]; /* line to be logged accumulated here */ -static char *linep; /* current pointer within line */ -static int llevel; /* level for logging */ +static char line[256]; /* line to be logged accumulated here */ +static char *linep; /* current pointer within line */ +static int llevel; /* level for logging */ void init_pr_log(prefix, level) const char *prefix; int level; { - linep = line; - if (prefix != NULL) { - ppp_strlcpy(line, prefix, sizeof(line)); - linep = line + strlen(line); - } - llevel = level; + linep = line; + if (prefix != NULL) { + ppp_strlcpy(line, prefix, sizeof(line)); + linep = line + strlen(line); + } + llevel = level; } void end_pr_log() { - if (linep != line) { - *linep = 0; - ppp_log_write(llevel, line); - } + if (linep != line) { + *linep = 0; + ppp_log_write(llevel, line); + } } /* @@ -521,47 +521,47 @@ end_pr_log() void pr_log (void *arg, const char *fmt, ...) { - int l, n; - va_list pvar; - char *p, *eol; - char buf[256]; - - va_start(pvar, fmt); - n = ppp_vslprintf(buf, sizeof(buf), fmt, pvar); - va_end(pvar); - - p = buf; - eol = strchr(buf, '\n'); - if (linep != line) { - l = (eol == NULL)? n: eol - buf; - if (linep + l < line + sizeof(line)) { - if (l > 0) { - memcpy(linep, buf, l); - linep += l; - } - if (eol == NULL) - return; - p = eol + 1; - eol = strchr(p, '\n'); - } - *linep = 0; - ppp_log_write(llevel, line); - linep = line; - } - - while (eol != NULL) { - *eol = 0; - ppp_log_write(llevel, p); - p = eol + 1; - eol = strchr(p, '\n'); - } - - /* assumes sizeof(buf) <= sizeof(line) */ - l = buf + n - p; - if (l > 0) { - memcpy(line, p, n); - linep = line + l; - } + int l, n; + va_list pvar; + char *p, *eol; + char buf[256]; + + va_start(pvar, fmt); + n = ppp_vslprintf(buf, sizeof(buf), fmt, pvar); + va_end(pvar); + + p = buf; + eol = strchr(buf, '\n'); + if (linep != line) { + l = (eol == NULL)? n: eol - buf; + if (linep + l < line + sizeof(line)) { + if (l > 0) { + memcpy(linep, buf, l); + linep += l; + } + if (eol == NULL) + return; + p = eol + 1; + eol = strchr(p, '\n'); + } + *linep = 0; + ppp_log_write(llevel, line); + linep = line; + } + + while (eol != NULL) { + *eol = 0; + ppp_log_write(llevel, p); + p = eol + 1; + eol = strchr(p, '\n'); + } + + /* assumes sizeof(buf) <= sizeof(line) */ + l = buf + n - p; + if (l > 0) { + memcpy(line, p, n); + linep = line + l; + } } #endif /* UNUSED */ @@ -574,27 +574,27 @@ void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const c printer(arg, "\""); for (; len > 0; --len) { - c = *p++; - if (' ' <= c && c <= '~') { - if (c == '\\' || c == '"') - printer(arg, "\\"); - printer(arg, "%c", c); - } else { - switch (c) { - case '\n': - printer(arg, "\\n"); - break; - case '\r': - printer(arg, "\\r"); - break; - case '\t': - printer(arg, "\\t"); - break; - default: - printer(arg, "\\%.3o", (u8_t)c); - /* no break */ - } - } + c = *p++; + if (' ' <= c && c <= '~') { + if (c == '\\' || c == '"') + printer(arg, "\\"); + printer(arg, "%c", c); + } else { + switch (c) { + case '\n': + printer(arg, "\\n"); + break; + case '\r': + printer(arg, "\\r"); + break; + case '\t': + printer(arg, "\\t"); + break; + default: + printer(arg, "\\%.3o", (u8_t)c); + /* no break */ + } + } } printer(arg, "\""); } @@ -615,13 +615,13 @@ static void ppp_log_write(int level, char *buf) { PPPDEBUG(level, ("%s\n", buf) ); #if 0 if (log_to_fd >= 0 && (level != LOG_DEBUG || debug)) { - int n = strlen(buf); + int n = strlen(buf); - if (n > 0 && buf[n-1] == '\n') - --n; - if (write(log_to_fd, buf, n) != n - || write(log_to_fd, "\n", 1) != 1) - log_to_fd = -1; + if (n > 0 && buf[n-1] == '\n') + --n; + if (write(log_to_fd, buf, n) != n + || write(log_to_fd, "\n", 1) != 1) + log_to_fd = -1; } #endif } @@ -710,18 +710,18 @@ void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len) { */ proto = (p[0] << 8) + p[1]; if (proto < 0xC000 && (proto & ~0x8000) == proto) - return; + return; /* * don't print valid LCP echo request/reply packets if the link is up. */ if (proto == PPP_LCP && pcb->phase == PPP_PHASE_RUNNING && len >= 2 + HEADERLEN) { - unsigned char *lcp = p + 2; - int l = (lcp[2] << 8) + lcp[3]; + unsigned char *lcp = p + 2; + int l = (lcp[2] << 8) + lcp[3]; - if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP) - && l >= HEADERLEN && l <= len - 2) - return; + if ((lcp[0] == ECHOREQ || lcp[0] == ECHOREP) + && l >= HEADERLEN && l <= len - 2) + return; } ppp_dbglog("%s %P", tag, p, len); @@ -737,34 +737,34 @@ void ppp_dump_packet(ppp_pcb *pcb, const char *tag, unsigned char *p, int len) { ssize_t complete_read(int fd, void *buf, size_t count) { - size_t done; - ssize_t nb; - char *ptr = buf; - - for (done = 0; done < count; ) { - nb = read(fd, ptr, count - done); - if (nb < 0) { - if (errno == EINTR) - continue; - return -1; - } - if (nb == 0) - break; - done += nb; - ptr += nb; - } - return done; + size_t done; + ssize_t nb; + char *ptr = buf; + + for (done = 0; done < count; ) { + nb = read(fd, ptr, count - done); + if (nb < 0) { + if (errno == EINTR) + continue; + return -1; + } + if (nb == 0) + break; + done += nb; + ptr += nb; + } + return done; } /* Procedures for locking the serial device using a lock file. */ #ifndef LOCK_DIR #ifdef __linux__ -#define LOCK_DIR "/var/lock" +#define LOCK_DIR "/var/lock" #else #ifdef SVR4 -#define LOCK_DIR "/var/spool/locks" +#define LOCK_DIR "/var/spool/locks" #else -#define LOCK_DIR "/var/spool/lock" +#define LOCK_DIR "/var/spool/lock" #endif #endif #endif /* LOCK_DIR */ @@ -783,14 +783,14 @@ lock(dev) result = mklock (dev, (void *) 0); if (result == 0) { - ppp_strlcpy(lock_file, dev, sizeof(lock_file)); - return 0; + ppp_strlcpy(lock_file, dev, sizeof(lock_file)); + return 0; } if (result > 0) ppp_notice("Device %s is locked by pid %d", dev, result); else - ppp_error("Can't create lock file %s", lock_file); + ppp_error("Can't create lock file %s", lock_file); return -1; #else /* LOCKLIB */ @@ -802,83 +802,83 @@ lock(dev) struct stat sbuf; if (stat(dev, &sbuf) < 0) { - ppp_error("Can't get device number for %s: %m", dev); - return -1; + ppp_error("Can't get device number for %s: %m", dev); + return -1; } if ((sbuf.st_mode & S_IFMT) != S_IFCHR) { - ppp_error("Can't lock %s: not a character device", dev); - return -1; + ppp_error("Can't lock %s: not a character device", dev); + return -1; } ppp_slprintf(lock_file, sizeof(lock_file), "%s/LK.%03d.%03d.%03d", - LOCK_DIR, major(sbuf.st_dev), - major(sbuf.st_rdev), minor(sbuf.st_rdev)); + LOCK_DIR, major(sbuf.st_dev), + major(sbuf.st_rdev), minor(sbuf.st_rdev)); #else char *p; char lockdev[MAXPATHLEN]; if ((p = strstr(dev, "dev/")) != NULL) { - dev = p + 4; - strncpy(lockdev, dev, MAXPATHLEN-1); - lockdev[MAXPATHLEN-1] = 0; - while ((p = strrchr(lockdev, '/')) != NULL) { - *p = '_'; - } - dev = lockdev; + dev = p + 4; + strncpy(lockdev, dev, MAXPATHLEN-1); + lockdev[MAXPATHLEN-1] = 0; + while ((p = strrchr(lockdev, '/')) != NULL) { + *p = '_'; + } + dev = lockdev; } else - if ((p = strrchr(dev, '/')) != NULL) - dev = p + 1; + if ((p = strrchr(dev, '/')) != NULL) + dev = p + 1; ppp_slprintf(lock_file, sizeof(lock_file), "%s/LCK..%s", LOCK_DIR, dev); #endif while ((fd = open(lock_file, O_EXCL | O_CREAT | O_RDWR, 0644)) < 0) { - if (errno != EEXIST) { - ppp_error("Can't create lock file %s: %m", lock_file); - break; - } - - /* Read the lock file to find out who has the device locked. */ - fd = open(lock_file, O_RDONLY, 0); - if (fd < 0) { - if (errno == ENOENT) /* This is just a timing problem. */ - continue; - ppp_error("Can't open existing lock file %s: %m", lock_file); - break; - } + if (errno != EEXIST) { + ppp_error("Can't create lock file %s: %m", lock_file); + break; + } + + /* Read the lock file to find out who has the device locked. */ + fd = open(lock_file, O_RDONLY, 0); + if (fd < 0) { + if (errno == ENOENT) /* This is just a timing problem. */ + continue; + ppp_error("Can't open existing lock file %s: %m", lock_file); + break; + } #ifndef LOCK_BINARY - n = read(fd, lock_buffer, 11); + n = read(fd, lock_buffer, 11); #else - n = read(fd, &pid, sizeof(pid)); + n = read(fd, &pid, sizeof(pid)); #endif /* LOCK_BINARY */ - close(fd); - fd = -1; - if (n <= 0) { - ppp_error("Can't read pid from lock file %s", lock_file); - break; - } - - /* See if the process still exists. */ + close(fd); + fd = -1; + if (n <= 0) { + ppp_error("Can't read pid from lock file %s", lock_file); + break; + } + + /* See if the process still exists. */ #ifndef LOCK_BINARY - lock_buffer[n] = 0; - pid = atoi(lock_buffer); + lock_buffer[n] = 0; + pid = atoi(lock_buffer); #endif /* LOCK_BINARY */ - if (pid == getpid()) - return 1; /* somebody else locked it for us */ - if (pid == 0 - || (kill(pid, 0) == -1 && errno == ESRCH)) { - if (unlink (lock_file) == 0) { - ppp_notice("Removed stale lock on %s (pid %d)", dev, pid); - continue; - } - ppp_warn("Couldn't remove stale lock on %s", dev); - } else - ppp_notice("Device %s is locked by pid %d", dev, pid); - break; + if (pid == getpid()) + return 1; /* somebody else locked it for us */ + if (pid == 0 + || (kill(pid, 0) == -1 && errno == ESRCH)) { + if (unlink (lock_file) == 0) { + ppp_notice("Removed stale lock on %s (pid %d)", dev, pid); + continue; + } + ppp_warn("Couldn't remove stale lock on %s", dev); + } else + ppp_notice("Device %s is locked by pid %d", dev, pid); + break; } if (fd < 0) { - lock_file[0] = 0; - return -1; + lock_file[0] = 0; + return -1; } pid = getpid(); @@ -916,12 +916,12 @@ relock(pid) char lock_buffer[12]; if (lock_file[0] == 0) - return -1; + return -1; fd = open(lock_file, O_WRONLY, 0); if (fd < 0) { - ppp_error("Couldn't reopen lock file %s: %m", lock_file); - lock_file[0] = 0; - return -1; + ppp_error("Couldn't reopen lock file %s: %m", lock_file); + lock_file[0] = 0; + return -1; } #ifndef LOCK_BINARY @@ -944,11 +944,11 @@ unlock() { if (lock_file[0]) { #ifdef LOCKLIB - (void) rmlock(lock_file, (void *) 0); + (void) rmlock(lock_file, (void *) 0); #else - unlink(lock_file); + unlink(lock_file); #endif - lock_file[0] = 0; + lock_file[0] = 0; } } diff --git a/components/net/lwip-2.1.2/test/fuzz/fuzz.c b/components/net/lwip-2.1.2/test/fuzz/fuzz.c index 8aa07ecc26..ecebc57052 100644 --- a/components/net/lwip-2.1.2/test/fuzz/fuzz.c +++ b/components/net/lwip-2.1.2/test/fuzz/fuzz.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Erik Ekman * */ diff --git a/components/net/lwip-2.1.2/test/fuzz/lwipopts.h b/components/net/lwip-2.1.2/test/fuzz/lwipopts.h index 4ab26f289b..50e60806b1 100644 --- a/components/net/lwip-2.1.2/test/fuzz/lwipopts.h +++ b/components/net/lwip-2.1.2/test/fuzz/lwipopts.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.c b/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.c index 3ac553b151..e73cfe3bb1 100644 --- a/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.c +++ b/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.c @@ -16,12 +16,12 @@ * - full duplex * - add asserts about internal socket/netconn/pcb state? */ - + /* * Copyright (c) 2017 Simon Goldschmidt * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * + * 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, @@ -30,21 +30,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.h b/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.h index 178e604ae6..256ea000fc 100644 --- a/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.h +++ b/components/net/lwip-2.1.2/test/sockets/sockets_stresstest.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2017 Simon Goldschmidt * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.1.2/test/unit/api/test_sockets.c b/components/net/lwip-2.1.2/test/unit/api/test_sockets.c index 472fa48950..ed2b811275 100644 --- a/components/net/lwip-2.1.2/test/unit/api/test_sockets.c +++ b/components/net/lwip-2.1.2/test/unit/api/test_sockets.c @@ -255,7 +255,7 @@ static void test_sockets_msgapi_update_iovs(struct msghdr *msg, size_t bytes) /* note: this modifies the underyling iov_base and iov_len for a partial read for an individual vector. This updates the msg->msg_iov pointer to skip fully consumed vecotrs */ - + /* process fully consumed vectors */ for (i = 0; i < msg->msg_iovlen; i++) { if (msg->msg_iov[i].iov_len <= bytes) { @@ -395,7 +395,7 @@ static void test_sockets_msgapi_tcp(int domain) /* note: since we always receive after sending, there will be open space in the send buffer */ fail_unless(ret > 0); - + bytes_written += ret; if (bytes_written < TOTAL_DATA_SZ) { test_sockets_msgapi_update_iovs(&smsg, (size_t)ret); @@ -432,7 +432,7 @@ static void test_sockets_msgapi_tcp(int domain) } } while(ret > 0); } - + ret = lwip_close(s1); fail_unless(ret == 0); ret = lwip_close(s2); @@ -588,13 +588,13 @@ static void test_sockets_msgapi_cmsg(int domain) memset(rcv_buf, 0, sizeof(rcv_buf)); ret = lwip_sendto(s, snd_buf, sizeof(snd_buf), 0, (struct sockaddr*)&addr_storage, addr_size); fail_unless(ret == sizeof(snd_buf)); - + tcpip_thread_poll_one(); ret = lwip_recvmsg(s, &msg, 0); fail_unless(ret == sizeof(rcv_buf)); fail_unless(!memcmp(rcv_buf, snd_buf, sizeof(rcv_buf))); - + /* Verify message header */ cmsg = CMSG_FIRSTHDR(&msg); fail_unless(cmsg != NULL); diff --git a/components/net/lwip-2.1.2/test/unit/arch/sys_arch.c b/components/net/lwip-2.1.2/test/unit/arch/sys_arch.c index cf826ebfe3..a84e3784e9 100644 --- a/components/net/lwip-2.1.2/test/unit/arch/sys_arch.c +++ b/components/net/lwip-2.1.2/test/unit/arch/sys_arch.c @@ -1,8 +1,8 @@ /* * Copyright (c) 2017 Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.1.2/test/unit/arch/sys_arch.h b/components/net/lwip-2.1.2/test/unit/arch/sys_arch.h index 331c2f2f15..ef829decb9 100644 --- a/components/net/lwip-2.1.2/test/unit/arch/sys_arch.h +++ b/components/net/lwip-2.1.2/test/unit/arch/sys_arch.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2017 Simon Goldschmidt - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.1.2/test/unit/core/test_timers.c b/components/net/lwip-2.1.2/test/unit/core/test_timers.c index 820b718924..30f6ac4cd8 100644 --- a/components/net/lwip-2.1.2/test/unit/core/test_timers.c +++ b/components/net/lwip-2.1.2/test/unit/core/test_timers.c @@ -61,7 +61,7 @@ do_test_cyclic_timers(u32_t offset) fail_unless(cyclic_fired == 1); fail_unless((*list_head)->time == (u32_t)(lwip_sys_now + test_cyclic.interval_ms - HANDLER_EXECUTION_TIME)); - + sys_untimeout(lwip_cyclic_timer, &test_cyclic); @@ -128,7 +128,7 @@ static void do_test_timers(u32_t offset) { struct sys_timeo** list_head = sys_timeouts_get_next_timeout(); - + lwip_sys_now = offset + 0; sys_timeout(10, dummy_handler, LWIP_PTR_NUMERIC_CAST(void*, 0)); @@ -142,7 +142,7 @@ do_test_timers(u32_t offset) fail_unless((*list_head)->time == (u32_t)(lwip_sys_now + 5)); fail_unless((*list_head)->next->time == (u32_t)(lwip_sys_now + 10)); fail_unless((*list_head)->next->next->time == (u32_t)(lwip_sys_now + 20)); - + /* check timers expire in correct order */ memset(&fired, 0, sizeof(fired)); diff --git a/components/net/lwip-2.1.2/test/unit/lwipopts.h b/components/net/lwip-2.1.2/test/unit/lwipopts.h index c00ace1561..7f077d21db 100644 --- a/components/net/lwip-2.1.2/test/unit/lwipopts.h +++ b/components/net/lwip-2.1.2/test/unit/lwipopts.h @@ -1,8 +1,8 @@ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modification, + * 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, @@ -11,21 +11,21 @@ * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT - * SHALL THE AUTHOR 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 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT + * SHALL THE AUTHOR 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. * * This file is part of the lwIP TCP/IP stack. - * + * * Author: Simon Goldschmidt * */ diff --git a/components/net/lwip-2.1.2/test/unit/tcp/tcp_helper.c b/components/net/lwip-2.1.2/test/unit/tcp/tcp_helper.c index 8689b71ac8..feaa3e5df1 100644 --- a/components/net/lwip-2.1.2/test/unit/tcp/tcp_helper.c +++ b/components/net/lwip-2.1.2/test/unit/tcp/tcp_helper.c @@ -151,13 +151,13 @@ tcp_set_state(struct tcp_pcb* pcb, enum tcp_state state, const ip_addr_t* local_ /* @todo: are these all states? */ /* @todo: remove from previous list */ pcb->state = state; - + iss = tcp_next_iss(pcb); pcb->snd_wl2 = iss; pcb->snd_nxt = iss; pcb->lastack = iss; pcb->snd_lbb = iss; - + if (state == ESTABLISHED) { TCP_REG(&tcp_active_pcbs, pcb); ip_addr_copy(pcb->local_ip, *local_ip); diff --git a/components/net/lwip-2.1.2/test/unit/tcp/test_tcp.c b/components/net/lwip-2.1.2/test/unit/tcp/test_tcp.c index c7f85f6a16..941e4f42d9 100644 --- a/components/net/lwip-2.1.2/test/unit/tcp/test_tcp.c +++ b/components/net/lwip-2.1.2/test/unit/tcp/test_tcp.c @@ -524,7 +524,7 @@ START_TEST(test_tcp_fast_retx_recover) EXPECT_RET(pcb->dupacks == 3); memset(&txcounters, 0, sizeof(txcounters)); /* @todo: check expected data?*/ - + /* send data5, not output yet */ err = tcp_write(pcb, data5, sizeof(data5), TCP_WRITE_FLAG_COPY); EXPECT_RET(err == ERR_OK); @@ -1263,7 +1263,7 @@ static void test_tcp_rto_timeout_impl(int link_down) /* check our pcb is no longer active */ for (cur = tcp_active_pcbs; cur != NULL; cur = cur->next) { EXPECT(cur != pcb); - } + } EXPECT_RET(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); } @@ -1359,7 +1359,7 @@ static void test_tcp_rto_timeout_syn_sent_impl(int link_down) /* check our pcb is no longer active */ for (cur = tcp_active_pcbs; cur != NULL; cur = cur->next) { EXPECT(cur != pcb); - } + } EXPECT_RET(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); } @@ -1409,7 +1409,7 @@ static void test_tcp_zwp_timeout_impl(int link_down) EXPECT(err == ERR_OK); err = tcp_output(pcb); EXPECT(err == ERR_OK); - + /* verify segment is in-flight */ EXPECT(pcb->unsent == NULL); check_seqnos(pcb->unacked, 1, seqnos); @@ -1488,7 +1488,7 @@ static void test_tcp_zwp_timeout_impl(int link_down) /* check our pcb is no longer active */ for (cur = tcp_active_pcbs; cur != NULL; cur = cur->next) { EXPECT(cur != pcb); - } + } EXPECT_RET(MEMP_STATS_GET(used, MEMP_TCP_PCB) == 0); } diff --git a/components/net/lwip_dhcpd/dhcp_server_raw.c b/components/net/lwip_dhcpd/dhcp_server_raw.c index 6c786301be..92fd11671c 100644 --- a/components/net/lwip_dhcpd/dhcp_server_raw.c +++ b/components/net/lwip_dhcpd/dhcp_server_raw.c @@ -26,7 +26,7 @@ * 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. - * + * * Change Logs: * Date Author Notes * 2014-04-01 Ren.Haibo the first version diff --git a/components/net/netdev/include/arpa/inet.h b/components/net/netdev/include/arpa/inet.h index 085e15dcbc..9072dffb79 100644 --- a/components/net/netdev/include/arpa/inet.h +++ b/components/net/netdev/include/arpa/inet.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/netdev/include/netdev.h b/components/net/netdev/include/netdev.h index e11a8929b0..16da0e502c 100644 --- a/components/net/netdev/include/netdev.h +++ b/components/net/netdev/include/netdev.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -79,8 +79,8 @@ struct netdev_ops; /* network interface device object */ struct netdev { - rt_slist_t list; - + rt_slist_t list; + char name[RT_NAME_MAX]; /* network interface device name */ ip_addr_t ip_addr; /* IP address */ ip_addr_t netmask; /* subnet mask */ @@ -91,11 +91,11 @@ struct netdev ip_addr_t dns_servers[NETDEV_DNS_SERVERS_NUM]; /* DNS server */ uint8_t hwaddr_len; /* hardware address length */ uint8_t hwaddr[NETDEV_HWADDR_MAX_LEN]; /* hardware address */ - + uint16_t flags; /* network interface device status flag */ uint16_t mtu; /* maximum transfer unit (in bytes) */ const struct netdev_ops *ops; /* network interface device operations */ - + netdev_callback_fn status_callback; /* network interface device flags change callback */ netdev_callback_fn addr_callback; /* network interface device address information change callback */ diff --git a/components/net/netdev/include/netdev_ipaddr.h b/components/net/netdev/include/netdev_ipaddr.h index 65970ec5b7..08ea50ed9d 100644 --- a/components/net/netdev/include/netdev_ipaddr.h +++ b/components/net/netdev/include/netdev_ipaddr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -23,30 +23,30 @@ extern "C" { * On subnets, the decomposition of addresses to host and net parts * is done according to subnet mask, not the masks here. */ -#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) -#define IN_CLASSA_NET 0xff000000 -#define IN_CLASSA_NSHIFT 24 -#define IN_CLASSA_HOST 0x00ffffff -#define IN_CLASSA_MAX 128 +#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0) +#define IN_CLASSA_NET 0xff000000 +#define IN_CLASSA_NSHIFT 24 +#define IN_CLASSA_HOST 0x00ffffff +#define IN_CLASSA_MAX 128 -#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) -#define IN_CLASSB_NET 0xffff0000 -#define IN_CLASSB_NSHIFT 16 -#define IN_CLASSB_HOST 0x0000ffff -#define IN_CLASSB_MAX 65536 +#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSB_NET 0xffff0000 +#define IN_CLASSB_NSHIFT 16 +#define IN_CLASSB_HOST 0x0000ffff +#define IN_CLASSB_MAX 65536 -#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) -#define IN_CLASSC_NET 0xffffff00 -#define IN_CLASSC_NSHIFT 8 -#define IN_CLASSC_HOST 0x000000ff +#define IN_CLASSC(i) (((long)(i) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC_NET 0xffffff00 +#define IN_CLASSC_NSHIFT 8 +#define IN_CLASSC_HOST 0x000000ff -#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) -#define IN_MULTICAST(i) IN_CLASSD(i) +#define IN_CLASSD(i) (((long)(i) & 0xf0000000) == 0xe0000000) +#define IN_MULTICAST(i) IN_CLASSD(i) -#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) -#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) +#define IN_EXPERIMENTAL(i) (((long)(i) & 0xe0000000) == 0xe0000000) +#define IN_BADCLASS(i) (((long)(i) & 0xf0000000) == 0xf0000000) -#define IN_LOOPBACKNET 127 /* official! */ +#define IN_LOOPBACKNET 127 /* official! */ /* IP address types for use in ip_addr_t.type member */ enum netdev_ip_addr_type { @@ -307,7 +307,7 @@ const char *netdev_inet_ntop(int af, const void *src, char *dst, int32_t size); int netdev_inet_pton(int af, const char *src, void *dst); #define inet_ntop(af, src, dst, size) netdev_inet_ntop(af, src, dst, size) -#define inet_pton(af, src, dst) netdev_inet_pton(af, src, dst) +#define inet_pton(af, src, dst) netdev_inet_pton(af, src, dst) #ifdef __cplusplus } diff --git a/components/net/netdev/src/netdev.c b/components/net/netdev/src/netdev.c index cef11847f9..3f7aa401c1 100644 --- a/components/net/netdev/src/netdev.c +++ b/components/net/netdev/src/netdev.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/netdev/src/netdev_ipaddr.c b/components/net/netdev/src/netdev_ipaddr.c index a70a90bb75..9abb41bd14 100644 --- a/components/net/netdev/src/netdev_ipaddr.c +++ b/components/net/netdev/src/netdev_ipaddr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/dfs_net/dfs_net.c b/components/net/sal_socket/dfs_net/dfs_net.c index f1a3d777a1..67b652c320 100644 --- a/components/net/sal_socket/dfs_net/dfs_net.c +++ b/components/net/sal_socket/dfs_net/dfs_net.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -21,7 +21,7 @@ int dfs_net_getsocket(int fd) { int socket; - struct dfs_fd *_dfs_fd; + struct dfs_fd *_dfs_fd; _dfs_fd = fd_get(fd); if (_dfs_fd == NULL) return -1; @@ -68,7 +68,7 @@ static int dfs_net_poll(struct dfs_fd *file, struct rt_pollreq *req) return sal_poll(file, req); } -const struct dfs_file_ops _net_fops = +const struct dfs_file_ops _net_fops = { NULL, /* open */ dfs_net_close, diff --git a/components/net/sal_socket/impl/af_inet.h b/components/net/sal_socket/impl/af_inet.h index caffbe1400..421d15bfae 100644 --- a/components/net/sal_socket/impl/af_inet.h +++ b/components/net/sal_socket/impl/af_inet.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/impl/af_inet_at.c b/components/net/sal_socket/impl/af_inet_at.c index 135e4183c4..c85dfe9f06 100644 --- a/components/net/sal_socket/impl/af_inet_at.c +++ b/components/net/sal_socket/impl/af_inet_at.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -85,7 +85,7 @@ static const struct sal_socket_ops at_socket_ops = #endif /* SAL_USING_POSIX */ }; -static const struct sal_netdb_ops at_netdb_ops = +static const struct sal_netdb_ops at_netdb_ops = { at_gethostbyname, NULL, diff --git a/components/net/sal_socket/impl/af_inet_lwip.c b/components/net/sal_socket/impl/af_inet_lwip.c index 56df735ab9..2e19275b5d 100644 --- a/components/net/sal_socket/impl/af_inet_lwip.c +++ b/components/net/sal_socket/impl/af_inet_lwip.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -229,7 +229,7 @@ int inet_ioctlsocket(int socket, long cmd, void *arg) { case F_GETFL: case F_SETFL: - return lwip_fcntl(socket, cmd, (int) arg); + return lwip_fcntl(socket, cmd, (int) arg); default: return lwip_ioctl(socket, cmd, arg); @@ -320,7 +320,7 @@ static const struct sal_proto_family lwip_inet_family = AF_INET6, #else AF_INET, -#endif +#endif &lwip_socket_ops, &lwip_netdb_ops, }; @@ -329,7 +329,7 @@ static const struct sal_proto_family lwip_inet_family = int sal_lwip_netdev_set_pf_info(struct netdev *netdev) { RT_ASSERT(netdev); - + netdev->sal_user_data = (void *) &lwip_inet_family; return 0; } diff --git a/components/net/sal_socket/impl/proto_mbedtls.c b/components/net/sal_socket/impl/proto_mbedtls.c index 3472bbeaf5..79fbdcc5d4 100644 --- a/components/net/sal_socket/impl/proto_mbedtls.c +++ b/components/net/sal_socket/impl/proto_mbedtls.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -59,7 +59,7 @@ static void *mebdtls_socket(int socket) { tls_free(session); session = RT_NULL; - + return RT_NULL; } @@ -68,7 +68,7 @@ static void *mebdtls_socket(int socket) { mbedtls_client_close(session); return RT_NULL; - } + } session->server_fd.fd = socket; return (void *)session; @@ -89,7 +89,7 @@ int mbedtls_net_send_cb(void *ctx, const unsigned char *buf, size_t len) { return -1; } - + pf = (struct sal_proto_family *)sock->netdev->sal_user_data; /* Register scoket sendto option to TLS send data callback */ @@ -128,7 +128,7 @@ int mbedtls_net_recv_cb( void *ctx, unsigned char *buf, size_t len) } pf = (struct sal_proto_family *)sock->netdev->sal_user_data; - + /* Register scoket recvfrom option to TLS recv data callback */ ret = pf->skt_ops->recvfrom((int) sock->user_data, (void *)buf, len, 0, RT_NULL, RT_NULL); if (ret < 0) @@ -183,7 +183,7 @@ static int mbedtls_connect(void *sock) mbedtls_x509_crt_verify_info((char *)session->buffer, session->buffer_len, " ! ", ret); goto __exit; } - + return ret; __exit: @@ -199,27 +199,27 @@ static int mbedtls_closesocket(void *sock) { struct sal_socket *ssock; int socket; - + if (sock == RT_NULL) { return 0; } - + socket = ((MbedTLSSession *) sock)->server_fd.fd; ssock = sal_get_socket(socket); if (ssock == RT_NULL) { return -1; } - + /* Close TLS client session, and clean user-data in SAL socket */ mbedtls_client_close((MbedTLSSession *) sock); ssock->user_data_tls = RT_NULL; - + return 0; } -static const struct sal_proto_tls_ops mbedtls_proto_ops= +static const struct sal_proto_tls_ops mbedtls_proto_ops= { RT_NULL, mebdtls_socket, diff --git a/components/net/sal_socket/include/dfs_net/dfs_net.h b/components/net/sal_socket/include/dfs_net/dfs_net.h index ad28b8ec2a..82b7526603 100644 --- a/components/net/sal_socket/include/dfs_net/dfs_net.h +++ b/components/net/sal_socket/include/dfs_net/dfs_net.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h b/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h index 8899daee96..f174bc6504 100644 --- a/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h +++ b/components/net/sal_socket/include/dfs_net/sys_select/sys/select.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/sal.h b/components/net/sal_socket/include/sal.h index 6ffaa90356..dd250e37b6 100644 --- a/components/net/sal_socket/include/sal.h +++ b/components/net/sal_socket/include/sal.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/sal_netdb.h b/components/net/sal_socket/include/sal_netdb.h index d5ce9b1d7e..50064ce343 100644 --- a/components/net/sal_socket/include/sal_netdb.h +++ b/components/net/sal_socket/include/sal_netdb.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/sal_socket.h b/components/net/sal_socket/include/sal_socket.h index b620bbe23c..497be47e41 100644 --- a/components/net/sal_socket/include/sal_socket.h +++ b/components/net/sal_socket/include/sal_socket.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -171,7 +171,7 @@ struct sockaddr_in #endif /* NETDEV_IPV4 */ #if NETDEV_IPV6 -struct sockaddr_in6 +struct sockaddr_in6 { uint8_t sin6_len; /* length of this structure */ sa_family_t sin6_family; /* AF_INET6 */ diff --git a/components/net/sal_socket/include/sal_tls.h b/components/net/sal_socket/include/sal_tls.h index 7681b313bd..f211a3c1f8 100644 --- a/components/net/sal_socket/include/sal_tls.h +++ b/components/net/sal_socket/include/sal_tls.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/socket/netdb.h b/components/net/sal_socket/include/socket/netdb.h index 17f83efe00..4783405022 100644 --- a/components/net/sal_socket/include/socket/netdb.h +++ b/components/net/sal_socket/include/socket/netdb.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/socket/netinet/in.h b/components/net/sal_socket/include/socket/netinet/in.h index 57c417d7b6..37240547b4 100644 --- a/components/net/sal_socket/include/socket/netinet/in.h +++ b/components/net/sal_socket/include/socket/netinet/in.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/socket/netinet/tcp.h b/components/net/sal_socket/include/socket/netinet/tcp.h index 2ac4d6f40d..a3b530186a 100644 --- a/components/net/sal_socket/include/socket/netinet/tcp.h +++ b/components/net/sal_socket/include/socket/netinet/tcp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/socket/netinet/udp.h b/components/net/sal_socket/include/socket/netinet/udp.h index 485d7d142c..21f50d55e5 100644 --- a/components/net/sal_socket/include/socket/netinet/udp.h +++ b/components/net/sal_socket/include/socket/netinet/udp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/include/socket/sys_socket/sys/socket.h b/components/net/sal_socket/include/socket/sys_socket/sys/socket.h index 04470aa84a..a86240e2ff 100644 --- a/components/net/sal_socket/include/socket/sys_socket/sys/socket.h +++ b/components/net/sal_socket/include/socket/sys_socket/sys/socket.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/socket/net_netdb.c b/components/net/sal_socket/socket/net_netdb.c index bc76a48965..03b995c68d 100644 --- a/components/net/sal_socket/socket/net_netdb.c +++ b/components/net/sal_socket/socket/net_netdb.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/net/sal_socket/socket/net_sockets.c b/components/net/sal_socket/socket/net_sockets.c index a53b2f1f9c..3637635d50 100644 --- a/components/net/sal_socket/socket/net_sockets.c +++ b/components/net/sal_socket/socket/net_sockets.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -95,7 +95,7 @@ int shutdown(int s, int how) rt_set_errno(-EBADF); return -1; } - + if (sal_shutdown(socket, how) == 0) { error = 0; @@ -105,7 +105,7 @@ int shutdown(int s, int how) rt_set_errno(-ENOTSOCK); error = -1; } - + fd_put(d); return error; diff --git a/components/net/sal_socket/src/sal_socket.c b/components/net/sal_socket/src/sal_socket.c index 27dea260fb..e7142fae94 100644 --- a/components/net/sal_socket/src/sal_socket.c +++ b/components/net/sal_socket/src/sal_socket.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ulog/backend/console_be.c b/components/utilities/ulog/backend/console_be.c index 95dd547426..b84cd95d09 100644 --- a/components/utilities/ulog/backend/console_be.c +++ b/components/utilities/ulog/backend/console_be.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ulog/syslog/syslog.c b/components/utilities/ulog/syslog/syslog.c index 4c290bed52..a081db6eb6 100644 --- a/components/utilities/ulog/syslog/syslog.c +++ b/components/utilities/ulog/syslog/syslog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ulog/syslog/syslog.h b/components/utilities/ulog/syslog/syslog.h index 43eec7125f..8e4d5ba15f 100644 --- a/components/utilities/ulog/syslog/syslog.h +++ b/components/utilities/ulog/syslog/syslog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ulog/ulog.c b/components/utilities/ulog/ulog.c index b4571f4920..e903a707b2 100644 --- a/components/utilities/ulog/ulog.c +++ b/components/utilities/ulog/ulog.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2019, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ulog/ulog.h b/components/utilities/ulog/ulog.h index 670644bb30..3754828e56 100644 --- a/components/utilities/ulog/ulog.h +++ b/components/utilities/ulog/ulog.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ulog/ulog_def.h b/components/utilities/ulog/ulog_def.h index 771e76a601..d51c6f0d84 100644 --- a/components/utilities/ulog/ulog_def.h +++ b/components/utilities/ulog/ulog_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -102,8 +102,8 @@ extern "C" { #define ulog_hex(TAG, width, buf, size) ulog_hexdump(TAG, width, buf, size) #else #define ulog_hex(TAG, width, buf, size) -#endif /* (LOG_LVL >= LOG_LVL_DBG) && (ULOG_OUTPUT_LVL >= LOG_LVL_DBG) */ - +#endif /* (LOG_LVL >= LOG_LVL_DBG) && (ULOG_OUTPUT_LVL >= LOG_LVL_DBG) */ + /* assert for developer. */ #ifdef ULOG_ASSERT_ENABLE #define ULOG_ASSERT(EXPR) \ @@ -142,7 +142,7 @@ extern "C" { #define log_d LOG_D #define log_v LOG_D #define log_raw LOG_RAW -#define log_hex LOG_HEX +#define log_hex LOG_HEX #define ELOG_LVL_ASSERT LOG_LVL_ASSERT #define ELOG_LVL_ERROR LOG_LVL_ERROR #define ELOG_LVL_WARN LOG_LVL_WARNING diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 6500ae2fbe..325823de8a 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/utest/utest.h b/components/utilities/utest/utest.h index e2d72a931d..33d50efddb 100644 --- a/components/utilities/utest/utest.h +++ b/components/utilities/utest/utest.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -22,13 +22,13 @@ extern "C" { /** * utest_error - * + * * @brief Test result. - * + * * @member UTEST_PASSED Test success. * @member UTEST_FAILED Test failed. * @member UTEST_PASSED Test skipped. - * + * */ enum utest_error { @@ -40,13 +40,13 @@ typedef enum utest_error utest_err_e; /** * utest - * + * * @brief utest data structure. - * + * * @member error Error number from enum `utest_error`. * @member passed_num Total number of tests passed. * @member failed_num Total number of tests failed. - * + * */ struct utest { @@ -58,16 +58,16 @@ typedef struct utest *utest_t; /** * utest_tc_export - * + * * @brief utest testcase data structure. * Will export the data to `UtestTcTab` section in flash. - * + * * @member name Testcase name. * @member run_timeout Testcase maximum test time (Time unit: seconds). * @member init Necessary initialization before executing the test case function. * @member tc Total number of tests failed. * @member cleanup Total number of tests failed. - * + * */ struct utest_tc_export { const char *name; @@ -80,61 +80,61 @@ typedef struct utest_tc_export *utest_tc_export_t; /** * test_unit_func - * + * * @brief Unit test handler function pointer. - * + * */ typedef void (*test_unit_func)(void); /** * utest_unit_run - * + * * @brief Unit test function executor. * No need for the user to call this function directly - * + * * @param func Unit test function. * @param unit_func_name Unit test function name. - * + * * @return void - * + * */ void utest_unit_run(test_unit_func func, const char *unit_func_name); /** * utest_handle_get - * + * * @brief Get the utest data structure handle. * No need for the user to call this function directly - * + * * @param void - * + * * @return utest_t type. (struct utest *) - * + * */ utest_t utest_handle_get(void); /** * UTEST_NAME_MAX_LEN - * + * * @brief Testcase name maximum length. - * + * */ #define UTEST_NAME_MAX_LEN (128u) /** * UTEST_TC_EXPORT - * + * * @brief Export testcase function to `UtestTcTab` section in flash. * Used in application layer. - * + * * @param testcase The testcase function. * @param name The testcase name. * @param init The initialization function of the test case. * @param cleanup The cleanup function of the test case. * @param timeout Testcase maximum test time (Time unit: seconds). - * + * * @return None - * + * */ #define UTEST_TC_EXPORT(testcase, name, init, cleanup, timeout) \ RT_USED static const struct utest_tc_export _utest_testcase \ @@ -149,14 +149,14 @@ utest_t utest_handle_get(void); /** * UTEST_UNIT_RUN - * + * * @brief Unit test function executor. * Used in `testcase` function in application. - * + * * @param test_unit_func Unit test function - * + * * @return None - * + * */ #define UTEST_UNIT_RUN(test_unit_func) \ utest_unit_run(test_unit_func, #test_unit_func); \ diff --git a/components/utilities/utest/utest_assert.h b/components/utilities/utest/utest_assert.h index d83279272e..2e2007e773 100644 --- a/components/utilities/utest/utest_assert.h +++ b/components/utilities/utest/utest_assert.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -30,10 +30,10 @@ void utest_assert_buf(const char *a, const char *b, rt_size_t sz, rt_bool_t equa /** * uassert_x macros - * + * * @brief Get the utest data structure handle. * No need for the user to call this function directly. - * + * * @macro uassert_true if @value is true, not assert, means passing. * @macro uassert_false if @value is false, not assert, means passing. * @macro uassert_null if @value is null, not assert, means passing. @@ -46,7 +46,7 @@ void utest_assert_buf(const char *a, const char *b, rt_size_t sz, rt_bool_t equa * @macro uassert_buf_not_equal if @a not equal to @b, not assert, means passing. buf type test. * @macro uassert_in_range if @value is in range of min and max, not assert, means passing. * @macro uassert_not_in_range if @value is not in range of min and max, not assert, means passing. - * + * */ #define uassert_true(value) __utest_assert(value, "(" #value ") is false") #define uassert_false(value) __utest_assert(!(value), "(" #value ") is true") @@ -62,7 +62,7 @@ void utest_assert_buf(const char *a, const char *b, rt_size_t sz, rt_bool_t equa #define uassert_buf_equal(a, b, sz) utest_assert_buf((const char*)(a), (const char*)(b), (sz), RT_TRUE, __FILE__, __LINE__, __func__, "buf not equal") #define uassert_buf_not_equal(a, b, sz) utest_assert_buf((const char*)(a), (const char*)(b), (sz), RT_FALSE, __FILE__, __LINE__, __func__, "buf equal") -#define uassert_in_range(value, min, max) __utest_assert(((value >= min) && (value <= max)), "(" #value ") not in range("#min","#max")") +#define uassert_in_range(value, min, max) __utest_assert(((value >= min) && (value <= max)), "(" #value ") not in range("#min","#max")") #define uassert_not_in_range(value, min, max) __utest_assert(!((value >= min) && (value <= max)), "(" #value ") in range("#min","#max")") #ifdef __cplusplus diff --git a/components/utilities/utest/utest_log.h b/components/utilities/utest/utest_log.h index 0403268351..6aa54386a8 100644 --- a/components/utilities/utest/utest_log.h +++ b/components/utilities/utest/utest_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/utilities/ymodem/ymodem.c b/components/utilities/ymodem/ymodem.c index 07055db615..a74237689d 100644 --- a/components/utilities/ymodem/ymodem.c +++ b/components/utilities/ymodem/ymodem.c @@ -1,5 +1,5 @@ /* - * COPYRIGHT (C) 2012, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved * * SPDX-License-Identifier: Apache-2.0 @@ -13,7 +13,7 @@ #include #include "ymodem.h" -#ifdef YMODEM_USING_CRC_TABLE +#ifdef YMODEM_USING_CRC_TABLE static const rt_uint16_t ccitt_table[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, diff --git a/components/utilities/ymodem/ymodem.h b/components/utilities/ymodem/ymodem.h index 8419290e13..7006cf268d 100644 --- a/components/utilities/ymodem/ymodem.h +++ b/components/utilities/ymodem/ymodem.h @@ -1,5 +1,5 @@ /* - * COPYRIGHT (C) 2012, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved * * SPDX-License-Identifier: Apache-2.0 diff --git a/components/utilities/zmodem/crc.h b/components/utilities/zmodem/crc.h index fd11c1960a..c5251a7aa1 100644 --- a/components/utilities/zmodem/crc.h +++ b/components/utilities/zmodem/crc.h @@ -39,14 +39,14 @@ static unsigned short crctab[256] = { }; /* - * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. + * updcrc macro derived from article Copyright (C) 1986 Stephen Satchell. * NOTE: First srgument must be in range 0 to 255. * Second argument is referenced twice. - * - * Programmers may incorporate any or all code into their programs, - * giving proper credit within the source. Publication of the - * source routines is permitted so long as proper credit is given - * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, + * + * Programmers may incorporate any or all code into their programs, + * giving proper credit within the source. Publication of the + * source routines is permitted so long as proper credit is given + * to Stephen Satchell, Satchell Evaluations and Chuck Forsberg, * Omen Technology. */ diff --git a/components/utilities/zmodem/rz.c b/components/utilities/zmodem/rz.c index 1324b5994b..1845fd24c2 100644 --- a/components/utilities/zmodem/rz.c +++ b/components/utilities/zmodem/rz.c @@ -1,11 +1,11 @@ /* * File : rz.c - * the implemention of receiving files from the remote computers + * the implemention of receiving files from the remote computers * through the zmodem protocol. * Change Logs: * Date Author Notes - * 2011-03-29 itspy - * 2011-12-12 aozima fixed syntax error. + * 2011-03-29 itspy + * 2011-12-12 aozima fixed syntax error. */ #include @@ -35,293 +35,293 @@ void zr_start(char *path) { struct zfile *zf; rt_uint8_t n; - char ch,*p,*q; - rt_err_t res = -RT_ERROR; + char ch,*p,*q; + rt_err_t res = -RT_ERROR; - zf = rt_malloc(sizeof(struct zfile)); - if (zf == RT_NULL) - { - rt_kprintf("zf: out of memory\r\n"); - return; - } - memset(zf, 0, sizeof(struct zfile)); + zf = rt_malloc(sizeof(struct zfile)); + if (zf == RT_NULL) + { + rt_kprintf("zf: out of memory\r\n"); + return; + } + memset(zf, 0, sizeof(struct zfile)); zf->fname = path; - zf->fd = -1; - res = zrec_files(zf); - p = zf->fname; - for (;;) - { - q = strstr(p,"/"); - if (q == RT_NULL) break; - p = q+1; - } + zf->fd = -1; + res = zrec_files(zf); + p = zf->fname; + for (;;) + { + q = strstr(p,"/"); + if (q == RT_NULL) break; + p = q+1; + } if (res == RT_EOK) - { + { rt_kprintf("\b\b\bfile: %s \r\n",p); - rt_kprintf("size: %ld bytes\r\n",zf->bytes_received); - rt_kprintf("receive completed.\r\n"); - close(zf->fd); - rt_free(zf->fname); + rt_kprintf("size: %ld bytes\r\n",zf->bytes_received); + rt_kprintf("receive completed.\r\n"); + close(zf->fd); + rt_free(zf->fname); } else { rt_kprintf("\b\b\bfile: %s \r\n",p); - rt_kprintf("size: 0 bytes\r\n"); - rt_kprintf("receive failed.\r\n"); - if (zf->fd >= 0) - { - close(zf->fd); - unlink(zf->fname); /* remove this file */ - rt_free(zf->fname); - } + rt_kprintf("size: 0 bytes\r\n"); + rt_kprintf("receive failed.\r\n"); + if (zf->fd >= 0) + { + close(zf->fd); + unlink(zf->fname); /* remove this file */ + rt_free(zf->fname); + } + } + rt_free(zf); + /* waiting,clear console buffer */ + rt_thread_delay(RT_TICK_PER_SECOND/2); + while(1) + { + n=rt_device_read(shell->device, 0, &ch, 1); + if (n == 0) break; } - rt_free(zf); - /* waiting,clear console buffer */ - rt_thread_delay(RT_TICK_PER_SECOND/2); - while(1) - { - n=rt_device_read(shell->device, 0, &ch, 1); - if (n == 0) break; - } - return ; + return ; } /* receiver init, wait for ack */ static rt_err_t zrec_init(rt_uint8_t *rxbuf, struct zfile *zf) { rt_uint8_t err_cnt = 0; - rt_err_t res = -RT_ERROR; + rt_err_t res = -RT_ERROR; - for (;;) - { - zput_pos(0L); - tx_header[ZF0] = ZF0_CMD; - tx_header[ZF1] = ZF1_CMD; - tx_header[ZF2] = ZF2_CMD; - zsend_hex_header(ZRINIT, tx_header); + for (;;) + { + zput_pos(0L); + tx_header[ZF0] = ZF0_CMD; + tx_header[ZF1] = ZF1_CMD; + tx_header[ZF2] = ZF2_CMD; + zsend_hex_header(ZRINIT, tx_header); again: res = zget_header(rx_header); - switch(res) - { - case ZFILE: - ZF0_CMD = rx_header[ZF0]; - ZF1_CMD = rx_header[ZF1]; - ZF2_CMD = rx_header[ZF2]; - ZF3_CMD = rx_header[ZF3]; - res = zget_data(rxbuf, RX_BUFFER_SIZE); - if (res == GOTCRCW) - { - if ((res =zget_file_info((char*)rxbuf,zf))!= RT_EOK) - { - zsend_hex_header(ZSKIP, tx_header); - return (res); - } - return RT_EOK;; - } - zsend_hex_header(ZNAK, tx_header); - goto again; - case ZSINIT: - if (zget_data((rt_uint8_t*)Attn, ZATTNLEN) == GOTCRCW) /* send zack */ - { - zsend_hex_header(ZACK, tx_header); - goto again; - } - zsend_hex_header(ZNAK, tx_header); /* send znak */ - goto again; - case ZRQINIT: - continue; - case ZEOF: - continue; - case ZCOMPL: - goto again; - case ZFIN: /* end file session */ - zrec_ack_bibi(); - return res; - default: - if (++err_cnt >1000) return -RT_ERROR; - continue; - } - } + switch(res) + { + case ZFILE: + ZF0_CMD = rx_header[ZF0]; + ZF1_CMD = rx_header[ZF1]; + ZF2_CMD = rx_header[ZF2]; + ZF3_CMD = rx_header[ZF3]; + res = zget_data(rxbuf, RX_BUFFER_SIZE); + if (res == GOTCRCW) + { + if ((res =zget_file_info((char*)rxbuf,zf))!= RT_EOK) + { + zsend_hex_header(ZSKIP, tx_header); + return (res); + } + return RT_EOK;; + } + zsend_hex_header(ZNAK, tx_header); + goto again; + case ZSINIT: + if (zget_data((rt_uint8_t*)Attn, ZATTNLEN) == GOTCRCW) /* send zack */ + { + zsend_hex_header(ZACK, tx_header); + goto again; + } + zsend_hex_header(ZNAK, tx_header); /* send znak */ + goto again; + case ZRQINIT: + continue; + case ZEOF: + continue; + case ZCOMPL: + goto again; + case ZFIN: /* end file session */ + zrec_ack_bibi(); + return res; + default: + if (++err_cnt >1000) return -RT_ERROR; + continue; + } + } } /* receive files */ static rt_err_t zrec_files(struct zfile *zf) { - rt_uint8_t *rxbuf; - rt_err_t res = -RT_ERROR; + rt_uint8_t *rxbuf; + rt_err_t res = -RT_ERROR; - zinit_parameter(); - rxbuf = rt_malloc(RX_BUFFER_SIZE*sizeof(rt_uint8_t)); - if (rxbuf == RT_NULL) - { - rt_kprintf("rxbuf: out of memory\r\n"); - return -RT_ERROR; - } - rt_kprintf("\r\nrz: ready...\r\n"); /* here ready to receive things */ - if ((res = zrec_init(rxbuf,zf))!= RT_EOK) - { - rt_kprintf("\b\b\breceive init failed\r\n"); - rt_free(rxbuf); - return -RT_ERROR; - } - res = zrec_file(rxbuf,zf); - if (res == ZFIN) - { - rt_free(rxbuf); - return RT_EOK; /* if finish session */ - } - else if (res == ZCAN) - { + zinit_parameter(); + rxbuf = rt_malloc(RX_BUFFER_SIZE*sizeof(rt_uint8_t)); + if (rxbuf == RT_NULL) + { + rt_kprintf("rxbuf: out of memory\r\n"); + return -RT_ERROR; + } + rt_kprintf("\r\nrz: ready...\r\n"); /* here ready to receive things */ + if ((res = zrec_init(rxbuf,zf))!= RT_EOK) + { + rt_kprintf("\b\b\breceive init failed\r\n"); + rt_free(rxbuf); + return -RT_ERROR; + } + res = zrec_file(rxbuf,zf); + if (res == ZFIN) + { rt_free(rxbuf); - return ZCAN; /* cancel by sender */ - } - else - { - zsend_can(); - rt_free(rxbuf); - return res; - } + return RT_EOK; /* if finish session */ + } + else if (res == ZCAN) + { + rt_free(rxbuf); + return ZCAN; /* cancel by sender */ + } + else + { + zsend_can(); + rt_free(rxbuf); + return res; + } } /* receive file */ static rt_err_t zrec_file(rt_uint8_t *rxbuf, struct zfile *zf) { - rt_err_t res = - RT_ERROR; - rt_uint16_t err_cnt = 0; + rt_err_t res = - RT_ERROR; + rt_uint16_t err_cnt = 0; - do - { - zput_pos(zf->bytes_received); - zsend_hex_header(ZRPOS, tx_header); + do + { + zput_pos(zf->bytes_received); + zsend_hex_header(ZRPOS, tx_header); again: res = zget_header(rx_header); - switch (res) - { - case ZDATA: - zget_pos(Rxpos); - if (Rxpos != zf->bytes_received) - { - zsend_break(Attn); - continue; - } - err_cnt = 0; - res = zrec_file_data(rxbuf,zf); - if (res == -RT_ERROR) - { - zsend_break(Attn); - continue; - } - else if (res == GOTCAN) return res; - else goto again; - case ZRPOS: - zget_pos(Rxpos); - continue; - case ZEOF: - err_cnt = 0; - zget_pos(Rxpos); - if (Rxpos != zf->bytes_received || Rxpos != zf->bytes_total) - { - continue; - } - return (zrec_init(rxbuf,zf)); /* resend ZRINIT packet,ready to receive next file */ + switch (res) + { + case ZDATA: + zget_pos(Rxpos); + if (Rxpos != zf->bytes_received) + { + zsend_break(Attn); + continue; + } + err_cnt = 0; + res = zrec_file_data(rxbuf,zf); + if (res == -RT_ERROR) + { + zsend_break(Attn); + continue; + } + else if (res == GOTCAN) return res; + else goto again; + case ZRPOS: + zget_pos(Rxpos); + continue; + case ZEOF: + err_cnt = 0; + zget_pos(Rxpos); + if (Rxpos != zf->bytes_received || Rxpos != zf->bytes_total) + { + continue; + } + return (zrec_init(rxbuf,zf)); /* resend ZRINIT packet,ready to receive next file */ case ZFIN: - zrec_ack_bibi(); - return ZCOMPL; - case ZCAN: + zrec_ack_bibi(); + return ZCOMPL; + case ZCAN: #ifdef ZDEBUG rt_kprintf("error code: sender cancelled \r\n"); #endif - zf->bytes_received = 0L; /* throw the received data */ - return res; - case ZSKIP: - return res; - case -RT_ERROR: - zsend_break(Attn); - continue; - case ZNAK: - case TIMEOUT: - default: - continue; - } - } while(++err_cnt < 100); + zf->bytes_received = 0L; /* throw the received data */ + return res; + case ZSKIP: + return res; + case -RT_ERROR: + zsend_break(Attn); + continue; + case ZNAK: + case TIMEOUT: + default: + continue; + } + } while(++err_cnt < 100); - return res; + return res; } /* proccess file infomation */ static rt_err_t zget_file_info(char *name, struct zfile *zf) { - char *p; - char *full_path,*ptr; - rt_uint16_t i,len; - rt_err_t res = -RT_ERROR; - struct statfs buf; - struct stat finfo; + char *p; + char *full_path,*ptr; + rt_uint16_t i,len; + rt_err_t res = -RT_ERROR; + struct statfs buf; + struct stat finfo; - if (zf->fname == RT_NULL) /* extract file path */ + if (zf->fname == RT_NULL) /* extract file path */ { - len = strlen(name)+2; - } - else - len = strlen(zf->fname)+strlen(name)+2; + len = strlen(name)+2; + } + else + len = strlen(zf->fname)+strlen(name)+2; full_path = rt_malloc(len); - if (full_path == RT_NULL) - { - zsend_can(); - rt_kprintf("\b\b\bfull_path: out of memory\n"); - rt_free(full_path); - return -RT_ERROR; - } - memset(full_path,0,len); + if (full_path == RT_NULL) + { + zsend_can(); + rt_kprintf("\b\b\bfull_path: out of memory\n"); + rt_free(full_path); + return -RT_ERROR; + } + memset(full_path,0,len); for (i=0,ptr=zf->fname;ifd=open(full_path, DFS_O_DIRECTORY,0)) < 0) - { - zsend_can(); - rt_kprintf("\b\b\bcan not open file:%s\r\n",zf->fname+1); - close(zf->fd); - zf->fd = -1; - rt_free(full_path); - return res; - } - fstat(zf->fd, &finfo); - if ((finfo.st_mode&S_IFDIR) != S_IFDIR) - { - close(zf->fd); - zf->fd = -1; - return res; - } - close(zf->fd); - /* get fullpath && file attributes */ + /* check if is a directory */ + if ((zf->fd=open(full_path, DFS_O_DIRECTORY,0)) < 0) + { + zsend_can(); + rt_kprintf("\b\b\bcan not open file:%s\r\n",zf->fname+1); + close(zf->fd); + zf->fd = -1; + rt_free(full_path); + return res; + } + fstat(zf->fd, &finfo); + if ((finfo.st_mode&S_IFDIR) != S_IFDIR) + { + close(zf->fd); + zf->fd = -1; + return res; + } + close(zf->fd); + /* get fullpath && file attributes */ strcat(full_path,name); zf->fname = full_path; - p = strlen(name)+name+1; - sscanf((const char *)p, "%ld%lo%o", &zf->bytes_total,&zf->ctime,&zf->mode); + p = strlen(name)+name+1; + sscanf((const char *)p, "%ld%lo%o", &zf->bytes_total,&zf->ctime,&zf->mode); #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) - dfs_statfs(working_directory,&buf); - if (zf->bytes_total > (buf.f_blocks * buf.f_bfree)) - { - zsend_can(); - rt_kprintf("\b\b\bnot enough disk space\r\n"); - zf->fd = -1; - rt_free(full_path); - return -RT_ERROR; - } + dfs_statfs(working_directory,&buf); + if (zf->bytes_total > (buf.f_blocks * buf.f_bfree)) + { + zsend_can(); + rt_kprintf("\b\b\bnot enough disk space\r\n"); + zf->fd = -1; + rt_free(full_path); + return -RT_ERROR; + } #else buf = buf; #endif - zf->bytes_received = 0L; - if ((zf->fd = open(zf->fname,DFS_O_CREAT|DFS_O_WRONLY,0)) < 0) /* create or replace exist file */ - { - zsend_can(); - rt_kprintf("\b\b\bcan not create file:%s \r\n",zf->fname); - return -RT_ERROR; - } + zf->bytes_received = 0L; + if ((zf->fd = open(zf->fname,DFS_O_CREAT|DFS_O_WRONLY,0)) < 0) /* create or replace exist file */ + { + zsend_can(); + rt_kprintf("\b\b\bcan not create file:%s \r\n",zf->fname); + return -RT_ERROR; + } - return RT_EOK; + return RT_EOK; } /* receive file data,continously, no ack */ @@ -330,72 +330,72 @@ static rt_err_t zrec_file_data(rt_uint8_t *buf, struct zfile *zf) rt_err_t res = -RT_ERROR; more_data: - res = zget_data(buf,RX_BUFFER_SIZE); - switch(res) - { - case GOTCRCW: /* zack received */ - zwrite_file(buf,Rxcount,zf); - zf->bytes_received += Rxcount; - zput_pos(zf->bytes_received); - zsend_line(XON); - zsend_hex_header(ZACK, tx_header); - return RT_EOK; - case GOTCRCQ: - zwrite_file(buf,Rxcount,zf); - zf->bytes_received += Rxcount; - zput_pos(zf->bytes_received); - zsend_hex_header(ZACK, tx_header); - goto more_data; - case GOTCRCG: - zwrite_file(buf,Rxcount,zf); - zf->bytes_received += Rxcount; - goto more_data; - case GOTCRCE: - zwrite_file(buf,Rxcount,zf); - zf->bytes_received += Rxcount; - return RT_EOK; - case GOTCAN: + res = zget_data(buf,RX_BUFFER_SIZE); + switch(res) + { + case GOTCRCW: /* zack received */ + zwrite_file(buf,Rxcount,zf); + zf->bytes_received += Rxcount; + zput_pos(zf->bytes_received); + zsend_line(XON); + zsend_hex_header(ZACK, tx_header); + return RT_EOK; + case GOTCRCQ: + zwrite_file(buf,Rxcount,zf); + zf->bytes_received += Rxcount; + zput_pos(zf->bytes_received); + zsend_hex_header(ZACK, tx_header); + goto more_data; + case GOTCRCG: + zwrite_file(buf,Rxcount,zf); + zf->bytes_received += Rxcount; + goto more_data; + case GOTCRCE: + zwrite_file(buf,Rxcount,zf); + zf->bytes_received += Rxcount; + return RT_EOK; + case GOTCAN: #ifdef ZDEBUG - rt_kprintf("error code : ZCAN \r\n"); + rt_kprintf("error code : ZCAN \r\n"); #endif - return res; - case TIMEOUT: - return res; + return res; + case TIMEOUT: + return res; case -RT_ERROR: - zsend_break(Attn); - return res; - default: - return res; - } + zsend_break(Attn); + return res; + default: + return res; + } } /* write file */ static rt_err_t zwrite_file(rt_uint8_t *buf,rt_uint16_t size, struct zfile *zf) { - return (write(zf->fd,buf,size)); + return (write(zf->fd,buf,size)); } /* ack bibi */ static void zrec_ack_bibi(void) { - rt_uint8_t i; + rt_uint8_t i; - zput_pos(0L); - for (i=0;i<3;i++) - { - zsend_hex_header(ZFIN, tx_header); - switch (zread_line(100)) - { - case 'O': - zread_line(1); - return; - case RCDO: - return; - case TIMEOUT: - default: - break; - } - } + zput_pos(0L); + for (i=0;i<3;i++) + { + zsend_hex_header(ZFIN, tx_header); + switch (zread_line(100)) + { + case 'O': + zread_line(1); + return; + case RCDO: + return; + case TIMEOUT: + default: + break; + } + } } /* end of rz.c */ diff --git a/components/utilities/zmodem/sz.c b/components/utilities/zmodem/sz.c index 0fde4165f6..0b0b5515f0 100644 --- a/components/utilities/zmodem/sz.c +++ b/components/utilities/zmodem/sz.c @@ -1,10 +1,10 @@ /* * File : sz.c - * the implemention of sending files to the remote computers + * the implemention of sending files to the remote computers * through the zmodem protocol. * Change Logs: * Date Author Notes - * 2011-03-29 itspy + * 2011-03-29 itspy */ #include @@ -17,10 +17,10 @@ #include "zdef.h" -static rt_uint8_t TX_BUFFER[TX_BUFFER_SIZE]; /* sender buffer */ -static rt_uint8_t file_cnt = 0; /* count of number of files opened */ -static rt_uint8_t Rxflags = 0; /* rx parameter flags */ -static rt_uint8_t ZF2_OP; /* file transfer option */ +static rt_uint8_t TX_BUFFER[TX_BUFFER_SIZE]; /* sender buffer */ +static rt_uint8_t file_cnt = 0; /* count of number of files opened */ +static rt_uint8_t Rxflags = 0; /* rx parameter flags */ +static rt_uint8_t ZF2_OP; /* file transfer option */ void zs_start(char *path); static void zsend_init(void); @@ -38,233 +38,233 @@ static void zsay_bibi(void); void zs_start(char *path) { struct zfile *zf; - rt_err_t res = RT_ERROR; + rt_err_t res = RT_ERROR; char *p,*q; - zf = rt_malloc(sizeof(struct zfile)); - if (zf == RT_NULL) - { - rt_kprintf("zf: out of memory\r\n"); - return; - } - rt_kprintf("\r\nsz: ready...\r\n"); /* here ready to send things */ - memset(zf, 0, sizeof(struct zfile)); + zf = rt_malloc(sizeof(struct zfile)); + if (zf == RT_NULL) + { + rt_kprintf("zf: out of memory\r\n"); + return; + } + rt_kprintf("\r\nsz: ready...\r\n"); /* here ready to send things */ + memset(zf, 0, sizeof(struct zfile)); zf->fname = path; - zf->fd = -1; - res = zsend_files(zf); - p = zf->fname; - for (;;) - { - q = strstr(p,"/"); - if (q == RT_NULL) break; - p = q+1; - } + zf->fd = -1; + res = zsend_files(zf); + p = zf->fname; + for (;;) + { + q = strstr(p,"/"); + if (q == RT_NULL) break; + p = q+1; + } if (res == RT_EOK) { rt_kprintf("\r\nfile: %s \r\nsize: %ld bytes\r\nsend completed.\r\n", - p,zf->bytes_received); + p,zf->bytes_received); } else { rt_kprintf("\r\nfile: %s \r\nsize: 0 bytes\r\nsend failed.\r\n",p); } - rt_free(zf); + rt_free(zf); - return; + return; } /* init the parameters */ static void zsend_init(void) { - rt_err_t res = -RT_ERROR; + rt_err_t res = -RT_ERROR; - zinit_parameter(); - for(;;) /* wait ZPAD */ - { - res = zread_line(800); - if (res == ZPAD) break; - } - for (;;) - { - res = zget_header(rx_header); - if (res == ZRINIT) break; - } - if ((rx_header[ZF1] & ZRQNVH)) - { - zput_pos(0x80L); /* Show we can var header */ - zsend_hex_header(ZRQINIT, tx_header); - } - Rxflags = rx_header[ZF0] & 0377; - if (Rxflags & CANFC32) Txfcs32 = 1; /* used 32bits CRC check */ + zinit_parameter(); + for(;;) /* wait ZPAD */ + { + res = zread_line(800); + if (res == ZPAD) break; + } + for (;;) + { + res = zget_header(rx_header); + if (res == ZRINIT) break; + } + if ((rx_header[ZF1] & ZRQNVH)) + { + zput_pos(0x80L); /* Show we can var header */ + zsend_hex_header(ZRQINIT, tx_header); + } + Rxflags = rx_header[ZF0] & 0377; + if (Rxflags & CANFC32) Txfcs32 = 1; /* used 32bits CRC check */ - if (ZF2_OP == ZTRLE && (Rxflags & CANRLE)) /* for RLE packet */ - Txfcs32 = 2; - else - ZF2_OP = 0; + if (ZF2_OP == ZTRLE && (Rxflags & CANRLE)) /* for RLE packet */ + Txfcs32 = 2; + else + ZF2_OP = 0; /* send SINIT cmd */ - return; + return; } /* send files */ static rt_err_t zsend_files(struct zfile *zf) { - char *p,*q; - char *str = "/"; - struct stat finfo; - rt_err_t res = -RT_ERROR; + char *p,*q; + char *str = "/"; + struct stat finfo; + rt_err_t res = -RT_ERROR; - if (zf->fname == RT_NULL) - { - rt_kprintf("\r\nerror: no file to be send.\r\n"); - return res; - } - if ((zf->fd=open(zf->fname, DFS_O_RDONLY,0)) <0) - { - rt_kprintf("\r\ncan not open file:%s\r\n",zf->fname+1); - return res; - } + if (zf->fname == RT_NULL) + { + rt_kprintf("\r\nerror: no file to be send.\r\n"); + return res; + } + if ((zf->fd=open(zf->fname, DFS_O_RDONLY,0)) <0) + { + rt_kprintf("\r\ncan not open file:%s\r\n",zf->fname+1); + return res; + } - zf->file_end = 0; - ++file_cnt; - /* extract file name */ - p = zf->fname; - for (;;) - { - q = strstr(p,str); - if (q == RT_NULL) break; - p = q+1; - } - q = (char*)TX_BUFFER; - for (;;) - { - *q++ = *p++; - if (*p == 0) break; - } - *q++ = 0; - p=q; - while (q < (char*)(TX_BUFFER + 1024)) - *q++ = 0; - /* get file attributes */ - fstat(zf->fd,&finfo); - Left_sizes += finfo.st_size; - rt_sprintf(p, "%lu %lo %o 3 %d %ld", (long)finfo.st_size, finfo.st_mtime, - finfo.st_mode, file_cnt, Left_sizes); - Left_sizes -= finfo.st_size; - TX_BUFFER[127] = (finfo.st_size + 127) >>7; - TX_BUFFER[126] = (finfo.st_size + 127) >>15; + zf->file_end = 0; + ++file_cnt; + /* extract file name */ + p = zf->fname; + for (;;) + { + q = strstr(p,str); + if (q == RT_NULL) break; + p = q+1; + } + q = (char*)TX_BUFFER; + for (;;) + { + *q++ = *p++; + if (*p == 0) break; + } + *q++ = 0; + p=q; + while (q < (char*)(TX_BUFFER + 1024)) + *q++ = 0; + /* get file attributes */ + fstat(zf->fd,&finfo); + Left_sizes += finfo.st_size; + rt_sprintf(p, "%lu %lo %o 3 %d %ld", (long)finfo.st_size, finfo.st_mtime, + finfo.st_mode, file_cnt, Left_sizes); + Left_sizes -= finfo.st_size; + TX_BUFFER[127] = (finfo.st_size + 127) >>7; + TX_BUFFER[126] = (finfo.st_size + 127) >>15; - zsend_init(); - /* start sending files */ - res = zsend_file(zf,TX_BUFFER, (p-(char*)TX_BUFFER)+strlen(p)+1); - zsay_bibi(); - close(zf->fd); - - return res; + zsend_init(); + /* start sending files */ + res = zsend_file(zf,TX_BUFFER, (p-(char*)TX_BUFFER)+strlen(p)+1); + zsay_bibi(); + close(zf->fd); + + return res; } /* send file name and related info */ static rt_err_t zsend_file(struct zfile *zf, rt_uint8_t *buf, rt_uint16_t len) { - rt_uint8_t cnt; - rt_err_t res = -RT_ERROR; + rt_uint8_t cnt; + rt_err_t res = -RT_ERROR; - for (cnt=0;cnt<5;cnt++) - { - tx_header[ZF0] = ZF0_CMD; /* file conversion option */ - tx_header[ZF1] = ZF1_CMD; /* file management option */ - tx_header[ZF2] = (ZF3_CMD|ZF2_OP); /* file transfer option */ - tx_header[ZF3] = ZF3_CMD; - zsend_bin_header(ZFILE, tx_header); - zsend_bin_data(buf, len, ZCRCW); + for (cnt=0;cnt<5;cnt++) + { + tx_header[ZF0] = ZF0_CMD; /* file conversion option */ + tx_header[ZF1] = ZF1_CMD; /* file management option */ + tx_header[ZF2] = (ZF3_CMD|ZF2_OP); /* file transfer option */ + tx_header[ZF3] = ZF3_CMD; + zsend_bin_header(ZFILE, tx_header); + zsend_bin_data(buf, len, ZCRCW); loop: - res = zget_header(rx_header); - switch (res) - { - case ZRINIT: - while ((res = zread_line(50)) > 0) - { - if (res == ZPAD) - { - goto loop; - } - } - break; - case ZCAN: - case TIMEOUT: - case ZABORT: - case ZFIN: + res = zget_header(rx_header); + switch (res) + { + case ZRINIT: + while ((res = zread_line(50)) > 0) + { + if (res == ZPAD) + { + goto loop; + } + } + break; + case ZCAN: + case TIMEOUT: + case ZABORT: + case ZFIN: + break; + case -RT_ERROR: + case ZNAK: + break; + case ZCRC: /* no CRC request */ + goto loop; + case ZFERR: + case ZSKIP: break; - case -RT_ERROR: - case ZNAK: - break; - case ZCRC: /* no CRC request */ - goto loop; - case ZFERR: - case ZSKIP: - break; - case ZRPOS: /* here we want */ - zget_pos(Rxpos); - Txpos = Rxpos; - return(zsend_file_data(zf)); - default: - break; - } - } + case ZRPOS: /* here we want */ + zget_pos(Rxpos); + Txpos = Rxpos; + return(zsend_file_data(zf)); + default: + break; + } + } - return res; + return res; } /* send the file data */ static rt_err_t zsend_file_data(struct zfile *zf) { - rt_int16_t cnt; - rt_uint8_t cmd; - rt_err_t res = -RT_ERROR; - /* send ZDATA packet, start to send data */ + rt_int16_t cnt; + rt_uint8_t cmd; + rt_err_t res = -RT_ERROR; + /* send ZDATA packet, start to send data */ start_send: - zput_pos(Txpos); - zsend_bin_header(ZDATA, tx_header); - do - { - cnt = zfill_buffer(zf,TX_BUFFER,RX_BUFFER_SIZE); - if (cnt < RX_BUFFER_SIZE ) - cmd = ZCRCE; - else - cmd = ZCRCG; - zsend_bin_data(TX_BUFFER, cnt, cmd); - zf->bytes_received= Txpos += cnt; - if (cmd == ZCRCW) - goto get_syn1; - } while (cnt == RX_BUFFER_SIZE); - for (;;) /* get ack and check if send finish */ - { - zput_pos(Txpos); - zsend_bin_header(ZEOF, tx_header); + zput_pos(Txpos); + zsend_bin_header(ZDATA, tx_header); + do + { + cnt = zfill_buffer(zf,TX_BUFFER,RX_BUFFER_SIZE); + if (cnt < RX_BUFFER_SIZE ) + cmd = ZCRCE; + else + cmd = ZCRCG; + zsend_bin_data(TX_BUFFER, cnt, cmd); + zf->bytes_received= Txpos += cnt; + if (cmd == ZCRCW) + goto get_syn1; + } while (cnt == RX_BUFFER_SIZE); + for (;;) /* get ack and check if send finish */ + { + zput_pos(Txpos); + zsend_bin_header(ZEOF, tx_header); get_syn1: res = zget_sync(); - switch (res) - { - case ZACK: - goto get_syn1; - case ZNAK: - continue; - case ZRPOS: /* resend here */ - lseek(zf->fd,Txpos,0); - goto start_send; - case ZRINIT: /* send finish,then begin to send next file */ - return RT_EOK; - case ZSKIP: - case -RT_ERROR: - return res; - default: + switch (res) + { + case ZACK: + goto get_syn1; + case ZNAK: + continue; + case ZRPOS: /* resend here */ + lseek(zf->fd,Txpos,0); + goto start_send; + case ZRINIT: /* send finish,then begin to send next file */ + return RT_EOK; + case ZSKIP: + case -RT_ERROR: return res; - } - } + default: + return res; + } + } } /* fill file data to buffer*/ static rt_uint16_t zfill_buffer(struct zfile *zf, rt_uint8_t *buf, rt_uint16_t size) { - return (read(zf->fd,buf,size)); + return (read(zf->fd,buf,size)); } /* wait sync(ack) from the receiver */ @@ -272,50 +272,50 @@ static rt_err_t zget_sync(void) { rt_err_t res = -RT_ERROR; - for (;;) - { - res = zget_header(rx_header); - switch (res) - { - case ZCAN: - case ZABORT: - case ZFIN: - case TIMEOUT: - return -RT_ERROR; - case ZRPOS: /* get pos, need to resend */ - zget_pos(Rxpos); - Txpos = Rxpos; - return res; - case ZACK: - return res; - case ZRINIT: /* get ZRINIT indicate that the prev file send completed */ - return res; - case ZSKIP: - return res; - case -RT_ERROR: - default: - zsend_bin_header(ZNAK, tx_header); - continue; - } - } + for (;;) + { + res = zget_header(rx_header); + switch (res) + { + case ZCAN: + case ZABORT: + case ZFIN: + case TIMEOUT: + return -RT_ERROR; + case ZRPOS: /* get pos, need to resend */ + zget_pos(Rxpos); + Txpos = Rxpos; + return res; + case ZACK: + return res; + case ZRINIT: /* get ZRINIT indicate that the prev file send completed */ + return res; + case ZSKIP: + return res; + case -RT_ERROR: + default: + zsend_bin_header(ZNAK, tx_header); + continue; + } + } } /* say "bibi" to the receiver */ static void zsay_bibi(void) { - for (;;) - { - zput_pos(0L); /* reninit position of next file*/ - zsend_hex_header(ZFIN, tx_header); /* send finished session cmd */ - switch (zget_header(rx_header)) - { - case ZFIN: - zsend_line('O'); - zsend_line('O'); - case ZCAN: - case TIMEOUT: - return; - } - } + for (;;) + { + zput_pos(0L); /* reninit position of next file*/ + zsend_hex_header(ZFIN, tx_header); /* send finished session cmd */ + switch (zget_header(rx_header)) + { + case ZFIN: + zsend_line('O'); + zsend_line('O'); + case ZCAN: + case TIMEOUT: + return; + } + } } /* end of sz.c */ diff --git a/components/utilities/zmodem/zcore.c b/components/utilities/zmodem/zcore.c index 02ffbba830..75d9647348 100644 --- a/components/utilities/zmodem/zcore.c +++ b/components/utilities/zmodem/zcore.c @@ -3,7 +3,7 @@ * the core functions of implementing zmodem protocol * Change Logs: * Date Author Notes - * 2011-03-29 itspy + * 2011-03-29 itspy */ #include @@ -16,22 +16,22 @@ #include #include "zdef.h" -char ZF0_CMD; /* file conversion request */ -char ZF1_CMD; /* file management request */ -char ZF2_CMD; /* file transport request */ -char ZF3_CMD; -rt_uint8_t Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ -rt_uint16_t Rxcount; /* received count*/ -char header_type; /* header type */ -rt_uint8_t rx_header[4]; /* received header */ -rt_uint8_t tx_header[4]; /* transmitted header */ -rt_uint32_t Rxpos; /* received file position */ -rt_uint32_t Txpos; /* transmitted file position */ -rt_uint8_t Txfcs32; /* TURE means send binary frames with 32 bit FCS */ -rt_uint8_t TxCRC; /* controls 32 bit CRC being sent */ -rt_uint8_t RxCRC; /* indicates/controls 32 bit CRC being received */ +char ZF0_CMD; /* file conversion request */ +char ZF1_CMD; /* file management request */ +char ZF2_CMD; /* file transport request */ +char ZF3_CMD; +rt_uint8_t Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ +rt_uint16_t Rxcount; /* received count*/ +char header_type; /* header type */ +rt_uint8_t rx_header[4]; /* received header */ +rt_uint8_t tx_header[4]; /* transmitted header */ +rt_uint32_t Rxpos; /* received file position */ +rt_uint32_t Txpos; /* transmitted file position */ +rt_uint8_t Txfcs32; /* TURE means send binary frames with 32 bit FCS */ +rt_uint8_t TxCRC; /* controls 32 bit CRC being sent */ +rt_uint8_t RxCRC; /* indicates/controls 32 bit CRC being received */ /* 0 == CRC16, 1 == CRC32, 2 == CRC32 + RLE */ -char Attn[ZATTNLEN+1]; /* attention string rx sends to tx on err */ +char Attn[ZATTNLEN+1]; /* attention string rx sends to tx on err */ void zinit_parameter(void); void zsend_bin_header(rt_uint8_t type, rt_uint8_t *hdr); @@ -52,670 +52,670 @@ rt_int16_t zread_byte(void); rt_int16_t zxor_read(void); void zput_pos(rt_uint32_t pos); void zget_pos(rt_uint32_t pos); - - + + void zinit_parameter(void) { rt_uint8_t i; - ZF0_CMD = CANFC32|CANFDX|CANOVIO; /* not chose CANFC32,CANRLE,although it have been supported */ - ZF1_CMD = 0; /* fix header length,not support CANVHDR */ - ZF2_CMD = 0; - ZF3_CMD = 0; - Rxframeind =0; - header_type = 0; - Rxcount = 0; - for (i=0;i<4;i++) rx_header[i] = tx_header[i] = 0; - Rxpos = Txpos = 0; - RxCRC = 0; - Txfcs32 = 0; - - return ; + ZF0_CMD = CANFC32|CANFDX|CANOVIO; /* not chose CANFC32,CANRLE,although it have been supported */ + ZF1_CMD = 0; /* fix header length,not support CANVHDR */ + ZF2_CMD = 0; + ZF3_CMD = 0; + Rxframeind =0; + header_type = 0; + Rxcount = 0; + for (i=0;i<4;i++) rx_header[i] = tx_header[i] = 0; + Rxpos = Txpos = 0; + RxCRC = 0; + Txfcs32 = 0; + + return ; } /* send binary header */ void zsend_bin_header(rt_uint8_t type, rt_uint8_t *hdr) { - rt_uint8_t i; - rt_uint32_t crc; - - zsend_byte(ZPAD); - zsend_byte(ZDLE); - TxCRC = Txfcs32; - if (TxCRC == 0) - { - zsend_byte(ZBIN); - zsend_zdle_char(type); - /* add 16bits crc */ - crc = 0L; - crc = updcrc16(type, 0); - for (i=0;i<4;i++) - { - zsend_zdle_char(*hdr); - crc = updcrc16((0377 & *hdr++),crc); - } - crc = updcrc16(0,updcrc16(0,crc)); - zsend_zdle_char(((int)(crc>>8))); - zsend_zdle_char(crc); - } - else if(TxCRC == 1) - { + rt_uint8_t i; + rt_uint32_t crc; + + zsend_byte(ZPAD); + zsend_byte(ZDLE); + TxCRC = Txfcs32; + if (TxCRC == 0) + { + zsend_byte(ZBIN); + zsend_zdle_char(type); + /* add 16bits crc */ + crc = 0L; + crc = updcrc16(type, 0); + for (i=0;i<4;i++) + { + zsend_zdle_char(*hdr); + crc = updcrc16((0377 & *hdr++),crc); + } + crc = updcrc16(0,updcrc16(0,crc)); + zsend_zdle_char(((int)(crc>>8))); + zsend_zdle_char(crc); + } + else if(TxCRC == 1) + { zsend_byte(ZBIN32); - zsend_zdle_char(type); - /* add 32bits crc */ - crc = 0xffffffffL; - crc = updcrc32(type, crc); + zsend_zdle_char(type); + /* add 32bits crc */ + crc = 0xffffffffL; + crc = updcrc32(type, crc); for (i=0;i<4;i++) - { - zsend_zdle_char(*hdr); - crc = updcrc32((0377 & *hdr++), crc); - } - crc = ~crc; - for (i=0; i<4;i++) - { - zsend_zdle_char(crc); - crc >>= 8; - } - } - else if (TxCRC == 2) - { - zsend_byte(ZBINR32); - zsend_zdle_char(type); - /* add 32bits crc */ - crc = 0xffffffffL; - crc = updcrc32(type, crc); + { + zsend_zdle_char(*hdr); + crc = updcrc32((0377 & *hdr++), crc); + } + crc = ~crc; + for (i=0; i<4;i++) + { + zsend_zdle_char(crc); + crc >>= 8; + } + } + else if (TxCRC == 2) + { + zsend_byte(ZBINR32); + zsend_zdle_char(type); + /* add 32bits crc */ + crc = 0xffffffffL; + crc = updcrc32(type, crc); for (i=0;i<4;i++) - { - zsend_zdle_char(*hdr); - crc = updcrc32((0377 & *hdr++), crc); - } - crc = ~crc; - for (i=0; i<4;i++) - { - zsend_zdle_char(crc); - crc >>= 8; - } - } - - return; + { + zsend_zdle_char(*hdr); + crc = updcrc32((0377 & *hdr++), crc); + } + crc = ~crc; + for (i=0; i<4;i++) + { + zsend_zdle_char(crc); + crc >>= 8; + } + } + + return; } /* send hex header */ void zsend_hex_header(rt_uint8_t type, rt_uint8_t *hdr) { - rt_uint8_t i; - rt_uint16_t crc; - - zsend_line(ZPAD); zsend_line(ZPAD); zsend_line(ZDLE); - zsend_line(ZHEX); - zsend_ascii(type); - crc = updcrc16(type, 0); - for (i=0; i<4; i++) - { - zsend_ascii(*hdr); - crc = updcrc16((0377 & *hdr++), crc); - } - crc = updcrc16(0,updcrc16(0,crc)); - zsend_ascii(crc>>8); - zsend_ascii(crc); - /* send display control cmd */ - zsend_line(015); zsend_line(0212); - if (type != ZFIN && type != ZACK) - zsend_line(021); - TxCRC = 0; /* clear tx crc type */ - - return; + rt_uint8_t i; + rt_uint16_t crc; + + zsend_line(ZPAD); zsend_line(ZPAD); zsend_line(ZDLE); + zsend_line(ZHEX); + zsend_ascii(type); + crc = updcrc16(type, 0); + for (i=0; i<4; i++) + { + zsend_ascii(*hdr); + crc = updcrc16((0377 & *hdr++), crc); + } + crc = updcrc16(0,updcrc16(0,crc)); + zsend_ascii(crc>>8); + zsend_ascii(crc); + /* send display control cmd */ + zsend_line(015); zsend_line(0212); + if (type != ZFIN && type != ZACK) + zsend_line(021); + TxCRC = 0; /* clear tx crc type */ + + return; } /* send binary data,with frameend */ void zsend_bin_data(rt_uint8_t *buf, rt_int16_t len, rt_uint8_t frameend) { rt_int16_t i,c,tmp; - rt_uint32_t crc; + rt_uint32_t crc; if (TxCRC == 0) /* send binary data with 16bits crc check */ - { - crc = 0x0L; - for (i=0;i>8); - zsend_zdle_char(crc); - } - else if (TxCRC == 1) /* send binary data with 32 bits crc check */ - { - crc = 0xffffffffL; - for (i=0;i>= 8; - } - } - else if (TxCRC == 2) /* send binary data with 32bits crc check,RLE encode */ - { - crc = 0xffffffffL; + { + crc = 0x0L; + for (i=0;i>8); + zsend_zdle_char(crc); + } + else if (TxCRC == 1) /* send binary data with 32 bits crc check */ + { + crc = 0xffffffffL; + for (i=0;i>= 8; + } + } + else if (TxCRC == 2) /* send binary data with 32bits crc check,RLE encode */ + { + crc = 0xffffffffL; tmp = *buf++ & 0377; - for (i = 0; --len >= 0; ++buf) - { - if ((c = *buf & 0377) == tmp && i < 126 && len>0) - { - ++i; continue; - } - if (i==0) - { - zsend_zdle_char(tmp); - crc = updcrc32(tmp, crc); - if (tmp == ZRESC) - { - zsend_zdle_char(0100); crc = updcrc32(0100, crc); - } - tmp = c; - } - else if (i == 1) - { - if (tmp != ZRESC) - { - zsend_zdle_char(tmp); zsend_zdle_char(tmp); - crc = updcrc32(tmp, crc); - crc = updcrc32(tmp, crc); - i = 0; tmp = c; - } - - } - else - { - zsend_zdle_char(ZRESC); crc = updcrc32(ZRESC, crc); - if (tmp == 040 && i < 34) - { - i += 036; - zsend_zdle_char(i); - crc = updcrc32(i, crc); - } - else - { - i += 0101; - zsend_zdle_char(i); crc = updcrc32(i, crc); - zsend_zdle_char(tmp); crc = updcrc32(tmp, crc); - } - i = 0; tmp = c; - } - } - zsend_byte(ZDLE); zsend_byte(frameend); - crc = updcrc32(frameend, crc); - crc = ~crc; - for (i=0;i<4;i++) - { - zsend_zdle_char(crc); - crc >>= 8; - } - } - if (frameend == ZCRCW) - zsend_byte(XON); - - return; + for (i = 0; --len >= 0; ++buf) + { + if ((c = *buf & 0377) == tmp && i < 126 && len>0) + { + ++i; continue; + } + if (i==0) + { + zsend_zdle_char(tmp); + crc = updcrc32(tmp, crc); + if (tmp == ZRESC) + { + zsend_zdle_char(0100); crc = updcrc32(0100, crc); + } + tmp = c; + } + else if (i == 1) + { + if (tmp != ZRESC) + { + zsend_zdle_char(tmp); zsend_zdle_char(tmp); + crc = updcrc32(tmp, crc); + crc = updcrc32(tmp, crc); + i = 0; tmp = c; + } + + } + else + { + zsend_zdle_char(ZRESC); crc = updcrc32(ZRESC, crc); + if (tmp == 040 && i < 34) + { + i += 036; + zsend_zdle_char(i); + crc = updcrc32(i, crc); + } + else + { + i += 0101; + zsend_zdle_char(i); crc = updcrc32(i, crc); + zsend_zdle_char(tmp); crc = updcrc32(tmp, crc); + } + i = 0; tmp = c; + } + } + zsend_byte(ZDLE); zsend_byte(frameend); + crc = updcrc32(frameend, crc); + crc = ~crc; + for (i=0;i<4;i++) + { + zsend_zdle_char(crc); + crc >>= 8; + } + } + if (frameend == ZCRCW) + zsend_byte(XON); + + return; } /* receive data,with 16bits CRC check */ static rt_int16_t zrec_data16(rt_uint8_t *buf, rt_uint16_t len) { - rt_int16_t c,crc_cnt; - rt_uint16_t crc; - rt_err_t res = -RT_ERROR; - rt_uint8_t *p,flag = 0; - - p = buf; - crc_cnt = 0; crc = 0L; - Rxcount = 0; - while(buf <= p+len) - { - if ((res = zread_byte()) & ~0377) - { - if (res == GOTCRCE || res == GOTCRCG || - res == GOTCRCQ || res == GOTCRCW) - { - c = res; - c = res; - crc = updcrc16(res&0377, crc); - flag = 1; - continue; - } - else if (res == GOTCAN) return ZCAN; - else if (res == TIMEOUT) return TIMEOUT; - else return res; - - } - else - { - if (flag) - { - crc = updcrc16(res, crc); - crc_cnt++; - if (crc_cnt < 2) continue; - if ((crc & 0xffff)) - { + rt_int16_t c,crc_cnt; + rt_uint16_t crc; + rt_err_t res = -RT_ERROR; + rt_uint8_t *p,flag = 0; + + p = buf; + crc_cnt = 0; crc = 0L; + Rxcount = 0; + while(buf <= p+len) + { + if ((res = zread_byte()) & ~0377) + { + if (res == GOTCRCE || res == GOTCRCG || + res == GOTCRCQ || res == GOTCRCW) + { + c = res; + c = res; + crc = updcrc16(res&0377, crc); + flag = 1; + continue; + } + else if (res == GOTCAN) return ZCAN; + else if (res == TIMEOUT) return TIMEOUT; + else return res; + + } + else + { + if (flag) + { + crc = updcrc16(res, crc); + crc_cnt++; + if (crc_cnt < 2) continue; + if ((crc & 0xffff)) + { #ifdef ZDEBUG - rt_kprintf("error code: CRC16 error \r\n"); + rt_kprintf("error code: CRC16 error \r\n"); #endif - return -RT_ERROR; - } + return -RT_ERROR; + } return c; - } - else - { - *buf++ = res; - Rxcount++; - crc = updcrc16(res, crc); - } - } - } - - return -RT_ERROR; + } + else + { + *buf++ = res; + Rxcount++; + crc = updcrc16(res, crc); + } + } + } + + return -RT_ERROR; } /* receive data,with 32bits CRC check */ static rt_int16_t zrec_data32(rt_uint8_t *buf, rt_int16_t len) { - rt_int16_t c,crc_cnt; - rt_uint32_t crc; - rt_err_t res = -RT_ERROR; - rt_uint8_t *p,flag = 0; - - crc_cnt = 0; crc = 0xffffffffL; - Rxcount = 0; - while (buf <= p+len) - { - if ((res = zread_byte()) & ~0377) - { - if (res == GOTCRCE || res == GOTCRCG || - res == GOTCRCQ || res == GOTCRCW) - { - c = res; - crc = updcrc32(res&0377, crc); - flag = 1; - continue; - } - else if (res == GOTCAN) return ZCAN; - else if (res == TIMEOUT) return TIMEOUT; - else return res; - - } - else - { - if (flag) - { - crc = updcrc32(res, crc); - crc_cnt++; - if (crc_cnt < 4) continue; - if ((crc & 0xDEBB20E3)) - { + rt_int16_t c,crc_cnt; + rt_uint32_t crc; + rt_err_t res = -RT_ERROR; + rt_uint8_t *p,flag = 0; + + crc_cnt = 0; crc = 0xffffffffL; + Rxcount = 0; + while (buf <= p+len) + { + if ((res = zread_byte()) & ~0377) + { + if (res == GOTCRCE || res == GOTCRCG || + res == GOTCRCQ || res == GOTCRCW) + { + c = res; + crc = updcrc32(res&0377, crc); + flag = 1; + continue; + } + else if (res == GOTCAN) return ZCAN; + else if (res == TIMEOUT) return TIMEOUT; + else return res; + + } + else + { + if (flag) + { + crc = updcrc32(res, crc); + crc_cnt++; + if (crc_cnt < 4) continue; + if ((crc & 0xDEBB20E3)) + { #ifdef ZDEBUG - rt_kprintf("error code: CRC32 error \r\n"); + rt_kprintf("error code: CRC32 error \r\n"); #endif - return -RT_ERROR; - } + return -RT_ERROR; + } return c; - } - else - { - *buf++ = res; - Rxcount++; - crc = updcrc32(res, crc); - } - } - } - - return -RT_ERROR; + } + else + { + *buf++ = res; + Rxcount++; + crc = updcrc32(res, crc); + } + } + } + + return -RT_ERROR; } /* receive data,with RLE encoded,32bits CRC check */ static rt_int16_t zrec_data32r(rt_uint8_t *buf, rt_int16_t len) { - rt_int16_t c,crc_cnt; - rt_uint32_t crc; - rt_err_t res = -RT_ERROR; - rt_uint8_t *p,flag = 0; - - crc_cnt = 0; crc = 0xffffffffL; - Rxcount = 0; - p = buf; - while (buf <= p+len) - { - if ((res = zread_byte()) & ~0377) - { - if (res == GOTCRCE || res == GOTCRCG || - res == GOTCRCQ || res == GOTCRCW) - { - c = res; - crc = updcrc32(res&0377, crc); - flag = 1; - continue; - } - else if (res == GOTCAN) return ZCAN; - else if (res == TIMEOUT) return TIMEOUT; - else return res; - - } - else - { - if (flag) - { - crc = updcrc32(res, crc); - crc_cnt++; - if (crc_cnt < 4) continue; - if ((crc & 0xDEBB20E3)) - { + rt_int16_t c,crc_cnt; + rt_uint32_t crc; + rt_err_t res = -RT_ERROR; + rt_uint8_t *p,flag = 0; + + crc_cnt = 0; crc = 0xffffffffL; + Rxcount = 0; + p = buf; + while (buf <= p+len) + { + if ((res = zread_byte()) & ~0377) + { + if (res == GOTCRCE || res == GOTCRCG || + res == GOTCRCQ || res == GOTCRCW) + { + c = res; + crc = updcrc32(res&0377, crc); + flag = 1; + continue; + } + else if (res == GOTCAN) return ZCAN; + else if (res == TIMEOUT) return TIMEOUT; + else return res; + + } + else + { + if (flag) + { + crc = updcrc32(res, crc); + crc_cnt++; + if (crc_cnt < 4) continue; + if ((crc & 0xDEBB20E3)) + { #ifdef ZDEBUG - rt_kprintf("error code: CRC32 error \r\n"); + rt_kprintf("error code: CRC32 error \r\n"); #endif - return -RT_ERROR; - } + return -RT_ERROR; + } return c; - } - else - { - crc = updcrc32(res, crc); - switch (c) - { - case 0: - if (res == ZRESC) - { - c = -1; continue; - } - *buf++ = res; - Rxcount++; - continue; - case -1: - if (res >= 040 && res < 0100) - { - c = res - 035; res = 040; - goto spaces; - } - if (res == 0100) - { - c = 0; - *buf++ = ZRESC; - Rxcount++; - continue; - } - c = res; continue; - default: - c -= 0100; - if (c < 1) - goto end; + } + else + { + crc = updcrc32(res, crc); + switch (c) + { + case 0: + if (res == ZRESC) + { + c = -1; continue; + } + *buf++ = res; + Rxcount++; + continue; + case -1: + if (res >= 040 && res < 0100) + { + c = res - 035; res = 040; + goto spaces; + } + if (res == 0100) + { + c = 0; + *buf++ = ZRESC; + Rxcount++; + continue; + } + c = res; continue; + default: + c -= 0100; + if (c < 1) + goto end; spaces: - if ((buf + c) > p+len) - goto end; - while ( --res >= 0) - { - *buf++ = res; - Rxcount++; - } - c = 0; continue; - } - } - } // if -else - - } + if ((buf + c) > p+len) + goto end; + while ( --res >= 0) + { + *buf++ = res; + Rxcount++; + } + c = 0; continue; + } + } + } // if -else + + } end: - return -RT_ERROR; + return -RT_ERROR; } rt_int16_t zget_data(rt_uint8_t *buf, rt_uint16_t len) { - rt_int16_t res = -RT_ERROR; - - if (RxCRC == 0) - { - res = zrec_data16(buf,len); - } - else if (RxCRC == 1) - { - res = zrec_data32(buf, len); - } - else if (RxCRC == 2) - { - res = zrec_data32r(buf, len); - } - - return res; + rt_int16_t res = -RT_ERROR; + + if (RxCRC == 0) + { + res = zrec_data16(buf,len); + } + else if (RxCRC == 1) + { + res = zrec_data32(buf, len); + } + else if (RxCRC == 2) + { + res = zrec_data32r(buf, len); + } + + return res; } /* get type and cmd of header, fix lenght */ rt_int16_t zget_header(rt_uint8_t *hdr) { - rt_int16_t c,prev_char; - rt_uint32_t bit; - rt_uint16_t get_can,step_out; + rt_int16_t c,prev_char; + rt_uint32_t bit; + rt_uint16_t get_can,step_out; - bit = get_device_baud(); /* get console baud rate */ - Rxframeind = header_type = 0; + bit = get_device_baud(); /* get console baud rate */ + Rxframeind = header_type = 0; step_out = 0; - prev_char = 0xff; - for (;;) - { - c = zread_line(100); - switch(c) - { - case 021: - case 0221: - if (prev_char == CAN) break; - if (prev_char == ZCRCW) goto start_again; - break; - case RCDO: - goto end; - case TIMEOUT: - if (prev_char == CAN) break; - if (prev_char == ZCRCW) - { - c = -RT_ERROR; goto end; - } - goto end; - case ZCRCW: - if (prev_char == CAN) goto start_again; - break; - case CAN: + prev_char = 0xff; + for (;;) + { + c = zread_line(100); + switch(c) + { + case 021: + case 0221: + if (prev_char == CAN) break; + if (prev_char == ZCRCW) goto start_again; + break; + case RCDO: + goto end; + case TIMEOUT: + if (prev_char == CAN) break; + if (prev_char == ZCRCW) + { + c = -RT_ERROR; goto end; + } + goto end; + case ZCRCW: + if (prev_char == CAN) goto start_again; + break; + case CAN: get_can: - if (++get_can > 5) - { - c = ZCAN; goto end; + if (++get_can > 5) + { + c = ZCAN; goto end; } - break; - case ZPAD: - if (prev_char == CAN) break; - if (prev_char == ZCRCW) goto start_again; - step_out = 1; - break; - default: - if (prev_char == CAN) break; - if (prev_char == ZCRCW) goto start_again; + break; + case ZPAD: + if (prev_char == CAN) break; + if (prev_char == ZCRCW) goto start_again; + step_out = 1; + break; + default: + if (prev_char == CAN) break; + if (prev_char == ZCRCW) goto start_again; start_again: - if (--bit == 0) - { - c = GCOUNT; goto end; - } - get_can = 0; - break; - } - prev_char = c; - if (step_out) break; /* exit loop */ - } - step_out = get_can = 0; - for (;;) - { - c = zxor_read(); - switch(c) - { - case ZPAD: - break; - case RCDO: - case TIMEOUT: - goto end; - case ZDLE: - step_out = 1; - break; - default: - goto start_again; - } - if (step_out) break; - } - - Rxframeind = c = zxor_read(); - switch (c) - { - case ZBIN32: - RxCRC = 1; c = zget_bin_fcs(hdr); break; - case ZBINR32: - RxCRC = 2; c = zget_bin_fcs(hdr); break; - case ZBIN: - RxCRC = 0; c = zget_bin_header(hdr); break; - case ZHEX: - RxCRC = 0; c = zget_hex_header(hdr); break; - case CAN: - goto get_can; - case RCDO: - case TIMEOUT: - goto end; - default: - goto start_again; - } + if (--bit == 0) + { + c = GCOUNT; goto end; + } + get_can = 0; + break; + } + prev_char = c; + if (step_out) break; /* exit loop */ + } + step_out = get_can = 0; + for (;;) + { + c = zxor_read(); + switch(c) + { + case ZPAD: + break; + case RCDO: + case TIMEOUT: + goto end; + case ZDLE: + step_out = 1; + break; + default: + goto start_again; + } + if (step_out) break; + } + + Rxframeind = c = zxor_read(); + switch (c) + { + case ZBIN32: + RxCRC = 1; c = zget_bin_fcs(hdr); break; + case ZBINR32: + RxCRC = 2; c = zget_bin_fcs(hdr); break; + case ZBIN: + RxCRC = 0; c = zget_bin_header(hdr); break; + case ZHEX: + RxCRC = 0; c = zget_hex_header(hdr); break; + case CAN: + goto get_can; + case RCDO: + case TIMEOUT: + goto end; + default: + goto start_again; + } end: - return c; + return c; } /* receive a binary header */ static rt_int16_t zget_bin_header(rt_uint8_t *hdr) { - rt_int16_t res, i; - rt_uint16_t crc; - - if ((res = zread_byte()) & ~0377) - return res; - header_type = res; - crc = updcrc16(res, 0); - - for (i=0;i<4;i++) - { - if ((res = zread_byte()) & ~0377) - return res; - crc = updcrc16(res, crc); - *hdr++ = res; - } - if ((res = zread_byte()) & ~0377) - return res; - crc = updcrc16(res, crc); - if ((res = zread_byte()) & ~0377) - return res; - crc = updcrc16(res, crc); - if (crc & 0xFFFF) - { - rt_kprintf("CRC error\n"); - return -RT_ERROR; - } - - return header_type; + rt_int16_t res, i; + rt_uint16_t crc; + + if ((res = zread_byte()) & ~0377) + return res; + header_type = res; + crc = updcrc16(res, 0); + + for (i=0;i<4;i++) + { + if ((res = zread_byte()) & ~0377) + return res; + crc = updcrc16(res, crc); + *hdr++ = res; + } + if ((res = zread_byte()) & ~0377) + return res; + crc = updcrc16(res, crc); + if ((res = zread_byte()) & ~0377) + return res; + crc = updcrc16(res, crc); + if (crc & 0xFFFF) + { + rt_kprintf("CRC error\n"); + return -RT_ERROR; + } + + return header_type; } /* receive a binary header,with 32bits FCS */ static rt_int16_t zget_bin_fcs(rt_uint8_t *hdr) { - rt_int16_t res, i; - rt_uint32_t crc; - - if ((res = zread_byte()) & ~0377) - return res; - header_type = res; - crc = 0xFFFFFFFFL; - crc = updcrc32(res, crc); - - for (i=0;i<4;i++) /* 4headers */ - { - if ((res = zread_byte()) & ~0377) - return res; - crc = updcrc32(res, crc); - *hdr++ = res; - - } - for (i=0;i<4;i++) /* 4bytes crc */ - { - if ((res = zread_byte()) & ~0377) - return res; - crc = updcrc32(res, crc); - - } - if (crc != 0xDEBB20E3) - { + rt_int16_t res, i; + rt_uint32_t crc; + + if ((res = zread_byte()) & ~0377) + return res; + header_type = res; + crc = 0xFFFFFFFFL; + crc = updcrc32(res, crc); + + for (i=0;i<4;i++) /* 4headers */ + { + if ((res = zread_byte()) & ~0377) + return res; + crc = updcrc32(res, crc); + *hdr++ = res; + + } + for (i=0;i<4;i++) /* 4bytes crc */ + { + if ((res = zread_byte()) & ~0377) + return res; + crc = updcrc32(res, crc); + + } + if (crc != 0xDEBB20E3) + { #ifdef ZDEBUG - rt_kprintf("CRC error\n"); + rt_kprintf("CRC error\n"); #endif - return -RT_ERROR; - } + return -RT_ERROR; + } - return header_type; + return header_type; } /* receive a hex style header (type and position) */ rt_int16_t zget_hex_header(rt_uint8_t *hdr) { - rt_int16_t res,i; - rt_uint16_t crc; - - if ((res = zget_hex()) < 0) - return res; - header_type = res; - crc = updcrc16(res, 0); - - for (i=0;i<4;i++) - { - if ((res = zget_hex()) < 0) - return res; - crc = updcrc16(res, crc); - *hdr++ = res; - } - if ((res = zget_hex()) < 0) - return res; - crc = updcrc16(res, crc); - if ((res = zget_hex()) < 0) - return res; - crc = updcrc16(res, crc); - if (crc & 0xFFFF) - { + rt_int16_t res,i; + rt_uint16_t crc; + + if ((res = zget_hex()) < 0) + return res; + header_type = res; + crc = updcrc16(res, 0); + + for (i=0;i<4;i++) + { + if ((res = zget_hex()) < 0) + return res; + crc = updcrc16(res, crc); + *hdr++ = res; + } + if ((res = zget_hex()) < 0) + return res; + crc = updcrc16(res, crc); + if ((res = zget_hex()) < 0) + return res; + crc = updcrc16(res, crc); + if (crc & 0xFFFF) + { #ifdef ZDEBUG - rt_kprintf("error code : CRC error\r\n"); + rt_kprintf("error code : CRC error\r\n"); #endif - return -RT_ERROR; - } - res = zread_line(100); - if (res < 0) - return res; - res = zread_line(100); - if (res < 0) - return res; - - return header_type; + return -RT_ERROR; + } + res = zread_line(100); + if (res < 0) + return res; + res = zread_line(100); + if (res < 0) + return res; + + return header_type; } /* convert to ascii */ static void zsend_ascii(rt_uint8_t c) { - const char hex[] = "0123456789abcdef"; + const char hex[] = "0123456789abcdef"; - zsend_line(hex[(c&0xF0)>>4]); - zsend_line(hex[(c)&0xF]); + zsend_line(hex[(c&0xF0)>>4]); + zsend_line(hex[(c)&0xF]); - return; + return; } /* @@ -723,54 +723,54 @@ static void zsend_ascii(rt_uint8_t c) */ void zsend_zdle_char(rt_uint16_t ch) { - rt_uint16_t res; - - res = ch & 0377; - switch (res) - { - case 0377: - zsend_byte(res); - break; - case ZDLE: - zsend_byte(ZDLE); - res ^= 0100; - zsend_byte(res); - break; - case 021: - case 023: - case 0221: - case 0223: - zsend_byte(ZDLE); - res ^= 0100; - zsend_byte(res); - break; - default: - zsend_byte(res); - } + rt_uint16_t res; + + res = ch & 0377; + switch (res) + { + case 0377: + zsend_byte(res); + break; + case ZDLE: + zsend_byte(ZDLE); + res ^= 0100; + zsend_byte(res); + break; + case 021: + case 023: + case 0221: + case 0223: + zsend_byte(ZDLE); + res ^= 0100; + zsend_byte(res); + break; + default: + zsend_byte(res); + } } /* decode two lower case hex digits into an 8 bit byte value */ static rt_int16_t zget_hex(void) { - rt_int16_t res,n; - - if ((res = zxor_read()) < 0) - return res; - n = res - '0'; - if (n > 9) - n -= ('a' - ':'); - if (n & ~0x0f) - return -RT_ERROR; - if ((res = zxor_read()) < 0) - return res; - res -= '0'; - if (res > 9) - res -= ('a' - ':'); - if (res & ~0x0f) - return -RT_ERROR; - res += (n<<4); - - return res; + rt_int16_t res,n; + + if ((res = zxor_read()) < 0) + return res; + n = res - '0'; + if (n > 9) + n -= ('a' - ':'); + if (n & ~0x0f) + return -RT_ERROR; + if ((res = zxor_read()) < 0) + return res; + res -= '0'; + if (res > 9) + res -= ('a' - ':'); + if (res & ~0x0f) + return -RT_ERROR; + res += (n<<4); + + return res; } @@ -780,58 +780,58 @@ static rt_int16_t zget_hex(void) */ rt_int16_t zread_byte(void) { - register int res; + register int res; again: - /* Quick check for non control characters */ - if ((res = zread_line(100)) & 0140) - return res; - switch (res) - { - case ZDLE: - break; - case 023: - case 0223: - case 021: - case 0221: - goto again; - default: - return res; - } + /* Quick check for non control characters */ + if ((res = zread_line(100)) & 0140) + return res; + switch (res) + { + case ZDLE: + break; + case 023: + case 0223: + case 021: + case 0221: + goto again; + default: + return res; + } again2: - if ((res = zread_line(100)) < 0) - return res; - if (res == CAN && (res = zread_line(100)) < 0) - return res; - if (res == CAN && (res = zread_line(100)) < 0) - return res; - if (res == CAN && (res = zread_line(100)) < 0) - return res; - switch (res) - { - case CAN: - return GOTCAN; - case ZCRCE: - case ZCRCG: - case ZCRCQ: - case ZCRCW: - return (res | GOTOR); - case ZRUB0: - return 0177; - case ZRUB1: - return 0377; - case 023: - case 0223: - case 021: - case 0221: - goto again2; - default: - if ((res & 0140) == 0100) - return (res ^ 0100); - break; - } - - return -RT_ERROR; + if ((res = zread_line(100)) < 0) + return res; + if (res == CAN && (res = zread_line(100)) < 0) + return res; + if (res == CAN && (res = zread_line(100)) < 0) + return res; + if (res == CAN && (res = zread_line(100)) < 0) + return res; + switch (res) + { + case CAN: + return GOTCAN; + case ZCRCE: + case ZCRCG: + case ZCRCQ: + case ZCRCW: + return (res | GOTOR); + case ZRUB0: + return 0177; + case ZRUB1: + return 0377; + case 023: + case 0223: + case 021: + case 0221: + goto again2; + default: + if ((res & 0140) == 0100) + return (res ^ 0100); + break; + } + + return -RT_ERROR; } /* @@ -840,46 +840,46 @@ again2: */ rt_int16_t zxor_read(void) { - rt_int16_t res; - - for (;;) - { - if ((res = zread_line(100)) < 0) - return res; - switch (res &= 0177) { - case XON: - case XOFF: - continue; - case '\r': - case '\n': - case ZDLE: - default: - return res; - } - } + rt_int16_t res; + + for (;;) + { + if ((res = zread_line(100)) < 0) + return res; + switch (res &= 0177) { + case XON: + case XOFF: + continue; + case '\r': + case '\n': + case ZDLE: + default: + return res; + } + } } /* put file posistion into the header*/ void zput_pos(rt_uint32_t pos) { - tx_header[ZP0] = pos; - tx_header[ZP1] = pos>>8; - tx_header[ZP2] = pos>>16; - tx_header[ZP3] = pos>>24; + tx_header[ZP0] = pos; + tx_header[ZP1] = pos>>8; + tx_header[ZP2] = pos>>16; + tx_header[ZP3] = pos>>24; - return; + return; } /* Recover a long integer from a header */ void zget_pos(rt_uint32_t pos) { - Rxpos = (rx_header[ZP3] & 0377); - Rxpos = (Rxpos << 8) | (rx_header[ZP2] & 0377); - Rxpos = (Rxpos << 8) | (rx_header[ZP1] & 0377); - Rxpos = (Rxpos << 8) | (rx_header[ZP0] & 0377); + Rxpos = (rx_header[ZP3] & 0377); + Rxpos = (Rxpos << 8) | (rx_header[ZP2] & 0377); + Rxpos = (Rxpos << 8) | (rx_header[ZP1] & 0377); + Rxpos = (Rxpos << 8) | (rx_header[ZP0] & 0377); - return; + return; } /* end of zcore.c */ diff --git a/components/utilities/zmodem/zdef.h b/components/utilities/zmodem/zdef.h index 3568bdfd96..cfb9784f30 100644 --- a/components/utilities/zmodem/zdef.h +++ b/components/utilities/zmodem/zdef.h @@ -3,133 +3,133 @@ #include #include "crc.h" -#define ZPAD '*' /* 052 padding character begins frames */ -#define ZDLE 030 /* ctrl-X ZMODEM escape - `ala BISYNC DLE */ -#define ZDLEE (ZDLE^0100) /* escaped ZDLE as transmitted */ -#define ZBIN 'A' /* binary frame indicator (CRC-16) */ -#define ZHEX 'B' /* hex frame indicator */ -#define ZBIN32 'C' /* binary frame with 32 bit FCS */ -#define ZBINR32 'D' /* RLE packed Binary frame with 32 bit FCS */ -#define ZVBIN 'a' /* binary frame indicator (CRC-16) */ -#define ZVHEX 'b' /* hex frame indicator */ -#define ZVBIN32 'c' /* binary frame with 32 bit FCS */ -#define ZVBINR32 'd' /* RLE packed Binary frame with 32 bit FCS */ -#define ZRESC 0176 /* RLE flag/escape character */ +#define ZPAD '*' /* 052 padding character begins frames */ +#define ZDLE 030 /* ctrl-X ZMODEM escape - `ala BISYNC DLE */ +#define ZDLEE (ZDLE^0100) /* escaped ZDLE as transmitted */ +#define ZBIN 'A' /* binary frame indicator (CRC-16) */ +#define ZHEX 'B' /* hex frame indicator */ +#define ZBIN32 'C' /* binary frame with 32 bit FCS */ +#define ZBINR32 'D' /* RLE packed Binary frame with 32 bit FCS */ +#define ZVBIN 'a' /* binary frame indicator (CRC-16) */ +#define ZVHEX 'b' /* hex frame indicator */ +#define ZVBIN32 'c' /* binary frame with 32 bit FCS */ +#define ZVBINR32 'd' /* RLE packed Binary frame with 32 bit FCS */ +#define ZRESC 0176 /* RLE flag/escape character */ /* Frame types */ -#define ZRQINIT 0 /* request receive init */ +#define ZRQINIT 0 /* request receive init */ #define ZRINIT 1 /* receive init */ -#define ZSINIT 2 /* send init sequence (optional) */ -#define ZACK 3 /* ACK to above */ -#define ZFILE 4 /* file name from sender */ -#define ZSKIP 5 /* ro sender: skip this file */ -#define ZNAK 6 /* last packet was garbled */ -#define ZABORT 7 /* abort batch transfers */ -#define ZFIN 8 /* finish session */ -#define ZRPOS 9 /* resume data trans at this position */ +#define ZSINIT 2 /* send init sequence (optional) */ +#define ZACK 3 /* ACK to above */ +#define ZFILE 4 /* file name from sender */ +#define ZSKIP 5 /* ro sender: skip this file */ +#define ZNAK 6 /* last packet was garbled */ +#define ZABORT 7 /* abort batch transfers */ +#define ZFIN 8 /* finish session */ +#define ZRPOS 9 /* resume data trans at this position */ #define ZDATA 10 /* data packet(s) follow */ #define ZEOF 11 /* end of file */ #define ZFERR 12 /* fatal Read or Write error Detected */ #define ZCRC 13 /* request for file CRC and response */ #define ZCHALLENGE 14 /* receiver's Challenge */ -#define ZCOMPL 15 /* request is complete */ -#define ZCAN 16 /* other end canned session with CAN*5 */ -#define ZFREECNT 17 /* request for free bytes on filesystem */ -#define ZCOMMAND 18 /* command from sending program */ +#define ZCOMPL 15 /* request is complete */ +#define ZCAN 16 /* other end canned session with CAN*5 */ +#define ZFREECNT 17 /* request for free bytes on filesystem */ +#define ZCOMMAND 18 /* command from sending program */ /* ZDLE sequfences */ -#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */ -#define ZCRCG 'i' /* CRC next, frame continues nonstop */ -#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */ -#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */ -#define ZRUB0 'l' /* translate to rubout 0177 */ -#define ZRUB1 'm' /* translate to rubout 0377 */ +#define ZCRCE 'h' /* CRC next, frame ends, header packet follows */ +#define ZCRCG 'i' /* CRC next, frame continues nonstop */ +#define ZCRCQ 'j' /* CRC next, frame continues, ZACK expected */ +#define ZCRCW 'k' /* CRC next, ZACK expected, end of frame */ +#define ZRUB0 'l' /* translate to rubout 0177 */ +#define ZRUB1 'm' /* translate to rubout 0377 */ /* zdlread return values (internal) */ /* -1 is general error, -2 is timeout */ #define GOTOR 0400 -#define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */ -#define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */ -#define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */ -#define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */ -#define GOTCAN (GOTOR|030) /* CAN*5 seen */ +#define GOTCRCE (ZCRCE|GOTOR) /* ZDLE-ZCRCE received */ +#define GOTCRCG (ZCRCG|GOTOR) /* ZDLE-ZCRCG received */ +#define GOTCRCQ (ZCRCQ|GOTOR) /* ZDLE-ZCRCQ received */ +#define GOTCRCW (ZCRCW|GOTOR) /* ZDLE-ZCRCW received */ +#define GOTCAN (GOTOR|030) /* CAN*5 seen */ /* Byte positions within header array */ -#define ZF0 3 /* first flags byte */ -#define ZF1 2 -#define ZF2 1 -#define ZF3 0 -#define ZP0 0 /* low order 8 bits of position */ -#define ZP1 1 -#define ZP2 2 -#define ZP3 3 /* high order 8 bits of file position */ +#define ZF0 3 /* first flags byte */ +#define ZF1 2 +#define ZF2 1 +#define ZF3 0 +#define ZP0 0 /* low order 8 bits of position */ +#define ZP1 1 +#define ZP2 2 +#define ZP3 3 /* high order 8 bits of file position */ /* parameters for ZRINIT header */ -#define ZRPXWN 8 /* 9th byte in header contains window size/256 */ -#define ZRPXQQ 9 /* 10th to 14th bytes contain quote mask */ +#define ZRPXWN 8 /* 9th byte in header contains window size/256 */ +#define ZRPXQQ 9 /* 10th to 14th bytes contain quote mask */ /* bit Masks for ZRINIT flags byte ZF0 */ -#define CANFDX 0x01 /* rx can send and receive true FDX */ -#define CANOVIO 0x02 /* rx can receive data during disk I/O */ -#define CANBRK 0x04 /* rx can send a break signal */ -#define CANRLE 0x10 /* receiver can decode RLE */ -#define CANLZW 0x20 /* receiver can uncompress */ -#define CANFC32 0x28 /* receiver can use 32 bit Frame Check */ -#define ESCCTL 0x64 /* receiver expects ctl chars to be escaped */ -#define ESC8 0xc8 /* receiver expects 8th bit to be escaped */ +#define CANFDX 0x01 /* rx can send and receive true FDX */ +#define CANOVIO 0x02 /* rx can receive data during disk I/O */ +#define CANBRK 0x04 /* rx can send a break signal */ +#define CANRLE 0x10 /* receiver can decode RLE */ +#define CANLZW 0x20 /* receiver can uncompress */ +#define CANFC32 0x28 /* receiver can use 32 bit Frame Check */ +#define ESCCTL 0x64 /* receiver expects ctl chars to be escaped */ +#define ESC8 0xc8 /* receiver expects 8th bit to be escaped */ /* bit Masks for ZRINIT flags byte ZF1 */ -#define CANVHDR 01 /* variable headers OK */ -#define ZRRQWN 8 /* receiver specified window size in ZRPXWN */ -#define ZRRQQQ 16 /* additional control chars to quote in ZRPXQQ */ -#define ZRQNVH (ZRRQWN|ZRRQQQ) /* variable len hdr reqd to access info */ +#define CANVHDR 01 /* variable headers OK */ +#define ZRRQWN 8 /* receiver specified window size in ZRPXWN */ +#define ZRRQQQ 16 /* additional control chars to quote in ZRPXQQ */ +#define ZRQNVH (ZRRQWN|ZRRQQQ) /* variable len hdr reqd to access info */ /* Parameters for ZSINIT frame */ -#define ZATTNLEN 32 /* max length of attention string */ -#define ALTCOFF ZF1 /* offset to alternate canit string, 0 if not used */ +#define ZATTNLEN 32 /* max length of attention string */ +#define ALTCOFF ZF1 /* offset to alternate canit string, 0 if not used */ /* Parameters for ZFILE frame */ /* Conversion options one of these in ZF0 */ -#define ZCBIN 1 /* binary transfer - inhibit conversion */ -#define ZCNL 2 /* convert NL to local end of line convention */ -#define ZCRESUM 3 /* resume interrupted file transfer */ +#define ZCBIN 1 /* binary transfer - inhibit conversion */ +#define ZCNL 2 /* convert NL to local end of line convention */ +#define ZCRESUM 3 /* resume interrupted file transfer */ /* management include options, one of these ored in ZF1 */ #define ZMSKNOLOC 0200 /* skip file if not present at rx */ /* management options, one of these ored in ZF1 */ -#define ZMMASK 037 /* mask for the choices below */ -#define ZMNEWL 1 /* transfer if source newer or longer */ -#define ZMCRC 2 /* transfer if different file CRC or length */ -#define ZMAPND 3 /* append contents to existing file (if any) */ -#define ZMCLOB 4 /* replace existing file */ -#define ZMNEW 5 /* transfer if source newer */ +#define ZMMASK 037 /* mask for the choices below */ +#define ZMNEWL 1 /* transfer if source newer or longer */ +#define ZMCRC 2 /* transfer if different file CRC or length */ +#define ZMAPND 3 /* append contents to existing file (if any) */ +#define ZMCLOB 4 /* replace existing file */ +#define ZMNEW 5 /* transfer if source newer */ /* number 5 is alive ... */ -#define ZMDIFF 6 /* transfer if dates or lengths different */ -#define ZMPROT 7 /* protect destination file */ -#define ZMCHNG 8 /* change filename if destination exists */ +#define ZMDIFF 6 /* transfer if dates or lengths different */ +#define ZMPROT 7 /* protect destination file */ +#define ZMCHNG 8 /* change filename if destination exists */ /* transport options, one of these in ZF2 */ -#define ZTLZW 1 /* lempel-Ziv compression */ -#define ZTRLE 3 /* run Length encoding */ +#define ZTLZW 1 /* lempel-Ziv compression */ +#define ZTRLE 3 /* run Length encoding */ /* extended options for ZF3, bit encoded */ -#define ZXSPARS 64 /* encoding for sparse file operations */ +#define ZXSPARS 64 /* encoding for sparse file operations */ #define ZCANVHDR 01 /* variable headers OK */ /* receiver window size override */ -#define ZRWOVR 4 /* byte position for receive window override/256 */ +#define ZRWOVR 4 /* byte position for receive window override/256 */ /* parameters for ZCOMMAND frame ZF0 (otherwise 0) */ -#define ZCACK1 1 /* acknowledge, then do command */ -extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */ +#define ZCACK1 1 /* acknowledge, then do command */ +extern char Attn[ZATTNLEN+1]; /* Attention string rx sends to tx on err */ /* globals used by ZMODEM functions */ extern rt_uint8_t Rxframeind; /* ZBIN ZBIN32, or ZHEX type of frame */ -extern char header_type; /* type of header received */ +extern char header_type; /* type of header received */ extern rt_uint8_t rx_header[4]; /* received header */ extern rt_uint8_t tx_header[4]; /* transmitted header */ -extern rt_uint8_t Txfcs32; /* TRUE means send binary frames with 32 bit FCS */ -extern rt_uint16_t Rxcount; /* count of data bytes received */ +extern rt_uint8_t Txfcs32; /* TRUE means send binary frames with 32 bit FCS */ +extern rt_uint16_t Rxcount; /* count of data bytes received */ extern rt_uint16_t Rxtimeout; /* tenths of seconds to wait for something */ -extern rt_uint32_t Rxpos; /* received file position */ -extern rt_uint32_t Txpos; /* transmitted file position */ -extern rt_uint8_t Txfcs32; /* TURE means send binary frames with 32 bit FCS */ +extern rt_uint32_t Rxpos; /* received file position */ +extern rt_uint32_t Txpos; /* transmitted file position */ +extern rt_uint8_t Txfcs32; /* TURE means send binary frames with 32 bit FCS */ /* ward Christensen / CP/M parameters - Don't change these! */ #define ENQ 005 @@ -141,34 +141,34 @@ extern rt_uint8_t Txfcs32; /* TURE means send binary frames with 32 bit #define ETX 3 #define SYN 026 #define ESC 033 -#define WANTG 0107 /* send G not NAK to get nonstop batch xmsn */ +#define WANTG 0107 /* send G not NAK to get nonstop batch xmsn */ #define EOT 4 #define ACK 6 #define NAK 025 #define CPMEOF 032 -#define WANTCRC 0103 /* send C not NAK to get crc not checksum */ +#define WANTCRC 0103 /* send C not NAK to get crc not checksum */ #define TIMEOUT (-2) #define RCDO (-3) #define GCOUNT (-4) #define ERRORMAX 5 #define RETRYMAX 5 #define WCEOT (-10) - - + + #define BITRATE 115200 #define TX_BUFFER_SIZE 1024 -#define RX_BUFFER_SIZE 1024 /* sender or receiver's max buffer size */ -extern char ZF0_CMD; /* local ZMODEM file conversion request */ -extern char ZF1_CMD; /* local ZMODEM file management request */ -extern char ZF2_CMD; /* local ZMODEM file management request */ -extern char ZF3_CMD; /* local ZMODEM file management request */ +#define RX_BUFFER_SIZE 1024 /* sender or receiver's max buffer size */ +extern char ZF0_CMD; /* local ZMODEM file conversion request */ +extern char ZF1_CMD; /* local ZMODEM file management request */ +extern char ZF2_CMD; /* local ZMODEM file management request */ +extern char ZF3_CMD; /* local ZMODEM file management request */ extern rt_uint32_t Baudrate ; extern rt_uint32_t Left_bytes; extern rt_uint32_t Left_sizes; - + struct zmodemf { @@ -179,18 +179,18 @@ extern struct zmodemf zmodem; struct zfile { - char *fname; - rt_int32_t fd; - rt_uint32_t ctime; + char *fname; + rt_int32_t fd; + rt_uint32_t ctime; rt_uint32_t mode; - rt_uint32_t bytes_total; - rt_uint32_t bytes_sent; - rt_uint32_t bytes_received; - rt_uint32_t file_end; - + rt_uint32_t bytes_total; + rt_uint32_t bytes_sent; + rt_uint32_t bytes_received; + rt_uint32_t file_end; + }; extern struct finsh_shell* shell; - + #define ZDEBUG 0 /* sz.c */ extern void zs_start(char *path); @@ -213,5 +213,5 @@ extern void zsend_line(rt_uint16_t c); extern rt_int16_t zread_line(rt_uint16_t timeout); extern void zsend_break(char *cmd); extern void zsend_can(void); - + #endif /* __ZDEF_H__ */ diff --git a/components/utilities/zmodem/zdevice.c b/components/utilities/zmodem/zdevice.c index 1562cc5f5c..3a144e79de 100644 --- a/components/utilities/zmodem/zdevice.c +++ b/components/utilities/zmodem/zdevice.c @@ -3,7 +3,7 @@ * the implemention of zmodem protocol. * Change Logs: * Date Author Notes - * 2011-03-29 itspy + * 2011-03-29 itspy */ #include @@ -15,11 +15,11 @@ #include #include "zdef.h" - -rt_uint32_t Line_left = 0; /* left number of data in the read line buffer*/ -rt_uint32_t Left_sizes = 0; /* left file sizes */ -rt_uint32_t Baudrate = BITRATE; /* console baudrate */ - + +rt_uint32_t Line_left = 0; /* left number of data in the read line buffer*/ +rt_uint32_t Left_sizes = 0; /* left file sizes */ +rt_uint32_t Baudrate = BITRATE; /* console baudrate */ + rt_uint32_t get_device_baud(void) @@ -34,7 +34,7 @@ rt_uint32_t get_sys_time(void) void zsend_byte(rt_uint16_t ch) { - rt_device_write(zmodem.device, 0, &ch,1); + rt_device_write(zmodem.device, 0, &ch,1); return; } @@ -43,38 +43,38 @@ void zsend_line(rt_uint16_t c) { rt_uint16_t ch; - ch = (c & 0377); - rt_device_write(zmodem.device, 0, &ch, 1); + ch = (c & 0377); + rt_device_write(zmodem.device, 0, &ch, 1); return; } rt_int16_t zread_line(rt_uint16_t timeout) { - char *str; - static char buf[10]; - - if (Line_left > 0) - { - Line_left -= 1; - return (*str++ & 0377); - } - Line_left = 0; - timeout/=5; - while (1) - { - Line_left = rt_device_read(shell->device, 0, buf, 1); - if (Line_left) - { - Line_left = Line_left; - str = buf; - break; - } - } - if (Line_left < 1) return TIMEOUT; - Line_left -=1; - - return (*str++ & 0377); + char *str; + static char buf[10]; + + if (Line_left > 0) + { + Line_left -= 1; + return (*str++ & 0377); + } + Line_left = 0; + timeout/=5; + while (1) + { + Line_left = rt_device_read(shell->device, 0, buf, 1); + if (Line_left) + { + Line_left = Line_left; + str = buf; + break; + } + } + if (Line_left < 1) return TIMEOUT; + Line_left -=1; + + return (*str++ & 0377); } /* @@ -83,32 +83,32 @@ rt_int16_t zread_line(rt_uint16_t timeout) */ void zsend_break(char *cmd) { - - while (*cmd++) - { - switch (*cmd) - { - case '\336': - continue; - case '\335': - rt_thread_delay(RT_TICK_PER_SECOND); - continue; - default: - zsend_line(*cmd); - break; - } - } + + while (*cmd++) + { + switch (*cmd) + { + case '\336': + continue; + case '\335': + rt_thread_delay(RT_TICK_PER_SECOND); + continue; + default: + zsend_line(*cmd); + break; + } + } } /* send cancel string to get the other end to shut up */ void zsend_can(void) { - static char cmd[] = {24,24,24,24,24,24,24,24,24,24,0}; + static char cmd[] = {24,24,24,24,24,24,24,24,24,24,0}; - zsend_break(cmd); - rt_kprintf("\x0d"); - Line_left=0; /* clear Line_left */ + zsend_break(cmd); + rt_kprintf("\x0d"); + Line_left=0; /* clear Line_left */ - return; + return; } /* end of zdevice.c */ diff --git a/components/utilities/zmodem/zstart.c b/components/utilities/zmodem/zstart.c index e5a36ca7ab..5c44ee86a7 100644 --- a/components/utilities/zmodem/zstart.c +++ b/components/utilities/zmodem/zstart.c @@ -3,7 +3,7 @@ * the implemention of zmodem protocol. * Change Logs: * Date Author Notes - * 2011-03-29 itspy + * 2011-03-29 itspy */ #include @@ -27,43 +27,43 @@ rt_err_t zmodem_rx_ind(rt_device_t dev, rt_size_t size) void finsh_rz(void *parameter) { - char *path; + char *path; rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size); - rt_uint8_t flag; + rt_uint8_t flag; - flag = RT_DEVICE_FLAG_STREAM; + flag = RT_DEVICE_FLAG_STREAM; zmodem.device->flag &=(~flag); rt_sem_init(&(zmodem.zsem), "zsem", 0, 0); - path = rt_thread_self()->parameter; - /* save old rx_indicate */ + path = rt_thread_self()->parameter; + /* save old rx_indicate */ rx_indicate = zmodem.device->rx_indicate; /* set new rx_indicate */ rt_device_set_rx_indicate(zmodem.device, RT_NULL); - /* start receive remote files */ + /* start receive remote files */ zr_start(path); - zmodem.device->flag |=flag; - /* recovery old rx_indicate */ + zmodem.device->flag |=flag; + /* recovery old rx_indicate */ rt_device_set_rx_indicate(zmodem.device, rx_indicate); /* finsh>> */ rt_kprintf(FINSH_PROMPT); } void finsh_sz(void *parameter) { - char *path; + char *path; rt_err_t (*rx_indicate)(rt_device_t dev, rt_size_t size); - rt_uint8_t flag; + rt_uint8_t flag; - flag = RT_DEVICE_FLAG_STREAM; + flag = RT_DEVICE_FLAG_STREAM; zmodem.device->flag &=(~flag); rt_sem_init(&(zmodem.zsem), "zsem", 0, 0); - path = rt_thread_self()->parameter; - /* save old rx_indicate */ + path = rt_thread_self()->parameter; + /* save old rx_indicate */ rx_indicate = zmodem.device->rx_indicate; - /* set new rx_indicate */ + /* set new rx_indicate */ rt_device_set_rx_indicate(zmodem.device, zmodem_rx_ind); - zs_start(path); - zmodem.device->flag |=flag; - /* recovery old rx_indicate */ + zs_start(path); + zmodem.device->flag |=flag; + /* recovery old rx_indicate */ rt_device_set_rx_indicate(zmodem.device, rx_indicate); /* finsh>> */ rt_kprintf(FINSH_PROMPT); diff --git a/components/vbus/prio_queue.c b/components/vbus/prio_queue.c index bca3cdcd9a..8c3c648e73 100644 --- a/components/vbus/prio_queue.c +++ b/components/vbus/prio_queue.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vbus/prio_queue.h b/components/vbus/prio_queue.h index 7358ffdb23..0af36d0ea9 100644 --- a/components/vbus/prio_queue.h +++ b/components/vbus/prio_queue.h @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vbus/share_hdr/vbus_api.h b/components/vbus/share_hdr/vbus_api.h index db6cb7b72c..a643822a9c 100644 --- a/components/vbus/share_hdr/vbus_api.h +++ b/components/vbus/share_hdr/vbus_api.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2018, RT-Thread Development Team + * Copyright (c) 2006-2021, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/components/vbus/vbus.c b/components/vbus/vbus.c index 8add15d9db..2adaad9449 100644 --- a/components/vbus/vbus.c +++ b/components/vbus/vbus.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: @@ -899,8 +899,8 @@ int rt_vbus_request_chn(struct rt_vbus_request *req, int timeout) { int i, chnr, err; - size_t plen = rt_strlen(req->name) + 2; - unsigned char *pbuf; + size_t plen = rt_strlen(req->name) + 2; + unsigned char *pbuf; rt_ubase_t lvl; lvl = rt_hw_interrupt_disable(); @@ -930,8 +930,8 @@ int rt_vbus_request_chn(struct rt_vbus_request *req, goto _waitforcmp; } - pbuf = rt_malloc(plen); - if (!pbuf) + pbuf = rt_malloc(plen); + if (!pbuf) { rt_hw_interrupt_enable(lvl); return -RT_ENOMEM; @@ -944,7 +944,7 @@ int rt_vbus_request_chn(struct rt_vbus_request *req, rt_memcpy(pbuf+1, req->name, plen-1); vbus_verbose("%s --> remote\n", dump_cmd_pkt(pbuf, plen)); - err = _chn0_post(pbuf, plen, RT_WAITING_FOREVER); + err = _chn0_post(pbuf, plen, RT_WAITING_FOREVER); rt_free(pbuf); _waitforcmp: diff --git a/components/vbus/vbus.h b/components/vbus/vbus.h index ea271d8e79..661e310e6d 100644 --- a/components/vbus/vbus.h +++ b/components/vbus/vbus.h @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: @@ -51,14 +51,14 @@ struct rt_vbus_data { }; struct rt_vbus_wm_cfg { - unsigned int low, high; + unsigned int low, high; }; struct rt_vbus_request { - unsigned char prio; - const char *name; - int is_server; - struct rt_vbus_wm_cfg recv_wm, post_wm; + unsigned char prio; + const char *name; + int is_server; + struct rt_vbus_wm_cfg recv_wm, post_wm; }; /** Request a channel. diff --git a/components/vbus/vbus_chnx.c b/components/vbus/vbus_chnx.c index d064d6f1f2..1014369cc2 100644 --- a/components/vbus/vbus_chnx.c +++ b/components/vbus/vbus_chnx.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vbus/watermark_queue.c b/components/vbus/watermark_queue.c index e56790d286..15c42d8080 100644 --- a/components/vbus/watermark_queue.c +++ b/components/vbus/watermark_queue.c @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vbus/watermark_queue.h b/components/vbus/watermark_queue.h index 0ecc52d8ff..484d981ed1 100644 --- a/components/vbus/watermark_queue.h +++ b/components/vbus/watermark_queue.h @@ -1,6 +1,6 @@ /* - * COPYRIGHT (C) 2018, Real-Thread Information Technology Ltd - * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vmm/vmm.c b/components/vmm/vmm.c index 2bca67376c..26aee1e3cd 100644 --- a/components/vmm/vmm.c +++ b/components/vmm/vmm.c @@ -1,9 +1,9 @@ /* * VMM startup file. * - * COPYRIGHT (C) 2013-2014, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vmm/vmm.h b/components/vmm/vmm.h index 17bba8439b..ef7d9a1667 100644 --- a/components/vmm/vmm.h +++ b/components/vmm/vmm.h @@ -1,9 +1,9 @@ /* * VMM startup file. * - * COPYRIGHT (C) 2013-2014, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vmm/vmm_context.c b/components/vmm/vmm_context.c index 2e3b95f825..bf8f2a058e 100644 --- a/components/vmm/vmm_context.c +++ b/components/vmm/vmm_context.c @@ -1,7 +1,7 @@ /* - * COPYRIGHT (C) 2013-2014, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vmm/vmm_context.h b/components/vmm/vmm_context.h index 019b681459..88cd27b8f1 100644 --- a/components/vmm/vmm_context.h +++ b/components/vmm/vmm_context.h @@ -1,7 +1,7 @@ /* - * COPYRIGHT (C) 2013-2014, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vmm/vmm_iomap.c b/components/vmm/vmm_iomap.c index 55bd1ac36e..582dcb6945 100644 --- a/components/vmm/vmm_iomap.c +++ b/components/vmm/vmm_iomap.c @@ -1,9 +1,9 @@ /* * VMM IO map table * - * COPYRIGHT (C) 2013-2014, Real-Thread Information Technology Ltd + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: diff --git a/components/vmm/vmm_vector.c b/components/vmm/vmm_vector.c index d7909607ce..1620d66c7d 100644 --- a/components/vmm/vmm_vector.c +++ b/components/vmm/vmm_vector.c @@ -1,9 +1,9 @@ /* * VMM vector handle - * - * COPYRIGHT (C) 2013-2014, Real-Thread Information Technology Ltd + * + * COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd * All rights reserved - * + * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: @@ -23,9 +23,9 @@ void vmm_guest_isr(int irqno, void* parameter) void vmm_vector_init(void) { - rt_hw_interrupt_install(RT_VMM_VIRQ_TRIGGER, vmm_guest_isr, RT_NULL, "virq"); - rt_hw_interrupt_umask(RT_VMM_VIRQ_TRIGGER); + rt_hw_interrupt_install(RT_VMM_VIRQ_TRIGGER, vmm_guest_isr, RT_NULL, "virq"); + rt_hw_interrupt_umask(RT_VMM_VIRQ_TRIGGER); - return; + return; } -- GitLab