Compare commits
8 Commits
7abf53c4d0
...
44049cab77
| Author | SHA1 | Date |
|---|---|---|
|
|
44049cab77 | |
|
|
93a7b2dfd3 | |
|
|
af09afb734 | |
|
|
69efecc428 | |
|
|
3698814740 | |
|
|
6ed0f0ea7f | |
|
|
0cfff2e5da | |
|
|
1e2c8fea4c |
250
CMakeLists.txt
250
CMakeLists.txt
|
|
@ -21,6 +21,25 @@ option(ENABLE_WERROR "Treat all compiler warnings as errors" OFF)
|
||||||
option(ENABLE_GPS "Enable GPS support" OFF)
|
option(ENABLE_GPS "Enable GPS support" OFF)
|
||||||
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
||||||
|
|
||||||
|
# Options for controlling targets. These groups correspond to the README.
|
||||||
|
option(ENABLE_BASIC_TOOLS "Build basic tools" ON)
|
||||||
|
option(ENABLE_IP_SERVER "Build tools providing CAN access via IP sockets" ON)
|
||||||
|
option(ENABLE_GATEWAY "Build in-kernel gateway configuration tools" ON)
|
||||||
|
option(ENABLE_MEASUREMENT "Build measurement tools" ON)
|
||||||
|
option(ENABLE_ISOTP "Build isotp tools" ON)
|
||||||
|
option(ENABLE_LOG_FILE "Build log file converter tools" ON)
|
||||||
|
option(ENABLE_SLCAN "Build slcan tools" ON)
|
||||||
|
option(ENABLE_MCP251XFD "Build MCP251XFD tools" ON)
|
||||||
|
|
||||||
|
# cmake_dependent_option is only available in CMake 3.22 and later.
|
||||||
|
if(ANDROID)
|
||||||
|
set(ENABLE_J1939 OFF)
|
||||||
|
set(ENABLE_ISOBUSFS OFF)
|
||||||
|
else()
|
||||||
|
option(ENABLE_J1939 "Build J1939 tools" ON)
|
||||||
|
option(ENABLE_ISOBUSFS "Build ISOBUS tools" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
if(ENABLE_GPS)
|
if(ENABLE_GPS)
|
||||||
pkg_check_modules(GPS REQUIRED libgps)
|
pkg_check_modules(GPS REQUIRED libgps)
|
||||||
|
|
@ -48,103 +67,111 @@ include_directories(./include)
|
||||||
|
|
||||||
check_function_exists(fork HAVE_FORK)
|
check_function_exists(fork HAVE_FORK)
|
||||||
|
|
||||||
set(PROGRAMS_CANLIB
|
# List of all programs to be built.
|
||||||
asc2log
|
# Each program is expected to have a corresponding source file with the same name.
|
||||||
canbusload
|
set(PROGRAMS)
|
||||||
|
# List of programs to link against can.
|
||||||
|
set(PROGRAMS_CANLIB)
|
||||||
|
# List of programs to link against j1939 and can.
|
||||||
|
set(PROGRAMS_J1939)
|
||||||
|
|
||||||
|
if(ENABLE_BASIC_TOOLS)
|
||||||
|
list(APPEND PROGRAMS cansniffer)
|
||||||
|
list(APPEND PROGRAMS_CANLIB
|
||||||
candump
|
candump
|
||||||
cangen
|
|
||||||
canplayer
|
canplayer
|
||||||
cansend
|
cansend
|
||||||
|
cangen
|
||||||
cansequence
|
cansequence
|
||||||
log2asc
|
)
|
||||||
log2long
|
endif()
|
||||||
slcanpty
|
|
||||||
)
|
|
||||||
|
|
||||||
if(HAVE_FORK)
|
if(ENABLE_IP_SERVER AND HAVE_FORK)
|
||||||
|
list(APPEND PROGRAMS bcmserver)
|
||||||
list(APPEND PROGRAMS_CANLIB canlogserver)
|
list(APPEND PROGRAMS_CANLIB canlogserver)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(PROGRAMS_J1939
|
if(ENABLE_GATEWAY)
|
||||||
j1939acd
|
list(APPEND PROGRAMS cangw)
|
||||||
j1939cat
|
endif()
|
||||||
j1939spy
|
|
||||||
j1939sr
|
|
||||||
testj1939
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PROGRAMS_J1939_TIMEDATE
|
if(ENABLE_MEASUREMENT)
|
||||||
j1939-timedate-srv
|
list(APPEND PROGRAMS
|
||||||
j1939-timedate-cli
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PROGRAMS_J1939_VEHICLE_POSITION
|
|
||||||
j1939-vehicle-position-srv
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PROGRAMS_ISOBUSFS
|
|
||||||
isobusfs-srv
|
|
||||||
isobusfs-cli
|
|
||||||
)
|
|
||||||
|
|
||||||
set(PROGRAMS
|
|
||||||
${PROGRAMS_CANLIB}
|
|
||||||
canerrsim
|
|
||||||
canfdtest
|
canfdtest
|
||||||
cangw
|
canerrsim
|
||||||
cansniffer
|
)
|
||||||
|
list(APPEND PROGRAMS_CANLIB canbusload)
|
||||||
|
|
||||||
|
add_executable(can-calc-bit-timing
|
||||||
|
calc-bit-timing/can-calc-bit-timing.c
|
||||||
|
)
|
||||||
|
install(TARGETS can-calc-bit-timing DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_ISOTP)
|
||||||
|
list(APPEND PROGRAMS
|
||||||
isotpdump
|
isotpdump
|
||||||
isotpperf
|
isotpperf
|
||||||
isotprecv
|
isotprecv
|
||||||
isotpsend
|
isotpsend
|
||||||
isotpsniffer
|
isotpsniffer
|
||||||
isotptun
|
isotptun
|
||||||
slcan_attach
|
)
|
||||||
slcand
|
|
||||||
)
|
|
||||||
|
|
||||||
if(HAVE_FORK)
|
if(HAVE_FORK)
|
||||||
list(APPEND PROGRAMS bcmserver)
|
|
||||||
list(APPEND PROGRAMS isotpserver)
|
list(APPEND PROGRAMS isotpserver)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(can-calc-bit-timing
|
if(ENABLE_J1939)
|
||||||
calc-bit-timing/can-calc-bit-timing.c
|
list(APPEND PROGRAMS_J1939
|
||||||
)
|
j1939acd
|
||||||
|
j1939cat
|
||||||
add_executable(mcp251xfd-dump
|
j1939spy
|
||||||
mcp251xfd/mcp251xfd-dev-coredump.c
|
j1939sr
|
||||||
mcp251xfd/mcp251xfd-dump.c
|
testj1939
|
||||||
mcp251xfd/mcp251xfd-main.c
|
|
||||||
mcp251xfd/mcp251xfd-regmap.c
|
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT ANDROID)
|
|
||||||
list(APPEND PROGRAMS ${PROGRAMS_J1939})
|
|
||||||
|
|
||||||
add_library(j1939 STATIC
|
|
||||||
libj1939.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(j1939
|
add_executable(j1939-timedate-cli
|
||||||
PRIVATE can
|
j1939_timedate/j1939_timedate_cli.c
|
||||||
)
|
)
|
||||||
|
target_link_libraries(j1939-timedate-cli
|
||||||
|
PRIVATE can j1939
|
||||||
|
)
|
||||||
|
install(TARGETS j1939-timedate-cli DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
add_library(isobusfs
|
add_executable(j1939-timedate-srv
|
||||||
|
j1939_timedate/j1939_timedate_srv.c
|
||||||
|
)
|
||||||
|
target_link_libraries(j1939-timedate-srv
|
||||||
|
PRIVATE can j1939
|
||||||
|
)
|
||||||
|
install(TARGETS j1939-timedate-srv DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_J1939 AND ENABLE_GPS)
|
||||||
|
add_executable(j1939-vehicle-position-srv
|
||||||
|
j1939_vehicle_position/j1939_vehicle_position_srv.c
|
||||||
|
)
|
||||||
|
target_link_libraries(j1939-vehicle-position-srv
|
||||||
|
PRIVATE can j1939 ${GPS_LIBRARIES}
|
||||||
|
)
|
||||||
|
install(TARGETS j1939-vehicle-position-srv DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_ISOBUSFS)
|
||||||
|
add_library(isobusfs EXCLUDE_FROM_ALL
|
||||||
isobusfs/isobusfs_cmn.c
|
isobusfs/isobusfs_cmn.c
|
||||||
isobusfs/isobusfs_cmn_dh.c
|
isobusfs/isobusfs_cmn_dh.c
|
||||||
)
|
)
|
||||||
|
|
||||||
set(PUBLIC_HEADER_ISOBUSFS
|
set(PUBLIC_HEADER_ISOBUSFS
|
||||||
isobusfs/isobusfs_cmn.h
|
isobusfs/isobusfs_cmn.h
|
||||||
isobusfs/isobusfs_cmn_cm.h
|
isobusfs/isobusfs_cmn_cm.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(isobusfs PROPERTIES
|
set_target_properties(isobusfs PROPERTIES
|
||||||
PUBLIC_HEADER "${PUBLIC_HEADER_ISOBUSFS}"
|
PUBLIC_HEADER "${PUBLIC_HEADER_ISOBUSFS}"
|
||||||
SOVERSION 0
|
SOVERSION 0
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS isobusfs
|
install(TARGETS isobusfs
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
|
|
@ -158,10 +185,10 @@ if(NOT ANDROID)
|
||||||
isobusfs/isobusfs_cli_selftests.c
|
isobusfs/isobusfs_cli_selftests.c
|
||||||
isobusfs/isobusfs_cli_int.c
|
isobusfs/isobusfs_cli_int.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(isobusfs-cli
|
target_link_libraries(isobusfs-cli
|
||||||
PRIVATE isobusfs can j1939
|
PRIVATE isobusfs can j1939
|
||||||
)
|
)
|
||||||
|
install(TARGETS isobusfs-cli DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
|
||||||
add_executable(isobusfs-srv
|
add_executable(isobusfs-srv
|
||||||
isobusfs/isobusfs_srv.c
|
isobusfs/isobusfs_srv.c
|
||||||
|
|
@ -172,66 +199,55 @@ if(NOT ANDROID)
|
||||||
isobusfs/isobusfs_srv_fh.c
|
isobusfs/isobusfs_srv_fh.c
|
||||||
isobusfs/isobusfs_srv_vh.c
|
isobusfs/isobusfs_srv_vh.c
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(isobusfs-srv
|
target_link_libraries(isobusfs-srv
|
||||||
PRIVATE isobusfs can j1939
|
PRIVATE isobusfs can j1939
|
||||||
)
|
)
|
||||||
|
install(TARGETS isobusfs-srv DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
install(TARGETS
|
|
||||||
isobusfs-cli
|
|
||||||
isobusfs-srv
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
||||||
|
|
||||||
set(PUBLIC_HEADER_j1939_TIMEDATE
|
|
||||||
j1939_timedate/j1939_timedate_cmn.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(j1939-timedate-cli
|
|
||||||
j1939_timedate/j1939_timedate_cli.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(j1939-timedate-cli
|
|
||||||
PRIVATE can j1939
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(j1939-timedate-srv
|
|
||||||
j1939_timedate/j1939_timedate_srv.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(j1939-timedate-srv
|
|
||||||
PRIVATE can j1939
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS
|
|
||||||
j1939-timedate-cli
|
|
||||||
j1939-timedate-srv
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
||||||
|
|
||||||
if(ENABLE_GPS)
|
|
||||||
set(PUBLIC_HEADER_J1939_VEHICLE_POSITION
|
|
||||||
j1939_vehicle_position/j1939_vehicle_position_cmn.h
|
|
||||||
)
|
|
||||||
|
|
||||||
add_executable(j1939-vehicle-position-srv
|
|
||||||
j1939_vehicle_position/j1939_vehicle_position_srv.c
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(j1939-vehicle-position-srv
|
|
||||||
PRIVATE can j1939 ${GPS_LIBRARIES}
|
|
||||||
)
|
|
||||||
|
|
||||||
install(TARGETS
|
|
||||||
j1939-vehicle-position-srv
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(can STATIC
|
if(ENABLE_LOG_FILE)
|
||||||
|
list(APPEND PROGRAMS_CANLIB
|
||||||
|
asc2log
|
||||||
|
log2asc
|
||||||
|
log2long
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_SLCAN)
|
||||||
|
list(APPEND PROGRAMS
|
||||||
|
slcan_attach
|
||||||
|
slcand
|
||||||
|
)
|
||||||
|
list(APPEND PROGRAMS_CANLIB slcanpty)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_MCP251XFD)
|
||||||
|
add_executable(mcp251xfd-dump
|
||||||
|
mcp251xfd/mcp251xfd-dev-coredump.c
|
||||||
|
mcp251xfd/mcp251xfd-dump.c
|
||||||
|
mcp251xfd/mcp251xfd-main.c
|
||||||
|
mcp251xfd/mcp251xfd-regmap.c
|
||||||
|
)
|
||||||
|
install(TARGETS mcp251xfd-dump DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND PROGRAMS
|
||||||
|
${PROGRAMS_CANLIB}
|
||||||
|
${PROGRAMS_J1939}
|
||||||
|
)
|
||||||
|
|
||||||
|
add_library(can STATIC EXCLUDE_FROM_ALL
|
||||||
lib.c
|
lib.c
|
||||||
canframelen.c
|
canframelen.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_library(j1939 STATIC EXCLUDE_FROM_ALL
|
||||||
|
libj1939.c
|
||||||
|
)
|
||||||
|
target_link_libraries(j1939
|
||||||
|
PRIVATE can
|
||||||
|
)
|
||||||
|
|
||||||
foreach(name ${PROGRAMS})
|
foreach(name ${PROGRAMS})
|
||||||
add_executable(${name} ${name}.c)
|
add_executable(${name} ${name}.c)
|
||||||
|
|
||||||
|
|
@ -248,12 +264,6 @@ foreach(name ${PROGRAMS})
|
||||||
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
install(TARGETS
|
|
||||||
can-calc-bit-timing
|
|
||||||
mcp251xfd-dump
|
|
||||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(uninstall
|
add_custom_target(uninstall
|
||||||
"${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/make_uninstall.cmake"
|
"${CMAKE_COMMAND}" -P "${CMAKE_SOURCE_DIR}/cmake/make_uninstall.cmake"
|
||||||
COMMENT "Add uninstall target"
|
COMMENT "Add uninstall target"
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,10 @@ subsystem (aka SocketCAN):
|
||||||
Follow the link to see examples on how this tools can be used:
|
Follow the link to see examples on how this tools can be used:
|
||||||
[Kickstart guide to can-j1939 on linux](https://github.com/linux-can/can-utils/blob/master/can-j1939-kickstart.md)
|
[Kickstart guide to can-j1939 on linux](https://github.com/linux-can/can-utils/blob/master/can-j1939-kickstart.md)
|
||||||
|
|
||||||
|
#### ISOBus File server tools
|
||||||
|
* isobusfs-cli : ISOBus file client
|
||||||
|
* isobusfs-srv : ISOBus file server
|
||||||
|
|
||||||
#### Log file converters
|
#### Log file converters
|
||||||
* asc2log : convert ASC logfile to compact CAN frame logfile
|
* asc2log : convert ASC logfile to compact CAN frame logfile
|
||||||
* log2asc : convert compact CAN frame logfile to ASC logfile
|
* log2asc : convert compact CAN frame logfile to ASC logfile
|
||||||
|
|
|
||||||
|
|
@ -1121,6 +1121,11 @@ static const unsigned int common_data_bitrates[] = {
|
||||||
4000000,
|
4000000,
|
||||||
2000000,
|
2000000,
|
||||||
1000000,
|
1000000,
|
||||||
|
800000,
|
||||||
|
500000,
|
||||||
|
250000,
|
||||||
|
125000,
|
||||||
|
100000,
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@
|
||||||
#include <linux/can.h>
|
#include <linux/can.h>
|
||||||
#include <linux/can/isotp.h>
|
#include <linux/can/isotp.h>
|
||||||
#include <linux/sockios.h>
|
#include <linux/sockios.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#define NO_CAN_ID 0xFFFFFFFFU
|
#define NO_CAN_ID 0xFFFFFFFFU
|
||||||
|
|
||||||
|
|
@ -66,6 +67,8 @@
|
||||||
#define FORMAT_ASCII 2
|
#define FORMAT_ASCII 2
|
||||||
#define FORMAT_DEFAULT (FORMAT_ASCII | FORMAT_HEX)
|
#define FORMAT_DEFAULT (FORMAT_ASCII | FORMAT_HEX)
|
||||||
|
|
||||||
|
#define PDU_BUF_SIZE 4096
|
||||||
|
|
||||||
void print_usage(char *prg)
|
void print_usage(char *prg)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "\nUsage: %s [options] <CAN interface>\n", prg);
|
fprintf(stderr, "\nUsage: %s [options] <CAN interface>\n", prg);
|
||||||
|
|
@ -79,6 +82,7 @@ void print_usage(char *prg)
|
||||||
fprintf(stderr, " -f <format> (1 = HEX, 2 = ASCII, 3 = HEX & ASCII - default: %d)\n", FORMAT_DEFAULT);
|
fprintf(stderr, " -f <format> (1 = HEX, 2 = ASCII, 3 = HEX & ASCII - default: %d)\n", FORMAT_DEFAULT);
|
||||||
fprintf(stderr, " -L (set link layer options for CAN FD)\n");
|
fprintf(stderr, " -L (set link layer options for CAN FD)\n");
|
||||||
fprintf(stderr, " -h <len> (head: print only first <len> bytes)\n");
|
fprintf(stderr, " -h <len> (head: print only first <len> bytes)\n");
|
||||||
|
fprintf(stderr, " -i (ignore syscall errors to receive malformed PDUs)\n");
|
||||||
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
|
fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n");
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
@ -189,15 +193,16 @@ int main(int argc, char **argv)
|
||||||
int head = 0;
|
int head = 0;
|
||||||
int timestamp = 0;
|
int timestamp = 0;
|
||||||
int format = FORMAT_DEFAULT;
|
int format = FORMAT_DEFAULT;
|
||||||
|
int ignore_errors = 0;
|
||||||
canid_t src = NO_CAN_ID;
|
canid_t src = NO_CAN_ID;
|
||||||
canid_t dst = NO_CAN_ID;
|
canid_t dst = NO_CAN_ID;
|
||||||
extern int optind, opterr, optopt;
|
extern int optind, opterr, optopt;
|
||||||
static struct timeval tv, last_tv;
|
static struct timeval tv, last_tv;
|
||||||
|
|
||||||
unsigned char buffer[4096];
|
unsigned char buffer[PDU_BUF_SIZE];
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?")) != -1) {
|
while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?i")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 's':
|
case 's':
|
||||||
src = strtoul(optarg, NULL, 16);
|
src = strtoul(optarg, NULL, 16);
|
||||||
|
|
@ -249,6 +254,10 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
ignore_errors = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
print_usage(basename(argv[0]));
|
print_usage(basename(argv[0]));
|
||||||
goto out;
|
goto out;
|
||||||
|
|
@ -367,31 +376,37 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(s, &rdfs)) {
|
if (FD_ISSET(s, &rdfs)) {
|
||||||
nbytes = read(s, buffer, 4096);
|
nbytes = read(s, buffer, PDU_BUF_SIZE);
|
||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
perror("read socket s");
|
perror("read socket s");
|
||||||
r = 1;
|
r = 1;
|
||||||
|
if(!ignore_errors)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (nbytes > 4095) {
|
if (nbytes > (PDU_BUF_SIZE - 1)) {
|
||||||
r = 1;
|
r = 1;
|
||||||
|
fprintf(stderr, "PDU length %d longer than PDU buffer: %s\n", nbytes, strerror(errno));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if(nbytes > 0)
|
||||||
printbuf(buffer, nbytes, color?2:0, timestamp, format,
|
printbuf(buffer, nbytes, color?2:0, timestamp, format,
|
||||||
&tv, &last_tv, dst, s, if_name, head);
|
&tv, &last_tv, dst, s, if_name, head);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FD_ISSET(t, &rdfs)) {
|
if (FD_ISSET(t, &rdfs)) {
|
||||||
nbytes = read(t, buffer, 4096);
|
nbytes = read(t, buffer, PDU_BUF_SIZE);
|
||||||
if (nbytes < 0) {
|
if (nbytes < 0) {
|
||||||
perror("read socket t");
|
perror("read socket t");
|
||||||
r = 1;
|
r = 1;
|
||||||
|
if(!ignore_errors)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (nbytes > 4095) {
|
if (nbytes > (PDU_BUF_SIZE - 1)) {
|
||||||
r = 1;
|
r = 1;
|
||||||
|
fprintf(stderr, "PDU length %d longer than PDU buffer: %s\n", nbytes, strerror(errno));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
if(nbytes > 0)
|
||||||
printbuf(buffer, nbytes, color?1:0, timestamp, format,
|
printbuf(buffer, nbytes, color?1:0, timestamp, format,
|
||||||
&tv, &last_tv, src, t, if_name, head);
|
&tv, &last_tv, src, t, if_name, head);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue